Program: 189663
Project: 189663
Buggy source:
@Override public CalculationResultMap evaluate(Collection<Integer> cohort,Map<String,Object> parameterValues,PatientCalculationContext context){
  Program tbProgram=MetadataUtils.existing(Program.class,TbMetadata._Program.TB);
  EncounterType tbScreening=MetadataUtils.existing(EncounterType.class,TbMetadata._EncounterType.TB_SCREENING);
  Set<Integer> alive=Filters.alive(cohort,context);
  Set<Integer> inTbProgram=Filters.inProgram(tbProgram,alive,context);
  CalculationResultMap ret=new CalculationResultMap();
  CalculationResultMap lastEncounterMap=Calculations.lastEncounter(null,alive,context);
  CalculationResultMap lastTbScreeningMap=Calculations.lastEncounter(tbScreening,alive,context);
  for (  Integer ptId : cohort) {
    Boolean missedScreening=false;
    if (alive.contains(ptId) && !inTbProgram.contains(ptId)) {
      Encounter lastEncounter=EmrCalculationUtils.encounterResultForPatient(lastEncounterMap,ptId);
      Encounter lastTbScreeningEncounter=EmrCalculationUtils.encounterResultForPatient(lastTbScreeningMap,ptId);
      DateTime lastEncounterDate=lastEncounter != null ? new DateTime(lastEncounter.getEncounterDatetime()) : null;
      DateTime lastTbScreeningDate=lastTbScreeningEncounter != null ? new DateTime(lastTbScreeningEncounter.getEncounterDatetime()) : null;
      if ((lastTbScreeningDate != null && lastEncounterDate != null)) {
        if (Math.abs(DateTimeComparator.getDateOnlyInstance().compare(lastTbScreeningDate,lastEncounterDate)) > 1) {
          missedScreening=true;
        }
      }
      ret.put(ptId,new BooleanResult(missedScreening,this));
    }
  }
  return ret;
}

Fixed version (ground truth):
@Override public CalculationResultMap evaluate(Collection<Integer> cohort,Map<String,Object> parameterValues,PatientCalculationContext context){
  Program tbProgram=MetadataUtils.existing(Program.class,TbMetadata._Program.TB);
  EncounterType tbScreening=MetadataUtils.existing(EncounterType.class,TbMetadata._EncounterType.TB_SCREENING);
  Set<Integer> alive=Filters.alive(cohort,context);
  Set<Integer> inTbProgram=Filters.inProgram(tbProgram,alive,context);
  CalculationResultMap ret=new CalculationResultMap();
  CalculationResultMap lastEncounterMap=Calculations.lastEncounter(null,alive,context);
  CalculationResultMap lastTbScreeningMap=Calculations.lastEncounter(tbScreening,alive,context);
  for (  Integer ptId : cohort) {
    Boolean missedScreening=false;
    if (alive.contains(ptId) && !inTbProgram.contains(ptId)) {
      Encounter lastEncounter=EmrCalculationUtils.encounterResultForPatient(lastEncounterMap,ptId);
      Encounter lastTbScreeningEncounter=EmrCalculationUtils.encounterResultForPatient(lastTbScreeningMap,ptId);
      DateTime lastEncounterDate=lastEncounter != null ? new DateTime(lastEncounter.getEncounterDatetime()) : null;
      DateTime lastTbScreeningDate=lastTbScreeningEncounter != null ? new DateTime(lastTbScreeningEncounter.getEncounterDatetime()) : null;
      if ((lastTbScreeningDate != null && lastEncounterDate != null)) {
        if (Math.abs(DateTimeComparator.getDateOnlyInstance().compare(lastTbScreeningDate,lastEncounterDate)) > 1) {
          missedScreening=true;
        }
      }
    }
    ret.put(ptId,new BooleanResult(missedScreening,this,context));
  }
  return ret;
}