Report data contract
The report builder resolves selected profile facts into one detached, JSON-serializable snapshot before HTML rendering or optional AI summarization.export-report-data.js owns this contract. PDF/print HTML and the practitioner overview consume it; neither is a source of truth for ranges, status, provenance, or section selection.
Use collectReportData(options) from export-report.js or the export.js facade for the active profile:
schemaVersion before depending on the shape. REPORT_DATA_SCHEMA_VERSION is currently 1.
Snapshot shape
The top-level record contains:schemaVersionandgeneratedAt;scope, including preset, selected date range, sections, categories, range mode, status basis, and display-unit profile;- minimized
profilemetadata; - selected
labs, including results, flags, trends, and collection context; - selected
notes,supplements,genetics, and context; and nullor empty values for report sections that were not selected.
Lab result contract
Every included marker result can carry:- collection date and draw-level context;
- source-file and collection-context provenance when recorded;
- the source report’s original range and unit when an import snapshot matches;
- numeric and formatted display values;
- marker-level and dated value notes;
- the range used for status, ranges displayed for the selected mode, and other available reference/optimal ranges; and
- resolved range label, kind, source, and
low,normal,high, orunratedstatus.
scope.rangeMode records the user’s display choice. scope.statusBasis makes the judging rule explicit. In Both mode, both reference and optimal ranges can be shown while optimal guidance judges status when available; reference is the fallback, and an eligible phase-specific reference range takes precedence.
A result is unrated when no applicable bound exists. Do not convert missing context or an intentionally suppressed range into normal.
Data-minimization boundary
Report sections are authorization and minimization inputs.buildReportDataSnapshot() includes labs only when a lab section was selected, includes notes/supplements/genetics/context only when their corresponding section was selected, and filters lab dates and categories before snapshot creation.
The optional practitioner overview calls formatReportDataForAgent() over this same selected snapshot. That projection is deliberately bounded and lossy: it prioritizes latest abnormalities, representative markers, notable trends, and a limited number of context sections. The full structured snapshot remains the lossless interface for a local integration that the user has authorized.
Do not let an HTML renderer or AI consumer re-read global application state. New consumers must receive the snapshot explicitly so the report builder’s selection remains the controlling boundary.
Owners and verification
Run
tests/report-data.test.js when the schema, range behavior, minimization, or agent projection changes. Run tests/report-export-html-runtime.test.js for renderer consumption and the directly related report-export Playwright cases for the builder/preview boundary.
The source implementation is in js/export-report-data.js.