Announcement

Collapse
No announcement yet.

How do I read multi-value OBX segments

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

  • How do I read multi-value OBX segments

    I have an HL7 message consisting of the following OBX segments. How do I extract the data from OBX-2 (foo2) without extracting the previous or next values?

    OBX|1|FT|TXT^TEXT|1|foo1||||||F||||||
    OBX|2|FT|TXT^TEXT|2|foo2||||||F||||||
    OBX|3|FT|TXT^TEXT|3|foo3||||||F||||||

  • #2
    Re: How do I read multi-value OBX segments

    OK, I figured that question out. I made my Transformation Mapping look like this
    msg['OBX'][1]['OBX.5']['OBX.5.1'].toString() and that returned 'foo2'.

    The only problem with this approach is that I don't know how many OBX segments there are. Is there a way to determine how many OBX there are and then return the value of each segment on a seperate line?

    Comment


    • #3
      Re: How do I read multi-value OBX segments

      Sample code below uses shows how to process multiple patient insurance. Similar code should work for multiple OBX segments too.

      Hope it helps!

      Code:
      var i = 0;
      // Check if the InsuranceCarrierID exist
      while (msg['ADT_A01.INSURANCE']['IN1']['IN1.3']['CX.1'][i] != null) {
         // Get the insurance carrier id               
         tempInsuranceCarrierID = msg['ADT_A01.INSURANCE']['IN1']['IN1.3']['CX.1'][i].toString();
         if (tempInsuranceCarrierID.length > 0) {	     
          ...
         }
         // increment index to process the next patient insurance, if any
         i = i + 1;
      }

      Comment


      • #4
        Re: How do I read multi-value OBX segments

        Thanks, that will help tremendously. As you can tell, I am a newbie when it comes to Mirth, so hopefully this next questions is not too bad....

        Where would I put something like that? I can't seem to find any good documentation for transformations, templates, filters, etc.

        Comment


        • #5
          Re: How do I read multi-value OBX segments

          You need to create JavaScript Transformer step. In the Transformer screen, when you do "Add Step", you see a row with "newVar0" under column "Name" and "Mapper" under column "Type". Double click under "Type" it should show a list box with "Mapper" and "JavaScript" dropdown. Select "JavaScript".

          Refer to the samples in FileRepository and Wiki:

          FileRepository
          http://www.mirthproject.org/index.ph...cman&Itemid=43

          Wiki
          http://www.mirthproject.org/index.ph...wiki&Itemid=44

          Comment


          • #6
            Re: How do I read multi-value OBX segments

            Thanks, that worked like a charm. I still wondering if I am trying to over complicate things. Here is my scenario:

            I want to open an HL7 message from the file system (File Reader Source) and write the message to a PDF (document writer). I want to extract segment 5 into the PDF template (which works) but I want to put blank lines where segment 5 contains no data (right now, it prints the entire HL7 message onto the template with no line breaks or carriage returns). Is there an easy way to do this?

            Comment


            • #7
              Re: How do I read multi-value OBX segments

              Refer:
              [orange]
              Carriage return PDF and Text doc formatting
              [/orange]
              http://www.mirthproject.org/index.ph...=318&Itemid=63
              [orange]
              can I do hl7 to pdf?
              [/orange]
              http://www.mirthproject.org/index.ph...=345&Itemid=63

              Hope it helps!

              Comment


              • #8
                Re: How do I read multi-value OBX segments

                Unfortunately, its not quite what I want to do. I have a message as

                OBX|1|FT|TXT^TEXT|1|testing segment 1||||||F||||||
                OBX|2|FT|TXT^TEXT|2|||||||F||||||
                OBX|3|FT|TXT^TEXT|3|testing segment 3||||||F||||||
                OBX|4|FT|TXT^TEXT|4|testing segment 4||||||F||||||

                If I create a Transformer with a variable ${Test}and a mapping of msg['OBX']['OBX.5']['OBX.5.1'].toString(), and then drag the variable ${Test} from the Destination Mapping section on the Channel, the message gets created on the PDF as

                testingsegment1 testingsegment 3 testing segment 4 (All on the same line)

                What I want it to look like is:

                Testing segment 1 (New line)
                (blank line since segment 2 has no data)
                Testing segment 3 (New Line)
                Testing segment 4 (New Line)

                Thanks for all your help so far. I feel like I am starting to really learn the product and already came up with quite a number of future uses.

                Comment


                • #9
                  Re: How do I read multi-value OBX segments

                  You can format and layout your PDF documents by using HTML in your template. Just layout your report using tables and put in the testing segment variables where you would like them (see nshaik's links for examples).

                  Gerald
                  Gerald Bortis | Chief Information Officer | Mirth Corporation

                  Comment


                  • #10
                    Re: How do I read multi-value OBX segments

                    Geraldb. Thanks for the reply.

                    I have a feeling i'm not explaining myself well. If you look at my previous post, you will see that I am only creating one transformer variable (${Test}). That one variable contains the value "testingsegment1 testingsegment 3 testing segment 4" (All on the same line).

                    What I really need to do is break out those values into multiple variables so that I can format them in tables correctly. However, I can't figure out how to break them out in seperate variables since "msg['OBX']['OBX.5']['OBX.5.1'].toString()" returns all the OBX values mentioned above.
                    And I can't specify "msg['OBX']['OBX.5']['OBX.5.1'][i].toString()" without doing some javascript function since I don't know what "i" could be.

                    If I do attempt to use javascript, I can't figure out how to return a var to the template to be printed????

                    I am sure I am just missing something and it is a very easy fix to do what I need.

                    Comment


                    • #11
                      Re: How do I read multi-value OBX segments

                      nshaik or anyone else: If I was using your javascript you gave above, in the following function

                      tempInsuranceCarrierID = msg['ADT_A01.INSURANCE']['IN1']['IN1.3']['CX.1'][i].toString();
                      if (tempInsuranceCarrierID.length > 0) {
                      ...
                      }

                      How do I return the value of tempInsuranceCarrierID to the template section so it can be printed on a PDF?

                      Comment


                      • #12
                        Re: How do I read multi-value OBX segments

                        Use connectorMap.put('tempInsuranceCarrierID&#039 ;, tempInsuranceCarrierID);
                        Chris Lang

                        Comment


                        • #13
                          Re: How do I read multi-value OBX segments

                          Awsome.... Thanks chrisl. Thats what I needed.

                          Comment

                          Working...
                          X