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.
static void Main(string args)
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);
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