diff --git a/src/lib/fhir/resources/observation.ts b/src/lib/fhir/resources/observation.ts index 07176a653..45a8bc4a8 100644 --- a/src/lib/fhir/resources/observation.ts +++ b/src/lib/fhir/resources/observation.ts @@ -177,8 +177,13 @@ function adherenceObservations( for (const [name, comp] of Object.entries(data.compliance)) { if (comp.total <= 0) continue; // Integer percent — the one canonical rounding the app card + PDF use, so - // a clinician sees the same adherence figure on every surface. - const rate = adherenceRatePercent(comp.taken, comp.total) ?? 0; + // a clinician sees the same adherence figure on every surface. The helper + // returns null exactly when nothing was expected, and a `?? 0` here would + // put a clinical claim of 0 % adherence into an exported bundle in that + // case. The `total <= 0` guard above already means it cannot happen; skip + // rather than coalesce so it stays impossible if that guard ever moves. + const rate = adherenceRatePercent(comp.taken, comp.total); + if (rate === null) continue; observations.push({ resourceType: "Observation", id: nextId(),