@Test public void evaluate_shouldReturnHivPatientsNotScreenedForTb() throws Exception { Program hivProgram = MetadataUtils.existing(Program.class, HivMetadata._Program.HIV); TestUtils.enrollInProgram(TestUtils.getPatient(2), hivProgram, TestUtils.date(2011, 1, 1)); TestUtils.enrollInProgram(TestUtils.getPatient(6), hivProgram, TestUtils.date(2011, 1, 1)); TestUtils.enrollInProgram(TestUtils.getPatient(7), hivProgram, TestUtils.date(2011, 1, 1)); Concept tbDiseaseStatus = Dictionary.getConcept(Dictionary.TUBERCULOSIS_DISEASE_STATUS); Concept diseaseSuspected = Dictionary.getConcept(Dictionary.DISEASE_SUSPECTED); Concept notAssessed = Dictionary.getConcept(Dictionary.NOT_ASSESSED); TestUtils.saveObs(TestUtils.getPatient(2), tbDiseaseStatus, notAssessed, TestUtils.date(2012, 6, 1)); TestUtils.saveObs(TestUtils.getPatient(7), tbDiseaseStatus, diseaseSuspected, TestUtils.date(2012, 6, 1)); TestUtils.saveObs(TestUtils.getPatient(8), tbDiseaseStatus, diseaseSuspected, TestUtils.date(2012, 6, 1)); List<Integer> ptIds = Arrays.asList(2, 6, 7, 8); CalculationResultMap resultMap = new NeverScreenedForTbCalculation().evaluate(ptIds, null, Context.getService(PatientCalculationService.class).createCalculationContext()); Assert.assertTrue((Boolean) resultMap.get(2).getValue()); Assert.assertTrue((Boolean) resultMap.get(6).getValue()); Assert.assertFalse((Boolean) resultMap.get(7).getValue()); Assert.assertFalse((Boolean) resultMap.get(8).getValue()); }
@Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> params, PatientCalculationContext context) { Program hivProgram = MetadataUtils.existing(Program.class, HivMetadata._Program.HIV); Program tbProgram = MetadataUtils.existing(Program.class, TbMetadata._Program.TB); Concept tbDiseaseStatus = Dictionary.getConcept(Dictionary.TUBERCULOSIS_DISEASE_STATUS); Concept diseaseSuspected = Dictionary.getConcept(Dictionary.DISEASE_SUSPECTED); Concept diseaseDiagnosed = Dictionary.getConcept(Dictionary.DISEASE_DIAGNOSED); Concept noSignsOrSymptoms = Dictionary.getConcept(Dictionary.NO_SIGNS_OR_SYMPTOMS_OF_DISEASE); Set<Integer> alive = Filters.alive(cohort, context); Set<Integer> inHivProgram = Filters.inProgram(hivProgram, alive, context); Set<Integer> inTbProgram = Filters.inProgram(tbProgram , alive ,context); CalculationResultMap screeningObs = Calculations.allObs(tbDiseaseStatus, cohort, context); CalculationResultMap ret = new CalculationResultMap(); for (Integer ptId : cohort) { boolean hivAndNeverScreened = false; if (inHivProgram.contains(ptId)) { hivAndNeverScreened = true; List<Obs> diseasesStatuses = CalculationUtils.extractResultValues((ListResult) screeningObs.get(ptId)); for (Obs diseaseStatus : diseasesStatuses) { if (diseaseSuspected.equals(diseaseStatus.getValueCoded()) || diseaseDiagnosed.equals(diseaseStatus.getValueCoded()) || noSignsOrSymptoms.equals(diseaseStatus.getValueCoded()) || inTbProgram.contains(ptId) ) { hivAndNeverScreened = false; break; } } } ret.put(ptId, new BooleanResult(hivAndNeverScreened, this, context)); } return ret; }
NeverScreenedForTbCalculation extends AbstractPatientCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> params, PatientCalculationContext context) { Program hivProgram = MetadataUtils.existing(Program.class, HivMetadata._Program.HIV); Program tbProgram = MetadataUtils.existing(Program.class, TbMetadata._Program.TB); Concept tbDiseaseStatus = Dictionary.getConcept(Dictionary.TUBERCULOSIS_DISEASE_STATUS); Concept diseaseSuspected = Dictionary.getConcept(Dictionary.DISEASE_SUSPECTED); Concept diseaseDiagnosed = Dictionary.getConcept(Dictionary.DISEASE_DIAGNOSED); Concept noSignsOrSymptoms = Dictionary.getConcept(Dictionary.NO_SIGNS_OR_SYMPTOMS_OF_DISEASE); Set<Integer> alive = Filters.alive(cohort, context); Set<Integer> inHivProgram = Filters.inProgram(hivProgram, alive, context); Set<Integer> inTbProgram = Filters.inProgram(tbProgram , alive ,context); CalculationResultMap screeningObs = Calculations.allObs(tbDiseaseStatus, cohort, context); CalculationResultMap ret = new CalculationResultMap(); for (Integer ptId : cohort) { boolean hivAndNeverScreened = false; if (inHivProgram.contains(ptId)) { hivAndNeverScreened = true; List<Obs> diseasesStatuses = CalculationUtils.extractResultValues((ListResult) screeningObs.get(ptId)); for (Obs diseaseStatus : diseasesStatuses) { if (diseaseSuspected.equals(diseaseStatus.getValueCoded()) || diseaseDiagnosed.equals(diseaseStatus.getValueCoded()) || noSignsOrSymptoms.equals(diseaseStatus.getValueCoded()) || inTbProgram.contains(ptId) ) { hivAndNeverScreened = false; break; } } } ret.put(ptId, new BooleanResult(hivAndNeverScreened, this, context)); } return ret; } }
NeverScreenedForTbCalculation extends AbstractPatientCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> params, PatientCalculationContext context) { Program hivProgram = MetadataUtils.existing(Program.class, HivMetadata._Program.HIV); Program tbProgram = MetadataUtils.existing(Program.class, TbMetadata._Program.TB); Concept tbDiseaseStatus = Dictionary.getConcept(Dictionary.TUBERCULOSIS_DISEASE_STATUS); Concept diseaseSuspected = Dictionary.getConcept(Dictionary.DISEASE_SUSPECTED); Concept diseaseDiagnosed = Dictionary.getConcept(Dictionary.DISEASE_DIAGNOSED); Concept noSignsOrSymptoms = Dictionary.getConcept(Dictionary.NO_SIGNS_OR_SYMPTOMS_OF_DISEASE); Set<Integer> alive = Filters.alive(cohort, context); Set<Integer> inHivProgram = Filters.inProgram(hivProgram, alive, context); Set<Integer> inTbProgram = Filters.inProgram(tbProgram , alive ,context); CalculationResultMap screeningObs = Calculations.allObs(tbDiseaseStatus, cohort, context); CalculationResultMap ret = new CalculationResultMap(); for (Integer ptId : cohort) { boolean hivAndNeverScreened = false; if (inHivProgram.contains(ptId)) { hivAndNeverScreened = true; List<Obs> diseasesStatuses = CalculationUtils.extractResultValues((ListResult) screeningObs.get(ptId)); for (Obs diseaseStatus : diseasesStatuses) { if (diseaseSuspected.equals(diseaseStatus.getValueCoded()) || diseaseDiagnosed.equals(diseaseStatus.getValueCoded()) || noSignsOrSymptoms.equals(diseaseStatus.getValueCoded()) || inTbProgram.contains(ptId) ) { hivAndNeverScreened = false; break; } } } ret.put(ptId, new BooleanResult(hivAndNeverScreened, this, context)); } return ret; }  }
NeverScreenedForTbCalculation extends AbstractPatientCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> params, PatientCalculationContext context) { Program hivProgram = MetadataUtils.existing(Program.class, HivMetadata._Program.HIV); Program tbProgram = MetadataUtils.existing(Program.class, TbMetadata._Program.TB); Concept tbDiseaseStatus = Dictionary.getConcept(Dictionary.TUBERCULOSIS_DISEASE_STATUS); Concept diseaseSuspected = Dictionary.getConcept(Dictionary.DISEASE_SUSPECTED); Concept diseaseDiagnosed = Dictionary.getConcept(Dictionary.DISEASE_DIAGNOSED); Concept noSignsOrSymptoms = Dictionary.getConcept(Dictionary.NO_SIGNS_OR_SYMPTOMS_OF_DISEASE); Set<Integer> alive = Filters.alive(cohort, context); Set<Integer> inHivProgram = Filters.inProgram(hivProgram, alive, context); Set<Integer> inTbProgram = Filters.inProgram(tbProgram , alive ,context); CalculationResultMap screeningObs = Calculations.allObs(tbDiseaseStatus, cohort, context); CalculationResultMap ret = new CalculationResultMap(); for (Integer ptId : cohort) { boolean hivAndNeverScreened = false; if (inHivProgram.contains(ptId)) { hivAndNeverScreened = true; List<Obs> diseasesStatuses = CalculationUtils.extractResultValues((ListResult) screeningObs.get(ptId)); for (Obs diseaseStatus : diseasesStatuses) { if (diseaseSuspected.equals(diseaseStatus.getValueCoded()) || diseaseDiagnosed.equals(diseaseStatus.getValueCoded()) || noSignsOrSymptoms.equals(diseaseStatus.getValueCoded()) || inTbProgram.contains(ptId) ) { hivAndNeverScreened = false; break; } } } ret.put(ptId, new BooleanResult(hivAndNeverScreened, this, context)); } return ret; }  @Override CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> params, PatientCalculationContext context); }
NeverScreenedForTbCalculation extends AbstractPatientCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> params, PatientCalculationContext context) { Program hivProgram = MetadataUtils.existing(Program.class, HivMetadata._Program.HIV); Program tbProgram = MetadataUtils.existing(Program.class, TbMetadata._Program.TB); Concept tbDiseaseStatus = Dictionary.getConcept(Dictionary.TUBERCULOSIS_DISEASE_STATUS); Concept diseaseSuspected = Dictionary.getConcept(Dictionary.DISEASE_SUSPECTED); Concept diseaseDiagnosed = Dictionary.getConcept(Dictionary.DISEASE_DIAGNOSED); Concept noSignsOrSymptoms = Dictionary.getConcept(Dictionary.NO_SIGNS_OR_SYMPTOMS_OF_DISEASE); Set<Integer> alive = Filters.alive(cohort, context); Set<Integer> inHivProgram = Filters.inProgram(hivProgram, alive, context); Set<Integer> inTbProgram = Filters.inProgram(tbProgram , alive ,context); CalculationResultMap screeningObs = Calculations.allObs(tbDiseaseStatus, cohort, context); CalculationResultMap ret = new CalculationResultMap(); for (Integer ptId : cohort) { boolean hivAndNeverScreened = false; if (inHivProgram.contains(ptId)) { hivAndNeverScreened = true; List<Obs> diseasesStatuses = CalculationUtils.extractResultValues((ListResult) screeningObs.get(ptId)); for (Obs diseaseStatus : diseasesStatuses) { if (diseaseSuspected.equals(diseaseStatus.getValueCoded()) || diseaseDiagnosed.equals(diseaseStatus.getValueCoded()) || noSignsOrSymptoms.equals(diseaseStatus.getValueCoded()) || inTbProgram.contains(ptId) ) { hivAndNeverScreened = false; break; } } } ret.put(ptId, new BooleanResult(hivAndNeverScreened, this, context)); } return ret; }  @Override CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> params, PatientCalculationContext context);  }