Sidebar

How I can insert HL7 message to Database

0 votes
988 views
asked Oct 8, 2018 by (270 points)
How I can insert HL7 message to Database

1 Answer

0 votes
I belive you are looking for the node tags to use in your insert statement. Node Tags will get replaced with the values they point to.

{m:/} will put in the entire message. If the message is your HL7 then it will be put into your insert statement.

Example:

var queryResult = qie.doQuery(
   "DatabaseName from Database Connections page",
   "INSERT INTO table_name\n" +
   "VALUES ({m:/})",
   false);
answered Oct 8, 2018 by brandon-w-8204 (30,600 points)
edited Oct 8, 2018 by gary-t-8719
commented Oct 22, 2018 by tucker-s-9335 (100 points)
I'm trying to do something similar, but from a FHIR message source. I'm practicing with the FHIR starter kit, and have been able to store the FHIR messages that are converted to HL7 to a MySQL instance. However, I'd like to store discrete patient information in separate tables as well. For instance, PatientID, FamilyName, etc. I'm having trouble figuring out how to use the node tags in the insert query above. Can I embed the insert statement in the mapping function and use the variable names in the script? Here is a snippet of where I was intending on calling the insert function:

// Now we will loop through each patient in the patients
// array returned by the call to getAllNodes() above and
// create an HL7 ADT message for each one.
for (var i=0 ; i < patients.length ; i++) {
   // First we need to parse the string returned by the
   // function getAllNodes() and convert it to an XML
   // message object.
   var patient = qie.parseXMLString(patients[i], 'UTF-8');
   
   // Now we will initialize our HL7 message by evaluating
   // the 'HL7 MSH Template' which is stored as a system
   // variable. The 'HL7 MSH Template' contains several
   // system node tags that are used to populate the HL7 MSH
   // segment with a single call to qie.evaluateTemplate().
   //
   // The 'HL7 MSH Template' system variable can be viewed
   // by selecting 'System Variables' from the left side bar.
   var hl7 = qie.evaluateTemplate(qie.getVariable('HL7 MSH Template'));
   
   // Now we need to parse the string that is returned by
   // qie.evaluateTemplate() and convert it to an HL7
   // message object. Doing so, allows us to manipulate
   // the hl7 message using the standard message object
   // funtions such as setNode(), addChildNode(), etc.
   hl7 = qie.parseHL7String(hl7);

   // Now we will set:
   //   message type = 'ADT' and
   //   event code   = 'A08' (update patient)
   hl7.setNode('MSH-9.1', 'ADT');
   hl7.setNode('MSH-9.2', 'A08');
   
   // Now we will add an EVN Segment to our hl7 message
   hl7.addChildNode('/', 'EVN', 'EVN||');

   // Now we will set the EVN event code and event date
   hl7.setNode('EVN-1', 'A08');
   hl7.setNode('EVN-2', qie.formatDate('yyyyMMddhhmmss'));

   // Now we will add a PID segment to our hl7 message.
   // Because HL7 message segments are often shared by
   // multiple HL7 message types, we have chosen to use
   // published functions to handle the process of creating
   // the different HL7 segments. The published function
   // fhirToHL7_PID() is used to create the PID segment and
   // can be found by selecting 'Published Functions' from
   // the left side navigation bar.
   fhirToHL7_PID(patient, hl7);
   
I was hoping to do the db insert after the HL7 PID segment is built.
...