From 153026ea85d62973d2ce869835d556e07a385d0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Thu, 4 Jun 2026 04:09:46 +0200 Subject: [PATCH] fix(clinician): localise measurement-type labels in the shared record view The clinician view rendered metric names through an English-only humaniser while the rest of the page was translated, leaving a mixed-language summary for non-English clinicians. Reuse the doctor-report type-label keys (already present in every locale) for the per-type label, falling back to the humaniser only for a type with no key. --- .../clinician/__tests__/clinician-view.test.tsx | 5 +++-- src/components/clinician/clinician-view.tsx | 15 +++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/components/clinician/__tests__/clinician-view.test.tsx b/src/components/clinician/__tests__/clinician-view.test.tsx index 2ac9a7ff3..34bbe9b2a 100644 --- a/src/components/clinician/__tests__/clinician-view.test.tsx +++ b/src/components/clinician/__tests__/clinician-view.test.tsx @@ -87,8 +87,9 @@ describe("", () => { it("renders clinical vitals from the scoped report", () => { const html = render(makeReport()); expect(html).toContain("Vital signs"); - // The measurement-type enum is humanised, not raw. - expect(html).toContain("Weight"); + // The measurement-type enum renders as its localised label, not the raw + // enum string. + expect(html).toContain("Body weight"); expect(html).not.toContain("WEIGHT"); }); diff --git a/src/components/clinician/clinician-view.tsx b/src/components/clinician/clinician-view.tsx index a2fcd5e47..217e07fc1 100644 --- a/src/components/clinician/clinician-view.tsx +++ b/src/components/clinician/clinician-view.tsx @@ -10,6 +10,7 @@ * a FENCED, muted wellness card carrying the load-bearing "descriptive, not a * clinical assessment / not a diagnosis" disclaimer. */ +import { DOCTOR_REPORT_TYPE_LABEL_KEYS } from "@/lib/doctor-report-pdf-core"; import type { DoctorReportData } from "@/lib/doctor-report-data"; import type { DoctorReportPrefs } from "@/lib/validations/doctor-report-prefs"; @@ -36,12 +37,14 @@ const WELLNESS_KEY: Record = { }; /** - * Humanise a measurement-type enum (`BLOOD_PRESSURE_SYS` → "Blood pressure - * sys") for a clinical label. The clinician view is locale-neutral on the raw - * metric name by design — the enum is the stable, language-independent anchor a - * clinician reads alongside the numbers; no per-type i18n bundle is maintained. + * Localised label for a measurement-type enum, reusing the doctor-report type + * key map so the clinician view reads in the viewer's locale alongside the rest + * of the page. A type with no key falls back to a humanised enum form + * (`BLOOD_PRESSURE_SYS` → "Blood pressure sys"). */ -function humaniseType(type: string): string { +function typeLabel(type: string, t: Translate): string { + const key = DOCTOR_REPORT_TYPE_LABEL_KEYS[type]; + if (key) return t(key); const lower = type.replace(/_/g, " ").toLowerCase(); return lower.charAt(0).toUpperCase() + lower.slice(1); } @@ -134,7 +137,7 @@ export function ClinicianView({ {measurementEntries.map(([type, s]) => (