Registrations: Defining SMS workflows with schedules, registration, and patient reports.

The registrations key contains actions that need to be performed for incoming reports of the specified form.

app_settings.json .registrations[]

formForm ID that should trigger the schedule.yes
eventsAn array of event object definitions of what should happen when this form is received.yes
event[].nameName of the event that has happened. The only supported event is on_create which happens when a form is received.yes
event[].triggerWhat should happen after the named event. assign_schedule will assign the schedule named in params to this report. Similarly clear_schedule will permanently clear all messages for a patient or place that are part of schedules listed in the params field. The full set of trigger configuration directives are described here.yes
event[].paramsAny useful information for the event. In our case, it holds the name of the schedule to be triggered.no
event[].bool_exprA JavaScript expression that will be cast to boolean to qualify execution of the event. Leaving blank will default to always true. CouchDB document fields can be accessed using doc.key.subkey. Regular expressions can be tested using pattern.test(value) e.g. /^[0-9]+$/.test(doc.fields.last_menstrual_period). In our example above, we’re making sure the form has an LMP date.no
validationsA set of validations to perform on incoming reports. More information about validation rules can be found here.no
validations.join_responsesA boolean specifying whether validation messages should be combined into one message.no
validations.list[]An array of validation rules a report should pass to be considered valid.no
validations.list[].propertyReport field for which this validation rule will be applied.no
validations.list[].ruleValidation condition to be applied to the property field. More information about rules can be found here.no
validations.list[].translation_keyTranslation key for the message reply to be sent if a report fails this rule.no
messagesAn array of automated responses to incoming reports.no
messages[].translation_keyTranslation key for the message text associated with this event.no
messages[].event_typeAn event that will trigger sending of this message. Typical values are: report_accepted when the report has been successfully validated and registration_not_found when the shortcode (patient ID or place ID) supplied in the report doesn’t match any shortcode issued by Medic.no
messages[].recipientWho the message should be sent to. Use reporting_unit for the sender of the report, clinic for clinic contact, and parent for the parent contact. See SMS Recipientsno

Code sample

This sample shows how a schedule would be triggered by a pregnancy report if the last_menstrual_period value is set.

"registrations": [
    "form": "pregnancy",
    "events": [
        "name": "on_create",
        "trigger": "assign_schedule",
        "params": "ANC Visit Reminders",
        "bool_expr": "doc.fields.last_menstrual_period"
    "validations": {},
    "messages": []

CHT Applications > Concepts > Workflows

Building connections between people, actions, and data systems

CHT Applications > Reference > app_settings.json : Sms Recipient Resolution

Settings: The primary location of settings for CHT applications

Last modified 24.11.2021: Fix a typo in registrations (8802ced1)