Timing/Quantity (TQ) -- HL7v2 composite data type.
Deprecated in v2.5.1 (replaced by TQ1/TQ2 segments), but retained for backward compatibility with OBR-27, ORC-7, and SCH-11 which use this type.
12 components:
- Quantity (CQ) -- sub-components delimited by
& - Interval (RI)
- Duration (ST)
- Start Date/Time (TS) -- sub-components delimited by
& - End Date/Time (TS) -- sub-components delimited by
& - Priority (ST)
- Condition (ST)
- Text (TX)
- Conjunction (ID) -- Table 0472: S (synchronous), A (asynchronous)
- Order Sequencing (OSD)
- Occurrence Duration (CE) -- sub-components delimited by
& - Total Occurrences (NM)
Summary
Types
@type t() :: %HL7v2.Type.TQ{ condition: binary() | nil, conjunction: binary() | nil, duration: binary() | nil, end_date_time: HL7v2.Type.TS.t() | nil, interval: HL7v2.Type.RI.t() | nil, occurrence_duration: HL7v2.Type.CE.t() | nil, order_sequencing: HL7v2.Type.OSD.t() | nil, priority: binary() | nil, quantity: HL7v2.Type.CQ.t() | nil, start_date_time: HL7v2.Type.TS.t() | nil, text: binary() | nil, total_occurrences: binary() | nil }
Functions
Encodes a TQ to a list of component strings.
Examples
iex> HL7v2.Type.TQ.encode(%HL7v2.Type.TQ{quantity: %HL7v2.Type.CQ{quantity: "1"}, duration: "S10"})
["1", "", "S10"]
iex> HL7v2.Type.TQ.encode(nil)
[]
iex> HL7v2.Type.TQ.encode(%HL7v2.Type.TQ{})
[]
Parses a TQ from a list of components.
Components containing sub-components (CQ, TS, CE, RI, OSD) are split by &
and parsed into their respective typed structs.
Examples
iex> HL7v2.Type.TQ.parse(["1&mL", "", "S10", "20260322143000"])
%HL7v2.Type.TQ{
quantity: %HL7v2.Type.CQ{quantity: "1", units: %HL7v2.Type.CE{identifier: "mL"}},
duration: "S10",
start_date_time: %HL7v2.Type.TS{time: %HL7v2.Type.DTM{year: 2026, month: 3, day: 22, hour: 14, minute: 30, second: 0}}
}
iex> HL7v2.Type.TQ.parse([])
%HL7v2.Type.TQ{}