Announcement

Collapse
No announcement yet.

ORU Messages

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ORU Messages

    I'm trying to write a JavaScript that will process a variety of ORU messages and I'm finding my lack of experience with JavaScript is most likely making the process complicated at best. Does someone have script that handles a variety of ORU message (HL7 2.5.1) you would be willing to share or possibly a suggestion on how I should be creating the JavaScript?

    Rich

  • #2
    I want to provide some additional infromation... I'm trying to transform the ORU messages to XML capturing all of the data that is available.

    Comment


    • #3
      I'm making progress, but I'm not creating the proper output. My input oru message has and OBR|1|... and an OBR|2|... segment and the only one being output is the SetID 2. I should be creating the XML for SetID 1 and then the XML for SetID 2. Here the Javascript used to create the XML. Note: the incomming message has no ORC message and there is a PV1 which does get created correctly. I'm creating subnodes under the ORB nodes for ORX and NTE segments.

      var cnodes = XML("<wrapper>"+msg.children().toString()+"</wrapper>");
      for (var i=0, ii=cnodes.children().length();i<ii;i++){ // iterate through total message
      var testname = String(cnodes.children()[i].name());

      if (testname == 'PV1'){
      var newPV1 = cnodes.child(i);
      var newPatientVisit1 = new XML($('PatientVisit1Template'));
      setPV1(newPatientVisit1,newPV1);
      tmp['ORUR01Record']['PatientVisit1'][pv1] = newPatientVisit1; //add last commonorder in place
      pv1++;
      }

      if (testname == 'ORC'){ //found a new common order
      //Means old common order is complete, if it exists
      if (newCommonOrder && newCommonOrder.length() > 0){
      tmp['ORUR01Record']['CommonOrder'][orc] = newCommonOrder; //add last commonorder in place
      orc++; //increment to spot for next common order
      bORC = false;
      }
      obx=0; //reset Observation Results count;
      obr=0;
      spm=0;
      txa=0;
      nte=0;
      bORC = true;
      var newORC = cnodes.child(i);
      var newCommonOrder = new XML($('CommonOrderTemplate')); //Copy of Complete structure
      setORC(newCommonOrder,newORC);
      }
      // newCommonOrder is the current Common Order
      if (testname == 'OBR'){ //found request for current common order
      if (bORC==true) {
      if (bOBR==true) {
      if (newObservationRequest && newObservationRequest.length() > 0) {
      newCommonOrder['ObservationRequest'][obr] = newObservationRequest;
      obr++
      }
      bOBR==false;
      }
      var newOBR = cnodes.child(i);
      var newObservationRequest = new XML($('ObservationRequestTemplate'));
      setOBR(newObservationRequest,newOBR);
      bOBR = true;
      obr++;
      obx=0;
      spm=0;
      nte=0;
      txa=0
      }
      else {
      bOBR = true;
      if (newObservationRequest && newObservationRequest.length() > 0) {
      tmp['OURR01Record']['ObservationRequest'][obr] = newObservationRequest;
      obr++;
      }
      obx=0;
      spm=0;
      nte=0;
      var newOBR = cnodes.child(i);
      var newObservationRequest = new XML($('ObservationRequestTemplate'));
      setOBR(newObservationRequest,newOBR);
      }
      }

      Comment


      • #4
        Here's the entire message I'm processing:

        MSH|^~\&|HCALAB|COCCBF|LAB||201007140209||ORU^R01| 386958..LAB.COCCBF|P|2.1
        PID|1||X999999999||TESTPAT^NOVO||19710101|F||||||| |||X99999999999|999-99-9999
        PV1|1|E|G.ED||||bes123^TESTDOC^CBS|||||||||||ER||| |||||||||||||||||||||||201007140132
        OBR|1|L435535|0714:CBF:CG00003S|PT^PROTHROMBIN TIME^L|S||201007140153|||||||201007140155||bes123^ TESTDOC^NOVO||||||201007140209|||F
        OBX|1|ST|PTP^PROTHROMBIN TIME PATIENT|1|99.9|SECONDS|8.8-11.5||||F||||ML
        OBX|2|ST|INR^INTERNATIONAL NORMAL RATIO|1|9.9||1.5-3.5|L|||F||||ML
        NTE|1||The INR is for monitoring patients who have been stabilized
        NTE|2||on Anticoagulant Therapy. The following ranges can be used
        NTE|3||as guidelines:
        NTE|4|| Conventional Anticoagulation INR 2.0 - 3.0
        NTE|5|| High Intensity Anticoagulation INR 3.0 - 3.5
        NTE|6|| Clinical Assessment Needed INR 3.5 - 5.0
        NTE|7
        NTE|8||Any INR >5.0 is considered a CRITICAL value and will be
        NTE|9||called to the Doctor.
        OBX|3|ST|NovoInsertedPL^Performing Lab:||||||||F
        NTE|1||ML - COLUMBIA BRIGHAM CITY 950 S 500W BRIGHAM CITY UT 84302
        OBR|2|L435535|0714:CBF:CG00003S|PTT^PARTIAL THROMBOPLASTIN TIME^L|S||201007140153|||||||201007140155||bes123^ TESTDOC^NOVO||||||201007140209|||F
        OBX|1|ST|PTTP^PTT PATIENT|1|99.9|SECONDS|22.0-31.0|N|||F||||ML
        OBX|2|ST|NovoInsertedPL^Performing Lab:||||||||F
        NTE|1||ML - COLUMBIA BRIGHAM CITY 950 S 500W BRIGHAM CITY UT 84302

        Comment


        • #5
          I've attached the Channel, the input message and the generated XML to show my issue. The channel is too large to upload. Here is the main script:

          var orc = 0; //set count of added CommonOrders
          var obr = 0; // set count of added observation request
          var obx = 0; //set count of added Observation Results...gets reset with each new Common Order
          var spm = 0; //set count of added Speciment Segments
          var txa = 0; //set count of transactions
          var nte = 0; //set count of notes and comments
          var pv1 = 0; //set count for patent visit
          var bORC=false;
          var bOBR=false;
          var bTXA=false;


          var cnodes = XML("<wrapper>"+msg.children().toString()+"</wrapper>");
          for (var i=0, ii=cnodes.children().length();i<ii;i++){ // iterate through total message
          var testname = String(cnodes.children()[i].name());
          logger.info('Received message: ' + testname);

          if (testname == 'PV1'){
          var newPV1 = cnodes.child(i);
          var newPatientVisit1 = new XML($('PatientVisit1Template'));
          setPV1(newPatientVisit1,newPV1);
          tmp['ORUR01Record']['PatientVisit1'][pv1] = newPatientVisit1; //add last commonorder in place
          pv1++;
          }

          if (testname == 'ORC'){ //found a new common order
          //Means old common order is complete, if it exists
          if (newCommonOrder && newCommonOrder.length() > 0){
          tmp['ORUR01Record']['CommonOrder'][orc] = newCommonOrder; //add last commonorder in place
          orc++; //increment to spot for next common order
          bORC = false;
          }
          obx=0; //reset Observation Results count;
          obr=0;
          spm=0;
          txa=0;
          nte=0;
          bORC = true;
          var newORC = cnodes.child(i);
          var newCommonOrder = new XML($('CommonOrderTemplate')); //Copy of Complete structure
          setORC(newCommonOrder,newORC);
          }
          // newCommonOrder is the current Common Order
          if (testname == 'OBR'){ //found request for current common order
          if (bORC==true) {
          if (newObservationRequest && newObservationRequest.length() > 0) {
          newCommonOrder['ObservationRequest'][obr] = newObservationRequest;
          obr++
          }
          var newOBR = cnodes.child(i);
          var newObservationRequest = new XML($('ObservationRequestTemplate'));
          setOBR(newObservationRequest,newOBR);
          bOBR = true;
          obr++;
          obx=0;
          spm=0;
          nte=0;
          txa=0
          }
          else {
          bOBR = true;
          if (newObservationRequest && newObservationRequest.length() > 0) {
          logger.info('Write newObservationRequest. OBR counter=' + obr);
          tmp['ORUR01Record']['ObservationRequest'][obr] = newObservationRequest; //add last commonorder in place
          obr++;
          }
          obx=0;
          spm=0;
          nte=0;
          var newOBR = cnodes.child(i);
          var newObservationRequest = new XML($('ObservationRequestTemplate'));
          setOBR(newObservationRequest,newOBR);
          }
          }

          if (testname =='TXA'){ //found transaction
          if (bORC==true) {
          if (bTXA==true) {
          if (newTranscriptionDocumentHeader && newTranscriptionDocumentHeader.length() > 0) {
          newCommonOrder['TranscriptionDocumentHeader'][txa] = newTranscriptionDocumentHeader;
          txa++;
          }
          bTXA = false;
          }
          else {
          var newTXA = cnodes.child(i);
          var newTranscriptionDocumentHeader = new XML($('TranscriptionDocumentHeaderTemplate'));
          setTXA(newTranscriptionDocumentHeader,newTXA);
          bTXA = true;
          txa++;
          obx=0;
          nte=0;
          }
          }
          else {
          bTXA = true;
          if (newTranscriptionDocumentHeader && newTranscriptionDocumentHeader.length() > 0) {
          tmp['OURR01Record']['TranscriptionDocumentHeader'][txa] = newTranscriptionDocumentHeader;
          txa++;
          }
          obx=0;
          nte=0;
          var newTXA = cnodes.child(i);
          var newTranscriptionDocumentHeader = new XML($('TranscriptionDocumentHeaderTemplate'));
          setTXA(newTranscriptionDocumentHeader,newTXA);
          }
          }
          if (testname == 'NTE'){ //found notes and comments
          var newNTE = cnodes.child(i);
          var newNotesandComments = new XML($('NotesandCommentsTemplate'));
          setNTE(newNotesandComments,newNTE);
          if (bOBR==true) {
          newObservationRequest['NotesandComments'][nte] = newNotesandComments;
          nte++;
          }
          else {
          if (bTXA==true) {
          newTranscriptionDocumentHeader['NotesandComments'][nte] = newNotesandComments;
          nte++
          }
          }
          }

          if (testname == 'OBX'){ //found observation for current common order
          var newOBX = cnodes.child(i);
          var newObservationResults = new XML($('ObservationResultsTemplate'));
          setOBX(newObservationResults,newOBX);
          if (bOBR==true) {
          newObservationRequest['ObservationResult'][obx] = newObservationResults;
          obx++;
          }
          else {
          if (bTXA==true) {
          newTranscriptionDocumentHeader['ObservationResult'][obx] = newObservationResults;
          obx++
          }
          }
          }

          if (testname == 'SPM'){ //found speciment segment
          var newSPM = cnodes.child(i);
          var newSpecimenSegment = new XML($('SpecimenSegmentTemplate'));
          setSPM(newSpecimenSegment,newSPM);
          if (bOBR==true) {
          newObservationRequest['SpecimenSegment'][spm] = newSpecimenSegment;
          spm++;
          }
          }
          } // completed iteration through total message
          // we come to the end, we must add in the last CommonOrder

          if (bORC==true && bOBR==true) {
          if (newObservationRequest && newObservationRequest.length() > 0) {
          newCommonOrder['ObservationRequest'][obr] = newObservationRequest;
          bOBR=false;
          }
          }

          if (bORC==true && bTXA==true) {
          if (newTranscriptionDocumentHeader && newTranscriptionDocumentHeader.length() > 0) {
          newCommonOrder['TranscriptionDocumentHeader'][txa] = newTranscriptionDocumentHeader;
          bTXA=false;
          }
          }

          if (bORC==true) {
          if (newCommonOrder && newCommonOrder.length() > 0){
          tmp['ORUR01Record']['CommonOrder'][orc] = newCommonOrder; //add last commonorder in place
          }
          }

          if (bOBR==true) {
          if (newObservationRequest && newObservationRequest.length() > 0) {
          logger.info('Write last newObservationRequest. OBR count=' + obr);
          tmp['ORUR01Record']['ObservationRequest'][obr] = newObservationRequest; //add last commonorder in place
          }
          }

          if (bTXA==true) {
          if (newTranscriptionDocumentHeader && newTranscriptionDocumentHeader.length() > 0) {
          tmp['ORUR01Record']['TranscriptionDocumentHeader'][txa] = newTranscriptionDocumentHeader; //add last commonorder in place
          }
          }
          Attached Files

          Comment


          • #6
            I've figured out my issue.

            Comment


            • #7
              What did it take to resolve this issue? Many of us would benefit from what you learned. Thanks.

              Comment


              • #8
                Here's how the javascript looks now compared to before. This one works with a new wrinkle:

                var orc = 0; //set count of added CommonOrders
                var obr = 0; // set count of added observation request
                var obx = 0; //set count of added Observation Results...gets reset with each new Common Order
                var spm = 0; //set count of added Speciment Segments
                var txa = 0; //set count of transactions
                var nte = 0; //set count of notes and comments
                var pv1 = 0; //set count for patent visit
                var bORC=false;
                var bOBR=false;
                var bTXA=false;


                var cnodes = XML("<wrapper>"+msg.children().toString()+"</wrapper>");
                for (var i=0, ii=cnodes.children().length();i<ii;i++){ // iterate through total message
                var testname = String(cnodes.children()[i].name());
                logger.info('Received message: ' + testname);

                if (testname == 'PV1'){
                var newPV1 = cnodes.child(i);
                var newPatientVisit1 = new XML($('PatientVisit1Template'));
                setPV1(newPatientVisit1,newPV1);
                tmp['ORUR01Record']['PatientVisit1'][pv1] = newPatientVisit1; //add last commonorder in place
                pv1++;
                }

                if (testname == 'ORC'){ //found a new common order
                //Means old common order is complete, if it exists
                if (newObservationRequest && newObservationRequest.length() > 0) {
                newCommonOrder['ObservationRequest'][obr] = newObservationRequest;
                var newObservationRequest = new XML($('ObservationRequestTemplate'));

                }
                if (newTranscriptionDocumentHeader && newTranscriptionDocumentHeader.length() > 0) {
                newCommonOrder['TranscriptionDocumentHeader'][txa] = newTranscriptionDocumentHeader;
                var newTranscriptionDocumentHeader = new XML($('TranscriptionDocumentHeaderTemplate'));
                }
                if (newCommonOrder && newCommonOrder.length() > 0){
                tmp['ORUR01Record']['CommonOrder'][orc] = newCommonOrder; //add last commonorder in place
                orc++; //increment to spot for next common order
                bORC = false;
                }
                obx=0; //reset Observation Results count;
                obr=0;
                spm=0;
                txa=0;
                nte=0;
                bORC = true;
                var newORC = cnodes.child(i);
                var newCommonOrder = new XML($('CommonOrderTemplate')); //Copy of Complete structure
                setORC(newCommonOrder,newORC);
                }
                // newCommonOrder is the current Common Order
                if (testname == 'OBR'){ //found request for current common order
                bOBR = true;
                if (!bORC == true) {
                if (newObservationRequest && newObservationRequest.length() > 0) {
                logger.info('Write newObservationRequest. OBR counter=' + obr);
                tmp['ORUR01Record']['ObservationRequest'][obr] = newObservationRequest; //add last commonorder in place
                obr++;
                }
                }
                obx=0;
                spm=0;
                nte=0;
                var newOBR = cnodes.child(i);
                var newObservationRequest = new XML($('ObservationRequestTemplate'));
                setOBR(newObservationRequest,newOBR);
                }

                if (testname =='TXA'){ //found transaction
                bTXA = true;
                if (!bORC==true) {
                if (newTranscriptionDocumentHeader && newTranscriptionDocumentHeader.length() > 0) {
                tmp['ORUR01Record']['TranscriptionDocumentHeader'][txa] = newTranscriptionDocumentHeader;
                txa++;
                }
                bTXA = true;
                txa++;
                obx=0;
                nte=0;
                }
                }
                if (testname == 'NTE'){ //found notes and comments
                var newNTE = cnodes.child(i);
                var newNotesandComments = new XML($('NotesandCommentsTemplate'));
                setNTE(newNotesandComments,newNTE);
                if (bOBR==true) {
                newObservationRequest['NotesandComments'][nte] = newNotesandComments;
                nte++;
                }
                else { if (bTXA==true) {
                newTranscriptionDocumentHeader['NotesandComments'][nte] = newNotesandComments;
                nte++
                }
                }
                }

                if (testname == 'OBX'){ //found observation for current common order
                var newOBX = cnodes.child(i);
                var newObservationResult = new XML($('ObservationResultsTemplate'));
                setOBX(newObservationResult,newOBX);
                if (bOBR==true) {
                logger.info('Write newObservationResult. OBX counter=' + obx);
                newObservationRequest['ObservationResult'][obx] = newObservationResult;
                obx++;
                }
                else { if (bTXA==true) {
                newTranscriptionDocumentHeader['ObservationResult'][obx] = newObservationResult;
                obx++
                }
                }
                }

                if (testname == 'SPM'){ //found speciment segment
                var newSPM = cnodes.child(i);
                var newSpecimenSegment = new XML($('SpecimenSegmentTemplate'));
                setSPM(newSpecimenSegment,newSPM);
                if (bOBR==true) {
                newObservationRequest['SpecimenSegment'][spm] = newSpecimenSegment;
                spm++;
                }
                }
                } // completed iteration through total message
                // we come to the end, we must add in the last CommonOrder

                if (bORC==true && bOBR==true) {
                if (newObservationRequest && newObservationRequest.length() > 0) {
                newCommonOrder['ObservationRequest'][obr] = newObservationRequest;
                bOBR=false;
                }
                }

                if (bORC==true && bTXA==true) {
                if (newTranscriptionDocumentHeader && newTranscriptionDocumentHeader.length() > 0) {
                newCommonOrder['TranscriptionDocumentHeader'][txa] = newTranscriptionDocumentHeader;
                bTXA=false;
                }
                }

                if (bORC==true) {
                if (newCommonOrder && newCommonOrder.length() > 0){
                tmp['ORUR01Record']['CommonOrder'][orc] = newCommonOrder; //add last commonorder in place
                }
                }

                if (bOBR==true) {
                if (newObservationRequest && newObservationRequest.length() > 0) {
                logger.info('Write last newObservationRequest. OBR count=' + obr);
                tmp['ORUR01Record']['ObservationRequest'][obr] = newObservationRequest; //add last commonorder in place
                }
                }

                if (bTXA==true) {
                if (newTranscriptionDocumentHeader && newTranscriptionDocumentHeader.length() > 0) {
                tmp['ORUR01Record']['TranscriptionDocumentHeader'][txa] = newTranscriptionDocumentHeader; //add last commonorder in place
                }
                }

                Comment


                • #9
                  I'm now getting an "OutOfMemoryError". I've attached the log file and the message I'm processing.
                  Attached Files

                  Comment


                  • #10
                    Resolved OutOfMemory issue by modifying wrapper.conf (in /conf folder).

                    Added:
                    wrapper.java.initmemory=128

                    and mofified:
                    wrapper.java.maxmemory=256 to
                    wrapper.java.maxmemory=512

                    Not sure which would have resolved the issue, but the message processes just fine and ran the remainder of the 'test' messages through and XML correctly generated for all.

                    Comment

                    Working...
                    X