Files
HealthLog/src/lib/report-selection/template.ts
T
Marc-André Bombeck 310a9a4690 feat(doctor-report): put emergency data on page one
Add an EMERGENCY leaf to the identity group of the report catalogue,
default-on, no module gate. When the leaf is admitted and the profile
holds emergency data, the aggregator collects it and the PDF renders an
emergency sheet as page one (banner, blood type, severe allergies, active
medications, chronic conditions, implants, advance directive and organ
donor, contacts, notes), then breaks to send the rest of the report to
page two. The section is withheld when the leaf is not admitted or no
data is present. Guards updated for the new leaf counts.
2026-08-10 05:32:59 +02:00

65 lines
2.4 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 { SENSITIVE_LEAF_IDS, 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));
}
/** Exported so the purity guard reads the same set the panel does. */
export const SENSITIVE_LEAVES = SENSITIVE_LEAF_IDS;