Namespaces
ovok.omnichannelAlerts
Read, set and preview the rule that decides who hears of each Signals alert event, and over which channel.
- Stable unknown
- Release candidate not available
- Development not available
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.omnichannelAlerts reads, sets and previews that rule. It is for project admins, and it needs the OMNICHANNEL_ALERTS_ENABLED setting on.
Turn it on
await ovok.projects.settings.update('OMNICHANNEL_ALERTS_ENABLED', true);Set the rule
await ovok.omnichannelAlerts.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. Any other label is refused withUNKNOWN_NOTIFY_LABELS, and a rule that cannot run on every event is refused withINVALID_NOTIFICATIONS; both are validation errors. retrievereads the rule, andnotificationsis null when the project has none.removedeletes it, so nobody is told of a new alert event.
Preview who it reaches
const { notify } = await ovok.omnichannelAlerts.preview({
patientId,
event: 'alert.refired',
});
for (const entry of notify) {
console.log(entry.channels, entry.recipients.map((person) => person.display));
}- Each entry lists the people its roles resolve to for that patient, and whether each has an email address on file.
eventisalert.triggeredwhen omitted. Passalertto set the sample alert'scode,reason,messageorvalue.- Pass
notificationsto try a rule before you save it. Nothing is sent. - The calls go to
v1/omnichannel-alerts/rulesandv1/omnichannel-alerts/preview.
See also
- omnichannelAlerts API reference: every method and type.
- ovok.push to register devices and set up the push provider.
- ovok.projects for project settings.
- Errors and retries
Last updated on