From f67323ac7e3b8a7d617834f2bd237912ce413827 Mon Sep 17 00:00:00 2001 From: gabu90 Date: Thu, 26 Sep 2024 10:09:56 +0300 Subject: [PATCH 1/8] WIP of Survailance --- .../EligibleForIDSRFlagsCalculation.java | 12 +- ...igibleForIDSRSymptomsFlagsCalculation.java | 914 ++++++++++++++++++ .../KenyaemrCoreRestController.java | 3 +- 3 files changed, 922 insertions(+), 7 deletions(-) create mode 100644 api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/surveillance/EligibleForIDSRSymptomsFlagsCalculation.java diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/surveillance/EligibleForIDSRFlagsCalculation.java b/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/surveillance/EligibleForIDSRFlagsCalculation.java index 25ee1d4a4..c18a90969 100644 --- a/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/surveillance/EligibleForIDSRFlagsCalculation.java +++ b/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/surveillance/EligibleForIDSRFlagsCalculation.java @@ -42,7 +42,7 @@ * SARI * * @should calculate admitted */ -public class EligibleForIDSRFlagsCalculation extends AbstractPatientCalculation implements PatientFlagCalculation { +public class EligibleForIDSRFlagsCalculation extends AbstractPatientCalculation { protected static final Log log = LogFactory.getLog(EligibleForIDSRFlagsCalculation.class); List idsrMessage = new ArrayList(); @@ -750,9 +750,9 @@ public CalculationResultMap evaluate(Collection cohort, Map= 38.0 same day + * @should calculate duration < 10 days + *

+ * SARI + * * @should calculate admitted + */ +public class EligibleForIDSRSymptomsFlagsCalculation extends AbstractPatientCalculation implements PatientFlagCalculation { + protected static final Log log = LogFactory.getLog(EligibleForIDSRSymptomsFlagsCalculation.class); + + List idsrMessage = new ArrayList(); + String idsrMessageString = ""; + + public static final EncounterType triageEncType = MetadataUtils.existing(EncounterType.class, CommonMetadata._EncounterType.TRIAGE); + public static final Form triageScreeningForm = MetadataUtils.existing(Form.class, CommonMetadata._Form.TRIAGE); + public static final EncounterType consultationEncType = MetadataUtils.existing(EncounterType.class, CommonMetadata._EncounterType.CONSULTATION); + public static final Form clinicalEncounterForm = MetadataUtils.existing(Form.class, CommonMetadata._Form.CLINICAL_ENCOUNTER); + public static final EncounterType greenCardEncType = MetadataUtils.existing(EncounterType.class, HivMetadata._EncounterType.HIV_CONSULTATION); + public static final Form greenCardForm = MetadataUtils.existing(Form.class, HivMetadata._Form.HIV_GREEN_CARD); + + String SCREENING_QUESTION = "5219AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + + String FEVER = "140238AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + String COUGH_PRESENCE = "143264AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + String DURATION = "159368AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + + String TEMPERATURE = "5088AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + String PATIENT_OUTCOME = "160433AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + String INPATIENT_ADMISSION = "1654AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + //Chikungunya + String JOINT_PAIN = "116558AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + //Cholera + String VOMITING = "122983AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + //String WATERY_DIARRHEA = "161887AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + //Dysentry + String BLOOD_IN_STOOL = "117671AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + String DIARRHEA = "142412AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + //Viral Haemorrhagic Fever + String BLEEDING_TENDENCIES = "162628AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + //MALARIA + //String HEADACHE = "139084AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + String CHILLS = "871AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + //Measles +// String RASH = "512AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + String CORYZA = "106AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + String CONJUCTIVITIS = "127777AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + //Rift Valley Fever + //String JAUNDICE = "136443AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + String DIZZINESS = "141830AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + String MALAISE = "135367AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + String SCREENING_QUESTION_EXAMINATION = "162737AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + String TYPE_OF_SERVICE_PROVIDED = "168146"; + //Polio + String LIMBS_WEAKNESS = "157498AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + String ONSET_QUESTION = "d7a3441d-6aeb-49be-b7d6-b2a3bb39e78d"; + String SUDDEN_ONSET = "162707AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + //Acute Jaundice Syndrome + String JAUNDICE = "136443AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + //Acute Febrile Rash Infection + String RASH = "512AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + + //Neurological Syndrome + String REFUSAL_TO_FEED = "6017AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + String CONVULSIONS = "113054AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + + //Acute Watery Diarrhoeal Disease + String NUMBER_OF_MOTIONS = "164456AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + String WATERY_DIARRHEA = "161887AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + + //// + String HEADACHE = "139084AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + String LYMPHADENOPATHY = "135488AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + String MYALGIA = "121AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + String BACKPAIN = "148035AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + + //NECK STIFFNESS + String NECK_STIFFNESS = "112721AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + /** + * Evaluates the calculation + */ + + @Override + public CalculationResultMap evaluate(Collection cohort, Map parameterValues, PatientCalculationContext context) { + + Set alive = Filters.alive(cohort, context); + PatientService patientService = Context.getPatientService(); + CalculationResultMap ret = new CalculationResultMap(); + + for (Integer ptId : alive) { + boolean eligible = false; + List activeVisits = Context.getVisitService().getActiveVisitsByPatient(patientService.getPatient(ptId)); + if (!activeVisits.isEmpty()) { + Date currentDate = new Date(); + Double tempValue = 0.0; + Double duration = 0.0; + Double motions = 0.0; + Date dateCreated = null; + String onsetStatus = null; + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + String todayDate = dateFormat.format(currentDate); + Patient patient = patientService.getPatient(ptId); + + Encounter lastTriageEncounter = EmrUtils.lastEncounter(patient, triageEncType, triageScreeningForm); + Encounter lastHivFollowUpEncounter = EmrUtils.lastEncounter(patient, greenCardEncType, greenCardForm); //last greencard followup form + Encounter lastClinicalEncounter = EmrUtils.lastEncounter(patient, consultationEncType, clinicalEncounterForm); //last clinical encounter form + + ConceptService cs = Context.getConceptService(); + Concept screeningQuestion = cs.getConceptByUuid(SCREENING_QUESTION); + Concept screeningQuestionExam = cs.getConceptByUuid(SCREENING_QUESTION_EXAMINATION); + Concept typeOfServiceProvided = cs.getConceptByUuid(TYPE_OF_SERVICE_PROVIDED); + + Concept measureFeverResult = cs.getConceptByUuid(FEVER); + Concept coughPresenceResult = cs.getConceptByUuid(COUGH_PRESENCE); + Concept adminQuestion = cs.getConceptByUuid(PATIENT_OUTCOME); + Concept admissionAnswer = cs.getConceptByUuid(INPATIENT_ADMISSION); + Concept jointPainResult = cs.getConceptByUuid(JOINT_PAIN); + Concept vomitingResult = cs.getConceptByUuid(VOMITING); + Concept wateryDiarrheaResult = cs.getConceptByUuid(WATERY_DIARRHEA); + Concept bloodyStoolResult = cs.getConceptByUuid(BLOOD_IN_STOOL); + Concept diarrheaResult = cs.getConceptByUuid(DIARRHEA); + Concept bleedingResult = cs.getConceptByUuid(BLEEDING_TENDENCIES); + Concept headacheResult = cs.getConceptByUuid(HEADACHE); + Concept chillsResult = cs.getConceptByUuid(CHILLS); + Concept rashResult = cs.getConceptByUuid(RASH); + Concept coryzaResult = cs.getConceptByUuid(CORYZA); + Concept conjunctivitisResult = cs.getConceptByUuid(CONJUCTIVITIS); + Concept jaundiceResult = cs.getConceptByUuid(JAUNDICE); + Concept dizzinessResult = cs.getConceptByUuid(DIZZINESS); + Concept malaiseResult = cs.getConceptByUuid(MALAISE); + Concept limbsWeaknessResult = cs.getConceptByUuid(LIMBS_WEAKNESS); + Concept meningitisResult = cs.getConceptByUuid(SUDDEN_ONSET); + Concept acuteFebrileRashInfectionResult = cs.getConceptByUuid(RASH); + Concept refusalToFeedResult = cs.getConceptByUuid(REFUSAL_TO_FEED); + Concept convulsionsResult = cs.getConceptByUuid(CONVULSIONS); + Concept lymphadenopathyResult = cs.getConceptByUuid(LYMPHADENOPATHY); + Concept myalgiaResult = cs.getConceptByUuid(MYALGIA); + Concept backpainResult = cs.getConceptByUuid(BACKPAIN); + Concept neckStiffnessResult = cs.getConceptByUuid(NECK_STIFFNESS); + //Conditions + String ili = "ILI"; + String sari = "SARI"; + String haemorrhagic_fever = "Acute Haemorrhagic Fever"; + String poliomyelitis = "Acute Flaccid Paralysis"; + // up to here + String jaundice = "Acute Jaundice"; + String meningitis = "Acute Meningitis and Encephalitis"; + String acute_febrile_rash_infection = "Acute Febrile Rash Infection"; + String acute_watery_diarrhoeal = "Acute Watery Diarrhoeal"; + String neurological_syndrome = "Neurological Syndrome"; + String acute_febrile_illness = "Acute Febrile Illness"; + String mpox = "Mpox"; + //Temperature + CalculationResultMap tempMap = Calculations.lastObs(cs.getConceptByUuid(TEMPERATURE), cohort, context); + //Fever + boolean triageEncounterHasFever = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, measureFeverResult) : false; + boolean hivFollowupEncounterHasFever = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, measureFeverResult) : false; + boolean clinicalEncounterHasFever = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, measureFeverResult) : false; + //Cough + boolean triageEncounterHasCough = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, coughPresenceResult) : false; + boolean hivFollowupEncounterHasCough = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, coughPresenceResult) : false; + boolean clinicalEncounterHasCough = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, coughPresenceResult) : false; + //Joint Pains + boolean triageEncounterHasJointPain = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, jointPainResult) : false; + boolean hivFollowupEncounterHasJointPain = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, jointPainResult) : false; + boolean clinicalEncounterHasJointPain = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, jointPainResult) : false; + // Vomiting + boolean triageEncounterHasVomit = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, vomitingResult) : false; + boolean hivFollowupEncounterHasVomit = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, vomitingResult) : false; + boolean clinicalEncounterHasVomit = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, vomitingResult) : false; + //Watery diarrhea + boolean triageEncounterHasWateryDiarrhea = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, wateryDiarrheaResult) : false; + boolean hivFollowupEncounterHasWateryDiarrhea = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, wateryDiarrheaResult) : false; + boolean clinicalEncounterHasWateryDiarrhea = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, wateryDiarrheaResult) : false; + //Diarrhea + boolean triageEncounterHasDiarrhea = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, diarrheaResult) : false; + boolean hivFollowupEncounterHasDiarrhea = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, diarrheaResult) : false; + boolean clinicalEncounterHasDiarrhea = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, diarrheaResult) : false; + + //neckStiffnessResult + boolean triageEncounterHasNeckStiffness = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, neckStiffnessResult) : false; + boolean hivFollowupEncounterHasNeckStiffness = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, neckStiffnessResult) : false; + boolean clinicalEncounterHasNeckStiffness = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, neckStiffnessResult) : false; + + //Blood in stool + boolean triageEncounterHasBloodyStool = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, bloodyStoolResult) : false; + boolean hivFollowupEncounterHasBloodyStool = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, bloodyStoolResult) : false; + boolean clinicalEncounterHasBloodyStool = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, bloodyStoolResult) : false; + //Bleeding tendencies + boolean triageEncounterHasBleeding = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, bleedingResult) : false; + boolean hivFollowupEncounterHasBleeding = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, bleedingResult) : false; + boolean clinicalEncounterHasBleeding = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, bleedingResult) : false; + //Headache + boolean triageEncounterHasHeadache = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, headacheResult) : false; + boolean hivFollowupEncounterHasHeadache = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, headacheResult) : false; + boolean clinicalEncounterHasHeadache = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, headacheResult) : false; + //Chills + boolean triageEncounterHasChills= lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, chillsResult) : false; + boolean hivFollowupEncounterHasChills = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, chillsResult) : false; + boolean clinicalEncounterHasChills = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, chillsResult) : false; + //Rash + boolean triageEncounterHasRash = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, rashResult) : false; + boolean hivFollowupEncounterHasRash = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, rashResult) : false; + boolean clinicalEncounterHasRash = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, rashResult) : false; + + //Acute Febrile Rash Infection + boolean triageEncounterHasAcuteRashInfection = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, acuteFebrileRashInfectionResult) : false; + boolean hivFollowupEncounterHasAcuteRashInfection = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, acuteFebrileRashInfectionResult) : false; + boolean clinicalEncounterHasAcuteRashInfection = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, acuteFebrileRashInfectionResult) : false; + + //Refusal to feed + boolean triageEncounterHasRefusalToFeed = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, refusalToFeedResult) : false; + boolean hivFollowupEncounterHasRefusalToFeed = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, refusalToFeedResult) : false; + boolean clinicalEncounterHasRefusalToFeed = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, refusalToFeedResult) : false; + + //Convulsions + boolean triageEncounterHasConvulsions = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, convulsionsResult) : false; + boolean hivFollowupEncounterHasConvulsions = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, convulsionsResult) : false; + boolean clinicalEncounterHasConvulsions = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, convulsionsResult) : false; + + //Coryza + boolean triageEncounterHasCoryza = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, coryzaResult) : false; + boolean hivFollowupEncounterHasCoryza = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, coryzaResult) : false; + boolean clinicalEncounterHasCoryza = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, coryzaResult) : false; + //Conjunctivitis + boolean triageEncounterHasConjunctivitis = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, conjunctivitisResult) : false; + boolean hivFollowupEncounterHasConjunctivitis = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, conjunctivitisResult) : false; + boolean clinicalEncounterHasConjunctivitis = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, conjunctivitisResult) : false; + //Jaundice + boolean triageEncounterHasJaundice = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestionExam, jaundiceResult) : false; + boolean hivFollowupEncounterHasJaundice = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestionExam, jaundiceResult) : false; + boolean clinicalEncounterHasJaundice = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestionExam, jaundiceResult) : false; + //Dizziness + boolean triageEncounterHasDizziness = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, dizzinessResult) : false; + boolean hivFollowupEncounterHasDizziness = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, dizzinessResult) : false; + boolean clinicalEncounterHasDizziness = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, dizzinessResult) : false; + //Malaise + boolean triageEncounterHasMalaise = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, malaiseResult) : false; + boolean hivFollowupEncounterHasMalaise = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, malaiseResult) : false; + boolean clinicalEncounterHasMalaise = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, malaiseResult) : false; + //Weakness of limbs + boolean triageEncounterHasWeakLimbs = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, limbsWeaknessResult) : false; + boolean hivFollowupEncounterHasWeakLimbs = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, limbsWeaknessResult) : false; + boolean clinicalEncounterHasWeakLimbs = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, limbsWeaknessResult) : false; + + //Acute Meningitis and Encephalitis Syndrome +// boolean triageEncounterHasMeningitis = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, meningitisResult) : false; +// boolean hivFollowupEncounterHasMeningitis = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, meningitisResult) : false; +// boolean clinicalEncounterHasMeningitis = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, meningitisResult) : false; + + //Sudden Onset + boolean triageEncounterHasSuddenOnset = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, meningitisResult) : false; + boolean hivFollowupEncounterHasSuddenOnset = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, meningitisResult) : false; + boolean clinicalEncounterHasSuddenOnset = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, meningitisResult) : false; + + //lymphadenopathy + boolean triageEncounterHasLymphadenopathy = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, lymphadenopathyResult) : false; + boolean hivFollowupEncounterHasLymphadenopathy = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, lymphadenopathyResult) : false; + boolean clinicalEncounterHasLymphadenopathy = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, lymphadenopathyResult) : false; + //myalgia + boolean triageEncounterHasMyalgia = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, myalgiaResult) : false; + boolean hivFollowupEncounterHasMyalgia = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, myalgiaResult) : false; + boolean clinicalEncounterHasMyalgia = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, myalgiaResult) : false; + //backpain + boolean triageEncounterHasBackpain = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, backpainResult) : false; + boolean hivFollowupEncounterHasBackpain = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, backpainResult) : false; + boolean clinicalEncounterHasBackpain = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, backpainResult) : false; + + //Check admission status : Found in clinical encounter and type of visit + boolean patientAdmissionStatus = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, adminQuestion, admissionAnswer) : false; + //Visit type is inpatient + Visit currentVisit = activeVisits.get(0); + Obs lastTempObs = EmrCalculationUtils.obsResultForPatient(tempMap, ptId); + if (lastTempObs != null) { + tempValue = lastTempObs.getValueNumeric(); + } + //Triage + if (lastTriageEncounter != null) { + //1. SARI and ILI + if (triageEncounterHasFever && triageEncounterHasCough) { + for (Obs obs : lastTriageEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(DURATION)) { + duration = obs.getValueNumeric(); + } + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if ((duration > 0.0 && duration < 10) && tempValue != null && tempValue >= 38.0) { + if (createdDate.equals(todayDate)) { + if (!patientAdmissionStatus && !currentVisit.getVisitType().getUuid().equals("a73e2ac6-263b-47fc-99fc-e0f2c09fc914")) { + eligible = true; + idsrMessage.add(ili); + break; + } else { + eligible = true; + idsrMessage.add(sari); + break; + } + } + } + } + } + } + //2. Viral Haemorrhagic fever + if (triageEncounterHasFever && triageEncounterHasBleeding) { + for (Obs obs : lastTriageEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(DURATION)) { + duration = obs.getValueNumeric(); + } + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if(duration > 0.0 && duration < 14) { + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(haemorrhagic_fever); + break; + } + } + } + } + } + //3.Poliomyelitis + if (triageEncounterHasWeakLimbs) { + if (patient.getAge() < 15) { + for (Obs obs : lastTriageEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(ONSET_QUESTION)) { + onsetStatus = obs.getValueCoded().getUuid(); + } + if (dateCreated != null && onsetStatus != null) { + String createdDate = dateFormat.format(dateCreated); + if (createdDate.equals(todayDate) && onsetStatus.equals(SUDDEN_ONSET)) { + eligible = true; + idsrMessage.add(poliomyelitis); + break; + } + } + } + } + + } + //4. Acute Meningitis and Encephalitis Syndrome + if (triageEncounterHasNeckStiffness) { + for (Obs obs : lastTriageEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(ONSET_QUESTION)) { + onsetStatus = obs.getValueCoded().getUuid(); + } + if (dateCreated != null && onsetStatus != null) { + String createdDate = dateFormat.format(dateCreated); + if (createdDate.equals(todayDate) && onsetStatus.equals(SUDDEN_ONSET)) { + eligible = true; + idsrMessage.add(meningitis); + break; + } + } + } + } + + + //5. Acute Febrile Rash Infection + if (triageEncounterHasFever && triageEncounterHasAcuteRashInfection) { + for (Obs obs : lastTriageEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(DURATION)) { + duration = obs.getValueNumeric(); + } + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if ((duration > 0.0 && duration < 14)) { + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(acute_febrile_rash_infection); + break; + } + } + } + } + } + //6. Neurological Syndrome + if (triageEncounterHasRefusalToFeed && triageEncounterHasConvulsions) { + if (patient.getAge() > 2) { + for (Obs obs : lastTriageEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(DURATION)) { + duration = obs.getValueNumeric(); + } + if ((duration > 2 && duration < 28)) { + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(neurological_syndrome); + break; + } + } + } + } + } + } + //7. Acute Febrile Illness + if (triageEncounterHasFever) { + for (Obs obs : lastTriageEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(DURATION)) { + duration = obs.getValueNumeric(); + } + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if ((duration > 0.0 && duration < 14) && tempValue != null && tempValue >= 38.0) { + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(acute_febrile_illness); + break; + } + } + } + } + } + //8. Acute Watery Diarrhoeal Disease + if (triageEncounterHasWateryDiarrhea) { + for (Obs obs : lastTriageEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(NUMBER_OF_MOTIONS)) { + motions = obs.getValueNumeric(); + } + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if ((motions < 3)) { + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(acute_watery_diarrhoeal); + break; + } + } + } + } + } + //9. Jaundice + if (triageEncounterHasJaundice) { + for (Obs obs : lastHivFollowUpEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(jaundice); + break; + } + } + } + } + //10. Monkeypox + if (triageEncounterHasRash && triageEncounterHasFever) { + if (triageEncounterHasHeadache || triageEncounterHasLymphadenopathy || triageEncounterHasMyalgia || triageEncounterHasBackpain) { + for (Obs obs : lastHivFollowUpEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if (tempValue != null && tempValue >= 38.5) { + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(mpox); + break; + } + } + } + } + } + } + } + //Hiv followup encounter + if (lastHivFollowUpEncounter != null) { + //1. SARI and ILI + if (hivFollowupEncounterHasFever && hivFollowupEncounterHasCough) { + for (Obs obs : lastHivFollowUpEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(DURATION)) { + duration = obs.getValueNumeric(); + } + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if ((duration > 0.0 && duration < 10) && tempValue != null && tempValue >= 38.0) { + if (createdDate.equals(todayDate)) { + if (!patientAdmissionStatus && !currentVisit.getVisitType().getUuid().equals("a73e2ac6-263b-47fc-99fc-e0f2c09fc914")) { + eligible = true; + idsrMessage.add(ili); + break; + } else { + eligible = true; + idsrMessage.add(sari); + break; + } + } + } + } + } + } + //2. Acute Haemorrhagic fever + if (hivFollowupEncounterHasFever && hivFollowupEncounterHasBleeding) { + for (Obs obs : lastHivFollowUpEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(DURATION)) { + duration = obs.getValueNumeric(); + } + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if(duration > 0.0 && duration < 14) { + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(haemorrhagic_fever); + break; + } + } + } + } + } + //3.Poliomyelitis + if (hivFollowupEncounterHasWeakLimbs) { + if (patient.getAge() < 15) { + for (Obs obs : lastHivFollowUpEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(ONSET_QUESTION)) { + onsetStatus = obs.getValueCoded().getUuid(); + } + if (dateCreated != null && onsetStatus != null) { + String createdDate = dateFormat.format(dateCreated); + if (createdDate.equals(todayDate) && onsetStatus.equals(SUDDEN_ONSET)) { + eligible = true; + idsrMessage.add(poliomyelitis); + break; + } + } + } + + } + } + // 4. Jaundice + if (hivFollowupEncounterHasJaundice) { + for (Obs obs : lastHivFollowUpEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(jaundice); + break; + } + } + } + } + //5. Acute Menigitis and Encephalitis Syndrome + if (hivFollowupEncounterHasNeckStiffness) { + for (Obs obs : lastHivFollowUpEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(ONSET_QUESTION)) { + onsetStatus = obs.getValueCoded().getUuid(); + } + if (dateCreated != null && onsetStatus != null) { + String createdDate = dateFormat.format(dateCreated); + if (createdDate.equals(todayDate) && onsetStatus.equals(SUDDEN_ONSET)) { + eligible = true; + idsrMessage.add(meningitis); + break; + } + } + } + } + + //5. Acute Febrile Rash Infection + if (hivFollowupEncounterHasFever && hivFollowupEncounterHasAcuteRashInfection) { + for (Obs obs : lastHivFollowUpEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(DURATION)) { + duration = obs.getValueNumeric(); + } + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if ((duration > 0.0 && duration < 14)) { + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(acute_febrile_rash_infection); + break; + } + } + } + } + } + //6. Neurological Syndrome + if (hivFollowupEncounterHasRefusalToFeed && hivFollowupEncounterHasConvulsions) { + if (patient.getAge() > 2) { + for (Obs obs : lastHivFollowUpEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(DURATION)) { + duration = obs.getValueNumeric(); + } + if ((duration > 2 && duration < 28)) { + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(neurological_syndrome); + break; + } + } + } + } + } + } + //7. Acute Febrile Illness + if (hivFollowupEncounterHasFever) { + for (Obs obs : lastHivFollowUpEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(DURATION)) { + duration = obs.getValueNumeric(); + } + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if ((duration > 0.0 && duration < 14) && tempValue != null && tempValue >= 38.0) { + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(acute_febrile_illness); + break; + } + } + } + } + } + //8. Acute Watery Diarrhoeal Disease + if (hivFollowupEncounterHasWateryDiarrhea) { + for (Obs obs : lastHivFollowUpEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(NUMBER_OF_MOTIONS)) { + motions = obs.getValueNumeric(); + } + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if ((motions < 3)) { + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(acute_watery_diarrhoeal); + break; + } + } + } + } + } + //9. Mpox + if (hivFollowupEncounterHasRash && hivFollowupEncounterHasFever) { + if (hivFollowupEncounterHasHeadache || hivFollowupEncounterHasLymphadenopathy || hivFollowupEncounterHasMyalgia || hivFollowupEncounterHasBackpain) { + for (Obs obs : lastHivFollowUpEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if (tempValue != null && tempValue >= 38.5) { + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(mpox); + break; + } + } + } + } + } + } + } + //Clinical Encounter + if (lastClinicalEncounter != null) { + //1. SARI and ILI + if (clinicalEncounterHasFever && clinicalEncounterHasCough) { + for (Obs obs : lastClinicalEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(DURATION)) { + duration = obs.getValueNumeric(); + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if ((duration > 0.0 && duration < 10) && tempValue != null && tempValue >= 38.0) { + if (createdDate.equals(todayDate)) { + if (!patientAdmissionStatus && !currentVisit.getVisitType().getUuid().equals("a73e2ac6-263b-47fc-99fc-e0f2c09fc914")) { + eligible = true; + idsrMessage.add(ili); + break; + } else { + eligible = true; + idsrMessage.add(sari); + break; + } + } + } + } + } + } + } + //2. Acute Haemorrhagic fever + if (clinicalEncounterHasFever && clinicalEncounterHasBleeding) { + for (Obs obs : lastClinicalEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(DURATION)) { + duration = obs.getValueNumeric(); + } + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if(duration > 0.0 && duration < 14) { + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(haemorrhagic_fever); + break; + } + } + } + } + + } + //3.Poliomyelitis + if (clinicalEncounterHasWeakLimbs) { + if (patient.getAge() < 15) { + for (Obs obs : lastClinicalEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(ONSET_QUESTION)) { + onsetStatus = obs.getValueCoded().getUuid(); + } + if (dateCreated != null && onsetStatus != null) { + String createdDate = dateFormat.format(dateCreated); + if (createdDate.equals(todayDate) && onsetStatus.equals(SUDDEN_ONSET)) { + eligible = true; + idsrMessage.add(poliomyelitis); + break; + } + } + } + } + } + //4. Jaundice + if (clinicalEncounterHasJaundice) { + for (Obs obs : lastClinicalEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(jaundice); + break; + } + } + } + } + //5. Acute Meningitis and Encephalitis Syndrome + if (clinicalEncounterHasNeckStiffness) { + for (Obs obs : lastClinicalEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(ONSET_QUESTION)) { + onsetStatus = obs.getValueCoded().getUuid(); + } + if (dateCreated != null && onsetStatus != null) { + String createdDate = dateFormat.format(dateCreated); + if (createdDate.equals(todayDate) && onsetStatus.equals(SUDDEN_ONSET)) { + eligible = true; + idsrMessage.add(meningitis); + break; + } + } + } + } + //6. Acute Febrile Rash Infection + if (clinicalEncounterHasFever && clinicalEncounterHasAcuteRashInfection) { + for (Obs obs : lastClinicalEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(DURATION)) { + duration = obs.getValueNumeric(); + } + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if ((duration > 0.0 && duration < 14)) { + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(acute_febrile_rash_infection); + break; + } + } + } + } + } + //7. Neurological Syndrome + if (clinicalEncounterHasRefusalToFeed && clinicalEncounterHasConvulsions) { + if (patient.getAge() > 2) { + for (Obs obs : lastClinicalEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(DURATION)) { + duration = obs.getValueNumeric(); + } + if ((duration > 2 && duration < 28)) { + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(neurological_syndrome); + break; + } + } + } + } + } + } + //8. Acute Febrile Illness + if (clinicalEncounterHasFever) { + for (Obs obs : lastClinicalEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(DURATION)) { + duration = obs.getValueNumeric(); + } + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if ((duration > 0.0 && duration < 14) && tempValue != null && tempValue >= 38.0) { + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(acute_febrile_illness); + break; + } + } + } + } + } + //9. Acute Watery Diarrhoeal Disease + if (clinicalEncounterHasWateryDiarrhea) { + for (Obs obs : lastClinicalEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(NUMBER_OF_MOTIONS)) { + motions = obs.getValueNumeric(); + } + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if ((motions < 3)) { + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(acute_watery_diarrhoeal); + break; + } + } + } + } + } + //10. Mpox + if (clinicalEncounterHasRash && clinicalEncounterHasFever) { + if (clinicalEncounterHasHeadache || clinicalEncounterHasLymphadenopathy || clinicalEncounterHasMyalgia || clinicalEncounterHasBackpain) { + for (Obs obs : lastClinicalEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if (tempValue != null && tempValue >= 38.5) { + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(mpox); + break; + } + } + } + } + } + } + + } + } + if (idsrMessage.size() > 0) { + idsrMessageString = StringUtils.join(idsrMessage, ","); + + } + ret.put(ptId, new BooleanResult(eligible, this)); + } + return ret; + } + + @Override + public String getFlagMessage() { + return "Suspected "+ idsrMessageString; + + } +} diff --git a/omod/src/main/java/org/openmrs/module/kenyaemr/web/controller/KenyaemrCoreRestController.java b/omod/src/main/java/org/openmrs/module/kenyaemr/web/controller/KenyaemrCoreRestController.java index d293c3cb9..988abdec2 100644 --- a/omod/src/main/java/org/openmrs/module/kenyaemr/web/controller/KenyaemrCoreRestController.java +++ b/omod/src/main/java/org/openmrs/module/kenyaemr/web/controller/KenyaemrCoreRestController.java @@ -305,7 +305,8 @@ public Object getAllPatientFlags(HttpServletRequest request, @RequestParam("pati CacheManager cacheManager = Context.getRegisteredComponent("apiCacheManager", CacheManager.class); Cache patientFlagCache = cacheManager.getCache("patientFlagCache"); List patientFlagsToRefreshOnEveryRequest = Arrays.asList( - "EligibleForIDSRFlagsCalculation" + // "EligibleForIDSRFlagsCalculation" + "EligibleForIDSRSymptomsFlagsCalculation" ); calculationManager.refresh(); From 434ea2b218ab88a01077e504caccc92bac56f604 Mon Sep 17 00:00:00 2001 From: gabu90 Date: Mon, 30 Sep 2024 07:28:59 +0300 Subject: [PATCH 2/8] Disease surveilance flagging response. --- ...igibleForIDSRSymptomsFlagsCalculation.java | 39 +++++++++++++------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/surveillance/EligibleForIDSRSymptomsFlagsCalculation.java b/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/surveillance/EligibleForIDSRSymptomsFlagsCalculation.java index 8a05915dc..c51184b0e 100644 --- a/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/surveillance/EligibleForIDSRSymptomsFlagsCalculation.java +++ b/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/surveillance/EligibleForIDSRSymptomsFlagsCalculation.java @@ -461,13 +461,18 @@ public CalculationResultMap evaluate(Collection cohort, Map 0.0 && duration < 14)) { + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(acute_watery_diarrhoeal); + break; + } } } } @@ -670,13 +675,18 @@ public CalculationResultMap evaluate(Collection cohort, Map 0.0 && duration < 14)) { + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(acute_watery_diarrhoeal); + break; + } } } } @@ -864,13 +874,18 @@ public CalculationResultMap evaluate(Collection cohort, Map 0.0 && duration < 14)) { + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(acute_watery_diarrhoeal); + break; + } } } } From 0a811d30653ed925d05b0a0a38134e866344090b Mon Sep 17 00:00:00 2001 From: gabu90 Date: Mon, 7 Oct 2024 15:34:13 +0300 Subject: [PATCH 3/8] Add global property to disable DMI flags --- ...igibleForIDSRSymptomsFlagsCalculation.java | 801 +++++++++--------- omod/src/main/resources/config.xml | 8 +- 2 files changed, 406 insertions(+), 403 deletions(-) diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/surveillance/EligibleForIDSRSymptomsFlagsCalculation.java b/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/surveillance/EligibleForIDSRSymptomsFlagsCalculation.java index c51184b0e..e9d67bd38 100644 --- a/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/surveillance/EligibleForIDSRSymptomsFlagsCalculation.java +++ b/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/surveillance/EligibleForIDSRSymptomsFlagsCalculation.java @@ -15,6 +15,7 @@ import org.joda.time.DateTime; import org.joda.time.Days; import org.openmrs.*; +import org.openmrs.api.AdministrationService; import org.openmrs.api.ConceptService; import org.openmrs.api.PatientService; import org.openmrs.api.context.Context; @@ -47,7 +48,8 @@ public class EligibleForIDSRSymptomsFlagsCalculation extends AbstractPatientCalc List idsrMessage = new ArrayList(); String idsrMessageString = ""; - + private AdministrationService administrationService = Context.getAdministrationService(); + final String isDmi = (administrationService.getGlobalProperty("kenyaemr.isDmi")); public static final EncounterType triageEncType = MetadataUtils.existing(EncounterType.class, CommonMetadata._EncounterType.TRIAGE); public static final Form triageScreeningForm = MetadataUtils.existing(Form.class, CommonMetadata._Form.TRIAGE); public static final EncounterType consultationEncType = MetadataUtils.existing(EncounterType.class, CommonMetadata._EncounterType.CONSULTATION); @@ -231,7 +233,7 @@ public CalculationResultMap evaluate(Collection cohort, Map cohort, Map 0.0 && duration < 10) && tempValue != null && tempValue >= 38.0) { + if (createdDate.equals(todayDate)) { + if (!patientAdmissionStatus && !currentVisit.getVisitType().getUuid().equals("a73e2ac6-263b-47fc-99fc-e0f2c09fc914")) { + eligible = true; + idsrMessage.add(ili); + break; + } else { + eligible = true; + idsrMessage.add(sari); + break; + } + } + } + } } - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if ((duration > 0.0 && duration < 10) && tempValue != null && tempValue >= 38.0) { - if (createdDate.equals(todayDate)) { - if (!patientAdmissionStatus && !currentVisit.getVisitType().getUuid().equals("a73e2ac6-263b-47fc-99fc-e0f2c09fc914")) { - eligible = true; - idsrMessage.add(ili); - break; - } else { + } + //2. Viral Haemorrhagic fever + if (triageEncounterHasFever && triageEncounterHasBleeding) { + for (Obs obs : lastTriageEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(DURATION)) { + duration = obs.getValueNumeric(); + } + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if (duration > 0.0 && duration < 14) { + if (createdDate.equals(todayDate)) { eligible = true; - idsrMessage.add(sari); + idsrMessage.add(haemorrhagic_fever); break; } } } } } - } - //2. Viral Haemorrhagic fever - if (triageEncounterHasFever && triageEncounterHasBleeding) { - for (Obs obs : lastTriageEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(DURATION)) { - duration = obs.getValueNumeric(); - } - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if(duration > 0.0 && duration < 14) { - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(haemorrhagic_fever); - break; + //3.Poliomyelitis + if (triageEncounterHasWeakLimbs) { + if (patient.getAge() < 15) { + for (Obs obs : lastTriageEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(ONSET_QUESTION)) { + onsetStatus = obs.getValueCoded().getUuid(); + } + if (dateCreated != null && onsetStatus != null) { + String createdDate = dateFormat.format(dateCreated); + if (createdDate.equals(todayDate) && onsetStatus.equals(SUDDEN_ONSET)) { + eligible = true; + idsrMessage.add(poliomyelitis); + break; + } } } } + } - } - //3.Poliomyelitis - if (triageEncounterHasWeakLimbs) { - if (patient.getAge() < 15) { + //4. Acute Meningitis and Encephalitis Syndrome + if (triageEncounterHasNeckStiffness) { for (Obs obs : lastTriageEncounter.getObs()) { dateCreated = obs.getDateCreated(); if (obs.getConcept().getUuid().equals(ONSET_QUESTION)) { @@ -368,198 +390,207 @@ public CalculationResultMap evaluate(Collection cohort, Map 0.0 && duration < 14)) { + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(acute_febrile_rash_infection); + break; + } } } } - } - - - //5. Acute Febrile Rash Infection - if (triageEncounterHasFever && triageEncounterHasAcuteRashInfection) { - for (Obs obs : lastTriageEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(DURATION)) { - duration = obs.getValueNumeric(); - } - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if ((duration > 0.0 && duration < 14)) { - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(acute_febrile_rash_infection); - break; + } + //6. Neurological Syndrome + if (triageEncounterHasRefusalToFeed && triageEncounterHasConvulsions) { + DateTime birthDate = new DateTime(patient.getBirthdate()); + int ageInDays = Days.daysBetween(birthDate, new DateTime()).getDays(); + if (ageInDays >= 2 && ageInDays <= 28) { + for (Obs obs : lastTriageEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(neurological_syndrome); + break; + } } } } } - } - //6. Neurological Syndrome - if (triageEncounterHasRefusalToFeed && triageEncounterHasConvulsions) { - if (patient.getAge() > 2) { + //7. Acute Febrile Illness + if (triageEncounterHasFever) { for (Obs obs : lastTriageEncounter.getObs()) { dateCreated = obs.getDateCreated(); if (obs.getConcept().getUuid().equals(DURATION)) { duration = obs.getValueNumeric(); } - if ((duration > 2 && duration < 28)) { if (dateCreated != null) { String createdDate = dateFormat.format(dateCreated); - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(neurological_syndrome); - break; + if ((duration > 0.0 && duration < 14) && tempValue != null && tempValue >= 38.0) { + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(acute_febrile_illness); + break; + } } } - } } } - } - //7. Acute Febrile Illness - if (triageEncounterHasFever) { - for (Obs obs : lastTriageEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(DURATION)) { - duration = obs.getValueNumeric(); + //8. Acute Watery Diarrhoeal Disease + if (triageEncounterHasWateryDiarrhea) { + for (Obs obs : lastTriageEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(NUMBER_OF_MOTIONS)) { + motions = obs.getValueNumeric(); + } + if (obs.getConcept().getUuid().equals(DURATION)) { + duration = obs.getValueNumeric(); + } + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if ((motions < 3)) { + if ((duration > 0.0 && duration < 14)) { + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(acute_watery_diarrhoeal); + break; + } + } + } + } } - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if ((duration > 0.0 && duration < 14) && tempValue != null && tempValue >= 38.0) { + } + //9. Jaundice + if (triageEncounterHasJaundice) { + for (Obs obs : lastHivFollowUpEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); if (createdDate.equals(todayDate)) { eligible = true; - idsrMessage.add(acute_febrile_illness); + idsrMessage.add(jaundice); break; } } } } - } - //8. Acute Watery Diarrhoeal Disease - if (triageEncounterHasWateryDiarrhea) { - for (Obs obs : lastTriageEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(NUMBER_OF_MOTIONS)) { - motions = obs.getValueNumeric(); - } - if (obs.getConcept().getUuid().equals(DURATION)) { - duration = obs.getValueNumeric(); - } - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if ((motions < 3)) { - if ((duration > 0.0 && duration < 14)) { - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(acute_watery_diarrhoeal); - break; + //10. Monkeypox + if (triageEncounterHasRash && triageEncounterHasFever) { + if (triageEncounterHasHeadache || triageEncounterHasLymphadenopathy || triageEncounterHasMyalgia || triageEncounterHasBackpain) { + for (Obs obs : lastHivFollowUpEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if (tempValue != null && tempValue >= 38.5) { + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(mpox); + break; + } } } } } } } - //9. Jaundice - if (triageEncounterHasJaundice) { - for (Obs obs : lastHivFollowUpEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(jaundice); - break; + //Hiv followup encounter + if (lastHivFollowUpEncounter != null) { + //1. SARI and ILI + if (hivFollowupEncounterHasFever && hivFollowupEncounterHasCough) { + for (Obs obs : lastHivFollowUpEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(DURATION)) { + duration = obs.getValueNumeric(); + } + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if ((duration > 0.0 && duration < 10) && tempValue != null && tempValue >= 38.0) { + if (createdDate.equals(todayDate)) { + if (!patientAdmissionStatus && !currentVisit.getVisitType().getUuid().equals("a73e2ac6-263b-47fc-99fc-e0f2c09fc914")) { + eligible = true; + idsrMessage.add(ili); + break; + } else { + eligible = true; + idsrMessage.add(sari); + break; + } + } + } } } } - } - //10. Monkeypox - if (triageEncounterHasRash && triageEncounterHasFever) { - if (triageEncounterHasHeadache || triageEncounterHasLymphadenopathy || triageEncounterHasMyalgia || triageEncounterHasBackpain) { + //2. Acute Haemorrhagic fever + if (hivFollowupEncounterHasFever && hivFollowupEncounterHasBleeding) { for (Obs obs : lastHivFollowUpEncounter.getObs()) { dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(DURATION)) { + duration = obs.getValueNumeric(); + } if (dateCreated != null) { String createdDate = dateFormat.format(dateCreated); - if (tempValue != null && tempValue >= 38.5) { - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(mpox); - break; - } + if (duration > 0.0 && duration < 14) { + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(haemorrhagic_fever); + break; + } } } } } - } - } - //Hiv followup encounter - if (lastHivFollowUpEncounter != null) { - //1. SARI and ILI - if (hivFollowupEncounterHasFever && hivFollowupEncounterHasCough) { - for (Obs obs : lastHivFollowUpEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(DURATION)) { - duration = obs.getValueNumeric(); - } - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if ((duration > 0.0 && duration < 10) && tempValue != null && tempValue >= 38.0) { - if (createdDate.equals(todayDate)) { - if (!patientAdmissionStatus && !currentVisit.getVisitType().getUuid().equals("a73e2ac6-263b-47fc-99fc-e0f2c09fc914")) { - eligible = true; - idsrMessage.add(ili); - break; - } else { + //3.Poliomyelitis + if (hivFollowupEncounterHasWeakLimbs) { + if (patient.getAge() < 15) { + for (Obs obs : lastHivFollowUpEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(ONSET_QUESTION)) { + onsetStatus = obs.getValueCoded().getUuid(); + } + if (dateCreated != null && onsetStatus != null) { + String createdDate = dateFormat.format(dateCreated); + if (createdDate.equals(todayDate) && onsetStatus.equals(SUDDEN_ONSET)) { eligible = true; - idsrMessage.add(sari); + idsrMessage.add(poliomyelitis); break; } } } + } } - } - //2. Acute Haemorrhagic fever - if (hivFollowupEncounterHasFever && hivFollowupEncounterHasBleeding) { - for (Obs obs : lastHivFollowUpEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(DURATION)) { - duration = obs.getValueNumeric(); - } - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if(duration > 0.0 && duration < 14) { + // 4. Jaundice + if (hivFollowupEncounterHasJaundice) { + for (Obs obs : lastHivFollowUpEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); if (createdDate.equals(todayDate)) { eligible = true; - idsrMessage.add(haemorrhagic_fever); + idsrMessage.add(jaundice); break; } } } } - } - //3.Poliomyelitis - if (hivFollowupEncounterHasWeakLimbs) { - if (patient.getAge() < 15) { + //5. Acute Menigitis and Encephalitis Syndrome + if (hivFollowupEncounterHasNeckStiffness) { for (Obs obs : lastHivFollowUpEncounter.getObs()) { dateCreated = obs.getDateCreated(); if (obs.getConcept().getUuid().equals(ONSET_QUESTION)) { @@ -569,167 +600,103 @@ public CalculationResultMap evaluate(Collection cohort, Map 0.0 && duration < 14)) { - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(acute_febrile_rash_infection); + idsrMessage.add(meningitis); break; } } } } - } - //6. Neurological Syndrome - if (hivFollowupEncounterHasRefusalToFeed && hivFollowupEncounterHasConvulsions) { - if (patient.getAge() > 2) { + //6. Acute Febrile Rash Infection + if (hivFollowupEncounterHasFever && hivFollowupEncounterHasAcuteRashInfection) { for (Obs obs : lastHivFollowUpEncounter.getObs()) { dateCreated = obs.getDateCreated(); if (obs.getConcept().getUuid().equals(DURATION)) { duration = obs.getValueNumeric(); } - if ((duration > 2 && duration < 28)) { if (dateCreated != null) { String createdDate = dateFormat.format(dateCreated); - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(neurological_syndrome); - break; - } - } - } - } - } - } - //7. Acute Febrile Illness - if (hivFollowupEncounterHasFever) { - for (Obs obs : lastHivFollowUpEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(DURATION)) { - duration = obs.getValueNumeric(); - } - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if ((duration > 0.0 && duration < 14) && tempValue != null && tempValue >= 38.0) { - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(acute_febrile_illness); - break; + if ((duration > 0.0 && duration < 14)) { + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(acute_febrile_rash_infection); + break; + } } } } } - } - //8. Acute Watery Diarrhoeal Disease - if (hivFollowupEncounterHasWateryDiarrhea) { - for (Obs obs : lastHivFollowUpEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(NUMBER_OF_MOTIONS)) { - motions = obs.getValueNumeric(); - } - if (obs.getConcept().getUuid().equals(DURATION)) { - duration = obs.getValueNumeric(); - } - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if ((motions < 3)) { - if ((duration > 0.0 && duration < 14)) { + //7. Neurological Syndrome + if (hivFollowupEncounterHasRefusalToFeed && hivFollowupEncounterHasConvulsions) { + DateTime birthDate = new DateTime(patient.getBirthdate()); + int ageInDays = Days.daysBetween(birthDate, new DateTime()).getDays(); + if (ageInDays >= 2 && ageInDays <= 28) { + for (Obs obs : lastTriageEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); if (createdDate.equals(todayDate)) { eligible = true; - idsrMessage.add(acute_watery_diarrhoeal); + idsrMessage.add(neurological_syndrome); break; } } } } } - } - //9. Mpox - if (hivFollowupEncounterHasRash && hivFollowupEncounterHasFever) { - if (hivFollowupEncounterHasHeadache || hivFollowupEncounterHasLymphadenopathy || hivFollowupEncounterHasMyalgia || hivFollowupEncounterHasBackpain) { + //8. Acute Febrile Illness + if (hivFollowupEncounterHasFever) { for (Obs obs : lastHivFollowUpEncounter.getObs()) { dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(DURATION)) { + duration = obs.getValueNumeric(); + } if (dateCreated != null) { String createdDate = dateFormat.format(dateCreated); - if (tempValue != null && tempValue >= 38.5) { + if ((duration > 0.0 && duration < 14) && tempValue != null && tempValue >= 38.0) { if (createdDate.equals(todayDate)) { eligible = true; - idsrMessage.add(mpox); + idsrMessage.add(acute_febrile_illness); break; } } } } } - } - } - //Clinical Encounter - if (lastClinicalEncounter != null) { - //1. SARI and ILI - if (clinicalEncounterHasFever && clinicalEncounterHasCough) { - for (Obs obs : lastClinicalEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(DURATION)) { - duration = obs.getValueNumeric(); + //9. Acute Watery Diarrhoeal Disease + if (hivFollowupEncounterHasWateryDiarrhea) { + for (Obs obs : lastHivFollowUpEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(NUMBER_OF_MOTIONS)) { + motions = obs.getValueNumeric(); + } + if (obs.getConcept().getUuid().equals(DURATION)) { + duration = obs.getValueNumeric(); + } if (dateCreated != null) { String createdDate = dateFormat.format(dateCreated); - if ((duration > 0.0 && duration < 10) && tempValue != null && tempValue >= 38.0) { - if (createdDate.equals(todayDate)) { - if (!patientAdmissionStatus && !currentVisit.getVisitType().getUuid().equals("a73e2ac6-263b-47fc-99fc-e0f2c09fc914")) { + if ((motions < 3)) { + if ((duration > 0.0 && duration < 14)) { + if (createdDate.equals(todayDate)) { eligible = true; - idsrMessage.add(ili); + idsrMessage.add(acute_watery_diarrhoeal); break; - } else { + } + } + } + } + } + } + //10. Mpox + if (hivFollowupEncounterHasRash && hivFollowupEncounterHasFever) { + if (hivFollowupEncounterHasHeadache || hivFollowupEncounterHasLymphadenopathy || hivFollowupEncounterHasMyalgia || hivFollowupEncounterHasBackpain) { + for (Obs obs : lastHivFollowUpEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if (tempValue != null && tempValue >= 38.5) { + if (createdDate.equals(todayDate)) { eligible = true; - idsrMessage.add(sari); + idsrMessage.add(mpox); break; } } @@ -738,180 +705,207 @@ public CalculationResultMap evaluate(Collection cohort, Map 0.0 && duration < 14) { - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(haemorrhagic_fever); - break; + //Clinical Encounter + if (lastClinicalEncounter != null) { + //1. SARI and ILI + if (clinicalEncounterHasFever && clinicalEncounterHasCough) { + for (Obs obs : lastClinicalEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(DURATION)) { + duration = obs.getValueNumeric(); + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if ((duration > 0.0 && duration < 10) && tempValue != null && tempValue >= 38.0) { + if (createdDate.equals(todayDate)) { + if (!patientAdmissionStatus && !currentVisit.getVisitType().getUuid().equals("a73e2ac6-263b-47fc-99fc-e0f2c09fc914")) { + eligible = true; + idsrMessage.add(ili); + break; + } else { + eligible = true; + idsrMessage.add(sari); + break; + } + } + } } } } } - - } - //3.Poliomyelitis - if (clinicalEncounterHasWeakLimbs) { - if (patient.getAge() < 15) { + //2. Acute Haemorrhagic fever + if (clinicalEncounterHasFever && clinicalEncounterHasBleeding) { for (Obs obs : lastClinicalEncounter.getObs()) { dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(ONSET_QUESTION)) { - onsetStatus = obs.getValueCoded().getUuid(); + if (obs.getConcept().getUuid().equals(DURATION)) { + duration = obs.getValueNumeric(); } - if (dateCreated != null && onsetStatus != null) { + if (dateCreated != null) { String createdDate = dateFormat.format(dateCreated); - if (createdDate.equals(todayDate) && onsetStatus.equals(SUDDEN_ONSET)) { - eligible = true; - idsrMessage.add(poliomyelitis); - break; + if (duration > 0.0 && duration < 14) { + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(haemorrhagic_fever); + break; + } } } } + } - } - //4. Jaundice - if (clinicalEncounterHasJaundice) { - for (Obs obs : lastClinicalEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(jaundice); - break; - } - } - } - } - //5. Acute Meningitis and Encephalitis Syndrome - if (clinicalEncounterHasNeckStiffness) { - for (Obs obs : lastClinicalEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(ONSET_QUESTION)) { - onsetStatus = obs.getValueCoded().getUuid(); - } - if (dateCreated != null && onsetStatus != null) { - String createdDate = dateFormat.format(dateCreated); - if (createdDate.equals(todayDate) && onsetStatus.equals(SUDDEN_ONSET)) { - eligible = true; - idsrMessage.add(meningitis); - break; + //3.Poliomyelitis + if (clinicalEncounterHasWeakLimbs) { + if (patient.getAge() < 15) { + for (Obs obs : lastClinicalEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(ONSET_QUESTION)) { + onsetStatus = obs.getValueCoded().getUuid(); + } + if (dateCreated != null && onsetStatus != null) { + String createdDate = dateFormat.format(dateCreated); + if (createdDate.equals(todayDate) && onsetStatus.equals(SUDDEN_ONSET)) { + eligible = true; + idsrMessage.add(poliomyelitis); + break; + } + } } } } - } - //6. Acute Febrile Rash Infection - if (clinicalEncounterHasFever && clinicalEncounterHasAcuteRashInfection) { - for (Obs obs : lastClinicalEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(DURATION)) { - duration = obs.getValueNumeric(); - } - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if ((duration > 0.0 && duration < 14)) { + //4. Jaundice + if (clinicalEncounterHasJaundice) { + for (Obs obs : lastClinicalEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); if (createdDate.equals(todayDate)) { eligible = true; - idsrMessage.add(acute_febrile_rash_infection); + idsrMessage.add(jaundice); break; } } } } - } - //7. Neurological Syndrome - if (clinicalEncounterHasRefusalToFeed && clinicalEncounterHasConvulsions) { - if (patient.getAge() > 2) { + //5. Acute Meningitis and Encephalitis Syndrome + if (clinicalEncounterHasNeckStiffness) { for (Obs obs : lastClinicalEncounter.getObs()) { dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(DURATION)) { - duration = obs.getValueNumeric(); + if (obs.getConcept().getUuid().equals(ONSET_QUESTION)) { + onsetStatus = obs.getValueCoded().getUuid(); } - if ((duration > 2 && duration < 28)) { - if (dateCreated != null) { + if (dateCreated != null && onsetStatus != null) { String createdDate = dateFormat.format(dateCreated); - if (createdDate.equals(todayDate)) { + if (createdDate.equals(todayDate) && onsetStatus.equals(SUDDEN_ONSET)) { eligible = true; - idsrMessage.add(neurological_syndrome); + idsrMessage.add(meningitis); break; } } - } } } - } - //8. Acute Febrile Illness - if (clinicalEncounterHasFever) { - for (Obs obs : lastClinicalEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(DURATION)) { - duration = obs.getValueNumeric(); - } - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if ((duration > 0.0 && duration < 14) && tempValue != null && tempValue >= 38.0) { - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(acute_febrile_illness); - break; + //6. Acute Febrile Rash Infection + if (clinicalEncounterHasFever && clinicalEncounterHasAcuteRashInfection) { + for (Obs obs : lastClinicalEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(DURATION)) { + duration = obs.getValueNumeric(); + } + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if ((duration > 0.0 && duration < 14)) { + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(acute_febrile_rash_infection); + break; + } } } } } - } - //9. Acute Watery Diarrhoeal Disease - if (clinicalEncounterHasWateryDiarrhea) { - for (Obs obs : lastClinicalEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(NUMBER_OF_MOTIONS)) { - motions = obs.getValueNumeric(); - } - if (obs.getConcept().getUuid().equals(DURATION)) { - duration = obs.getValueNumeric(); - } - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if ((motions < 3)) { - if ((duration > 0.0 && duration < 14)) { + //7. Neurological Syndrome + if (clinicalEncounterHasRefusalToFeed && clinicalEncounterHasConvulsions) { + DateTime birthDate = new DateTime(patient.getBirthdate()); + int ageInDays = Days.daysBetween(birthDate, new DateTime()).getDays(); + if (ageInDays >= 2 && ageInDays <= 28) { + for (Obs obs : lastTriageEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); if (createdDate.equals(todayDate)) { eligible = true; - idsrMessage.add(acute_watery_diarrhoeal); + idsrMessage.add(neurological_syndrome); break; } } } } } - } - //10. Mpox - if (clinicalEncounterHasRash && clinicalEncounterHasFever) { - if (clinicalEncounterHasHeadache || clinicalEncounterHasLymphadenopathy || clinicalEncounterHasMyalgia || clinicalEncounterHasBackpain) { + //8. Acute Febrile Illness + if (clinicalEncounterHasFever) { for (Obs obs : lastClinicalEncounter.getObs()) { dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(DURATION)) { + duration = obs.getValueNumeric(); + } if (dateCreated != null) { String createdDate = dateFormat.format(dateCreated); - if (tempValue != null && tempValue >= 38.5) { + if ((duration > 0.0 && duration < 14) && tempValue != null && tempValue >= 38.0) { if (createdDate.equals(todayDate)) { eligible = true; - idsrMessage.add(mpox); + idsrMessage.add(acute_febrile_illness); break; } } } } } + //9. Acute Watery Diarrhoeal Disease + if (clinicalEncounterHasWateryDiarrhea) { + for (Obs obs : lastClinicalEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (obs.getConcept().getUuid().equals(NUMBER_OF_MOTIONS)) { + motions = obs.getValueNumeric(); + } + if (obs.getConcept().getUuid().equals(DURATION)) { + duration = obs.getValueNumeric(); + } + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if ((motions < 3)) { + if ((duration > 0.0 && duration < 14)) { + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(acute_watery_diarrhoeal); + break; + } + } + } + } + } + } + //10. Mpox + if (clinicalEncounterHasRash && clinicalEncounterHasFever) { + if (clinicalEncounterHasHeadache || clinicalEncounterHasLymphadenopathy || clinicalEncounterHasMyalgia || clinicalEncounterHasBackpain) { + for (Obs obs : lastClinicalEncounter.getObs()) { + dateCreated = obs.getDateCreated(); + if (dateCreated != null) { + String createdDate = dateFormat.format(dateCreated); + if (tempValue != null && tempValue >= 38.5) { + if (createdDate.equals(todayDate)) { + eligible = true; + idsrMessage.add(mpox); + break; + } + } + } + } + } + } + } - } + } + if (idsrMessage.size() > 0) { idsrMessageString = StringUtils.join(idsrMessage, ","); @@ -923,7 +917,10 @@ public CalculationResultMap evaluate(Collection cohort, Map - + + kenyaemr.isDmi + false + + Defines whether facility is DMI site or not + + kenyaemr.generateUPN false From 6c9f2bc87b9239227b7e08e236b7edf9442513aa Mon Sep 17 00:00:00 2001 From: gabu90 Date: Sat, 12 Oct 2024 09:38:25 +0300 Subject: [PATCH 4/8] Develop a case report for the flagged syndromes --- .../IDSRSuspectedCaseListReportBuilder.java | 451 +++++++++++++++++- .../dmi/FebrileIllnessCohortDefinition.java | 24 + .../dmi/FebrileRashCohortDefinition.java | 24 + .../dmi/JaundiceCohortDefinition.java | 24 + .../dmi/MeningitisCohortDefinition.java | 24 + .../definition/dmi/MpoxCohortDefinition.java | 24 + .../NeurologicalSyndromeCohortDefinition.java | 24 + .../dmi/WateryDiarrhoeaCohortDefinition.java | 24 + ...brileIllnessCohortDefinitionEvaluator.java | 77 +++ .../FebrileRashCohortDefinitionEvaluator.java | 80 ++++ .../JaundiceCohortDefinitionEvaluator.java | 77 +++ .../MeningitisCohortDefinitionEvaluator.java | 72 +++ .../dmi/MpoxCohortDefinitionEvaluator.java | 84 ++++ ...icalSyndromeCohortDefinitionEvaluator.java | 77 +++ ...eryDiarrhoeaCohortDefinitionEvaluator.java | 79 +++ .../evaluator/dmi/DiseaseDataEvaluator.java | 76 ++- .../library/dmi/IDSRCohortLibrary.java | 218 ++++++++- .../library/dmi/IDSRIndicatorLibrary.java | 53 +- .../resources/content/kenyaemr.common.xml | 3 +- .../webapp/resources/reports/dmi/idsr.xls | Bin 33280 -> 35840 bytes 20 files changed, 1496 insertions(+), 19 deletions(-) create mode 100644 api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/dmi/FebrileIllnessCohortDefinition.java create mode 100644 api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/dmi/FebrileRashCohortDefinition.java create mode 100644 api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/dmi/JaundiceCohortDefinition.java create mode 100644 api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/dmi/MeningitisCohortDefinition.java create mode 100644 api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/dmi/MpoxCohortDefinition.java create mode 100644 api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/dmi/NeurologicalSyndromeCohortDefinition.java create mode 100644 api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/dmi/WateryDiarrhoeaCohortDefinition.java create mode 100644 api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/dmi/FebrileIllnessCohortDefinitionEvaluator.java create mode 100644 api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/dmi/FebrileRashCohortDefinitionEvaluator.java create mode 100644 api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/dmi/JaundiceCohortDefinitionEvaluator.java create mode 100644 api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/dmi/MeningitisCohortDefinitionEvaluator.java create mode 100644 api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/dmi/MpoxCohortDefinitionEvaluator.java create mode 100644 api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/dmi/NeurologicalSyndromeCohortDefinitionEvaluator.java create mode 100644 api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/dmi/WateryDiarrhoeaCohortDefinitionEvaluator.java diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/builder/dmi/IDSRSuspectedCaseListReportBuilder.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/builder/dmi/IDSRSuspectedCaseListReportBuilder.java index d5bf957f6..dd49c855c 100644 --- a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/builder/dmi/IDSRSuspectedCaseListReportBuilder.java +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/builder/dmi/IDSRSuspectedCaseListReportBuilder.java @@ -82,7 +82,15 @@ protected List> buildDataSets(ReportDescriptor descrip ReportUtils.map(chikungunyaDataSetDefinitionColumns(), "startDate=${startDate},endDate=${endDate}"), ReportUtils.map(poliomyelitisDataSetDefinitionColumns(), "startDate=${startDate},endDate=${endDate}"), ReportUtils.map(viralHaemorrhagicFeverDataSetDefinitionColumns(), "startDate=${startDate},endDate=${endDate}"), - ReportUtils.map(measlesDataSetDefinitionColumns(), "startDate=${startDate},endDate=${endDate}")); + ReportUtils.map(measlesDataSetDefinitionColumns(), "startDate=${startDate},endDate=${endDate}"), + ReportUtils.map(mPoxDataSetDefinitionColumns(), "startDate=${startDate},endDate=${endDate}"), + ReportUtils.map(jaundiceDataSetDefinitionColumns(), "startDate=${startDate},endDate=${endDate}"), + ReportUtils.map(febrileIllnessDataSetDefinitionColumns(), "startDate=${startDate},endDate=${endDate}"), + ReportUtils.map(febrileRashDataSetDefinitionColumns(), "startDate=${startDate},endDate=${endDate}"), + ReportUtils.map(meningitisDataSetDefinitionColumns(), "startDate=${startDate},endDate=${endDate}"), + ReportUtils.map(neurologicalSyndromeDataSetDefinitionColumns(), "startDate=${startDate},endDate=${endDate}"), + ReportUtils.map(wateryDiarrhoeaDataSetDefinitionColumns(), "startDate=${startDate},endDate=${endDate}") + ); } protected DataSetDefinition caseIdentificationClassificationIndicators() { @@ -109,16 +117,39 @@ protected DataSetDefinition caseIdentificationClassificationIndicators() { cohortDsd.addColumn("Chikungunya", "", ReportUtils.map(idsrIndicatorLibrary.chikungunyaCases(), indParams), ""); cohortDsd.addColumn( - "Poliomyelitis", "", + "Acute Flaccid Paralysis", "", ReportUtils.map(idsrIndicatorLibrary.poliomyelitisCases(), indParams), ""); cohortDsd.addColumn( - "Viral Haemorrhagic Fever", + "Acute Haemorrhagic Fever", "", ReportUtils.map(idsrIndicatorLibrary.viralHaemorrhagicFeverCases(), indParams), ""); cohortDsd.addColumn( "Measles", "", ReportUtils.map(idsrIndicatorLibrary.measlesCases(), indParams), ""); + cohortDsd.addColumn( + "Monkey Pox", + "", ReportUtils.map(idsrIndicatorLibrary.monkeyPoxCases(), indParams), ""); + cohortDsd.addColumn( + "Acute Jaundice", + "", ReportUtils.map(idsrIndicatorLibrary.jaundiceCases(), indParams), ""); + cohortDsd.addColumn( + "Neurological Syndrome", + "", ReportUtils.map(idsrIndicatorLibrary.neurologicalSyndromeCases(), indParams), ""); + cohortDsd.addColumn( + "Acute Watery Diarrhoea", + "", ReportUtils.map(idsrIndicatorLibrary.acuteWateryDiarrhoeaCases(), indParams), ""); + cohortDsd.addColumn( + "Acute Febrile Rash Infections", + "", ReportUtils.map(idsrIndicatorLibrary.acuteFebrileRashCases(), indParams), ""); + cohortDsd.addColumn( + "Acute Febrile Illness", + "", ReportUtils.map(idsrIndicatorLibrary.acuteFebrileIllnessCases(), indParams), ""); + cohortDsd.addColumn( + "Acute Meningitis and Encephalitis", + "", ReportUtils.map(idsrIndicatorLibrary.acuteMeningitisCases(), indParams), ""); return cohortDsd; + + } protected DataSetDefinition idsrSuspectedCasesDataSetDefinitionColumns() { @@ -737,7 +768,7 @@ protected DataSetDefinition chikungunyaDataSetDefinitionColumns() { protected DataSetDefinition poliomyelitisDataSetDefinitionColumns() { PatientDataSetDefinition dsd = new PatientDataSetDefinition(); dsd.setName("poliomyelitis"); - dsd.setDescription("Poliomyelitis"); + dsd.setDescription("Acute Flaccid Paralysis"); dsd.addParameter(new Parameter("startDate", "Start Date", Date.class)); dsd.addParameter(new Parameter("endDate", "End Date", Date.class)); String paramMapping = "startDate=${startDate},endDate=${endDate}"; @@ -795,7 +826,7 @@ protected DataSetDefinition poliomyelitisDataSetDefinitionColumns() { protected DataSetDefinition viralHaemorrhagicFeverDataSetDefinitionColumns() { PatientDataSetDefinition dsd = new PatientDataSetDefinition(); dsd.setName("viralHaemorrhagicFever"); - dsd.setDescription("Viral Haemorrhagic Fever Information"); + dsd.setDescription("Acute Haemorrhagic Fever"); dsd.addParameter(new Parameter("startDate", "Start Date", Date.class)); dsd.addParameter(new Parameter("endDate", "End Date", Date.class)); String paramMapping = "startDate=${startDate},endDate=${endDate}"; @@ -907,4 +938,414 @@ protected DataSetDefinition measlesDataSetDefinitionColumns() { dsd.addRowFilter(cd, paramMapping); return dsd; } + + protected DataSetDefinition mPoxDataSetDefinitionColumns() { + PatientDataSetDefinition dsd = new PatientDataSetDefinition(); + dsd.setName("mPox"); + dsd.setDescription("Monkey Pox"); + dsd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + dsd.addParameter(new Parameter("endDate", "End Date", Date.class)); + String paramMapping = "startDate=${startDate},endDate=${endDate}"; + + PatientIdentifierType upn = MetadataUtils.existing(PatientIdentifierType.class, + HivMetadata._PatientIdentifierType.UNIQUE_PATIENT_NUMBER); + PatientIdentifierType nupi = MetadataUtils.existing(PatientIdentifierType.class, + CommonMetadata._PatientIdentifierType.NATIONAL_UNIQUE_PATIENT_IDENTIFIER); + DataConverter identifierFormatter = new ObjectFormatter("{identifier}"); + DataDefinition identifierDef = new ConvertedPatientDataDefinition("identifier", new PatientIdentifierDataDefinition( + upn.getName(), upn), identifierFormatter); + DataDefinition nupiDef = new ConvertedPatientDataDefinition("identifier", new PatientIdentifierDataDefinition( + nupi.getName(), nupi), identifierFormatter); + AgeAtReportingDataDefinition ageAtReportingDataDefinition = new AgeAtReportingDataDefinition(); + ageAtReportingDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + + ETLNextAppointmentDateDataDefinition lastAppointmentDateDataDefinition = new ETLNextAppointmentDateDataDefinition(); + lastAppointmentDateDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + lastAppointmentDateDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + VisitTypeWithComplaintsDataDefinition visitTypeDataDefinition = new VisitTypeWithComplaintsDataDefinition(); + visitTypeDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + visitTypeDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + + ComplaintAttendantProviderDataDefinition attendedByDataDefinition = new ComplaintAttendantProviderDataDefinition(); + attendedByDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + attendedByDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + + VisitDateWithComplaintsDataDefinition visitDateWithComplaintsDataDefinition = new VisitDateWithComplaintsDataDefinition(); + visitDateWithComplaintsDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + visitDateWithComplaintsDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + + DataConverter formatter = new ObjectFormatter("{familyName}, {givenName}"); + DataDefinition nameDef = new ConvertedPersonDataDefinition("name", + new PreferredNameDataDefinition(), formatter); + PersonAttributeType phoneNumber = MetadataUtils.existing(PersonAttributeType.class, + CommonMetadata._PersonAttributeType.TELEPHONE_CONTACT); + dsd.addColumn("id", new PersonIdDataDefinition(), ""); + dsd.addColumn("Name", nameDef, ""); + // dsd.addColumn("Hospital Unit", new MFLCodeDataDefinition(), ""); + dsd.addColumn("Visit Type", visitTypeDataDefinition, paramMapping); + dsd.addColumn("Sex", new GenderDataDefinition(), "", null); + dsd.addColumn("Age", ageAtReportingDataDefinition, "endDate=${endDate}"); + dsd.addColumn("Visit Date", visitDateWithComplaintsDataDefinition, paramMapping); + dsd.addColumn("Attended By", attendedByDataDefinition, paramMapping); + dsd.addColumn("Next Visit", lastAppointmentDateDataDefinition, paramMapping); + + MpoxCohortDefinition cd = new MpoxCohortDefinition(); + cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + cd.addParameter(new Parameter("endDate", "End Date", Date.class)); + + dsd.addRowFilter(cd, paramMapping); + return dsd; + } + + protected DataSetDefinition jaundiceDataSetDefinitionColumns() { + PatientDataSetDefinition dsd = new PatientDataSetDefinition(); + dsd.setName("jaundice"); + dsd.setDescription("Acute Jaundice"); + dsd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + dsd.addParameter(new Parameter("endDate", "End Date", Date.class)); + String paramMapping = "startDate=${startDate},endDate=${endDate}"; + + PatientIdentifierType upn = MetadataUtils.existing(PatientIdentifierType.class, + HivMetadata._PatientIdentifierType.UNIQUE_PATIENT_NUMBER); + PatientIdentifierType nupi = MetadataUtils.existing(PatientIdentifierType.class, + CommonMetadata._PatientIdentifierType.NATIONAL_UNIQUE_PATIENT_IDENTIFIER); + DataConverter identifierFormatter = new ObjectFormatter("{identifier}"); + DataDefinition identifierDef = new ConvertedPatientDataDefinition("identifier", new PatientIdentifierDataDefinition( + upn.getName(), upn), identifierFormatter); + DataDefinition nupiDef = new ConvertedPatientDataDefinition("identifier", new PatientIdentifierDataDefinition( + nupi.getName(), nupi), identifierFormatter); + AgeAtReportingDataDefinition ageAtReportingDataDefinition = new AgeAtReportingDataDefinition(); + ageAtReportingDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + + ETLNextAppointmentDateDataDefinition lastAppointmentDateDataDefinition = new ETLNextAppointmentDateDataDefinition(); + lastAppointmentDateDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + lastAppointmentDateDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + VisitTypeWithComplaintsDataDefinition visitTypeDataDefinition = new VisitTypeWithComplaintsDataDefinition(); + visitTypeDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + visitTypeDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + + ComplaintAttendantProviderDataDefinition attendedByDataDefinition = new ComplaintAttendantProviderDataDefinition(); + attendedByDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + attendedByDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + + VisitDateWithComplaintsDataDefinition visitDateWithComplaintsDataDefinition = new VisitDateWithComplaintsDataDefinition(); + visitDateWithComplaintsDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + visitDateWithComplaintsDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + + DataConverter formatter = new ObjectFormatter("{familyName}, {givenName}"); + DataDefinition nameDef = new ConvertedPersonDataDefinition("name", + new PreferredNameDataDefinition(), formatter); + PersonAttributeType phoneNumber = MetadataUtils.existing(PersonAttributeType.class, + CommonMetadata._PersonAttributeType.TELEPHONE_CONTACT); + dsd.addColumn("id", new PersonIdDataDefinition(), ""); + dsd.addColumn("Name", nameDef, ""); + // dsd.addColumn("Hospital Unit", new MFLCodeDataDefinition(), ""); + dsd.addColumn("Visit Type", visitTypeDataDefinition, paramMapping); + dsd.addColumn("Sex", new GenderDataDefinition(), "", null); + dsd.addColumn("Age", ageAtReportingDataDefinition, "endDate=${endDate}"); + dsd.addColumn("Visit Date", visitDateWithComplaintsDataDefinition, paramMapping); + dsd.addColumn("Attended By", attendedByDataDefinition, paramMapping); + dsd.addColumn("Next Visit", lastAppointmentDateDataDefinition, paramMapping); + + JaundiceCohortDefinition cd = new JaundiceCohortDefinition(); + cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + cd.addParameter(new Parameter("endDate", "End Date", Date.class)); + + dsd.addRowFilter(cd, paramMapping); + return dsd; + } + + protected DataSetDefinition febrileIllnessDataSetDefinitionColumns() { + PatientDataSetDefinition dsd = new PatientDataSetDefinition(); + dsd.setName("febrileIllness"); + dsd.setDescription("Acute Febrile Illness"); + dsd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + dsd.addParameter(new Parameter("endDate", "End Date", Date.class)); + String paramMapping = "startDate=${startDate},endDate=${endDate}"; + + PatientIdentifierType upn = MetadataUtils.existing(PatientIdentifierType.class, + HivMetadata._PatientIdentifierType.UNIQUE_PATIENT_NUMBER); + PatientIdentifierType nupi = MetadataUtils.existing(PatientIdentifierType.class, + CommonMetadata._PatientIdentifierType.NATIONAL_UNIQUE_PATIENT_IDENTIFIER); + DataConverter identifierFormatter = new ObjectFormatter("{identifier}"); + DataDefinition identifierDef = new ConvertedPatientDataDefinition("identifier", new PatientIdentifierDataDefinition( + upn.getName(), upn), identifierFormatter); + DataDefinition nupiDef = new ConvertedPatientDataDefinition("identifier", new PatientIdentifierDataDefinition( + nupi.getName(), nupi), identifierFormatter); + AgeAtReportingDataDefinition ageAtReportingDataDefinition = new AgeAtReportingDataDefinition(); + ageAtReportingDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + + ETLNextAppointmentDateDataDefinition lastAppointmentDateDataDefinition = new ETLNextAppointmentDateDataDefinition(); + lastAppointmentDateDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + lastAppointmentDateDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + VisitTypeWithComplaintsDataDefinition visitTypeDataDefinition = new VisitTypeWithComplaintsDataDefinition(); + visitTypeDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + visitTypeDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + + ComplaintAttendantProviderDataDefinition attendedByDataDefinition = new ComplaintAttendantProviderDataDefinition(); + attendedByDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + attendedByDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + + VisitDateWithComplaintsDataDefinition visitDateWithComplaintsDataDefinition = new VisitDateWithComplaintsDataDefinition(); + visitDateWithComplaintsDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + visitDateWithComplaintsDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + + DataConverter formatter = new ObjectFormatter("{familyName}, {givenName}"); + DataDefinition nameDef = new ConvertedPersonDataDefinition("name", + new PreferredNameDataDefinition(), formatter); + PersonAttributeType phoneNumber = MetadataUtils.existing(PersonAttributeType.class, + CommonMetadata._PersonAttributeType.TELEPHONE_CONTACT); + dsd.addColumn("id", new PersonIdDataDefinition(), ""); + dsd.addColumn("Name", nameDef, ""); + // dsd.addColumn("Hospital Unit", new MFLCodeDataDefinition(), ""); + dsd.addColumn("Visit Type", visitTypeDataDefinition, paramMapping); + dsd.addColumn("Sex", new GenderDataDefinition(), "", null); + dsd.addColumn("Age", ageAtReportingDataDefinition, "endDate=${endDate}"); + dsd.addColumn("Visit Date", visitDateWithComplaintsDataDefinition, paramMapping); + dsd.addColumn("Attended By", attendedByDataDefinition, paramMapping); + dsd.addColumn("Next Visit", lastAppointmentDateDataDefinition, paramMapping); + + FebrileIllnessCohortDefinition cd = new FebrileIllnessCohortDefinition(); + cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + cd.addParameter(new Parameter("endDate", "End Date", Date.class)); + + dsd.addRowFilter(cd, paramMapping); + return dsd; + } + + protected DataSetDefinition febrileRashDataSetDefinitionColumns() { + PatientDataSetDefinition dsd = new PatientDataSetDefinition(); + dsd.setName("febrileRash"); + dsd.setDescription("Acute Febrile Rash Infections"); + dsd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + dsd.addParameter(new Parameter("endDate", "End Date", Date.class)); + String paramMapping = "startDate=${startDate},endDate=${endDate}"; + + PatientIdentifierType upn = MetadataUtils.existing(PatientIdentifierType.class, + HivMetadata._PatientIdentifierType.UNIQUE_PATIENT_NUMBER); + PatientIdentifierType nupi = MetadataUtils.existing(PatientIdentifierType.class, + CommonMetadata._PatientIdentifierType.NATIONAL_UNIQUE_PATIENT_IDENTIFIER); + DataConverter identifierFormatter = new ObjectFormatter("{identifier}"); + DataDefinition identifierDef = new ConvertedPatientDataDefinition("identifier", new PatientIdentifierDataDefinition( + upn.getName(), upn), identifierFormatter); + DataDefinition nupiDef = new ConvertedPatientDataDefinition("identifier", new PatientIdentifierDataDefinition( + nupi.getName(), nupi), identifierFormatter); + AgeAtReportingDataDefinition ageAtReportingDataDefinition = new AgeAtReportingDataDefinition(); + ageAtReportingDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + + ETLNextAppointmentDateDataDefinition lastAppointmentDateDataDefinition = new ETLNextAppointmentDateDataDefinition(); + lastAppointmentDateDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + lastAppointmentDateDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + VisitTypeWithComplaintsDataDefinition visitTypeDataDefinition = new VisitTypeWithComplaintsDataDefinition(); + visitTypeDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + visitTypeDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + + ComplaintAttendantProviderDataDefinition attendedByDataDefinition = new ComplaintAttendantProviderDataDefinition(); + attendedByDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + attendedByDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + + VisitDateWithComplaintsDataDefinition visitDateWithComplaintsDataDefinition = new VisitDateWithComplaintsDataDefinition(); + visitDateWithComplaintsDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + visitDateWithComplaintsDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + + DataConverter formatter = new ObjectFormatter("{familyName}, {givenName}"); + DataDefinition nameDef = new ConvertedPersonDataDefinition("name", + new PreferredNameDataDefinition(), formatter); + PersonAttributeType phoneNumber = MetadataUtils.existing(PersonAttributeType.class, + CommonMetadata._PersonAttributeType.TELEPHONE_CONTACT); + dsd.addColumn("id", new PersonIdDataDefinition(), ""); + dsd.addColumn("Name", nameDef, ""); + // dsd.addColumn("Hospital Unit", new MFLCodeDataDefinition(), ""); + dsd.addColumn("Visit Type", visitTypeDataDefinition, paramMapping); + dsd.addColumn("Sex", new GenderDataDefinition(), "", null); + dsd.addColumn("Age", ageAtReportingDataDefinition, "endDate=${endDate}"); + dsd.addColumn("Visit Date", visitDateWithComplaintsDataDefinition, paramMapping); + dsd.addColumn("Attended By", attendedByDataDefinition, paramMapping); + dsd.addColumn("Next Visit", lastAppointmentDateDataDefinition, paramMapping); + + FebrileRashCohortDefinition cd = new FebrileRashCohortDefinition(); + cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + cd.addParameter(new Parameter("endDate", "End Date", Date.class)); + + dsd.addRowFilter(cd, paramMapping); + return dsd; + } + + protected DataSetDefinition meningitisDataSetDefinitionColumns() { + PatientDataSetDefinition dsd = new PatientDataSetDefinition(); + dsd.setName("meningitis"); + dsd.setDescription("Acute Meningitis and Encephalitis"); + dsd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + dsd.addParameter(new Parameter("endDate", "End Date", Date.class)); + String paramMapping = "startDate=${startDate},endDate=${endDate}"; + + PatientIdentifierType upn = MetadataUtils.existing(PatientIdentifierType.class, + HivMetadata._PatientIdentifierType.UNIQUE_PATIENT_NUMBER); + PatientIdentifierType nupi = MetadataUtils.existing(PatientIdentifierType.class, + CommonMetadata._PatientIdentifierType.NATIONAL_UNIQUE_PATIENT_IDENTIFIER); + DataConverter identifierFormatter = new ObjectFormatter("{identifier}"); + DataDefinition identifierDef = new ConvertedPatientDataDefinition("identifier", new PatientIdentifierDataDefinition( + upn.getName(), upn), identifierFormatter); + DataDefinition nupiDef = new ConvertedPatientDataDefinition("identifier", new PatientIdentifierDataDefinition( + nupi.getName(), nupi), identifierFormatter); + AgeAtReportingDataDefinition ageAtReportingDataDefinition = new AgeAtReportingDataDefinition(); + ageAtReportingDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + + ETLNextAppointmentDateDataDefinition lastAppointmentDateDataDefinition = new ETLNextAppointmentDateDataDefinition(); + lastAppointmentDateDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + lastAppointmentDateDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + VisitTypeWithComplaintsDataDefinition visitTypeDataDefinition = new VisitTypeWithComplaintsDataDefinition(); + visitTypeDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + visitTypeDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + + ComplaintAttendantProviderDataDefinition attendedByDataDefinition = new ComplaintAttendantProviderDataDefinition(); + attendedByDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + attendedByDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + + VisitDateWithComplaintsDataDefinition visitDateWithComplaintsDataDefinition = new VisitDateWithComplaintsDataDefinition(); + visitDateWithComplaintsDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + visitDateWithComplaintsDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + + DataConverter formatter = new ObjectFormatter("{familyName}, {givenName}"); + DataDefinition nameDef = new ConvertedPersonDataDefinition("name", + new PreferredNameDataDefinition(), formatter); + PersonAttributeType phoneNumber = MetadataUtils.existing(PersonAttributeType.class, + CommonMetadata._PersonAttributeType.TELEPHONE_CONTACT); + dsd.addColumn("id", new PersonIdDataDefinition(), ""); + dsd.addColumn("Name", nameDef, ""); + // dsd.addColumn("Hospital Unit", new MFLCodeDataDefinition(), ""); + dsd.addColumn("Visit Type", visitTypeDataDefinition, paramMapping); + dsd.addColumn("Sex", new GenderDataDefinition(), "", null); + dsd.addColumn("Age", ageAtReportingDataDefinition, "endDate=${endDate}"); + dsd.addColumn("Visit Date", visitDateWithComplaintsDataDefinition, paramMapping); + dsd.addColumn("Attended By", attendedByDataDefinition, paramMapping); + dsd.addColumn("Next Visit", lastAppointmentDateDataDefinition, paramMapping); + + MeningitisCohortDefinition cd = new MeningitisCohortDefinition(); + cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + cd.addParameter(new Parameter("endDate", "End Date", Date.class)); + + dsd.addRowFilter(cd, paramMapping); + return dsd; + } + + protected DataSetDefinition neurologicalSyndromeDataSetDefinitionColumns() { + PatientDataSetDefinition dsd = new PatientDataSetDefinition(); + dsd.setName("neurological"); + dsd.setDescription("Neurological Syndrome"); + dsd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + dsd.addParameter(new Parameter("endDate", "End Date", Date.class)); + String paramMapping = "startDate=${startDate},endDate=${endDate}"; + + PatientIdentifierType upn = MetadataUtils.existing(PatientIdentifierType.class, + HivMetadata._PatientIdentifierType.UNIQUE_PATIENT_NUMBER); + PatientIdentifierType nupi = MetadataUtils.existing(PatientIdentifierType.class, + CommonMetadata._PatientIdentifierType.NATIONAL_UNIQUE_PATIENT_IDENTIFIER); + DataConverter identifierFormatter = new ObjectFormatter("{identifier}"); + DataDefinition identifierDef = new ConvertedPatientDataDefinition("identifier", new PatientIdentifierDataDefinition( + upn.getName(), upn), identifierFormatter); + DataDefinition nupiDef = new ConvertedPatientDataDefinition("identifier", new PatientIdentifierDataDefinition( + nupi.getName(), nupi), identifierFormatter); + AgeAtReportingDataDefinition ageAtReportingDataDefinition = new AgeAtReportingDataDefinition(); + ageAtReportingDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + + ETLNextAppointmentDateDataDefinition lastAppointmentDateDataDefinition = new ETLNextAppointmentDateDataDefinition(); + lastAppointmentDateDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + lastAppointmentDateDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + VisitTypeWithComplaintsDataDefinition visitTypeDataDefinition = new VisitTypeWithComplaintsDataDefinition(); + visitTypeDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + visitTypeDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + + ComplaintAttendantProviderDataDefinition attendedByDataDefinition = new ComplaintAttendantProviderDataDefinition(); + attendedByDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + attendedByDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + + VisitDateWithComplaintsDataDefinition visitDateWithComplaintsDataDefinition = new VisitDateWithComplaintsDataDefinition(); + visitDateWithComplaintsDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + visitDateWithComplaintsDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + + DataConverter formatter = new ObjectFormatter("{familyName}, {givenName}"); + DataDefinition nameDef = new ConvertedPersonDataDefinition("name", + new PreferredNameDataDefinition(), formatter); + PersonAttributeType phoneNumber = MetadataUtils.existing(PersonAttributeType.class, + CommonMetadata._PersonAttributeType.TELEPHONE_CONTACT); + dsd.addColumn("id", new PersonIdDataDefinition(), ""); + dsd.addColumn("Name", nameDef, ""); + // dsd.addColumn("Hospital Unit", new MFLCodeDataDefinition(), ""); + dsd.addColumn("Visit Type", visitTypeDataDefinition, paramMapping); + dsd.addColumn("Sex", new GenderDataDefinition(), "", null); + dsd.addColumn("Age", ageAtReportingDataDefinition, "endDate=${endDate}"); + dsd.addColumn("Visit Date", visitDateWithComplaintsDataDefinition, paramMapping); + dsd.addColumn("Attended By", attendedByDataDefinition, paramMapping); + dsd.addColumn("Next Visit", lastAppointmentDateDataDefinition, paramMapping); + + NeurologicalSyndromeCohortDefinition cd = new NeurologicalSyndromeCohortDefinition(); + cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + cd.addParameter(new Parameter("endDate", "End Date", Date.class)); + + dsd.addRowFilter(cd, paramMapping); + return dsd; + } + + protected DataSetDefinition wateryDiarrhoeaDataSetDefinitionColumns() { + PatientDataSetDefinition dsd = new PatientDataSetDefinition(); + dsd.setName("wateryDiarrhoea"); + dsd.setDescription("Acute Watery Diarrhoea"); + dsd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + dsd.addParameter(new Parameter("endDate", "End Date", Date.class)); + String paramMapping = "startDate=${startDate},endDate=${endDate}"; + + PatientIdentifierType upn = MetadataUtils.existing(PatientIdentifierType.class, + HivMetadata._PatientIdentifierType.UNIQUE_PATIENT_NUMBER); + PatientIdentifierType nupi = MetadataUtils.existing(PatientIdentifierType.class, + CommonMetadata._PatientIdentifierType.NATIONAL_UNIQUE_PATIENT_IDENTIFIER); + DataConverter identifierFormatter = new ObjectFormatter("{identifier}"); + DataDefinition identifierDef = new ConvertedPatientDataDefinition("identifier", new PatientIdentifierDataDefinition( + upn.getName(), upn), identifierFormatter); + DataDefinition nupiDef = new ConvertedPatientDataDefinition("identifier", new PatientIdentifierDataDefinition( + nupi.getName(), nupi), identifierFormatter); + AgeAtReportingDataDefinition ageAtReportingDataDefinition = new AgeAtReportingDataDefinition(); + ageAtReportingDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + + ETLNextAppointmentDateDataDefinition lastAppointmentDateDataDefinition = new ETLNextAppointmentDateDataDefinition(); + lastAppointmentDateDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + lastAppointmentDateDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + VisitTypeWithComplaintsDataDefinition visitTypeDataDefinition = new VisitTypeWithComplaintsDataDefinition(); + visitTypeDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + visitTypeDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + + ComplaintAttendantProviderDataDefinition attendedByDataDefinition = new ComplaintAttendantProviderDataDefinition(); + attendedByDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + attendedByDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + + VisitDateWithComplaintsDataDefinition visitDateWithComplaintsDataDefinition = new VisitDateWithComplaintsDataDefinition(); + visitDateWithComplaintsDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + visitDateWithComplaintsDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + + DataConverter formatter = new ObjectFormatter("{familyName}, {givenName}"); + DataDefinition nameDef = new ConvertedPersonDataDefinition("name", + new PreferredNameDataDefinition(), formatter); + PersonAttributeType phoneNumber = MetadataUtils.existing(PersonAttributeType.class, + CommonMetadata._PersonAttributeType.TELEPHONE_CONTACT); + dsd.addColumn("id", new PersonIdDataDefinition(), ""); + dsd.addColumn("Name", nameDef, ""); + // dsd.addColumn("Hospital Unit", new MFLCodeDataDefinition(), ""); + dsd.addColumn("Visit Type", visitTypeDataDefinition, paramMapping); + dsd.addColumn("Sex", new GenderDataDefinition(), "", null); + dsd.addColumn("Age", ageAtReportingDataDefinition, "endDate=${endDate}"); + dsd.addColumn("Visit Date", visitDateWithComplaintsDataDefinition, paramMapping); + dsd.addColumn("Attended By", attendedByDataDefinition, paramMapping); + dsd.addColumn("Next Visit", lastAppointmentDateDataDefinition, paramMapping); + + WateryDiarrhoeaCohortDefinition cd = new WateryDiarrhoeaCohortDefinition(); + cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + cd.addParameter(new Parameter("endDate", "End Date", Date.class)); + + dsd.addRowFilter(cd, paramMapping); + return dsd; + } + + + + } diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/dmi/FebrileIllnessCohortDefinition.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/dmi/FebrileIllnessCohortDefinition.java new file mode 100644 index 000000000..de8bdf540 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/dmi/FebrileIllnessCohortDefinition.java @@ -0,0 +1,24 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.cohort.definition.dmi; + +import org.openmrs.module.reporting.cohort.definition.BaseCohortDefinition; +import org.openmrs.module.reporting.common.Localized; +import org.openmrs.module.reporting.definition.configuration.ConfigurationPropertyCachingStrategy; +import org.openmrs.module.reporting.evaluation.caching.Caching; + +/** + * Febrile illness cohort definition + */ +@Caching(strategy = ConfigurationPropertyCachingStrategy.class) +@Localized("reporting.FebrileIllnessCohortDefinition") +public class FebrileIllnessCohortDefinition extends BaseCohortDefinition { + +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/dmi/FebrileRashCohortDefinition.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/dmi/FebrileRashCohortDefinition.java new file mode 100644 index 000000000..27fdbaef2 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/dmi/FebrileRashCohortDefinition.java @@ -0,0 +1,24 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.cohort.definition.dmi; + +import org.openmrs.module.reporting.cohort.definition.BaseCohortDefinition; +import org.openmrs.module.reporting.common.Localized; +import org.openmrs.module.reporting.definition.configuration.ConfigurationPropertyCachingStrategy; +import org.openmrs.module.reporting.evaluation.caching.Caching; + +/** + * Febrile Rash cohort definition + */ +@Caching(strategy = ConfigurationPropertyCachingStrategy.class) +@Localized("reporting.FebrileRashCohortDefinition") +public class FebrileRashCohortDefinition extends BaseCohortDefinition { + +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/dmi/JaundiceCohortDefinition.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/dmi/JaundiceCohortDefinition.java new file mode 100644 index 000000000..5843d1c7b --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/dmi/JaundiceCohortDefinition.java @@ -0,0 +1,24 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.cohort.definition.dmi; + +import org.openmrs.module.reporting.cohort.definition.BaseCohortDefinition; +import org.openmrs.module.reporting.common.Localized; +import org.openmrs.module.reporting.definition.configuration.ConfigurationPropertyCachingStrategy; +import org.openmrs.module.reporting.evaluation.caching.Caching; + +/** + * Jaundice cohort definition + */ +@Caching(strategy = ConfigurationPropertyCachingStrategy.class) +@Localized("reporting.JaundiceCohortDefinition") +public class JaundiceCohortDefinition extends BaseCohortDefinition { + +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/dmi/MeningitisCohortDefinition.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/dmi/MeningitisCohortDefinition.java new file mode 100644 index 000000000..3f3451e19 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/dmi/MeningitisCohortDefinition.java @@ -0,0 +1,24 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.cohort.definition.dmi; + +import org.openmrs.module.reporting.cohort.definition.BaseCohortDefinition; +import org.openmrs.module.reporting.common.Localized; +import org.openmrs.module.reporting.definition.configuration.ConfigurationPropertyCachingStrategy; +import org.openmrs.module.reporting.evaluation.caching.Caching; + +/** + * Meningitis cohort definition + */ +@Caching(strategy = ConfigurationPropertyCachingStrategy.class) +@Localized("reporting.MeningitisCohortDefinition") +public class MeningitisCohortDefinition extends BaseCohortDefinition { + +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/dmi/MpoxCohortDefinition.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/dmi/MpoxCohortDefinition.java new file mode 100644 index 000000000..2eee3b827 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/dmi/MpoxCohortDefinition.java @@ -0,0 +1,24 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.cohort.definition.dmi; + +import org.openmrs.module.reporting.cohort.definition.BaseCohortDefinition; +import org.openmrs.module.reporting.common.Localized; +import org.openmrs.module.reporting.definition.configuration.ConfigurationPropertyCachingStrategy; +import org.openmrs.module.reporting.evaluation.caching.Caching; + +/** + * mpox cohort definition + */ +@Caching(strategy = ConfigurationPropertyCachingStrategy.class) +@Localized("reporting.MpoxCohortDefinition") +public class MpoxCohortDefinition extends BaseCohortDefinition { + +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/dmi/NeurologicalSyndromeCohortDefinition.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/dmi/NeurologicalSyndromeCohortDefinition.java new file mode 100644 index 000000000..eba489688 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/dmi/NeurologicalSyndromeCohortDefinition.java @@ -0,0 +1,24 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.cohort.definition.dmi; + +import org.openmrs.module.reporting.cohort.definition.BaseCohortDefinition; +import org.openmrs.module.reporting.common.Localized; +import org.openmrs.module.reporting.definition.configuration.ConfigurationPropertyCachingStrategy; +import org.openmrs.module.reporting.evaluation.caching.Caching; + +/** + * Neurological Syndrome cohort definition + */ +@Caching(strategy = ConfigurationPropertyCachingStrategy.class) +@Localized("reporting.NeurologicalSyndromeCohortDefinition") +public class NeurologicalSyndromeCohortDefinition extends BaseCohortDefinition { + +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/dmi/WateryDiarrhoeaCohortDefinition.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/dmi/WateryDiarrhoeaCohortDefinition.java new file mode 100644 index 000000000..72b367850 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/dmi/WateryDiarrhoeaCohortDefinition.java @@ -0,0 +1,24 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.cohort.definition.dmi; + +import org.openmrs.module.reporting.cohort.definition.BaseCohortDefinition; +import org.openmrs.module.reporting.common.Localized; +import org.openmrs.module.reporting.definition.configuration.ConfigurationPropertyCachingStrategy; +import org.openmrs.module.reporting.evaluation.caching.Caching; + +/** + * Watery Diarrhoea cohort definition + */ +@Caching(strategy = ConfigurationPropertyCachingStrategy.class) +@Localized("reporting.WateryDiarrhoeaCohortDefinition") +public class WateryDiarrhoeaCohortDefinition extends BaseCohortDefinition { + +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/dmi/FebrileIllnessCohortDefinitionEvaluator.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/dmi/FebrileIllnessCohortDefinitionEvaluator.java new file mode 100644 index 000000000..0a4c13bc8 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/dmi/FebrileIllnessCohortDefinitionEvaluator.java @@ -0,0 +1,77 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.cohort.definition.evaluator.dmi; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openmrs.Cohort; +import org.openmrs.annotation.Handler; +import org.openmrs.module.kenyaemr.reporting.cohort.definition.dmi.FebrileIllnessCohortDefinition; +import org.openmrs.module.reporting.cohort.EvaluatedCohort; +import org.openmrs.module.reporting.cohort.definition.CohortDefinition; +import org.openmrs.module.reporting.cohort.definition.evaluator.CohortDefinitionEvaluator; +import org.openmrs.module.reporting.evaluation.EvaluationContext; +import org.openmrs.module.reporting.evaluation.EvaluationException; +import org.openmrs.module.reporting.evaluation.querybuilder.SqlQueryBuilder; +import org.openmrs.module.reporting.evaluation.service.EvaluationService; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.HashSet; +import java.util.List; + +/** + * Evaluator for Febrile Illness Cohort + */ +@Handler(supports = { FebrileIllnessCohortDefinition.class }) +public class FebrileIllnessCohortDefinitionEvaluator implements CohortDefinitionEvaluator { + + private final Log log = LogFactory.getLog(this.getClass()); + + @Autowired + EvaluationService evaluationService; + + @Override + public EvaluatedCohort evaluate(CohortDefinition cohortDefinition, EvaluationContext context) throws EvaluationException { + + FebrileIllnessCohortDefinition definition = (FebrileIllnessCohortDefinition) cohortDefinition; + + if (definition == null) + return null; + Cohort newCohort = new Cohort(); + String sqlQuery = "select a.patient_id\n" + + " from (select patient_id, c.visit_date,group_concat(c.complaint) as complaint,\n" + + " CASE\n" + + " WHEN group_concat(concat_ws('|',c.complaint,c.complaint_duration)) LIKE '%140238%' THEN\n" + + " SUBSTRING_INDEX(SUBSTRING_INDEX(group_concat(concat_ws('|',c.complaint,c.complaint_duration)) , '|', -1), ',', 1)\n" + + " END AS fever_duration_from_days\n" + + " from kenyaemr_etl.etl_allergy_chronic_illness c\n" + + " where c.complaint = 140238\n" + + " AND c.complaint_duration < 14\n" + + " and date(c.visit_date) between date(:startDate) and date(:endDate)\n" + + " group by patient_id) a\n" + + " join kenyaemr_etl.etl_patient_demographics d on a.patient_id = d.patient_id\n" + + " join kenyaemr_etl.etl_patient_triage t\n" + + " on a.patient_id = t.patient_id and date(t.visit_date) between date(:startDate) and date(:endDate) and\n" + + " t.temperature > 38.5 and date(a.visit_date) between date(:startDate) and date(:endDate)\n" + + " where FIND_IN_SET(140238, a.complaint) > 0;"; + + SqlQueryBuilder builder = new SqlQueryBuilder(); + builder.append(sqlQuery); + Date startDate = (Date) context.getParameterValue("startDate"); + Date endDate = (Date) context.getParameterValue("endDate"); + builder.addParameter("startDate", startDate); + builder.addParameter("endDate", endDate); + + List ptIds = evaluationService.evaluateToList(builder, Integer.class, context); + newCohort.setMemberIds(new HashSet(ptIds)); + return new EvaluatedCohort(newCohort, definition, context); + } +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/dmi/FebrileRashCohortDefinitionEvaluator.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/dmi/FebrileRashCohortDefinitionEvaluator.java new file mode 100644 index 000000000..720db55c4 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/dmi/FebrileRashCohortDefinitionEvaluator.java @@ -0,0 +1,80 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.cohort.definition.evaluator.dmi; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openmrs.Cohort; +import org.openmrs.annotation.Handler; +import org.openmrs.module.kenyaemr.reporting.cohort.definition.dmi.FebrileRashCohortDefinition; +import org.openmrs.module.reporting.cohort.EvaluatedCohort; +import org.openmrs.module.reporting.cohort.definition.CohortDefinition; +import org.openmrs.module.reporting.cohort.definition.evaluator.CohortDefinitionEvaluator; +import org.openmrs.module.reporting.evaluation.EvaluationContext; +import org.openmrs.module.reporting.evaluation.EvaluationException; +import org.openmrs.module.reporting.evaluation.querybuilder.SqlQueryBuilder; +import org.openmrs.module.reporting.evaluation.service.EvaluationService; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.HashSet; +import java.util.List; + +/** + * Evaluator for FebrileRash Cohort + */ +@Handler(supports = { FebrileRashCohortDefinition.class }) +public class FebrileRashCohortDefinitionEvaluator implements CohortDefinitionEvaluator { + + private final Log log = LogFactory.getLog(this.getClass()); + + @Autowired + EvaluationService evaluationService; + + @Override + public EvaluatedCohort evaluate(CohortDefinition cohortDefinition, EvaluationContext context) throws EvaluationException { + + FebrileRashCohortDefinition definition = (FebrileRashCohortDefinition) cohortDefinition; + + if (definition == null) + return null; + + Cohort newCohort = new Cohort(); + String sqlQuery = "SELECT a.patient_id\n" + + "FROM (\n" + + " SELECT\n" + + " patient_id,\n" + + " c.visit_date,\n" + + " GROUP_CONCAT(c.complaint) AS complaint,\n" + + " DATE_SUB(c.visit_date, INTERVAL c.complaint_duration DAY) AS complaint_date,\n" + + " c.complaint_duration\n" + + " FROM\n" + + " kenyaemr_etl.etl_allergy_chronic_illness c\n" + + " WHERE\n" + + " c.complaint IN (140238, 512)\n" + + " AND c.complaint_duration < 14\n" + + " AND DATE(c.visit_date) BETWEEN DATE(:startDate) AND DATE(:endDate)\n" + + " GROUP BY patient_id) a\n" + + "WHERE\n" + + " FIND_IN_SET(140238, a.complaint) > 0\n" + + " AND FIND_IN_SET(512, a.complaint) > 0;"; + + SqlQueryBuilder builder = new SqlQueryBuilder(); + builder.append(sqlQuery); + Date startDate = (Date) context.getParameterValue("startDate"); + Date endDate = (Date) context.getParameterValue("endDate"); + builder.addParameter("startDate", startDate); + builder.addParameter("endDate", endDate); + + List ptIds = evaluationService.evaluateToList(builder, Integer.class, context); + newCohort.setMemberIds(new HashSet(ptIds)); + return new EvaluatedCohort(newCohort, definition, context); + } +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/dmi/JaundiceCohortDefinitionEvaluator.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/dmi/JaundiceCohortDefinitionEvaluator.java new file mode 100644 index 000000000..cfd7129fb --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/dmi/JaundiceCohortDefinitionEvaluator.java @@ -0,0 +1,77 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.cohort.definition.evaluator.dmi; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openmrs.Cohort; +import org.openmrs.annotation.Handler; +import org.openmrs.module.kenyaemr.reporting.cohort.definition.dmi.JaundiceCohortDefinition; +import org.openmrs.module.reporting.cohort.EvaluatedCohort; +import org.openmrs.module.reporting.cohort.definition.CohortDefinition; +import org.openmrs.module.reporting.cohort.definition.evaluator.CohortDefinitionEvaluator; +import org.openmrs.module.reporting.evaluation.EvaluationContext; +import org.openmrs.module.reporting.evaluation.EvaluationException; +import org.openmrs.module.reporting.evaluation.querybuilder.SqlQueryBuilder; +import org.openmrs.module.reporting.evaluation.service.EvaluationService; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.HashSet; +import java.util.List; + +/** + * Evaluator for Jaundice Cohort + */ +@Handler(supports = { JaundiceCohortDefinition.class }) +public class JaundiceCohortDefinitionEvaluator implements CohortDefinitionEvaluator { + + private final Log log = LogFactory.getLog(this.getClass()); + + @Autowired + EvaluationService evaluationService; + + @Override + public EvaluatedCohort evaluate(CohortDefinition cohortDefinition, EvaluationContext context) throws EvaluationException { + + JaundiceCohortDefinition definition = (JaundiceCohortDefinition) cohortDefinition; + + if (definition == null) + return null; + Cohort newCohort = new Cohort(); + String sqlQuery = "SELECT a.patient_id\n" + + "FROM (\n" + + " SELECT patient_id, GROUP_CONCAT(c.general_examination) AS general_examination\n" + + " FROM kenyaemr_etl.etl_clinical_encounter c\n" + + " WHERE c.general_examination LIKE '%Jaundice%'\n" + + " AND DATE(c.visit_date) BETWEEN DATE(:startDate) AND DATE(:endDate)\n" + + " GROUP BY patient_id\n" + + " UNION ALL\n" + + " SELECT patient_id, GROUP_CONCAT(h.general_examination) AS general_examination\n" + + " FROM kenyaemr_etl.etl_patient_hiv_followup h\n" + + " WHERE h.general_examination LIKE '%Jaundice%'\n" + + " AND DATE(h.visit_date) BETWEEN DATE(:startDate) AND DATE(:endDate)\n" + + " GROUP BY patient_id\n" + + ") a\n" + + "WHERE a.general_examination IS NOT NULL\n" + + " AND FIND_IN_SET('Jaundice', a.general_examination) > 0;"; + + SqlQueryBuilder builder = new SqlQueryBuilder(); + builder.append(sqlQuery); + Date startDate = (Date) context.getParameterValue("startDate"); + Date endDate = (Date) context.getParameterValue("endDate"); + builder.addParameter("startDate", startDate); + builder.addParameter("endDate", endDate); + + List ptIds = evaluationService.evaluateToList(builder, Integer.class, context); + newCohort.setMemberIds(new HashSet(ptIds)); + return new EvaluatedCohort(newCohort, definition, context); + } +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/dmi/MeningitisCohortDefinitionEvaluator.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/dmi/MeningitisCohortDefinitionEvaluator.java new file mode 100644 index 000000000..b1444d529 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/dmi/MeningitisCohortDefinitionEvaluator.java @@ -0,0 +1,72 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.cohort.definition.evaluator.dmi; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openmrs.Cohort; +import org.openmrs.annotation.Handler; +import org.openmrs.module.kenyaemr.reporting.cohort.definition.dmi.MeningitisCohortDefinition; +import org.openmrs.module.reporting.cohort.EvaluatedCohort; +import org.openmrs.module.reporting.cohort.definition.CohortDefinition; +import org.openmrs.module.reporting.cohort.definition.evaluator.CohortDefinitionEvaluator; +import org.openmrs.module.reporting.evaluation.EvaluationContext; +import org.openmrs.module.reporting.evaluation.EvaluationException; +import org.openmrs.module.reporting.evaluation.querybuilder.SqlQueryBuilder; +import org.openmrs.module.reporting.evaluation.service.EvaluationService; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.HashSet; +import java.util.List; + +/** + * Evaluator for Meningitis Cohort + */ +@Handler(supports = { MeningitisCohortDefinition.class }) +public class MeningitisCohortDefinitionEvaluator implements CohortDefinitionEvaluator { + + private final Log log = LogFactory.getLog(this.getClass()); + + @Autowired + EvaluationService evaluationService; + + @Override + public EvaluatedCohort evaluate(CohortDefinition cohortDefinition, EvaluationContext context) throws EvaluationException { + + MeningitisCohortDefinition definition = (MeningitisCohortDefinition) cohortDefinition; + + if (definition == null) + return null; + + Cohort newCohort = new Cohort(); + + String sqlQuery = "SELECT a.patient_id\n" + + "FROM (\n" + + " SELECT patient_id, GROUP_CONCAT(c.complaint) AS complaint\n" + + " FROM kenyaemr_etl.etl_allergy_chronic_illness c\n" + + " WHERE c.complaint IN (112721)\n" + + " AND DATE(c.visit_date) BETWEEN DATE(:startDate) AND DATE(:endDate)\n" + + " GROUP BY patient_id\n" + + ") a\n" + + "WHERE FIND_IN_SET(112721, a.complaint) > 0;"; + + SqlQueryBuilder builder = new SqlQueryBuilder(); + builder.append(sqlQuery); + Date startDate = (Date) context.getParameterValue("startDate"); + Date endDate = (Date) context.getParameterValue("endDate"); + builder.addParameter("startDate", startDate); + builder.addParameter("endDate", endDate); + + List ptIds = evaluationService.evaluateToList(builder, Integer.class, context); + newCohort.setMemberIds(new HashSet(ptIds)); + return new EvaluatedCohort(newCohort, definition, context); + } +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/dmi/MpoxCohortDefinitionEvaluator.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/dmi/MpoxCohortDefinitionEvaluator.java new file mode 100644 index 000000000..9f7e6c4cb --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/dmi/MpoxCohortDefinitionEvaluator.java @@ -0,0 +1,84 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.cohort.definition.evaluator.dmi; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openmrs.Cohort; +import org.openmrs.annotation.Handler; +import org.openmrs.module.kenyaemr.reporting.cohort.definition.dmi.MpoxCohortDefinition; +import org.openmrs.module.reporting.cohort.EvaluatedCohort; +import org.openmrs.module.reporting.cohort.definition.CohortDefinition; +import org.openmrs.module.reporting.cohort.definition.evaluator.CohortDefinitionEvaluator; +import org.openmrs.module.reporting.evaluation.EvaluationContext; +import org.openmrs.module.reporting.evaluation.EvaluationException; +import org.openmrs.module.reporting.evaluation.querybuilder.SqlQueryBuilder; +import org.openmrs.module.reporting.evaluation.service.EvaluationService; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.HashSet; +import java.util.List; + +/** + * Evaluator for MPox Cohort + */ +@Handler(supports = { MpoxCohortDefinition.class }) +public class MpoxCohortDefinitionEvaluator implements CohortDefinitionEvaluator { + + private final Log log = LogFactory.getLog(this.getClass()); + + @Autowired + EvaluationService evaluationService; + + @Override + public EvaluatedCohort evaluate(CohortDefinition cohortDefinition, EvaluationContext context) throws EvaluationException { + + MpoxCohortDefinition definition = (MpoxCohortDefinition) cohortDefinition; + + if (definition == null) + return null; + + Cohort newCohort = new Cohort(); + + String sqlQuery = "select a.patient_id\n" + + " from (select patient_id, c.visit_date, group_concat(c.complaint) as complaint,\n" + + " CASE\n" + + " WHEN group_concat(concat_ws('|', c.complaint, c.complaint_duration)) LIKE '%140238%' THEN\n" + + " SUBSTRING_INDEX(SUBSTRING_INDEX(group_concat(concat_ws('|', c.complaint, c.complaint_duration)), '|', -1), ',', 1)\n" + + " END AS fever_duration_from_days\n" + + " from kenyaemr_etl.etl_allergy_chronic_illness c\n" + + " where c.complaint in (140238, 512, 139084, 135488, 121, 148035)\n" + + " and date(c.visit_date) between date(:startDate) and date(:endDate)\n" + + " group by patient_id) a\n" + + " join kenyaemr_etl.etl_patient_demographics d on a.patient_id = d.patient_id\n" + + " join kenyaemr_etl.etl_patient_triage t on a.patient_id = t.patient_id\n" + + " and date(t.visit_date) between date(:startDate) and date(:endDate)\n" + + " and t.temperature > 38.5\n" + + " and date(a.visit_date) between date(:startDate) and date(:endDate)\n" + + " where FIND_IN_SET(140238, a.complaint) > 0\n" + + " and FIND_IN_SET(512, a.complaint) > 0\n" + + " and (FIND_IN_SET(139084, a.complaint) > 0\n" + + " or FIND_IN_SET(135488, a.complaint) > 0\n" + + " or FIND_IN_SET(121, a.complaint) > 0\n" + + " or FIND_IN_SET(148035, a.complaint) > 0);"; + + SqlQueryBuilder builder = new SqlQueryBuilder(); + builder.append(sqlQuery); + Date startDate = (Date) context.getParameterValue("startDate"); + Date endDate = (Date) context.getParameterValue("endDate"); + builder.addParameter("startDate", startDate); + builder.addParameter("endDate", endDate); + + List ptIds = evaluationService.evaluateToList(builder, Integer.class, context); + newCohort.setMemberIds(new HashSet(ptIds)); + return new EvaluatedCohort(newCohort, definition, context); + } +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/dmi/NeurologicalSyndromeCohortDefinitionEvaluator.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/dmi/NeurologicalSyndromeCohortDefinitionEvaluator.java new file mode 100644 index 000000000..e694cca98 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/dmi/NeurologicalSyndromeCohortDefinitionEvaluator.java @@ -0,0 +1,77 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.cohort.definition.evaluator.dmi; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openmrs.Cohort; +import org.openmrs.annotation.Handler; +import org.openmrs.module.kenyaemr.reporting.cohort.definition.dmi.NeurologicalSyndromeCohortDefinition; +import org.openmrs.module.reporting.cohort.EvaluatedCohort; +import org.openmrs.module.reporting.cohort.definition.CohortDefinition; +import org.openmrs.module.reporting.cohort.definition.evaluator.CohortDefinitionEvaluator; +import org.openmrs.module.reporting.evaluation.EvaluationContext; +import org.openmrs.module.reporting.evaluation.EvaluationException; +import org.openmrs.module.reporting.evaluation.querybuilder.SqlQueryBuilder; +import org.openmrs.module.reporting.evaluation.service.EvaluationService; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.HashSet; +import java.util.List; + +/** + * Evaluator for Neurological Syndrome Cohort + */ +@Handler(supports = { NeurologicalSyndromeCohortDefinition.class }) +public class NeurologicalSyndromeCohortDefinitionEvaluator implements CohortDefinitionEvaluator { + + private final Log log = LogFactory.getLog(this.getClass()); + + @Autowired + EvaluationService evaluationService; + + @Override + public EvaluatedCohort evaluate(CohortDefinition cohortDefinition, EvaluationContext context) throws EvaluationException { + + NeurologicalSyndromeCohortDefinition definition = (NeurologicalSyndromeCohortDefinition) cohortDefinition; + + if (definition == null) + return null; + + Cohort newCohort = new Cohort(); + + String qry = " SELECT a.patient_id\n" + + "FROM (\n" + + " SELECT patient_id, c.visit_date, GROUP_CONCAT(c.complaint) AS complaint\n" + + " FROM kenyaemr_etl.etl_allergy_chronic_illness c\n" + + " WHERE c.complaint IN (6017, 113054)\n" + + " AND DATE(c.visit_date) BETWEEN DATE(:startDate) AND DATE(:endDate)\n" + + " GROUP BY patient_id\n" + + ") a\n" + + "JOIN kenyaemr_etl.etl_patient_demographics d ON a.patient_id = d.patient_id\n" + + "JOIN kenyaemr_etl.etl_patient_triage t ON a.patient_id = t.patient_id\n" + + " AND DATE(t.visit_date) BETWEEN DATE(:startDate) AND DATE(:endDate)\n" + + "WHERE FIND_IN_SET(6017, a.complaint) > 0\n" + + " AND FIND_IN_SET(113054, a.complaint) > 0\n" + + " AND TIMESTAMPDIFF(DAY, d.DOB, a.visit_date) BETWEEN 2 AND 28;"; + + SqlQueryBuilder builder = new SqlQueryBuilder(); + builder.append(qry); + Date startDate = (Date) context.getParameterValue("startDate"); + Date endDate = (Date) context.getParameterValue("endDate"); + builder.addParameter("startDate", startDate); + builder.addParameter("endDate", endDate); + + List ptIds = evaluationService.evaluateToList(builder, Integer.class, context); + newCohort.setMemberIds(new HashSet(ptIds)); + return new EvaluatedCohort(newCohort, definition, context); + } +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/dmi/WateryDiarrhoeaCohortDefinitionEvaluator.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/dmi/WateryDiarrhoeaCohortDefinitionEvaluator.java new file mode 100644 index 000000000..f7706d93b --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/cohort/definition/evaluator/dmi/WateryDiarrhoeaCohortDefinitionEvaluator.java @@ -0,0 +1,79 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.kenyaemr.reporting.cohort.definition.evaluator.dmi; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openmrs.Cohort; +import org.openmrs.annotation.Handler; +import org.openmrs.module.kenyaemr.reporting.cohort.definition.dmi.WateryDiarrhoeaCohortDefinition; +import org.openmrs.module.reporting.cohort.EvaluatedCohort; +import org.openmrs.module.reporting.cohort.definition.CohortDefinition; +import org.openmrs.module.reporting.cohort.definition.evaluator.CohortDefinitionEvaluator; +import org.openmrs.module.reporting.evaluation.EvaluationContext; +import org.openmrs.module.reporting.evaluation.EvaluationException; +import org.openmrs.module.reporting.evaluation.querybuilder.SqlQueryBuilder; +import org.openmrs.module.reporting.evaluation.service.EvaluationService; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.HashSet; +import java.util.List; + +/** + * Evaluator for Watery Diarrhoea Cohort + */ +@Handler(supports = { WateryDiarrhoeaCohortDefinition.class }) +public class WateryDiarrhoeaCohortDefinitionEvaluator implements CohortDefinitionEvaluator { + + private final Log log = LogFactory.getLog(this.getClass()); + + @Autowired + EvaluationService evaluationService; + + @Override + public EvaluatedCohort evaluate(CohortDefinition cohortDefinition, EvaluationContext context) throws EvaluationException { + + WateryDiarrhoeaCohortDefinition definition = (WateryDiarrhoeaCohortDefinition) cohortDefinition; + + if (definition == null) + return null; + + Cohort newCohort = new Cohort(); + + String qry = "SELECT a.patient_id\n" + + "FROM (\n" + + " SELECT \n" + + " patient_id, \n" + + " c.visit_date,\n" + + " GROUP_CONCAT(c.complaint) AS complaint, \n" + + " DATE_SUB(c.visit_date, INTERVAL c.complaint_duration DAY) AS complaint_date,\n" + + " c.complaint_duration\n" + + " FROM \n" + + " kenyaemr_etl.etl_allergy_chronic_illness c\n" + + " WHERE \n" + + " c.complaint = 161887\n" + + " AND c.complaint_duration < 14\n" + + " AND DATE(c.visit_date) BETWEEN DATE(:startDate) AND DATE(:endDate)\n" + + " GROUP BY patient_id) a\n" + + "WHERE FIND_IN_SET(161887, a.complaint) > 0;;"; + + SqlQueryBuilder builder = new SqlQueryBuilder(); + builder.append(qry); + Date startDate = (Date) context.getParameterValue("startDate"); + Date endDate = (Date) context.getParameterValue("endDate"); + builder.addParameter("startDate", startDate); + builder.addParameter("endDate", endDate); + + List ptIds = evaluationService.evaluateToList(builder, Integer.class, context); + newCohort.setMemberIds(new HashSet(ptIds)); + return new EvaluatedCohort(newCohort, definition, context); + } +} diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/dmi/DiseaseDataEvaluator.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/dmi/DiseaseDataEvaluator.java index a973283f7..ba95c6138 100644 --- a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/dmi/DiseaseDataEvaluator.java +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/data/converter/definition/evaluator/dmi/DiseaseDataEvaluator.java @@ -35,12 +35,55 @@ public class DiseaseDataEvaluator implements PersonDataEvaluator { public EvaluatedPersonData evaluate(PersonDataDefinition definition, EvaluationContext context) throws EvaluationException { EvaluatedPersonData c = new EvaluatedPersonData(definition, context); +// String qry = "select a.patient_id,\n" + +// " CASE\n" + +// " WHEN FIND_IN_SET(117671, a.complaint) > 0 AND FIND_IN_SET(142412, a.complaint) > 0 THEN 'Dysentery'\n" + +// " WHEN FIND_IN_SET(142412, a.complaint) > 0 AND FIND_IN_SET(122983, a.complaint) > 0 AND\n" + +// " a.complaint_duration > 2\n" + +// " THEN 'Cholera'\n" + +// " WHEN a.complaint = 143264 AND a.complaint_duration < 10 AND\n" + +// " date(a.visit_date) BETWEEN DATE(:startDate) AND DATE(:endDate) AND a.visit_type_id = 1 AND\n" + +// " a.temperature >= 38 THEN 'ILI'\n" + +// " WHEN a.complaint = 143264 AND a.complaint_duration < 10 AND\n" + +// " date(a.visit_date) BETWEEN DATE(:startDate) AND DATE(:endDate) AND a.visit_type_id = 3 AND\n" + +// " a.temperature >= 38 THEN 'SARI'\n" + +// " WHEN FIND_IN_SET(140238, a.complaint) > 0 AND FIND_IN_SET(141830, a.complaint) > 0 AND\n" + +// " FIND_IN_SET(136443, a.complaint) > 0 AND FIND_IN_SET(135367, a.complaint) > 0 AND\n" + +// " a.fever_duration_from_days > 2 THEN 'Rift Valley Fever'\n" + +// " WHEN FIND_IN_SET(140238, a.complaint) > 0 AND FIND_IN_SET(139084, a.complaint) > 0 AND\n" + +// " FIND_IN_SET(871, a.complaint) > 0 AND a.fever_duration_from_days > 1 THEN 'Malaria'\n" + +// " WHEN FIND_IN_SET(140238, a.complaint) > 0 AND FIND_IN_SET(116558, a.complaint) > 0 AND a.temperature > 38.5 AND a.fever_duration_from_days > 2\n" + +// " THEN 'Chikungunya'\n" + +// " WHEN FIND_IN_SET(157498, a.complaint) > 0 AND timestampdiff(YEAR, a.DOB, a.visit_date) <= 15\n" + +// " THEN 'Poliomyelitis'\n" + +// " WHEN FIND_IN_SET(140238, a.complaint) > 0 AND FIND_IN_SET(162628, a.complaint) > 0 AND\n" + +// " a.fever_duration_from_days >= 3 THEN 'Viral Haemorrhagic Fever'\n" + +// " WHEN FIND_IN_SET(140238, a.complaint) > 0 AND FIND_IN_SET(512, a.complaint) > 0 AND\n" + +// " FIND_IN_SET(106, a.complaint) > 0 AND FIND_IN_SET(516, a.complaint) > 0 AND\n" + +// " FIND_IN_SET(143264, a.complaint) > 0 AND a.fever_duration_from_days > 2 THEN 'Measles'\n" + +// " WHEN FIND_IN_SET(140238, a.complaint) > 0 AND FIND_IN_SET(512, a.complaint) > 0 AND FIND_IN_SET(139084, a.complaint) > 0 AND a.temperature > 38.5\n" + +// " or FIND_IN_SET(135488, a.complaint) > 0\n" + +// " or FIND_IN_SET(121, a.complaint) > 0\n" + +// " or FIND_IN_SET(148035, a.complaint) > 0 THEN 'Mpox'\n" + +// " WHEN FIND_IN_SET(6017, a.complaint) > 0\n"+ +// " AND FIND_IN_SET(113054, a.complaint) > 0\n" + +// " AND TIMESTAMPDIFF(DAY, d.DOB, a.visit_date) BETWEEN 2 AND 28 THEN 'Neurological Syndrome'\n" + +// " WHEN FIND_IN_SET(161887, a.complaint) > 0 \n"+ +// " AND a.complaint_duration < 14 THEN 'Acute Watery Diarrhoea'\n"+ +// " WHEN FIND_IN_SET(140238, a.complaint) > 0 \n"+ +// " AND a.complaint_duration < 14 \n"+ +// " AND FIND_IN_SET(512, a.complaint) > 0 THEN 'Acute Febrile Rash Infections'\n"+ +// " WHEN FIND_IN_SET(140238, a.complaint) > 0 \n"+ +// " AND a.complaint_duration < 14 \n"+ +// " date(a.visit_date) BETWEEN DATE(:startDate) AND DATE(:endDate) AND\n" + +// " a.temperature >= 38 THEN 'Acute Febrile Illness'\n" + +// " WHEN FIND_IN_SET(112721, a.complaint) > 0 THEN 'Acute Meningitis and Encephalitis'\n" + +// " END AS disease\n" + String qry = "select a.patient_id,\n" + " CASE\n" + " WHEN FIND_IN_SET(117671, a.complaint) > 0 AND FIND_IN_SET(142412, a.complaint) > 0 THEN 'Dysentery'\n" + " WHEN FIND_IN_SET(142412, a.complaint) > 0 AND FIND_IN_SET(122983, a.complaint) > 0 AND\n" + - " a.complaint_duration > 2\n" + - " THEN 'Cholera'\n" + + " a.complaint_duration > 2 THEN 'Cholera'\n" + " WHEN a.complaint = 143264 AND a.complaint_duration < 10 AND\n" + " date(a.visit_date) BETWEEN DATE(:startDate) AND DATE(:endDate) AND a.visit_type_id = 1 AND\n" + " a.temperature >= 38 THEN 'ILI'\n" + @@ -52,16 +95,31 @@ public EvaluatedPersonData evaluate(PersonDataDefinition definition, EvaluationC " a.fever_duration_from_days > 2 THEN 'Rift Valley Fever'\n" + " WHEN FIND_IN_SET(140238, a.complaint) > 0 AND FIND_IN_SET(139084, a.complaint) > 0 AND\n" + " FIND_IN_SET(871, a.complaint) > 0 AND a.fever_duration_from_days > 1 THEN 'Malaria'\n" + - " WHEN FIND_IN_SET(140238, a.complaint) > 0 AND FIND_IN_SET(116558, a.complaint) > 0 AND a.temperature > 38.5 AND a.fever_duration_from_days > 2\n" + - " THEN 'Chikungunya'\n" + - " WHEN FIND_IN_SET(157498, a.complaint) > 0 AND timestampdiff(YEAR, a.DOB, a.visit_date) <= 15\n" + - " THEN 'Poliomyelitis'\n" + + " WHEN FIND_IN_SET(140238, a.complaint) > 0 AND FIND_IN_SET(116558, a.complaint) > 0 AND a.temperature > 38.5 AND a.fever_duration_from_days > 2 THEN 'Chikungunya'\n" + + " WHEN FIND_IN_SET(157498, a.complaint) > 0 AND timestampdiff(YEAR, a.DOB, a.visit_date) <= 15 THEN 'Acute Flaccid Paralysis'\n" + " WHEN FIND_IN_SET(140238, a.complaint) > 0 AND FIND_IN_SET(162628, a.complaint) > 0 AND\n" + - " a.fever_duration_from_days >= 3 THEN 'Viral Haemorrhagic Fever'\n" + + " a.fever_duration_from_days >= 3 THEN 'Acute Haemorrhagic Fever'\n" + " WHEN FIND_IN_SET(140238, a.complaint) > 0 AND FIND_IN_SET(512, a.complaint) > 0 AND\n" + " FIND_IN_SET(106, a.complaint) > 0 AND FIND_IN_SET(516, a.complaint) > 0 AND\n" + - " FIND_IN_SET(143264, a.complaint) > 0 AND a.fever_duration_from_days > 2 THEN 'Measles'\n" + - " END AS disease\n" + + " FIND_IN_SET(143264, a.complaint) > 0 AND a.fever_duration_from_days > 2 THEN 'Measles'\n" + + " WHEN FIND_IN_SET(140238, a.complaint) > 0 AND FIND_IN_SET(512, a.complaint) > 0 AND FIND_IN_SET(139084, a.complaint) > 0 AND a.temperature > 38.5\n" + + " OR FIND_IN_SET(135488, a.complaint) > 0\n" + + " OR FIND_IN_SET(121, a.complaint) > 0\n" + + " OR FIND_IN_SET(148035, a.complaint) > 0 THEN 'Mpox'\n" + + " WHEN FIND_IN_SET(6017, a.complaint) > 0\n" + + " AND FIND_IN_SET(113054, a.complaint) > 0\n" + + " AND TIMESTAMPDIFF(DAY, a.DOB, a.visit_date) BETWEEN 2 AND 28 THEN 'Neurological Syndrome'\n" + + " WHEN FIND_IN_SET(161887, a.complaint) > 0\n" + + " AND a.complaint_duration < 14 THEN 'Acute Watery Diarrhoea'\n" + + " WHEN FIND_IN_SET(140238, a.complaint) > 0\n" + + " AND a.complaint_duration < 14\n" + + " AND FIND_IN_SET(512, a.complaint) > 0 THEN 'Acute Febrile Rash Infections'\n" + + " WHEN FIND_IN_SET(140238, a.complaint) > 0\n" + + " AND a.complaint_duration < 14\n" + + " AND date(a.visit_date) BETWEEN DATE(:startDate) AND DATE(:endDate) AND\n" + + " a.temperature >= 38 THEN 'Acute Febrile Illness'\n" + + " WHEN FIND_IN_SET(112721, a.complaint) > 0 THEN 'Acute Meningitis and Encephalitis'\n" + + " END AS disease\n"+ " from (select c.patient_id,\n" + " group_concat(c.complaint) as complaint,\n" + " epd.dob,\n" + diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/library/dmi/IDSRCohortLibrary.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/library/dmi/IDSRCohortLibrary.java index 2c489eb24..e106780b4 100644 --- a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/library/dmi/IDSRCohortLibrary.java +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/library/dmi/IDSRCohortLibrary.java @@ -248,7 +248,7 @@ public CohortDefinition poliomyelitisCases() { cd.setQuery(sqlQuery); cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); cd.addParameter(new Parameter("endDate", "End Date", Date.class)); - cd.setDescription("Poliomyelitis Cases"); + cd.setDescription("Acute Flaccid Paralysis"); return cd; } @@ -275,7 +275,7 @@ public CohortDefinition viralHaemorrhagicFeverCases() { cd.setQuery(sqlQuery); cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); cd.addParameter(new Parameter("endDate", "End Date", Date.class)); - cd.setDescription("viral Haemorrhagic Fever Cases"); + cd.setDescription("Acute Haemorrhagic Fever"); return cd;} /** @@ -308,4 +308,218 @@ public CohortDefinition measlesCases() { return cd; } + /** + * Monkey Pox Cases + * @return + */ + public CohortDefinition monkeyPoxCases() { + SqlCohortDefinition cd = new SqlCohortDefinition(); + String sqlQuery = "select a.patient_id\n" + + " from (select patient_id, c.visit_date, group_concat(c.complaint) as complaint,\n" + + " CASE\n" + + " WHEN group_concat(concat_ws('|', c.complaint, c.complaint_duration)) LIKE '%140238%' THEN\n" + + " SUBSTRING_INDEX(SUBSTRING_INDEX(group_concat(concat_ws('|', c.complaint, c.complaint_duration)), '|', -1), ',', 1)\n" + + " END AS fever_duration_from_days\n" + + " from kenyaemr_etl.etl_allergy_chronic_illness c\n" + + " where c.complaint in (140238, 512, 139084, 135488, 121, 148035)\n" + + " and date(c.visit_date) between date(:startDate) and date(:endDate)\n" + + " group by patient_id) a\n" + + " join kenyaemr_etl.etl_patient_demographics d on a.patient_id = d.patient_id\n" + + " join kenyaemr_etl.etl_patient_triage t on a.patient_id = t.patient_id\n" + + " and date(t.visit_date) between date(:startDate) and date(:endDate)\n" + + " and t.temperature > 38.5\n" + + " and date(a.visit_date) between date(:startDate) and date(:endDate)\n" + + " where FIND_IN_SET(140238, a.complaint) > 0\n" + + " and FIND_IN_SET(512, a.complaint) > 0\n" + + " and (FIND_IN_SET(139084, a.complaint) > 0\n" + + " or FIND_IN_SET(135488, a.complaint) > 0\n" + + " or FIND_IN_SET(121, a.complaint) > 0\n" + + " or FIND_IN_SET(148035, a.complaint) > 0);"; + cd.setName("monkeyPox"); + cd.setQuery(sqlQuery); + cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + cd.addParameter(new Parameter("endDate", "End Date", Date.class)); + cd.setDescription("Monkey Pox"); + + return cd; + } + + + /** + * Jaundice cases + * @return + */ + + public CohortDefinition jaundiceCases() { + SqlCohortDefinition cd = new SqlCohortDefinition(); + String sqlQuery = "SELECT a.patient_id\n" + + "FROM (\n" + + " SELECT patient_id, GROUP_CONCAT(c.general_examination) AS general_examination\n" + + " FROM kenyaemr_etl.etl_clinical_encounter c\n" + + " WHERE c.general_examination LIKE '%Jaundice%'\n" + + " AND DATE(c.visit_date) BETWEEN DATE(:startDate) AND DATE(:endDate)\n" + + " GROUP BY patient_id\n" + + " UNION ALL\n" + + " SELECT patient_id, GROUP_CONCAT(h.general_examination) AS general_examination\n" + + " FROM kenyaemr_etl.etl_patient_hiv_followup h\n" + + " WHERE h.general_examination LIKE '%Jaundice%'\n" + + " AND DATE(h.visit_date) BETWEEN DATE(:startDate) AND DATE(:endDate)\n" + + " GROUP BY patient_id\n" + + ") a\n" + + "WHERE a.general_examination IS NOT NULL\n" + + " AND FIND_IN_SET('Jaundice', a.general_examination) > 0;"; + cd.setName("jaundice"); + cd.setQuery(sqlQuery); + cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + cd.addParameter(new Parameter("endDate", "End Date", Date.class)); + cd.setDescription("Acute Jaundice"); + + return cd; + } + + /** + * Neurological Syndrome + * @return + */ + public CohortDefinition neurologicalSyndrome() { + SqlCohortDefinition cd = new SqlCohortDefinition(); + String sqlQuery = "SELECT a.patient_id\n" + + "FROM (\n" + + " SELECT patient_id, c.visit_date, GROUP_CONCAT(c.complaint) AS complaint\n" + + " FROM kenyaemr_etl.etl_allergy_chronic_illness c\n" + + " WHERE c.complaint IN (6017, 113054)\n" + + " AND DATE(c.visit_date) BETWEEN DATE(:startDate) AND DATE(:endDate)\n" + + " GROUP BY patient_id\n" + + ") a\n" + + "JOIN kenyaemr_etl.etl_patient_demographics d ON a.patient_id = d.patient_id\n" + + "JOIN kenyaemr_etl.etl_patient_triage t ON a.patient_id = t.patient_id\n" + + " AND DATE(t.visit_date) BETWEEN DATE(:startDate) AND DATE(:endDate)\n" + + "WHERE FIND_IN_SET(6017, a.complaint) > 0\n" + + " AND FIND_IN_SET(113054, a.complaint) > 0\n" + + " AND TIMESTAMPDIFF(DAY, d.DOB, a.visit_date) BETWEEN 2 AND 28;"; + cd.setName("neurologicalSyndrome"); + cd.setQuery(sqlQuery); + cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + cd.addParameter(new Parameter("endDate", "End Date", Date.class)); + cd.setDescription("Neurological Syndrome"); + + return cd; + } + + /** + * Acute Watery Diarrhoea + * @return + */ + public CohortDefinition acuteWateryDiarrhoea() { + SqlCohortDefinition cd = new SqlCohortDefinition(); + String sqlQuery = "SELECT a.patient_id\n" + + "FROM (\n" + + " SELECT \n" + + " patient_id, \n" + + " c.visit_date,\n" + + " GROUP_CONCAT(c.complaint) AS complaint, \n" + + " DATE_SUB(c.visit_date, INTERVAL c.complaint_duration DAY) AS complaint_date,\n" + + " c.complaint_duration\n" + + " FROM \n" + + " kenyaemr_etl.etl_allergy_chronic_illness c\n" + + " WHERE \n" + + " c.complaint = 161887\n" + + " AND c.complaint_duration < 14\n" + + " AND DATE(c.visit_date) BETWEEN DATE(:startDate) AND DATE(:endDate)\n" + + " GROUP BY patient_id) a\n" + + "WHERE FIND_IN_SET(161887, a.complaint) > 0;"; + cd.setName("acuteWateryDiarrhoea"); + cd.setQuery(sqlQuery); + cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + cd.addParameter(new Parameter("endDate", "End Date", Date.class)); + cd.setDescription("Acute Watery Diarrhoea"); + + return cd; + } + + /** + * Acute Febrile Rash infections + * @return + */ + public CohortDefinition acuteFebrileRashInfections(){ + SqlCohortDefinition cd = new SqlCohortDefinition(); + String sqlQuery = "SELECT a.patient_id\n" + + "FROM (\n" + + " SELECT\n" + + " patient_id,\n" + + " c.visit_date,\n" + + " GROUP_CONCAT(c.complaint) AS complaint,\n" + + " DATE_SUB(c.visit_date, INTERVAL c.complaint_duration DAY) AS complaint_date,\n" + + " c.complaint_duration\n" + + " FROM\n" + + " kenyaemr_etl.etl_allergy_chronic_illness c\n" + + " WHERE\n" + + " c.complaint IN (140238, 512)\n" + + " AND c.complaint_duration < 14\n" + + " AND DATE(c.visit_date) BETWEEN DATE(:startDate) AND DATE(:endDate)\n" + + " GROUP BY patient_id) a\n" + + "WHERE\n" + + " FIND_IN_SET(140238, a.complaint) > 0\n" + + " AND FIND_IN_SET(512, a.complaint) > 0;"; + cd.setName("acuteFebrileRashInfections"); + cd.setQuery(sqlQuery); + cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + cd.addParameter(new Parameter("endDate", "End Date", Date.class)); + cd.setDescription("Acute Febrile Rash Infections"); + + return cd; + } + /** + * Acute Febrile illness + * @return + */ + public CohortDefinition acuteFebrileIllness(){ + SqlCohortDefinition cd = new SqlCohortDefinition(); + String sqlQuery = "select a.patient_id\n" + + " from (select patient_id, c.visit_date,group_concat(c.complaint) as complaint,\n" + + " CASE\n" + + " WHEN group_concat(concat_ws('|',c.complaint,c.complaint_duration)) LIKE '%140238%' THEN\n" + + " SUBSTRING_INDEX(SUBSTRING_INDEX(group_concat(concat_ws('|',c.complaint,c.complaint_duration)) , '|', -1), ',', 1)\n" + + " END AS fever_duration_from_days\n" + + " from kenyaemr_etl.etl_allergy_chronic_illness c\n" + + " where c.complaint = 140238\n" + + " AND c.complaint_duration < 14\n" + + " and date(c.visit_date) between date(:startDate) and date(:endDate)\n" + + " group by patient_id) a\n" + + " join kenyaemr_etl.etl_patient_demographics d on a.patient_id = d.patient_id\n" + + " join kenyaemr_etl.etl_patient_triage t\n" + + " on a.patient_id = t.patient_id and date(t.visit_date) between date(:startDate) and date(:endDate) and\n" + + " t.temperature > 38.5 and date(a.visit_date) between date(:startDate) and date(:endDate)\n" + + " where FIND_IN_SET(140238, a.complaint) > 0;"; + cd.setName("acuteFebrileIllness"); + cd.setQuery(sqlQuery); + cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + cd.addParameter(new Parameter("endDate", "End Date", Date.class)); + cd.setDescription("Acute Febrile Illness"); + + return cd; + } + /** + * Acute Meningitis and Encephalitis + */ + public CohortDefinition acuteMeningitisAndEncephalitis() { + SqlCohortDefinition cd = new SqlCohortDefinition(); + String sqlQuery = "SELECT a.patient_id\n" + + "FROM (\n" + + " SELECT patient_id, GROUP_CONCAT(c.complaint) AS complaint\n" + + " FROM kenyaemr_etl.etl_allergy_chronic_illness c\n" + + " WHERE c.complaint IN (112721)\n" + + " AND DATE(c.visit_date) BETWEEN DATE(:startDate) AND DATE(:endDate)\n" + + " GROUP BY patient_id\n" + + ") a\n" + + "WHERE FIND_IN_SET(112721, a.complaint) > 0;"; + cd.setName("meningitis"); + cd.setQuery(sqlQuery); + cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + cd.addParameter(new Parameter("endDate", "End Date", Date.class)); + cd.setDescription("Acute Meningitis and Encephalitis"); + + return cd; + } + } \ No newline at end of file diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/library/dmi/IDSRIndicatorLibrary.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/library/dmi/IDSRIndicatorLibrary.java index 46c7f28f3..fb142d1e2 100644 --- a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/library/dmi/IDSRIndicatorLibrary.java +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/library/dmi/IDSRIndicatorLibrary.java @@ -93,7 +93,7 @@ public CohortIndicator chikungunyaCases() { * @return indicator */ public CohortIndicator poliomyelitisCases() { - return cohortIndicator("HIV Positive tests", map(idsrCohortLibrary.poliomyelitisCases(), "startDate=${startDate},endDate=${endDate}")); + return cohortIndicator("Acute Flaccid Paralysis", map(idsrCohortLibrary.poliomyelitisCases(), "startDate=${startDate},endDate=${endDate}")); } /** @@ -101,7 +101,7 @@ public CohortIndicator poliomyelitisCases() { * @return indicator */ public CohortIndicator viralHaemorrhagicFeverCases() { - return cohortIndicator("HIV Negative tests", map(idsrCohortLibrary.viralHaemorrhagicFeverCases(), "startDate=${startDate},endDate=${endDate}")); + return cohortIndicator("Acute Haemorrhagic Fever", map(idsrCohortLibrary.viralHaemorrhagicFeverCases(), "startDate=${startDate},endDate=${endDate}")); } /** @@ -112,4 +112,53 @@ public CohortIndicator measlesCases() { return cohortIndicator("Measles cases", map(idsrCohortLibrary.measlesCases(), "startDate=${startDate},endDate=${endDate}")); } + /** + * Monkey Pox Cases + * @return indicator + */ + public CohortIndicator monkeyPoxCases() { + return cohortIndicator("Monkey Pox", map(idsrCohortLibrary.monkeyPoxCases(), "startDate=${startDate},endDate=${endDate}")); + } + /** + * Jaundice case + * @return indicator + */ + public CohortIndicator jaundiceCases() { + return cohortIndicator("Acute Jaundice", map(idsrCohortLibrary.jaundiceCases(), "startDate=${startDate},endDate=${endDate}")); + } + /** + * Neurological Syndrome + * @return + */ + public CohortIndicator neurologicalSyndromeCases() { + return cohortIndicator("Neurological Syndrome", map(idsrCohortLibrary.neurologicalSyndrome(), "startDate=${startDate},endDate=${endDate}")); + } + /** + * Acute Watery Diarrhoea + * @return + */ + public CohortIndicator acuteWateryDiarrhoeaCases() { + return cohortIndicator("Acute Watery Diarrhoea", map(idsrCohortLibrary.acuteWateryDiarrhoea(), "startDate=${startDate},endDate=${endDate}")); + } + /** + * Acute Febrile Rash infections + * @return + */ + public CohortIndicator acuteFebrileRashCases() { + return cohortIndicator("Acute Febrile Rash Infections", map(idsrCohortLibrary.acuteFebrileRashInfections(), "startDate=${startDate},endDate=${endDate}")); + } + /** + * Acute Febrile illness + * @return + */ + public CohortIndicator acuteFebrileIllnessCases() { + return cohortIndicator("Acute Febrile Illness", map(idsrCohortLibrary.acuteFebrileIllness(), "startDate=${startDate},endDate=${endDate}")); + } + + /** + * Acute Meningitis and Encephalitis + */ + public CohortIndicator acuteMeningitisCases() { + return cohortIndicator("Acute Meningitis and Encephalitis", map(idsrCohortLibrary.acuteMeningitisAndEncephalitis(), "startDate=${startDate},endDate=${endDate}")); + } } \ No newline at end of file diff --git a/api/src/main/resources/content/kenyaemr.common.xml b/api/src/main/resources/content/kenyaemr.common.xml index 0618a12c9..b3cf15303 100644 --- a/api/src/main/resources/content/kenyaemr.common.xml +++ b/api/src/main/resources/content/kenyaemr.common.xml @@ -988,7 +988,8 @@ - + diff --git a/omod/src/main/webapp/resources/reports/dmi/idsr.xls b/omod/src/main/webapp/resources/reports/dmi/idsr.xls index 40dba2e40a1182dbde11021c779eff9bea5caed2..7e8f647ecbb9e40e32cbf92096bc333b5b4501dc 100644 GIT binary patch literal 35840 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 a{lx!*SN^#;ovHm9Q=N-)eI36_`Tq~6O&x6j literal 33280 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 Date: Mon, 14 Oct 2024 14:12:12 +0300 Subject: [PATCH 5/8] Deleted EligibleForIDSRFlagsCalculation file --- .../EligibleForIDSRFlagsCalculation.java | 758 ------------------ 1 file changed, 758 deletions(-) delete mode 100644 api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/surveillance/EligibleForIDSRFlagsCalculation.java diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/surveillance/EligibleForIDSRFlagsCalculation.java b/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/surveillance/EligibleForIDSRFlagsCalculation.java deleted file mode 100644 index c18a90969..000000000 --- a/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/surveillance/EligibleForIDSRFlagsCalculation.java +++ /dev/null @@ -1,758 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.kenyaemr.calculation.library.surveillance; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.joda.time.DateTime; -import org.joda.time.Days; -import org.openmrs.*; -import org.openmrs.api.ConceptService; -import org.openmrs.api.PatientService; -import org.openmrs.api.context.Context; -import org.openmrs.calculation.patient.PatientCalculationContext; -import org.openmrs.calculation.result.CalculationResultMap; -import org.openmrs.module.kenyacore.calculation.*; -import org.openmrs.module.kenyaemr.calculation.EmrCalculationUtils; -import org.openmrs.module.kenyaemr.metadata.CommonMetadata; -import org.openmrs.module.kenyaemr.metadata.HivMetadata; -import org.openmrs.module.kenyaemr.util.EmrUtils; -import org.openmrs.module.metadatadeploy.MetadataUtils; - -import java.text.SimpleDateFormat; -import java.util.*; - -/** - * Calculates the eligibility for ILI screening flag for patients - * - * @should calculate Active visit - * @should calculate cough for <= 10 days - * @should calculate fever for <= 10 days - * @should calculate temperature for >= 38.0 same day - * @should calculate duration < 10 days - *

- * SARI - * * @should calculate admitted - */ -public class EligibleForIDSRFlagsCalculation extends AbstractPatientCalculation { - protected static final Log log = LogFactory.getLog(EligibleForIDSRFlagsCalculation.class); - - List idsrMessage = new ArrayList(); - String idsrMessageString = ""; - - public static final EncounterType triageEncType = MetadataUtils.existing(EncounterType.class, CommonMetadata._EncounterType.TRIAGE); - public static final Form triageScreeningForm = MetadataUtils.existing(Form.class, CommonMetadata._Form.TRIAGE); - public static final EncounterType consultationEncType = MetadataUtils.existing(EncounterType.class, CommonMetadata._EncounterType.CONSULTATION); - public static final Form clinicalEncounterForm = MetadataUtils.existing(Form.class, CommonMetadata._Form.CLINICAL_ENCOUNTER); - public static final EncounterType greenCardEncType = MetadataUtils.existing(EncounterType.class, HivMetadata._EncounterType.HIV_CONSULTATION); - public static final Form greenCardForm = MetadataUtils.existing(Form.class, HivMetadata._Form.HIV_GREEN_CARD); - - String SCREENING_QUESTION = "5219AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - - String FEVER = "140238AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - String COUGH_PRESENCE = "143264AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - String DURATION = "159368AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - - String TEMPERATURE = "5088AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - String PATIENT_OUTCOME = "160433AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - String INPATIENT_ADMISSION = "1654AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - //Chikungunya - String JOINT_PAIN = "116558AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - //Cholera - String VOMITING = "122983AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - String WATERY_DIARRHEA = "161887AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - //Dysentry - String BLOOD_IN_STOOL = "117671AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - String DIARRHEA = "142412AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - //Viral Haemorrhagic Fever - String BLEEDING_TENDENCIES = "162628AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - //MALARIA - String HEADACHE = "139084AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - String CHILLS = "871AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - //Measles - String RASH = "512AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - String CORYZA = "106AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - String CONJUCTIVITIS = "127777AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - //Rift Valley Fever - String JAUNDICE = "136443AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - String DIZZINESS = "141830AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - String MALAISE = "135367AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - String SCREENING_QUESTION_EXAMINATION = "162737AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - //Polio - String LIMBS_WEAKNESS = "157498AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - String ONSET_QUESTION = "d7a3441d-6aeb-49be-b7d6-b2a3bb39e78d"; - String SUDDEN_ONSET = "162707AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - - /** - * Evaluates the calculation - */ - - @Override - public CalculationResultMap evaluate(Collection cohort, Map parameterValues, PatientCalculationContext context) { - - Set alive = Filters.alive(cohort, context); - PatientService patientService = Context.getPatientService(); - CalculationResultMap ret = new CalculationResultMap(); - - for (Integer ptId : alive) { - boolean eligible = false; - List activeVisits = Context.getVisitService().getActiveVisitsByPatient(patientService.getPatient(ptId)); - if (!activeVisits.isEmpty()) { - Date currentDate = new Date(); - Double tempValue = 0.0; - Double duration = 0.0; - Date dateCreated = null; - String onsetStatus = null; - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - String todayDate = dateFormat.format(currentDate); - Patient patient = patientService.getPatient(ptId); - - Encounter lastTriageEncounter = EmrUtils.lastEncounter(patient, triageEncType, triageScreeningForm); - Encounter lastHivFollowUpEncounter = EmrUtils.lastEncounter(patient, greenCardEncType, greenCardForm); //last greencard followup form - Encounter lastClinicalEncounter = EmrUtils.lastEncounter(patient, consultationEncType, clinicalEncounterForm); //last clinical encounter form - - ConceptService cs = Context.getConceptService(); - Concept screeningQuestion = cs.getConceptByUuid(SCREENING_QUESTION); - Concept screeningQuestionExam = cs.getConceptByUuid(SCREENING_QUESTION_EXAMINATION); - - Concept measureFeverResult = cs.getConceptByUuid(FEVER); - Concept coughPresenceResult = cs.getConceptByUuid(COUGH_PRESENCE); - Concept adminQuestion = cs.getConceptByUuid(PATIENT_OUTCOME); - Concept admissionAnswer = cs.getConceptByUuid(INPATIENT_ADMISSION); - Concept jointPainResult = cs.getConceptByUuid(JOINT_PAIN); - Concept vomitingResult = cs.getConceptByUuid(VOMITING); - Concept wateryDiarrheaResult = cs.getConceptByUuid(WATERY_DIARRHEA); - Concept bloodyStoolResult = cs.getConceptByUuid(BLOOD_IN_STOOL); - Concept diarrheaResult = cs.getConceptByUuid(DIARRHEA); - Concept bleedingResult = cs.getConceptByUuid(BLEEDING_TENDENCIES); - Concept headacheResult = cs.getConceptByUuid(HEADACHE); - Concept chillsResult = cs.getConceptByUuid(CHILLS); - Concept rashResult = cs.getConceptByUuid(RASH); - Concept coryzaResult = cs.getConceptByUuid(CORYZA); - Concept conjunctivitisResult = cs.getConceptByUuid(CONJUCTIVITIS); - Concept jaundiceResult = cs.getConceptByUuid(JAUNDICE); - Concept dizzinessResult = cs.getConceptByUuid(DIZZINESS); - Concept malaiseResult = cs.getConceptByUuid(MALAISE); - Concept limbsWeaknessResult = cs.getConceptByUuid(LIMBS_WEAKNESS); - //Conditions - String chikungunya = "Chikungunya"; - String ili = "ILI"; - String sari = "SARI"; - String cholera = "Cholera"; - String dysentry = "Dysentery"; - String haemorrhagic_fever = "Haemorrhagic Fever"; - String malaria = "Malaria"; - String measles = "Measles"; - String rift_valley_fever = "Rift Valley Fever"; - String poliomyelitis = "Poliomyelitis"; - //Temperature - CalculationResultMap tempMap = Calculations.lastObs(cs.getConceptByUuid(TEMPERATURE), cohort, context); - //Fever - boolean triageEncounterHasFever = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, measureFeverResult) : false; - boolean hivFollowupEncounterHasFever = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, measureFeverResult) : false; - boolean clinicalEncounterHasFever = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, measureFeverResult) : false; - //Cough - boolean triageEncounterHasCough = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, coughPresenceResult) : false; - boolean hivFollowupEncounterHasCough = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, coughPresenceResult) : false; - boolean clinicalEncounterHasCough = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, coughPresenceResult) : false; - //Joint Pains - boolean triageEncounterHasJointPain = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, jointPainResult) : false; - boolean hivFollowupEncounterHasJointPain = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, jointPainResult) : false; - boolean clinicalEncounterHasJointPain = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, jointPainResult) : false; - // Vomiting - boolean triageEncounterHasVomit = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, vomitingResult) : false; - boolean hivFollowupEncounterHasVomit = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, vomitingResult) : false; - boolean clinicalEncounterHasVomit = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, vomitingResult) : false; - //Watery diarrhea - boolean triageEncounterHasWateryDiarrhea = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, wateryDiarrheaResult) : false; - boolean hivFollowupEncounterHasWateryDiarrhea = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, wateryDiarrheaResult) : false; - boolean clinicalEncounterHasWateryDiarrhea = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, wateryDiarrheaResult) : false; - //Diarrhea - boolean triageEncounterHasDiarrhea = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, diarrheaResult) : false; - boolean hivFollowupEncounterHasDiarrhea = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, diarrheaResult) : false; - boolean clinicalEncounterHasDiarrhea = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, diarrheaResult) : false; - //Blood in stool - boolean triageEncounterHasBloodyStool = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, bloodyStoolResult) : false; - boolean hivFollowupEncounterHasBloodyStool = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, bloodyStoolResult) : false; - boolean clinicalEncounterHasBloodyStool = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, bloodyStoolResult) : false; - //Bleeding tendencies - boolean triageEncounterHasBleeding = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, bleedingResult) : false; - boolean hivFollowupEncounterHasBleeding = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, bleedingResult) : false; - boolean clinicalEncounterHasBleeding = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, bleedingResult) : false; - //Headache - boolean triageEncounterHasHeadache = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, headacheResult) : false; - boolean hivFollowupEncounterHasHeadache = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, headacheResult) : false; - boolean clinicalEncounterHasHeadache = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, headacheResult) : false; - //Chills - boolean triageEncounterHasChills= lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, chillsResult) : false; - boolean hivFollowupEncounterHasChills = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, chillsResult) : false; - boolean clinicalEncounterHasChills = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, chillsResult) : false; - //Rash - boolean triageEncounterHasRash = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, rashResult) : false; - boolean hivFollowupEncounterHasRash = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, rashResult) : false; - boolean clinicalEncounterHasRash = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, rashResult) : false; - //Coryza - boolean triageEncounterHasCoryza = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, coryzaResult) : false; - boolean hivFollowupEncounterHasCoryza = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, coryzaResult) : false; - boolean clinicalEncounterHasCoryza = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, coryzaResult) : false; - //Conjunctivitis - boolean triageEncounterHasConjunctivitis = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, conjunctivitisResult) : false; - boolean hivFollowupEncounterHasConjunctivitis = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, conjunctivitisResult) : false; - boolean clinicalEncounterHasConjunctivitis = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, conjunctivitisResult) : false; - //Jaundice - boolean triageEncounterHasJaundice = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestionExam, jaundiceResult) : false; - boolean hivFollowupEncounterHasJaundice = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestionExam, jaundiceResult) : false; - boolean clinicalEncounterHasJaundice = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestionExam, jaundiceResult) : false; - //Dizziness - boolean triageEncounterHasDizziness = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, dizzinessResult) : false; - boolean hivFollowupEncounterHasDizziness = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, dizzinessResult) : false; - boolean clinicalEncounterHasDizziness = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, dizzinessResult) : false; - //Malaise - boolean triageEncounterHasMalaise = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, malaiseResult) : false; - boolean hivFollowupEncounterHasMalaise = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, malaiseResult) : false; - boolean clinicalEncounterHasMalaise = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, malaiseResult) : false; - //Weakness of limbs - boolean triageEncounterHasWeakLimbs = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, limbsWeaknessResult) : false; - boolean hivFollowupEncounterHasWeakLimbs = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, limbsWeaknessResult) : false; - boolean clinicalEncounterHasWeakLimbs = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, limbsWeaknessResult) : false; - - //Check admission status : Found in clinical encounter and type of visit - boolean patientAdmissionStatus = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, adminQuestion, admissionAnswer) : false; - //Visit type is inpatient - Visit currentVisit = activeVisits.get(0); - Obs lastTempObs = EmrCalculationUtils.obsResultForPatient(tempMap, ptId); - if (lastTempObs != null) { - tempValue = lastTempObs.getValueNumeric(); - } - //Triage - if (lastTriageEncounter != null) { - //1. SARI and ILI - if (triageEncounterHasFever && triageEncounterHasCough) { - for (Obs obs : lastTriageEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(DURATION)) { - duration = obs.getValueNumeric(); - } - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if ((duration > 0.0 && duration < 10) && tempValue != null && tempValue >= 38.0) { - if (createdDate.equals(todayDate)) { - if (!patientAdmissionStatus && !currentVisit.getVisitType().getUuid().equals("a73e2ac6-263b-47fc-99fc-e0f2c09fc914")) { - eligible = true; - idsrMessage.add(ili); - break; - } else { - eligible = true; - idsrMessage.add(sari); - break; - } - } - } - } - } - } - //2. CHIKUNGUNYA - if (triageEncounterHasJointPain && triageEncounterHasFever) { - for (Obs obs : lastTriageEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(DURATION)) { - duration = obs.getValueNumeric(); - } - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if (duration > 2 && tempValue != null && tempValue > 38.5) { - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(chikungunya); - break; - } - } - } - } - } - //3. CHOLERA - if (triageEncounterHasVomit && triageEncounterHasWateryDiarrhea) { - if (patient.getAge() > 2) { - for (Obs obs : lastTriageEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(cholera); - break; - } - } - } - } - } - //4.Dysentry - if (triageEncounterHasBloodyStool && triageEncounterHasDiarrhea) { - for (Obs obs : lastTriageEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(dysentry); - break; - } - } - } - } - //5. Viral Haemorrhagic fever - if (triageEncounterHasFever && triageEncounterHasBleeding) { - for (Obs obs : lastTriageEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(haemorrhagic_fever); - break; - } - } - } - } - //6. Malaria - if (triageEncounterHasHeadache && triageEncounterHasChills && triageEncounterHasFever) { - for (Obs obs : lastTriageEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(DURATION)) { - duration = obs.getValueNumeric(); - } - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if (duration > 1 && tempValue != null && tempValue >= 37.5) { - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(malaria); - break; - } - } - } - } - } - //7.Measles - if (triageEncounterHasFever && triageEncounterHasRash && triageEncounterHasCoryza && triageEncounterHasCough && triageEncounterHasConjunctivitis) { - for (Obs obs : lastTriageEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(DURATION)) { - duration = obs.getValueNumeric(); - } - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if (duration > 2) { - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(measles); - break; - } - } - } - } - } - - //8.Rift Valley Fever - if (triageEncounterHasJaundice && triageEncounterHasDizziness && triageEncounterHasMalaise && triageEncounterHasFever) { - for (Obs obs : lastTriageEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(DURATION)) { - duration = obs.getValueNumeric(); - } - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if (duration > 2 && tempValue != null && tempValue > 37.5) { - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(rift_valley_fever); - break; - } - } - } - } - } - //9.Poliomyelitis - if (triageEncounterHasWeakLimbs) { - if (patient.getAge() < 15) { - for (Obs obs : lastTriageEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(ONSET_QUESTION)) { - onsetStatus = obs.getValueCoded().getUuid(); - } - if (dateCreated != null && onsetStatus != null) { - String createdDate = dateFormat.format(dateCreated); - if (createdDate.equals(todayDate) && onsetStatus.equals(SUDDEN_ONSET)) { - eligible = true; - idsrMessage.add(poliomyelitis); - break; - } - } - } - } - - } - } - - //Hiv followup encounter - if (lastHivFollowUpEncounter != null) { - //1. SARI and ILI - if (hivFollowupEncounterHasFever && hivFollowupEncounterHasCough) { - for (Obs obs : lastHivFollowUpEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(DURATION)) { - duration = obs.getValueNumeric(); - } - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if ((duration > 0.0 && duration < 10) && tempValue != null && tempValue >= 38.0) { - if (createdDate.equals(todayDate)) { - if (!patientAdmissionStatus && !currentVisit.getVisitType().getUuid().equals("a73e2ac6-263b-47fc-99fc-e0f2c09fc914")) { - eligible = true; - idsrMessage.add(ili); - break; - } else { - eligible = true; - idsrMessage.add(sari); - break; - } - } - } - } - } - } - //2. CHIKUNGUNYA - if (hivFollowupEncounterHasJointPain && hivFollowupEncounterHasFever) { - for (Obs obs : lastHivFollowUpEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(DURATION)) { - duration = obs.getValueNumeric(); - } - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if (duration > 2 && tempValue != null && tempValue > 38.5) { - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(chikungunya); - break; - } - } - } - } - } - //3. CHOLERA - if (hivFollowupEncounterHasVomit && hivFollowupEncounterHasWateryDiarrhea) { - if (patient.getAge() > 2) { - for (Obs obs : lastHivFollowUpEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(cholera); - break; - } - } break; - } - } - } - - //4.Dysentry - if (hivFollowupEncounterHasBloodyStool && hivFollowupEncounterHasDiarrhea) { - for (Obs obs : lastHivFollowUpEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(dysentry); - break; - } - } - } - } - //5. Viral Haemorrhagic fever - if (hivFollowupEncounterHasFever && hivFollowupEncounterHasBleeding) { - for (Obs obs : lastHivFollowUpEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(haemorrhagic_fever); - break; - } - } - } - } - //6. Malaria - if (hivFollowupEncounterHasHeadache && hivFollowupEncounterHasChills && hivFollowupEncounterHasFever) { - for (Obs obs : lastHivFollowUpEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(DURATION)) { - duration = obs.getValueNumeric(); - } - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if (duration > 1 && tempValue != null && tempValue >= 37.5) { - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(malaria); - break; - } - } - } - } - } - //7.Measles - if (hivFollowupEncounterHasFever && hivFollowupEncounterHasRash && hivFollowupEncounterHasCoryza && hivFollowupEncounterHasCough && hivFollowupEncounterHasConjunctivitis) { - for (Obs obs : lastHivFollowUpEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(DURATION)) { - duration = obs.getValueNumeric(); - } - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if (duration > 2) { - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(measles); - break; - } - } - } - } - } - //8.Rift Valley Fever - if (hivFollowupEncounterHasJaundice && hivFollowupEncounterHasDizziness && hivFollowupEncounterHasFever && hivFollowupEncounterHasMalaise) { - for (Obs obs : lastHivFollowUpEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(DURATION)) { - duration = obs.getValueNumeric(); - } - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if (duration > 2 && tempValue != null && tempValue > 37.5) { - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(rift_valley_fever); - break; - } - } - } - } - } - //9.Poliomyelitis - if (hivFollowupEncounterHasWeakLimbs) { - if (patient.getAge() < 15) { - for (Obs obs : lastHivFollowUpEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(ONSET_QUESTION)) { - onsetStatus = obs.getValueCoded().getUuid(); - } - if (dateCreated != null && onsetStatus != null) { - String createdDate = dateFormat.format(dateCreated); - if (createdDate.equals(todayDate) && onsetStatus.equals(SUDDEN_ONSET)) { - eligible = true; - idsrMessage.add(poliomyelitis); - break; - } - } - } - - } - } - - } - //Clinical Encounter - if (lastClinicalEncounter != null) { - //1. SARI and ILI - if (clinicalEncounterHasFever && clinicalEncounterHasCough) { - for (Obs obs : lastClinicalEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(DURATION)) { - duration = obs.getValueNumeric(); - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if ((duration > 0.0 && duration < 10) && tempValue != null && tempValue >= 38.0) { - if (createdDate.equals(todayDate)) { - if (!patientAdmissionStatus && !currentVisit.getVisitType().getUuid().equals("a73e2ac6-263b-47fc-99fc-e0f2c09fc914")) { - eligible = true; - idsrMessage.add(ili); - break; - } else { - eligible = true; - idsrMessage.add(sari); - break; - } - } - } - } - } - } - } - //2. CHIKUNGUNYA - if (clinicalEncounterHasJointPain && clinicalEncounterHasFever) { - for (Obs obs : lastClinicalEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(DURATION)) { - duration = obs.getValueNumeric(); - } - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if (duration > 2 && tempValue != null && tempValue > 38.5) { - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(chikungunya); - break; - } - } - } - } - } - //3. CHOLERA - if (clinicalEncounterHasVomit && clinicalEncounterHasWateryDiarrhea) { - if (patient.getAge() > 2) { - for (Obs obs : lastClinicalEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(cholera); - break; - } - } - } - - } - } - //4.DYSENTRY - if (clinicalEncounterHasDiarrhea && clinicalEncounterHasBloodyStool) { - for (Obs obs : lastClinicalEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(dysentry); - break; - } - } - } - } - //5. Viral Haemorrhagic fever - if (clinicalEncounterHasFever && clinicalEncounterHasBleeding) { - for (Obs obs : lastClinicalEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(haemorrhagic_fever); - break; - } - } - } - } - //6. Malaria - if (clinicalEncounterHasHeadache && clinicalEncounterHasChills && clinicalEncounterHasFever) { - for (Obs obs : lastClinicalEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(DURATION)) { - duration = obs.getValueNumeric(); - } - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if (duration > 1 && tempValue != null && tempValue >= 37.5) { - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(malaria); - break; - } - } - } - } - } - //7.Measles - if (clinicalEncounterHasFever && clinicalEncounterHasRash && clinicalEncounterHasCoryza && clinicalEncounterHasCough && clinicalEncounterHasConjunctivitis) { - for (Obs obs : lastClinicalEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(DURATION)) { - duration = obs.getValueNumeric(); - } - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if (duration > 2) { - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(measles); - break; - } - } - } - } - } - //8.Rift Valley Fever - if (clinicalEncounterHasJaundice && clinicalEncounterHasDizziness && clinicalEncounterHasFever && clinicalEncounterHasMalaise) { - for (Obs obs : lastClinicalEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(DURATION)) { - duration = obs.getValueNumeric(); - } - if (dateCreated != null) { - String createdDate = dateFormat.format(dateCreated); - if (duration > 2 && tempValue != null && tempValue > 37.5) { - if (createdDate.equals(todayDate)) { - eligible = true; - idsrMessage.add(rift_valley_fever); - break; - } - } - } - } - } - //9.Poliomyelitis - if (clinicalEncounterHasWeakLimbs) { - if (patient.getAge() < 15) { - for (Obs obs : lastClinicalEncounter.getObs()) { - dateCreated = obs.getDateCreated(); - if (obs.getConcept().getUuid().equals(ONSET_QUESTION)) { - onsetStatus = obs.getValueCoded().getUuid(); - } - if (dateCreated != null && onsetStatus != null) { - String createdDate = dateFormat.format(dateCreated); - if (createdDate.equals(todayDate) && onsetStatus.equals(SUDDEN_ONSET)) { - eligible = true; - idsrMessage.add(poliomyelitis); - break; - } - } - } - } - } - } - } - if (idsrMessage.size() > 0) { - idsrMessageString = StringUtils.join(idsrMessage, ","); - - } - ret.put(ptId, new BooleanResult(eligible, this)); - } - return ret; - } - -// @Override -// public String getFlagMessage() { -// return "Suspected "+ idsrMessageString; -// -// } -} From 79468c2c9e9591667e97bd4ac0539eeb1df10735 Mon Sep 17 00:00:00 2001 From: gabu90 Date: Mon, 14 Oct 2024 14:32:53 +0300 Subject: [PATCH 6/8] removed the commented part EligibleForIDSRFlagsCalculation in KEnyaemrCoreRestController --- .../kenyaemr/web/controller/KenyaemrCoreRestController.java | 1 - 1 file changed, 1 deletion(-) diff --git a/omod/src/main/java/org/openmrs/module/kenyaemr/web/controller/KenyaemrCoreRestController.java b/omod/src/main/java/org/openmrs/module/kenyaemr/web/controller/KenyaemrCoreRestController.java index 988abdec2..6432153f9 100644 --- a/omod/src/main/java/org/openmrs/module/kenyaemr/web/controller/KenyaemrCoreRestController.java +++ b/omod/src/main/java/org/openmrs/module/kenyaemr/web/controller/KenyaemrCoreRestController.java @@ -305,7 +305,6 @@ public Object getAllPatientFlags(HttpServletRequest request, @RequestParam("pati CacheManager cacheManager = Context.getRegisteredComponent("apiCacheManager", CacheManager.class); Cache patientFlagCache = cacheManager.getCache("patientFlagCache"); List patientFlagsToRefreshOnEveryRequest = Arrays.asList( - // "EligibleForIDSRFlagsCalculation" "EligibleForIDSRSymptomsFlagsCalculation" ); calculationManager.refresh(); From a69311e99b70a16f27669384adbc8734b4de892d Mon Sep 17 00:00:00 2001 From: gabu90 Date: Tue, 15 Oct 2024 10:05:08 +0300 Subject: [PATCH 7/8] Modification on the global property in EligibleForIDRS symptoms --- ...igibleForIDSRSymptomsFlagsCalculation.java | 386 +++++++++--------- 1 file changed, 192 insertions(+), 194 deletions(-) diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/surveillance/EligibleForIDSRSymptomsFlagsCalculation.java b/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/surveillance/EligibleForIDSRSymptomsFlagsCalculation.java index e9d67bd38..3dffaad73 100644 --- a/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/surveillance/EligibleForIDSRSymptomsFlagsCalculation.java +++ b/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/surveillance/EligibleForIDSRSymptomsFlagsCalculation.java @@ -121,197 +121,198 @@ public class EligibleForIDSRSymptomsFlagsCalculation extends AbstractPatientCalc @Override public CalculationResultMap evaluate(Collection cohort, Map parameterValues, PatientCalculationContext context) { - Set alive = Filters.alive(cohort, context); - PatientService patientService = Context.getPatientService(); CalculationResultMap ret = new CalculationResultMap(); - - for (Integer ptId : alive) { - boolean eligible = false; - List activeVisits = Context.getVisitService().getActiveVisitsByPatient(patientService.getPatient(ptId)); - if (!activeVisits.isEmpty()) { - Date currentDate = new Date(); - Double tempValue = 0.0; - Double duration = 0.0; - Double motions = 0.0; - Date dateCreated = null; - String onsetStatus = null; - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - String todayDate = dateFormat.format(currentDate); - Patient patient = patientService.getPatient(ptId); - - Encounter lastTriageEncounter = EmrUtils.lastEncounter(patient, triageEncType, triageScreeningForm); - Encounter lastHivFollowUpEncounter = EmrUtils.lastEncounter(patient, greenCardEncType, greenCardForm); //last greencard followup form - Encounter lastClinicalEncounter = EmrUtils.lastEncounter(patient, consultationEncType, clinicalEncounterForm); //last clinical encounter form - - ConceptService cs = Context.getConceptService(); - Concept screeningQuestion = cs.getConceptByUuid(SCREENING_QUESTION); - Concept screeningQuestionExam = cs.getConceptByUuid(SCREENING_QUESTION_EXAMINATION); - Concept typeOfServiceProvided = cs.getConceptByUuid(TYPE_OF_SERVICE_PROVIDED); - - Concept measureFeverResult = cs.getConceptByUuid(FEVER); - Concept coughPresenceResult = cs.getConceptByUuid(COUGH_PRESENCE); - Concept adminQuestion = cs.getConceptByUuid(PATIENT_OUTCOME); - Concept admissionAnswer = cs.getConceptByUuid(INPATIENT_ADMISSION); - Concept jointPainResult = cs.getConceptByUuid(JOINT_PAIN); - Concept vomitingResult = cs.getConceptByUuid(VOMITING); - Concept wateryDiarrheaResult = cs.getConceptByUuid(WATERY_DIARRHEA); - Concept bloodyStoolResult = cs.getConceptByUuid(BLOOD_IN_STOOL); - Concept diarrheaResult = cs.getConceptByUuid(DIARRHEA); - Concept bleedingResult = cs.getConceptByUuid(BLEEDING_TENDENCIES); - Concept headacheResult = cs.getConceptByUuid(HEADACHE); - Concept chillsResult = cs.getConceptByUuid(CHILLS); - Concept rashResult = cs.getConceptByUuid(RASH); - Concept coryzaResult = cs.getConceptByUuid(CORYZA); - Concept conjunctivitisResult = cs.getConceptByUuid(CONJUCTIVITIS); - Concept jaundiceResult = cs.getConceptByUuid(JAUNDICE); - Concept dizzinessResult = cs.getConceptByUuid(DIZZINESS); - Concept malaiseResult = cs.getConceptByUuid(MALAISE); - Concept limbsWeaknessResult = cs.getConceptByUuid(LIMBS_WEAKNESS); - Concept meningitisResult = cs.getConceptByUuid(SUDDEN_ONSET); - Concept acuteFebrileRashInfectionResult = cs.getConceptByUuid(RASH); - Concept refusalToFeedResult = cs.getConceptByUuid(REFUSAL_TO_FEED); - Concept convulsionsResult = cs.getConceptByUuid(CONVULSIONS); - Concept lymphadenopathyResult = cs.getConceptByUuid(LYMPHADENOPATHY); - Concept myalgiaResult = cs.getConceptByUuid(MYALGIA); - Concept backpainResult = cs.getConceptByUuid(BACKPAIN); - Concept neckStiffnessResult = cs.getConceptByUuid(NECK_STIFFNESS); - //Conditions - String ili = "ILI"; - String sari = "SARI"; - String haemorrhagic_fever = "Acute Haemorrhagic Fever"; - String poliomyelitis = "Acute Flaccid Paralysis"; - // up to here - String jaundice = "Acute Jaundice"; - String meningitis = "Acute Meningitis and Encephalitis"; - String acute_febrile_rash_infection = "Acute Febrile Rash Infection"; - String acute_watery_diarrhoeal = "Acute Watery Diarrhoeal"; - String neurological_syndrome = "Neurological Syndrome"; - String acute_febrile_illness = "Acute Febrile Illness"; - String mpox = "Mpox"; - //Temperature - CalculationResultMap tempMap = Calculations.lastObs(cs.getConceptByUuid(TEMPERATURE), cohort, context); - //Fever - boolean triageEncounterHasFever = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, measureFeverResult) : false; - boolean hivFollowupEncounterHasFever = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, measureFeverResult) : false; - boolean clinicalEncounterHasFever = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, measureFeverResult) : false; - //Cough - boolean triageEncounterHasCough = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, coughPresenceResult) : false; - boolean hivFollowupEncounterHasCough = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, coughPresenceResult) : false; - boolean clinicalEncounterHasCough = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, coughPresenceResult) : false; - //Joint Pains - boolean triageEncounterHasJointPain = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, jointPainResult) : false; - boolean hivFollowupEncounterHasJointPain = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, jointPainResult) : false; - boolean clinicalEncounterHasJointPain = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, jointPainResult) : false; - // Vomiting - boolean triageEncounterHasVomit = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, vomitingResult) : false; - boolean hivFollowupEncounterHasVomit = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, vomitingResult) : false; - boolean clinicalEncounterHasVomit = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, vomitingResult) : false; - //Watery diarrhea - boolean triageEncounterHasWateryDiarrhea = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, wateryDiarrheaResult) : false; - boolean hivFollowupEncounterHasWateryDiarrhea = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, wateryDiarrheaResult) : false; - boolean clinicalEncounterHasWateryDiarrhea = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, wateryDiarrheaResult) : false; - //Diarrhea - boolean triageEncounterHasDiarrhea = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, diarrheaResult) : false; - boolean hivFollowupEncounterHasDiarrhea = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, diarrheaResult) : false; - boolean clinicalEncounterHasDiarrhea = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, diarrheaResult) : false; - - //neckStiffnessResult - boolean triageEncounterHasNeckStiffness = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, neckStiffnessResult) : false; - boolean hivFollowupEncounterHasNeckStiffness = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, neckStiffnessResult) : false; - boolean clinicalEncounterHasNeckStiffness = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, neckStiffnessResult) : false; - - //Blood in stool - boolean triageEncounterHasBloodyStool = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, bloodyStoolResult) : false; - boolean hivFollowupEncounterHasBloodyStool = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, bloodyStoolResult) : false; - boolean clinicalEncounterHasBloodyStool = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, bloodyStoolResult) : false; - //Bleeding tendencies - boolean triageEncounterHasBleeding = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, bleedingResult) : false; - boolean hivFollowupEncounterHasBleeding = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, bleedingResult) : false; - boolean clinicalEncounterHasBleeding = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, bleedingResult) : false; - //Headache - boolean triageEncounterHasHeadache = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, headacheResult) : false; - boolean hivFollowupEncounterHasHeadache = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, headacheResult) : false; - boolean clinicalEncounterHasHeadache = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, headacheResult) : false; - //Chills - boolean triageEncounterHasChills = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, chillsResult) : false; - boolean hivFollowupEncounterHasChills = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, chillsResult) : false; - boolean clinicalEncounterHasChills = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, chillsResult) : false; - //Rash - boolean triageEncounterHasRash = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, rashResult) : false; - boolean hivFollowupEncounterHasRash = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, rashResult) : false; - boolean clinicalEncounterHasRash = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, rashResult) : false; - - //Acute Febrile Rash Infection - boolean triageEncounterHasAcuteRashInfection = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, acuteFebrileRashInfectionResult) : false; - boolean hivFollowupEncounterHasAcuteRashInfection = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, acuteFebrileRashInfectionResult) : false; - boolean clinicalEncounterHasAcuteRashInfection = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, acuteFebrileRashInfectionResult) : false; - - //Refusal to feed - boolean triageEncounterHasRefusalToFeed = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, refusalToFeedResult) : false; - boolean hivFollowupEncounterHasRefusalToFeed = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, refusalToFeedResult) : false; - boolean clinicalEncounterHasRefusalToFeed = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, refusalToFeedResult) : false; - - //Convulsions - boolean triageEncounterHasConvulsions = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, convulsionsResult) : false; - boolean hivFollowupEncounterHasConvulsions = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, convulsionsResult) : false; - boolean clinicalEncounterHasConvulsions = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, convulsionsResult) : false; - - //Coryza - boolean triageEncounterHasCoryza = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, coryzaResult) : false; - boolean hivFollowupEncounterHasCoryza = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, coryzaResult) : false; - boolean clinicalEncounterHasCoryza = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, coryzaResult) : false; - //Conjunctivitis - boolean triageEncounterHasConjunctivitis = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, conjunctivitisResult) : false; - boolean hivFollowupEncounterHasConjunctivitis = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, conjunctivitisResult) : false; - boolean clinicalEncounterHasConjunctivitis = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, conjunctivitisResult) : false; - //Jaundice - boolean triageEncounterHasJaundice = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestionExam, jaundiceResult) : false; - boolean hivFollowupEncounterHasJaundice = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestionExam, jaundiceResult) : false; - boolean clinicalEncounterHasJaundice = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestionExam, jaundiceResult) : false; - //Dizziness - boolean triageEncounterHasDizziness = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, dizzinessResult) : false; - boolean hivFollowupEncounterHasDizziness = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, dizzinessResult) : false; - boolean clinicalEncounterHasDizziness = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, dizzinessResult) : false; - //Malaise - boolean triageEncounterHasMalaise = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, malaiseResult) : false; - boolean hivFollowupEncounterHasMalaise = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, malaiseResult) : false; - boolean clinicalEncounterHasMalaise = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, malaiseResult) : false; - //Weakness of limbs - boolean triageEncounterHasWeakLimbs = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, limbsWeaknessResult) : false; - boolean hivFollowupEncounterHasWeakLimbs = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, limbsWeaknessResult) : false; - boolean clinicalEncounterHasWeakLimbs = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, limbsWeaknessResult) : false; - - //Acute Meningitis and Encephalitis Syndrome + if (isDmi.equals("true")) { + Set alive = Filters.alive(cohort, context); + PatientService patientService = Context.getPatientService(); + + for (Integer ptId : alive) { + boolean eligible = false; + List activeVisits = Context.getVisitService().getActiveVisitsByPatient(patientService.getPatient(ptId)); + if (!activeVisits.isEmpty()) { + Date currentDate = new Date(); + Double tempValue = 0.0; + Double duration = 0.0; + Double motions = 0.0; + Date dateCreated = null; + String onsetStatus = null; + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + String todayDate = dateFormat.format(currentDate); + Patient patient = patientService.getPatient(ptId); + + Encounter lastTriageEncounter = EmrUtils.lastEncounter(patient, triageEncType, triageScreeningForm); + Encounter lastHivFollowUpEncounter = EmrUtils.lastEncounter(patient, greenCardEncType, greenCardForm); //last greencard followup form + Encounter lastClinicalEncounter = EmrUtils.lastEncounter(patient, consultationEncType, clinicalEncounterForm); //last clinical encounter form + + ConceptService cs = Context.getConceptService(); + Concept screeningQuestion = cs.getConceptByUuid(SCREENING_QUESTION); + Concept screeningQuestionExam = cs.getConceptByUuid(SCREENING_QUESTION_EXAMINATION); + Concept typeOfServiceProvided = cs.getConceptByUuid(TYPE_OF_SERVICE_PROVIDED); + + Concept measureFeverResult = cs.getConceptByUuid(FEVER); + Concept coughPresenceResult = cs.getConceptByUuid(COUGH_PRESENCE); + Concept adminQuestion = cs.getConceptByUuid(PATIENT_OUTCOME); + Concept admissionAnswer = cs.getConceptByUuid(INPATIENT_ADMISSION); + Concept jointPainResult = cs.getConceptByUuid(JOINT_PAIN); + Concept vomitingResult = cs.getConceptByUuid(VOMITING); + Concept wateryDiarrheaResult = cs.getConceptByUuid(WATERY_DIARRHEA); + Concept bloodyStoolResult = cs.getConceptByUuid(BLOOD_IN_STOOL); + Concept diarrheaResult = cs.getConceptByUuid(DIARRHEA); + Concept bleedingResult = cs.getConceptByUuid(BLEEDING_TENDENCIES); + Concept headacheResult = cs.getConceptByUuid(HEADACHE); + Concept chillsResult = cs.getConceptByUuid(CHILLS); + Concept rashResult = cs.getConceptByUuid(RASH); + Concept coryzaResult = cs.getConceptByUuid(CORYZA); + Concept conjunctivitisResult = cs.getConceptByUuid(CONJUCTIVITIS); + Concept jaundiceResult = cs.getConceptByUuid(JAUNDICE); + Concept dizzinessResult = cs.getConceptByUuid(DIZZINESS); + Concept malaiseResult = cs.getConceptByUuid(MALAISE); + Concept limbsWeaknessResult = cs.getConceptByUuid(LIMBS_WEAKNESS); + Concept meningitisResult = cs.getConceptByUuid(SUDDEN_ONSET); + Concept acuteFebrileRashInfectionResult = cs.getConceptByUuid(RASH); + Concept refusalToFeedResult = cs.getConceptByUuid(REFUSAL_TO_FEED); + Concept convulsionsResult = cs.getConceptByUuid(CONVULSIONS); + Concept lymphadenopathyResult = cs.getConceptByUuid(LYMPHADENOPATHY); + Concept myalgiaResult = cs.getConceptByUuid(MYALGIA); + Concept backpainResult = cs.getConceptByUuid(BACKPAIN); + Concept neckStiffnessResult = cs.getConceptByUuid(NECK_STIFFNESS); + //Conditions + String ili = "ILI"; + String sari = "SARI"; + String haemorrhagic_fever = "Acute Haemorrhagic Fever"; + String poliomyelitis = "Acute Flaccid Paralysis"; + // up to here + String jaundice = "Acute Jaundice"; + String meningitis = "Acute Meningitis and Encephalitis"; + String acute_febrile_rash_infection = "Acute Febrile Rash Infection"; + String acute_watery_diarrhoeal = "Acute Watery Diarrhoeal"; + String neurological_syndrome = "Neurological Syndrome"; + String acute_febrile_illness = "Acute Febrile Illness"; + String mpox = "Mpox"; + //Temperature + CalculationResultMap tempMap = Calculations.lastObs(cs.getConceptByUuid(TEMPERATURE), cohort, context); + //Fever + boolean triageEncounterHasFever = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, measureFeverResult) : false; + boolean hivFollowupEncounterHasFever = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, measureFeverResult) : false; + boolean clinicalEncounterHasFever = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, measureFeverResult) : false; + //Cough + boolean triageEncounterHasCough = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, coughPresenceResult) : false; + boolean hivFollowupEncounterHasCough = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, coughPresenceResult) : false; + boolean clinicalEncounterHasCough = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, coughPresenceResult) : false; + //Joint Pains + boolean triageEncounterHasJointPain = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, jointPainResult) : false; + boolean hivFollowupEncounterHasJointPain = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, jointPainResult) : false; + boolean clinicalEncounterHasJointPain = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, jointPainResult) : false; + // Vomiting + boolean triageEncounterHasVomit = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, vomitingResult) : false; + boolean hivFollowupEncounterHasVomit = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, vomitingResult) : false; + boolean clinicalEncounterHasVomit = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, vomitingResult) : false; + //Watery diarrhea + boolean triageEncounterHasWateryDiarrhea = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, wateryDiarrheaResult) : false; + boolean hivFollowupEncounterHasWateryDiarrhea = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, wateryDiarrheaResult) : false; + boolean clinicalEncounterHasWateryDiarrhea = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, wateryDiarrheaResult) : false; + //Diarrhea + boolean triageEncounterHasDiarrhea = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, diarrheaResult) : false; + boolean hivFollowupEncounterHasDiarrhea = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, diarrheaResult) : false; + boolean clinicalEncounterHasDiarrhea = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, diarrheaResult) : false; + + //neckStiffnessResult + boolean triageEncounterHasNeckStiffness = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, neckStiffnessResult) : false; + boolean hivFollowupEncounterHasNeckStiffness = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, neckStiffnessResult) : false; + boolean clinicalEncounterHasNeckStiffness = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, neckStiffnessResult) : false; + + //Blood in stool + boolean triageEncounterHasBloodyStool = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, bloodyStoolResult) : false; + boolean hivFollowupEncounterHasBloodyStool = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, bloodyStoolResult) : false; + boolean clinicalEncounterHasBloodyStool = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, bloodyStoolResult) : false; + //Bleeding tendencies + boolean triageEncounterHasBleeding = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, bleedingResult) : false; + boolean hivFollowupEncounterHasBleeding = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, bleedingResult) : false; + boolean clinicalEncounterHasBleeding = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, bleedingResult) : false; + //Headache + boolean triageEncounterHasHeadache = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, headacheResult) : false; + boolean hivFollowupEncounterHasHeadache = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, headacheResult) : false; + boolean clinicalEncounterHasHeadache = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, headacheResult) : false; + //Chills + boolean triageEncounterHasChills = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, chillsResult) : false; + boolean hivFollowupEncounterHasChills = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, chillsResult) : false; + boolean clinicalEncounterHasChills = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, chillsResult) : false; + //Rash + boolean triageEncounterHasRash = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, rashResult) : false; + boolean hivFollowupEncounterHasRash = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, rashResult) : false; + boolean clinicalEncounterHasRash = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, rashResult) : false; + + //Acute Febrile Rash Infection + boolean triageEncounterHasAcuteRashInfection = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, acuteFebrileRashInfectionResult) : false; + boolean hivFollowupEncounterHasAcuteRashInfection = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, acuteFebrileRashInfectionResult) : false; + boolean clinicalEncounterHasAcuteRashInfection = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, acuteFebrileRashInfectionResult) : false; + + //Refusal to feed + boolean triageEncounterHasRefusalToFeed = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, refusalToFeedResult) : false; + boolean hivFollowupEncounterHasRefusalToFeed = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, refusalToFeedResult) : false; + boolean clinicalEncounterHasRefusalToFeed = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, refusalToFeedResult) : false; + + //Convulsions + boolean triageEncounterHasConvulsions = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, convulsionsResult) : false; + boolean hivFollowupEncounterHasConvulsions = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, convulsionsResult) : false; + boolean clinicalEncounterHasConvulsions = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, convulsionsResult) : false; + + //Coryza + boolean triageEncounterHasCoryza = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, coryzaResult) : false; + boolean hivFollowupEncounterHasCoryza = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, coryzaResult) : false; + boolean clinicalEncounterHasCoryza = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, coryzaResult) : false; + //Conjunctivitis + boolean triageEncounterHasConjunctivitis = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, conjunctivitisResult) : false; + boolean hivFollowupEncounterHasConjunctivitis = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, conjunctivitisResult) : false; + boolean clinicalEncounterHasConjunctivitis = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, conjunctivitisResult) : false; + //Jaundice + boolean triageEncounterHasJaundice = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestionExam, jaundiceResult) : false; + boolean hivFollowupEncounterHasJaundice = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestionExam, jaundiceResult) : false; + boolean clinicalEncounterHasJaundice = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestionExam, jaundiceResult) : false; + //Dizziness + boolean triageEncounterHasDizziness = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, dizzinessResult) : false; + boolean hivFollowupEncounterHasDizziness = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, dizzinessResult) : false; + boolean clinicalEncounterHasDizziness = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, dizzinessResult) : false; + //Malaise + boolean triageEncounterHasMalaise = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, malaiseResult) : false; + boolean hivFollowupEncounterHasMalaise = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, malaiseResult) : false; + boolean clinicalEncounterHasMalaise = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, malaiseResult) : false; + //Weakness of limbs + boolean triageEncounterHasWeakLimbs = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, limbsWeaknessResult) : false; + boolean hivFollowupEncounterHasWeakLimbs = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, limbsWeaknessResult) : false; + boolean clinicalEncounterHasWeakLimbs = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, limbsWeaknessResult) : false; + + //Acute Meningitis and Encephalitis Syndrome // boolean triageEncounterHasMeningitis = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, meningitisResult) : false; // boolean hivFollowupEncounterHasMeningitis = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, meningitisResult) : false; // boolean clinicalEncounterHasMeningitis = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, meningitisResult) : false; - //Sudden Onset - boolean triageEncounterHasSuddenOnset = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, meningitisResult) : false; - boolean hivFollowupEncounterHasSuddenOnset = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, meningitisResult) : false; - boolean clinicalEncounterHasSuddenOnset = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, meningitisResult) : false; - - //lymphadenopathy - boolean triageEncounterHasLymphadenopathy = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, lymphadenopathyResult) : false; - boolean hivFollowupEncounterHasLymphadenopathy = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, lymphadenopathyResult) : false; - boolean clinicalEncounterHasLymphadenopathy = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, lymphadenopathyResult) : false; - //myalgia - boolean triageEncounterHasMyalgia = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, myalgiaResult) : false; - boolean hivFollowupEncounterHasMyalgia = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, myalgiaResult) : false; - boolean clinicalEncounterHasMyalgia = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, myalgiaResult) : false; - //backpain - boolean triageEncounterHasBackpain = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, backpainResult) : false; - boolean hivFollowupEncounterHasBackpain = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, backpainResult) : false; - boolean clinicalEncounterHasBackpain = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, backpainResult) : false; - - //Check admission status : Found in clinical encounter and type of visit - boolean patientAdmissionStatus = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, adminQuestion, admissionAnswer) : false; - //Visit type is inpatient - Visit currentVisit = activeVisits.get(0); - Obs lastTempObs = EmrCalculationUtils.obsResultForPatient(tempMap, ptId); - if (lastTempObs != null) { - tempValue = lastTempObs.getValueNumeric(); - } + //Sudden Onset + boolean triageEncounterHasSuddenOnset = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, meningitisResult) : false; + boolean hivFollowupEncounterHasSuddenOnset = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, meningitisResult) : false; + boolean clinicalEncounterHasSuddenOnset = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, meningitisResult) : false; + + //lymphadenopathy + boolean triageEncounterHasLymphadenopathy = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, lymphadenopathyResult) : false; + boolean hivFollowupEncounterHasLymphadenopathy = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, lymphadenopathyResult) : false; + boolean clinicalEncounterHasLymphadenopathy = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, lymphadenopathyResult) : false; + //myalgia + boolean triageEncounterHasMyalgia = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, myalgiaResult) : false; + boolean hivFollowupEncounterHasMyalgia = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, myalgiaResult) : false; + boolean clinicalEncounterHasMyalgia = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, myalgiaResult) : false; + //backpain + boolean triageEncounterHasBackpain = lastTriageEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastTriageEncounter, screeningQuestion, backpainResult) : false; + boolean hivFollowupEncounterHasBackpain = lastHivFollowUpEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastHivFollowUpEncounter, screeningQuestion, backpainResult) : false; + boolean clinicalEncounterHasBackpain = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, screeningQuestion, backpainResult) : false; + + //Check admission status : Found in clinical encounter and type of visit + boolean patientAdmissionStatus = lastClinicalEncounter != null ? EmrUtils.encounterThatPassCodedAnswer(lastClinicalEncounter, adminQuestion, admissionAnswer) : false; + //Visit type is inpatient + Visit currentVisit = activeVisits.get(0); + Obs lastTempObs = EmrCalculationUtils.obsResultForPatient(tempMap, ptId); + if (lastTempObs != null) { + tempValue = lastTempObs.getValueNumeric(); + } //Triage if (lastTriageEncounter != null) { @@ -904,23 +905,20 @@ public CalculationResultMap evaluate(Collection cohort, Map 0) { - idsrMessageString = StringUtils.join(idsrMessage, ","); + if (idsrMessage.size() > 0) { + idsrMessageString = StringUtils.join(idsrMessage, ","); + } + ret.put(ptId, new BooleanResult(eligible, this)); } - ret.put(ptId, new BooleanResult(eligible, this)); } return ret; } @Override public String getFlagMessage() { - if (isDmi.equals("true")) { return "Suspected " + idsrMessageString; - } else { - return ""; - } } } From 668e6a05da48ef674194f53847cf13e417cd2b40 Mon Sep 17 00:00:00 2001 From: gabu90 Date: Tue, 15 Oct 2024 10:53:36 +0300 Subject: [PATCH 8/8] Clear the unwanted flags --- .../IDSRSuspectedCaseListReportBuilder.java | 251 ------------------ .../library/dmi/IDSRCohortLibrary.java | 181 ------------- .../library/dmi/IDSRIndicatorLibrary.java | 49 ---- 3 files changed, 481 deletions(-) diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/builder/dmi/IDSRSuspectedCaseListReportBuilder.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/builder/dmi/IDSRSuspectedCaseListReportBuilder.java index dd49c855c..b551b1ae5 100644 --- a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/builder/dmi/IDSRSuspectedCaseListReportBuilder.java +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/builder/dmi/IDSRSuspectedCaseListReportBuilder.java @@ -76,13 +76,8 @@ protected List> buildDataSets(ReportDescriptor descrip ReportUtils.map(dysenteryDataSetDefinitionColumns(), "startDate=${startDate},endDate=${endDate}"), ReportUtils.map( choleraDataSetDefinitionColumns(), "startDate=${startDate},endDate=${endDate}"), - ReportUtils.map(riftValleyFeverDataSetDefinitionColumns(), - "startDate=${startDate},endDate=${endDate}"), ReportUtils.map( - malariaDataSetDefinitionColumns(), "startDate=${startDate},endDate=${endDate}"), - ReportUtils.map(chikungunyaDataSetDefinitionColumns(), "startDate=${startDate},endDate=${endDate}"), ReportUtils.map(poliomyelitisDataSetDefinitionColumns(), "startDate=${startDate},endDate=${endDate}"), ReportUtils.map(viralHaemorrhagicFeverDataSetDefinitionColumns(), "startDate=${startDate},endDate=${endDate}"), - ReportUtils.map(measlesDataSetDefinitionColumns(), "startDate=${startDate},endDate=${endDate}"), ReportUtils.map(mPoxDataSetDefinitionColumns(), "startDate=${startDate},endDate=${endDate}"), ReportUtils.map(jaundiceDataSetDefinitionColumns(), "startDate=${startDate},endDate=${endDate}"), ReportUtils.map(febrileIllnessDataSetDefinitionColumns(), "startDate=${startDate},endDate=${endDate}"), @@ -100,31 +95,16 @@ protected DataSetDefinition caseIdentificationClassificationIndicators() { cohortDsd.addParameter(new Parameter("endDate", "End Date", Date.class)); String indParams = "startDate=${startDate},endDate=${endDate}"; - cohortDsd.addColumn("Dysentery", "", - ReportUtils.map(idsrIndicatorLibrary.dysenteryCases(), indParams), ""); - cohortDsd.addColumn("Cholera", "", - ReportUtils.map(idsrIndicatorLibrary.choleraCases(), indParams), ""); cohortDsd.addColumn("ILI", "", ReportUtils.map(idsrIndicatorLibrary.iliCases(), indParams), ""); cohortDsd.addColumn("SARI", "", ReportUtils.map(idsrIndicatorLibrary.sariCases(), indParams), ""); - cohortDsd.addColumn( - "Riftvalley Fever", "", - ReportUtils.map(idsrIndicatorLibrary.riftvalleyFeverCases(), indParams), ""); - cohortDsd.addColumn( - "Malaria", "", - ReportUtils.map(idsrIndicatorLibrary.malariaCases(), indParams), ""); - cohortDsd.addColumn("Chikungunya", "", - ReportUtils.map(idsrIndicatorLibrary.chikungunyaCases(), indParams), ""); cohortDsd.addColumn( "Acute Flaccid Paralysis", "", ReportUtils.map(idsrIndicatorLibrary.poliomyelitisCases(), indParams), ""); cohortDsd.addColumn( "Acute Haemorrhagic Fever", "", ReportUtils.map(idsrIndicatorLibrary.viralHaemorrhagicFeverCases(), indParams), ""); - cohortDsd.addColumn( - "Measles", - "", ReportUtils.map(idsrIndicatorLibrary.measlesCases(), indParams), ""); cohortDsd.addColumn( "Monkey Pox", "", ReportUtils.map(idsrIndicatorLibrary.monkeyPoxCases(), indParams), ""); @@ -591,179 +571,6 @@ protected DataSetDefinition sariDataSetDefinitionColumns() { return dsd; } - protected DataSetDefinition riftValleyFeverDataSetDefinitionColumns() { - PatientDataSetDefinition dsd = new PatientDataSetDefinition(); - dsd.setName("riftvalleyFever"); - dsd.setDescription("Riftvalley Fever"); - dsd.addParameter(new Parameter("startDate", "Start Date", Date.class)); - dsd.addParameter(new Parameter("endDate", "End Date", Date.class)); - String paramMapping = "startDate=${startDate},endDate=${endDate}"; - - PatientIdentifierType upn = MetadataUtils.existing(PatientIdentifierType.class, - HivMetadata._PatientIdentifierType.UNIQUE_PATIENT_NUMBER); - PatientIdentifierType nupi = MetadataUtils.existing(PatientIdentifierType.class, - CommonMetadata._PatientIdentifierType.NATIONAL_UNIQUE_PATIENT_IDENTIFIER); - DataConverter identifierFormatter = new ObjectFormatter("{identifier}"); - DataDefinition identifierDef = new ConvertedPatientDataDefinition("identifier", new PatientIdentifierDataDefinition( - upn.getName(), upn), identifierFormatter); - DataDefinition nupiDef = new ConvertedPatientDataDefinition("identifier", new PatientIdentifierDataDefinition( - nupi.getName(), nupi), identifierFormatter); - AgeAtReportingDataDefinition ageAtReportingDataDefinition = new AgeAtReportingDataDefinition(); - ageAtReportingDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); - - ETLNextAppointmentDateDataDefinition lastAppointmentDateDataDefinition = new ETLNextAppointmentDateDataDefinition(); - lastAppointmentDateDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); - lastAppointmentDateDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); - VisitTypeWithComplaintsDataDefinition visitTypeDataDefinition = new VisitTypeWithComplaintsDataDefinition(); - visitTypeDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); - visitTypeDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); - - ComplaintAttendantProviderDataDefinition attendedByDataDefinition = new ComplaintAttendantProviderDataDefinition(); - attendedByDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); - attendedByDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); - - VisitDateWithComplaintsDataDefinition visitDateWithComplaintsDataDefinition = new VisitDateWithComplaintsDataDefinition(); - visitDateWithComplaintsDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); - visitDateWithComplaintsDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); - - DataConverter formatter = new ObjectFormatter("{familyName}, {givenName}"); - DataDefinition nameDef = new ConvertedPersonDataDefinition("name", - new PreferredNameDataDefinition(), formatter); - PersonAttributeType phoneNumber = MetadataUtils.existing(PersonAttributeType.class, - CommonMetadata._PersonAttributeType.TELEPHONE_CONTACT); - dsd.addColumn("id", new PersonIdDataDefinition(), ""); - dsd.addColumn("Name", nameDef, ""); - // dsd.addColumn("Hospital Unit", new MFLCodeDataDefinition(), ""); - dsd.addColumn("Visit Type", visitTypeDataDefinition, paramMapping); - dsd.addColumn("Sex", new GenderDataDefinition(), "", null); - dsd.addColumn("Age", ageAtReportingDataDefinition, "endDate=${endDate}"); - dsd.addColumn("Visit Date", visitDateWithComplaintsDataDefinition, paramMapping); - dsd.addColumn("Attended By", attendedByDataDefinition, paramMapping); - dsd.addColumn("Next Visit", lastAppointmentDateDataDefinition, paramMapping); - - RiftValleyFeverCohortDefinition cd = new RiftValleyFeverCohortDefinition(); - cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); - cd.addParameter(new Parameter("endDate", "End Date", Date.class)); - - dsd.addRowFilter(cd, paramMapping); - return dsd; - } - - protected DataSetDefinition malariaDataSetDefinitionColumns() { - PatientDataSetDefinition dsd = new PatientDataSetDefinition(); - dsd.setName("malaria"); - dsd.setDescription("Malaria Information"); - dsd.addParameter(new Parameter("startDate", "Start Date", Date.class)); - dsd.addParameter(new Parameter("endDate", "End Date", Date.class)); - String paramMapping = "startDate=${startDate},endDate=${endDate}"; - - PatientIdentifierType upn = MetadataUtils.existing(PatientIdentifierType.class, - HivMetadata._PatientIdentifierType.UNIQUE_PATIENT_NUMBER); - PatientIdentifierType nupi = MetadataUtils.existing(PatientIdentifierType.class, - CommonMetadata._PatientIdentifierType.NATIONAL_UNIQUE_PATIENT_IDENTIFIER); - DataConverter identifierFormatter = new ObjectFormatter("{identifier}"); - DataDefinition identifierDef = new ConvertedPatientDataDefinition("identifier", new PatientIdentifierDataDefinition( - upn.getName(), upn), identifierFormatter); - DataDefinition nupiDef = new ConvertedPatientDataDefinition("identifier", new PatientIdentifierDataDefinition( - nupi.getName(), nupi), identifierFormatter); - AgeAtReportingDataDefinition ageAtReportingDataDefinition = new AgeAtReportingDataDefinition(); - ageAtReportingDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); - - ETLNextAppointmentDateDataDefinition lastAppointmentDateDataDefinition = new ETLNextAppointmentDateDataDefinition(); - lastAppointmentDateDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); - lastAppointmentDateDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); - VisitTypeWithComplaintsDataDefinition visitTypeDataDefinition = new VisitTypeWithComplaintsDataDefinition(); - visitTypeDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); - visitTypeDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); - - ComplaintAttendantProviderDataDefinition attendedByDataDefinition = new ComplaintAttendantProviderDataDefinition(); - attendedByDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); - attendedByDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); - - VisitDateWithComplaintsDataDefinition visitDateWithComplaintsDataDefinition = new VisitDateWithComplaintsDataDefinition(); - visitDateWithComplaintsDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); - visitDateWithComplaintsDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); - - DataConverter formatter = new ObjectFormatter("{familyName}, {givenName}"); - DataDefinition nameDef = new ConvertedPersonDataDefinition("name", - new PreferredNameDataDefinition(), formatter); - PersonAttributeType phoneNumber = MetadataUtils.existing(PersonAttributeType.class, - CommonMetadata._PersonAttributeType.TELEPHONE_CONTACT); - dsd.addColumn("id", new PersonIdDataDefinition(), ""); - dsd.addColumn("Name", nameDef, ""); - // dsd.addColumn("Hospital Unit", new MFLCodeDataDefinition(), ""); - dsd.addColumn("Visit Type", visitTypeDataDefinition, paramMapping); - dsd.addColumn("Sex", new GenderDataDefinition(), "", null); - dsd.addColumn("Age", ageAtReportingDataDefinition, "endDate=${endDate}"); - dsd.addColumn("Visit Date", visitDateWithComplaintsDataDefinition, paramMapping); - dsd.addColumn("Attended By", attendedByDataDefinition, paramMapping); - dsd.addColumn("Next Visit", lastAppointmentDateDataDefinition, paramMapping); - - MalariaCohortDefinition cd = new MalariaCohortDefinition(); - cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); - cd.addParameter(new Parameter("endDate", "End Date", Date.class)); - - dsd.addRowFilter(cd, paramMapping); - return dsd; - } - - protected DataSetDefinition chikungunyaDataSetDefinitionColumns() { - PatientDataSetDefinition dsd = new PatientDataSetDefinition(); - dsd.setName("chikungunya"); - dsd.setDescription("Chikungunya"); - dsd.addParameter(new Parameter("startDate", "Start Date", Date.class)); - dsd.addParameter(new Parameter("endDate", "End Date", Date.class)); - String paramMapping = "startDate=${startDate},endDate=${endDate}"; - - PatientIdentifierType upn = MetadataUtils.existing(PatientIdentifierType.class, - HivMetadata._PatientIdentifierType.UNIQUE_PATIENT_NUMBER); - PatientIdentifierType nupi = MetadataUtils.existing(PatientIdentifierType.class, - CommonMetadata._PatientIdentifierType.NATIONAL_UNIQUE_PATIENT_IDENTIFIER); - DataConverter identifierFormatter = new ObjectFormatter("{identifier}"); - DataDefinition identifierDef = new ConvertedPatientDataDefinition("identifier", new PatientIdentifierDataDefinition( - upn.getName(), upn), identifierFormatter); - DataDefinition nupiDef = new ConvertedPatientDataDefinition("identifier", new PatientIdentifierDataDefinition( - nupi.getName(), nupi), identifierFormatter); - AgeAtReportingDataDefinition ageAtReportingDataDefinition = new AgeAtReportingDataDefinition(); - ageAtReportingDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); - - ETLNextAppointmentDateDataDefinition lastAppointmentDateDataDefinition = new ETLNextAppointmentDateDataDefinition(); - lastAppointmentDateDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); - lastAppointmentDateDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); - VisitTypeWithComplaintsDataDefinition visitTypeDataDefinition = new VisitTypeWithComplaintsDataDefinition(); - visitTypeDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); - visitTypeDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); - - ComplaintAttendantProviderDataDefinition attendedByDataDefinition = new ComplaintAttendantProviderDataDefinition(); - attendedByDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); - attendedByDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); - - VisitDateWithComplaintsDataDefinition visitDateWithComplaintsDataDefinition = new VisitDateWithComplaintsDataDefinition(); - visitDateWithComplaintsDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); - visitDateWithComplaintsDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); - - DataConverter formatter = new ObjectFormatter("{familyName}, {givenName}"); - DataDefinition nameDef = new ConvertedPersonDataDefinition("name", - new PreferredNameDataDefinition(), formatter); - PersonAttributeType phoneNumber = MetadataUtils.existing(PersonAttributeType.class, - CommonMetadata._PersonAttributeType.TELEPHONE_CONTACT); - dsd.addColumn("id", new PersonIdDataDefinition(), ""); - dsd.addColumn("Name", nameDef, ""); - // dsd.addColumn("Hospital Unit", new MFLCodeDataDefinition(), ""); - dsd.addColumn("Visit Type", visitTypeDataDefinition, paramMapping); - dsd.addColumn("Sex", new GenderDataDefinition(), "", null); - dsd.addColumn("Age", ageAtReportingDataDefinition, "endDate=${endDate}"); - dsd.addColumn("Visit Date", visitDateWithComplaintsDataDefinition, paramMapping); - dsd.addColumn("Attended By", attendedByDataDefinition, paramMapping); - dsd.addColumn("Next Visit", lastAppointmentDateDataDefinition, paramMapping); - - ChikungunyaCohortDefinition cd = new ChikungunyaCohortDefinition(); - cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); - cd.addParameter(new Parameter("endDate", "End Date", Date.class)); - - dsd.addRowFilter(cd, paramMapping); - return dsd; - } protected DataSetDefinition poliomyelitisDataSetDefinitionColumns() { PatientDataSetDefinition dsd = new PatientDataSetDefinition(); @@ -881,64 +688,6 @@ protected DataSetDefinition viralHaemorrhagicFeverDataSetDefinitionColumns() { return dsd; } - protected DataSetDefinition measlesDataSetDefinitionColumns() { - PatientDataSetDefinition dsd = new PatientDataSetDefinition(); - dsd.setName("measles"); - dsd.setDescription("Measles"); - dsd.addParameter(new Parameter("startDate", "Start Date", Date.class)); - dsd.addParameter(new Parameter("endDate", "End Date", Date.class)); - String paramMapping = "startDate=${startDate},endDate=${endDate}"; - - PatientIdentifierType upn = MetadataUtils.existing(PatientIdentifierType.class, - HivMetadata._PatientIdentifierType.UNIQUE_PATIENT_NUMBER); - PatientIdentifierType nupi = MetadataUtils.existing(PatientIdentifierType.class, - CommonMetadata._PatientIdentifierType.NATIONAL_UNIQUE_PATIENT_IDENTIFIER); - DataConverter identifierFormatter = new ObjectFormatter("{identifier}"); - DataDefinition identifierDef = new ConvertedPatientDataDefinition("identifier", new PatientIdentifierDataDefinition( - upn.getName(), upn), identifierFormatter); - DataDefinition nupiDef = new ConvertedPatientDataDefinition("identifier", new PatientIdentifierDataDefinition( - nupi.getName(), nupi), identifierFormatter); - AgeAtReportingDataDefinition ageAtReportingDataDefinition = new AgeAtReportingDataDefinition(); - ageAtReportingDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); - - ETLNextAppointmentDateDataDefinition lastAppointmentDateDataDefinition = new ETLNextAppointmentDateDataDefinition(); - lastAppointmentDateDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); - lastAppointmentDateDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); - VisitTypeWithComplaintsDataDefinition visitTypeDataDefinition = new VisitTypeWithComplaintsDataDefinition(); - visitTypeDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); - visitTypeDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); - - ComplaintAttendantProviderDataDefinition attendedByDataDefinition = new ComplaintAttendantProviderDataDefinition(); - attendedByDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); - attendedByDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); - - VisitDateWithComplaintsDataDefinition visitDateWithComplaintsDataDefinition = new VisitDateWithComplaintsDataDefinition(); - visitDateWithComplaintsDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); - visitDateWithComplaintsDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); - - DataConverter formatter = new ObjectFormatter("{familyName}, {givenName}"); - DataDefinition nameDef = new ConvertedPersonDataDefinition("name", - new PreferredNameDataDefinition(), formatter); - PersonAttributeType phoneNumber = MetadataUtils.existing(PersonAttributeType.class, - CommonMetadata._PersonAttributeType.TELEPHONE_CONTACT); - dsd.addColumn("id", new PersonIdDataDefinition(), ""); - dsd.addColumn("Name", nameDef, ""); - // dsd.addColumn("Hospital Unit", new MFLCodeDataDefinition(), ""); - dsd.addColumn("Visit Type", visitTypeDataDefinition, paramMapping); - dsd.addColumn("Sex", new GenderDataDefinition(), "", null); - dsd.addColumn("Age", ageAtReportingDataDefinition, "endDate=${endDate}"); - dsd.addColumn("Visit Date", visitDateWithComplaintsDataDefinition, paramMapping); - dsd.addColumn("Attended By", attendedByDataDefinition, paramMapping); - dsd.addColumn("Next Visit", lastAppointmentDateDataDefinition, paramMapping); - - MeaslesCohortDefinition cd = new MeaslesCohortDefinition(); - cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); - cd.addParameter(new Parameter("endDate", "End Date", Date.class)); - - dsd.addRowFilter(cd, paramMapping); - return dsd; - } - protected DataSetDefinition mPoxDataSetDefinitionColumns() { PatientDataSetDefinition dsd = new PatientDataSetDefinition(); dsd.setName("mPox"); diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/library/dmi/IDSRCohortLibrary.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/library/dmi/IDSRCohortLibrary.java index e106780b4..40069bb07 100644 --- a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/library/dmi/IDSRCohortLibrary.java +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/library/dmi/IDSRCohortLibrary.java @@ -28,55 +28,6 @@ @Component public class IDSRCohortLibrary { - - /** - * Dysentery cases - * @return - */ - public CohortDefinition dysenteryCases() { - SqlCohortDefinition cd = new SqlCohortDefinition(); - String sqlQuery = "select a.patient_id\n" + - "from (select patient_id, group_concat(c.complaint) as complaint\n" + - " from kenyaemr_etl.etl_allergy_chronic_illness c\n" + - " where c.complaint in (117671, 142412)\n" + - " and date(c.visit_date) between date(:startDate) and date(:endDate)\n" + - " group by patient_id) a\n" + - "where FIND_IN_SET(117671, a.complaint) > 0\n" + - " and FIND_IN_SET(142412, a.complaint) > 0;"; - cd.setName("dysenteryCases"); - cd.setQuery(sqlQuery); - cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); - cd.addParameter(new Parameter("endDate", "End Date", Date.class)); - cd.setDescription("Dysentery cases"); - - return cd; - } - - /** - * Cholera cases - * @return - */ - public CohortDefinition choleraCases() { - SqlCohortDefinition cd = new SqlCohortDefinition(); - String sqlQuery = "select a.patient_id\n" + - " from (select patient_id, c.visit_date,group_concat(c.complaint) as complaint, DATE_SUB(c.visit_date, INTERVAL c.complaint_duration DAY) as complaint_date,\n" + - " c.complaint_duration\n" + - " from kenyaemr_etl.etl_allergy_chronic_illness c\n" + - " where c.complaint in (161887,122983)\n" + - " and date(c.visit_date) between date(:startDate) and date(:endDate)\n" + - " group by patient_id) a\n" + - " join kenyaemr_etl.etl_patient_demographics d on a.patient_id = d.patient_id\n" + - " where timestampdiff(YEAR,date(d.DOB),coalesce(date(DATE_SUB(a.visit_date, INTERVAL a.complaint_duration DAY)),date(a.visit_date))) > 2 and FIND_IN_SET(122983, a.complaint) > 0\n" + - " and FIND_IN_SET(161887, a.complaint) > 0;"; - cd.setName("choleraCases"); - cd.setQuery(sqlQuery); - cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); - cd.addParameter(new Parameter("endDate", "End Date", Date.class)); - cd.setDescription("Cholera cases"); - - return cd; - } - /** * ILI Cases * @return @@ -128,105 +79,6 @@ public CohortDefinition sariCases() { return cd; } - - /** - * Riftvalley Fever Cases - * @return - */ - public CohortDefinition riftvalleyFeverCases() { - SqlCohortDefinition cd = new SqlCohortDefinition(); - String sqlQuery = "select a.patient_id\n" + - "from (select patient_id, c.visit_date,group_concat(c.complaint) as complaint,\n" + - " CASE\n" + - " WHEN group_concat(concat_ws('|',c.complaint,c.complaint_duration)) LIKE '%140238%' THEN\n" + - " SUBSTRING_INDEX(SUBSTRING_INDEX(group_concat(concat_ws('|',c.complaint,c.complaint_duration)) , '|', -1), ',', 1)\n" + - " END AS fever_duration_from_days\n" + - " from kenyaemr_etl.etl_allergy_chronic_illness c\n" + - " where c.complaint in (140238,141830,136443,135367)\n" + - " and date(c.visit_date) between date(:startDate) and date(:endDate)\n" + - " group by patient_id) a\n" + - " join kenyaemr_etl.etl_patient_demographics d on a.patient_id = d.patient_id\n" + - " join kenyaemr_etl.etl_patient_triage t\n" + - " on a.patient_id = t.patient_id and date(t.visit_date) between date(:startDate) and date(:endDate) and\n" + - " t.temperature > 37.5 and date(a.visit_date) between date(:startDate) and date(:endDate)\n" + - "where FIND_IN_SET(140238, a.complaint) > 0\n" + - " and (FIND_IN_SET(141830, a.complaint) > 0 and a.fever_duration_from_days > 2)\n" + - " and FIND_IN_SET(136443, a.complaint) > 0\n" + - " and FIND_IN_SET(135367, a.complaint) > 0;"; - cd.setName("riftvalleyFeverCases"); - cd.setQuery(sqlQuery); - cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); - cd.addParameter(new Parameter("endDate", "End Date", Date.class)); - cd.setDescription("Riftvalley Fever Cases"); - - return cd; - } - - /** - * Malaria Cases - * @return - */ - public CohortDefinition malariaCases() { - SqlCohortDefinition cd = new SqlCohortDefinition(); - String sqlQuery = "select a.patient_id\n" + - "from (select patient_id, c.visit_date,group_concat(c.complaint) as complaint,\n" + - " CASE\n" + - " WHEN group_concat(concat_ws('|',c.complaint,c.complaint_duration)) LIKE '%140238%' THEN\n" + - " SUBSTRING_INDEX(SUBSTRING_INDEX(group_concat(concat_ws('|',c.complaint,c.complaint_duration)) , '|', -1), ',', 1)\n" + - " END AS fever_duration_from_days\n" + - " from kenyaemr_etl.etl_allergy_chronic_illness c\n" + - " where c.complaint in (140238,139084,871)\n" + - " and date(c.visit_date) between date(:startDate) and date(:endDate)\n" + - " group by patient_id) a\n" + - " join kenyaemr_etl.etl_patient_demographics d on a.patient_id = d.patient_id\n" + - " join kenyaemr_etl.etl_patient_triage t\n" + - " on a.patient_id = t.patient_id and date(t.visit_date) between date(:startDate) and date(:endDate) and\n" + - " t.temperature > 37.5 and date(a.visit_date) between date(:startDate) and date(:endDate)\n" + - "where FIND_IN_SET(140238, a.complaint) > 0\n" + - " and FIND_IN_SET(139084, a.complaint) > 0\n" + - " and FIND_IN_SET(871, a.complaint) > 0\n" + - " and a.fever_duration_from_days > 1;"; - cd.setName("malariaCases"); - cd.setQuery(sqlQuery); - cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); - cd.addParameter(new Parameter("endDate", "End Date", Date.class)); - cd.setDescription("Malaria cases"); - - return cd; - } - - /** - * Chikungunya Cases - * @return - */ - public CohortDefinition chikungunyaCases() { - SqlCohortDefinition cd = new SqlCohortDefinition(); - String sqlQuery = "select a.patient_id\n" + - " from (select patient_id, c.visit_date,group_concat(c.complaint) as complaint,\n" + - " CASE\n" + - " WHEN group_concat(concat_ws('|',c.complaint,c.complaint_duration)) LIKE '%140238%' THEN\n" + - " SUBSTRING_INDEX(SUBSTRING_INDEX(group_concat(concat_ws('|',c.complaint,c.complaint_duration)) , '|', -1), ',', 1)\n" + - " END AS fever_duration_from_days\n" + - " from kenyaemr_etl.etl_allergy_chronic_illness c\n" + - " where c.complaint in (140238, 116558)\n" + - " and date(c.visit_date) between date(:startDate) and date(:endDate)\n" + - " group by patient_id) a\n" + - " join kenyaemr_etl.etl_patient_demographics d on a.patient_id = d.patient_id\n" + - " join kenyaemr_etl.etl_patient_triage t\n" + - " on a.patient_id = t.patient_id and date(t.visit_date) between date(:startDate) and date(:endDate) and\n" + - " t.temperature > 38.5 and date(a.visit_date) between date(:startDate) and date(:endDate)\n" + - " where fever_duration_from_days > 2\n" + - " and FIND_IN_SET(140238, a.complaint) > 0\n" + - " and FIND_IN_SET(116558, a.complaint) > 0"; - cd.setName("chikungunyaCases"); - cd.setQuery(sqlQuery); - cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); - cd.addParameter(new Parameter("endDate", "End Date", Date.class)); - cd.setDescription("Chikungunya cases"); - - return cd; - } - /** * Poliomyelitis Cases * @return @@ -278,36 +130,6 @@ public CohortDefinition viralHaemorrhagicFeverCases() { cd.setDescription("Acute Haemorrhagic Fever"); return cd;} - /** - * Measles Cases - * @return - */ - public CohortDefinition measlesCases() { - SqlCohortDefinition cd = new SqlCohortDefinition(); - String sqlQuery = "select a.patient_id\n" + - " from (select patient_id, c.visit_date,group_concat(c.complaint) as complaint,\n" + - " CASE\n" + - " WHEN group_concat(concat_ws('|',c.complaint,c.complaint_duration)) LIKE '%140238%' THEN\n" + - " SUBSTRING_INDEX(SUBSTRING_INDEX(group_concat(concat_ws('|',c.complaint,c.complaint_duration)) , '|', -1), ',', 1)\n" + - " END AS fever_duration_from_days\n" + - " from kenyaemr_etl.etl_allergy_chronic_illness c\n" + - " where c.complaint in (140238,512,106,516,143264)\n" + - " and date(c.visit_date) between date(:startDate) and date(:endDate)\n" + - " group by patient_id) a\n" + - " where fever_duration_from_days > 2\n" + - " and FIND_IN_SET(140238, a.complaint) > 0\n" + - " and FIND_IN_SET(512, a.complaint) > 0\n" + - " and FIND_IN_SET(106, a.complaint) > 0\n" + - " and FIND_IN_SET(516, a.complaint) > 0\n" + - " and FIND_IN_SET(143264, a.complaint) > 0;"; - cd.setName("measlesCases"); - cd.setQuery(sqlQuery); - cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); - cd.addParameter(new Parameter("endDate", "End Date", Date.class)); - cd.setDescription("Measles Cases"); - - return cd; - } /** * Monkey Pox Cases * @return @@ -343,13 +165,10 @@ public CohortDefinition monkeyPoxCases() { return cd; } - - /** * Jaundice cases * @return */ - public CohortDefinition jaundiceCases() { SqlCohortDefinition cd = new SqlCohortDefinition(); String sqlQuery = "SELECT a.patient_id\n" + diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/library/dmi/IDSRIndicatorLibrary.java b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/library/dmi/IDSRIndicatorLibrary.java index fb142d1e2..bdbecd5a7 100644 --- a/api/src/main/java/org/openmrs/module/kenyaemr/reporting/library/dmi/IDSRIndicatorLibrary.java +++ b/api/src/main/java/org/openmrs/module/kenyaemr/reporting/library/dmi/IDSRIndicatorLibrary.java @@ -31,23 +31,6 @@ public class IDSRIndicatorLibrary { @Autowired private IDSRCohortLibrary idsrCohortLibrary; - - /** - * Dysentery Cases - * @return indicator - */ - public CohortIndicator dysenteryCases() { - return cohortIndicator("Individuals tested at the facility", map(idsrCohortLibrary.dysenteryCases(), "startDate=${startDate},endDate=${endDate}")); - } - - /** - * Cholera Cases - * @return indicator - */ - public CohortIndicator choleraCases() { - return cohortIndicator("Individuals tested", map(idsrCohortLibrary.choleraCases(), "startDate=${startDate},endDate=${endDate}")); - } - /** * ILI Cases * @return indicator @@ -64,30 +47,6 @@ public CohortIndicator sariCases() { return cohortIndicator("New tests", map(idsrCohortLibrary.sariCases(), "startDate=${startDate},endDate=${endDate}")); } - /** - * Riftvalley Fever Cases - * @return indicator - */ - public CohortIndicator riftvalleyFeverCases() { - return cohortIndicator("Repeat tests", map(idsrCohortLibrary.riftvalleyFeverCases(), "startDate=${startDate},endDate=${endDate}")); - } - - /** - * Malaria - * @return indicator - */ - public CohortIndicator malariaCases() { - return cohortIndicator("Couple testing", map(idsrCohortLibrary.malariaCases(), "startDate=${startDate},endDate=${endDate}")); - } - - /** - * Chikungunya Cases - * @return indicator - */ - public CohortIndicator chikungunyaCases() { - return cohortIndicator("Key population testing", map(idsrCohortLibrary.chikungunyaCases(), "startDate=${startDate},endDate=${endDate}")); - } - /** * Poliomyelitis Cases * @return indicator @@ -104,14 +63,6 @@ public CohortIndicator viralHaemorrhagicFeverCases() { return cohortIndicator("Acute Haemorrhagic Fever", map(idsrCohortLibrary.viralHaemorrhagicFeverCases(), "startDate=${startDate},endDate=${endDate}")); } - /** - * Measles cases - * @return indicator - */ - public CohortIndicator measlesCases() { - return cohortIndicator("Measles cases", map(idsrCohortLibrary.measlesCases(), "startDate=${startDate},endDate=${endDate}")); - } - /** * Monkey Pox Cases * @return indicator