GithubHelp home page GithubHelp logo

pantelisgeorgiadis / hl7-mllp Goto Github PK

View Code? Open in Web Editor NEW
9.0 1.0 1.0 520 KB

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

License: MIT License

JavaScript 90.73% TypeScript 9.27%
hl7 mllp

hl7-mllp's Introduction

NPM version 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.

hl7-mllp's People

Contributors

pantelisgeorgiadis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

rgensor3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.