From 350fd1b767bf4b156b04f23399fa482af6c5e1c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Wed, 14 Oct 2026 19:19:15 +0200 Subject: [PATCH] fix(labs): name calcifediol as the source of the vitamin D factor The note said the factor was taken from cholecalciferol (C27H44O2). Vitamin D3 is C27H44O; C27H44O2 is 25-hydroxyvitamin D3 (calcifediol), the form the assay reports and the one whose molar mass gives 1 ng/mL = 2.496 nmol/L. The factor was right; the note now says what it rests on. --- .../__tests__/registry.test.ts | 19 ++++++++++++++++++- src/lib/labs/unit-conversion/registry.ts | 7 ++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/lib/labs/unit-conversion/__tests__/registry.test.ts b/src/lib/labs/unit-conversion/__tests__/registry.test.ts index 724a7f8b4..21c9d3d33 100644 --- a/src/lib/labs/unit-conversion/__tests__/registry.test.ts +++ b/src/lib/labs/unit-conversion/__tests__/registry.test.ts @@ -28,7 +28,7 @@ const MOLAR_MASS: Record = { "uric-acid": 168.112, // C5H4N4O3 "calcium-total": 40.078, // Ca "bilirubin-total": 584.673, // C33H36N4O6 - "vitamin-d": 400.647, // C27H44O2 + "vitamin-d": 400.647, // C27H44O2, 25-hydroxyvitamin D3 (calcifediol) }; /** Of the entry's amount unit: how many of its mass unit one of it is, per g/mol. */ @@ -44,6 +44,23 @@ const POWER_OF_TEN: Record = { "vitamin-d": 1 / 1_000, // nmol/L -> ng/mL }; +describe("the vitamin D entry", () => { + const entry = analyteConversionFor("vitamin-d")!; + + it("names the molecule its factor comes from: calcifediol, not vitamin D3", () => { + // Cholecalciferol is C27H44O; the factor uses C27H44O2, which is the + // 25-hydroxy form a lab reports. The note must say which one it is. + expect(entry.source).toContain("calcifediol"); + expect(entry.source).toContain("C27H44O2"); + expect(entry.source).not.toMatch(/cholecalciferol \(C27H44O2\)/); + }); + + it("converts 1 ng/mL to 2.496 nmol/L", () => { + // ng/mL is the hub; nmol/L maps to it by 400.647 / 1000. + expect(1 / entry.units["nmol/L"].a).toBeCloseTo(2.496, 3); + }); +}); + describe("the registry's entries", () => { const entries = allAnalyteConversions(); diff --git a/src/lib/labs/unit-conversion/registry.ts b/src/lib/labs/unit-conversion/registry.ts index 2ec1e2ee1..37148c03c 100644 --- a/src/lib/labs/unit-conversion/registry.ts +++ b/src/lib/labs/unit-conversion/registry.ts @@ -187,7 +187,12 @@ const ENTRIES: readonly AnalyteConversion[] = [ formula: { C: 27, H: 44, O: 2 }, mass: "ng/mL", amount: "nmol/L", - note: "25-hydroxyvitamin D, taken as cholecalciferol (C27H44O2).", + // What a lab measures and reports is 25-hydroxyvitamin D (calcifediol), + // so its molar mass sets the factor: 1 ng/mL is 2.496 nmol/L. Vitamin D3 + // itself (cholecalciferol, C27H44O) is lighter by the one oxygen atom. + note: + "25-hydroxyvitamin D3 (calcifediol, C27H44O2), the form the assay reports; " + + "1 ng/mL = 2.496 nmol/L.", }), defineAnalyteConversion({ key: "hba1c",