Skip to main content

parse_mllp

Function parse_mllp 

Source
pub fn parse_mllp(bytes: &[u8]) -> Result<Message, Error>
Expand description

Parse HL7 v2 message from MLLP framed bytes.

This function first removes the MLLP framing and then parses the message.

§Arguments

  • bytes - The MLLP-framed HL7 message bytes

§Returns

The parsed Message, or an error if parsing fails

§Example

use hl7v2_parser::parse_mllp;
use hl7v2_mllp::wrap_mllp;

let hl7 = b"MSH|^~\\&|SendingApp|SendingFac|ReceivingApp|ReceivingFac|20250128152312||ADT^A01|ABC123|P|2.5.1\r";
let framed = wrap_mllp(hl7);
let message = parse_mllp(&framed).unwrap();
assert_eq!(message.segments.len(), 1);