Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Friday, April 28, 2017 9:59:14 AM(UTC)

Aaron  
Aaron

Groups: Registered, Tech Support, Administrators
Posts: 71

Was thanked: 3 time(s) in 3 post(s)

Attached is a simple sample application developed in Visual Studio 2017 using .NET 4.5.2 that demonstrates how you can use LEADTOOLS to parse HL7 messages and retrieve each individual value from the message. This application assumes that you already have the LEADTOOLS Medical SDK installed and references the DLLs from the default installation directory:

<Install Directory>\LEADTOOLS 19\Bin\Dotnet4\Win32

In this application, the PipeMessageConverter, MessageStructure, MessageStructureConverter, and IHL7MessageItem classes are used to take in the HL7 message as a string and provide you with an IHL7MessageItem object that contains all the data that was parsed from the string:

Code:

PipeMessageConverter pmc = new PipeMessageConverter();
MessageStructure ms = pmc.PipeMessageToMessageStructure(@"MSH|^~\&|||||201302060735||ORM^O01||T|2.3.1|||
   PID|||12345||Chudnovski^Evgenia^L.||19640806|F|||||||||||1242423432||
   PV1||OUT|ER||||A95273^McCarthy^John|133323^Rabinovich^Alex|B78243^Perry^John||||||||C63456^Paul^Ron||||
   ORC|NW|12345|RA20130206|||||||||D12345^McCain^John|||||||
   OBR||12345|RA20130206|R PEL AP||||||||||||99999^ER^DOC|||273135625|||||RA||||||dfdfdf|sfsfsdfsd sdf fdf fdsf|||||201302061000|
   ZDS|2.16.124.113543.6021.5.20130206.073513.562^^Application^DICOM");
MessageStructureConverter msc = new MessageStructureConverter();
IHL7MessageItem hl7msg = msc.MessageStructureToMessage(ms, new MessageStructureConverter.Options() { Add_NoneStandardSegmentToRoot = true, Ignore_NoneStandardSegment = true, Parse_RepeatableParentGroupFirst = true, Forgive_IncompleteMessage = true }).Message;

GetAllItems(hl7msg);


At this point we have the individual HL7 nodes and now we just need to loop through the nodes and retrieve each data field. For this we will use the INodeItem interface:

Code:

static void GetAllItems(INodeItem nodeItem)
{
   foreach (INodeItem sub in nodeItem.Nodes)
   {
      FindFields(sub);
      GetAllItems(sub);
   }
}

static void FindFields(INodeItem nodeItem)
{
   if (nodeItem.Fields.Count == 0)
      return;

   for (int seq = 0; seq < nodeItem.Fields.Count; seq++)
   {
      for (int rep = 0; rep < nodeItem.Fields[seq].Repetitions.Count; rep++)
      {
         IField f = nodeItem.Fields[seq].Repetitions[rep];

         if (!f.IsEmpty)
         {
            Console.WriteLine(nodeItem.ToString() + "   " + (seq + 1).ToString() + "   " + f.Value.ToString());
         }

         if (f.HasSubComponents)
         {
            {
               string DeepValue = f.DeepValue;
               if (!string.IsNullOrEmpty(DeepValue))
               {
                  Console.WriteLine(nodeItem.ToString() + "   " + (seq + 1).ToString() + "   " + DeepValue.ToString());
               }
            }
         }
      }
   }
}


The demo prints out each field that is retrieved and its information to the console (node name, sequence number, and value), but at that point you have the individual values and their corresponding attributes so you can store them as needed.
File Attachment(s):
SimpleHL7Parser.zip (12kb) downloaded 191 time(s).
Aaron Brasington
Developer Support Engineer
LEAD Technologies, Inc.

LEAD Logo
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2017, Yet Another Forum.NET
This page was generated in 0.167 seconds.