web stats
Filter with multiple conditions - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Thread Tools Display Modes
Old 11-04-2019, 07:19 AM
pfrey pfrey is offline
OBX.1 Kenobi
Join Date: May 2007
Posts: 26
Default Filter with multiple conditions

I am trying to create a filter that will look to see if a message meets multiple conditions to filter the message or allow it through. The filter needs to look at both the type of Order (OBR 4.2) and the Ordering Physician (OBR 16.1). If both the order type and ordering physician do not equal specific values then it should allow the message through. Right now it is filtering the message if even one of the fields meets the criteria. Here is the javascript that I am using.

if (( $('OrderType') != "CARDIAC" || $('OrderType') != "ABI" || $('OrderType') != "CARTID" || $('OrderType') != "LEADBIL" || $('OrderType') != "LEADBIX" || $('OrderType') != "LEADIBIL" || $('OrderType') != "LEADILT" || $('OrderType') != "LEADIRT" || $('OrderType') != "LEADLT" || $('OrderType') != "LEADRT" || $('OrderType') != "LEADUBIL" || $('OrderType') != "LEALT" || $('OrderType') != "LEART" || $('OrderType') != "LEVREF") && ($('OrderPhys') != "MIRZU" || $('OrderPhys') != "HARED" || $('OrderPhys') != "HARAC")) {
return true;
Reply With Quote
Old 11-04-2019, 07:30 AM
cory_cole cory_cole is offline
Mirth Guru
Join Date: Mar 2012
Posts: 1,310
cory_cole is on a distinguished road

change || to &&
Reply With Quote
Old 11-04-2019, 12:09 PM
agermano agermano is offline
Mirth Guru
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,028
agermano is on a distinguished road

Cory is right. Changing all of your ORs to ANDs will fix the problem.

If you want to use some javascript features and make the code a little easier to manage, you can do something like below. I'd recommend putting the codes in an order that makes them easy to locate.

PHP Code:
var orderTypes = [

orderDocs = [

notEquals(string) {
    return function 
notEquals(other) { return string != other; };

orderTypes.every(notEquals($('OrderType'))) && orderDocs.every(notEquals($('OrderPhys'))); 
Reply With Quote

if statement, multiple conditions

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 10:09 PM.

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