npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nikklassen/hl7parser

v0.2.2

Published

HL7 2.x parser and generator.

Downloads

6

Readme

Build Status

Forked from hl7parser

HL7Parser

HL7Parser is a CommonJS module for working with HL7 2.x messages.

Table of contents

Installation

HL7Parser can be installed using npm:

$ npm install hl7parser --save

Examples

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.

Documentation

"hl7parser" Module


Message Interface


An HL7 message.

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.
  • value any - 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

Node Interface


A node in an HL7 message. Can represent a message, segment, field, component, or sub-component.

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.
  • value any - 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

create(text)

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