From 12579466c08eec483bf94e952acdbcbe1146ec49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sun, 28 Jun 2026 18:25:43 +0200 Subject: [PATCH] fix(mental-health): gate screener-score export on the opt-in module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The PHQ-9/GAD-7 totals flowed into the doctor-report / FHIR export unconditionally while the AI/MCP surfaces were correctly fenced off. Map the two `*_SCORE` measurement types to the mental-health module so the totals export only once the account opts the module in (default OFF โ€” privacy by default), consistent with how mood/sleep/glucose gate. Item-level answers are never a measurement, so they can never leak through this path. --- src/lib/doctor-report-data.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lib/doctor-report-data.ts b/src/lib/doctor-report-data.ts index d2783626d..112084178 100644 --- a/src/lib/doctor-report-data.ts +++ b/src/lib/doctor-report-data.ts @@ -1515,6 +1515,16 @@ const MEASUREMENT_TYPE_MODULE: Record = { RECOVERY_SCORE: "recovery", STRESS_SCORE: "recovery", BLOOD_GLUCOSE: "glucose", + // v1.25.0 โ€” the PHQ-9 / GAD-7 screener TOTALS ride the doctor-report / FHIR + // export only when the opt-in mental-health module is on (default OFF โ†’ + // excluded by default, privacy-by-default). Item-level answers are never a + // Measurement, so they can never leak through this path regardless. The total + // is the intended clinical artefact (total + band per clinical-instruments.md + // ยง4); gating it on the module keeps the export consistent with how mood / + // sleep / glucose are gated and avoids exporting a screener the account never + // opted into. + PHQ9_SCORE: "mentalHealth", + GAD7_SCORE: "mentalHealth", }; function filterMeasurementKeys(