HL7 v3.0 message handling.

February 12, 2008

Health Level 7 (www.hl7.org) has released version 3.0 for quite a while back, and I have to work on its message handling and integration with health care applications. The new version completely focuses on XML based messages. The Normative Edition comes with a good load of xsds (XML Schema Definition); one for each message type and believe me there are tons of xsds. The message structure has got very much readable and easy to parse using any language which has good xml parser as compared to version 2.x.
The best approach which I can think of for now, is using the xsds do generate classes. I tried to use XSD.exe from the Visual Studio 2005 Tools, but I was unable to fix the reference types. The xsd.exe tool does not take into account the referenced schema definitions, and so I was not able to auto-generate class from those xsd, but when I get that done then I have no big headache. Once the classes are generated, we can just use XmlSerializer class to DeSerialize the xml-message directly to the class and then access the respective properties. Looks simple?

I tried the same trick within a test application which has “shiporder.xml” and “shiporder.xsd”, these files were taken from w3c 🙂

I created the class using xsd.exe from VS.NET tools, which created “shiporder.cs” for me:
cmd>> xsd shiporder.xsd /c

Then I build a simple and sweet standalone application to test it.
//code c#
using System.IO;
using System.Xml.Serialization;
namespace XSDTest
class Program
static void Main(string[] args)

// shiporder.cs
XmlSerializer serial = new XmlSerializer(typeof(shiporder));
TextReader reader = new StreamReader(“shiporder.xml”);

// this is how you directly get the data back.
shiporder so = (shiporder) serial.Deserialize(reader);

//end code

I hope I will be able to resolve the reference schemas in the HL7 xsds, and then build the classes out of it in near future, till then try out other possible methods 🙂 -Bugs


2 Responses to “HL7 v3.0 message handling.”

  1. René Spronk Says:


    Generally the referencing issue is solved by flattening the schema. One can even further preprocess the HL7 schema by means of an XSLT to remove any unwanted data type definition hierarchies to reduce the number of generated classes. This has been sucessfully done using JAXB or its .net equivalent.

    See http://www.ringholm.de/download/implementation_mechanics.ppt for details.


  2. […] HL7 v3.0 MessageHandling […]

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: