Git Product home page Git Product logo

hl7parser's Introduction

Build Status

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

hl7parser's People

Contributors

meirgottlieb avatar jorinvo avatar richard-mihalovic avatar

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.