You are on page 1of 4

HL7-XML process project

R. Wang Mar 04, 05 Introduction: This project automates the process from receiving HL7 message to loading to Promis tables by bridging XML. This project involved several parts: receiving HL7 message, processing HL7 message, converting to XML, Loading to database by using SQL*Loader, querying XML table and inserting to Promis table. The figure 1 depicts the basic flow of this project.
H L7 M essa e g

H A TLi st e er. p L7 D n l

S v to F l e a e i

H 7 D .h 7 L _A T l

P _H _b ro L7 atch p . l

H 7 D _P l 7 L _A T .h

B ck to n x in mn H 7 mssa e a e t co i g L e g (s)

B rx l X L co v rte a m M n e r


I n rt_X L_TA LE se M B

X L L A _T B E M_ O D A L

S L*Lo e Q ad r

H 7 D _P m L _A T .x l

I n rX L D se M_A T

P m ta l e ro i s b

Figure 1. Flowchart of HL7XML project Receiving HL7 message There is a perl program “” to receive the HL7 message. As this program running, a specific port is open to be available to receive message from sender. As soon as one/more messages are received, a batch file is called to go through the HL7 processing till this message be inserted into the Promis table. The HL7 message received originally is stored in HL7 file “HL7_ADT.hl7” for further process. Validating HL7 message

Basically, the original HL7 message contains unwanted space or string which should be eliminated before converting to XML because the XML converter will not accept the HL7 message with idle parts. Another perl program “” will perform this work. This perl file read the message from “HL7_ADT.hl7” into an array line by line and only keep the qualified message body in a new HL7 file with name “HL7_ADT_P.hl7”. Converting HL7 to XML As for the conversion from HL7 to XML, we use the tool “barxml” to do it. Currently, “barxml” offers two HL7 version conversion: V2.3 and V2.4. Technically, this converter will automatically identify the version of HL7 file. “Barxml” also provides helpful error message to help us know why the error happened if we experienced it. A new xml file “HL7_ADT_P.xml” will be created if this conversion is successful. Loading to XML table by using SQL*Loader The new XML file means that the HL7 message is parsed to structured data with XML format. That makes it possible to insert to oracle table with datatype XMLType. Oralce offers robust support on this datatype and make us can query XMLType with standard SQL statement which save us lots of works to parse the unstructured HL7 data. By using SQL*Loader, this xml is insert into table “XML_LOAD_TABLE” as a CLOB column. Before we do that, two new tables “XML_LOAD_TABLE” (CLOB) and “XML_TABLE” (XMLType) should be created. * table: xml_load_table (CLOB) create table xml_load_table (xmlcolumn CLOB); * table: xml_table (XMLType) create table xml_table (xmldoc sys.xmltype); Converting CLOB to XMLType CLOB is a kind of normal large object in Oracle, but is lack on XML support. That means we can’t query CLOB with SQL statement. Fortunately, CLOB can be converted to XMLType by using the XMLType function “CreateXML”. As we convert CLOB to XMLType, we can easily query XMLType to get the necessary HL7 segment message. The procedure “insert_xml_table” is called to perform the converting. Querying XML table and Inserting to Promis table Even though we already had the structured message on XMLType, we still need more control to process the string queried from table XML_TABLE. Currentlly, the cursor is used to process the message segment one by one and then insert into Promis table. Back to next incoming HL7 message(s)

As soon as the data has been inserted into Promis table, the program will return to receive next incoming HL7 message(s) and then perform the same process described above. Program files list: 1. --- Perl file to receive the HL7 data from sender and call batch file to process the rest of jobs 2. HL7_batch.bat --- OS batch file to integrate the processing files, including validating HL7 format, converting to XML, loading xml to database, inserting into Promis table 3. --- Perl file to validate the HL7 message (eliminating idle parts) 4. Barxml --- Java tool to convert HL7 to XML 5. VIHATest.ctl --- SQL*Loader control file to identify the loading method 6. insert_xml_table.sql --- SQL script to create the procedure insert_xml_table, which create the data in XMLType and then insert into table xml_table 7. insertXml_ADT.sql --- SQL scripe to query the data from XMLType in table xml_table and then insert into Promis table, used in test, VIHA_Patients Appendix Two ways to save xml data in oracle database: 1. LOB data This xml data saving way in Oracle offers flexibility when the XML data model changed. In our application, that means the possible change in HL7, further converted to XML, will not affect the data loading and saving method we are currently using. Another important point is that saving data in LOB will keep the complete data oringinally converted from HL7. That make us keep the data consistent with the one we received. The disadvantage of this method is that saving data in LOB require more phisical disk space. 2. Structrued (relation-object) data Comparing to LOB data, structured data is not flexible as LOB data because the data in XML file will be parsed and further inserted into specific xml table. The changes on HL7 data model will make data schema redefined. Saving data in structured xml will lose some information in XML. If we want the completness of data, this method is not our choice. The advange of this method is that the performance on DML is excellent and it requires less physical disk space than LOB data. Summary Currently, Promis is experiencing challenge of HL7 loading. We are working to find a effective solution to make the HL7 loading easily. We are trying to parse the HL7 data by bridging XML to skip the fussy work previously handled by

PL/SQL. We simplify the process and keep the complete HL7 data in XML table and we make it possible to get the data from this source to Promis table. At this time, we want to keep the Promis database structure unchagned. Less loading time of LOB data than structured data is also very helpful for us to load the high volumn of HL7 data into Promis. Therefore, the saving method of LOB data works to us to achieve our objective. Note: visit the following link to get scripts mentioned in this article.