Written by Evan Lucas
$ npm install --save nodengine-hl7
var hl7 = require('nodengine-hl7')
A Transform Stream
var hl7 = require('nodengine-hl7')
, Parser = hl7.Parser
error
emitted if an error occurs parsing a Segment
var fs = require('fs')
, parser = new Parser()
, fp = 'input.hl7'
var stream = fs.createReadStream(fp)
stream.pipe(parser)
parser.on('error', function(err) {
console.log('Error parsing:', err)
})
message
emitted every time a Message is encountered
messages
emitted at the end of the stream. This will be an array of Message objects.
var hl7 = require('nodengine-hl7')
, Message = hl7.Message
var message = new Message()
Name | Type(s) | Description |
---|---|---|
segments | Array, Segment | A single Segment or and array of Segments |
returns true if the Message has any Segments
var message = new Message()
, seg = new Segment(...)
message.addSegment(seg)
Name | Type(s) | Description |
---|---|---|
segment | Segment | The Segment to add to the Message |
returns the header Segment of the message
returns the delimiters for this Message
Defaults to:
{
segment: '\r',
field: '|',
component: '^',
subcomponent: '&',
repetition: '~',
escape: '\\'
}
var hl7 = require('nodengine-hl7')
, Segment = hl7.Segment
var segment = new Segment()
Name | Type(s) | Description |
---|---|---|
data | String, Buffer | The segment data |
delimiters (optional) | Object | The Message delimiters |
Note: the delimiters do not need to be passed if the message is a header segment
returns an Array of the fields in the segment
returns true if the segment is a Message Header Segment (MSH, FSH, BHS)
returns the segment type
Name | Type(s) | Description |
---|---|---|
variant | Object | The variant segment |
The variant segment must contain a name
key which specifies the variant name and the fields
key which is an Array of the field names to use
var hl7 = require('nodengine-hl7')
, Segment = hl7.Segment
var variant = {
name: 'ADD',
fields: [
'SegmentType',
'AddendumContinuationPointer',
'SendingApplication'
]
}
Segment.registerVariant(variant)
All registered Segment Types. Currently, the available segments are: