Skip to content

Instantly share code, notes, and snippets.

@samuelmale
Created August 7, 2025 13:38
Show Gist options
  • Save samuelmale/8645cafd0e6732aadde274b7b8d92731 to your computer and use it in GitHub Desktop.
Save samuelmale/8645cafd0e6732aadde274b7b8d92731 to your computer and use it in GitHub Desktop.
package org.openmrs.module.drools.patientflags;
//generated from Decision Table
import org.openmrs.Patient;
import org.openmrs.module.drools.patientflags.FlaggedPatient;
import org.openmrs.module.drools.calculation.Operator;
import static org.openmrs.module.drools.utils.DroolsDateUtils.daysAgo;
global org.openmrs.module.drools.calculation.DroolsCalculationService calculationService;
global String SYSTOLIC_UUID;
global java.util.List flaggedPatients;
no-loop true
agenda-group "sepsis"
// rule values at A13, header at A8
rule "Sepsis Warning 1"
/* All 3 Symptoms */
salience 65535
when
$patient: Patient(age > 18, calculationService.checkObs($patient, "CIEL:5088", Operator.GTE, daysAgo(1)).matches(Operator.GT, 38) || calculationService.checkObs($patient, "CIEL:5088", Operator.GTE, daysAgo(1)).matches(Operator.LT, 36), calculationService.checkObs($patient, "CIEL:5087", Operator.GTE, daysAgo(1)).matches(Operator.GT, 90), calculationService.checkObs($patient, "CIEL:5242", Operator.GTE, daysAgo(1)).matches(Operator.GT, 20))
not FlaggedPatient(patientId == $patient.getId())
then
insert(new FlaggedPatient($patient.getId(), "Sepsis Warning"));
end
// rule values at A14, header at A8
rule "Sepsis Warning 2"
/* Temperature & Pulse */
salience 65534
when
$patient: Patient(age > 18, calculationService.checkObs($patient, "CIEL:5088", Operator.GTE, daysAgo(1)).matches(Operator.GT, 38) || calculationService.checkObs($patient, "CIEL:5088", Operator.GTE, daysAgo(1)).matches(Operator.LT, 36), calculationService.checkObs($patient, "CIEL:5087", Operator.GTE, daysAgo(1)).matches(Operator.GT, 90))
not FlaggedPatient(patientId == $patient.getId())
then
insert(new FlaggedPatient($patient.getId(), "Sepsis Warning"));
end
// rule values at A15, header at A8
rule "Sepsis Warning 3"
/* Temperature & Respiratory Rate */
salience 65533
when
$patient: Patient(age > 18, calculationService.checkObs($patient, "CIEL:5088", Operator.GTE, daysAgo(1)).matches(Operator.GT, 38) || calculationService.checkObs($patient, "CIEL:5088", Operator.GTE, daysAgo(1)).matches(Operator.LT, 36), calculationService.checkObs($patient, "CIEL:5242", Operator.GTE, daysAgo(1)).matches(Operator.GT, 20))
not FlaggedPatient(patientId == $patient.getId())
then
insert(new FlaggedPatient($patient.getId(), "Sepsis Warning"));
end
// rule values at A16, header at A8
rule "Sepsis Warning 4"
/* Pulse & Respiratory Rate */
salience 65532
when
$patient: Patient(age > 18, calculationService.checkObs($patient, "CIEL:5087", Operator.GTE, daysAgo(1)).matches(Operator.GT, 90), calculationService.checkObs($patient, "CIEL:5242", Operator.GTE, daysAgo(1)).matches(Operator.GT, 20))
not FlaggedPatient(patientId == $patient.getId())
then
insert(new FlaggedPatient($patient.getId(), "Sepsis Warning"));
end
// rule values at A17, header at A8
rule "Sepsis Severe"
/* Sepsis Warning & Systolic Pressure */
salience 65531
when
$patient: Patient(age > 18, calculationService.checkObs($patient, "CIEL:5085", Operator.GTE, daysAgo(1)).matches(Operator.LT, 90))
$flag: FlaggedPatient(patientId == $patient.getId(), message == "Sepsis Warning")
then
modify($flag){ setMessage("Severe Sepsis") }
end
// rule values at A18, header at A8
rule "Export Flag"
salience 65530
when
$flag: FlaggedPatient()
then
flaggedPatients.add($flag);
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment