mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-18 08:02:12 +00:00
feat(illness): Rest Mode — annotate score/recovery/streaks during an active episode + FHIR/doctor-report
An active illness/condition episode annotates, it never penalises: the measured number is untouched, only the narrative changes. - rest-mode.ts: one server-authoritative resolver (module-gated, fail-soft) for "is the account in Rest Mode + which episodes back it". iOS mirrors the resolved context, never recomputes the suppression. - health-score: /api/analytics attaches a value-free Rest Mode annotation; computeHealthScore stays pure (score never adjusted). - recovery-score: computeRecoveryScore carries the Rest Mode context as of the scored day; the persisted blend is unchanged. - coach-nudge: pause cadence-nudges during an active episode (new skippedDuringIllness counter, gate sits before the trigger search). - achievements: bridgeFrozenStreakGaps freezes (does not break) every day-streak across illness days; never invents a streak, a non-illness gap still breaks. - coincident-deviation: reframe a fired flag as illness-explained; vital numbers untouched. Surfaced as a neutral line on the insights card. - coach snapshot: illness history + active illness as load-bearing context so the coach knows about Rest Mode (no decrypted note reaches the prompt). - FHIR: illness episodes map to Condition (generic disease root, label on code.text, patient-reported/unconfirmed) + a bounding Encounter. - doctor-report: module-gated illness section in the aggregator + PDF table (retrospective, neutral palette); FHIR Condition section in the bundle. i18n x6 for the report + reframe copy. Tests: score-annotation-not- penalisation, streak-freeze, coach-nudge pause, FHIR Condition/Encounter mapping, doctor-report inclusion, Rest Mode resolver. typecheck/lint/test green, openapi in sync, knip clean.
This commit is contained in:
1 parent
8447ad90cc
commit
c59cf0b652
37 files changed
+1352
-24
No files matched your search
@@ -488,3 +488,62 @@ describe("doctor-report clinical glucose panel", () => {
|
||||
expect(text).not.toContain("Glucose overview (clinical)");
|
||||
});
|
||||
});
|
||||
|
||||
// v1.18.1 P4 — illness / condition episodes section. Retrospective + factual:
|
||||
// label, type, course, onset, resolved. Present only when the aggregator
|
||||
// populated `illnessEpisodes` (module on + episode in window).
|
||||
describe("doctor-report illness section", () => {
|
||||
it("prints the conditions table with label, type, and dates", async () => {
|
||||
const data = makeData({
|
||||
illnessEpisodes: [
|
||||
{
|
||||
label: "Erkältung",
|
||||
type: "INFECTION",
|
||||
lifecycle: "ACUTE",
|
||||
onsetAt: "2026-04-01T00:00:00.000Z",
|
||||
resolvedAt: "2026-04-10T00:00:00.000Z",
|
||||
},
|
||||
],
|
||||
});
|
||||
const bytes = renderDoctorReportPdfBytes(data, {
|
||||
t: getServerTranslator("en").t,
|
||||
locale: "en",
|
||||
now: FIXED_NOW,
|
||||
});
|
||||
const text = await extractText(bytes);
|
||||
expect(text).toContain("Conditions & illnesses");
|
||||
expect(text).toContain("Erkältung");
|
||||
});
|
||||
|
||||
it("marks an ongoing (unresolved) episode rather than a blank cell", async () => {
|
||||
const data = makeData({
|
||||
illnessEpisodes: [
|
||||
{
|
||||
label: "Heuschnupfen",
|
||||
type: "ALLERGY",
|
||||
lifecycle: "RECURRING",
|
||||
onsetAt: "2026-04-01T00:00:00.000Z",
|
||||
resolvedAt: null,
|
||||
},
|
||||
],
|
||||
});
|
||||
const bytes = renderDoctorReportPdfBytes(data, {
|
||||
t: getServerTranslator("en").t,
|
||||
locale: "en",
|
||||
now: FIXED_NOW,
|
||||
});
|
||||
const text = await extractText(bytes);
|
||||
expect(text).toContain("Heuschnupfen");
|
||||
expect(text).toContain("Ongoing");
|
||||
});
|
||||
|
||||
it("omits the section entirely when there are no episodes", async () => {
|
||||
const bytes = renderDoctorReportPdfBytes(makeData(), {
|
||||
t: getServerTranslator("en").t,
|
||||
locale: "en",
|
||||
now: FIXED_NOW,
|
||||
});
|
||||
const text = await extractText(bytes);
|
||||
expect(text).not.toContain("Conditions & illnesses");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user