ex_hl7 v0.4.2 HL7.Composite.Def

Macros and functions used to define HL7 composite fields

Link to this section 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

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

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 check_component!(name, type, default, module, components)
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

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?(type, 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?(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 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.
Link to this macro composite(list) (macro)

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.

Link to this function composite_type?(module)
Link to this function default_for(type, default)
Link to this function quote_single_type(composite)
Link to this function quote_struct_type(module, field_specs)
Link to this function scalar_type?(arg1)