HL7Parser is a CommonJS module for working with HL7 2.x messages.
HL7Parser can be installed using npm:
$ npm install hl7parser --save
Parse an HL7 message.
var hl7parser = require("hl7parser");
var message = hl7parser.create("MSH|^~\&|||||20121031232617||ADT^A04|20381|P|2.3||||NE\rEVN|A04|20121031162617||01\rPID|1|16194|16194||Jones^Bob");
console.log(message.get("PID.5.2").toString()); // prints "Bob"
See the tests for more examples.
An HL7 message.
addSegment
name
length
get
set
exists
forEach
toString
toRaw
toArray
isEmpty
toDate
toInteger
toFloat
toBoolean
Adds a segment to the message.
Parameters
- path
string
- The name of the segment to add (e.g. "PID").
Returns: Node
The name of the node.
Type: string
The number of child nodes in the node.
Type: number
Gets a child node with the given path.
Parameters
- path
string | number
- The path of the child node to retrieve. The path can be a number or string. If the path is a number, then child node at the specified index is returned.
Returns: Node
Sets a child node at the given path.
Parameters
- path
string
- The path of the child node to set. - value
any
- The value to set at the given path.
Returns: void
Checks if a child node exists at the given path.
Parameters
- path
string | number
- That path to check.
Returns: boolean
Iterates through all child nodes, calling the callback for each node. Similar to Array.forEach.
Parameters
- callback - The function to call for each child node.
Returns: void
Returns a string representation of the node. If the node has child nodes then the raw representation of the node is returned; otherwise, the value of the node is returned with escape sequences resolved.
Returns: string
Returns the raw string representation of the node, including delimiters and escape sequences.
Returns: string
Returns all child nodes as an array.
Returns: Node[]
Returns true if the node is empty; otherwise, returns false.
Returns: boolean
Returns the value of the node as a date. If the length of the string is exactly 8, the value is parsed using the format YYYYMMDD. If the length of the string is >= 14, the value is parsed using the format YYYYMMDDHHMMSS.
Returns: Date
Returns the value of the node as an integer.
Returns: number
Returns the value of the node as a floating point number.
Returns: number
Returns the value of the node as a boolean. A value of "Y" is returned as true. A value of "N" is returned as false. All other values return null.
Returns: boolean
A node in an HL7 message. Can represent a message, segment, field, component, or sub-component.
name
length
get
set
exists
forEach
toString
toRaw
toArray
isEmpty
toDate
toInteger
toFloat
toBoolean
The name of the node.
Type: string
The number of child nodes in the node.
Type: number
Gets a child node with the given path.
Parameters
- path
string | number
- The path of the child node to retrieve. The path can be a number or string. If the path is a number, then child node at the specified index is returned.
Returns: Node
Sets a child node at the given path.
Parameters
- path
string
- The path of the child node to set. - value
any
- The value to set at the given path.
Returns: void
Checks if a child node exists at the given path.
Parameters
- path
string | number
- That path to check.
Returns: boolean
Iterates through all child nodes, calling the callback for each node. Similar to Array.forEach.
Parameters
- callback - The function to call for each child node.
Returns: void
Returns a string representation of the node. If the node has child nodes then the raw representation of the node is returned; otherwise, the value of the node is returned with escape sequences resolved.
Returns: string
Returns the raw string representation of the node, including delimiters and escape sequences.
Returns: string
Returns all child nodes as an array.
Returns: Node[]
Returns true if the node is empty; otherwise, returns false.
Returns: boolean
Returns the value of the node as a date. If the length of the string is exactly 8, the value is parsed using the format YYYYMMDD. If the length of the string is >= 14, the value is parsed using the format YYYYMMDDHHMMSS.
Returns: Date
Returns the value of the node as an integer.
Returns: number
Returns the value of the node as a floating point number.
Returns: number
Returns the value of the node as a boolean. A value of "Y" is returned as true. A value of "N" is returned as false. All other values return null.
Returns: boolean
Creates a new HL7 message. If the message text is not specified, an empty HL7 message is created.
Parameters
- text
string
- Optional. The text to parse.
Returns: Message