Expand description
Serde support for Health Level Seven (HL7®) messages in Rust.
The hl7 crate organizes HL7 by standard, one module each — hl7::v2
is the hl7-2 crate, hl7::v3 is hl7-3 — because a “message” or a
“code” in one standard is a different thing in another. This crate is
the same shape one layer up: Serde support for each standard’s types,
one module each, so a parsed message can flow through serde_json,
serde_yaml, bincode, or any other Serde data format.
v2— theserde-hl7-v2crate:Serialize/Deserializewrappers forhl7-2’s message, generic-mode tree, validation diagnostics, and release. Behind thev2feature, on by default.v3— theserde-hl7-v3crate: wrappers forhl7-3’s message envelope, RIM backbone classes, data types, and the XML element tree beneath them. Behind thev3feature, on by default.
use serde_hl7::v2;
let text = "MSH|^~\\&|LAB||EPIC||20240101||ORU^R01|1|P|2.5\r\
PID|1||241900||SMITH^JOHN";
let message = v2::Message::parse(text)?;
let json = serde_json::to_string(&message)?;
let back: v2::Message = serde_json::from_str(&json)?;
assert_eq!(back.to_er7(), text);Each module is its own crate underneath, so a caller who wants only one standard can depend on that crate directly instead of this umbrella — or keep this crate and turn the other off:
[dependencies]
serde-hl7 = { version = "0.1", default-features = false, features = ["v2"] }Nothing lives at the root but the modules. Every wrapper is hand-written
against Serde’s low-level traits in the per-standard crate, with exactly
two runtime dependencies each — serde and the hl7-* crate it wraps —
and no format crate anywhere but in tests. See each module’s own
documentation for the wire shape of every type, and serde-hl7-v2’s
and serde-hl7-v3’s spec/index.md for the normative rules.
§Trademarks
HL7®, and FHIR® are the registered trademarks of Health Level Seven International and their use of these trademarks does not constitute an endorsement by HL7.
Re-exports§
pub use serde_hl7_v2 as v2;pub use serde_hl7_v3 as v3;