HL7 2.x parser and generator.
npm install hl7parser
HL7Parser is a CommonJS module for working with HL7 2.x messages.
* Installation
* Examples
* Documentation
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.
#### addSegment(path)
Adds a segment to the message.
__Parameters__
* path string - The name of the segment to add (e.g. "PID").
__Returns:__ Node
#### name
The name of the node.
__Type:__ string
#### length
The number of child nodes in the node.
__Type:__ number
#### get(path)
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
#### set(path, value)
Sets a child node at the given path.
__Parameters__
* path string - The path of the child node to set.any
* value - The value to set at the given path.
__Returns:__ void
#### exists(path)
Checks if a child node exists at the given path.
__Parameters__
* path string | number - That path to check.
__Returns:__ boolean
#### forEach(callback)
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
#### toString()
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
#### toRaw()
Returns the raw string representation of the node, including delimiters and escape sequences.
__Returns:__ string
#### toArray()
Returns all child nodes as an array.
__Returns:__ Node[]
#### isEmpty()
Returns true if the node is empty; otherwise, returns false.
__Returns:__ boolean
#### toDate()
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
#### toInteger()
Returns the value of the node as an integer.
__Returns:__ number
#### toFloat()
Returns the value of the node as a floating point number.
__Returns:__ number
#### toBoolean()
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
#### name
The name of the node.
__Type:__ string
#### length
The number of child nodes in the node.
__Type:__ number
#### get(path)
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
#### set(path, value)
Sets a child node at the given path.
__Parameters__
* path string - The path of the child node to set.any
* value - The value to set at the given path.
__Returns:__ void
#### exists(path)
Checks if a child node exists at the given path.
__Parameters__
* path string | number - That path to check.
__Returns:__ boolean
#### forEach(callback)
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
#### toString()
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
#### toRaw()
Returns the raw string representation of the node, including delimiters and escape sequences.
__Returns:__ string
#### toArray()
Returns all child nodes as an array.
__Returns:__ Node[]
#### isEmpty()
Returns true if the node is empty; otherwise, returns false.
__Returns:__ boolean
#### toDate()
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
#### toInteger()
Returns the value of the node as an integer.
__Returns:__ number
#### toFloat()
Returns the value of the node as a floating point number.
__Returns:__ number
#### toBoolean()
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
__Parameters__
* text string - Optional. The text to parse.
__Returns:__ Message`