Program: 84549
Project: 84549
Buggy source:
/** 
 * Called prior to form display. Allows for data to be put in the request to be used in the view
 * @see org.springframework.web.servlet.mvc.SimpleFormController#referenceData(javax.servlet.http.HttpServletRequest)
 */
protected Map<String,Object> referenceData(HttpServletRequest request,Object obj,Errors err) throws Exception {
  Patient patient=(Patient)obj;
  List<Form> forms=new Vector<Form>();
  Map<String,Object> map=new HashMap<String,Object>();
  List<Encounter> encounters=new Vector<Encounter>();
  if (Context.isAuthenticated() && patient.getPatientId() != null) {
    boolean onlyPublishedForms=true;
    if (Context.hasPrivilege(OpenmrsConstants.PRIV_VIEW_UNPUBLISHED_FORMS))     onlyPublishedForms=false;
    forms.addAll(Context.getFormService().getForms(null,onlyPublishedForms,null,false,null,null,null));
    List<Encounter> encs=Context.getEncounterService().getEncountersByPatient(patient);
    if (encs != null && encs.size() > 0)     encounters.addAll(encs);
  }
  String patientVariation="String_Node_Str";
  Concept reasonForExitConcept=Context.getConceptService().getConcept(Context.getAdministrationService().getGlobalProperty("String_Node_Str"));
  if (reasonForExitConcept != null && patient.getPatientId() != null) {
    List<Obs> patientExitObs=Context.getObsService().getObservationsByPersonAndConcept(patient,reasonForExitConcept);
    if (patientExitObs != null) {
      log.debug("String_Node_Str" + patientExitObs.size());
      if (patientExitObs.size() == 1) {
        Obs exitObs=patientExitObs.iterator().next();
        Concept exitReason=exitObs.getValueCoded();
        Date exitDate=exitObs.getObsDatetime();
        if (exitReason != null && exitDate != null) {
          patientVariation="String_Node_Str";
        }
      }
 else {
        log.error("String_Node_Str");
      }
    }
  }
  map.put("String_Node_Str",patientVariation);
  map.put("String_Node_Str",forms);
  map.put("String_Node_Str",new PatientIdentifier());
  map.put("String_Node_Str",new PersonName());
  map.put("String_Node_Str",new PersonAddress());
  map.put("String_Node_Str",encounters);
  super.setupReferenceData(map,patient);
  return map;
}

Fixed version (ground truth):
/** 
 * Called prior to form display. Allows for data to be put in the request to be used in the view
 * @see org.springframework.web.servlet.mvc.SimpleFormController#referenceData(javax.servlet.http.HttpServletRequest)
 */
protected Map<String,Object> referenceData(HttpServletRequest request,Object obj,Errors err) throws Exception {
  Patient patient=(Patient)obj;
  List<Form> forms=new Vector<Form>();
  Map<String,Object> map=new HashMap<String,Object>();
  List<Encounter> encounters=new Vector<Encounter>();
  if (Context.isAuthenticated() && patient.getPatientId() != null) {
    boolean onlyPublishedForms=true;
    if (Context.hasPrivilege(OpenmrsConstants.PRIV_VIEW_UNPUBLISHED_FORMS))     onlyPublishedForms=false;
    forms.addAll(Context.getFormService().getForms(null,onlyPublishedForms,null,false,null,null,null));
    List<Encounter> encs=Context.getEncounterService().getEncountersByPatient(patient);
    if (encs != null && encs.size() > 0)     encounters.addAll(encs);
  }
  String patientVariation="String_Node_Str";
  Concept reasonForExitConcept=Context.getConceptService().getConcept(Context.getAdministrationService().getGlobalProperty("String_Node_Str"));
  if (reasonForExitConcept != null && patient.getPatientId() != null) {
    List<Obs> patientExitObs=Context.getObsService().getObservationsByPersonAndConcept(patient,reasonForExitConcept);
    if (patientExitObs != null && patientExitObs.size() > 0) {
      log.debug("String_Node_Str" + patientExitObs.size());
      if (patientExitObs.size() == 1) {
        Obs exitObs=patientExitObs.iterator().next();
        Concept exitReason=exitObs.getValueCoded();
        Date exitDate=exitObs.getObsDatetime();
        if (exitReason != null && exitDate != null) {
          patientVariation="String_Node_Str";
        }
      }
 else {
        log.error("String_Node_Str");
      }
    }
  }
  map.put("String_Node_Str",patientVariation);
  map.put("String_Node_Str",forms);
  map.put("String_Node_Str",new PatientIdentifier());
  map.put("String_Node_Str",new PersonName());
  map.put("String_Node_Str",new PersonAddress());
  map.put("String_Node_Str",encounters);
  super.setupReferenceData(map,patient);
  return map;
}