diff --git a/docs/api/openapi.yaml b/docs/api/openapi.yaml index f8df7b97e..18a01132b 100644 --- a/docs/api/openapi.yaml +++ b/docs/api/openapi.yaml @@ -23985,6 +23985,7 @@ components: - SLEEP_AID - DIABETES - ANTIBIOTIC + - MENTAL_HEALTH - OTHER treatmentClass: type: string @@ -24321,6 +24322,7 @@ components: - SLEEP_AID - DIABETES - ANTIBIOTIC + - MENTAL_HEALTH - OTHER treatmentClass: type: string @@ -44086,6 +44088,7 @@ components: - SLEEP_AID - DIABETES - ANTIBIOTIC + - MENTAL_HEALTH - OTHER description: Clinical taxonomy stored in the `medication_categories` side-table. Orthogonal to `MedicationTreatmentClass`. CreateMedicationResponse: diff --git a/messages/de.json b/messages/de.json index aea0a1d7e..2e1336d21 100644 --- a/messages/de.json +++ b/messages/de.json @@ -1212,6 +1212,7 @@ "categorySleepAid": "Schlafmittel", "categoryDiabetes": "Diabetes", "categoryAntibiotic": "Antibiotikum", + "categoryMentalHealth": "Psychische Gesundheit", "categoryOther": "Sonstiges", "daysSun": "So", "daysMon": "Mo", @@ -1567,6 +1568,7 @@ "vitamin": "Vitamine", "supplement": "Nahrungsergänzung", "antibiotic": "Antibiotikum", + "mentalHealth": "Psychische Gesundheit", "other": "Sonstiges" }, "cadence": { diff --git a/messages/en.json b/messages/en.json index b645c80d4..73afdad3a 100644 --- a/messages/en.json +++ b/messages/en.json @@ -1212,6 +1212,7 @@ "categorySleepAid": "Sleep Aid", "categoryDiabetes": "Diabetes", "categoryAntibiotic": "Antibiotic", + "categoryMentalHealth": "Mental health", "categoryOther": "Other", "daysSun": "Sun", "daysMon": "Mon", @@ -1567,6 +1568,7 @@ "vitamin": "Vitamins", "supplement": "Supplement", "antibiotic": "Antibiotic", + "mentalHealth": "Mental health", "other": "Other" }, "cadence": { diff --git a/messages/es.json b/messages/es.json index 8afcaa88f..40b1d7b68 100644 --- a/messages/es.json +++ b/messages/es.json @@ -1212,6 +1212,7 @@ "categorySleepAid": "Para dormir", "categoryDiabetes": "Diabetes", "categoryAntibiotic": "Antibiótico", + "categoryMentalHealth": "Salud mental", "categoryOther": "Otros", "daysSun": "Do", "daysMon": "Lu", @@ -1567,6 +1568,7 @@ "vitamin": "Vitaminas", "supplement": "Suplemento", "antibiotic": "Antibiótico", + "mentalHealth": "Salud mental", "other": "Otro" }, "cadence": { diff --git a/messages/fr.json b/messages/fr.json index e0dfd01a5..7b02455d8 100644 --- a/messages/fr.json +++ b/messages/fr.json @@ -1212,6 +1212,7 @@ "categorySleepAid": "Aide au sommeil", "categoryDiabetes": "Diabetes", "categoryAntibiotic": "Antibiotique", + "categoryMentalHealth": "Santé mentale", "categoryOther": "Autres", "daysSun": "Dim", "daysMon": "Lun", @@ -1567,6 +1568,7 @@ "vitamin": "Vitamines", "supplement": "Complément", "antibiotic": "Antibiotique", + "mentalHealth": "Santé mentale", "other": "Autre" }, "cadence": { diff --git a/messages/it.json b/messages/it.json index 9a5a5d262..073f20c90 100644 --- a/messages/it.json +++ b/messages/it.json @@ -1212,6 +1212,7 @@ "categorySleepAid": "Per dormire", "categoryDiabetes": "Diabetes", "categoryAntibiotic": "Antibiotico", + "categoryMentalHealth": "Salute mentale", "categoryOther": "Altro", "daysSun": "Dom", "daysMon": "Lun", @@ -1567,6 +1568,7 @@ "vitamin": "Vitamine", "supplement": "Integratore", "antibiotic": "Antibiotico", + "mentalHealth": "Salute mentale", "other": "Altro" }, "cadence": { diff --git a/messages/ko.json b/messages/ko.json index c9d156ea8..4f08433c1 100644 --- a/messages/ko.json +++ b/messages/ko.json @@ -1212,6 +1212,7 @@ "categorySleepAid": "수면 보조", "categoryDiabetes": "당뇨", "categoryAntibiotic": "항생제", + "categoryMentalHealth": "정신 건강", "categoryOther": "기타", "daysSun": "일", "daysMon": "월", @@ -1567,6 +1568,7 @@ "vitamin": "비타민", "supplement": "보충제", "antibiotic": "항생제", + "mentalHealth": "정신 건강", "other": "기타" }, "cadence": { diff --git a/messages/pl.json b/messages/pl.json index e0be302f3..568350511 100644 --- a/messages/pl.json +++ b/messages/pl.json @@ -1212,6 +1212,7 @@ "categorySleepAid": "Na sen", "categoryDiabetes": "Diabetes", "categoryAntibiotic": "Antybiotyk", + "categoryMentalHealth": "Zdrowie psychiczne", "categoryOther": "Inne", "daysSun": "Nd", "daysMon": "Pn", @@ -1567,6 +1568,7 @@ "vitamin": "Witaminy", "supplement": "Suplement", "antibiotic": "Antybiotyk", + "mentalHealth": "Zdrowie psychiczne", "other": "Inne" }, "cadence": { diff --git a/src/app/api/medications/__tests__/route.test.ts b/src/app/api/medications/__tests__/route.test.ts index 66d575baa..888ef60c7 100644 --- a/src/app/api/medications/__tests__/route.test.ts +++ b/src/app/api/medications/__tests__/route.test.ts @@ -364,6 +364,18 @@ describe("POST /api/medications — v1.5.4 clinical category extension", () => { expect(res.status).toBe(201); }); + it("accepts MENTAL_HEALTH as a valid clinical category (v1.39.4, #1041)", async () => { + const res = await POST( + postReq({ + name: "Sertraline", + dose: "50 mg", + category: "MENTAL_HEALTH", + schedules: [{ windowStart: "08:00", windowEnd: "09:00" }], + }), + ); + expect(res.status).toBe(201); + }); + it("still 422s on an unknown category string", async () => { const res = await POST( postReq({ diff --git a/src/components/medications/wizard/__tests__/wizard-payload.test.ts b/src/components/medications/wizard/__tests__/wizard-payload.test.ts index dd7411e25..34c956e6b 100644 --- a/src/components/medications/wizard/__tests__/wizard-payload.test.ts +++ b/src/components/medications/wizard/__tests__/wizard-payload.test.ts @@ -310,6 +310,13 @@ describe("WIZARD_TREATMENT_MAPPING — Step 2 row → request body", () => { }); }); + it("maps Psychische Gesundheit → (GENERIC, MENTAL_HEALTH) — new in v1.39.4", () => { + expect(WIZARD_TREATMENT_MAPPING.mentalHealth).toEqual({ + treatmentClass: "GENERIC", + category: "MENTAL_HEALTH", + }); + }); + it("maps GLP-1-Injektion → (GLP1, OTHER) — only row with GLP1", () => { expect(WIZARD_TREATMENT_MAPPING.glp1).toEqual({ treatmentClass: "GLP1", @@ -327,6 +334,7 @@ describe("WIZARD_TREATMENT_MAPPING — Step 2 row → request body", () => { "vitamin", "supplement", "antibiotic", + "mentalHealth", "other", ]; for (const row of rows) { @@ -347,6 +355,7 @@ describe("rowFromTreatment — reverse mapping for edit-hydration", () => { it("ANTIBIOTIC category maps to the antibiotic row", () => { expect(rowFromTreatment("GENERIC", "ANTIBIOTIC")).toBe("antibiotic"); + expect(rowFromTreatment("GENERIC", "MENTAL_HEALTH")).toBe("mentalHealth"); }); it("unknown category falls back to 'other'", () => { diff --git a/src/components/medications/wizard/steps/step2-class.tsx b/src/components/medications/wizard/steps/step2-class.tsx index 9ff663e84..10cdea478 100644 --- a/src/components/medications/wizard/steps/step2-class.tsx +++ b/src/components/medications/wizard/steps/step2-class.tsx @@ -3,6 +3,7 @@ import { Activity, Apple, + Brain, Droplet, Flame, Leaf, @@ -35,6 +36,7 @@ const ROW_ICONS: Record> = { vitamin: Apple, supplement: Leaf, antibiotic: ShieldCheck, + mentalHealth: Brain, other: Tag as unknown as LucideIcon, }; diff --git a/src/components/medications/wizard/wizard-payload.ts b/src/components/medications/wizard/wizard-payload.ts index 5941ed063..506c32d9a 100644 --- a/src/components/medications/wizard/wizard-payload.ts +++ b/src/components/medications/wizard/wizard-payload.ts @@ -86,12 +86,13 @@ export type WizardTreatmentRow = | "vitamin" | "supplement" | "antibiotic" + | "mentalHealth" | "other"; /** - * The ten taxonomy rows in their visible order. maintainer-confirmed (D-1 - * §3 Step 2): Blutdruck · Diabetes · Hormone · GLP-1-Injektion · - * Schmerz · Allergie · Vitamine · Nahrungsergänzung · Antibiotikum · + * The taxonomy rows in their visible order (D-1 §3 Step 2): Blutdruck · + * Diabetes · Hormone · GLP-1-Injektion · Schmerz · Allergie · Vitamine · + * Nahrungsergänzung · Antibiotikum · Psychische Gesundheit (v1.39.4) · * Sonstiges. */ export const WIZARD_TREATMENT_ROWS: readonly WizardTreatmentRow[] = [ @@ -104,6 +105,7 @@ export const WIZARD_TREATMENT_ROWS: readonly WizardTreatmentRow[] = [ "vitamin", "supplement", "antibiotic", + "mentalHealth", "other", ]; @@ -128,6 +130,7 @@ export const WIZARD_TREATMENT_MAPPING: Record< vitamin: { treatmentClass: "GENERIC", category: "VITAMIN" }, supplement: { treatmentClass: "GENERIC", category: "SUPPLEMENT" }, antibiotic: { treatmentClass: "GENERIC", category: "ANTIBIOTIC" }, + mentalHealth: { treatmentClass: "GENERIC", category: "MENTAL_HEALTH" }, other: { treatmentClass: "GENERIC", category: "OTHER" }, }; @@ -159,6 +162,8 @@ export function rowFromTreatment( return "supplement"; case "ANTIBIOTIC": return "antibiotic"; + case "MENTAL_HEALTH": + return "mentalHealth"; default: return "other"; } diff --git a/src/lib/medications/category-label.ts b/src/lib/medications/category-label.ts index fb51009cb..087a2f188 100644 --- a/src/lib/medications/category-label.ts +++ b/src/lib/medications/category-label.ts @@ -34,6 +34,7 @@ const MEDICATION_CATEGORY_KEYS: Record = { SLEEP_AID: "medications.categorySleepAid", DIABETES: "medications.categoryDiabetes", ANTIBIOTIC: "medications.categoryAntibiotic", + MENTAL_HEALTH: "medications.categoryMentalHealth", OTHER: "medications.categoryOther", }; diff --git a/src/lib/validations/medication/base.ts b/src/lib/validations/medication/base.ts index 9f37e13f1..fdd1ff527 100644 --- a/src/lib/validations/medication/base.ts +++ b/src/lib/validations/medication/base.ts @@ -68,7 +68,9 @@ export const rxNormCodeField = z * wizard's Step 2 taxonomy can write a first-class bucket for those * two rows instead of collapsing them into `OTHER`. The column is a * plain TEXT field — no Prisma enum exists to migrate; the Zod values - * list is the only enforcement layer. + * list is the only enforcement layer. v1.39.4 adds `MENTAL_HEALTH` + * (antidepressants, anxiolytics, mood stabilisers, ADHD medication), again + * without a migration. */ export const MEDICATION_CATEGORY_VALUES = [ "BLOOD_PRESSURE", @@ -83,6 +85,7 @@ export const MEDICATION_CATEGORY_VALUES = [ "SLEEP_AID", "DIABETES", "ANTIBIOTIC", + "MENTAL_HEALTH", "OTHER", ] as const; export type MedicationCategoryValue =