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
option()
Link to this section Functions
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
base_type!(type)
base_type?(arg1)
check_base_type?(arg1)
check_component!(name, type, default, module, components)
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?(arg1, default)
check_type!(name, type)
Checks that the type of a component inside a composite field is valid
check_type?(composite_type)
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 theYYYYMMDD
format.:datetime
: a field containing a%NaiveDateTime{}
struct that is serialized using theYYYYMMDD[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 anHL7.Composite
.
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.