Namespaces
Omni-channel alerts
Learn how to read, set and preview the rule that decides who hears of each Signals alert event.
- Stable unknown
- Release candidate not available
- Development since 0.2.0-dev.33+c6e0f70
Ovok keeps the project's omni-channel alerts rule and runs it on each alert event Signals sends. The rule names who to tell and over which channel, and Ovok tells them by push and email. ovok.omnichannel_alerts reads, sets and previews that rule. It is for project admins, and it needs the OMNICHANNEL_ALERTS_ENABLED setting on.
Set the rule
ovok.projects.settings.update("OMNICHANNEL_ALERTS_ENABLED", True)
ovok.omnichannel_alerts.rules.update({
"logic": {
"if": [
{"==": [{"var": "event"}, "alert.triggered"]},
{"notify": {"channels": ["push", "email"], "to": ["practitioner", "caregiver"]}},
{"==": [{"var": "event"}, "alert.refired"]},
{"notify": {"channels": ["push", "email"], "to": ["relatedPerson", "sharedWith"]}},
[],
]
}
})logicis JSON Logic. It answersnotifyentries, each namingchannelsand the roles to tell (to), or an empty list to tell nobody.- The logic can read
event,alert.id,alert.code,alert.reason,alert.message,alert.valueandpatient.id. eventis one ofalert.triggered,alert.empty,alert.note,alert.inactive,alert.refired,alert.resolvedandalert.acknowledged.- Channels are
pushandemail. Roles arepractitioner,caregiver,relatedPersonandsharedWith. An unknown label (UNKNOWN_NOTIFY_LABELS) or a rule that cannot run on every event (INVALID_NOTIFICATIONS) raisesOvokValidationError. retrievereads the rule undernotifications, None when the project has none.removedeletes it.
Preview who it reaches
preview = ovok.omnichannel_alerts.preview({"patientId": patient_id, "event": "alert.refired"})
for entry in preview["notify"]:
print(entry["channels"], [person["display"] for person in entry["recipients"]])- Each entry lists the people its roles resolve to for that patient, and whether each has an email address on file.
eventisalert.triggeredwhen omitted. Addalertto set the sample alert'scode,reason,messageorvalue, andnotificationsto try a rule before you save it. Nothing is sent.
See also
Last updated on