Field-level validation rules for HL7v2 typed segments.
For each typed segment struct, checks:
- Required fields (
:roptionality) are not nil - Repeating fields with bounded
max_repsdo not exceed the limit - Coded fields against HL7-defined tables (opt-in via
validate_tables: true)
Summary
Functions
Returns a list of field-level validation errors/warnings for a single segment.
Returns a list of conditional-rule errors/warnings for a segment.
Functions
Returns a list of field-level validation errors/warnings for a single segment.
Skips validation for:
HL7v2.Segment.ZXX(site-defined, no typed fields)- Raw tuples
{name, fields}(not typed)
Options
:validate_tables-- whentrue, checks coded fields against HL7 tables. Defaults tofalse.
Returns a list of conditional-rule errors/warnings for a segment.
Conditional rules are HL7-specified dependencies between fields. In strict
mode they produce :error, in lenient mode :warning.
An optional context map may contain :trigger_event and :message_code
extracted from MSH-9. When provided, trigger-aware rules (e.g., scheduling
modification segments, PV2 transfer events) use definitive checks instead
of heuristic approximations.
Examples
# Without context (backwards compatible)
conditional_errors(segment, "AIS", :lenient)
# With trigger context
conditional_errors(segment, "AIS", :strict, %{trigger_event: "S03", message_code: "SIU"})