ex_hl7 v0.3.0 HL7.Segment.Def
Macros and functions used to define HL7 segments
Summary
Functions
Check that the default value of a field in a segment is valid
Check that the length of a field in a segment is valid
Check that the type of a field in a segment is valid
Macros
Macro that injects the code used to represent a field within an HL7 segment
block. Each field
definition looks like the following one
Macro that generates the code that allows a module to be used as an HL7
segment. A segment
definition looks like the following block
Functions
Specs
build_descriptor([{name :: atom, seq :: pos_integer, type :: atom, length :: pos_integer}]) :: tuple
Check that the default value of a field in a segment is valid
Macros
Macro that injects the code used to represent a field within an HL7 segment
block. Each field
definition looks like the following one:
field :diagnosis_type, seq: 6, type: :binary, length: 2
A field
has a name that has to be an atom, a seq
number (1-based) with
the field’s position in the segment, a type
and a length
. The default
type
is :string
and the default length
is nil
. 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 anHL7.Composite
. There are some sample composite field modules already defined in theHL7.Composite
module.
Macro that generates the code that allows a module to be used as an HL7
segment. A segment
definition looks like the following block:
alias HL7.Composite.CE
segment "DG1" do
field :set_id, seq: 1, type: :integer, length: 4
field :diagnosis, seq: 3, type: CE, length: 64
field :diagnosis_type, seq: 6, type: :binary, length: 2
end
A segment
has a name or segment ID, which is a binary that will be used to
identify the segment when parsing an HL7 message or when converting the
segment into its wire format.
Note: when defining a segment, the fields with correlative sequence (seq
)
numbers need not be in order, but it is recommended that you do so.