diff --git a/server/src/lib/analytes.ts b/server/src/lib/analytes.ts index 75f8b68..7aa262f 100644 --- a/server/src/lib/analytes.ts +++ b/server/src/lib/analytes.ts @@ -85,7 +85,7 @@ export const ANALYTES: Analyte[] = [ key: "dhea_s", display: "DHEA-S", canonicalUnit: "µmol/L", - molarMass: 384.5, + molarMass: 368.49, panel: "hormones", aliases: ["dhea-s", "dhea s", "dheas", "dehydroepiandrosterone sulfate"], }, @@ -347,7 +347,12 @@ export const ANALYTES: Analyte[] = [ canonicalUnit: "mmol/L", molarMass: 60.06, panel: "kidney", - aliases: ["urea", "bun", "blood urea nitrogen"], + // Deliberately no "bun"/"blood urea nitrogen" aliases: BUN mg/dL -> urea + // mmol/L needs the nitrogen divisor (2N = 28.01 g/mol), not urea's own + // molar mass (60.06). Mapping BUN here would silently under-convert by + // ~2.14x. BUN rows stay unmapped (raw value preserved) until a proper + // BUN analyte with its own divisor is added. + aliases: ["urea"], }, // --- cbc --- diff --git a/server/test/normalize.test.ts b/server/test/normalize.test.ts index 34589b4..ebf338c 100644 --- a/server/test/normalize.test.ts +++ b/server/test/normalize.test.ts @@ -52,4 +52,13 @@ describe("normalizeMarker", () => { expect(n.valueNum).toBeCloseTo(0.3); expect(n.value).toBe("<0.3"); }); + test("BUN is not mapped onto urea (needs N-divisor, not molar mass)", () => { + expect(resolveAnalyte("BUN")).toBeNull(); + expect(resolveAnalyte("blood urea nitrogen")).toBeNull(); + expect(resolveAnalyte("urea")?.key).toBe("urea"); + }); + test("DHEA-S µg/dL converts with corrected molar mass", () => { + const n = normalizeMarker({ name: "DHEA-S", value: "250", unit: "ug/dL" }); + expect(n.valueCanonical).toBeCloseTo(6.78, 1); // 250 * 0.02713 + }); });