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.
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.
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
Notification Critics processing have two scenarios.
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.
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