Table of Contents
...
Facilities | ||||||
---|---|---|---|---|---|---|
FacilityId | OrganizationId | Name | Timezone | NFCEnabled | NFCSelfModificationEnabled | BarCodeEnabled |
ACME-PH | ACME | Pearl Harbor | US/Hawaii | true | false | false |
...
SurveyTemplates | |
---|---|
SurveyId | Name |
1 | New Line Report |
2 | Line Maintenance |
3 | Infection Report |
4 | Breast Milk Report |
5 | Patient Demographics |
6 | Patient Discharge |
7 | Patient Open Lines |
8 | Form Open Lines |
9 | Admission Questions |
10 | Patient Final Discharge |
11 | AUDIT |
12 | MDQ |
7. Organization's Alerts
7.1 SurveyAgent
Remember that Alerts are generated by the SurveyAgent. For this scenario we are going to have 2 rules generating alerts: 'New Patient Admission" and "Milk Importance Not Discussed".
For this scenario, we are going to place both rules in a single .drl file. The name of the file will be ACME-alerts.drl
Code Block | ||||
---|---|---|---|---|
| ||||
package org.socraticgrid.survey.agent;
import org.drools.mas.body.content.*;
import org.drools.mas.action.message.*;
import org.drools.mas.action.message.types.*;
import org.drools.mas.action.message.invokers.*;
import org.socraticgrid.survey.agent.api.model.SurveySubmissionFact;
import org.socraticgrid.survey.agent.api.model.SurveySubmissionAnswerFact;
import org.socraticgrid.survey.agent.api.model.PreValidationResult;
import org.socraticgrid.survey.agent.log.RulesLoggerHelper;
import org.socraticgrid.surveys.model.*;
import org.socraticgrid.surveys.service.SurveyService;
import org.socraticgrid.alertmanager.service.AlertService;
import org.slf4j.Logger;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.Date;
import org.drools.mas.action.helpers.*;
/* Global Services */
global SurveyService surveyService;
global AlertService alertService;
global Logger logger;
rule "New Patient Admission"
when
//There is a Submission of a #5 Survey
//And there alert was not previously sent.
$s: SurveySubmissionFact(
surveyId == 5,
$chartId: q["q008"],
alertService.parameterizedAlertExists($s.getPatientId(), "New Patient Admission") == false
)
then
RulesLoggerHelper.debug(logger, drools, "New Admission detected: {}", $s);
templateVariables.put("common_patient_chartId", $chartId);
insert( new ResolvableActionAgentNotificationCandidateFact(
drools.getRule().getName(), //sourceRule
"ADMISSION", //sourceProgram
(SurveySubmissionFact)$s, //sourceFact
$s.getPatientId(), //sourcePatient
"HIGH", //priority
"ACME-NewAdmission", //template
"10s", //timeout
templateVariables //template variables
));
end
rule "Milk Importance Not Discussed"
when
//There is a Submission of a #4 Survey
$s: SurveySubmissionFact(
surveyId == 4,
q["q007"] == "No"
)
then
RulesLoggerHelper.debug(logger, drools, "Milk Importance Not Discussed: {}", $s);
insert( new ResolvableActionAgentNotificationCandidateFact(
drools.getRule().getName(), //sourceRule
"NCCC", //sourceProgram
(SurveySubmissionFact)$s, //sourceFact
$s.getPatientId(), //sourcePatient
"HIGH", //priority
"ACME-NotDiscussed", //template
"10s", //timeout
null //template variables
));
end
|