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.