diff --git a/src/components/clinician/__tests__/clinician-view.test.tsx b/src/components/clinician/__tests__/clinician-view.test.tsx index 91f475b2c..e04ee32b3 100644 --- a/src/components/clinician/__tests__/clinician-view.test.tsx +++ b/src/components/clinician/__tests__/clinician-view.test.tsx @@ -156,6 +156,37 @@ describe("", () => { expect(html).not.toContain("Current smoker"); }); + it("names both windows when a lab's report and the saved band disagree", () => { + // Two windows that disagree about the same number, and a card showing one + // of them is a partial answer. The PDF settles this with a footnote under + // the table; inline, both fit on the line. + const html = render( + makeReport({ + labResults: [ + { + panel: null, + analyte: "Potassium", + value: 5.2, + valueText: null, + unit: "mmol/L", + referenceLow: 3.9, + referenceHigh: 5.4, + catalogReferenceLow: 3.5, + catalogReferenceHigh: 5, + sourceReferenceText: null, + referenceOrigin: "source", + referenceDivergesFromCatalog: true, + takenAt: "2026-01-20T09:00:00.000Z", + count: 1, + }, + ], + }), + ); + expect(html).toContain("Potassium"); + expect(html).toContain("Reference 3.9–5.4"); + expect(html).toContain("saved range 3.5–5"); + }); + it("renders the fenced wellness card with the descriptive disclaimer", () => { const html = render(makeReport()); expect(html).toContain("Wellness scores"); diff --git a/src/components/clinician/history-sections.tsx b/src/components/clinician/history-sections.tsx index ec3963162..d26545b5d 100644 --- a/src/components/clinician/history-sections.tsx +++ b/src/components/clinician/history-sections.tsx @@ -69,6 +69,10 @@ export function LabResultsSection({ const reading = qualitative ? lab.valueText : `${fmtNum(lab.value as number)} ${lab.unit}`.trim(); + const range = (low: number | null, high: number | null) => + formatReferenceRange(low, high, (value) => String(fmtNum(value)), { + emptyText: "", + }); // The window the reading was judged against, printed as the source // report printed it when that is where it came from, so a clinician // comparing against the original reads the same characters. @@ -76,12 +80,15 @@ export function LabResultsSection({ ? null : lab.referenceOrigin === "source" && lab.sourceReferenceText ? lab.sourceReferenceText - : formatReferenceRange( - lab.referenceLow, - lab.referenceHigh, - (value) => String(fmtNum(value)), - { emptyText: "" }, - ); + : range(lab.referenceLow, lab.referenceHigh); + // When the report's own window and the saved band disagree about the + // same number, both are named. Showing one of two disagreeing windows + // is a partial answer, and the PDF's footnote says so; here it fits on + // the line rather than under a table. + const catalog = + !qualitative && lab.referenceDivergesFromCatalog + ? range(lab.catalogReferenceLow, lab.catalogReferenceHigh) + : ""; return (