From fd1464867d039b528db3fb00a85322f2b56dec5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sun, 26 Jul 2026 10:34:38 +0200 Subject: [PATCH] fix(medications): separate the two container dates and name the ampoule caveat The row printed the opening date and the printed expiry with nothing between them. It carries the same middle dot the unit figures use. The docblock now says out loud what the enum cannot distinguish: AMPOULE covers both a punctured multi-dose vial, where the post-opening window is real, and a carton of single-use glass ampoules, where it is not. The kind is never auto-selected, so picking it is a statement about an opened container, and the opening date is editable when it turns out not to be. --- .../__tests__/inventory-section-dates.test.tsx | 16 ++++++++++++++++ .../medications/sections/inventory-section.tsx | 1 + src/lib/medications/inventory/state-machine.ts | 7 ++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/components/medications/__tests__/inventory-section-dates.test.tsx b/src/components/medications/__tests__/inventory-section-dates.test.tsx index b52cbcff2..a35c71485 100644 --- a/src/components/medications/__tests__/inventory-section-dates.test.tsx +++ b/src/components/medications/__tests__/inventory-section-dates.test.tsx @@ -124,6 +124,22 @@ describe(" — item-row dates", () => { expect(html).toContain("Haltbar bis 01.06.2027"); }); + it("separates the two dates when the row carries both", () => { + seedItems([ + { + ...BASE, + firstUseAt: "2026-06-12T00:00:00.000Z", + printedExpiry: "2027-06-01T00:00:00.000Z", + }, + ]); + const html = render( + , + ); + expect(html).toContain("Geöffnet 12.06.2026"); + expect(html).toContain("Haltbar bis 01.06.2027"); + expect(html).toContain("·"); + }); + it("shows no date line when neither date is recorded", () => { // Absence reads as absence — no placeholder, no invented date. seedItems([{ ...BASE, firstUseAt: null, printedExpiry: null }]); diff --git a/src/components/medications/sections/inventory-section.tsx b/src/components/medications/sections/inventory-section.tsx index aac3bba24..6473f207f 100644 --- a/src/components/medications/sections/inventory-section.tsx +++ b/src/components/medications/sections/inventory-section.tsx @@ -505,6 +505,7 @@ export function InventorySection({ })} )} + {item.firstUseAt && item.printedExpiry && ·} {item.printedExpiry && ( {t("medications.detail.bestand.expiresOn", { diff --git a/src/lib/medications/inventory/state-machine.ts b/src/lib/medications/inventory/state-machine.ts index ed6fd92f5..10b49884c 100644 --- a/src/lib/medications/inventory/state-machine.ts +++ b/src/lib/medications/inventory/state-machine.ts @@ -37,7 +37,12 @@ * - AMPOULE — the member a punctured injectable reservoir (ampoule or * multi-dose vial) lands on; there is no separate VIAL member. Same * physical fact as the pen: the barrier is broken and the contents - * are exposed. + * are exposed. The enum cannot tell that reservoir apart from a + * carton of single-use glass ampoules, where the clock would be + * wrong for the same reason it was wrong on a blister; the kind is + * never auto-selected, so choosing it is a deliberate statement + * about a container that was opened, and the opening date is + * editable when it turns out not to be. * - BLISTER — every tablet sits in its own sealed foil cavity. * Pressing out tablet 1 does nothing to tablets 2..n. The carton * expiry is the only expiry.