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

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:
1. Quantity (CQ) -- sub-components delimited by `&`
2. Interval (RI)
3. Duration (ST)
4. Start Date/Time (TS) -- sub-components delimited by `&`
5. End Date/Time (TS) -- sub-components delimited by `&`
6. Priority (ST)
7. Condition (ST)
8. Text (TX)
9. Conjunction (ID) -- Table 0472: S (synchronous), A (asynchronous)
10. Order Sequencing (OSD)
11. Occurrence Duration (CE) -- sub-components delimited by `&`
12. Total Occurrences (NM)

# `t`

```elixir
@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
}
```

# `encode`

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

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

# `parse`

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

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

---

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