Expand description
Simple MLLP implementation
“The goal of the MLLP Message Transport protocol is to provide an interface between HL7 Applications and the transport protocol that uses minimal overhead.” (from HL7 Version 3 Standard: Transport Specification - MLLP, Release 2).
MLLP is a simple protocol used for transmitting HL7 messages between HL7 applications. It goes
like this <SB>...<EB><CR>
, where:
- SB is the Start Block Character, 0x0B.
- EB is the End Block Character, 0x1C.
- CR is the Carriage Return Character, 0x0D. This is called the Block Format.
MLLP contains 2 other formats, the Commit Acknowledgement
Block <SB><ACK><EB><CR>
, and the Negative Commit Acknowledgement Block <SB><NACK><EB><CR>
,
where:
- ACK is the acknowledgement character, 0x06.
- NAK is the negative-acknowledgement character, 0x15.
§Quick start
Client side code might look like this:
use std::io::prelude::*;
use std::net::TcpStream;
use mllp_rs::MllpCodec;
// Client side
let mut stream = TcpStream::connect("127.0.0.1:5000")?;
let _ = stream.write(MllpCodec::encode("MSH|^~\&|WIR|||36|20200514123930||VXU^V04^VXU_V04|43|P|2.5.1|||ER".as_bytes()).as_bytes());
Server side code might look like this:
use std::io::prelude::*;
use std::net::TcpListener;
use mllp_rs::MllpCodec;
let mut listener = TcpListener::bind(addr).unwrap();
for stream in listener.incoming() {
let mut buf: Vec<u8> = vec![];
let _ = stream?.read_to_end(&mut buf);
let decoded_data = String::from_utf8_lossy(MllpCodec::decode(buf.as_slice())?);
}