Announcement

Collapse

Mirth Connect 4.0.1 Released!

Mirth Connect 4.0.1 is now available as an appliance update and on our GitHub page. Mirth Connect 4.0.1 is a patch release containing a bug fix which includes fixing a Jetty keystore regression that caused Connect servers using a PKCS12 keystore containing a wildcard certificate and/or a certificate with a SAN to throw an exception on startup. See the release notes for the list of fixes and updates.

Download | See What's New | Upgrade Guide | Release Notes

For discussion on this release, see this thread.
See more
See less

Multiple OBX - Database writer to single line

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

  • Multiple OBX - Database writer to single line

    Hi Guys! I'm a mirth novice so please bear with me.
    I'm setting up a database writer to write ORU to database, everything is going good, but I've got multiple OBX, how can I write them in one column?

    I've attached a sample ORU message
    and a sample of what I'd like to convert it to for the database writer.

    Can somebody help direct me in the direction to achieve this?

    Thanks!
    Attached Files

  • #2
    You can merge multiple OBX in a single OBX and then upload. There are many threads on merging OBX segments. One of them is:

    http://www.mirthproject.org/communit...ead.php?t=6943

    Hopefully this should help.

    Comment


    • #3
      That would be helpful if I knew what to do with it. remember. I'm a novice here.

      I know how to create mappings so I can insert in to database. but where would I apply these scripts? (I really need some sort of dummy guide)

      Thanks!
      --Jason

      Comment


      • #4
        What version of MC are you using?

        You can manipulate messages in the Source Transformer or Destination Transformer. I personally use JavaScript 90% of the time because 1) it's super easy and 2) I tend to have a lot going on.

        I assume you're using a Database Writer destination. You can add some code in the Destination Transformer to loop through all the OBX segments into a single channelMap and plug that into the update statement.

        I have access to Version 3.2.2.x and 3.5.1.x

        Comment


        • #5
          In the destination transformer javascript use something like this.

          Code:
          var obxText = '';
          
          for each (var obr in msg.OBR) {
          	for each (var obx in getSegmentsAfter(msg,obr,'OBX', false)) {
          		obxText = obxText + obx['OBX.5']['OBX.5.1'].toString();		
          	}
          }
          
          globalChannelMap.put('allOBXValues', obxText);
          and then your update/insert statement would look something like this
          Code:
          UPDATE table_name
           SET column1 = ${allOBXValues}, 
           WHERE condition;
          I'm sure someone will correct my code but that's the gist of it.

          Comment


          • #6
            Thanks!

            just a little clarification needed
            I see your example has OBX5 and OBX 5.1

            my ORU messages can contain anywhere from OBX|1 to OBX|47 to OBX|1 to OBX|180

            how would I specify from 1 through whatever ?

            Thanks!

            Comment


            • #7
              how would I specify from 1 through whatever ?
              The looping is in the 'for each' and in conjunction with the getSegmentsAfter. This will loop through all the OBX lines and grab each OBX.5.1 and build the channelMap variable.

              So

              OBX|1||||This||||||||||||||||
              OBX|2||||is|||||||||||||||
              OBX|3||||where||||||||||||||||
              OBX|4||||it is.||||||||||||||||

              Will come out as 'This is where it is.'

              my ORU messages can contain anywhere from OBX|1 to OBX|47 to OBX|1 to OBX|180
              If you had a million OBX it would still loop through all of them.

              You can change which portion of the OBX segment you want to grab by altering the obx['OBX.5']['OBX.5.1'].toString();. If you want the OBX.8 then you wold use obx['OBX.8']['OBX.8.1'].toString();

              You MAY need to add the getSegmentsAfter function to your Mirth Application. That can be found here: http://www.mirthcorp.com/community/f...?t=6902&page=2

              Just follow the directions for implamentation

              Comment


              • #8
                You can learn more about the HL7 OBX segment here

                https://corepointhealth.com/resource...l7-obx-segment

                obx['OBX.5']['OBX.5.1'] is how mirth knows exactly were to look in the message.

                OBX.5 is the Observation Value. Because each field can have repeating values We want to look at the first one so we use obx['OBX.5']['OBX.5.1'].

                Comment


                • #9
                  OH! awesome! thanks! now one more dumb question from a complete newb.

                  how can I take this:
                  OBX|1||||This||||||||||||||||
                  OBX|2||||is|||||||||||||||
                  OBX|3||||where||||||||||||||||
                  OBX|4||||it is.||||||||||||||||

                  and make it look like this:
                  'This~ is~ where~ it~ is.~'

                  Comment


                  • #10
                    Code:
                    obxText = obxText + obx['OBX.5']['OBX.5.1'].toString() + 
                    "~";

                    Comment


                    • #11
                      Dude! you are a great! thank you so much! I'm going to go to town and play.
                      if I'm wherever you are. I owe you a drink or dinner or whatever! RSNA, HIMSS, etc.

                      Comment


                      • #12
                        Thanks! I think I'm getting close, but I got an error that I don't quite know what to do with.
                        ------------------------------------------------------
                        Transformer error
                        ERROR MESSAGE: Error evaluating transformer
                        com.mirth.connect.server.MirthJavascriptTransforme rException:
                        CHANNEL: Report Text writer
                        CONNECTOR: Destination 1
                        SCRIPT SOURCE: TRANSFORMER
                        SOURCE CODE:
                        65:
                        66: channelMap.put('PatientID', validate( mapping , '', new Array()));
                        67: var obxText = '';
                        68:
                        69: for each (var obr in msg.OBR) {
                        70: for each (var obx in getSegmentsAfter(msg,obr,'OBX', false)) {
                        71: obxText = obxText + obx['OBX.5']['OBX.5.1'].toString() + "~";
                        72: }
                        73: }
                        74:
                        LINE NUMBER: 70
                        DETAILS: ReferenceError: "getSegmentsAfter" is not defined.
                        at 06142945-9aa0-4527-818c-3a7803ac533d:70 (doTransform)
                        at 06142945-9aa0-4527-818c-3a7803ac533d:107 (doScript)
                        at 06142945-9aa0-4527-818c-3a7803ac533d:109
                        at com.mirth.connect.server.transformers.JavaScriptFi lterTransformer$FilterTransformerTask.doCall(JavaS criptFilterTransformer.java:154)
                        at com.mirth.connect.server.transformers.JavaScriptFi lterTransformer$FilterTransformerTask.doCall(JavaS criptFilterTransformer.java:119)
                        at com.mirth.connect.server.util.javascript.JavaScrip tTask.call(JavaScriptTask.java:113)
                        at java.util.concurrent.FutureTask.run(Unknown Source)
                        at java.util.concurrent.ThreadPoolExecutor.runWorker( Unknown Source)
                        at java.util.concurrent.ThreadPoolExecutor$Worker.run (Unknown Source)
                        at java.lang.Thread.run(Unknown Source)

                        Comment


                        • #13
                          You need to add the getSegmentAfter code into your MC templates.

                          Comment


                          • #14
                            Man! I'm starting to feel like an uber super newb.

                            How do I do that?

                            And I'm really going to owe you a dinner!

                            Comment


                            • #15
                              Method 1
                              • Download the "getSegmentsAfter (new 2-13-13).xml" file from the link.
                              • On the left side of Mirth Connect click Channels.
                              • Then click Edit Code Templates
                              • Then click Import Code Template
                              • Find the xml file you just downloaded and it will install.
                              • Deploy your channel


                              Method 2
                              • On the left side of Mirth Connect click Channels.
                              • Then click Edit Code Templates
                              • Select New Code Template (If you're using 3.5.1 you may need to select an existing library first)
                              • Select Function from the drop list
                              • Paste the code from the forum link into the Code area.
                              • Edit the Name and Description of the template if desired.
                              • Deploy your channel

                              Comment

                              Working...
                              X