Announcement

Collapse
No announcement yet.

Help with Simple OBX file reader

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

  • Help with Simple OBX file reader

    I am trying to just pass on everything that I get in a channel to an output file but can't figure out how to handle the case where there may be multiple OBX lines of different lengths (see below sample). I have set up a transformer to handle the MSH, PID, PVI and other segment mapping but how do I map the dynamic nature of multiple OBX? Do I just add an output template with every possible filed configuration? Can someone please help me understand how to achieve this?

    OBX|1|FT|
    OBX|2|FT|||This is a test report.|
    OBX|3|FT|
    OBX|4|FT|
    OBX|5|FT|
    OBX|6|FT||| ______________________________|
    OBX|7|FT||| DOC TEST|
    OBX|8|FT|
    OBX|9|FT|||TR: hts |
    OBX|10|FT|||DD: 07/12/2010 10:37:01|
    OBX|11|FT|||DT: 07/12/2010|
    OBX|12|FT|||Job#: 123|

  • #2
    With the given input, what is the output you expect?
    JJ Mouris
    FFE Luxembourg
    IT-Department

    Comment


    • #3
      Repeating Segments

      Anytime that you have a segment that can repeat (such as an OBX), you need to use a JavaScript type transformer step with a loop to access the segments, since obviously you won't know in advance how many instances of the segment that you'll have.

      There are a couple of different ways to accomplish this. One is to loop over all segments, checking the name of the segment each time through the loop. The other is to iterate over only named segments (such as OBX). There are templates available for both of these methods in the code template listing on the Reference tab in the transformers view. They're under the Message Functions category.

      Comment


      • #4
        Mourisj; I want it to output exactly as it is in the incoming message. I'm using the transformer to move a few things around in the other segments but want to keep this OBX part the same.
        Last edited by steveman; 07-14-2010, 01:24 PM.

        Comment


        • #5
          Originally posted by ericb View Post
          Anytime that you have a segment that can repeat (such as an OBX), you need to use a JavaScript type transformer step with a loop to access the segments, since obviously you won't know in advance how many instances of the segment that you'll have.

          There are a couple of different ways to accomplish this. One is to loop over all segments, checking the name of the segment each time through the loop. The other is to iterate over only named segments (such as OBX). There are templates available for both of these methods in the code template listing on the Reference tab in the transformers view. They're under the Message Functions category.
          Thanks Eric - I take a look there. If any one has a direct example though it would be appreciated

          Comment


          • #6
            I tried what I thought would work below but still no joy. What am I doing wrong?

            var count = 0;
            for each (obx in msg..OBX)
            {
            var sample_value = obx['OBX.1']['OBX.1.1'].toString();
            }
            tmp['OBX'][count]['OBX.1']['OBX.1.1'] = msg['OBX']['OBX.1']['OBX1.1.1'][count].toString()
            count++;

            Comment


            • #7
              // Try this code.


              var msg=new XML(channelMap.get('msg').toString());

              var sql='';
              var i=0;

              for each(segment in msg.children())
              {
              if (segment.name().toString() == "OBR")
              {
              sql="value of i: " + i + ", results of sql: ";
              sql=sql + msg['OBX'][i]['OBX.1']['OBX.1.1'].toString();
              sql=sql + msg['OBX'][i]['OBX.2']['OBX.2.1'].toString();
              sql=sql + msg['OBX'][i]['OBX.3']['OBX.3.1'].toString();
              sql=sql + msg['OBX'][i]['OBX.3']['OBX.3.2'].toString();
              sql=sql + msg['OBX'][i]['OBX.4']['OBX.4.1'].toString();
              sql=sql + msg['OBX'][i]['OBX.5']['OBX.5.1'].toString();
              sql=sql + msg['OBX'][i]['OBX.6']['OBX.6.1'].toString();
              sql=sql + msg['OBX'][i]['OBX.7']['OBX.7.1'].toString();
              sql=sql + msg['OBX'][i]['OBX.8']['OBX.8.1'].toString();
              sql=sql + msg['OBX'][i]['OBX.9']['OBX.9.1'].toString();
              sql=sql + msg['OBX'][i]['OBX.10']['OBX.10.1'].toString();
              sql=sql + msg['OBX'][i]['OBX.11']['OBX.11.1'].toString();
              logger.info(sql);
              i++;
              }
              }
              dbConn.close();

              Comment


              • #8
                thanks but I am actually wanting to write this back to a file not sql plus I don't know how many OBX segments or fields will be in each message as this is dynamic.

                Is there any way to just write out exactly what the OBX segments I get in each message back to the new destination file?

                Comment


                • #9
                  try this:

                  for each (seg in msg..OBX){
                  pdfTemplate = pdfTemplate + seg['OBX.5']['OBX.5.1'] + '\n';
                  pdfTemplate = pdfTemplate +"<br/>"
                  }

                  Comment

                  Working...
                  X