Announcement

Collapse
No announcement yet.

Using Filters to send to Multiple Destinations

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

  • Using Filters to send to Multiple Destinations

    Hi,

    I haven't used Filters at all yet in Mirth, but I am assuming I need to in this situation.

    I have a Channel that builds a CSV file with 3 different sets of data. Depending on which data is returned, that section is filled in with data and the rest of the CSV message is just blanks and commas. I wish to break this 1 file down into 3 different files. I am assuming I need to create 3 Destination's and use filters to split apart the message and pass them to the right destination, but I am not sure how the syntax to the Filtering should go.

    Currently, my CSV file can looks like 1 of the following examples:
    ,,,,,,,,,,,,,,,,LAB,437707,725,PRE,000025,20090106 ,6.0,MG/DL
    MED,605252,000025,EPOGEN,039345,20090429,IV,3000,, UNIT,C,,,,,,,,,,,,,
    ,,,,,,,,,,,KTV,426454,20090429,Kt/V,1.05,,,,,,,,


    I wish to have 3 separate files created that looks like the following(basically without the commas):
    LAB,437707,725,PRE,000025,20090106,6.0,MG/DL
    MED,605252,000025,EPOGEN,039345,20090429,IV,3000,, UNIT,C
    KTV,426454,20090429,Kt/V,1.05

  • #2
    Ok,

    Made some progress. Created 3 different Destination Channels, each with a filter that like the following, depending on which type of message it is

    Code:
    if (msg['row']['column1'].toString() == 'MED' ) {return true;}
    else {return false;}
    Now, though, I am left with a all of the commas, which i need to get rid of.

    Currently:
    MED,605252,000025,EPOGEN,039345,20090429,IV,3000,, UNIT,C,,,,,,,,,,,,,

    Need after filtering and sending to Destination:
    MED,605252,000025,EPOGEN,039345,20090429,IV,3000,, UNIT,C


    Is there a way to tell Mirth to only send data up to a certain column? So, in this case, I could tell it "only send values up to [column][10]"?

    Comment


    • #3
      Well...spent the last few days messing with Filters, Transformers, Javascript code...to no avail. Can't get rid of those pesky comma's.

      Comment


      • #4
        Look into using the javascript substr or substring to remove last n commas.

        http://www.w3schools.com/jsref/jsref_substring.asp

        Comment


        • #5
          So, I tried the following and neither worked. Is the message even editable after it has been Filtered and sent to a Destination? I tried this in 1 of my Destination Transformers:

          My string looks like this after it has been Filtered:
          Code:
          MED,605252,000025,EPOGEN,039345,20090429,IV,3000,, UNIT,C,,,,,,,,,,,,,
          I am trying to remove the trailing commas with either of these two:
          Code:
          message = message.TrimEnd(',')
          Code:
          message = message.toString().substr(-13);
          The Trimend() Mirth complains about not seeing the function in the javascript library.

          The subStr() function appears to have no effect at all when I look at the 'Sent' messages. The string shown in the message is the same as when it was created.

          Comment

          Working...
          X