JSPM

hl7js-grammar

0.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 24
  • Score
    100M100P100Q91095F
  • License MIT

Node.js Parser for HL7 Grammar

Package Exports

  • hl7js-grammar

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (hl7js-grammar) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

hl7js-grammar

HL7 Grammar Parser(hl7js compatible) for Node.js

Installation

install via NPM:

npm install hl7js-grammar

Usage

Initializing:

var parser = require('hl7js-grammar');

reader.read(expression, callback)

/// Basic Parsing
/// Ref: http://www.interfaceware.com/blog/hl7-segment-grammar-notation/
var grSimple = 'MSH PID NK1 PV1';
var grOptional = 'MSH PID NK1 PV1 [PV2]';
var grMultiple = 'MSH PID {NK1} PV1 [PV2]';
var grOptionalMultiple = 'MSH PID [{NK1}] PV1 [PV2]';
var grGroup = 'MSH PID [{OBR {OBX}}]';

var expression = grGroup;
parser.parse(expression, function (err, grammar) {
    console.log(err);

    console.log('ip: ', expression);
    console.log(JSON.stringify(grammar));
});

/// Prints the following
/// ip:  MSH PID [{OBR {OBX}}]
/// [{"id":"MSH","required":true},{"id":"PID","required":true},{"id":"OBR","required":false,"isArray":true,"isGroup":true,"grammar":[{"id":"OBX","required":true,"isArray":true}]}]

Output format

Output is compatible to be used with hl7js

/// Format
var grammar = [
{
    id: 'Segment_ID',
    required: true,
    isGroup: true,
    isArray: true,

    grammar: [
    ]
];

/// Example
var oruGrammar = [
    {
        id: 'MSH',
        required: true
    },
    {
        id: 'PID',
        required: true
    },
    {
        id: 'OBR',
        required: true,
        isGroup: true,
        isArray: true,

        grammar: [
            {
                id: 'OBX',
                required: true,
                isArray: true
            }
        ]
    }
];

Contributions

Contributions are welcome

Issues

Please file your issues here: