ex_hl7 v1.0.0 HL7.Composite.Spec

Macros and functions used to define HL7 composite fields

Link to this section Summary

Functions

Function that receives the type used in a segment or composite field definition and returns its basic type. If a composite type is passed, it will navigate through its definition and return the basic type (i.e. :string; :integer, :float; :date; :datetime) of the corresponding field.

Checks that a component definition is correct

Checks that the default value assigned to a component inside a composite field is valid

Checks that the type of a component inside a composite field is valid

Macro that generates the code for each individual component within an HL7 composite field. Each component definition looks like the following one

Macro that generates the code that allows a module to be used as a composite field for HL7 segments. A composite field definition looks like the following block

Link to this section Types

Link to this type

option()

option() ::
  {:separators, [{key :: atom(), separator :: byte()}]} | {:trim, boolean()}

Link to this section Functions

Link to this function

base_type(composite_type)

Function that receives the type used in a segment or composite field definition and returns its basic type. If a composite type is passed, it will navigate through its definition and return the basic type (i.e. :string; :integer, :float; :date; :datetime) of the corresponding field.

It accepts both basic types and composite types, returning the atom corresponding to the type or nil if the type is invalid.

Examples

iex> alias HL7.Composite.Spec
...> alias HL7.Composite.Default.CX
...> Spec.base_type({CX, :assigning_authority, :universal_id})
:string
iex> Spec.base_type({CX, :effective_date})
:date
iex> Spec.base_type(:integer)
:integer
iex> Spec.base_type(:invalid_type)
nil
Link to this function

base_type!(type)

Link to this function

base_type?(arg1)

Link to this function

check_base_type?(arg1)

Link to this function

check_component!(name, type, default, module, components)

check_component!(
  name :: atom(),
  type :: atom(),
  default :: any(),
  module(),
  components :: [{name :: atom(), type :: atom()}]
) :: nil | no_return()

Checks that a component definition is correct

Link to this function

check_default!(name, type, default)

Checks that the default value assigned to a component inside a composite field is valid

Link to this function

check_default?(arg1, default)

Link to this function

check_type!(name, type)

Checks that the type of a component inside a composite field is valid

Link to this function

check_type?(composite_type)

Link to this macro

component(name, args \\ [])

(macro)

Macro that generates the code for each individual component within an HL7 composite field. Each component definition looks like the following one:

component :price, type: :float

A component has a name that has to be an atom, a type and a default value. The default type is :string and the default value is "" for basic types and an empty struct for composite types. The supported types are:

  • :string
  • :integer
  • :float
  • :date: a field containing a date as a %Date{} struct that is serialized using the YYYYMMDD format.
  • :datetime: a field containing a %NaiveDateTime{} struct that is serialized using the YYYYMMDD[hhmm[ss]] format.
  • an atom corresponding to a composite field's module name. The module must have been built using the macros from the HL7.Composite.Spec module or following the behaviour of an HL7.Composite.
Link to this macro

composite(list)

(macro)

Macro that generates the code that allows a module to be used as a composite field for HL7 segments. A composite field definition looks like the following block:

composite do
  component :number, type: :string
  component :date,   type: :date
  component :source, type: :string
end

Note: when defining a composite, the fields have to be in the order they appear in the message.

Link to this function

composite_module?(module)

Link to this function

default_for(type, default)

Link to this function

quote_base_type(composite)