ex_hl7 v1.0.0 HL7.Segment

Generic functions used by HL7 segment macros

Link to this section Summary

Functions

Given a field specification, generate the intermediate representation for the field using the data present in a segment map.

Return the ID of a segment.

Return the module corresponding to a segment.

Link to this section Types

Link to this type

spec()

spec() ::
  {name :: atom(), seq :: HL7.Type.sequence(), type :: atom(),
   len :: pos_integer()}

Link to this section Functions

Link to this function

get_field_ir!(segment, field_spec)

get_field_ir!(t(), [HL7.Type.field_spec()]) :: HL7.Type.field() | no_return()

Given a field specification, generate the intermediate representation for the field using the data present in a segment map.

A field that has the following definition in a segment:

alias HL7.Composite.Default.CX

field :patient_id,               seq:  3, rep: 1, type: {CX, :id}, len: 20
field :auth_id,                  seq:  3, rep: 1, type: {CX, :assigning_authority, :namespace_id}, len: 6
field :auth_universal_id,        seq:  3, rep: 1, type: {CX, :assigning_authority, :universal_id}, len: 6
field :auth_universal_id_type,   seq:  3, rep: 1, type: {CX, :assigning_authority, :universal_id_type}, len: 10
field :id_type,                  seq:  3, rep: 1, type: {CX, :id_type}, len: 2
field :patient_document_id,      seq:  3, rep: 2, type: {CX, :id}, len: 20
field :patient_document_id_type, seq:  3, rep: 2, type: {CX, :id_type}, len: 2

Will have the following field specification (note that the specifications of each item in the field are sorted based on their coordinate in descending order):

field_spec = [
  {:patient_document_id_type,    {2, 4},    :string, 2},
  {:patient_document_id,         {2, 1},    :string, 20},
  {:id_type,                     {1, 5},    :string, 2},
  {:authority_universal_id_type, {1, 4, 3}, :string, 10},
  {:authority_universal_id,      {1, 4, 2}, :string, 6},
  {:authority_id,                {1, 4, 1}, :string, 6},
  {:patient_id,                  {1, 1},    :string, 20}
]

The coordinate of an item is a tuple (with a maximum of 3 elements) representing their position in the field. Each element of the coordinate tuple is an index with the following meaning.

  1. repetition index
  2. component index
  3. subcomponent index

Examples

iex> field_spec = [
  {:patient_document_id_type,    {2, 4},    :string, 2},
  {:patient_document_id,         {2, 1},    :string, 20},
  {:id_type,                     {1, 5},    :string, 2},
  {:authority_universal_id_type, {1, 4, 3}, :string, 10},
  {:authority_universal_id,      {1, 4, 2}, :string, 6},
  {:authority_id,                {1, 4, 1}, :string, 6},
  {:patient_id,                  {1, 1},    :string, 20}
]
...> segment = %{
  patient_id: "Juan Perez",
  authority_id: "XYZ123",
  authority_universal_id: "808818",
  authority_universal_id_type: "IIN",
  id_type: "CU",
  patient_document_id: "12345678",
  patient_document_id_type: "DNI"
}
...> get_field_ir!(segment, field_spec)
[
  {"Juan Perez", "", "", {"XYZ123", "808818", "IIN"}, "CU"},
  {"12345678", "", "", "DNI"}
]

Return the ID of a segment.

Examples

iex> alias HL7.Segment.Default.Builder
...> {:ok, {segment, segment_spec}} = Builder.new("MSH")
...> id(segment)
"MSH"
Link to this function

match_base_coord(coord_1, coord_2, depth)

Link to this function

module(arg1)

module(t()) :: module()

Return the module corresponding to a segment.

Examples

iex> alias HL7.Segment.Default.Builder
...> {:ok, {segment, segment_spec}} = Builder.new("MSH")
...> module(segment)
HL7.Segment.Default.MSH
Link to this function

put_field_ir!(segment, list, value)

put_field_ir!(t(), [HL7.Type.field_spec()], HL7.Type.value()) ::
  t() | no_return()