Announcement

Collapse
No announcement yet.

Looping through multiple OBX segments, updating SQL database

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

  • Looping through multiple OBX segments, updating SQL database

    I am receiving multiple OBX segments within an ORU message.

    I'd like to loop through the OBX segments and perform either of the following steps:

    1) Concatenate the values of OBX 5.1 fields and insert the concatenated value into a SQL database (as well as several other fields from the message).

    2) Read each OBX 5.1 field separately and insert a separate record for each value (as well as several other fields from the message).

  • #2
    Re: Looping through multiple OBX segments, updating SQL database

    Refer "Patients w/ multiple insurance" support forum post.



    Hope it helps.

    Comment


    • #3
      Re:Looping through multiple OBX segments, updating SQL database

      I saw the IN1 sample, and that worked for concatenating the data into one field in one record, now I need to insert each segment into a separate record.

      OBX|1|.....
      OBX|2|.....
      OBX|3|.....

      Each OBX segment above needs to be inserted into a separate record in my MS SQL database, so I end up with 3 records.

      Any help is much appreciated!

      Comment


      • #4
        Re:Looping through multiple OBX segments, updating SQL database

        Following is an example of code you can use:

        Code:
        for each (obx in msg..OBX) {
          obx[OBX.1][OBX.1.1] = value1;
          ...
          ...
          ...
        
          // insert the values into DB.
          ...
        }
        Chris Ro
        Sr. Software Engineer | Mirth Corporation

        Comment


        • #5
          Looping through multiple OBX segments, updating SQL database

          You suggest doing this in transformer or javascript within destination connector?

          Comment


          • #6
            Another example of thumbing through mulitiple OBX segments using javascript:
            ---------------------------------------------------------
            var driver = "net.sourceforge.jtds.jdbc.Driver";
            var url = "jdbc:jtds:sqlserver://aaa-sql-db:1111/ABCD";
            var user = "ABCD";
            var pwd = "";
            var dbConn = DatabaseConnectionFactory.createDatabaseConnection (driver,url,user,pwd);
            for (obxSeq in msg[SQOBXSQ]){
            var obxtype = msg[SQOBXSQ][obxSeq][SQOBX.2SQ][SQOBX.2.1SQ].toString();
            var rptline = msg[SQOBXSQ][obxSeq][SQOBX.5SQ][SQOBX.5.1SQ].toString();
            strProc = Insert stmt
            }
            dbConn.close();
            ----------------------------------------------
            hope this helps

            Comment

            Working...
            X
            😀
            🥰
            🤢
            😎
            😡
            👍
            👎