Skip to main content
Version: v0.0.4

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:

  • giveCode carries its own coding-system provenance via the CWE (giveCode.nameOfCodingSystem: e.g. RXN RxNorm, NDC). The helper surfaces the claim; it never validates or looks the code up.
  • amount (how much) and strength (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?

readonly optional amount?: MedicationAmount

Give/dispense/administered amount (+ units). See MedicationAmount.


components

readonly components: readonly MedicationComponent[]

RXC children grouped under this RX* (compound components). Always present (possibly empty).


context

readonly context: MedicationContext

Which RX* segment this medication came from (give/dispense/administered).


dosageForm?

readonly optional dosageForm?: CWE

RXO-5 requested dosage form (order context).


giveCode?

readonly optional giveCode?: CWE

RXO-1 / RXE-2 / RXD-2 / RXA-5 give/dispense/administered drug code, with provenance.


routes

readonly routes: readonly MedicationRoute[]

RXR children grouped under this RX* (Table 0162 route). Always present (possibly empty).


strength?

readonly optional strength?: MedicationStrength

RXE-25/26 give strength: ENCODED context only; never reconciled with giveCode.


timings

readonly timings: readonly OrderTiming[]

TQ1 / legacy embedded-TQ (RXE-1) timing(s) grouped under this medication. Always present: empty when the medication carries no timing. See OrderTiming.