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

Composite Quantity with Units (CQ) -- HL7v2 composite data type.

Used for quantities with associated units.

2 components:
1. Quantity (NM)
2. Units (CE) -- sub-components delimited by `&`

# `t`

```elixir
@type t() :: %HL7v2.Type.CQ{quantity: binary() | nil, units: HL7v2.Type.CE.t() | nil}
```

# `encode`

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

Encodes a CQ to a list of component strings.

## Examples

    iex> HL7v2.Type.CQ.encode(%HL7v2.Type.CQ{quantity: "10", units: %HL7v2.Type.CE{identifier: "mL"}})
    ["10", "mL"]

    iex> HL7v2.Type.CQ.encode(%HL7v2.Type.CQ{quantity: "5"})
    ["5"]

    iex> HL7v2.Type.CQ.encode(nil)
    []

# `parse`

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

Parses a CQ from a list of components.

## Examples

    iex> HL7v2.Type.CQ.parse(["10", "mL&milliliter&UCUM"])
    %HL7v2.Type.CQ{quantity: "10", units: %HL7v2.Type.CE{identifier: "mL", text: "milliliter", name_of_coding_system: "UCUM"}}

    iex> HL7v2.Type.CQ.parse(["5"])
    %HL7v2.Type.CQ{quantity: "5"}

    iex> HL7v2.Type.CQ.parse([])
    %HL7v2.Type.CQ{}

---

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