mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 21:10:59 +00:00
feat(medications): add per-schedule units-per-dose column
Add a nullable units_per_dose to medication_schedules so a split-dose plan can consume a different unit count at different times of day (a whole tablet in the morning, a half at noon) on ONE medication instead of two. NULL inherits the medication-level units_per_dose, so every existing row keeps its current behaviour. Migration 0332 adds one nullable Decimal(10,4) column with no backfill.
This commit is contained in:
1 parent
9a74bfb629
commit
0e34f9edda
2 files changed
+16
No files matched your search
@@ -0,0 +1,6 @@
|
||||
-- #219 — per-schedule inventory units consumed per dose.
|
||||
-- Additive, nullable, no backfill: every existing schedule row reads NULL and
|
||||
-- the consume hook keeps inheriting the medication-level `units_per_dose`, so
|
||||
-- behaviour is unchanged until a user sets a per-slot value. Same
|
||||
-- Decimal(10,4) grain as `medications.units_per_dose`.
|
||||
ALTER TABLE "medication_schedules" ADD COLUMN "units_per_dose" DECIMAL(10,4);
|
||||
@@ -2738,6 +2738,16 @@ model MedicationSchedule {
|
||||
windowEnd String @map("window_end") // HH:mm format, e.g. "10:00"
|
||||
label String? // e.g. "Morning", "Evening"
|
||||
dose String? // Per-schedule dose override; null = use Medication.dose
|
||||
/// v1.37.10 (#219) — per-schedule inventory units consumed per dose. The
|
||||
/// intake consumption hook counts UNITS (tablets, ampoules, puffs); a
|
||||
/// split-dose plan takes a different unit count at different times of day
|
||||
/// (a whole tablet in the morning, a half at noon). NULL inherits the
|
||||
/// medication-level `Medication.unitsPerDose`, so every existing row keeps
|
||||
/// its current behaviour. Same Decimal(10,4) grain + curated fraction /
|
||||
/// whole-number posture as the medication-level column; the consume hook
|
||||
/// matches a taken intake's slot to its schedule by wall-clock time and
|
||||
/// reads this first, falling back to the medication level on NULL.
|
||||
unitsPerDose Decimal? @map("units_per_dose") @db.Decimal(10, 4)
|
||||
/// Legacy string encoding of the cadence ("null | 1,3,5 | i2;1,3,5").
|
||||
/// v1.5 writes go to `rrule` / `rollingIntervalDays` and v1.5.1 flipped
|
||||
/// the readers to consult the new fields first.
|
||||
|
||||
Reference in new issue
Block a user