mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 23:33:29 +00:00
feat(medications): fractional dosing via decimal units per dose (#316)
A dose can now consume a fraction of a unit — a half, third or quarter tablet for a split pill. The wizard offers a curated fraction set beside the whole numbers (the most error-resistant input); units-per-dose and the per-container counts widen from Int to Decimal, so a 30-tablet pack dosed at a half reads 29.5 after one dose and the days-left projection follows. The consumption ledger stamps and refunds the exact fraction, and existing whole-number doses are untouched. OpenAPI regenerated — the three unit fields move from integer to number — and the units-per-dose hint is updated across the six locales. Also anchors a first-use date relative to now in an inventory route test that had aged past its 30-day in-use window.
This commit is contained in:
1 parent
5ce3e81972
commit
f4dec8c28f
30 files changed
+510
-136
No files matched your search
@@ -149,9 +149,8 @@ export const medicationResource = z
|
||||
),
|
||||
unitsPerDose: z
|
||||
.number()
|
||||
.int()
|
||||
.describe(
|
||||
"v1.16.10 — inventory units one dose consumes (e.g. 2 tablets of 2 mg for a 4 mg dose). Default 1. The intake consumption hook decrements this many units per taken dose; dose-derived readouts divide unit counts by it.",
|
||||
"v1.16.10 — inventory units one dose consumes (e.g. 2 tablets of 2 mg for a 4 mg dose). v1.16.12 — may be a split-pill fraction (¼ / ⅓ / ½ / ⅔ / ¾); thirds carry as ≈0.3333 / 0.6667. Default 1. The intake consumption hook decrements this many units per taken dose; dose-derived readouts divide unit counts by it.",
|
||||
),
|
||||
active: z.boolean(),
|
||||
notificationsEnabled: z.boolean(),
|
||||
@@ -250,7 +249,7 @@ const medicationListEntry = medicationResource
|
||||
.int()
|
||||
.nullable()
|
||||
.describe(
|
||||
"v1.16.10 — dose-derived stock: `floor(stockUnitsRemaining / max(1, unitsPerDose))`. NULL when inventory tracking is off. Drives the table view's Bestand column. Read-only — aggregated, not stored.",
|
||||
"v1.16.10 — dose-derived stock: `floor(stockUnitsRemaining / unitsPerDose)`, where `unitsPerDose` may be a fraction (½ tablet ⇒ twice the doses). Stays a whole-dose count. NULL when inventory tracking is off. Drives the table view's Bestand column. Read-only — aggregated, not stored.",
|
||||
),
|
||||
})
|
||||
.meta({
|
||||
@@ -290,15 +289,13 @@ const medicationInventoryItemResource = z
|
||||
),
|
||||
unitsTotal: z
|
||||
.number()
|
||||
.int()
|
||||
.describe(
|
||||
"Units the container shipped with (tablets / ampoules / puffs; 1–1000). Dose-derived readouts divide by the medication's `unitsPerDose`.",
|
||||
"Units the container shipped with (tablets / ampoules / puffs; 1–1000). v1.16.12 — fractional, so a split-pill remainder reads cleanly. Dose-derived readouts divide by the medication's `unitsPerDose`.",
|
||||
),
|
||||
unitsRemaining: z
|
||||
.number()
|
||||
.int()
|
||||
.describe(
|
||||
"Units left in the container. Decremented by the intake consumption hook (FEFO with spillover across containers); refunded when a taken dose is skipped, edited away, or deleted.",
|
||||
"Units left in the container. v1.16.12 — fractional (a ½-tablet dose leaves 29.5 of 30). Decremented by the intake consumption hook (FEFO with spillover across containers); refunded when a taken dose is skipped, edited away, or deleted.",
|
||||
),
|
||||
firstUseAt: z.iso
|
||||
.datetime({ offset: true })
|
||||
|
||||
Reference in new issue
Block a user