Files
HealthLog/src/lib/report-selection/template.ts
T
Marc-André Bombeck fb344c4f78 Remove two dead alias constants
SENSITIVE_LEAVES and COACH_SUGGESTED_ACTION_TYPES each aliased a
constant defined elsewhere and were never imported. Neither is a
re-export the way the barrel lines were — the definition itself is the
dead thing, and both doc comments describe a consumer that does not
exist: the purity guard reads SENSITIVE_LEAF_IDS from ./catalogue
directly, and nothing mirrors the suggested-action allowlist.

The imports that fed them go with them.
2026-08-23 19:11:12 +02:00

62 lines
2.2 KiB
TypeScript

/**
* The one shipped template: what a general doctor's visit usually needs.
*
* Nothing applies it on its own. It reaches a selection only when a person
* presses the button that carries its name, on a panel they are looking at —
* never on load, never on a stored selection, never on a share link, never on
* a surface that cannot ask a human. A set that arrives without being asked
* for is a preselection whatever it is called, and the one thing this release
* refuses is material in a report nobody ticked.
*
* The template intersects the fenced tier at zero leaves, and
* `catalogue-guard.test.ts` fails the build if that stops being true.
*/
import { type ReportLeafId } from "./catalogue";
/**
* Identity and insurer (the cover page a practice files the document under),
* the three classic vitals, weight and BMI, the glucose series and its panel,
* labs, the drug list and adherence, allergies and past illness episodes.
*
* Deliberately not in it: everything a wearable produces, gait and mobility,
* environment exposure, the per-dose administration ledger (a clinician asks
* for adherence, not for every logged dose), the GLP-1 block, and the whole
* fenced tier.
*/
export const STANDARD_TEMPLATE_LEAVES: readonly ReportLeafId[] = [
"PATIENT_IDENTITY",
"EMERGENCY",
"INSURANCE",
"BLOOD_PRESSURE_SYS",
"BLOOD_PRESSURE_DIA",
"PULSE",
"WEIGHT",
"BODY_MASS_INDEX",
"BLOOD_GLUCOSE",
"GLUCOSE_PANEL",
"LAB_RESULTS",
"MEDICATION_LIST",
"MEDICATION_COMPLIANCE",
"ALLERGIES",
"ILLNESS_EPISODES",
"IMMUNIZATIONS",
];
/** The template's i18n label — it is named on the button, never anonymous. */
export const STANDARD_TEMPLATE_LABEL_KEY = "reportSelection.templateStandard";
/**
* The template as one surface can offer it: the shipped set minus the leaves
* that surface may not carry (the share-link form hides the insurance leaf,
* which the server refuses anyway).
*
* Pure, so "one click applies exactly the standard set and nothing outside it"
* is provable without a DOM.
*/
export function standardTemplateFor(
hiddenLeaves: readonly ReportLeafId[] = [],
): ReportLeafId[] {
const hidden = new Set(hiddenLeaves);
return STANDARD_TEMPLATE_LEAVES.filter((leaf) => !hidden.has(leaf));
}