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'] } },
      [],
    ],
  },
});
  • logic is JSON Logic. It answers notify entries, each naming channels and 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.value and patient.id.
  • event is one of alert.triggered, alert.empty, alert.note, alert.inactive, alert.refired, alert.resolved and alert.acknowledged.
  • Channels are push and email. Roles are practitioner, caregiver, relatedPerson and sharedWith. Any other label is refused with UNKNOWN_NOTIFY_LABELS, and a rule that cannot run on every event is refused with INVALID_NOTIFICATIONS; both are validation errors.
  • retrieve reads the rule, and notifications is null when the project has none. remove deletes 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.
  • event is alert.triggered when omitted. Pass alert to set the sample alert's code, reason, message or value.
  • Pass notifications to try a rule before you save it. Nothing is sent.
  • The calls go to v1/omnichannel-alerts/rules and v1/omnichannel-alerts/preview.

See also

Last updated on

On this page