Blog of Gonzalo Brusella

The personal blog of a developer on the loose

I am not a person who loves to leave all things unfinished. This is no exception.

A while ago, I started blogging about how to work with HL7 in an easy way. I had to deal with it and I can guarantee you, my reader, that in some cases is not an easy task. On the first part I wrote about the structure of an HL7 message; now is time to handle this message in a systemic way (aka: developing).

While you have integration suites (I remember a few: Microsoft’s BizTalk, Oracle’s Fussion, SAP PI, etc.), some times you don’t need a über product for getting the job done. Sometimes it is perfect to write your-own-and-very-flexible code.

After googling a while, I found a little jewel for us developers. HAPI for Java developers and NHAPI for .Net ones. The original project is the Java one, so if you need some documentation you should go to the source project.

Now you got the essentials. It is time to show you some code, but first a little of context.

Recently I had to deal with the validation of affiliates to a Health Care company. This company uses HL7 internally. Also this company does not let you to contact them directly, you must use a carrier (another company who gets your message and, after validating it sends the data in HL7 format to the Health Care company). Some of this carriers asks for a plain (and proprietary) text file format to communicate with them, sometimes they expose an HL7 interface (Kudos from me to them).

Luckily for me in Argentina a long time ago there was an agreement (I don’t remember how I got this info, but it’s true) among the Carriers and the Health Care Companies to standardize the HL7 format for several operations (among others, the operations I needed to do).

HL7 Note: In reference to HL7, the protocol aims to create new customized messages types when those provided by the norm does not fit the business need. These messages are called Z messages. The Z messages can contain Z segments and Z groups, and all are locally defined by norm, so you can end up with a colliding set of HL7 Z elements (the same name of Z message/segment/group but different internal definition). In a nutshell: a nightmare.

Both HAPI and NHAPI are open source libraries and I choose NHAPI for the samples because I already have some code made on it.

Let’s define a new Z Segment:

Show the code

Let’s define a new Z Message:

Show the code

Note: This is not the original post. I had to modify it to avoid futher problems with a previous employer. Feel free to contact me for any HL7 questions you may have.


Posted by gbrusella On October - 14 - 2009 Development

Comments are closed.