mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-07 04:12:04 +00:00
feat(meds): extend MedicationCategory with diabetes and antibiotic
Adds DIABETES and ANTIBIOTIC to MEDICATION_CATEGORY_VALUES so the upcoming modal wizard's Step 2 taxonomy can write the two rows as first-class clinical categories instead of falling back to OTHER. The clinical category column on medication_categories is plain TEXT backed by Zod for validation; no Prisma enum exists to ALTER, so the migration is documentation-only and the category-label drift-guard gets the matching keys. Both new values feed back into the rendered badges on the medication card. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
47c8f52001
commit
a868bd1cf2
3 files changed
+37
No files matched your search
@@ -0,0 +1,24 @@
|
||||
-- v1.5.4 — Clinical category bucket additions.
|
||||
--
|
||||
-- The medication's clinical category lives in a side-table
|
||||
-- (`medication_categories`) with a TEXT column rather than a Prisma
|
||||
-- enum, so adding a new bucket does not require an ALTER TYPE. The
|
||||
-- migration is documentation-only — the new "DIABETES" and
|
||||
-- "ANTIBIOTIC" values are enforced at the Zod layer
|
||||
-- (`MEDICATION_CATEGORY_VALUES` in src/lib/validations/medication.ts)
|
||||
-- and the side-table's `normalizeCategory` helper accepts them on
|
||||
-- the same path as the pre-existing buckets.
|
||||
--
|
||||
-- The modal-wizard's Step 2 taxonomy adds Diabetes and Antibiotikum
|
||||
-- as first-class rows. The mapping table (see
|
||||
-- src/components/medications/wizard/wizard-payload.ts —
|
||||
-- WIZARD_TREATMENT_MAPPING) writes "DIABETES" and "ANTIBIOTIC" to
|
||||
-- the side-table for those rows instead of collapsing them into
|
||||
-- "OTHER".
|
||||
--
|
||||
-- No SQL changes are needed — the index on `category` already covers
|
||||
-- the new values, and existing rows retain their previous bucket.
|
||||
|
||||
-- Force a non-empty migration body so prisma records the new step
|
||||
-- in the `_prisma_migrations` ledger.
|
||||
SELECT 1 WHERE FALSE;
|
||||
@@ -29,6 +29,8 @@ const MEDICATION_CATEGORY_KEYS: Record<string, string> = {
|
||||
HORMONE: "medications.categoryHormone",
|
||||
SKIN: "medications.categorySkin",
|
||||
SLEEP_AID: "medications.categorySleepAid",
|
||||
DIABETES: "medications.categoryDiabetes",
|
||||
ANTIBIOTIC: "medications.categoryAntibiotic",
|
||||
OTHER: "medications.categoryOther",
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
import { z } from "zod/v4";
|
||||
|
||||
const timeRegex = /^([01]\d|2[0-3]):([0-5]\d)$/;
|
||||
/**
|
||||
* Clinical-category values stored in the `medication_categories` side-
|
||||
* table (TEXT column). v1.5.4 adds `DIABETES` and `ANTIBIOTIC` so the
|
||||
* 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.
|
||||
*/
|
||||
export const MEDICATION_CATEGORY_VALUES = [
|
||||
"BLOOD_PRESSURE",
|
||||
"VITAMIN",
|
||||
@@ -12,8 +20,11 @@ export const MEDICATION_CATEGORY_VALUES = [
|
||||
"HORMONE",
|
||||
"SKIN",
|
||||
"SLEEP_AID",
|
||||
"DIABETES",
|
||||
"ANTIBIOTIC",
|
||||
"OTHER",
|
||||
] as const;
|
||||
export type MedicationCategoryValue = (typeof MEDICATION_CATEGORY_VALUES)[number];
|
||||
|
||||
/**
|
||||
* v1.4.25 W4d — Prisma-level treatment class. Orthogonal to
|
||||
|
||||
Reference in new issue
Block a user