XML Message Format

Top  Previous  Next

The EasyHL7 XML message format was designed with application development in mind.  It is quite large, which can make it somewhat unwieldy for things like archiving or database storage (for which we recommend archival/storage in native HL7 format).  But this drawback is more than compensated by the wealth of information that is available to you when looking at a message in XML versus native HL7.  Consider the following examples:

 

In the PID segment of HL7 field element 8 is the patient sex.  In HL7 it might be represented like so (for a male):

 

PID|1|2827|2827||Smith^Barney^^^Mr^^^||19560107000000^^|M||Caucasian^^^^^^|PO Box 12345^^Somewhere^TX^76834^^^^^||(325)555-1212^Home^^^^325^5551212^^|||Married^^^^^^|||123-45-6789||||||||||||

 

Now zoom in on just the patient sex element of the XML version of the same PID segment.

 

<FIELD8 DESCRIPTION="Sex" DATATYPE="IS" FIELDLEN="1" REQUIRED="0" TABLEID="1" COMPONENTS="1" MAXCOMPONENT="1">

<COMPONENT1 DATATYPE="ST" DESCRIPTION="Code value for user-defined table">M</COMPONENT1>

</FIELD8>

 

What was represented in 1 character of HL7 takes over 200 characters to represent in XML.  With the XML format however you get the field value (M) and also an entire encapsulation of the vendor's HL7 definition for that element including:

 

The description of the field element
The hl7 datatype of the field element
The defined maximum length of the field
Whether the field element is designated as being required by the vendor for that segment
The HL7 table ID (if applicable)
The number of components allowed for that data type
The highest numbered component that actually contains data (MAXCOMPONENT)
The HL7 datatype of each component of the field element
The description of each component of the field element

 

Having this information available allows you the flexibility to perform multiple tasks such as:

Data validation.  Does the data element conform (field len)? Is it required? If it relates to a Table, does it contain a code value that exists in that table (see GetHL7Table method)?
Viewing and/or reporting data.  With datatypes, descriptions, etc. all present, custom views or reports can easily be programmed to dynamically display HL7 data (see the OpenFileManager method)
Web or browser display of HL7 messages using XSLT