web stats
Second destination depending on outcome on first else an error response - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 01-18-2010, 12:53 PM
nickydavid nickydavid is offline
Mirth Newb
 
Join Date: Jun 2009
Posts: 25
nickydavid is on a distinguished road
Default Second destination depending on outcome on first else an error response

Hello All,

I have a situation where I read in an hl7 message, extract some string and send it to a webservice(my first destination). If the webservice returns with a 'true' then I send a string to my second destination(a JMS connector) which is the second destination and if it comes back with a 'false' I send back an error message/response instead.
Can someone give me suggestions on how I can accomplish this task? Is it possible to do something like this?

Thanks. I would greatly appreciate any help in this matter.
-Nicky
Reply With Quote
  #2  
Old 01-18-2010, 01:35 PM
jbartels jbartels is offline
Mirth Guru
 
Join Date: Oct 2006
Posts: 719
jbartels is on a distinguished road
Default

You want two destinations (one to send an error back, one to hit JMS) and each one has a filter that tests the response from the webservice.

You can also use the route method in a javascript step to pass the message along.
__________________
Jon Bartels

Zen is hiring!!!!
http://consultzen.com/careers/
Talented healthcare IT professionals wanted. Engineers to sales to management.
Good benefits, great working environment, genuinely interesting work.
Reply With Quote
  #3  
Old 01-18-2010, 01:50 PM
nickydavid nickydavid is offline
Mirth Newb
 
Join Date: Jun 2009
Posts: 25
nickydavid is on a distinguished road
Default

Thanks for the quick response. Just a couple of questions to clarify:
1. So in total I need 3 destinations. The last two will test the result of the first?
2. route method in javascript: Did you mean 'router.routeMessage(channelName, 'message');'. I thought this method only lets you route messages to channels and not destinations. Am I wrong?
The last question I had is about sending an error response, in another task I had used responseMap.put("ACKResponse", ResponseFactory.getSuccessResponse(finalResponse))
in a postscript to send back a response .. that was the only way to get it to work. So if you say that I have one destination for sending back the error, how exactly do I do it? I do not have the url/port number of where the hl7message comes in from to be able to send it back. I was looking for some sort of NACK sort of a thing.

Greatly appreciate your help.
Thanks a ton,
Nicky
Reply With Quote
  #4  
Old 02-22-2010, 01:56 PM
deepa deepa is offline
OBX.1 Kenobi
 
Join Date: Feb 2010
Posts: 39
deepa is on a distinguished road
Default

Hi,

I have a similar situation as Nicky. I need to make an FTP transfer, and send a success email when the transfer is successful, and send an error email when the transfer failed for some reason.
Right now, I have the src-target FTP connectors setup, and I can have two more destinations configured to send success/failure emails. How would I branch between them based on the response from the first destination ?

Thanks,
Deepa
Reply With Quote
  #5  
Old 02-23-2010, 01:21 PM
deepa deepa is offline
OBX.1 Kenobi
 
Join Date: Feb 2010
Posts: 39
deepa is on a distinguished road
Question

I just saw the sticky note on the guidelines, and wanted to provide more details about the problem.

Mirth version - Mirth Connect Administrator 1.8.2.4472

These are the different options I tried (but in vain) :

1. Created 3 destinations. First was for FTP transfer, second for a failure email, third for a success email. Created filter across second destination to accept only if the FTP response code is an error code. But I am not exactly sure of what is returned by the first destination. And this setup is not working.

2. Created a Javascript writer on destination, which would supposedly have code for transferring files on FTP, and in the catch block, I can send a failure email + return, and at the end of this all, send a success email. This is not completely implemented yet, its a whole bunch of code though.

3. Tried to access the Response from first destination in the Postprocessor. Couldnt find a handle to the Response. ResponseMap only seems to give out any keys that we would have updated earlier in the flow. And ResponseMap.getRespone() returns a new Response object. Nothing seem to return the Response from my first destination's execution of operation.

Please let me know more about the Response object returned from the destination FTP connector. How can I access this object on the script ?

Thanks in advance.
Deepa
Reply With Quote
  #6  
Old 02-23-2010, 01:54 PM
bradd bradd is offline
Mirth Employee
 
Join Date: May 2009
Location: Irvine, CA
Posts: 133
bradd is on a distinguished road
Default

In the post processor you can get the response by using the following code:


var status = responseMap.get("Destination 1").getStatus();

this should return SUCCESS or FAILURE.

use this in the post processor. This should help with routing your messages properly.

-Brad
Reply With Quote
  #7  
Old 02-23-2010, 03:07 PM
deepa deepa is offline
OBX.1 Kenobi
 
Join Date: Feb 2010
Posts: 39
deepa is on a distinguished road
Thumbs up

Yes, this works. Thanks a lot Brad!

-Deepa
Reply With Quote
  #8  
Old 03-11-2010, 12:21 AM
pleo__ pleo__ is offline
OBX.1 Kenobi
 
Join Date: Sep 2009
Posts: 37
pleo__ is on a distinguished road
Default

Quote:
Originally Posted by nickydavid View Post
Thanks for the quick response. Just a couple of questions to clarify:
1. So in total I need 3 destinations. The last two will test the result of the first?
2. route method in javascript: Did you mean 'router.routeMessage(channelName, 'message');'. I thought this method only lets you route messages to channels and not destinations. Am I wrong?
The last question I had is about sending an error response, in another task I had used responseMap.put("ACKResponse", ResponseFactory.getSuccessResponse(finalResponse))
in a postscript to send back a response .. that was the only way to get it to work. So if you say that I have one destination for sending back the error, how exactly do I do it? I do not have the url/port number of where the hl7message comes in from to be able to send it back. I was looking for some sort of NACK sort of a thing.

Greatly appreciate your help.
Thanks a ton,
Nicky
someone can answer to the second question?
many thanks!
Reply With Quote
  #9  
Old 03-18-2010, 10:42 AM
bradd bradd is offline
Mirth Employee
 
Join Date: May 2009
Location: Irvine, CA
Posts: 133
bradd is on a distinguished road
Default

route is used for routing to other channels, you are correct.
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 08:07 PM.


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