Jobs for Miracle Feet's CommCare to Salesforce integration, using the Open Function platform. See the MiracleFeet India repository for more on the India CAST app integration.
N.B., all changes to the master
branch will be automatically deployed to Open Function.
MiracleFeet has configured CommCare to deliver the "CAST" application to support partner treatment providers and service delivery across 26 countries.
MiracleFeet has implemented OpenFn to automate one-way data integration between CAST (CommCare) and the MF Global System (Salesforce) for real-time monitoring and reporting across CommCare form submissions and case updates.
forms
or modify cases
in CommCareInbox
as Messages
humanProper(...)
(e.g.,field('gciclubfoot__Brace_Problems__c', humanProper(state.data.properties.brace_problems)),
) will work for new language-common version. MiracleFeet global administrators are responsible for integration monitoring & reprocessing of any failed runs. For additional OpenFn support, users may contact support@openfn.org.
Originally the SMS scheduling solution relied on CommCare form updates received in the OpenFn inbox to schedule messages. It has been re-designed to achieve the same functionality based on patient details fetched from Salesforce. See here for the data flow diagrams.
Watch the solution overview video for the original CommCare-Infobip SMS integration for patient visit reminders and educational SMSs.
And see here for the original project concept.
Prerequisites Patients' Salesforce information necessary for SMS scheduling is now being synced from CommCare via the existing Add new patient, Update Patient, Add new visit and Update visit jobs when an update happens in CommCare. These update the new Salesforce fields: SMS Treatment, SMS Original Treatment, SMS Treatment Start Date, and the Pronoun fields. We also make use of the Patient First Name, Guardian First Name, Brace Problems Type, Last and Next Visit dates, and the Send SMS and SMS Opt In fields to create messages and verify consent.
Inbox Security is set up for the projec with Basic Authentication.
How it works...
We have separate jobs to schedule "Bracing Night" messages and to handle changes in clinic status.
A high-level overview of the SMS jobs can be found here.
The following diagrams describe the SMS scheduling/cancelation logic for the different flows.
Alert IDs in the diagrams (e.g. Alert 8
) refer to # Alert in the Master Mapping Table. Admins can check all information on the alert (scheduling time, condition for scheduling, SMS text and translations) in the sheet by Alert ID.
Overview
bulkId
-s. bulkId
are constructed from the alert ID (e.g. casting_intro-1
and the CommCare case_id
: casting_intro-1-XXX
. They are used to uniquely identify SMS-s in Infobip. upsert
logic in Infobip: when scheduling or deleting an SMS, OpenFn first checks if an SMS with the corresponding bulkId
has already been scheduled for the future or already sent. If this is the case, no changes are made. If the SMS hasn't been scheduled or sent, it gets scheduled.bulkId
has been scheduled for the future or already sent. If it is scheduled, it gets canceled.8
and 9
of the bracing-night messages and all the other (non-bracing-night) alerts. The bracing-night job only schedules alerts 9B
to 9P
.Guardian_1_Phone_Landline__c == false
on the Patient's Salesforce profile.Logic for setting missed appointment reminders
SMS reminders are scheduled to be sent if a patient misses an appointment they are scheduled for. This is set when a new next_visit_date
is added. If there were alerts set for previous visits, those are canceled in Infobip.
Used values: last_visit_date/original_next_visit_date
for previous scheduled visits, next visit date
for next visit
Steps
Check if there’s a last visit date. If so, check if these bulkIDs have been scheduled
visitAfter1-{form.case.@case_id}-{last_visit_date}
visitAfter2-{form.case.@case_id}-{last_visit_date}
If yes, delete them.
Schedule the reminders with the current next visit date
visitAfter1-{form.case.@case_id}-{next_visit_date}
visitAfter2-{form.case.@case_id}-{next_visit_date}
Scheduling a message on the Infobip API
curl --location --request POST 'https://apidomain.infobip.com/sms/1/text/advanced' \
--header 'Authorization: App ${api_key}' \
--data-raw '{"bulkId": "bracing_day-6-345678", "messages":[{"from": "+111","destinations": [{"to": "+111"}],"text": "A long time ago, in a galaxy far, far away...","sendAt": "2021-12-24T18:20:00.000"}]}'
Opt-in, opt-out
Send_SMS__c = true
SMS_Opt_In_II__c = true
SMS_Opt_In__c = true
Treatment changes, stopping treatment
When a patient is marked as stopped, suspended or completed treatment, they will no receive educational messages and visit reminders. If they move from one treatment to a different one, educational messages for the original treatment are stopped and SMS campaign for the new treatment is scheduled.
Scheduling "Bracing Night" SMSs
Since September 2021 it's not possible to schedule messages on the Infobip API for more than 6 month ahead.
The Bracing Night
SMS campaign runs for more than 3.5 years. We use the following process to schedule these messages:
We run the [Bracing-night 1] Fetch bracing night contacts from SF job to check on SF if there's any contact that has Bracing Night set as SMS Treatment.
The [Bracing-night 2] Schedule bracing night SMSs will then automatically launch to schedule any necessary SMSs for the next 3 months, based on the SMS_Treatment_Start_Date__c
field.
Clinic status and SMS scheduling
Clinic status is set in Salesforce, in the Status field.
All "Actively supported" clinics are eligible for SMS (although not all have it turned on)
We run the [Deactivation-1] Fetch Inactive Clinics from SF job daily to check for clinics that are inactive and disable SMS-s for associated patients guided by the below logic:
To enroll a new country to SMS
send_sms
field)Account.Country__c in ('Nigeria', 'Uganda')
To update SMS scheduling times, SMS templates, SMS language codes, or add new translations:
Migration Checklist
Access here.
node mappings/converter.js
To add/remove alerts or reminders, update CommCare field names, change opt-in/opt-out conditions, add new CommCare forms that trigger SMS-s, or any other change, contact support@openfn.org.
SMS scheduling only happens for patients whose Clinic Status
in Salesforce is either in "Actively Supported" or "Temporarily Suspended". In order to add or remove clinic from the scheduling flow, change the Clinic Status accordingly. To opt a clinic into SMS alerts, this Status
should be updated in Salesforce.
Administrator Training Slides
Change Management Training Slides
Salesforce-based flow roll-out
Brace Problems Type
data to patients in SalesforceOriginal flow roll-out