-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #164 from Werick/upn-revised
KenyEmr Ehancements
- Loading branch information
Showing
9 changed files
with
168 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
.../main/java/org/openmrs/module/kenyaemr/calculation/library/PatientProgramCalculation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package org.openmrs.module.kenyaemr.calculation.library; | ||
|
||
import org.openmrs.Patient; | ||
import org.openmrs.PatientProgram; | ||
import org.openmrs.Program; | ||
import org.openmrs.api.context.Context; | ||
import org.openmrs.calculation.patient.PatientCalculationContext; | ||
import org.openmrs.calculation.patient.PatientCalculationService; | ||
import org.openmrs.calculation.result.CalculationResultMap; | ||
import org.openmrs.calculation.result.SimpleResult; | ||
import org.openmrs.module.kenyacore.calculation.AbstractPatientCalculation; | ||
import org.openmrs.module.kenyacore.calculation.CalculationUtils; | ||
import org.openmrs.module.kenyaemr.Metadata; | ||
import org.openmrs.module.reporting.cohort.EvaluatedCohort; | ||
import org.openmrs.module.reporting.cohort.definition.InProgramCohortDefinition; | ||
|
||
import java.util.*; | ||
|
||
/** | ||
* Created by dev on 9/24/16. | ||
*/ | ||
public class PatientProgramCalculation extends AbstractPatientCalculation { | ||
@Override | ||
public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> map, PatientCalculationContext context) { | ||
CalculationResultMap ret = new CalculationResultMap(); | ||
InProgramCohortDefinition cd = new InProgramCohortDefinition(); | ||
List<Program> programs = new ArrayList<Program>(); | ||
programs.add(Context.getProgramWorkflowService().getProgramByUuid(Metadata.Program.HIV)); | ||
programs.add(Context.getProgramWorkflowService().getProgramByUuid(Metadata.Program.MCH_CS)); | ||
programs.add(Context.getProgramWorkflowService().getProgramByUuid(Metadata.Program.MCH_MS)); | ||
programs.add(Context.getProgramWorkflowService().getProgramByUuid(Metadata.Program.TB)); | ||
cd.setPrograms(programs); | ||
|
||
EvaluatedCohort patientProgramCohort = CalculationUtils.evaluateWithReporting(cd, cohort, null, context); | ||
|
||
Map<String, Object> params = new HashMap<String, Object>(); | ||
params.put("program", programs.get(0)); | ||
CalculationResultMap hivProgram = new InProgramCalculation().evaluate(cohort, params, Context.getService(PatientCalculationService.class).createCalculationContext()); | ||
|
||
params.put("program", programs.get(1)); | ||
CalculationResultMap mch_csProgram = new InProgramCalculation().evaluate(cohort, params, Context.getService(PatientCalculationService.class).createCalculationContext()); | ||
|
||
params.put("program", programs.get(2)); | ||
CalculationResultMap mch_msProgram = new InProgramCalculation().evaluate(cohort, params, Context.getService(PatientCalculationService.class).createCalculationContext()); | ||
|
||
params.put("program", programs.get(3)); | ||
CalculationResultMap tbProgram = new InProgramCalculation().evaluate(cohort, params, Context.getService(PatientCalculationService.class).createCalculationContext()); | ||
|
||
|
||
for(Integer ptId: cohort){ | ||
String patientProgram = ""; | ||
if(patientProgramCohort.contains(ptId)) { | ||
if ((Boolean)hivProgram.get(ptId).getValue()) { | ||
patientProgram = "HIV"; | ||
} | ||
|
||
if ((Boolean)tbProgram.get(ptId).getValue()) { | ||
patientProgram = patientProgram.equalsIgnoreCase("")? "TB" : patientProgram+",TB"; | ||
} | ||
|
||
if ((Boolean)mch_csProgram.get(ptId).getValue()) { | ||
patientProgram = patientProgram.equalsIgnoreCase("")? "MCH_CS" : patientProgram+",MCH_CS"; | ||
} | ||
|
||
if ((Boolean)mch_msProgram.get(ptId).getValue()) { | ||
patientProgram = patientProgram.equalsIgnoreCase("")? "MCH_MS" : patientProgram+",MCH_MS"; | ||
} | ||
} | ||
ret.put(ptId, new SimpleResult(patientProgram, this)); | ||
} | ||
|
||
//List<PatientProgram> pp= Context.getProgramWorkflowService().getPatientPrograms(cohort,programs); | ||
return ret; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters