web stats
set delay in Postprocessor - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 09-08-2010, 10:47 PM
jmendezzz jmendezzz is offline
OBX.2 Kenobi
 
Join Date: Nov 2009
Posts: 85
jmendezzz is on a distinguished road
Default set delay in Postprocessor

Mirth Version: 1.8.2

Hi everyone,

I have a channel that receives(source) HL7 messages via LLP Listener and appends to a file as long as the filename exist in that folder if not it creates a file. The logic is as follow: I have a transformer that every time it receives a message it checks if a file with the placer order id exist(ORC-2) if it does, then remove most of the msh and append the message to the existing file. Next i have a postprocessor javascript that will check if the message contains a flag in OBR-30 of "F" if it does then move file to the next folder. The problem i am encountering is that sometimes the sender application may send two messages in 1 to 6 seconds apart where OBR-30 contains the flag of "F" at that point the postprocessor javascript moves the file to another folder. I am trying to delay the postprocessor javascript from moving that file for about 6 seconds, i tried using the setTimeout function. I created a function for the setTimeout and created another function in which i wrapped the postprocessor javascript but to no avail. i am attaching the channel to see if anyone can provide any ideas or solutions as to how i can create a delay in the postprocessor or how i can work around this. Thanks in Advance!
Attached Files
File Type: xml GROUP_RESULTS.XML (21.0 KB, 24 views)

Last edited by jmendezzz; 09-08-2010 at 10:49 PM. Reason: attach channel
Reply With Quote
  #2  
Old 09-08-2010, 10:57 PM
lgoran lgoran is offline
Mirth Newb
 
Join Date: Sep 2010
Posts: 14
lgoran is on a distinguished road
Default

Javascript lacks a useful "sleep" function, but it works fine if you call a Java method
which makes a "Thread.sleep(nnnn)".
Reply With Quote
  #3  
Old 09-09-2010, 08:16 AM
jmendezzz jmendezzz is offline
OBX.2 Kenobi
 
Join Date: Nov 2009
Posts: 85
jmendezzz is on a distinguished road
Default

Thank you, for your reply but how do i go about calling a java class within Mirth. if you can provide me a snippet of how i can go about doing that. Thanks again.
Reply With Quote
  #4  
Old 09-09-2010, 08:40 AM
asulis asulis is offline
Mirth Guru
 
Join Date: Dec 2006
Location: Cagliari, Sardinia, Italy
Posts: 210
asulis is an unknown quantity at this point
Default

This is a simple javascript function I found to make a sleep and it works for me:
Code:
function pausecomp(millis)
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); }
while(curDate-date < millis);
}
Hope this helps
Alessandro
Reply With Quote
  #5  
Old 09-09-2010, 01:52 PM
lgoran lgoran is offline
Mirth Newb
 
Join Date: Sep 2010
Posts: 14
lgoran is on a distinguished road
Default

The "pausecomp" function will certainly work, but it will be a terrible performance
killer. I would not use it in a production system.

Read this article about calling a Java class from Javascript:
http://www.mirthcorp.com/community/w...ode+from+Mirth
Reply With Quote
  #6  
Old 09-13-2010, 12:36 PM
TMarz TMarz is offline
OBX.2 Kenobi
 
Join Date: Jul 2009
Posts: 60
TMarz is on a distinguished road
Default

I use:

java.lang.Thread.sleep(6000);

where 6000 is milliseconds I think. Works fine for me.
Reply With Quote
  #7  
Old 09-13-2010, 12:45 PM
lgoran lgoran is offline
Mirth Newb
 
Join Date: Sep 2010
Posts: 14
lgoran is on a distinguished road
Default

Quote:
Originally Posted by TMarz View Post
I use:

java.lang.Thread.sleep(6000);

where 6000 is milliseconds I think. Works fine for me.
Certainly much easier than bulding a Java class and put it in a jar-file the way I
suggested.
Reply With Quote
  #8  
Old 07-19-2018, 01:25 PM
stormcel stormcel is offline
OBX.3 Kenobi
 
Join Date: Mar 2010
Location: Phoenix
Posts: 154
stormcel is on a distinguished road
Default

this is an old thread, but I had to add my two cents.
I got a lot of conflicting advice and this little thread sleeper just saved my bacon!!!
So thanks.
And to all the newbies out there...
Search the forum!!!!
There are gems like this in here!!!
Reply With Quote
Reply

Tags
hl7, postprocessor

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 06:01 AM.


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