S h o r t S t o r i e s

// Tales from software development

Archive for the ‘HL7’ Category

NHapi bug: OBX-5 repetitions not handled correctly

with 4 comments

Recently I stumbled across a bug in NHapi in which the second and further repetitions of an OBX-5 field are not correctly processed. It’s surprising that this bug hasn’t been noticed before as it appears to have been there from the start.

The Varies class in NHapi.Base.Model implements a method called fixOBX5() which instantiates an NHapi HL7 data type instance of the type specified in OBX-2 for each repetition in the OBX-5 and stores it in the data property of the Varies instance associated with the repetition.

Unfortunately, fixOBX5() is written in such a way that only the first repetition is processed. This means that the data property of the Varies instance for the first repetition will be correctly set to an instance of the type specified in OBX-2 (e.g. TX, CE, NM, SN, etc) but the subsequent repetitions, if any, won’t.

The problem has been logged on CodePlex, the new home (as of April 2014) for NHapi.

I’ve also forked the NHapi source, fixed the bug, and sent the NHapi team a pull request so that they can incorporate the fix.

 

Advertisements

Written by Sea Monkey

August 19, 2014 at 8:00 pm

Posted in HL7

Tagged with

Line endings in HL7 messages

leave a comment »

Despite working with HL7 messages for several years I got caught out by what type of line endings to use when constructing an HL7 message.

I should point out that this is usually handled by the API or integration engine being used but I just needed a message file that I could throw at an MLLP Sender to test it. I remembered that the line endings were not Windows style CR/LF (0x0D/0x0A) and assumed it was UNIX style LF (0x0A) only to find that the message processor at the other end of the MLLP connection failed to parse the message correctly.

I checked the HL7 specifications and was surprised to find that the segment separator character is not 0x0A as you might expect but 0x0D.

So, if you want to think of segment separators as line ends, this corresponds to the old Mac line end style rather than UNIX.

Written by Sea Monkey

February 3, 2014 at 7:00 pm

Posted in Development, HL7

Tagged with ,