mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-12 14:16:12 +00:00
The hypertensive-crisis floors were defined in three modules with a divergent diastolic value: the notification engine and the Coach acute clause used 180/120, but the dashboard hero used 180/110. A reading like 170/112 lit the red critical-BP banner on the hero yet never tripped the notification alarm or matched the Coach's stated acute number — one surface said crisis, the other two stayed calm on the same row. Promote the absolute floors into a dependency-free clinical-floors leaf and have the hero, the safety-floor engine, the status registry's fever band, and the illness escalation all import from it. The crisis diastolic floor is the guideline-correct 120 (ACC/AHA hypertensive urgency); the wider 110 hero net is dropped so the surfaces tell one story. A coverage test pins that every consumer resolves the same constants.
70 lines
2.5 KiB
TypeScript
70 lines
2.5 KiB
TypeScript
/**
|
|
* D3-H1 coverage — the clinical safety floors are ONE source of truth.
|
|
*
|
|
* Before v1.21.0 the "is this BP a crisis?" floors lived in three modules with
|
|
* a divergent diastolic value (notification engine + Coach 180/120, dashboard
|
|
* hero 180/110), so a 170/112 reading lit the hero banner yet never tripped the
|
|
* alarm. This suite pins that every consumer now resolves the SAME canonical
|
|
* constants from `@/lib/clinical-floors`, so the three surfaces can never drift
|
|
* apart again without a test failure.
|
|
*/
|
|
import { describe, it, expect } from "vitest";
|
|
|
|
import {
|
|
BP_SYS_CRITICAL,
|
|
BP_DIA_CRITICAL,
|
|
BP_SYS_HYPOTENSIVE_FLOOR,
|
|
GLUCOSE_HYPO_FLOOR,
|
|
GLUCOSE_HYPO_SEVERE_FLOOR,
|
|
GLUCOSE_HYPER_FLOOR,
|
|
FEVER_BAND_C,
|
|
FEVER_RED_FLAG_C,
|
|
SPO2_RED_FLAG_PCT,
|
|
} from "@/lib/clinical-floors";
|
|
import {
|
|
BP_SYS_HYPERTENSIVE,
|
|
BP_DIA_HYPERTENSIVE,
|
|
BP_SYS_HYPOTENSIVE,
|
|
GLUCOSE_HYPO,
|
|
GLUCOSE_HYPO_SEVERE,
|
|
GLUCOSE_HYPER,
|
|
} from "@/lib/illness/safety-floors";
|
|
import { getMetricStatusMeta } from "@/lib/insights/metric-status-registry";
|
|
|
|
describe("clinical-floors — single source of truth", () => {
|
|
it("uses the guideline-correct hypertensive-crisis floors (180/120)", () => {
|
|
// ACC/AHA hypertensive-urgency floor: the diastolic floor is 120, NOT the
|
|
// former hero-only 110 that fired the banner on calmer readings.
|
|
expect(BP_SYS_CRITICAL).toBe(180);
|
|
expect(BP_DIA_CRITICAL).toBe(120);
|
|
});
|
|
|
|
it("safety-floors notification engine re-exports the canonical constants", () => {
|
|
expect(BP_SYS_HYPERTENSIVE).toBe(BP_SYS_CRITICAL);
|
|
expect(BP_DIA_HYPERTENSIVE).toBe(BP_DIA_CRITICAL);
|
|
expect(BP_SYS_HYPOTENSIVE).toBe(BP_SYS_HYPOTENSIVE_FLOOR);
|
|
expect(GLUCOSE_HYPO).toBe(GLUCOSE_HYPO_FLOOR);
|
|
expect(GLUCOSE_HYPO_SEVERE).toBe(GLUCOSE_HYPO_SEVERE_FLOOR);
|
|
expect(GLUCOSE_HYPER).toBe(GLUCOSE_HYPER_FLOOR);
|
|
});
|
|
|
|
it("the status registry's fever band binds to the canonical FEVER_BAND_C", () => {
|
|
expect(getMetricStatusMeta("BODY_TEMPERATURE")?.feverBandC).toBe(
|
|
FEVER_BAND_C,
|
|
);
|
|
});
|
|
|
|
it("the single-reading fever band sits below the sustained-fever escalation", () => {
|
|
// Two intentional lines for two questions — but both from one module, so
|
|
// they are visibly a pair (D3-L1), not unrelated magic numbers.
|
|
expect(FEVER_BAND_C).toBeLessThan(FEVER_RED_FLAG_C);
|
|
});
|
|
|
|
it("keeps the documented glucose + SpO2 floors stable", () => {
|
|
expect(GLUCOSE_HYPO_FLOOR).toBe(70);
|
|
expect(GLUCOSE_HYPO_SEVERE_FLOOR).toBe(54);
|
|
expect(GLUCOSE_HYPER_FLOOR).toBe(250);
|
|
expect(SPO2_RED_FLAG_PCT).toBe(92);
|
|
});
|
|
});
|