fix(report): release the medication effect only with the medication list

The effect block names every medication it describes and its
confounders, so a report or share link that withheld the medication
list still carried the names. The aggregator now loads the block only
when both leaves are admitted, the clinician view checks the list leaf
as well, and the leaf label says it needs the list.
This commit is contained in:
Marc-André Bombeck committed 2026-10-21 23:31:58 +02:00
1 parent 733b00ee1a
commit cfe5e2d3c6
13 files changed
+95 -12

No files matched your search

@@ -163,6 +163,53 @@ describe("<ClinicianView>", () => {
expect(html).not.toContain("Current smoker");
});
it("shows the medication effect only beside the medication list", () => {
const report = makeReport({
medicationEffects: [
{
medicationName: "Named effect drug",
startsOn: "2026-01-05",
targets: [
{
type: "BLOOD_PRESSURE_SYS",
effect: {
present: false,
reason: "insufficient_after",
level: 0.95,
window: null,
days: {
before: 40,
after: 3,
excludedLowAdherence: 0,
excludedNotTaking: 0,
},
adherence: {
status: "tracked",
floorPct: 80,
lookbackDays: 14,
},
levelChange: null,
slopeChangePerWeek: null,
preSlopePerWeek: null,
fit: null,
confounders: [],
},
},
],
},
],
});
const leaves = ["MEDICATION_EFFECT", "BLOOD_PRESSURE_SYS"] as const;
expect(
render(report, {
selection: selectionFromLeaves([...leaves, "MEDICATION_LIST"]),
}),
).toContain("Named effect drug");
expect(
render(report, { selection: selectionFromLeaves([...leaves]) }),
).not.toContain("Named effect drug");
});
it("names both windows when a lab's report and the saved band disagree", () => {
// Two windows that disagree about the same number, and a card showing one
// of them is a partial answer. The PDF settles this with a footnote under
@@ -113,7 +113,11 @@ export function MedicationEffectSection({
/** A stated calendar day (YYYY-MM-DD) in the owner's date order. */
fmtDay: (day: string) => string;
}) {
const effects = report.medicationEffects ?? [];
// The block names medications: without the list leaf it shows nothing,
// whatever the payload carries.
const effects = scope.admits("MEDICATION_LIST")
? (report.medicationEffects ?? [])
: [];
const glucoseUnit = resolveGlucoseUnit(report.glucoseUnit ?? null);
return (
<LeafSection