Files
medassist-ng/backend/src/utils/package-profiles.ts
T
Daniel Volz c5c75f65e4 feat: add inhaler and injection package types
Closes #558

- add inhaler and injection as supported medication package types
- align refill, planner, dashboard, report, export, and notification wording for the new discrete package types
- include the validated CI repair for formatting and dashboard label parity
2026-05-11 21:29:59 +02:00

44 lines
1.7 KiB
TypeScript

export const PACKAGE_TYPES = ["blister", "bottle", "tube", "liquid_container", "inhaler", "injection"] as const;
export type PackageType = (typeof PACKAGE_TYPES)[number];
const PACKAGE_TYPE_SET = new Set<string>(PACKAGE_TYPES);
export function normalizePackageType(packageType?: string | null): PackageType {
if (packageType && PACKAGE_TYPE_SET.has(packageType)) {
return packageType as PackageType;
}
return "blister";
}
export function isTubePackageType(packageType?: string | null): boolean {
return normalizePackageType(packageType) === "tube";
}
export function isLiquidContainerPackageType(packageType?: string | null): boolean {
return normalizePackageType(packageType) === "liquid_container";
}
export function isPackageAmountPackageType(packageType?: string | null): boolean {
const normalized = normalizePackageType(packageType);
return normalized === "tube" || normalized === "liquid_container";
}
export function isDiscreteCountPackageType(packageType?: string | null): boolean {
const normalized = normalizePackageType(packageType);
return normalized === "bottle" || normalized === "inhaler" || normalized === "injection";
}
export function isAmountBasedPackageType(packageType?: string | null): boolean {
return isPackageAmountPackageType(packageType) || isDiscreteCountPackageType(packageType);
}
export function getPlannerUnitKind(packageType?: string | null): "pills" | "ml" | "units" | "puffs" | "injections" {
const normalized = normalizePackageType(packageType);
if (normalized === "tube") return "units";
if (normalized === "liquid_container") return "ml";
if (normalized === "inhaler") return "puffs";
if (normalized === "injection") return "injections";
return "pills";
}