Announcement

Collapse
No announcement yet.

Create multiple OBX segmetns

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

  • Create multiple OBX segmetns

    Does anyone have a working example of a ORU^R01 message.

    I need to be able to create this message from reading data from different SQL database tables and put them into a ORU^R01 message and writing to a file or LLP.

    In my ORU I have the MSH,PID,OBR working, now what I can not figure out is how the get my into multiple OBX segments. Does anyone know how to get multiple rows of data that represent OBX data into the hl7 format of OBX data?

    When I try to include the OBX data i get the following error...
    org.mozilla.javascript.EcmaError: TypeError: Assignment to lists with more that one item is not supported (1344a152-a193-4642-8187-ebff542a1db3#12)


    Thanks,
    Bobbie

  • #2
    Re: Create multiple OBX segmetns

    Bobbie,

    I have a great example of this that I'll post later today.

    -Chris
    Chris Lang

    Comment


    • #3
      Re: Create multiple OBX segmetns

      Thanks so much I have to have this completed today and I have tried so many different things...

      Comment


      • #4
        Re: Create multiple OBX segmetns

        Code:
        //this assumes your data from the database is a report seperated by newlines. You will need something to iterate over to create each obx segment
        var data = msg['OBX DATA FROM DB'].split('\n');
        var i = 0;
        while (i < data.length)
        {
            tmp[&#039;ORU_R01.PATIENT_RESULT&#039;][&#039;ORU_R01.ORDER_OBSERVATION&#039;][&#039;ORU_R01.OBSERVATION&#039;][&#039;OBX&#039;][&#039;OBX.5&#039;][i] = data[i];
            i += 1;
        }

        The key here is the index after [&#039;OBX.5&#039;] - [i]. E4X will automatically add a new segment when you increase the index number. ie:
        Code:
        tmp[&#039;ORU_R01.PATIENT_RESULT&#039;][&#039;ORU_R01.ORDER_OBSERVATION&#039;][&#039;ORU_R01.OBSERVATION&#039;][&#039;OBX&#039;][&#039;OBX.5&#039;][0] = "test 1"
        tmp[&#039;ORU_R01.PATIENT_RESULT&#039;][&#039;ORU_R01.ORDER_OBSERVATION&#039;][&#039;ORU_R01.OBSERVATION&#039;][&#039;OBX&#039;][&#039;OBX.5&#039;][1] = "test 2"
        tmp[&#039;ORU_R01.PATIENT_RESULT&#039;][&#039;ORU_R01.ORDER_OBSERVATION&#039;][&#039;ORU_R01.OBSERVATION&#039;][&#039;OBX&#039;][&#039;OBX.5&#039;][2] = "test 3"
        tmp[&#039;ORU_R01.PATIENT_RESULT&#039;][&#039;ORU_R01.ORDER_OBSERVATION&#039;][&#039;ORU_R01.OBSERVATION&#039;][&#039;OBX&#039;][&#039;OBX.5&#039;][4] = "test 4"
        ...etc
        Just make sure you have one OBX.5 segment in your template message.

        -Chris
        Chris Lang

        Comment


        • #5
          Re: Create multiple OBX segmetns

          So I would create a javascript step for each of the OBX elements that I have data for?

          Comment


          • #6
            Re: Create multiple OBX segmetns

            Bobbie,

            You can include all of that code in one Javascript step. Ideally you would just have a loop that goes through all the elements you want to include. No more than 5 or 10 lines total.

            -Chris
            Chris Lang

            Comment


            • #7
              Re: Create multiple OBX segmetns

              Again thanks Chris for all of your help.

              I did as you instructed and I have it working the only problem I am having now I that it will not create more than one OBX . I should have 8 OBX&#039;s below instead it is creating 8 different messages.

              MSH|^~\&|REMOTE|REMOTE|Clinical|Health|20061201120 515||ORU^R01||P|2.3
              PID|1|67001118^^^HOME^EK|118^^^HOME^MR||Dummy^Test
              OBR|1|12345||29274-8^VITAL SIGNS MEASUREMENTS^LN||20061201120515|20060914141120|||| ||||||||||||||F
              OBX|1|NM|8479-8^INTRAVASCULAR SYSTOLIC^LN||128|mmhg||||||||20050401144100|||Bloo d Pressure

              Comment


              • #8
                Re: Create multiple OBX segmetns

                tmp[&#039;ORU_R01.PATIENT_RESULT&#039;][&#039;ORU_R01.ORDER_OBSERVATION&#039;][&#039;ORU_R01.OBSERVATION&#039;][&#039;OBX&#039;][i][&#039;OBX.5&#039;]

                Also, can you post an example of the data you are reading in?

                -Chris
                Chris Lang

                Comment


                • #9
                  Re: Create multiple OBX segmetns

                  Sure HEre you go this is collected by a SQL statement

                  12345 2006-09-14T14:11:20- NM 8479-8 INTRAVASCULAR SYSTOLIC 128 mmhg 2006-09-14T14:11:20- Blood Pressure
                  12345 2006-09-14T14:11:20- NM 8462-4 INTRAVASCULAR DIASTOLIC 91 mmhg 2006-09-14T14:11:20- Blood Pressure
                  12345 2006-09-14T14:11:20- NM 8867-4 HEART BEAT 84 /min 2006-09-14T14:11:20- Blood Pressure
                  12345 2006-09-14T14:08:22- NM 2710-2 OXYGEN SATURATION 99 % 2006-09-14T14:08:22- Pulse Oximetry
                  12345 2006-09-14T14:08:22- NM 8867-4 HEART BEAT 68 /min 2006-09-14T14:08:22- Pulse Oximetry
                  12345 2006-09-14T10:50:44- NM 8479-8 INTRAVASCULAR SYSTOLIC 129 mmhg 2006-09-14T10:50:44- Blood Pressure
                  12345 2006-09-14T10:50:44- NM 8462-4 INTRAVASCULAR DIASTOLIC 99 mmhg 2006-09-14T10:50:44- Blood Pressure
                  12345 2006-09-14T10:50:44- NM 8867-4 HEART BEAT 75 /min 2006-09-14T10:50:44- Blood Pressure

                  Comment


                  • #10
                    Re: Create multiple OBX segmetns

                    Are these all different rows from the DB that you&#039;d like to concatenate into one HL7 message?
                    Chris Lang

                    Comment


                    • #11
                      Re: Create multiple OBX segmetns

                      Yes that is correct...

                      Comment


                      • #12
                        Re: Create multiple OBX segmetns

                        What is your SELECT statement like in Mirth?

                        One problem you are going to have is that Mirth creates a new HL7 message for each ROW it reads in from the database.

                        It is possible to select multiple rows and create one HL7 message, however the SQL logic will need to go in your transformer. You would essentially have a SQL statement on the Source DB reader that checks there is a new message to generate, then a transformer that does another SQL query to pull down all the rows that go into the desired message.

                        You would loop through the result set and insert each OBX field into the template message.

                        -Chris
                        Chris Lang

                        Comment


                        • #13
                          Re: Create multiple OBX segmetns

                          Okay I understand I will give that a try. Thanks again for all of your help...

                          Comment


                          • #14
                            Re: Create multiple OBX segmetns

                            No prob!
                            Chris Lang

                            Comment


                            • #15
                              Re: Create multiple OBX segmetns

                              Hey Chris,
                              Sorry to keep bugging you but I am still not able to get it to do Multiple OBX segments.

                              The code below is out of my Javascript transformer, I know it is syntax just can&#039;t figure it out.

                              var tempDriver = "net.sourceforge.jtds.jdbc.Driver";
                              var tempAddress = "jdbc:jtds:sqlserver://localhost:1433/HL7";
                              var tempUser = "";
                              var tempWord = "";

                              var tempIdentifier = "&#039;" + msg[&#039;patientidentifier&#039;].toString() + "&#039;";
                              var tempPlaceOrderNum = "";
                              var tempUSI1 = "29274-8";
                              var tempUSI2 = "VITAL SIGNS MEASUREMENTS";
                              var tempUSI3 = "LN";
                              var tempRequestDate = localMap.get(&#039;MsgDate&#039;
                              var tempCapturedDate = "";
                              var tempResultStatus = "F";
                              var tempValueType ="";
                              var tempObsv1 = "";
                              var tempObsv2 = "";
                              var tempObsv3 = "LN";
                              var tempObsvValue = "";
                              var tempUnits = "";
                              var tempObsvStatus = "F";
                              var tempObsvMethod = "";


                              //create a sql statement that will pull back the data that I need.
                              //loop through the data to create the OBR and the OBX&#039;s
                              var dbConnMeas = DatabaseConnectionFactory.createDatabaseConnection (tempDriver, tempAddress, tempUser, tempWord);
                              var spParamsMeas = tempIdentifier ;

                              var expressionMeas = "EXEC sp_HL7_GetPatientMeasurements " + spParamsMeas;
                              var resultMeas = dbConnMeas.executeCachedQuery(expressionMeas);

                              var OBXi = 0;
                              var OBRi = 0;
                              while(resultMeas.next())
                              {
                              tempPlaceOrderNum = String(resultMeas.getString(2));
                              var getCapturedDate = String(resultMeas.getString(3));
                              if(getCapturedDate != null || getCapturedDate != "")
                              {
                              var originaldate = getCapturedDate;
                              originaldate = originaldate.replace(/-/g, "");
                              originaldate = originaldate.replace(/T/g, "");
                              originaldate = originaldate.replace(/:/g, "");
                              tempCapturedDate = originaldate;
                              }


                              tempValueType = String(resultMeas.getString(4));
                              tempObsv1 = String(resultMeas.getString(5));
                              tempObsv2 = String(resultMeas.getString(6));
                              tempObsvValue = String(resultMeas.getString(7));
                              tempUnits = String(resultMeas.getString(8));
                              tempObsvMethod = String(resultMeas.getString(9));

                              if(tmp[&#039;ORU_R01.RESPONSE&#039;][&#039;ORU_R01.ORDER_OBSERVATION&#039;][&#039;OBR&#039;][&#039;OBR.2&#039;][&#039;EI.1&#039;][OBRi] != tempPlaceOrderNum)
                              {
                              tmp[&#039;ORU_R01.RESPONSE&#039;][&#039;ORU_R01.ORDER_OBSERVATION&#039;][&#039;OBR&#039;][&#039;OBR.1&#039;][OBRi] = [OBRi];
                              tmp[&#039;ORU_R01.RESPONSE&#039;][&#039;ORU_R01.ORDER_OBSERVATION&#039;][&#039;OBR&#039;][&#039;OBR.2&#039;][&#039;EI.1&#039;][OBRi] = tempPlaceOrderNum;
                              logger.info(&#039;PlaceOrderNum: &#039; + tempPlaceOrderNum);
                              tmp[&#039;ORU_R01.RESPONSE&#039;][&#039;ORU_R01.ORDER_OBSERVATION&#039;][&#039;OBR&#039;][&#039;OBR.4&#039;][&#039;CE.1&#039;][OBRi] = tempUSI1;
                              tmp[&#039;ORU_R01.RESPONSE&#039;][&#039;ORU_R01.ORDER_OBSERVATION&#039;][&#039;OBR&#039;][&#039;OBR.4&#039;][&#039;CE.2&#039;][OBRi] = tempUSI2;
                              tmp[&#039;ORU_R01.RESPONSE&#039;][&#039;ORU_R01.ORDER_OBSERVATION&#039;][&#039;OBR&#039;][&#039;OBR.4&#039;][&#039;CE.3&#039;][OBRi] = tempUSI3;
                              tmp[&#039;ORU_R01.RESPONSE&#039;][&#039;ORU_R01.ORDER_OBSERVATION&#039;][&#039;OBR&#039;][&#039;OBR.6&#039;][&#039;TS.1&#039;][OBRi] = tempRequestDate;
                              tmp[&#039;ORU_R01.RESPONSE&#039;][&#039;ORU_R01.ORDER_OBSERVATION&#039;][&#039;OBR&#039;][&#039;OBR.7&#039;][&#039;TS.1&#039;][OBRi] = tempCapturedDate;
                              tmp[&#039;ORU_R01.RESPONSE&#039;][&#039;ORU_R01.ORDER_OBSERVATION&#039;][&#039;OBR&#039;][&#039;OBR.25&#039;][OBRi] = tempResultStatus;
                              OBRi += 1;
                              }

                              tmp[&#039;ORU_R01.RESPONSE&#039;][&#039;ORU_R01.ORDER_OBSERVATION&#039;][&#039;ORU_R01.OBSERVATION&#039;][&#039;OBX&#039;][&#039;OBX.1&#039;][OBXi] = OBXi;
                              tmp[&#039;ORU_R01.RESPONSE&#039;][&#039;ORU_R01.ORDER_OBSERVATION&#039;][&#039;ORU_R01.OBSERVATION&#039;][&#039;OBX&#039;][&#039;OBX.2&#039;][OBXi] = tempValueType;
                              tmp[&#039;ORU_R01.RESPONSE&#039;][&#039;ORU_R01.ORDER_OBSERVATION&#039;][&#039;ORU_R01.OBSERVATION&#039;][&#039;OBX&#039;][&#039;OBX.3&#039;][&#039;CE.1&#039;][OBXi] = tempObsv1;
                              tmp[&#039;ORU_R01.RESPONSE&#039;][&#039;ORU_R01.ORDER_OBSERVATION&#039;][&#039;ORU_R01.OBSERVATION&#039;][&#039;OBX&#039;][&#039;OBX.3&#039;][&#039;CE.2&#039;][OBXi] = tempObsv2;
                              tmp[&#039;ORU_R01.RESPONSE&#039;][&#039;ORU_R01.ORDER_OBSERVATION&#039;][&#039;ORU_R01.OBSERVATION&#039;][&#039;OBX&#039;][&#039;OBX.3&#039;][&#039;CE.3&#039;][OBXi] = tempObsv3;

                              tmp[&#039;ORU_R01.RESPONSE&#039;][&#039;ORU_R01.ORDER_OBSERVATION&#039;][&#039;ORU_R01.OBSERVATION&#039;][&#039;OBX&#039;][&#039;OBX.5&#039;][OBXi] = tempObsvValue;
                              tmp[&#039;ORU_R01.RESPONSE&#039;][&#039;ORU_R01.ORDER_OBSERVATION&#039;][&#039;ORU_R01.OBSERVATION&#039;][&#039;OBX&#039;][&#039;OBX.6&#039;][&#039;CE.1&#039;][OBXi] = tempUnits;
                              tmp[&#039;ORU_R01.RESPONSE&#039;][&#039;ORU_R01.ORDER_OBSERVATION&#039;][&#039;ORU_R01.OBSERVATION&#039;][&#039;OBX&#039;][&#039;OBX.11&#039;][OBXi] = tempObsvStatus;
                              tmp[&#039;ORU_R01.RESPONSE&#039;][&#039;ORU_R01.ORDER_OBSERVATION&#039;][&#039;ORU_R01.OBSERVATION&#039;][&#039;OBX&#039;][&#039;OBX.14&#039;][&#039;TS.1&#039;][OBXi] = tempCapturedDate;
                              tmp[&#039;ORU_R01.RESPONSE&#039;][&#039;ORU_R01.ORDER_OBSERVATION&#039;][&#039;ORU_R01.OBSERVATION&#039;][&#039;OBX&#039;][&#039;OBX.17&#039;][&#039;CE.1&#039;][OBXi] = tempObsvMethod;

                              OBXi += 1;
                              }

                              //cleanup
                              resultMeas.close();
                              dbConnMeas.close();

                              Comment

                              Working...
                              X