Archives
- ► 2012 (8)
- ► 2011 (157)
- ► 2010 (174)
- ► 2009 (12)
Which topics would you like us to cover more?
Latest comments
- How to reset you Kindle
3, eve...
Thanks for this article and the related "Inside th...
By H K - How to reset you Kindle
3, eve...
How do you drain power on the board? I dont have r...
By Grace - How to reset you Kindle
3, eve...
You're welcome!
By Bas - How to reset you Kindle
3, eve...
Thanks man....removing the battery worked like a c...
By DaveMan - nHapi
example
Hi Slypete, Thank you for your comment. This way w...
By Bas - nHapi
example
Hello, Employing .Net dynamics, one can implement ...
By slypete - Implementing MLLP in C#
Hi Mayura, I'm not sure I understand your question...
By Bas - Implementing MLLP in C#
I have used SSL stream to secure the MLLP transact...
By Mayura
Latest tweets
| 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. |
I think, therefore I am. - R. Descartes





Comments
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
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!
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
Thank you for your input. This is a good solution for this problem. Of course that is if you have the budget.
RSS feed for comments to this post