Program: 115084
Project: 115084
Buggy source:
private ODM getODM(String studyOID,String subjectKey){
  String ssoid=subjectKey;
  if (ssoid == null) {
    return null;
  }
  StudyEventDAO eventDAO=new StudyEventDAO(dataSource);
  CRFVersionDAO versionDAO=new CRFVersionDAO(dataSource);
  StudyDAO studyDAO=new StudyDAO(dataSource);
  StudySubjectDAO studySubjectDAO=new StudySubjectDAO(dataSource);
  EventCRFDAO eventCRFDAO=new EventCRFDAO(dataSource);
  ItemDataDAO itemDataDAO=new ItemDataDAO(dataSource);
  CRFDAO crfDAO=new CRFDAO(dataSource);
  List<ODMcomplexTypeDefinitionFormData> formDatas=new ArrayList<>();
  try {
    StudyEventBean nextEvent=(StudyEventBean)eventDAO.getNextScheduledEvent(ssoid);
    logger.debug("String_Node_Str" + nextEvent.getName() + "String_Node_Str"+ nextEvent.getId());
    ArrayList<CRFVersionBean> crfs=versionDAO.findDefCRFVersionsByStudyEvent(nextEvent.getStudyEventDefinitionId());
    List<EventCRFBean> eventCrfs=eventCRFDAO.findAllByStudyEvent(nextEvent);
    StudyBean study=studyDAO.findByOid(studyOID);
    StudySubjectBean studySubjectBean=studySubjectDAO.findByOid(ssoid);
    for (    CRFVersionBean crfVersion : crfs) {
      boolean itemDataExists=false;
      boolean validStatus=true;
      for (      EventCRFBean eventCrf : eventCrfs) {
        if (eventCrf.getCRFVersionId() == crfVersion.getId()) {
          int eventStatus=eventCrf.getStatus().getId();
          if (eventStatus != 1 && eventStatus != 2)           validStatus=false;
          if (eventStatus == 1 && itemDataDAO.findAllByEventCRFId(eventCrf.getId()).size() > 0)           itemDataExists=true;
        }
      }
      if (!itemDataExists && validStatus) {
        String formUrl=createEnketoUrl(studyOID,crfVersion,nextEvent,ssoid);
        formDatas.add(getFormDataPerCrf(crfVersion,nextEvent,eventCrfs,crfDAO,formUrl));
      }
    }
    return createOdm(study,studySubjectBean,nextEvent,formDatas);
  }
 catch (  Exception e) {
    logger.debug(e.getMessage());
    logger.debug(ExceptionUtils.getStackTrace(e));
  }
  return null;
}

Fixed version (ground truth):
private ODM getODM(String studyOID,String subjectKey){
  ODM odm=new ODM();
  String ssId=subjectKey;
  if (ssId == null) {
    return null;
  }
  StudyEventDAO eventDAO=new StudyEventDAO(dataSource);
  CRFVersionDAO versionDAO=new CRFVersionDAO(dataSource);
  StudyDAO studyDAO=new StudyDAO(dataSource);
  StudySubjectDAO studySubjectDAO=new StudySubjectDAO(dataSource);
  EventCRFDAO eventCRFDAO=new EventCRFDAO(dataSource);
  ItemDataDAO itemDataDAO=new ItemDataDAO(dataSource);
  CRFDAO crfDAO=new CRFDAO(dataSource);
  List<ODMcomplexTypeDefinitionFormData> formDatas=new ArrayList<>();
  try {
    StudyBean study=studyDAO.findByOid(studyOID);
    StudySubjectBean studySubjectBean=studySubjectDAO.findByLabelAndStudy(ssId,study);
    if (studySubjectBean != null && studySubjectBean.getId() != 0) {
      StudyEventBean nextEvent=(StudyEventBean)eventDAO.getNextScheduledEvent(studySubjectBean.getOid());
      logger.debug("String_Node_Str" + nextEvent.getName() + "String_Node_Str"+ nextEvent.getId());
      ArrayList<CRFVersionBean> crfs=versionDAO.findDefCRFVersionsByStudyEvent(nextEvent.getStudyEventDefinitionId());
      List<EventCRFBean> eventCrfs=eventCRFDAO.findAllByStudyEvent(nextEvent);
      for (      CRFVersionBean crfVersion : crfs) {
        boolean itemDataExists=false;
        boolean validStatus=true;
        for (        EventCRFBean eventCrf : eventCrfs) {
          if (eventCrf.getCRFVersionId() == crfVersion.getId()) {
            int eventStatus=eventCrf.getStatus().getId();
            if (eventStatus != 1 && eventStatus != 2)             validStatus=false;
            if (eventStatus == 1 && itemDataDAO.findAllByEventCRFId(eventCrf.getId()).size() > 0)             itemDataExists=true;
          }
        }
        if (!itemDataExists && validStatus) {
          String formUrl=createEnketoUrl(studyOID,crfVersion,nextEvent,studySubjectBean.getOid());
          formDatas.add(getFormDataPerCrf(crfVersion,nextEvent,eventCrfs,crfDAO,formUrl));
        }
      }
      return createOdm(study,studySubjectBean,nextEvent,formDatas);
    }
  }
 catch (  Exception e) {
    logger.debug(e.getMessage());
    logger.debug(ExceptionUtils.getStackTrace(e));
  }
  return odm;
}