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
| How to create an application supporting multiple HL7 version using nHapi |
| Written by Division by Zero |
| Monday, 15 March 2010 14:37 |
|
This is a question I received. So, here's an example. I can't give a lot of code details, but I think a generic overview and description of a possible solution would help. First, let's take a look at a possible application design.
1. Network layer The first layer is the network handling. Of course this is application specific. The actual network handling probably is listening to a specific port on the network, receiving a single connection, receiving multiple and synchronous HL7 messages on this connection. Note: the messages will be send with MLLP. 2. Service layer The service layer will parse the HL7 message to a business object. In the image above this will be a "Person". First the complete message, still available as plain text, must be parsed to a nHapi message object. Here's an example: The IMessage object will give us enough information to determine which version of HL7 is used and what kind of message is received. I've used the factory design pattern twice in this example. First to get the right parser for the right HL7 version. The second is to get the right parser for this message. Now that we have the right message for the right version we can interpret the message and create our business object. This example shows you how to get the "display name" from the HL7 message. This is mostly a safe bet, but not always the right data. To really interpret the message in a right way you actually have to read the HL7 specs. And if you need to implement something like this example, reading the specs is a very good idea. 3. Other layers The other layers kinda speak for themselves. Now you have a business object you can perform any business operation needed for you application. The example inserts, updates or deletes a record in/from the database in order to keep the list of patients in sync with the central information system. Remember: this is a very basic and short example. HL7 is able to do a lot and has quite complex messages. But this is basically what you need to do for every messages. After you processed the message HL7 prescribes that you send an acknowledge message to tell the server that the message was processed correctly or not. See my post about ack/nack messages. If you have any questions or want to discuss something about this topic, please use this forum. Tags:
|
I think, therefore I am. - R. Descartes






Comments
If you have a more specific question, maybe I can help you with it. I certainly will try. You can post your question here if you'd like!
I didn't have much time, but I've posted a little example solution on this blog:
dib0.nl/.../132-nhapi-example
I hope it helps!
With the example I posted, you can do just that. It reads a message and is able to parse multiple HL7 versions (as an example the parsing of one message type of one version was supplied).
Using the IAck implementation for a specific version, you are able to create an Ack message for every HL7 version.
If you have any questions of run in to any problems, let me know. Maybe I can help you with them.
create ADT, ORU, and ORM message. I know hl7 version, eventCode (example 2.3 ADT_A01) and I want create interface to create hl7message for every version. In my application, I've database tables, Order and Order_position. I get data from this table and create message. I can read version, eventCode from this table. Have you got any suggestion ?
I think the best way is to use the factory pattern again, like the example I posted earlier. But now you start with the data from your database. With the version and event type the factory returns a hl7 specific parser (you'll have to write a specific parser for every hl7 version and event type). This parser returns an IMessage (from the nHapi library). This IMessage object you can parse to an actual message. Like this:
string version = "2.5";
string eventType = "ADT";
IMessageCreator creator = Hl7Factory.GetMessageCreat or(version, eventType);
IMessage hl7Message = creator.CreateMessage("Put you data here as a string or an object created on the data from the database");
// Parse the message to an actual hl7 messsage
PipeParser parser = new PipeParser();
string actualMessage = parser.Encode(hl7Messa ge);
There is a slightly more extensive example in the Quickstart Guide for nHapi, by Chad Chenoweth. You can download a copy from my site:
www.dib0.nl/.../nhapi_1_0.pdf
or a copy from a sourceforge mirror:
www.google.nl/.../
I hope this helps. If you have any more questions, please let me know.
Since there is no PID and OBX section in ORU_R01, I am not sure how I will have to attach these data segment into a message. Any help is appreciated.
Thanks,
The ORU_R01 message doesn't contain the PID and OBX segments directly. This is because it is possible to send more than one observationresu lt. If you use the Terser you can access the segments like this:
ORU_R01 msg = new ORU_R01();
Terser terser = new Terser(msg);
PID pid = (PID) terser.getSegment("/.PATIENT_RESULT/PATIENT/PID");
pid.AdministrativeS ex.Value = "M";
OBX obx = (OBX)terser.getSegment("/.PATIENT_RESULT/ORDER_OBSERVATI ON/OBSERVATION(0)/OBX");
obx.ObservationIden tifier.Identifier.Value = "1";
I hope this is helpful. If you have any questions or want an example (I need more time to create one) let me know!
I hope you will be able to help me out with this. Thanks a million:
Sample message:
MSH|^~\&|Application Name|Hospital Name||44|200006 23134511||ORU^R01|20000623134511135475|P|2.3
PID||12345678|69619||John^Smith|| 19550101|M
ORC|RE||||A
OBR|||144137|Report Name|||201002221034|||||||||||||| |201006281344|||F||||||Som e Study|472^LastN ame^FirstName
OBX|1|ED|REPORT_NAME ||Pdf Report Data
Terser terser = new Terser(msg);
//PID:
PID pid = (PID)terser.getSegment("/.PATIENT_RESULT/PATIENT/PID");
pid.AdministrativeS ex.Value = "M";
//OBX
OBX obx = (OBX)terser.getSegment("/.PATIENT_RESULT/ORDER_OBSERVATI ON/OBSERVATION(0)/OBX");
obx.ObservationIden tifier.Identifier.Value = "Report Name";
obx.ValueType.Value = "ED";
obx.SetIDOBX.Value = "1";
// Load the pdf file (report) and attach it as embedded data within OBX segment
string strFileName = "PdfReport.pdf";
string strEncodedpdf = string.Empty;
FileInfo fileInfo = new FileInfo(strFil eName);
if (fileInfo.Exists)
{
//Read file into strEncodedpdf
}
// How to attached 'strEncodedpdf' into OBX.5 segment ???
// Create a MLLP string
PipeParser p = new PipeParser();
string mllpMsg = (char)11+ p.Encode(msg) + (char)28+ (char)13;
It's kinda hard to explain how to add a PDf file to a HL7 message. To show you I've created a little demo solution. In this solution there is a HL7 V2.3 and a V2.4 example. There are multiple ways of creating and editing messages.
In the example you'll get two different ways to handle an ORU_R01 message. You can download the demo here: www.dib0.nl/.../oruexample.zip.
Good luck! I hope this will help you. Let me know if you have any more questions. And let me know if this did help you (always good to hear)!
I am going to work on the integrating my application. Once that works, I will post the result. But I expect the integration to go smooth.
OBX obx = (OBX)terser.getSegment("/.PATIENT_RESULT/ORDER_OBSERVATI ON/OBSERVATION(0)/OBX");
Where did you know the you should use:
"/.PATIENT_RESULT/ORDER_OBSERVATI ON/OBSERVATION(0)/OBX" ?
Now I am trying to modify other segments and I am stuck again.
Thanks for your help.
At first I apologize for this late reaction. I just found your previous post in my log-files. Somehow it didn't get through my security test. In the mean time the problems with comments are fixed, so I've added your comment.
Well It's all in the HL7 specs. They require some time to get to know them and learn how to read them. I believe the first introduction of the spec is a guide on how to read the rest of the specs.
You are able to get them at hl7.org (the international organization) or your local hl7 organization.
I need to parse ORU_R01 HL7 2.3.1 message and store the result in our SQL database.
Please guide me how to decode the lab result. thank you so much.
Thank you for your question. This kinda depends on what data you'll get and how you want to store it. Here's an example on how to get the data from the OBX segment:
NHapi.Base.Model.Varies v = msg.GetRESPONSE().GetORDER_OBSERV ATION(0).GetOBSERVATION( 0).OBX.GetObservationV alue(0);
NHapi.Model.V23.Datatype.ED ed = (NHapi.Model.V23.Datatype.ED)v.Data;
byte[] pdFileContent = Convert.FromBase64Strin g(ed.Data2.Value);
In the example you see that there are no repetitions here (this is an assumption). The actual data can be stored as different types. Here it is stored as a ED field. In this field all the information on the pdf (this is what I used) is stored as well as the form of encoding used.
I hope this will help you. If you have any questions, please let me know!
RSS feed for comments to this post