Date/Time Range (DR) -- HL7v2 composite data type.
Two components: range start and range end, both TS (Time Stamp) type. When only a start is known, component 2 is null (open-ended range). When only an end is known, component 1 is null.
Summary
Functions
Encodes a date/time range to a list of component strings.
Parses a date/time range from a list of components.
Types
@type t() :: %HL7v2.Type.DR{ range_end: HL7v2.Type.TS.t() | nil, range_start: HL7v2.Type.TS.t() | nil }
Functions
Encodes a date/time range to a list of component strings.
Examples
iex> HL7v2.Type.DR.encode(%HL7v2.Type.DR{
...> range_start: %HL7v2.Type.TS{time: %HL7v2.Type.DTM{year: 2026, month: 1, day: 1}},
...> range_end: %HL7v2.Type.TS{time: %HL7v2.Type.DTM{year: 2026, month: 12, day: 31}}
...> })
["20260101", "20261231"]
iex> HL7v2.Type.DR.encode(nil)
[]
Parses a date/time range from a list of components.
Each component is itself a TS, so sub-components within are split by &.
In practice, most DR values carry only a DTM string per component.
Examples
iex> HL7v2.Type.DR.parse(["20260101", "20261231"])
%HL7v2.Type.DR{
range_start: %HL7v2.Type.TS{time: %HL7v2.Type.DTM{year: 2026, month: 1, day: 1}},
range_end: %HL7v2.Type.TS{time: %HL7v2.Type.DTM{year: 2026, month: 12, day: 31}}
}
iex> HL7v2.Type.DR.parse([])
%HL7v2.Type.DR{}