Joining the Open Source Software (OSS) Community

Jesse Reynolds
Iron Bridge Open Interoperability
3 min readOct 1, 2019

Iron Bridge, like many other companies, has gained so much from open source software that we have decided to join the community by contributing one of our internally used modules, “hl7-standard”. This healthcare data focused module is javascript based and can be used as a stand-alone javascript library, installed into a nodejs environment, or imported into applications like Mirth to simplify complex HL7 data transformations.

After searching far and wide for an HL7 parser that fit our environmental needs, we decided it would be best to build our own. After many years of internal use, we feel our library ‘hl7-standard’ can be shared with the healthcare community.

You can find the source code and documentation here: https://github.com/ironbridgecorp/hl7-standard.

We wish to collaborate with like-minded individuals in the healthcare ecosystem who share our vision and goal. Please join us on our ‘hl7-standard’ gitter channel https://gitter.im/hl7-standard/community.

Roadmap of Iron Bridge Open Source Projects

  • hl7-standard
  • edi-standard
  • fhirify

Get Started with “hl7-standard”

Before we get started with ‘hl7-standard’, we are going to assume you have nodejs installed, if you do not check out: https://nodejs.org/en/. Alternatively, you can run this example and more on our live playground here: https://developer.nuvolahub.com/#/opensource/hl7-standard/examples.

Let’s start by creating a new directory and installing the library:

> mkdir example_project/ 
> cd example_project/
> npm install hl7-standard

Now let’s create a test file, call it example.js, and add the follow logic to give us access to the filesystem and “hl7-standard”:

const fs = require('fs');
const HL7 = require('hl7-standard');

Now we are ready to work with the library. Today we are going to build up a simple HL7 message (ADT) from scratch. To do that, we are going to be primarily using the set method. To view all methods, check out the github docs. We will building our message by creating our MSH segment and mapping values to it.

let hl7 = new HL7();
hl7.createSegment('MSH');
hl7.set('MSH', {
'MSH.2': '^~\\&',
'MSH.3': 'Example',
'MSH.4': '123456',
'MSH.5': '',
'MSH.6': '',
'MSH.7': new Date(),
'MSH.8': '',
'MSH.9': {
'MSH.9.1': 'ADT',
'MSH.9.2': 'A08'
},
'MSH.10': '',
'MSH.11': 'T',
'MSH.12': '2.3'
});

Notice how we just mapped the entire MSH segment in one step, pretty neat huh? Well we can set a single field as well:

hl7.createSegment('EVN');
hl7.set('EVN.1', 'A08');

What about repeating fields? Let’s set up multiple patient addresses to show how this can be handled:

hl7.createSegment(‘PID’);hl7.set('PID.3.1', '312312');
hl7.set('PID.5', {
'PID.5.1': 'Wick',
'PID.5.2': 'John'
});
hl7.set('PID.7.1', '19670822');
hl7.set('PID.8.1', 'M');
hl7.set('PID.11', [{
'PID.11.1': '123 Example Rd',
'PID.11.2': '',
'PID.11.3': 'Pittsburgh',
'PID.11.4': 'PA',
'PID.11.4': '15226',
'PID.11.5': 'USA'
}, {
'PID.11.1': '321 Sample St',
'PID.11.2': '',
'PID.11.3': 'Pittsburgh',
'PID.11.4': 'PA',
'PID.11.4': '15317',
'PID.11.5': 'USA'
}]);

Finally, after we create a few more segments following the same pattern, we can write that file to our project to export the result. We do this with the fs module. To get hl7 out of our hl7-standard library, we call the build method:

let result = hl7.build();
fs.writeFileSync(‘/example_project/output.hl7’, result, ‘utf8’);

And that’s it! The new hl7 message can be sent on its way. If you want to see this in action, head over to our live playground and have some fun.

In the upcoming weeks, be on the lookout for “hl7-standard” how to’s, including:

  • Processing large HL7 batch messages
  • Utilizing ‘hl7-standard’ within AWS Lambda
  • Transforming HL7 to FHIR

Learn more about Iron Bridge at https://www.ironbridgecorp.com

--

--