HL7v2.MessageDefinition (HL7v2 v3.10.1)

Copy Markdown View Source

Canonical message structure mappings and validation dispatch.

Maps HL7v2 trigger events to their canonical message structures (e.g., ADT^A04 → ADT_A01) and dispatches structural validation to HL7v2.Standard.MessageStructure and HL7v2.Validation.Structural.

Summary

Functions

Returns the canonical message structure for a message code and trigger event.

Validates segment presence/structure against the message definition.

Functions

canonical_structure(code, event)

@spec canonical_structure(binary(), binary()) :: binary()

Returns the canonical message structure for a message code and trigger event.

Many HL7v2 trigger events share the same abstract message definition. For example, ADT^A04, ADT^A08, and ADT^A13 all use the ADT_A01 structure.

Falls back to "CODE_EVENT" when no canonical mapping exists.

Examples

iex> HL7v2.MessageDefinition.canonical_structure("ADT", "A28")
"ADT_A05"

iex> HL7v2.MessageDefinition.canonical_structure("ADT", "A01")
"ADT_A01"

iex> HL7v2.MessageDefinition.canonical_structure("ZZZ", "Z01")
"ZZZ_Z01"

validate_structure(structure, segment_ids)

@spec validate_structure(binary() | nil, [binary()]) :: :ok | {:error, [map()]}

Validates segment presence/structure against the message definition.

Delegates to HL7v2.Validation.Structural for structures with group-aware definitions. Returns a warning for unknown structures.