fix(medications): keep recent doses in the trailing history window

The Verlauf ledger dropped doses the full history showed. Three windows
ended too early or started too late:

- The server clamped the window floor to the medication's creation
  instant and filtered recorded doses by the same floor, so a dose
  logged for earlier the same day on a medication added afterwards
  fell out of "Last 90 days". The creation floor now bounds minted
  slots only; recorded doses use the requested window.
- A dose taken inside its window before the slot's own time is stored
  on the slot anchor, which still lay past the window end. The read
  horizon now reaches the latest recorded anchor within a day, without
  minting later upcoming slots.
- The client pinned from/to at mount and reused them on every refetch,
  so a dose added after the tab opened stayed hidden until a reload.
  The window is now resolved when the request fires and only "from"
  travels; the query key carries the window length instead of instants.

Refs #1028
This commit is contained in:
Marc-André Bombeck committed 2026-09-24 07:22:06 +02:00
1 parent aa58495cbe
commit 01cd755de6
5 files changed
+301 -26

No files matched your search

+2 -2
View File
@@ -83,8 +83,8 @@ export const medicationKeys = {
* Übersicht headline % flip in the same paint, then reconciles on the
* authoritative refetch.
*/
medicationDoseHistory: (medicationId: string, from: string, to: string) =>
["medications", medicationId, "dose-history", from, to] as const,
medicationDoseHistory: (medicationId: string, windowDays: number) =>
["medications", medicationId, "dose-history", windowDays] as const,
medicationIntakeDrugLevelChart: (medicationId: string) =>
["medications", medicationId, "intake", "drug-level-chart"] as const,
/**