Announcement

Collapse
No announcement yet.

set delay in Postprocessor

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

  • 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
    Last edited by jmendezzz; 09-08-2010, 09:49 PM. Reason: attach channel

  • #2
    Javascript lacks a useful "sleep" function, but it works fine if you call a Java method
    which makes a "Thread.sleep(nnnn)".

    Comment


    • #3
      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.

      Comment


      • #4
        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

        Comment


        • #5
          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

          Comment


          • #6
            I use:

            java.lang.Thread.sleep(6000);

            where 6000 is milliseconds I think. Works fine for me.

            Comment


            • #7
              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.

              Comment


              • #8
                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!!!

                Comment

                Working...
                X