@zenuinebit/prescription
v0.1.0
Published
Prescription dosing helpers: frequency to times, course length, quantity to dispense, weight-based dose and a printable text/HTML format.
Readme
@zenuinebit/prescription
Helpers for writing prescriptions: dosing frequency, quantity to dispense, dose by body weight, and a printable layout. No dependencies.
These helpers do arithmetic and formatting only. They know no drug, check no interactions and do not decide whether a dose is safe. A qualified clinician must review every prescription and dose.
import {
parseFrequency, describeFrequency, quantity, courseEnd, administrationTimes,
weightBasedDose, liquidVolumeMl, renderText, renderHTML,
} from "@zenuinebit/prescription";
describeFrequency("1-0-1"); // "1-0-1 (morning, night)"
quantity({ frequency: "TDS", days: 5 }); // { units: 15, dispense: 15 }
quantity({ frequency: "OD", days: 5, unitsPerTake: 0.5, packSize: 10 }); // { units: 2.5, dispense: 3, packs: 1 }
courseEnd("2025-03-01", 5); // "2025-03-05"
administrationTimes("TDS"); // ["08:00", "15:00", "22:00"]
// Weight-based: say whether the figure is per dose or per day, there is no default
weightBasedDose({ weightKg: 12, mgPerKg: 15, basis: "per-dose", dosesPerDay: 3, maxSingleMg: 500 });
// { singleMg: 180, dailyMg: 540, capped: false }
liquidVolumeMl(180, { mg: 125, ml: 5 }); // 7.2 (ml)
renderText(rx); // plain text for chat or a thermal printer
renderHTML(rx); // A5 page to print; all text is escapedFrequencies understood: OD, BD, TDS, QID, HS, STAT, SOS/PRN, Q4H/Q6H/Q8H/Q12H (dots and case ignored), and morning-afternoon-night notation like 1-0-1 or 1-1-1-1. In that notation each number is a multiplier of unitsPerTake.
Good to know
SOS/PRNmedicines needmaxPerDaybefore a quantity can be worked out.- Maximums in
weightBasedDoselower the dose and setcapped: true. Rounding never pushes a dose back over its maximum. courseEndcounts the start day as day 1.
Not included: a drug database, interaction or allergy checks, renal or paediatric dosing rules, and digital signatures.
