feat(mental-health): measure screener change against the meaningful-change threshold

The assessments list now carries, per PHQ-9, GAD-7 and WHO-5, the latest
total against the previous and the first administration, classified
against the change studies treat as meaningful: 5 points on the PHQ-9,
4 on the GAD-7, 10 on the WHO-5 percentage scale. A smaller change reads
as within the threshold rather than better or worse. The instrument
detail states each change and whether it reaches that size, in neutral
words. The read takes totals and dates only, never an answer.
This commit is contained in:
Marc-André Bombeck committed 2026-10-21 21:59:42 +02:00
1 parent 2ba6214a65
commit 5c64192afc
20 files changed
+659 -15

No files matched your search

+41 -1
View File
@@ -100,8 +100,48 @@ const createResponse = z
})
.meta({ id: "CreateMentalHealthAssessmentResponse" });
const scorePoint = z.object({
score: z.number(),
takenAt: z.string(),
});
const changeVerdict = z
.enum(["improved", "worsened", "within_threshold"])
.nullable();
const assessmentTrend = z
.object({
instrument: z.enum(["PHQ9", "GAD7", "WHO5"]),
n: z.number().int(),
threshold: z
.number()
.describe(
"Meaningful-change threshold in reported points: PHQ-9 5, GAD-7 4, WHO-5 10 (0–100 scale).",
),
higherIsBetter: z.boolean(),
first: scorePoint,
previous: scorePoint.nullable(),
latest: scorePoint,
changeFromPrevious: z.number().nullable(),
changeFromFirst: z.number().nullable(),
sincePrevious: changeVerdict,
sinceFirst: changeVerdict,
})
.meta({
id: "MentalHealthAssessmentTrend",
description:
"v1.44 — the latest total against the previous and the first administration, classified against the instrument's meaningful-change threshold in its own direction. A change below the threshold is `within_threshold`. Server-computed over the whole history, not the page.",
});
const listResponse = z
.object({ assessments: z.array(assessmentRow) })
.object({
assessments: z.array(assessmentRow),
trends: z
.array(assessmentTrend)
.optional()
.describe(
"v1.44 — one per PHQ-9 / GAD-7 / WHO-5 with at least one administration. Absent on older servers.",
),
})
.meta({ id: "ListMentalHealthAssessmentsResponse" });
const detailResponse = z