Files
HealthLog/src/lib/insights/ecg-classification.ts
T
Marc-André Bombeck 08d3cd2c31 Split the ECG cap and one provenance entry off their label maps
The /insights overview crept a kilobyte over its ceiling: the ECG
teaser imported its overview cap from the classification module, which
dragged that module's label map and helpers into the eager page, and
the Health Score card pulled the whole metric-provenance map for its
one citation. The cap now lives in a value-only module and the single
provenance entry is split out, so the overview imports the bare number
and citation it renders. Both routes are back under budget. The
aggregate ceiling rises to hold the six-locale copy the new encounter,
mood-context, mood-prognosis and practitioner surfaces added, which the
whole-build sum counts independently and no single route downloads.
2026-08-08 17:56:40 +02:00

37 lines
1.4 KiB
TypeScript

/**
* The recording device's own rhythm verdict, and the two things every ECG
* surface needs to say about it.
*
* The list, the detail page and the cross-link card all render this value and
* all three used to carry their own copy of the label map. It is one map now,
* so a fourth surface cannot introduce a fifth wording.
*
* HealthLog produces NO verdict of its own — no measured intervals, no
* beat/P/QRS/T annotation, no risk score. Everything here is the device's
* result, passed through.
*/
export type EcgClassification =
"IRREGULAR" | "NOT_DETECTED" | "INCONCLUSIVE" | null;
/** i18n key per device verdict, under `insights.ecg.result.*`. */
export const ECG_RESULT_LABEL_KEYS: Record<string, string> = {
IRREGULAR: "insights.ecg.result.irregular",
NOT_DETECTED: "insights.ecg.result.notDetected",
INCONCLUSIVE: "insights.ecg.result.inconclusive",
};
/** Resolve the device verdict to its localised label, or null when unset. */
export function ecgResultLabel(
classification: EcgClassification,
t: (key: string) => string,
): string | null {
if (!classification) return null;
const key = ECG_RESULT_LABEL_KEYS[classification];
return key ? t(key) : null;
}
/** A non-normal device result carries the "discuss with a clinician" note. */
export function isNonNormalEcg(classification: EcgClassification): boolean {
return classification === "IRREGULAR" || classification === "INCONCLUSIVE";
}