Reminder Rules - Using Javascript Conditions

Clinics can create Reminder Rules to send reminders to a sub-set of patients based on their appointment (provider, type, reason, etc) or certain demographics (age, gender, etc). 

For complex Reminder Rules, you can find some guidance on using JavaScript conditions to create a rules to suit your needs below.   For example:

"We only want to send a reminder to patients of a specific provider."

"We want to exclude virtual visit patients from receiving reminders with COVID screening."

"We want to send reminders to all patients except for patients of Providers A or B."

"We want to send reminders to any patients of Providers A or B."

"We want to send a reminder to all patients scheduled for an appointment that has a specific word or phrase in the Reason for Visit field."

Below, you can learn more about how you can configure your reminders to accommodate some of the situations above. Do you have another creative trigger to automate reminders for certain patients? Tell us about it!

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 for appointments of provider A only.
ScriptUtil.getKeyword("@providerName").includes("Provider A")
Copy 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 all appointments types or reasons for visit that contain a given text or phrase

In some cases, you may have many Appointment Types or Reasons for Visit that have common name components (e.g. 'virtual visit), but are each unique.  In some scenarios, you may want to send a reminder to all the patients that have any one of the Appointment Types or Reasons that share the common name component.  You can avoid having to create a separate reminder rule for each one and instead you can create a reminder rule that performs a partial string match (triggering for all appointment types that include a certain word or phrase).  In this case, the partial string you want to match is the common name component.   The formula below shows how a partial string match is performed:

ScriptUtil.getKeyword('@ptReasonForVisit').includes('partial string')

where the 'partial string' is the common name component of all the Appointment Types or Reason For Visits that you want to include in the reminder rule.

Action Rule
Send reminder for all appointment types with "virtual visit" in the title.
ScriptUtil.getKeyword('@ptReasonForVisit').includes('virtual visit')
Copy Rule

3. Excluding a subset of patients from a Type or Reason

If you only want some patients within an Appointment Type or Reason to receive the reminder, you can 'filter out' patients using the following approach:

!ScriptUtil.getKeyword("the field that you want to use as the filter").includes("the value you wanted to filter out")

For "the value you wanted to filter out", you will need to enter the exact text value that appears in your EMR.  (It is recommended you copy and paste it to avoid typographic errors.)

 

Action Rule
Send reminder for all appointments types except 'Tele/E-Visit'.
!ScriptUtil.getKeyword("@ptReasonForVisit").includes("Tele/E-Visit")
Copy Rule
Send reminder for appointments for all providers except 'Provider A'.
!ScriptUtil.getKeyword("@providerName").includes("Provider A")
Copy Rule

4. 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 "Tele/E-Visit" OR "In-Person" appointments.
ScriptUtil.getKeyword('@ptReasonForVisit').includes ('Tele/E-Visit') || ScriptUtil.getKeyword('@ptReasonForVisit').includes('In-Person')
Copy Rule
Send reminder only for patients of Providers "A", "B" OR "C".
ScriptUtil.getKeyword('@providerName').includes('Provider A') || ScriptUtil.getKeyword('@providerName').includes('Provider B') || ScriptUtil.getKeyword('@providerName').includes('Provider C')
Copy Rule
Send reminder for all appointment types except "Tele/E-Visit" AND "In-Person" appointments.
!ScriptUtil.getKeyword('@ptReasonForVisit').includes ('Tele/E-Visit') && !ScriptUtil.getKeyword('@ptReasonForVisit').includes('In-Person')
Copy Rule
Send reminder only for patients of Provider "A" AND an appointment type of "Tele/E-Visit" .
ScriptUtil.getKeyword('@providerName').includes('Provider A') && ScriptUtil.getKeyword('@ptReasonForVisit').includes('Tele/E-Visit')
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