Expand description
Convert HL7 v2.5 messages from the typed JSON representation the
sibling hl7-2-from-er7-into-json crate produces back to ER7
(pipe-delimited) encoding.
This is the inverse of that crate. It names every JSON key after either
an HL7 v2.5 data type or a bare position, but in both cases the number
after a key’s last dot is always the 1-based position at that level —
field under a segment, component under a field, subcomponent under a
component. Reconstruction leans on that one fact rather than an HL7
v2.5 data-type dictionary, so this crate carries none; see
spec/index.md for the exact rules and their limits.
let json = r#"{
"ORM_O01": {
"MSH": { "MSH.1": "|", "MSH.2": "^~\\&", "MSH.9": {"MSG.1": "ORM", "MSG.2": "O01"} },
"ORM_O01.PATIENT": {
"PID": { "PID.5": { "XPN.1": {"FN.1": "TEST"}, "XPN.2": "FOUAZ" } }
}
}
}"#;
let er7 = hl7_2_from_json_into_er7::convert(json).unwrap();
assert!(er7.starts_with(r"MSH|^~\&|"));
assert!(er7.contains("PID|||||TEST^FOUAZ"));Re-exports§
pub use er7;
Modules§
- json
- A minimal, dependency-free JSON reader (RFC 8259) for the documents this crate consumes.
- reconstruct
- Rebuilding the ER7 value tree from the parsed JSON
Valuetree.
Enums§
- Hl7Error
- Errors that can occur while turning JSON into an
er7::Message.
Functions§
- convert
- Convert one JSON document to ER7 text, with default rendering: carriage-return segment terminators, and no trailing terminator.
- convert_
with_ options - Convert one JSON document to ER7 text, choosing the segment terminator
and whether the last segment gets one too — see
er7::RenderOptions. - parse
- Parse a converted-JSON document into an
er7::Message, reconstructing its full ER7 value tree — segments, fields, repetitions, components, and subcomponents.