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
//! HL7 v2 message normalization.
//!
//! This module provides normalization for raw HL7 v2 bytes by parsing and
//! writing messages in a consistent format. Optionally, delimiters can be
//! rewritten to canonical HL7 delimiters (`|^~\&`).
//!
//! # Example
//!
//! ```
//! use hl7v2::normalize;
//!
//! let hl7 = b"MSH|^~\\&|SendingApp|SendingFac|ReceivingApp|ReceivingFac|20250128152312||ADT^A01|ABC123|P|2.5.1\r";
//! let normalized = normalize(hl7, true).unwrap();
//! assert!(normalized.starts_with(b"MSH|^~\\&|"));
//! ```
use crate;
use crateparse;
use cratewrite;
/// Normalize HL7 v2 bytes.
///
/// The message is parsed and rewritten using `hl7v2::writer`. When
/// `canonical_delims` is `true`, the output message delimiters are rewritten
/// to canonical HL7 delimiters (`|^~\&`).
///
/// # Errors
///
/// Returns an error when the input bytes cannot be parsed as an HL7 v2 message.