feat(report): name the analysed window of each medication effect

The effect is fitted on up to 90 days before a start and 180 after
it, which can lie outside the report period. The PDF notes and the
clinician view now state the fitted window for every effect shown.
This commit is contained in:
Marc-André Bombeck committed 2026-10-21 23:37:09 +02:00
1 parent cfe5e2d3c6
commit bb6982aea2
12 files changed
+84 -12

No files matched your search

@@ -200,6 +200,43 @@ describe("<ClinicianView>", () => {
],
});
const leaves = ["MEDICATION_EFFECT", "BLOOD_PRESSURE_SYS"] as const;
const est = {
estimate: -5,
ciLow: -7,
ciHigh: -3,
standardError: 1,
includesZero: false,
};
const fitted = makeReport({
medicationEffects: [
{
...report.medicationEffects![0],
targets: [
{
type: "BLOOD_PRESSURE_SYS",
effect: {
...report.medicationEffects![0].targets[0].effect,
present: true,
reason: undefined,
levelChange: est,
slopeChangePerWeek: est,
preSlopePerWeek: est,
window: {
from: "2025-10-07",
to: "2026-01-20",
endReason: "today",
},
},
},
],
},
],
});
expect(
render(fitted, {
selection: selectionFromLeaves([...leaves, "MEDICATION_LIST"]),
}),
).toContain("This window can reach beyond the report period.");
expect(
render(report, {
selection: selectionFromLeaves([...leaves, "MEDICATION_LIST"]),
@@ -163,6 +163,14 @@ export function MedicationEffectSection({
unit,
})}
</p>
{e.window ? (
<p className="text-muted-foreground text-xs">
{t("doctorReport.medicationEffect.windowLine", {
from: fmtDay(e.window.from),
to: fmtDay(e.window.to),
})}
</p>
) : null}
<p className="text-muted-foreground text-xs">
{t("doctorReport.medicationEffect.days", {
before: e.days.before,