HL7v2.Standard.MessageStructure (HL7v2 v3.10.1)

Copy Markdown View Source

HL7 v2.5.1 abstract message structure definitions.

Each message structure is defined as a tree of segments and groups with cardinality constraints, following the HL7 v2.5.1 abstract message definitions.

Structure AST

Each node is one of:

  • {:segment, id, optionality} — a single segment occurrence
  • {:segment, id, optionality, :repeating} — a repeating segment
  • {:group, name, optionality, children} — a segment group (single)
  • {:group, name, optionality, :repeating, children} — a repeating group

Where:

  • id is an atom like :MSH, :PID, :PV1
  • name is a group name atom like :PATIENT, :VISIT, :ORDER
  • optionality is :required or :optional
  • children is a list of nested nodes

222 structure definitions covering all 186 official v2.5.1 abstract message structures plus aliases and response variants. Run mix hl7v2.gen_docs to regenerate reference documentation from these definitions.

Source: HL7 v2.5.1 abstract message definitions via https://www.hl7.eu/HL7v2x/v251/hl7v251msgstruct.htm and https://hl7-definition.caristix.com/v2/HL7v2.5.1/TriggerEvents

Summary

Functions

Returns the count of defined structures.

Returns the structure definition for a message structure name, or nil.

Returns all defined structure names.

Extracts the flat list of required segment IDs from a structure definition.

Types

structure()

@type structure() :: %{
  name: binary(),
  description: binary(),
  nodes: [structure_node()]
}

structure_node()

@type structure_node() ::
  {:segment, atom(), :required | :optional}
  | {:segment, atom(), :required | :optional, :repeating}
  | {:group, atom(), :required | :optional, [structure_node()]}
  | {:group, atom(), :required | :optional, :repeating, [structure_node()]}

Functions

count()

@spec count() :: non_neg_integer()

Returns the count of defined structures.

get(name)

@spec get(binary()) :: structure() | nil

Returns the structure definition for a message structure name, or nil.

names()

@spec names() :: [binary()]

Returns all defined structure names.

required_segments(map)

@spec required_segments(structure()) :: [atom()]

Extracts the flat list of required segment IDs from a structure definition.

This is the bridge to the current presence-only validation: it walks the structure tree and collects all required segment IDs, ignoring group nesting.