1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! A small, dependency-free HL7 v2.x parser.
//!
//! The parser splits a message into segments, fields, repetitions, components and
//! subcomponents and keeps the **byte span** of every node, so a caller can point
//! back into the original text (for highlighting, diffing or error reporting)
//! without searching for the value again.
//!
//! Design constraints:
//!
//! * No dependencies, no `unsafe`, no panics on malformed input. Malformed
//! messages are the normal case in integration work; every failure is a value.
//! * Tolerant of what real interfaces produce: `\r`, `\r\n` and bare `\n`
//! segment terminators, MLLP framing bytes, a UTF-8 BOM, a malformed MSH-2.
//! * MSH numbering is handled correctly: MSH-1 is the field separator and
//! MSH-2 the encoding characters, so `MSH-9` is the message type in this
//! crate exactly as it is in the standard.
//! * Encoding characters come from MSH-2, never hardcoded. Escape sequences
//! (`\F\`, `\S\`, `\T\`, `\R\`, `\E\`, `\Xdd..\`, `\.br\`) decode on demand.
//! * Host-target only code: no `web-sys`, no I/O. It compiles for
//! `wasm32-unknown-unknown` unchanged.
//!
//! ```
//! use hl7kit::Message;
//!
//! let text = "MSH|^~\\&|RIS|HOSP|PACS|HOSP|20260905120000||ORM^O01|42|P|2.5.1\r\
//! PID|1||4MR1^^^HOSP^MR||Doe^Jane||19700101|F\r\
//! OBR|1|A1001||MR1^MRI HEAD|||20260905|||||||||||A1001|RP-77\r\
//! ZDS|1.3.6.1.4.1.5962.1.2.4.20040826185059.5457^^Application^DICOM\r";
//!
//! let msg = Message::parse(text).unwrap();
//! assert_eq!(msg.get("MSH-9.1"), Some("ORM"));
//! assert_eq!(msg.get("PID-3.1"), Some("4MR1"));
//! assert_eq!(msg.get("OBR-18"), Some("A1001"));
//! assert_eq!(msg.get("ZDS-1.1"), Some("1.3.6.1.4.1.5962.1.2.4.20040826185059.5457"));
//!
//! // Every value knows where it came from.
//! let span = msg.get_span("PID-3.1").unwrap();
//! assert_eq!(&text[span.range()], "4MR1");
//! ```
//!
//! The [`order`] module builds on the parser to extract the four identifiers an
//! imaging order carries (patient ID, accession number, requested procedure ID
//! and study instance UID) as defined by the IHE Radiology Technical Framework.
//!
//! The [`builder`] module writes messages: values are set structurally and
//! delimiter characters inside them are escaped, so what you build parses
//! back to what you set.
pub use Encoding;
pub use ;
pub use unescape;
pub use ;
pub use Path;