HL7v2.Type.MO (HL7v2 v3.10.1)

Copy Markdown View Source

Money (MO) -- HL7v2 composite data type.

Used for monetary amounts with optional denomination.

2 components:

  1. Quantity (NM)
  2. Denomination (ID) -- ISO 4217 currency code (e.g., USD, EUR)

Summary

Functions

Encodes an MO to a list of component strings.

Parses an MO from a list of components.

Types

t()

@type t() :: %HL7v2.Type.MO{denomination: binary() | nil, quantity: binary() | nil}

Functions

encode(mo)

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

Encodes an MO to a list of component strings.

Examples

iex> HL7v2.Type.MO.encode(%HL7v2.Type.MO{quantity: "150.00", denomination: "USD"})
["150.00", "USD"]

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

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

parse(components)

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

Parses an MO from a list of components.

Examples

iex> HL7v2.Type.MO.parse(["150.00", "USD"])
%HL7v2.Type.MO{quantity: "150.00", denomination: "USD"}

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

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