Skip to content

HL7 Minimum Lower Layer Protocol (MLLP) implementation for Node.js

License

Notifications You must be signed in to change notification settings

PantelisGeorgiadis/hl7-mllp

Repository files navigation

NPM version NPM downloads build MIT License

hl7-mllp

HL7 Minimum Lower Layer Protocol (MLLP) implementation for Node.js.

Note

This effort is a work-in-progress and should not be used for production or clinical purposes.

Install

npm install hl7-mllp

Build

npm install
npm run build

Examples

Client

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);

Server

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();

License

hl7-mllp is released under the MIT License.

About

HL7 Minimum Lower Layer Protocol (MLLP) implementation for Node.js

Topics

Resources

License

Stars

Watchers

Forks