fix(labs): remove BUN aliases from urea, correct DHEA-S molar mass

This commit is contained in:
marcuspaico
2026-08-17 15:28:13 -07:00
parent ae7ec9d699
commit e0bb888115
2 changed files with 16 additions and 2 deletions

View File

@@ -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 ---

View File

@@ -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
});
});