mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-13 06:32:03 +00:00
fix(visits): cap the window before a visit at the longest report
The window before a booked visit started at the last matching visit however far back it lay, while the health-report export covers 730 days and fell back to its 90-day default for anything longer. The card then offered a report the export did not build. The window now stops at the export's limit, read from one shared constant, and preparation.capped says when it did; the web says "The last two years" for it. The export clamps an over-long explicit range to the last 730 days before its end instead of falling back to 90 days, so a custom range or a linked window cannot shrink silently either, and its day count forgives the hour a clock change adds, so two years of local days count as 730.
This commit is contained in:
1 parent
f39598f2e7
commit
da3d29424d
22 files changed
+282
-32
No files matched your search
@@ -197,6 +197,7 @@ describe("<VisitsSection> since the last visit", () => {
|
||||
to: "2026-12-01",
|
||||
basis: "practitioner",
|
||||
since: sameDoctor,
|
||||
capped: false,
|
||||
},
|
||||
});
|
||||
const unprepared = visit({ ...next, preparation: null });
|
||||
@@ -346,6 +347,7 @@ describe("<VisitsSection> since the last visit", () => {
|
||||
to: "2026-12-01",
|
||||
basis: "default",
|
||||
since: null,
|
||||
capped: false,
|
||||
},
|
||||
}),
|
||||
],
|
||||
|
||||
@@ -22,7 +22,10 @@ type Translate = (
|
||||
export interface PreparationText {
|
||||
/** Where the window starts: "Since your last visit with … on …". */
|
||||
title: string;
|
||||
/** Why, when the title alone does not say: only on the default window. */
|
||||
/**
|
||||
* Why, when the title alone does not say: on the default window, and on a
|
||||
* window capped at the longest report.
|
||||
*/
|
||||
reason: string | null;
|
||||
}
|
||||
|
||||
@@ -33,6 +36,14 @@ export function preparationText(
|
||||
): PreparationText {
|
||||
const date = formatDay(preparation.from);
|
||||
const since = preparation.since;
|
||||
// The matched visit is further back than a report covers: the window is
|
||||
// the last two years, and the title must not promise everything since.
|
||||
if (preparation.capped) {
|
||||
return {
|
||||
title: t("encounters.preparation.capped"),
|
||||
reason: t("encounters.preparation.cappedReason"),
|
||||
};
|
||||
}
|
||||
switch (preparation.basis) {
|
||||
case "practitioner":
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user