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 Getting data from a HL7 ORU_R01 message
Getting data from a HL7 ORU_R01 message
Written by Division by Zero   
Tuesday, 16 August 2011 08:49

A while ago someone asked me how to retrieve data from an OBX segement in an ORU_R01 message.  This isn't quite obvious to do. So here's an example on how to get a Base64 encoded PDF file from an ORU_R01 message.

In the following example I use some code from an earlier post.

The first bit shows how to add a PDF file (this could be any file) to the message. The last few lines of code is how to retreive the PDF file from the message. The file is in the data property of the ED data type.

// I use an example message as template. This is a shortcut, so I don't have to create this message from scratch
string templateMessage = "MSH|^~\\&|Application Name|Hospital Name||44|20000623134511||ORU^R01|20000623134511135475|P|2.3\rPID||12345678|69619||John^Smith||19550101|M\rORC|RE||||A\rOBR|||144137|Report Name|||201002221034|||||||||||||||201006281344|||F||||||Some Study|472^LastName^FirstName\rOBX|1|ED|REPORT_NAME||";
PipeParser pipeParser = new PipeParser();
NHapi.Model.V23.Message.ORU_R01 msg = (NHapi.Model.V23.Message.ORU_R01) pipeParser.Parse(templateMessage);
 
Terser terser = new Terser(msg);
// Now we retreive the first observation result (there's only one in the template)
NHapi.Model.V23.Segment.OBX obx = msg.GetRESPONSE().GetORDER_OBSERVATION().GetOBSERVATION().OBX;
// The last field needs to be filled with a Basse64 encoded PDF-file. First we need to set
// the right file type and encoding.
Terser.Set(obx, 5, 0, 1, 1, "Acrobat");
Terser.Set(obx, 5, 0, 2, 1, "text");
Terser.Set(obx, 5, 0, 3, 1, "pdf");
Terser.Set(obx, 5, 0, 4, 1, "Base64");
 
// Now we read the PDF, encode it and add it to the OBX segment
byte[] pdfContent = File.ReadAllBytes("..\\..\\..\\ORUExample\\Resources\\Example.pdf");
Terser.Set(obx, 5, 0, 5, 1, Convert.ToBase64String(pdfContent));
 
// Now to retreive the PDF we need to get to the obervations. This will contain an element of the type ED
// Assume there are no repetitions. Get the first item everytime
NHapi.Base.Model.Varies v = msg.GetRESPONSE().GetORDER_OBSERVATION(0).GetOBSERVATION(0).OBX.GetObservationValue(0);
NHapi.Model.V23.Datatype.ED ed = (NHapi.Model.V23.Datatype.ED)v.Data;
byte[] pdFileContent = Convert.FromBase64String(ed.Data2.Value);
 

Add comment


Security code
Refresh

The right word may be effective, but no word was ever as effective as a rightly timed pause. - Mark Twain


© 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.