Interface: Medication
A medication extracted from one RXO/RXE/RXD/RXA segment, with its RXR
(route) and RXC (component) children grouped
positionally. context records which RX* segment this came from (give
vs dispense vs administered).
Safety contract. A wrong drug, strength, or route can harm a real patient, so this view is deliberately conservative:
giveCodecarries its own coding-system provenance via the CWE (giveCode.nameOfCodingSystem: e.g.RXNRxNorm,NDC). The helper surfaces the claim; it never validates or looks the code up.amount(how much) andstrength(concentration) are SEPARATE fields and are never reconciled: including against any strength a coded drug implies. A disagreement is preserved for the consumer to see.- Malformed RX* segments never throw: absent fields are omitted keys.
routes and components are ALWAYS present (possibly empty). So is
timings: empty when no TQ1 / legacy embedded TQ (RXE-1)
accompanies the medication; the repeat pattern is surfaced verbatim, never
normalized to a schedule. Deferred (not v1): sig/frequency interpretation,
dose-range or interaction checking, pharmacologic resolution of compounds.
Example
import type { Medication } from "@cosyte/hl7";
const med: Medication = {
context: "encoded",
giveCode: { identifier: "1049630", text: "Acetaminophen 325 MG", nameOfCodingSystem: "RXN" },
amount: { minimum: 2, units: { identifier: "TAB" } },
strength: { value: 325, units: { identifier: "mg", nameOfCodingSystem: "UCUM" } },
routes: [{ route: { identifier: "PO", text: "Oral" } }],
components: [],
timings: [{ source: "TQ1", repeatPattern: { code: "Q6H", kind: "parametric", interval: { count: 6, unit: "H" } } }],
};
Properties
amount?
readonlyoptionalamount?:MedicationAmount
Give/dispense/administered amount (+ units). See MedicationAmount.
components
readonlycomponents: readonlyMedicationComponent[]
RXC children grouped under this RX* (compound components). Always present (possibly empty).
context
readonlycontext:MedicationContext
Which RX* segment this medication came from (give/dispense/administered).
dosageForm?
readonlyoptionaldosageForm?:CWE
RXO-5 requested dosage form (order context).
giveCode?
readonlyoptionalgiveCode?:CWE
RXO-1 / RXE-2 / RXD-2 / RXA-5 give/dispense/administered drug code, with provenance.
routes
readonlyroutes: readonlyMedicationRoute[]
RXR children grouped under this RX* (Table 0162 route). Always present (possibly empty).
strength?
readonlyoptionalstrength?:MedicationStrength
RXE-25/26 give strength: ENCODED context only; never reconciled with giveCode.
timings
readonlytimings: readonlyOrderTiming[]
TQ1 / legacy embedded-TQ (RXE-1) timing(s) grouped under this medication. Always present: empty when the medication carries no timing. See OrderTiming.