web stats
splitting the HL7 message - Page 2 - Mirth Community

Go Back   Mirth Community > Open Source HIT > General Discussion

Reply
 
Thread Tools Display Modes
  #11  
Old 09-15-2008, 02:49 PM
simidau simidau is offline
OBX.2 Kenobi
 
Join Date: Feb 2008
Posts: 62
simidau
Default Re:splitting the HL7 message

This is what I did. Not sure if it was for the before mentioned hl7 message but if not it was something similar.
This goes through the results and puts each set of results into a table.

Code:
    var iObx = 0; // 0 based format
    var iObr = 0; // 0 based format
    var iOpi = 0; // 0 based format

  // Get the requests and patient details
  for (var iOpi = 0; iOpi < msg['ORU_R01.PATIENT_RESULT'].length(); iOpi++)
  {
    // Patient details
    var patientID = msg['ORU_R01.PATIENT_RESULT'][i0pi]['ORU_R01.PATIENT']['PID']['PID.2']['PID.2.1'].toString();
    var patientID2 = msg['ORU_R01.PATIENT_RESULT'][i0pi]['ORU_R01.PATIENT']['PID']['PID.3']['CX.1'].toString();
    var patientName = msg['ORU_R01.PATIENT_RESULT'][i0pi]['ORU_R01.PATIENT']['PID']['PID.5']['XPN.1']['FN.1'].toString() + msg['PID']['PID.5']['PID.5.3'].toString() + msg['ORU_R01.PATIENT_RESULT'][i0pi]['ORU_R01.PATIENT']['PID']['PID.5']['XPN.2'].toString();
    var patientDOB = msg['ORU_R01.PATIENT_RESULT'][i0pi]['ORU_R01.PATIENT']['PID']['PID.7']['TS.1'].toString();
    var patientSex = msg['ORU_R01.PATIENT_RESULT'][i0pi]['ORU_R01.PATIENT']['PID']['PID.8'].toString();

    // Read the results!
    do
    {
        // Request details
        var SetNo = msg['ORU_R01.PATIENT_RESULT'][i0pi]['ORU_R01.ORDER_OBSERVATION']
        msg['OBR'][iObr]['OBR.1']['OBR.1.1'].toString();
        var OrderNumber = msg['OBR'][iObr]['OBR.3']['OBR.3.1'].toString();
        var UniversalServiceText = msg['OBR'][iObr]['OBR.4']['OBR.4.2'].toString();
        var DateTimeRequested = msg['OBR'][iObr]['OBR.6']['OBR.6.1'].toString();
        var OrderingProvider = msg['OBR'][iObr]['OBR.16']['OBR.16.2'].toString();
        var ObservationDate = msg['OBR'][iObr]['OBR.7']['OBR.7.1'].toString();
        var SpecimenSource = msg['OBR'][iObr]['OBR.15']['OBR.15.1'].toString();
        // Process your OBX segment - msg['OBX'][iObx] - here
        var Ob_ID = "NULL";
        var Ob_Name = "NULL";
        var Ob_Coding = "NULL";
        var Ob_Range = "NULL";
        var Ob_Value = "NULL";
        var Units = "NULL";
        var Abnormal_Flags = "NULL";
        var Observ_result_status = "NULL";

        //variable obervation Name
        var Ob_ID = msg['OBX'][iObx]['OBX.3']['OBX.3.1'];
        var Ob_Name = msg['OBX'][iObx]['OBX.3']['OBX.3.2'];
        var Ob_Coding = msg['OBX'][iObx]['OBX.3']['OBX.3.3'];
        var Ob_Value = msg['OBX'][iObx]['OBX.5']['OBX.5.1']; 
        var Units = msg['OBX'][iObx]['OBX.6']['OBX.6.1'];
        var Ob_Range = msg['OBX'][iObx]['OBX.7']['OBX.7.1']; 
        var Abnormal_Flags = msg['OBX'][iObx]['OBX.8']['OBX.8.1']; 
        var Observ_result_status = msg['OBX'][iObx]['OBX.11']['OBX.11.1']; 
        
         //obr id needed to identify which obr this obx belongs to
         var expression = "INSERT INTO results ";
	 expression += "(LabNumber,Name,UR,DOB,Sex,CollectionDate,Test,TestName,Result,Range,Specimen,Flag,Units) ";
	 expression += "values ('" + OrderNumber + "', '" + patientName + "', '" + patientID2 + "', '" + patientDOB + "', '" + patientSex + "', '" + ObservationDate + "', '" + Ob_ID + "', '" + Ob_Name + "', '" + Ob_Value + "','" + Ob_Range + "','" + SpecimenSource + "', '" + Abnormal_Flags + "','" + Units + "');";
	 bigexpression = bigexpression + "\n" + expression;
         var result = dbConn.executeUpdate(expression);

    	iObr++;
    }
    while (iObr < msg['ORU_R01.PATIENT_RESULT'][i0pi]['ORU_R01.ORDER_OBSERVATION'].length() && 1 != msg['OBR'][iObr]['OBR.1']['OBR.1.1']);
  }

    //simply closes the connection to the DB
    dbConn.close();
}
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 01:55 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation