HL7v2.Type.CP (HL7v2 v3.10.1)

Copy Markdown View Source

Composite Price (CP) -- HL7v2 composite data type.

Used for price information with optional range and type qualifiers.

6 components:

  1. Price (MO) -- sub-components delimited by & (quantity & denomination)
  2. Price Type (ID) -- Table 0205
  3. From Value (NM)
  4. To Value (NM)
  5. Range Units (CE) -- sub-components delimited by &
  6. Range Type (ID) -- Table 0298

Summary

Functions

Encodes a CP to a list of component strings.

Parses a CP from a list of components.

Types

t()

@type t() :: %HL7v2.Type.CP{
  from_value: binary() | nil,
  price: HL7v2.Type.MO.t() | nil,
  price_type: binary() | nil,
  range_type: binary() | nil,
  range_units: HL7v2.Type.CE.t() | nil,
  to_value: binary() | nil
}

Functions

encode(cp)

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

Encodes a CP to a list of component strings.

Examples

iex> HL7v2.Type.CP.encode(%HL7v2.Type.CP{price: %HL7v2.Type.MO{quantity: "100.00", denomination: "USD"}, price_type: "UP"})
["100.00&USD", "UP"]

iex> HL7v2.Type.CP.encode(%HL7v2.Type.CP{price: %HL7v2.Type.MO{quantity: "50"}})
["50"]

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

parse(components)

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

Parses a CP from a list of components.

Examples

iex> HL7v2.Type.CP.parse(["100.00&USD", "UP"])
%HL7v2.Type.CP{price: %HL7v2.Type.MO{quantity: "100.00", denomination: "USD"}, price_type: "UP"}

iex> HL7v2.Type.CP.parse(["50"])
%HL7v2.Type.CP{price: %HL7v2.Type.MO{quantity: "50"}}

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