fix(medications): count forgotten doses as missed, not skipped

A never-acted dose past its 24h cutoff was flipped to skipped=true by the
hourly cron. The compliance engine excludes skipped doses from the
denominator (a deliberate user pause), so a forgotten dose then counted
neither as taken nor missed — silently inflating adherence.

Add a dedicated auto_missed terminal state. The cron now sets auto_missed
(not skipped) on a never-acted pending row, so the engine counts it as a
real miss against the rate, while a user-initiated skip stays excluded.
The two are mutually exclusive on a live row by construction.
This commit is contained in:
Marc-André Bombeck committed 2026-06-07 13:26:41 +02:00
1 parent 384fc9caa1
commit 29fa982e11
4 files changed
+97 -42

No files matched your search

@@ -0,0 +1,13 @@
-- v1.15.9 — terminal "auto-missed" state for forgotten medication doses.
--
-- The hourly auto-miss cron previously flipped a never-acted pending dose to
-- `skipped = true`. Because the compliance engine excludes skipped doses from
-- the denominator (a deliberate user pause), a forgotten dose then neither
-- counted as taken nor as missed — silently inflating adherence.
--
-- This column lets the engine tell the two apart: a user-initiated skip stays
-- `skipped = true` (excluded), while a forgotten dose past its miss cutoff is
-- marked `auto_missed = true` and counts as a MISS against the rate. Every
-- legacy row defaults to false.
ALTER TABLE "medication_intake_events"
ADD COLUMN "auto_missed" BOOLEAN NOT NULL DEFAULT false;