Reminder Rules - Using Javascript Conditions

Most reminder rules can be built using our simple rule builder. In special cases when our simple rule builder can't meet your needs, you can use JavaScript expressions to create a reminder rule.

1. Specifying a subset of patients using keywords

You can use keywords as a filter to only send reminders to patient appointments that meet that specific criteria. The most common criteria can be triggered using ScriptPatient functions and ScriptUtil functions. These functions are formulated as follows:

Object.function('relevant keyword') == 'value that meets the specific criteria

For "Object.function", select between ScriptPatient functions or ScriptUtil functions. 

For "relevant keyword", use Ocean keywords

For "value that meets the specific criteria", you will need to enter the exact text value. If this is a value from your EMR (e.g. appointment type or reason for visit), it is recommended you copy and paste it directly from your EMR to avoid typographic errors.

Provider names and appointment types can sometimes be returned inconsistently from EMRs. We use .includes instead of an exact match (==) as a catch all to cover these cases. 

Action Rule
Send reminder only for patients over the age of 55.
pt.getAge() > 55
Copy Rule
Send reminder only for female patients.
pt.isFemale()
Copy Rule

2. Including patients that meet one of multiple criteria

You may wish to set a single reminder rule that will be sent for any appointment that meets any one of several criteria. Your first step is to determine the criteria that needs to be met in order for the reminder rule to trigger. You can use the 'or' operand || (two parallel bars), or the 'and' && (two ampersands) within the Javascript condition to specify your condition. Use 'or' to trigger the reminder if any of the conditions apply. Use 'and' to trigger the reminder if all conditions apply.

Action Rule
Send reminder for all female patients over the age of 55.
pt.isFemale() && pt.getAge() >= 55
Copy Rule
Send a reminder for all appointments except those containing "VV" AND "TEL"
!ScriptUtil.getKeyword('@ptReasonForVisit').includes ('VV') && !ScriptUtil.getKeyword('@ptReasonForVisit').includes('TEL')
Copy Rule

3. OSCAR PRO users: key in on free-text Reason field

  • OSCAR PRO contains two Reason fields in the appointment window. Our reminders rule builder by default keys in on the value in the reason drop down. It's possible to key in on the free-text field by using JavaScript expressions.
  • It's also possible to key in on an appointment with both a type and free-text in the reason field. Ocean will string together the Appointment Type and free-text field using a dash "-". Ensure that you are copying the appointment type label verbatim from your EMR. 
Action Rule
Send reminder for appointment containing "video" in the free-text Reason field.
ScriptUtil.getKeyword('@ptReasonForVisit').includes('video')
Copy Rule
Send reminder for appointments with "Initial Intake" AND "video" in the free-text Reason field.
ScriptUtil.getKeyword('@ptReasonForVisit').includes ('Initial Intake-video')
Copy Rule

Test your Reminders

When creating a new reminder rule, especially one that involves custom JavaScripts like the examples above, it's always a good idea to run a test to ensure the script runs as desired. Learn more about Testing Reminders.

Have more questions? Submit a request