Git Product home page Git Product logo

hl7js's Introduction

hl7js (Beta)

Node.js package for parsing and writing HL7 files

Installation

install via NPM:

npm install hl7js

Usage

Initializing Reader:

var Reader = require('hl7js').Reader;
var reader = new Reader();

reader.read(buffer, callback)

/// Basic Parsing
var reader = new Reader('BASIC');
fs.readFile(hl7_file_path, function (err, buffer) {

    reader.read(buffer.toString(), function (err, hl7Data) {
        console.log(err);
        console.log(hl7Data);
    });
});

Reading With Grammar

reader.read(buffer, grammarExpression, callback)

fs.readFile(hl7_file_path, function (err, buffer) {

    reader.read(buffer.toString(), 'MSH PID [{OBR {OBX}}]', function (err, hl7Data, hl7Json) {
            console.log(err);

            if (!err) {
                var patientName = hl7Json['PID'][5]; /// Similar pattern: hl7Json['PID'].fields[5].value ==> For advanced usage
                console.log('ORU->Patient name: ', patientName);
            }
    });
});

Reading header fields

var messageType = hl7Data.mshSegment.messageType;

Reading patient name

var patientName = hl7Json['PID'][5];
/// (or)
var patientName = hl7Json['PID'].fields[5].value;

Initializing Writer: (Alpha version)

var Writer = require('hl7js').Writer;

/// Initializing writer with default delimiters
var writer = new Writer();
/// Initializing writer with user defined delimiters
var writer = new Writer({
    lineSeparator: '0xD 0xA',
    framePrefix: '',
    frameSuffix: '',
    fieldSeparater: '|',
    componentSeparater: '^',
    fieldRepeatSeparater: '~',
    escapeCharacter: '\\',
    subComponentSeparater: '&'
});

writer.addHeader(options) - adding MSH

writer.addHeader({
    sendingApplication: 's_app',
    sendingFacility: 'a_facility',
    receivingApplication: 'r_app',
    receivingFacility: 'r_facility',
    dateTimeOfMessage: 'dt',
    security: '',
    messageType: 'ADT^A01',
    messageControlId: '123',
    processingId: '',
    versionId: '2.5',
    sequenceNo: '',
    continuationPointer: '',
    acceptAckType: '',
    applicationAckType: '',
    countryCode: '',
    characterSet: '',
    messageLanguage: ''
});

writer.addSegment(segmentId [, dataArray]) - Adding Other segments

writer.addSegment('PID', ['name', 1, 2, ['lname', 'fname'], 'eee']);
writer.addSegment('IN1', ['1']);
writer.addSegment('IN2');

writer.toString() - Reads HL7 Text

var hl7Text = writer.toString();
console.log(hl7Text);

Contributions

Contributions are welcome

Issues

Please file your issues here:

hl7js's People

Contributors

rameshr avatar rameshrr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

hl7js's Issues

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.