@Test public void evaluate() throws Exception { Program mchcsProgram = MetadataUtils.existing(Program.class, MchMetadata._Program.MCHCS); TestUtils.enrollInProgram(TestUtils.getPatient(6), mchcsProgram, new Date()); TestUtils.enrollInProgram(TestUtils.getPatient(7), mchcsProgram, new Date()); TestUtils.enrollInProgram(TestUtils.getPatient(8), mchcsProgram, new Date()); Concept infantHivStatus = Dictionary.getConcept(Dictionary.CHILDS_CURRENT_HIV_STATUS); Concept nvp = Dictionary.getConcept(Dictionary.NEVIRAPINE); Concept nvpazt3tc = Dictionary.getConcept(Dictionary.LAMIVUDINE_NEVIRAPINE_ZIDOVUDINE); Concept medOrders = Dictionary.getConcept(Dictionary.MEDICATION_ORDERS); TestUtils.saveObs(TestUtils.getPatient(6),infantHivStatus,Dictionary.getConcept(Dictionary.EXPOSURE_TO_HIV), new Date()); TestUtils.saveObs(TestUtils.getPatient(6), medOrders, nvp, TestUtils.date(2013, 1, 1)); TestUtils.saveObs(TestUtils.getPatient(7),infantHivStatus,Dictionary.getConcept(Dictionary.EXPOSURE_TO_HIV), new Date()); TestUtils.saveObs(TestUtils.getPatient(7), medOrders, nvpazt3tc, TestUtils.date(2013, 1, 1)); TestUtils.saveObs(TestUtils.getPatient(8),infantHivStatus,Dictionary.getConcept(Dictionary.EXPOSURE_TO_HIV), new Date()); Context.flushSession(); List<Integer> cohort = Arrays.asList(6, 7, 8); CalculationResultMap resultMap = new InfantNeverTakenProphylaxisCalculation().evaluate(cohort, null, Context.getService(PatientCalculationService.class).createCalculationContext()); Assert.assertFalse((Boolean) resultMap.get(6).getValue()); Assert.assertFalse((Boolean) resultMap.get(7).getValue()); Assert.assertTrue((Boolean) resultMap.get(8).getValue()); }
@Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> parameterValues, PatientCalculationContext context) { Program mchcsProgram = MetadataUtils.existing(Program.class, MchMetadata._Program.MCHCS); Set<Integer> alive = Filters.alive(cohort, context); Set<Integer> inMchcsProgram = Filters.inProgram(mchcsProgram, alive, context); CalculationResultMap lastChildHivStatus = Calculations.lastObs(Dictionary.getConcept(Dictionary.CHILDS_CURRENT_HIV_STATUS), inMchcsProgram, context); CalculationResultMap medOrdersObss = Calculations.allObs(Dictionary.getConcept(Dictionary.MEDICATION_ORDERS), cohort, context); Concept nvp = Dictionary.getConcept(Dictionary.NEVIRAPINE); Concept nvpazt3tc = Dictionary.getConcept(Dictionary.LAMIVUDINE_NEVIRAPINE_ZIDOVUDINE); Concept hivExposed = Dictionary.getConcept(Dictionary.EXPOSURE_TO_HIV); CalculationResultMap ret = new CalculationResultMap(); for (Integer ptId : cohort) { boolean notOnPcp = false; Obs hivStatusObs = EmrCalculationUtils.obsResultForPatient(lastChildHivStatus, ptId); if (inMchcsProgram.contains(ptId) && lastChildHivStatus != null && hivStatusObs !=null && (hivStatusObs.getValueCoded().equals(hivExposed))) { notOnPcp = true; ListResult patientMedOrders = (ListResult) medOrdersObss.get(ptId); if (patientMedOrders != null) { List<Obs> medOrderObsList = CalculationUtils.extractResultValues(patientMedOrders); for (Obs medOrderObs : medOrderObsList) { if (medOrderObs.getValueCoded().equals(nvp) || medOrderObs.getValueCoded().equals(nvpazt3tc)) { notOnPcp = false; break; } } } } ret.put(ptId, new BooleanResult(notOnPcp, this, context)); } return ret; }
InfantNeverTakenProphylaxisCalculation extends AbstractPatientCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> parameterValues, PatientCalculationContext context) { Program mchcsProgram = MetadataUtils.existing(Program.class, MchMetadata._Program.MCHCS); Set<Integer> alive = Filters.alive(cohort, context); Set<Integer> inMchcsProgram = Filters.inProgram(mchcsProgram, alive, context); CalculationResultMap lastChildHivStatus = Calculations.lastObs(Dictionary.getConcept(Dictionary.CHILDS_CURRENT_HIV_STATUS), inMchcsProgram, context); CalculationResultMap medOrdersObss = Calculations.allObs(Dictionary.getConcept(Dictionary.MEDICATION_ORDERS), cohort, context); Concept nvp = Dictionary.getConcept(Dictionary.NEVIRAPINE); Concept nvpazt3tc = Dictionary.getConcept(Dictionary.LAMIVUDINE_NEVIRAPINE_ZIDOVUDINE); Concept hivExposed = Dictionary.getConcept(Dictionary.EXPOSURE_TO_HIV); CalculationResultMap ret = new CalculationResultMap(); for (Integer ptId : cohort) { boolean notOnPcp = false; Obs hivStatusObs = EmrCalculationUtils.obsResultForPatient(lastChildHivStatus, ptId); if (inMchcsProgram.contains(ptId) && lastChildHivStatus != null && hivStatusObs !=null && (hivStatusObs.getValueCoded().equals(hivExposed))) { notOnPcp = true; ListResult patientMedOrders = (ListResult) medOrdersObss.get(ptId); if (patientMedOrders != null) { List<Obs> medOrderObsList = CalculationUtils.extractResultValues(patientMedOrders); for (Obs medOrderObs : medOrderObsList) { if (medOrderObs.getValueCoded().equals(nvp) || medOrderObs.getValueCoded().equals(nvpazt3tc)) { notOnPcp = false; break; } } } } ret.put(ptId, new BooleanResult(notOnPcp, this, context)); } return ret; } }
InfantNeverTakenProphylaxisCalculation extends AbstractPatientCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> parameterValues, PatientCalculationContext context) { Program mchcsProgram = MetadataUtils.existing(Program.class, MchMetadata._Program.MCHCS); Set<Integer> alive = Filters.alive(cohort, context); Set<Integer> inMchcsProgram = Filters.inProgram(mchcsProgram, alive, context); CalculationResultMap lastChildHivStatus = Calculations.lastObs(Dictionary.getConcept(Dictionary.CHILDS_CURRENT_HIV_STATUS), inMchcsProgram, context); CalculationResultMap medOrdersObss = Calculations.allObs(Dictionary.getConcept(Dictionary.MEDICATION_ORDERS), cohort, context); Concept nvp = Dictionary.getConcept(Dictionary.NEVIRAPINE); Concept nvpazt3tc = Dictionary.getConcept(Dictionary.LAMIVUDINE_NEVIRAPINE_ZIDOVUDINE); Concept hivExposed = Dictionary.getConcept(Dictionary.EXPOSURE_TO_HIV); CalculationResultMap ret = new CalculationResultMap(); for (Integer ptId : cohort) { boolean notOnPcp = false; Obs hivStatusObs = EmrCalculationUtils.obsResultForPatient(lastChildHivStatus, ptId); if (inMchcsProgram.contains(ptId) && lastChildHivStatus != null && hivStatusObs !=null && (hivStatusObs.getValueCoded().equals(hivExposed))) { notOnPcp = true; ListResult patientMedOrders = (ListResult) medOrdersObss.get(ptId); if (patientMedOrders != null) { List<Obs> medOrderObsList = CalculationUtils.extractResultValues(patientMedOrders); for (Obs medOrderObs : medOrderObsList) { if (medOrderObs.getValueCoded().equals(nvp) || medOrderObs.getValueCoded().equals(nvpazt3tc)) { notOnPcp = false; break; } } } } ret.put(ptId, new BooleanResult(notOnPcp, this, context)); } return ret; }  }
InfantNeverTakenProphylaxisCalculation extends AbstractPatientCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> parameterValues, PatientCalculationContext context) { Program mchcsProgram = MetadataUtils.existing(Program.class, MchMetadata._Program.MCHCS); Set<Integer> alive = Filters.alive(cohort, context); Set<Integer> inMchcsProgram = Filters.inProgram(mchcsProgram, alive, context); CalculationResultMap lastChildHivStatus = Calculations.lastObs(Dictionary.getConcept(Dictionary.CHILDS_CURRENT_HIV_STATUS), inMchcsProgram, context); CalculationResultMap medOrdersObss = Calculations.allObs(Dictionary.getConcept(Dictionary.MEDICATION_ORDERS), cohort, context); Concept nvp = Dictionary.getConcept(Dictionary.NEVIRAPINE); Concept nvpazt3tc = Dictionary.getConcept(Dictionary.LAMIVUDINE_NEVIRAPINE_ZIDOVUDINE); Concept hivExposed = Dictionary.getConcept(Dictionary.EXPOSURE_TO_HIV); CalculationResultMap ret = new CalculationResultMap(); for (Integer ptId : cohort) { boolean notOnPcp = false; Obs hivStatusObs = EmrCalculationUtils.obsResultForPatient(lastChildHivStatus, ptId); if (inMchcsProgram.contains(ptId) && lastChildHivStatus != null && hivStatusObs !=null && (hivStatusObs.getValueCoded().equals(hivExposed))) { notOnPcp = true; ListResult patientMedOrders = (ListResult) medOrdersObss.get(ptId); if (patientMedOrders != null) { List<Obs> medOrderObsList = CalculationUtils.extractResultValues(patientMedOrders); for (Obs medOrderObs : medOrderObsList) { if (medOrderObs.getValueCoded().equals(nvp) || medOrderObs.getValueCoded().equals(nvpazt3tc)) { notOnPcp = false; break; } } } } ret.put(ptId, new BooleanResult(notOnPcp, this, context)); } return ret; }  @Override CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> parameterValues, PatientCalculationContext context); }
InfantNeverTakenProphylaxisCalculation extends AbstractPatientCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> parameterValues, PatientCalculationContext context) { Program mchcsProgram = MetadataUtils.existing(Program.class, MchMetadata._Program.MCHCS); Set<Integer> alive = Filters.alive(cohort, context); Set<Integer> inMchcsProgram = Filters.inProgram(mchcsProgram, alive, context); CalculationResultMap lastChildHivStatus = Calculations.lastObs(Dictionary.getConcept(Dictionary.CHILDS_CURRENT_HIV_STATUS), inMchcsProgram, context); CalculationResultMap medOrdersObss = Calculations.allObs(Dictionary.getConcept(Dictionary.MEDICATION_ORDERS), cohort, context); Concept nvp = Dictionary.getConcept(Dictionary.NEVIRAPINE); Concept nvpazt3tc = Dictionary.getConcept(Dictionary.LAMIVUDINE_NEVIRAPINE_ZIDOVUDINE); Concept hivExposed = Dictionary.getConcept(Dictionary.EXPOSURE_TO_HIV); CalculationResultMap ret = new CalculationResultMap(); for (Integer ptId : cohort) { boolean notOnPcp = false; Obs hivStatusObs = EmrCalculationUtils.obsResultForPatient(lastChildHivStatus, ptId); if (inMchcsProgram.contains(ptId) && lastChildHivStatus != null && hivStatusObs !=null && (hivStatusObs.getValueCoded().equals(hivExposed))) { notOnPcp = true; ListResult patientMedOrders = (ListResult) medOrdersObss.get(ptId); if (patientMedOrders != null) { List<Obs> medOrderObsList = CalculationUtils.extractResultValues(patientMedOrders); for (Obs medOrderObs : medOrderObsList) { if (medOrderObs.getValueCoded().equals(nvp) || medOrderObs.getValueCoded().equals(nvpazt3tc)) { notOnPcp = false; break; } } } } ret.put(ptId, new BooleanResult(notOnPcp, this, context)); } return ret; }  @Override CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> parameterValues, PatientCalculationContext context);  }