Files
HealthLog/src
Marc-André Bombeck 10e658f66d fix(medications): project daily-schedule intakes for today's window
Schedule-expansion never minted today's intake rows for medications
with `daysOfWeek: null` until the reminder worker entered the RED
phase at the end of the dose window. The database stores `null` to
mean "every day" (the `MedicationSchedule.daysOfWeek` column carries
that annotation in `prisma/schema.prisma`), so daily meds spent the
whole morning with zero scheduled rows. Endpoint
`/api/medications/intake?scope=today` returned `[]` even when two
active daily meds existed; iOS Dashboard tile + Erfassen sheet both
fell to "Heute nichts geplant" / "Keine offene Einnahme" end-to-end.

Adds `expandTodayIntakes` to `src/lib/medication-schedule.ts` — a
pure projection that re-uses the existing `parseScheduleRecurrence`
(empty array == every day) and respects explicit weekday filters
when present. The `scope=today` route projects active schedules
through the helper, then idempotently backfills any missing rows
into `MedicationIntakeEvent` so the iOS POST update path keeps the
existing intakeId contract.

Tests:
  - `medication-schedule.test.ts` gains eight cases covering
    `daysOfWeek: null`, `""`, `"0,1,2,3,4,5,6"`, explicit-weekday
    excludes-today / includes-today, the operator's Ramipril +
    Metformin fixture, DST-correct `scheduledFor` anchoring at
    `windowStart` in Europe/Berlin, and multi-week cadence skip.
  - `intake/route.test.ts` gains two cases: backfill mints the
    missing row + does-not-double-mint when the row already exists.

Full vitest suite stays green (4672 passed / 1 skipped).
2026-05-21 10:59:25 +02:00
..
2026-05-16 19:46:43 +02:00
2026-05-16 03:17:00 +02:00