Convert HL7 to XML
Hi We have a need in our Ensemble production to take HL7 ver 2.3 and provide an XML representation of it to provide to non-HL7 consumers. What would be the prefereed way to do it. Are there are pre-defined XML schemas in Ensemble that could be use ? We are currently on Ensemble 2015.2
One way of doing it.. In my opinion its ugly to read but it accomplishes what you require..
The sourceXMLStream contains XML like...
Hi!
HL7 has an XML Schema that you can import as Ensemble classes. You can use these classes to implement your business services and operations web services. Here is the XML schema link.
Another way of using this XML Schema is not to import them as classes. Instead, use the XML Schema importing tool we have on Ensemble Management Portal and use EnsLib.EDI.XML.Document with it. You could receive plain XML text and transform it into an EnsLib.EDI.XML.Document. It will be faster to process than to transform it to objects. If you are interested, I can share some code.
All that being said, I strongly suggest NOT TO DO ANY OF THIS.
HL7v2 XML encoding isn't used anywhere and the natural reasoning behind using it is just ridiculous. If you are asking someone to support HL7v2 and they are willing to spend their time implementing the standard, then explain to them that it is best for them to simply implement it the way 99% of the world uses it: with the normal |^~& separators. It's a text string that they can simply embed into their web service call.
There are these two XML encoding versions:
Both encodings are horrible since they won't give you pretty field names that you can simply transform into an object and understand the meaning of the fields just by reading their names. Here is what an class generated from the standard HL7v2 XML Schema looks like (the PID segment):
You see? No semantics. Just structure. So, why not simply send the HL7v2 standard text through your Web Service or HTTP service? Here are the advantages of using the standard HL7v2 text encoding instead of the XML encoding:
Kind regards,
AS
{
Parameter XMLNAME = "PID.CONTENT";
Parameter XMLSEQUENCE = 1;
Parameter XMLTYPE = "PID.CONTENT";
Parameter XMLIGNORENULL = 1;
Property PID1 As HL7251Schema.PID.X1.CONTENT(XMLNAME = "PID.1", XMLREF = 1);
Property PID2 As HL7251Schema.PID.X2.CONTENT(XMLNAME = "PID.2", XMLREF = 1);
Property PID3 As list Of HL7251Schema.PID.X3.CONTENT(XMLNAME = "PID.3", XMLPROJECTION = "ELEMENT", XMLREF = 1) [ Required ];
Property PID4 As list Of HL7251Schema.PID.X4.CONTENT(XMLNAME = "PID.4", XMLPROJECTION = "ELEMENT", XMLREF = 1);