Skip to main content
Version: v0.0.4

Interface: OrderTiming

The order/medication timing structure: one TQ1 segment (v2.5+) or the legacy embedded TQ in ORC-7 / RXE-1 (pre-v2.5). Attached to Order.timings and Medication.timings.

Safety contract. hl7 surfaces the timing structure; it does not compute administration schedules, resolve "institution-specified times" to clock times, or interpret sig. The load-bearing repeatPattern and totalOccurrences are preserved verbatim (see RepeatPattern); startDateTime/endDateTime keep the TS precision + timezone fidelity. A malformed timing never throws: absent pieces are omitted keys.

Example

import type { OrderTiming } from "@cosyte/hl7";
const t: OrderTiming = {
source: "TQ1",
quantity: { value: 1 },
repeatPattern: { code: "Q6H", kind: "parametric", interval: { count: 6, unit: "H" } },
totalOccurrences: 20,
};

Properties

endDateTime?

readonly optional endDateTime?: DtmParts

TQ1-8 / legacy TQ.5 end date/time as the fidelity TS.


explicitTime?

readonly optional explicitTime?: string

TQ1-4 / legacy TQ.2 interval RI.2 explicit time(s): surfaced verbatim (first repetition/value).


priority?

readonly optional priority?: CWE

TQ1-9 priority (CWE) / legacy TQ.6 priority (surfaced as a CWE { identifier }).


quantity?

readonly optional quantity?: TimingQuantity

TQ1-2 / legacy TQ.1 service quantity (CQ).


repeatPattern?

readonly optional repeatPattern?: RepeatPattern

TQ1-3 / legacy TQ.2 interval RI.1 repeat pattern (Table 0335): verbatim. See RepeatPattern.


serviceDuration?

readonly optional serviceDuration?: string

TQ1-6 / legacy TQ.3 service duration: surfaced verbatim.


source

readonly source: "TQ1" | "legacy"

Which structure this timing was read from: the dedicated TQ1 segment (v2.5+) or the legacy embedded TQ data type in ORC-7 (orders) / RXE-1 (encoded medications, pre-v2.5). The library treats the presence of a TQ1 segment as the v2.5+ signal: the legacy embedded TQ is surfaced only when no TQ1 accompanies the order, so the same timing is never double-counted and a legacy-only timing is never dropped.


startDateTime?

readonly optional startDateTime?: DtmParts

TQ1-7 / legacy TQ.4 start date/time as the fidelity TS.


totalOccurrences?

readonly optional totalOccurrences?: number

TQ1-14 / legacy TQ.12 total occurrences (NM): how many times the service is to be performed (strict-parsed; never NaN). TQ1-14, not TQ1-11 (TQ1-11 is Text Instruction). Load-bearing: losing it drops the total administered count.