fix(reminders): decide what stays due by the cycle, not the measurement type

The first cut kept only free-text check-ups due after their reminder
and let every reminder with a measurement type roll on. A fortnightly
PHQ-9 or GAD-7 reminder is a measurement reminder, and each one still
jumped two weeks forward the morning it was sent without the
questionnaire being filled.

The rule is now the cycle length. A reminder whose next slot is more
than seven days away, or that has no cadence, stays due after its
reminder until it is satisfied (a matching reading, a lab result or
"done"), skipped or snoozed, and is sent again at most once a week. A
reminder on a weekly or shorter cycle rolls on as before. Appointments
stay one-shot. A reading that lands on an open measurement reminder
still sets lastSatisfiedAt and schedules the next cycle from itself.

The 0355 repair drops its "no measurement type" condition for the same
cycle rule, so the fortnightly questionnaires in the reported shape
are put back on the day they were reminded.
This commit is contained in:
Marc-André Bombeck committed 2026-09-26 10:33:13 +02:00
1 parent 4d4a527c0d
commit fb960fb72e
7 files changed
+296 -82

No files matched your search

+5 -4
View File
@@ -5483,10 +5483,11 @@ model MeasurementReminder {
skipCount Int @default(0) @map("skip_count")
/// v1.39.2 — when a reminder for this row last reached at least one channel.
/// Written by the reminder tick after a delivered dispatch, read by the same
/// tick. A check-up (no `measurementType`, not an appointment) no longer
/// rolls `nextDueAt` forward when it is reminded: it stays due until it is
/// done, skipped or snoozed, and this cursor is what keeps the repeat to at
/// most once a week. A nudge counts as "already sent for this slot" only
/// tick. A reminder on a cycle longer than a week, or a one-shot (never an
/// appointment), no longer rolls `nextDueAt` forward when it is reminded:
/// it stays due until it is satisfied (a reading, a lab result or "done"),
/// skipped or snoozed, and this cursor keeps the repeat to at most once a
/// week. A nudge counts as "already sent for this slot" only
/// while `lastNotifiedAt >= nextDueAt`, so a snooze, a skip or a satisfy
/// (each of which moves `nextDueAt`) opens a fresh slot that fires on its
/// own day. Operational state, deliberately not in the backup: a restored