hl7v2-types
HL7 v2 message structure trees, segment field tables, data type component tables and message definitions as Rust data.
The crate holds the tables a v2 parser walks:
-
structure: every message structure of the HL7 v2 definitions (305 of them, for exampleORU_R01-AandADT_A01-A) as astatictree of segments, segment groups, choice groups and openHxxslots in definition order, each with its position, its cardinality (minimum, and maximum or unbounded) and, for a segment, its segment status code. -
segment: every segment definition (190), each with its fields by position: the field name, the data type code, the cardinality (whose maximum is the repetition), the optionality code, the length and conformance length, and the HL7 table its binding names, by table number and value set URL. The batch envelopes (BHS,BTS,FHS,FTS) and the other segments no structure references (ADD,FAC,OVR,PDC,PSH) are in it too. -
data_type: every data type definition (83: 12 primitive, 71 complex with 448 components), each complex type with its components by position: the component name, its data type, cardinality, optionality code, length and conformance length, and table. A field points at its data type'sstatic;Varies, which no data type definition defines, stays a code. -
message: every message definition (696), indexed by message code and trigger event (MSH-9.1andMSH-9.2), each pointing at the message structure variant it names:message::find("ADT", "A04")namesADT_A01-B. The 34 definitions that name no structure carry none. -
legacy: the message structures the v2.9.1 definitions no longer carry (57 codes,ORM_O01among them), one tree per earlier version whose tables carry it (218 trees over versions 2.3 to 2.8.2), for examplelegacy::v2_5_1::structure::orm_o01::ORM_O01. Each carries itsversionandwithdrawn_as_of(ORM_O01: 2.7). The segments a tree names come from the same version's tables, each field with the data type code that version gives it: 495 per-version segments are emitted under the version'ssegmentmodule, and the 98 references to a segment whose field table agrees with the v2.9.1 one point at the v2.9.1static.legacy::versions("ORM_O01")lists the trees, andmessage::find_legacy("ORM", "O01", "2.5.1")finds one by code, event and version (message::LEGACY, 218 entries).
structure::find, segment::find and data_type::find look an entry up by
its definition id, and message::find by code and event. A tree node points
at the segment's own static, so the field table is one step from the node
that places the segment. The shapes are in model, and every one of them
compares by value (PartialEq, Eq). Every field, component and node
carries the element id of its definition (OBX.1-setId, CX.1,
ORU_R01-A.5-PATIENT_RESULT), and every code is carried as the definitions
write it.
The crate carries no table contents. The v2
tables are published as FHIR CodeSystem and ValueSet resources in the HL7
terminology package, which a terminology server serves by the value set URL a
field names.
Source
Every file is generated by
fhir-codegen
from the HL7 v2 definitions of HL7/v2ig
(input/sourceOfTruth, logical StructureDefinitions derived from HL7
V2.9.1) at the commit the banner of each file names, and marked
// @generated. The legacy module is generated from the NIST IGAMT export
of HL7's v2 database
(usnistgov/igamt-hl7Tools-service,
src/main/resources/hl7db), checked against table 0354 of the HL7
terminology package. The definitions and the export are fetched at build
time and are not part of this crate. To change the output, change the generator and
regenerate; the crate is never hand-edited.
Licence
Apache License 2.0 (LICENSE).