# `HL7v2.Type.DR`
[🔗](https://github.com/Balneario-de-Cofrentes/hl7v2/blob/v3.10.1/lib/hl7v2/type/dr.ex#L1)

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.

# `t`

```elixir
@type t() :: %HL7v2.Type.DR{
  range_end: HL7v2.Type.TS.t() | nil,
  range_start: HL7v2.Type.TS.t() | nil
}
```

# `encode`

```elixir
@spec encode(t() | nil) :: list()
```

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)
    []

# `parse`

```elixir
@spec parse(list()) :: t()
```

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{}

---

*Consult [api-reference.md](api-reference.md) for complete listing*
