Skip to main content

Crate hl7_3

Crate hl7_3 

Source
Expand description

Health Level Seven (HL7) version 3 (V3) for Rust — a foundation, not a complete implementation.

HL7 v3 replaced v2’s pipe-delimited text and per-message-type segment tables with one thing reused everywhere: the Reference Information Model (RIM), six backbone classes (rim::Act, rim::Entity, rim::Role, rim::Participation, rim::ActRelationship, rim::RoleLink) that every domain payload — lab results, care records, structured product labeling — is assembled from, serialized as XML instead of ER7. It achieved little messaging adoption of its own (implementers found the model-driven rigor expensive to work with) but its RIM and three-level structure live on directly inside the Clinical Document Architecture (CDA), which did succeed.

use hl7_3::message;

let xml = r#"
<QUQI_IN000001UV01 xmlns="urn:hl7-org:v3">
  <id root="2.16.840.1.113883.19.5" extension="MSG00001"/>
  <interactionId root="2.16.840.1.113883.1.6" extension="QUQI_IN000001UV01"/>
  <controlActProcess classCode="CACT" moodCode="EVN">
    <code code="QUQI_TE000001UV01"/>
    <subject>
      <observation classCode="OBS" moodCode="EVN"/>
    </subject>
  </controlActProcess>
</QUQI_IN000001UV01>
"#;
let parsed = message::parse(xml)?;
assert_eq!(parsed.control_act.unwrap().domain.unwrap().local_name(), "observation");

§What this crate is, and is not

It is: the RIM backbone classes as Rust types (rim), the data types RIM attributes are built from — identifiers, coded values, intervals, quantities, encapsulated data, and the explicit-null mechanism any of them can carry instead of a value (vocabulary) — and a reader for the three-level message envelope every interaction shares (message) — transport wrapper, control act wrapper, domain payload.

It is not: a validator against any of HL7 v3’s vocabulary domains or interaction schemas, a CDA document model, or a decoder for any specific domain payload’s internal shape (a lab result, a care record) — those vary per interaction and are read with rim types by the caller, the same way generic mode in hl7-2 hands back a tree rather than a typed message. spec/index.md is the exact, current statement of scope; where this comment and that document disagree, the document is right.

For a stable, long-lived interaction, typed::FromElement — derived with #[derive(FromElement)] behind the derive feature (hl7-3-derive) — maps a struct’s fields onto an element’s attributes and children once, the way hl7-2’s struct mode does for v2 paths. See typed for the attributes and an example.

Re-exports§

pub use message::ControlAct;
pub use message::Message;
pub use typed::FromElement;
pub use typed::FromElementValue;
pub use vocabulary::Cd;
pub use vocabulary::Ed;
pub use vocabulary::Ii;
pub use vocabulary::Ivl;
pub use vocabulary::NullFlavor;
pub use vocabulary::Pq;
pub use hl7_2_xml_lite_helper as xml;

Modules§

message
The three-level structure every HL7 v3 message shares, whatever domain it carries: a transport wrapper, a control act wrapper, and a domain payload.
rim
The Reference Information Model (RIM): the six backbone classes every HL7 v3 domain payload is built from.
typed
Struct mode: compile-time types read off an XML element, instead of walking crate::rim types by hand.
vocabulary
The data types RIM attributes are built from: identifiers, coded values, intervals, quantities, encapsulated data, and the explicit-null mechanism every one of them can carry instead of a value.

Enums§

Error
What can go wrong.