fix(illness): escalate sustained fever and low SpO2 on write

A sustained fever (three calendar-consecutive days at or above the fever
red-flag floor) or sustained low SpO2 was already classified "seek care",
but the only escalation path ran inside a GET on the episode correlation
route — no push fired unless the user opened that tab, and no cron drove
it. The proactive on-write safety check covered only blood pressure and
glucose; the two signals with the strongest safety case had the weakest
delivery.

Add sustained-run temperature and SpO2 checks to the on-write
`runSafetyFloorCheck`, wired from both measurement-ingest seams. The run
length and clinical floors are shared with the retrospective detector (no
duplicated thresholds), day bucketing honours the user's timezone, and
escalation reuses the existing red-flag notification with its push-attempt
dedup so a febrile user logging repeatedly is alerted at most once per
reason per day.
This commit is contained in:
Marc-André Bombeck committed 2026-06-28 03:28:11 +02:00
1 parent 3405bb6fd3
commit 9e6a58b186
4 files changed
+530 -2

No files matched your search

+2
View File
@@ -802,6 +802,7 @@ async function postMeasurement(request: NextRequest) {
symptomsPresent: parsed.data.measurements.some(
(m) => m.symptomsPresent === true,
),
timezone: user.timezone ?? undefined,
}).catch(() => {});
// v1.5.0 — refresh the persistent rollup table for every distinct
@@ -948,6 +949,7 @@ async function postMeasurement(request: NextRequest) {
},
],
symptomsPresent,
timezone: user.timezone ?? undefined,
}).catch(() => {});
// v1.5.0 — refresh the persistent rollup row for the affected