fix(mental-health): gate screener-score export on the opt-in module

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.
This commit is contained in:
Marc-André Bombeck committed 2026-06-28 18:25:43 +02:00
1 parent 5f0ca355f9
commit 12579466c0
1 file changed
+10
+10
View File
@@ -1515,6 +1515,16 @@ const MEASUREMENT_TYPE_MODULE: Record<string, ModuleKey> = {
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<T>(