Program: 114992
Project: 114992
Buggy source:
private ArrayList<ExportFormDataBean> getFormDataForClinicalStudy(StudySubject ss,StudyEvent se,String formVersionOID){
  List<ExportFormDataBean> formDataBean=new ArrayList<ExportFormDataBean>();
  boolean formCheck=true;
  if (formVersionOID != null)   formCheck=false;
  boolean hiddenCrfCheckPassed=true;
  List<CrfBean> hiddenCrfs=new ArrayList<CrfBean>();
  for (  EventCrf ecrf : se.getEventCrfs()) {
    EventDefinitionCrf eventDefinitionCrf=null;
    List<EventDefinitionCrf> edcs=se.getStudyEventDefinition().getEventDefinitionCrfs();
    hiddenCrfCheckPassed=true;
    int siteId=0;
    int parentStudyId=0;
    Study study=ss.getStudy();
    if (study.getStudy() != null) {
      if (isActiveRoleAtSite) {
        siteId=study.getStudyId();
        parentStudyId=study.getStudy().getStudyId();
        hiddenCrfs=listOfHiddenCrfs(siteId,parentStudyId,edcs,ecrf);
      }
 else {
        parentStudyId=study.getStudy().getStudyId();
        hiddenCrfs=listOfHiddenCrfs(parentStudyId,parentStudyId,edcs,ecrf);
      }
      if (hiddenCrfs.contains(ecrf.getCrfVersion().getCrf())) {
        hiddenCrfCheckPassed=false;
      }
      eventDefinitionCrf=getEventDefinitionCrfDao().findByStudyEventDefinitionIdAndCRFIdAndStudyId(se.getStudyEventDefinition().getStudyEventDefinitionId(),ecrf.getFormLayout().getCrf().getCrfId(),study.getStudyId());
      if (eventDefinitionCrf == null) {
        eventDefinitionCrf=getEventDefinitionCrfDao().findByStudyEventDefinitionIdAndCRFIdAndStudyId(se.getStudyEventDefinition().getStudyEventDefinitionId(),ecrf.getFormLayout().getCrf().getCrfId(),study.getStudy().getStudyId());
      }
    }
 else {
      eventDefinitionCrf=getEventDefinitionCrfDao().findByStudyEventDefinitionIdAndCRFIdAndStudyId(se.getStudyEventDefinition().getStudyEventDefinitionId(),ecrf.getFormLayout().getCrf().getCrfId(),study.getStudyId());
    }
    if (hiddenCrfCheckPassed) {
      if (!formCheck) {
        if (ecrf.getCrfVersion().getOcOid().equals(formVersionOID))         formCheck=true;
 else         formCheck=false;
      }
      if (formCheck) {
        ExportFormDataBean dataBean=new ExportFormDataBean();
        dataBean.setEventDefinitionCrf(eventDefinitionCrf);
        dataBean.setEventCrf(ecrf);
        dataBean.setFormLayout(ecrf.getFormLayout());
        dataBean.setFormName(ecrf.getCrfVersion().getCrf().getName());
        dataBean.setItemGroupData(fetchItemData(ecrf.getCrfVersion().getItemGroupMetadatas(),ecrf.getEventCrfId(),ecrf.getCrfVersion().getVersioningMaps(),ecrf));
        dataBean.setFormOID(ecrf.getCrfVersion().getCrf().getOcOid());
        if (ecrf.getDateInterviewed() != null)         dataBean.setInterviewDate(ecrf.getDateInterviewed() + "String_Node_Str");
        if (ecrf.getInterviewerName() != null)         dataBean.setInterviewerName(ecrf.getInterviewerName());
        dataBean.setStatus(fetchEventCRFStatus(ecrf));
        dataBean.setCreatedDate(ecrf.getDateCreated());
        dataBean.setCreatedBy(ecrf.getUserAccount().getUserName());
        dataBean.setUpdatedDate(ecrf.getDateUpdated());
        UserAccount updatedUserAccount=userAccountDao.findById(ecrf.getUpdateId());
        dataBean.setUpdatedBy(updatedUserAccount.getUserName());
        if (ecrf.getFormLayout().getName() != null)         dataBean.setFormLayoutName(ecrf.getFormLayout().getName());
        if (collectAudits)         dataBean.setAuditLogs(fetchAuditLogs(ecrf.getEventCrfId(),"String_Node_Str",ecrf.getCrfVersion().getCrf().getOcOid(),null));
        if (collectDns)         dataBean.setDiscrepancyNotes(fetchDiscrepancyNotes(ecrf));
        formDataBean.add(dataBean);
        if (formVersionOID != null)         formCheck=false;
      }
    }
  }
  return (ArrayList<ExportFormDataBean>)formDataBean;
}

Fixed version (ground truth):
private ArrayList<ExportFormDataBean> getFormDataForClinicalStudy(Study study,StudySubject ss,StudyEvent se,String formVersionOID){
  List<ExportFormDataBean> formDataBean=new ArrayList<ExportFormDataBean>();
  boolean formCheck=true;
  if (formVersionOID != null)   formCheck=false;
  boolean hiddenCrfCheckPassed=true;
  List<CrfBean> hiddenCrfs=new ArrayList<CrfBean>();
  for (  EventCrf ecrf : se.getEventCrfs()) {
    EventDefinitionCrf eventDefinitionCrf=null;
    List<EventDefinitionCrf> edcs=se.getStudyEventDefinition().getEventDefinitionCrfs();
    hiddenCrfCheckPassed=true;
    int siteId=0;
    int parentStudyId=0;
    if (study.getStudy() != null) {
      if (isActiveRoleAtSite) {
        siteId=study.getStudyId();
        parentStudyId=study.getStudy().getStudyId();
        hiddenCrfs=listOfHiddenCrfs(siteId,parentStudyId,edcs,ecrf);
      }
 else {
        parentStudyId=study.getStudy().getStudyId();
        hiddenCrfs=listOfHiddenCrfs(parentStudyId,parentStudyId,edcs,ecrf);
      }
      if (hiddenCrfs.contains(ecrf.getCrfVersion().getCrf())) {
        hiddenCrfCheckPassed=false;
      }
      eventDefinitionCrf=getEventDefinitionCrfDao().findByStudyEventDefinitionIdAndCRFIdAndStudyId(se.getStudyEventDefinition().getStudyEventDefinitionId(),ecrf.getFormLayout().getCrf().getCrfId(),study.getStudyId());
      if (eventDefinitionCrf == null) {
        eventDefinitionCrf=getEventDefinitionCrfDao().findByStudyEventDefinitionIdAndCRFIdAndStudyId(se.getStudyEventDefinition().getStudyEventDefinitionId(),ecrf.getFormLayout().getCrf().getCrfId(),study.getStudy().getStudyId());
      }
    }
 else {
      eventDefinitionCrf=getEventDefinitionCrfDao().findByStudyEventDefinitionIdAndCRFIdAndStudyId(se.getStudyEventDefinition().getStudyEventDefinitionId(),ecrf.getFormLayout().getCrf().getCrfId(),study.getStudyId());
    }
    if (hiddenCrfCheckPassed) {
      if (!formCheck) {
        if (ecrf.getCrfVersion().getOcOid().equals(formVersionOID))         formCheck=true;
 else         formCheck=false;
      }
      if (formCheck) {
        ExportFormDataBean dataBean=new ExportFormDataBean();
        dataBean.setEventDefinitionCrf(eventDefinitionCrf);
        dataBean.setEventCrf(ecrf);
        dataBean.setFormLayout(ecrf.getFormLayout());
        dataBean.setFormName(ecrf.getCrfVersion().getCrf().getName());
        dataBean.setItemGroupData(fetchItemData(ecrf.getCrfVersion().getItemGroupMetadatas(),ecrf.getEventCrfId(),ecrf.getCrfVersion().getVersioningMaps(),ecrf));
        dataBean.setFormOID(ecrf.getCrfVersion().getCrf().getOcOid());
        if (ecrf.getDateInterviewed() != null)         dataBean.setInterviewDate(ecrf.getDateInterviewed() + "String_Node_Str");
        if (ecrf.getInterviewerName() != null)         dataBean.setInterviewerName(ecrf.getInterviewerName());
        dataBean.setStatus(fetchEventCRFStatus(ecrf));
        dataBean.setCreatedDate(ecrf.getDateCreated());
        dataBean.setCreatedBy(ecrf.getUserAccount().getUserName());
        dataBean.setUpdatedDate(ecrf.getDateUpdated());
        UserAccount updatedUserAccount=userAccountDao.findById(ecrf.getUpdateId());
        dataBean.setUpdatedBy(updatedUserAccount.getUserName());
        if (ecrf.getFormLayout().getName() != null)         dataBean.setFormLayoutName(ecrf.getFormLayout().getName());
        if (collectAudits)         dataBean.setAuditLogs(fetchAuditLogs(ecrf.getEventCrfId(),"String_Node_Str",ecrf.getCrfVersion().getCrf().getOcOid(),null));
        if (collectDns)         dataBean.setDiscrepancyNotes(fetchDiscrepancyNotes(ecrf));
        formDataBean.add(dataBean);
        if (formVersionOID != null)         formCheck=false;
      }
    }
  }
  return (ArrayList<ExportFormDataBean>)formDataBean;
}