No announcement yet.

Multiple OBX Segments from query

  • Filter
  • Time
  • Show
Clear All
new posts

  • Multiple OBX Segments from query

    Hello to all! I apologize if this has already been addressed elsewhere but I was unable to locate it.

    I am new to Mirth connect and am attempting to use a database query to create an HL7 v2.3 message. Where I am stuck is in the creation of multiple OBX segments during the mapping. Each OBX segment will have the same values in all areas except the SETID (OBX 1) and Observation Value (OBX 5).

    I can manipulate the database query as needed to make mapping as easy as possible in MIRTH but an unsure how to begin.

    Thanks in advance!

    Wade Z.

  • #2
    Are you using a Database Reader? If so, note that each row in the result set will be processed as a discrete message through the channel. It sounds like instead what you want is to aggregate the rows together and send only a single message through. We have an open issue for that (MIRTH-2337) but in the meantime you can use a JavaScript Reader instead, build up a custom message, and return it. Then in your transformer you can build an HL7 message, iterating through each row in your inbound message and creating an OBX segment for each one.
    Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

    Nicholas Rupley
    Work: 949-237-6069
    Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.

    - How do I foo?
    - You just bar.


    • #3
      Thanks for your comments. Just to clarify the database query will only return one result per message that needs to be sent.

      I will be creating one long string field containing all of the OBX values necessary. My thought was that I could use a delimiter of some sort so that the transformer can parse the large string and create segments for each delimited section as well as increment the OBX setid.

      For example my OBX query value could look like the following with a bar delimiter "visit for diabetes|patient name|visit date|medication list|"

      MY OBX segments after processing would look something like the following

      OBX|1|ST|NOTE||visit for diabetes||||||F||||||
      OBX|2|ST|NOTE||patient name||||||F||||||
      OBX|3|ST|NOTE||visit date||||||F||||||
      OBX|4|ST|NOTE||medication list||||||F||||||

      Is something that can be accomplished?


      • #4
        Certainly possible, I do this kind of thing all the time. My exact process is a little different than yours, but nothing you can't adjust to suit your needs.

        What I do instead of creating a single string delimited is to actually produce a full message, then any custom values I need I put into the very last segment of the message and in the transformer the message is auto converted to xml so I can just do something like:

        connectorMap.put('value1', msg['NTE']['NTE.1']['NTE.1.1'].toString());

        In your situation, using the pipes as my loop control and assuming you're doing all this from javascript:

        mySplitString = myDBString.split('|');
        var obxCounter = 1;
        for (var i = 0;i<=mySplitString.length() - 1;i++)
           createSegmentBefore('OBX', msg.NTE);
           msg['OBX']['OBX.1']['OBX.1.1'] = obxCounter;
           msg['OBX']['OBX.5']['OBX.5.1'] = mySplitString[i];

        So even if you don't do exactly what I do, you could still use a transformer to parse your database returned string and work with the values accordingly.
        Last edited by skekasaurus; 03-04-2014, 12:47 PM.
        Mirth Connect v3.2.2
        Java 8
        SQL Server 2005


        • #5
          Thanks for the reply I will give this a shot and let you know what I come up with.