Program: 189667
Project: 189667
Buggy source:
/** 
 * @see org.openmrs.calculation.patient.PatientCalculation#evaluate(java.util.Collection,java.util.Map,org.openmrs.calculation.patient.PatientCalculationContext)
 */
@Override public CalculationResultMap evaluate(Collection<Integer> cohort,Map<String,Object> parameterValues,PatientCalculationContext context){
  Program mchcsProgram=MetadataUtils.getProgram(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 lastHivRapidTest1=Calculations.lastObs(Dictionary.getConcept(Dictionary.HIV_RAPID_TEST_1_QUALITATIVE),inMchcsProgram,context);
  CalculationResultMap lastHivRapidTest2=Calculations.lastObs(Dictionary.getConcept(Dictionary.HIV_RAPID_TEST_2_QUALITATIVE),inMchcsProgram,context);
  Concept hivExposed=Dictionary.getConcept(Dictionary.EXPOSURE_TO_HIV);
  CalculationResultMap ret=new CalculationResultMap();
  for (  Integer ptId : cohort) {
    boolean needsAntibody=false;
    if (inMchcsProgram.contains(ptId) && lastChildHivStatus != null) {
      Obs hivStatusObs=EmrCalculationUtils.obsResultForPatient(lastChildHivStatus,ptId);
      Obs rapidTest1=EmrCalculationUtils.obsResultForPatient(lastHivRapidTest1,ptId);
      Obs rapidTest2=EmrCalculationUtils.obsResultForPatient(lastHivRapidTest2,ptId);
      if (rapidTest1 == null && rapidTest2 == null && (hivStatusObs.getValueCoded().equals(hivExposed))) {
        needsAntibody=true;
      }
    }
    ret.put(ptId,new BooleanResult(needsAntibody,this,context));
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * @see org.openmrs.calculation.patient.PatientCalculation#evaluate(java.util.Collection,java.util.Map,org.openmrs.calculation.patient.PatientCalculationContext)
 */
@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 lastHivRapidTest1=Calculations.lastObs(Dictionary.getConcept(Dictionary.HIV_RAPID_TEST_1_QUALITATIVE),inMchcsProgram,context);
  CalculationResultMap lastHivRapidTest2=Calculations.lastObs(Dictionary.getConcept(Dictionary.HIV_RAPID_TEST_2_QUALITATIVE),inMchcsProgram,context);
  Concept hivExposed=Dictionary.getConcept(Dictionary.EXPOSURE_TO_HIV);
  CalculationResultMap ret=new CalculationResultMap();
  for (  Integer ptId : cohort) {
    boolean needsAntibody=false;
    if (inMchcsProgram.contains(ptId)) {
      Obs hivStatusObs=EmrCalculationUtils.obsResultForPatient(lastChildHivStatus,ptId);
      Obs rapidTest1=EmrCalculationUtils.obsResultForPatient(lastHivRapidTest1,ptId);
      Obs rapidTest2=EmrCalculationUtils.obsResultForPatient(lastHivRapidTest2,ptId);
      if (hivStatusObs != null && (hivStatusObs.getValueCoded().equals(hivExposed)) && rapidTest1 == null && rapidTest2 == null) {
        needsAntibody=true;
      }
    }
    ret.put(ptId,new BooleanResult(needsAntibody,this,context));
  }
  return ret;
}