Daily using/supporting

Get Firefox browser!
Get Thunderbird!
Get Opera browser!
Get The Gimp!
Get Inkscape!
Get LibreOffice!
Get Videolan!
Get Linux!
Get Mandriva!
Get Joomla!
Hacker Emblem

Archives

Which topics would you like us to cover more?

Latest comments

Latest tweets

about 1 day ago Using REDIPS.drag to add drag and drop to your .Net webapplication #li #dib0 http://t.co/n8zY3s7d
about 7 days ago http://t.co/cknQcDbo #Kindle
about 15 days ago Freedom isn't the ability to choose what to do or say, but the ability to choose what not to do or say #freedom
about 29 days ago http://t.co/61KTQknI #Kindle
12 Apr 2012 Force the use of a networking adapter using C# #li #dib0 http://t.co/ZTJOPzOz
9 Apr 2012 Mandriva 2010.2 and USB devices in Virtualbox http://t.co/fwq9gbHB
9 Apr 2012 Execute a http request to you own site with PHP http://t.co/DIvWPrpd
Home Architecture, security and coding Why nHapi sometimes parses a message as a generic message
Why nHapi sometimes parses a message as a generic message
Written by Division by Zero   
Tuesday, 08 March 2011 11:28

Sometimes while parsing a piped HL7 version 2.4 message with nHapi it parses the message as a generic message. Take the example application I used ina former post. To determine the right type of message I use the method GetStructureName() available on the IMessage interface. Normally this returns a string containing the segment structure available from the MSH-9-3 segment. With some of the test messages I got the GetStructureName() method returned the string 'GenericMessage+V24'. I've only seen this with version 2.4 messages, probably because the structure name can defer from the event name. The problem with this message is that it is impossible to cast to a strong type object, which is much easier to work with.

What happens? Well, the parser determines the structure of the message by reading the 9th segment of the message header. If it has three elements it returns the last element as the structure name and determines the message to be explicitly defined (this is the easy variant). If there are less than three elements the message is an Ack message, or a not explicitly defined message. In case of an Ack message, this will be returned. In the latter case a generic (not explicitly defined) message will be parsed.

For example. The following header will be parsed as a generic message:

MSH|^~\&|SomeApp||||20110215100411||SIU^S15|11873630|P^T|2.4|||AL|EN

To correct this, the MSH-9-3 segment must be added with the correct structure name, like this:

MSH|^~\&|SomeApp||||20110215100411||SIU^S15^SIU_S12|11873630|P^T|2.4|||AL|EN

This last message header will be able to be parsed explicitly. As you can see the event name and the structure name don't have to be the same. In the HL7 version 2.4 event structure there can be more events within one structure name.

 

Comments  

 
0 # RomanShade 2011-09-14 16:27
This doesn't work for me ... I added the third component, but it still returns GenericMessage+ V24 ... any other ideas that can cause this? I've verified the message is valid in HL7 Browser. I'm at a loss.
Reply | Reply with quote | Quote
 
 
+1 # Bas 2011-09-14 16:47
Hi RomanShade,

I'm sorry to hear that it doesn't solve your problem. Could you post the message header segment (MSH)? Maybe we can help you solve the problem.

Bas
Reply | Reply with quote | Quote
 
 
+1 # RomanShade 2011-09-14 21:19
I solved the problem ... sorta. The cause is the message event type (ADT_A08). Apparently, there is no implementation for an A08 in 2.4? If it's any other event type, A01, A03, etc., it works as expected.
Reply | Reply with quote | Quote
 
 
+2 # Bas 2011-09-15 08:36
Hi RomanShade,

HL7 version 2.4 differs from previous version. In 2.4 the A08 event is a kind of subtype of the ADT_A01 event.

The header should look like this:
MSH|^~&|SomeApp||||20110215100411||ADT^A08^ADT_A 01|11873630|P^T|2.4|||AL|EN

This way nHapi will parse the message as an ADT_A01 type object. If you have parsed is to an object you can do the following to get the 'sub-event':
string eventType = message.MSH.MessageType.TriggerEvent.Value;

This will result in "A08" with the header as described above.

So to parse the message do something like this (with the header as described above):
PipeParser hl7Parser = new PipeParser();
IMessage hl7Message = hl7Parser.Parse(message);
if (hl7Message.Version == "2.4")
{
if (hl7Message.Message.GetStructureNam e() == "ADT_A01")
{
ADT_A01 message = (ADT_A01) hl7Message;
// now you can determine if it's an A08 type
if (message.MSH.MessageType.TriggerEvent.Value == "A08")
{
// Do something with the A08 event
}
}
}

The ADT_A01 in version 2.4 contains different A?? events. For example A08, A01, A04 and A13. All these 'sub-events' use the same message structure. Of course, if you want to handle multiple types you have to rewrite the code I've posted here.

Hope this is helpfull!
Reply | Reply with quote | Quote
 
 
0 # RomanShade 2011-09-16 14:42
VERY helpful. Thank you sir!
Reply | Reply with quote | Quote
 
 
+1 # Bas 2011-09-16 15:02
Glad I could help! You're welcome! :lol:
Reply | Reply with quote | Quote
 
 
+1 # GeekMasterzero 2012-04-26 05:45
This also happen in v2.5 and 2.5.1 if you look at the file EventMap.properties it actually show that an A04 and A08 map to A01. this is because the code for nhapi has customised. you can use the solution above, or purchase the HL7 db's from HL7.org and regenerate the class's your self or you can clone the following files:
ADT_A01_INSURANCE.cs
ADT_A01_PROCEDURE.cs
ADT_A01.cs and find and replace "ADT_A01" with "ADT_A04" recompile and your done.
*Note*
if you purchase the the DB's these classes are not missing
Reply | Reply with quote | Quote
 
 
0 # Bas 2012-04-26 08:06
Hi GeekMasterZero,

Thank you for your input. This is a good solution for this problem. Of course that is if you have the budget. ;-)
Reply | Reply with quote | Quote
 

Add comment


Security code
Refresh

I think, therefore I am. - R. Descartes


© 2009 - 2012, Division by Zero

Template based on the empire template by joomlashack 

Valid XHTML 1.0 Strict  Valid CSS!  Creative Commons License
This work by Division by Zero is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Netherlands License.