HL7v2.Type.NR (HL7v2 v3.10.1)

Copy Markdown View Source

Numeric Range (NR) -- HL7v2 composite data type.

Two components: low value and high value, both NM type. Specifies an interval between lowest and highest values.

Summary

Functions

Encodes a numeric range to a list of component strings.

Parses a numeric range from a list of components.

Types

t()

@type t() :: %HL7v2.Type.NR{
  high: HL7v2.Type.NM.t() | nil,
  low: HL7v2.Type.NM.t() | nil
}

Functions

encode(nr)

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

Encodes a numeric range to a list of component strings.

Examples

iex> HL7v2.Type.NR.encode(%HL7v2.Type.NR{low: "2.5", high: "10"})
["2.5", "10"]

iex> HL7v2.Type.NR.encode(%HL7v2.Type.NR{})
[]

parse(components)

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

Parses a numeric range from a list of components.

Examples

iex> HL7v2.Type.NR.parse(["2.5", "10.0"])
%HL7v2.Type.NR{low: %HL7v2.Type.NM{value: "2.5", original: "2.5"}, high: %HL7v2.Type.NM{value: "10", original: "10.0"}}

iex> HL7v2.Type.NR.parse(["", "100"])
%HL7v2.Type.NR{low: nil, high: %HL7v2.Type.NM{value: "100", original: "100"}}

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