Mirth Connect 4.2.0 Released!

Mirth Connect 4.2.0 is now available as an appliance update and on our GitHub page.

This is a major release containing new features like streamlining the process of selecting a listener port, adding the usernames to the overwriting channel changes warning message, adding additional, sortable columns to the Events screen, and being able to select multiple messages when sending messages through a channel. We also added new message integrity features like adding new JavaScript utility methods for hashing channel messages and automatically hashing outgoing messages. This release also contains enhancements for the Mirth Connect Administrator Launcher and several bug fixes, security improvements, and updates to the commercial extensions. See the release notes for the list of fixes and updates.

Download | See What's New | Upgrade Guide | Release Notes

For discussion on this release, see this thread.
See more
See less

How to throw Exception in Javascript

  • Filter
  • Time
  • Show
Clear All
new posts

  • How to throw Exception in Javascript

    Dear All,

    How to handle the exception using javascript?

    If Patient Name is not there in ADT message I need to throw Exception and I need not Process that message.

    I am using Mirth 1.5


  • #2
    Re:How to throw Exception in Javascript

    Use the filter to validate and reject messages before they even get to the transformer.
    Brendan Haverlock | Mirth Software Engineer | Mirth Corporation


    • #3
      Re:How to throw Exception in Javascript

      Thanks for the Help.Is it possible to show this message as Error.


      • #4
        Is it possible to show message as Error when filter false?
        And move File to Error-Directory?
        Last edited by Calle_2007; 03-21-2012, 07:09 AM.


        • #5
          Originally posted by Calle_2007 View Post
          Is it possible to show message as Error when filter false?
          And move File to Error-Directory?
          I think I've answered this same question before... maybe. You can throw an exception from your filter, which will update the message status and channel statistics accordingly. If instead you want the message to process through successfully, but the status in the database and the channel stats to reflect an error, you can do those updates manually in the postprocessor for example; search the forums for the relevant code on how to do that...

          However, I suppose this sort of defeats the purpose of a filter... generally it's there so that you can avoid processing a message for the purpose of not throwing an error. *shrugs*
          Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

          Nicholas Rupley
          Work: 949-237-6069
          Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.

          - How do I foo?
          - You just bar.


          • #6
            Originally posted by narupley View Post
            I think I've answered this same question before...
            The thread narupley is referring to is:
            Force message to Error.

            Originally posted by Calle_2007 View Post
            Is it possible to show message as Error when filter false?
            I opened a suggestion of improvement:
            [#MIRTH-2063] Choose the status of the message.

            If you have the same need, you can vote for it, and then wait for the experts to choose whether to implement it or not .
            Last edited by DBE; 03-28-2012, 08:15 AM.


            • #7
              There are a few ways you can do this.

              I would recommend against throwing an error as you may miss it in the error log.

              Here's how I would do it:

              For all cases this would be done at the filter.

              Method #1a:

              If there won't be tons of these I'd go with email alerts. You need to make sure you have an SMTP server associated in your Mirth settings.

              if (message == good) {
                return true;
              }  else {
              var smtpConn = SMTPConnectionFactory.createSMTPConnection();
              var body = 'The code ' + strOBX + ' was not found in the OBX table.\n';
              body = body + 'Please do not respond to this message.';
              smtpConn.send('', '[email protected]', '[email protected]', 'No Mapping for Code in OBX Table', body);
              return false;
              #1 b is an email sent using the Mirth alerts

              In your filter replace the email stuff with

              You'd then set up an alert for this channel in the Mirth Alerts window.

              Method #2: File Drop

              In your destination filter you'd have

              if (message == good) {
                 return true; 
              } else {
                return false;
              Create a second destination as a file drop and reverse the true/false (so it will filter if its good and go if its not).

              In your file writer I'd create a file name that is the formatted date and set the append flag to true. (This gives you one file a day).

              You can write a minimum dataset by mapping say patient name and account (or whatever you need) to the channelMap and replace your encodedData in the file writer with those values.

              The third method would be to send the bad message to a completely different channel (why you'd want to do this I don't know, but I thought of it so I'm including it)

              router.routeMessage(channelName, 'message', useQueue);
              If I need to refer to a channel from another one I add the channel name to global channel map by putting this in the monitored channel's deploy script.

              [/code]var channelName = nelController.getInstance().getDeployedChannelById (channelId).getName();


              //substitute some meaningful name for 'thischannel'


              I know I just threw a lot of info at you, let us know if you need any further assistance
              I can be reached through gmail and Google Talk using davidrothbauer at gmail dot com

              Test all my code suggestions prior to implementation