From d0b7749a99e40bfcb71c7cf5d4bbe9cf3d7c4315 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sat, 14 Nov 2026 09:35:35 +0100 Subject: [PATCH] fix(medications): keep the request schemas out of the wizard bundle The note field imported its length limit from the validation module, which pulled zod and the medication request schemas into the client and put the medications list and detail pages over their bundle budget. The limit lives in a zod-free module now, and the validation re-exports it. --- .../medications/wizard/steps/step8-note-field.tsx | 2 +- src/lib/medications/note-limits.ts | 8 ++++++++ src/lib/validations/medication/base.ts | 9 ++------- 3 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 src/lib/medications/note-limits.ts diff --git a/src/components/medications/wizard/steps/step8-note-field.tsx b/src/components/medications/wizard/steps/step8-note-field.tsx index 4f80a0f23..45bd52929 100644 --- a/src/components/medications/wizard/steps/step8-note-field.tsx +++ b/src/components/medications/wizard/steps/step8-note-field.tsx @@ -3,7 +3,7 @@ import { Label } from "@/components/ui/label"; import { Textarea } from "@/components/ui/textarea"; import { useTranslations } from "@/lib/i18n/context"; -import { MEDICATION_NOTE_MAX_CHARS } from "@/lib/validations/medication/base"; +import { MEDICATION_NOTE_MAX_CHARS } from "@/lib/medications/note-limits"; import type { StepProps } from "./step1-name"; diff --git a/src/lib/medications/note-limits.ts b/src/lib/medications/note-limits.ts new file mode 100644 index 000000000..89219cde7 --- /dev/null +++ b/src/lib/medications/note-limits.ts @@ -0,0 +1,8 @@ +/** + * #1371 — the longest note a medication carries. Room for a full set of + * directions ("on an empty stomach, 30 to 60 minutes before breakfast, not + * within four hours of calcium or iron") with space to spare. Its own module, + * free of zod, so the editor can cap its input without pulling the request + * schemas into the page bundle. + */ +export const MEDICATION_NOTE_MAX_CHARS = 500; diff --git a/src/lib/validations/medication/base.ts b/src/lib/validations/medication/base.ts index 656ab51d8..76ccf59b1 100644 --- a/src/lib/validations/medication/base.ts +++ b/src/lib/validations/medication/base.ts @@ -4,6 +4,7 @@ import { INJECTION_SITE_KEYS } from "@/lib/medications/injection-sites"; import { validateEntryInstant } from "@/lib/validations/entry-instant"; import { hhmmToMinutes } from "@/lib/medications/scheduling/hhmm"; import { isoDateTime } from "@/lib/validations/datetime"; +import { MEDICATION_NOTE_MAX_CHARS } from "@/lib/medications/note-limits"; /** * v1.8.5 — the eight injection-site enum values, mirrored from the @@ -63,13 +64,7 @@ export const rxNormCodeField = z .describe( "Optional RxNorm RxCUI (numeric, US identifier, e.g. `2601723`). Secondary coding emitted under `http://www.nlm.nih.gov/research/umls/rxnorm` alongside any ATC code, never instead of the free-text name. NULL clears it; absent leaves it untouched.", ); -/** - * #1371 — the longest note a medication carries. Room for a full set of - * directions ("on an empty stomach, 30 to 60 minutes before breakfast, not - * within four hours of calcium or iron") with space to spare; the editor caps - * its input at the same length. - */ -export const MEDICATION_NOTE_MAX_CHARS = 500; +export { MEDICATION_NOTE_MAX_CHARS }; /** * #1371 — the person's own note on a medication. Trimmed; an empty string or * NULL clears it, absent leaves it untouched. Sealed at rest by the writer.