feat: persist package amount metadata in backend (#356)

* feat: add package amount persistence and backend route support

* test: align backend test schemas with medication metadata fields

* fix(backend): restore intake usage normalizer for planner endpoint

* fix(backend): keep export typing compatible before liquid-unit stack step
This commit is contained in:
Daniel Volz
2026-02-28 23:21:13 +01:00
committed by GitHub
parent 2f2edfa479
commit 7accb2aad6
14 changed files with 2887 additions and 18 deletions
+16
View File
@@ -17,6 +17,22 @@ export type Intake = {
intakeRemindersEnabled: boolean;
};
/**
* Normalize intake usage for stock math.
*
* Stock semantics currently treat numeric usage as-is for all supported
* medication forms/package types. The helper centralizes this behavior so route
* logic can depend on a single validated numeric value.
*/
export function normalizeIntakeUsageForStock(
intake: Pick<Intake, "usage">,
_medicationForm?: string | null,
_packageType?: string | null
): number {
const usage = Number(intake.usage);
return Number.isFinite(usage) && usage > 0 ? usage : 0;
}
// =============================================================================
// Timezone utilities
// =============================================================================