Program: 86780
Project: 86780
Buggy source:
/** 
 * @see PersonDataEvaluator#evaluate(PersonDataDefinition,EvaluationContext)
 * @should return all ages on the date of the given definition
 */
public EvaluatedPersonData evaluate(PersonDataDefinition definition,EvaluationContext context) throws EvaluationException {
  AgeAtDateOfOtherDataDefinition add=(AgeAtDateOfOtherDataDefinition)definition;
  EvaluatedPersonData birthdates=Context.getService(PersonDataService.class).evaluate(new BirthdateDataDefinition(),context);
  MappedData<? extends DataDefinition> effectiveDateDefinition=add.getEffectiveDateDefinition();
  BaseData effectiveDates;
  if (effectiveDateDefinition.getParameterizable() instanceof PersonDataDefinition) {
    effectiveDates=Context.getService(PersonDataService.class).evaluate((MappedData<PersonDataDefinition>)effectiveDateDefinition,context);
  }
 else   if (effectiveDateDefinition.getParameterizable() instanceof PatientDataDefinition) {
    effectiveDates=Context.getService(PatientDataService.class).evaluate((MappedData<PatientDataDefinition>)effectiveDateDefinition,context);
  }
 else {
    throw new EvaluationException("String_Node_Str");
  }
  List<DataConverter> converters=effectiveDateDefinition.getConverters();
  if (converters != null && converters.size() > 0) {
    for (    Integer pId : effectiveDates.getData().keySet()) {
      Object convertedValue=DataUtil.convertData(effectiveDates.getData().get(pId),converters);
      effectiveDates.addData(pId,convertedValue);
    }
  }
  EvaluatedPersonData ret=new EvaluatedPersonData(definition,context);
  BirthdateToAgeConverter converter=new BirthdateToAgeConverter();
  for (  Integer personId : birthdates.getData().keySet()) {
    Object birthdate=birthdates.getData().get(personId);
    converter.setEffectiveDate((Date)effectiveDates.getData().get(personId));
    ret.addData(personId,converter.convert(birthdate));
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * @see PersonDataEvaluator#evaluate(PersonDataDefinition,EvaluationContext)
 * @should return all ages on the date of the given definition
 */
public EvaluatedPersonData evaluate(PersonDataDefinition definition,EvaluationContext context) throws EvaluationException {
  AgeAtDateOfOtherDataDefinition add=(AgeAtDateOfOtherDataDefinition)definition;
  EvaluatedPersonData birthdates=Context.getService(PersonDataService.class).evaluate(new BirthdateDataDefinition(),context);
  MappedData<? extends DataDefinition> effectiveDateDefinition=add.getEffectiveDateDefinition();
  BaseData effectiveDates;
  if (effectiveDateDefinition.getParameterizable() instanceof PersonDataDefinition) {
    effectiveDates=Context.getService(PersonDataService.class).evaluate((MappedData<PersonDataDefinition>)effectiveDateDefinition,context);
  }
 else   if (effectiveDateDefinition.getParameterizable() instanceof PatientDataDefinition) {
    effectiveDates=Context.getService(PatientDataService.class).evaluate((MappedData<PatientDataDefinition>)effectiveDateDefinition,context);
  }
 else {
    throw new EvaluationException("String_Node_Str");
  }
  List<DataConverter> converters=effectiveDateDefinition.getConverters();
  if (converters != null && converters.size() > 0) {
    for (    Integer pId : effectiveDates.getData().keySet()) {
      Object convertedValue=DataUtil.convertData(effectiveDates.getData().get(pId),converters);
      effectiveDates.addData(pId,convertedValue);
    }
  }
  EvaluatedPersonData ret=new EvaluatedPersonData(definition,context);
  BirthdateToAgeConverter converter=new BirthdateToAgeConverter();
  for (  Integer personId : birthdates.getData().keySet()) {
    Object birthdate=birthdates.getData().get(personId);
    Date dateOfOtherDefinition=(Date)effectiveDates.getData().get(personId);
    if (dateOfOtherDefinition != null) {
      converter.setEffectiveDate(dateOfOtherDefinition);
      ret.addData(personId,converter.convert(birthdate));
    }
 else {
      ret.addData(personId,null);
    }
  }
  return ret;
}