HL7 Minimum Lower Layer Protocol (MLLP) implementation for Node.js.
This effort is a work-in-progress and should not be used for production or clinical purposes.
npm install hl7-mllp
npm install
npm run build
const hl7Mllp = require('hl7-mllp');
const { Client, Hl7Message } = hl7Mllp;
const client = new Client();
const hl7Message = new Hl7Message(
`MSH|^~\&|SENDINGAPP|SENDINGFACILITY|RECEIVINGAPP|RECEIVINGFACILITY|200001010000||ADT|1234567890|D|2.2|
PID||123456^^^2^ID 1|654321||DOE^JOHN^^^^|DOE^JOHN^^^^|19480203|M|`
);
hl7Message.on('acknowledge', (ackMessage) => {
console.log(ackMessage.toString());
});
client.addMessage(hl7Message);
client.send('127.0.0.1', 12345);
const hl7Mllp = require('hl7-mllp');
const { Server, Hl7Message, Hl7MessageHandler } = hl7Mllp;
class Hl7MllpMessageHandler extends Hl7MessageHandler {
constructor(socket, opts) {
super(socket, opts);
}
// Handle incoming messages
onMessage(message, callback) {
console.log(message.toString());
callback(Hl7Message.createAcknowledgeMessage(message));
}
}
const server = new Server(Hl7MllpMessageHandler);
server.on('networkError', (e) => {
console.log('Network error: ', e);
});
server.listen(port);
// When done
server.close();
hl7-mllp is released under the MIT License.