NCD Technical Overview

Module Dependency

This Module depends on Messaging module and MRN Generator module.
NCD Module uses Siddhi-CEP, a Complex Event Processing Engine(CEP), as its back-end for efficient and effective processing of Critics.

Adding Critics

Notification Critics are aggregation of Notification Conditions and Notification messages.

When Critics are added to the system; Critics and their associated Conditions, Messages and Contact Numbers get stored in the OpenMRS database, under ncd_notifier_critic, ncd_notifier_condition, ncd_notifier_message and ncd_notifier_contacts tables.

Processing Critics

A Complex Event Processing Engine (CEP) is used as the back-end for critic processing. CEP is an upside-down database where there will be stored Queries on which the data flows through. These Queries fire notifications when they encounter matching Event patterns.

In-order to process Critics using CEP, the Encounters are converted in to Event tuples and the Notification Conditions are converted in to CEP Queries.

Here two types of CEP queries are used

  1. Filtering Queries
    This will filter the Events (Encounters) according to the defined conditions.
  2. Sequence Queries
    This will monitor whether all the necessary states are achieved for the critic to be satisfied.

Notification Critics processing have two scenarios.

  1. Immediately; when the Encounters are entered
    NCD uses Aspect Oriented programming to capture newly entered Encounters, and since CEP is always waiting for Events, the newly captured Encounters are converted into several CEP Event tuples and send for processing in Siddhi-CEP.
  2. Using Scheduled Task when the Messaging Condition gets satisfied
    NCD uses OpenMRS Scheduler Task to periodically check whether the Critics are satisfied in one hour intervals. Here all Encounters will be converted to appropriate Events and sent for processing against the queries defined in the CEP.

For each Encounter NCD creates two types of Events, One is PatientEvent which is used to check whether the patient has satisfied the given conditions using Filter Query, and other are some ConceptEvents, which are created from the Encounter Obs, to check whether the Concepts related to the Critic have got satisfied using Filter Queries.

When a PatientEvent satisfies the given condition CEP will create a new Event called AcceptedPatientEvent and send that to the Sequence Query, similarly when a ConceptEvent gets satisfied an appropriate AcceptedConceptEvent will be created and sent to the Sequence Query. Then when the appropriate AcceptedPatientEvent and the AcceptedConceptEvents have occurred the Sequence Query will create an AcceptedCriticEvent. The AcceptedCriticEvent will then be used to send Critic Notifications.

Sending Notifications

When an AcceptedCriticEvent has occurred, all the Messages related to that Critic which needs to be notified are loaded. Then the patients email addresses and/or sms numbers (MessagingAddress) are retrieved and if needed new MessagingAddress are created from the given contact details. Finally using regular expression manipulations the message templates are customized to actual messages and send via email or sms using the MessagingService API of the OpenMRS Messaging Module

Known Issues

  1. Only 10 conditions can be added to the critic at the same time. If more than 10 conditions needed the critic needs to be saved and reopened.
  2. Schedule Tasks needs to run on One hour intervals. This is because the smallest unit in the Messaging Conditions is Hours.