web stats
Using Filters to send to Multiple Destinations - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 03-04-2011, 12:19 PM
upstart33 upstart33 is offline
Mirth Guru
 
Join Date: Dec 2010
Location: Chicago, IL.
Posts: 459
upstart33 is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 03-04-2011, 12:51 PM
upstart33 upstart33 is offline
Mirth Guru
 
Join Date: Dec 2010
Location: Chicago, IL.
Posts: 459
upstart33 is on a distinguished road
Default

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]"?
Reply With Quote
  #3  
Old 03-08-2011, 12:48 PM
upstart33 upstart33 is offline
Mirth Guru
 
Join Date: Dec 2010
Location: Chicago, IL.
Posts: 459
upstart33 is on a distinguished road
Default

Well...spent the last few days messing with Filters, Transformers, Javascript code...to no avail. Can't get rid of those pesky comma's.
Reply With Quote
  #4  
Old 03-08-2011, 01:22 PM
bradd bradd is offline
Mirth Employee
 
Join Date: May 2009
Location: Irvine, CA
Posts: 133
bradd is on a distinguished road
Default

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

http://www.w3schools.com/jsref/jsref_substring.asp
Reply With Quote
  #5  
Old 03-09-2011, 05:40 AM
upstart33 upstart33 is offline
Mirth Guru
 
Join Date: Dec 2010
Location: Chicago, IL.
Posts: 459
upstart33 is on a distinguished road
Default

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.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 09:29 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation