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 🙏

© 2026 – Pkg Stats / Ryan Hefner

hl7v2-dictionary

v2.3.6

Published

HL7 v2.1 to v2.9 definitions - segments, data types, message structures, tables - for NodeJS

Readme

hl7v2-dictionary

The definitions of HL7 v2.1 to v2.9, generated from HL7's own v2 XML schemas: every segment and its fields, every data type and its components, every message structure and its groups, and HL7's tables - with named positions for every field, and TypeScript types for every version.

NPM Version NPM Downloads CI Tests Test Coverage

hl7v2 reads, writes and validates messages by them.

Upgrading from 1.x? Version 2 changes how values are read and written and adds type checks for typed messages - see Migrating from v1 to v2.

Installation

npm install hl7v2-dictionary

Node.js 22 or later; ES modules, TypeScript types included.

Usage

import { dictionaries, PIDSegment, XPNType } from 'hl7v2-dictionary';

const dict = dictionaries['2.5'];

dict.segments.PID.fields[PIDSegment.PatientName];
// { type: 'XPN', desc: 'Patient Name', opt: 'R', rep: 'infinite', len: 250, table: 200, item: 108 }

dict.types.XPN.fields[XPNType.GivenName]; // { type: 'ST', desc: 'Given Name', ... }
dict.messages.ORU_R01.segments.PATIENT_RESULT; // a group of the structure
dict.tableValue(1, 'F'); // 'Female'

A site's own definitions

const site = dictionaries['2.5'].extend({
  segments: { ZPI: { fields: { 1: { type: 'ST', desc: 'Nickname', opt: 'O' } } } },
  tables: { 1: { values: { X: 'Non-binary' } } },
});
// HL7Message.parse(text, { dictionaries: { '2.5': site } })

What it holds

  • 14 versions: 2.1, 2.2, 2.3, 2.3.1, 2.4, 2.5, 2.5.1, 2.6, 2.7, 2.7.1, 2.8, 2.8.1, 2.8.2, 2.9 - each as HL7 defines it: a field the version withdrew is absent, a data type is the version's own.
  • Message structures with their groups, choices and repeating segments; a trigger event is its structure's definition (ADT_A04 is ADT_A01); a group lists the names other versions give it.
  • Field attributes: data type, optionality, repetition, lengths (maximum, minimum, conformance), truncation, table, HL7 element number.
  • HL7's tables and their values.
  • Field enums - PIDSegment.PatientName, XPNType.GivenName - for every segment and data type of every version.
  • TypeScript types for every version's segments, data types and message structures - types only.
  • Value codecs for dates, times and numbers - checking HL7's forms, keeping values as written.

Built the first time a version is used; definitions shared between versions and frozen, changed through extend().

Documentation

Node Compatibility

  • node >= 22.x

License

Available under the BSD 3-Clause license. The HL7 v2 XML schemas the data is generated from are licensed by HL7 and are not part of this package's source.