ex_hl7 v0.3.0 HL7.Composite.Def

Macros and functions used to define HL7 composite fields

Summary

Functions

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

Macros

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 in HL7 segments. A composite field definition looks like the following block

Types

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

Functions

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

Specs

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

Checks that a component definition is correct

check_default!(name, type, default)

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

check_default?(type, default)
check_type!(name, type)

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

check_type?(type)
composite_type?(module)
default_for(type, default)
quote_single_type(composite)
quote_struct_type(module, field_specs)
scalar_type?(arg1)

Macros

component(name, args \\ [])

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 scalar types and an empty struct for composite types. The supported types are:

  • :string
  • :integer
  • :float
  • :date: a field containing a date as a {year, month, day} that is serialized using the YYYYMMDD format.
  • :datetime: a field containing a date/time tuple (i.e. {{year, month, day}, {hour, min, sec}}) 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.Def module or following the behaviour of an HL7.Composite. There are some sample composite field modules already defined in the HL7.Composite module.
composite(list)

Macro that generates the code that allows a module to be used as a composite field in 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 are in the message.