HL7v2.Type.CQ (HL7v2 v3.10.1)

Copy Markdown View Source

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 &

Summary

Functions

Encodes a CQ to a list of component strings.

Parses a CQ from a list of components.

Types

t()

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

Functions

encode(cq)

@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(components)

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