Skip to content

hitgeek/hl7-dictionary

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hl7-dictionary

stable NPM

HL7-dictionary contains definitions of messages, segments, fields and tables from the following versions:

  • 2.1
  • 2.2
  • 2.3
  • 2.3.1
  • 2.4
  • 2.5
  • 2.6.1
  • 2.7
  • 2.7.1

Install

Install via NPM:

$ npm install hl7-dictionary

Or get a browserified packaged source file:

Usage

To include the whole definitions and tables you just simple import the module:

var HL7Dictionary = require('hl7-dictionary');

// Access definition 2.4
console.log(HL7Dictionary.definitions['2.4'].messages['ACK'].desc);
-> General Acknowledgment

// Access table for administrative sex
console.log(HL7Dictionary.tables['1'].values['F'];
-> Female

You can include a definition in your code using the following:

require('hl7-dictionary').definitions['2.3'];

Definitions

Every definition includes messages, segments and fields in the same object:

var HL7Definition2_3 = require('hl7-dictionary').definitions['2.3'];

console.log(HL7Definition2_3);
{
    'messages': ...
    'segments': ...
    'fields': ...
}

Messages

The attribute messages from the definition is an object with message ID as key and message definition as content. A message included a description and is composed of several segments. Each segment has the following attributes:

  • name: The attribute name (Three capital letters)
  • desc: Description of this segment
  • min: Minimum number of appareances of this segment in the message (See cardinality)
  • max: Maximun number of appareances of this segment in the message, 0 for unbound. (See cardinality)
  • children (optional): The message may include children segments and they're included in this attribute as an array of segments, the same way they're included in the message.segments attribute.
  • compounds (optional): While the children attribute defines a sequence of segments that could/must be include in the same order (depending on their cardinality) the compound attribute defines a set of segments as choices to be allowed in the same position.

Example for simple ACK in 2.7

console.log( HL7Definition.definitions['2.7'].messages['ACK'] );

"ACK": {
    "desc": "General acknowledgment message",
    "segments": {
        "desc": "General acknowledgment message",
        "segments": [
            {
                "name": "MSH",
                "desc": "Message header",
                "min": 1,
                "max": 1
            },
            {
                "name": "MSA",
                "desc": "Message acknowledgment",
                "min": 1,
                "max": 1
            },
            {
                "name": "ERR",
                "desc": "Error",
                "min": 0,
                "max": 1
            }
        ]
    }
}

A more complex definition, that includes children and compound attributes:

"ORM_O01": {
    "desc": "Order message",
    "segments": {
        "desc": "Order message",
        "segments": [
            {
                "name": "MSH",
                "desc": "Message header",
                "min": 1,
                "max": 1
            },
            {
                "name": "NTE",
                "desc": "Notes and comments",
                "min": 0,
                "max": 0
            },
            {
                "name": "PATIENT",
                "desc": "Patient",
                "min": 0,
                "max": 1,
                "children": [
                    {
                        "name": "PID",
                        "desc": "Patient identification",
                        "min": 1,
                        "max": 1
                    },
                    {
                        "name": "NTE",
                        "desc": "Notes and comments",
                        "min": 0,
                        "max": 0
                    },
                    {
                        "name": "PV1",
                        "desc": "Patient visit",
                        "min": 0,
                        "max": 1
                    }
                ]
            },
            {
                "name": "ORDER",
                "desc": "Order",
                "min": 1,
                "max": 0,
                "children": [
                    {
                        "name": "ORC",
                        "desc": "Common order",
                        "min": 1,
                        "max": 1
                    },
                    {
                        "name": "ORDER_DETAIL",
                        "desc": "Order detail",
                        "min": 0,
                        "max": 1,
                        "children": [
                            {
                                "name": "OBR,ORO,RX1",
                                "desc": "Details",
                                "min": 0,
                                "max": 0,
                                "compounds": [
                                    {
                                        "name": "OBR",
                                        "desc": "Observation request",
                                        "min": 1,
                                        "max": 1
                                    },
                                    {
                                        "name": "ORO",
                                        "desc": "Order other",
                                        "min": 1,
                                        "max": 1
                                    },
                                    {
                                        "name": "RX1",
                                        "desc": "Pharmacy order",
                                        "min": 1,
                                        "max": 1
                                    }
                                ]
                            },
                            {
                                "name": "NTE",
                                "desc": "Notes and comments",
                                "min": 0,
                                "max": 0
                            },
                            {
                                "name": "OBSERVATION",
                                "desc": "Observation",
                                "min": 0,
                                "max": 0,
                                "children": [
                                    {
                                        "name": "OBX",
                                        "desc": "Observation/Result",
                                        "min": 1,
                                        "max": 1
                                    },
                                    {
                                        "name": "NTE",
                                        "desc": "Notes and Comments (for Results)",
                                        "min": 0,
                                        "max": 0
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "name": "BLG",
                        "desc": "Billing",
                        "min": 0,
                        "max": 1
                    }
                ]
            }
        ]
    }
}

Segments

A segment consist of several fields. Each field has the following attributes:

  • datatype: Data type stored in this field
  • desc: Description
  • len: Maximum length of the field
  • opt:
    • 0: Optional
    • 1: Required
    • 2: Conditional
    • 2: Backward compatibility
  • rep:
    • 0: Repeatable (Unbound)
    • 1: Just one
    • N: Less or equal N
  • table (Optional): The reference (ID) of the table with the allowed values for this field.

Example of ACC (Accident) segment in 2.1:

console.log( HL7Dictionary.definitions['2.1'].segments['ACC'] );

"ACC": {
    "desc": "Accident",
    "fields": [
        {
            "datatype": "TS",
            "desc": "Accident date / time",
            "len": 26,
            "opt": 1,
            "rep": 1,
        },
        {
            "datatype": "ID",
            "desc": "Accident code",
            "len": 2,
            "opt": 1,
            "rep": 1,
            "table": 50
        },
        {
            "datatype": "ST",
            "desc": "Accident location",
            "len": 25,
            "opt": 1,
            "rep": 1,
        }
    ]
}

Fields

Some fields datatype are composed of several simple datatypes. Each complex datatype includes a list of subfields

  • datatype: Data type stored in this field
  • desc: Description
  • len: Maximum length of the field
  • opt:
    • 0: Optional (O)
    • 1: Required (R)
    • 2: Conditional
    • 2: Backward compatibility
  • rep:
    • 0: Repeatable (Unbound)
    • 1: Just one
    • N: Less or equal N
  • table (Optional): The reference (ID) of the table with the allowed values for this field.

Example of the EI field in the 2.4

console.log( HL7Dictionary.definitions['2.4'].fields['EI'] );

{
    "desc": "Entity Identifier",
    "subfields": [
        {
            "datatype": "ST",
            "desc": "Entity Identifier",
            "opt": 1,
            "rep": 1
        },
        {
            "datatype": "IS",
            "desc": "Namespace ID",
            "opt": 1,
            "rep": 1,
            "table": 300
        },
        {
            "datatype": "ST",
            "desc": "Universal ID",
            "opt": 1,
            "rep": 1
        },
        {
            "datatype": "ID",
            "desc": "Universal ID Type",
            "opt": 1,
            "rep": 1,
            "table": 301
        }
    ]
}

Cardinality

The cardinality is based on the minand max attributes:

min max count
0 0 (unbound) 0..*
0 1 0..1
1 0 (unbound) 1..*
1 1 1
0 N 0..N

Tables

Predefined tables help to validate the allowed values for encoded fields.

console.log( HL7Dictionary.tables[1] ); 

{
    "desc": "Administrative Sex",
    "values": {
        "A": "Ambiguous",
        "F": "Female",
        "M": "Male",
        "N": "Not applicable",
        "O": "Other",
        "U": "Unknown"
    }
}
console.log( HL7Dictionary.tables[1].values["F"] ); 

"Female"

License

MIT, see LICENSE.md for details.

Copyright

Copyright 2015 Fernando Serrano [email protected]

About

HL7 Dictionary in javascript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%