Search in sources :

Example 81 with EventDefinitionCRFDAO

use of org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO in project OpenClinica by OpenClinica.

the class SignStudySubjectServlet method getDisplayEventCRFs.

/**
     * Each of the event CRFs with its corresponding CRFBean. Then generates a
     * list of DisplayEventCRFBeans, one for each event CRF.
     *
     * @param eventCRFs
     *            The list of event CRFs for this study event.
     * @return The list of DisplayEventCRFBeans for this study event.
     */
public static ArrayList getDisplayEventCRFs(StudyBean study, DataSource ds, ArrayList eventCRFs, UserAccountBean ub, StudyUserRoleBean currentRole, SubjectEventStatus status) {
    ArrayList answer = new ArrayList();
    // HashMap definitionsById = new HashMap();
    int i;
    /*
         * for (i = 0; i < eventDefinitionCRFs.size(); i++) {
         * EventDefinitionCRFBean edc = (EventDefinitionCRFBean)
         * eventDefinitionCRFs.get(i); definitionsById.put(new
         * Integer(edc.getStudyEventDefinitionId()), edc); }
         */
    StudyEventDAO sedao = new StudyEventDAO(ds);
    CRFDAO cdao = new CRFDAO(ds);
    CRFVersionDAO cvdao = new CRFVersionDAO(ds);
    ItemDataDAO iddao = new ItemDataDAO(ds);
    EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(ds);
    for (i = 0; i < eventCRFs.size(); i++) {
        EventCRFBean ecb = (EventCRFBean) eventCRFs.get(i);
        // populate the event CRF with its crf bean
        int crfVersionId = ecb.getCRFVersionId();
        CRFBean cb = cdao.findByVersionId(crfVersionId);
        ecb.setCrf(cb);
        CRFVersionBean cvb = (CRFVersionBean) cvdao.findByPK(crfVersionId);
        ecb.setCrfVersion(cvb);
        // then get the definition so we can call
        // DisplayEventCRFBean.setFlags
        int studyEventId = ecb.getStudyEventId();
        int studyEventDefinitionId = sedao.getDefinitionIdFromStudyEventId(studyEventId);
        // EventDefinitionCRFBean edc = (EventDefinitionCRFBean)
        // definitionsById.get(new Integer(
        // studyEventDefinitionId));
        // fix problem of the above code(commented out), find the correct
        // edc, note that on definitionId can be related to multiple
        // eventdefinitioncrfBeans
        EventDefinitionCRFBean edc = edcdao.findByStudyEventDefinitionIdAndCRFId(study, studyEventDefinitionId, cb.getId());
        // rules updated 112007 tbh
        if (status.equals(SubjectEventStatus.LOCKED) || status.equals(SubjectEventStatus.SKIPPED) || status.equals(SubjectEventStatus.STOPPED)) {
            ecb.setStage(DataEntryStage.LOCKED);
        // we need to set a SED-wide flag here, because other edcs
        // in this event can be filled in and change the status, tbh
        } else if (status.equals(SubjectEventStatus.INVALID)) {
            ecb.setStage(DataEntryStage.LOCKED);
        } else if (!cb.getStatus().equals(Status.AVAILABLE)) {
            ecb.setStage(DataEntryStage.LOCKED);
        } else if (!cvb.getStatus().equals(Status.AVAILABLE)) {
            ecb.setStage(DataEntryStage.LOCKED);
        }
        // TODO need to refactor since this is similar to other code, tbh
        if (edc != null) {
            // System.out.println("edc is not null, need to set flags");
            DisplayEventCRFBean dec = new DisplayEventCRFBean();
            // System.out.println("edc.isDoubleEntry()" +
            // edc.isDoubleEntry() + ecb.getId());
            dec.setFlags(ecb, ub, currentRole, edc.isDoubleEntry());
            //                if (dec.isLocked()) {
            //                    System.out.println("*** found a locked DEC: " + edc.getCrfName());
            //                }
            ArrayList idata = iddao.findAllByEventCRFId(ecb.getId());
            if (!idata.isEmpty()) {
                // consider an event crf started only if item data get
                // created
                answer.add(dec);
            }
        }
    }
    return answer;
}
Also used : DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) ArrayList(java.util.ArrayList) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean)

Example 82 with EventDefinitionCRFDAO

use of org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO in project OpenClinica by OpenClinica.

the class TableOfContentsServlet method getDisplayBean.

public static DisplayTableOfContentsBean getDisplayBean(EventCRFBean ecb, DataSource ds, StudyBean currentStudy) {
    DisplayTableOfContentsBean answer = new DisplayTableOfContentsBean();
    answer.setEventCRF(ecb);
    // get data
    StudySubjectDAO ssdao = new StudySubjectDAO(ds);
    StudySubjectBean ssb = (StudySubjectBean) ssdao.findByPK(ecb.getStudySubjectId());
    answer.setStudySubject(ssb);
    StudyEventDAO sedao = new StudyEventDAO(ds);
    StudyEventBean seb = (StudyEventBean) sedao.findByPK(ecb.getStudyEventId());
    answer.setStudyEvent(seb);
    SectionDAO sdao = new SectionDAO(ds);
    ArrayList sections = getSections(ecb, ds);
    answer.setSections(sections);
    // get metadata
    StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(ds);
    StudyEventDefinitionBean sedb = (StudyEventDefinitionBean) seddao.findByPK(seb.getStudyEventDefinitionId());
    answer.setStudyEventDefinition(sedb);
    CRFVersionDAO cvdao = new CRFVersionDAO(ds);
    CRFVersionBean cvb = (CRFVersionBean) cvdao.findByPK(ecb.getCRFVersionId());
    answer.setCrfVersion(cvb);
    CRFDAO cdao = new CRFDAO(ds);
    CRFBean cb = (CRFBean) cdao.findByPK(cvb.getCrfId());
    answer.setCrf(cb);
    StudyBean studyForStudySubject = new StudyDAO(ds).findByStudySubjectId(ssb.getId());
    EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(ds);
    EventDefinitionCRFBean edcb = edcdao.findByStudyEventDefinitionIdAndCRFId(studyForStudySubject, sedb.getId(), cb.getId());
    answer.setEventDefinitionCRF(edcb);
    answer.setAction(getActionForStage(ecb.getStage()));
    return answer;
}
Also used : EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) DisplayTableOfContentsBean(org.akaza.openclinica.bean.submit.DisplayTableOfContentsBean) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) SectionDAO(org.akaza.openclinica.dao.submit.SectionDAO)

Example 83 with EventDefinitionCRFDAO

use of org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO in project OpenClinica by OpenClinica.

the class CrfBusinessLogicHelper method noneAreRequired.

protected boolean noneAreRequired(StudyEventBean seBean, StudyBean study) {
    boolean noneAreRequired = true;
    EventDefinitionCRFDAO edcDao = new EventDefinitionCRFDAO(ds);
    ArrayList allEDCs = (ArrayList) edcDao.findAllActiveByEventDefinitionId(study, seBean.getStudyEventDefinitionId());
    logger.info("found all EDCs: " + allEDCs.size());
    for (int i = 0; i < allEDCs.size(); i++) {
        EventDefinitionCRFBean ec = (EventDefinitionCRFBean) allEDCs.get(i);
        logger.info("found crf name: " + ec.getCrfName());
        if (ec.isRequiredCRF()) {
            noneAreRequired = false;
            break;
        }
    }
    logger.info("returning for none are required: " + noneAreRequired);
    return noneAreRequired;
}
Also used : ArrayList(java.util.ArrayList) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 84 with EventDefinitionCRFDAO

use of org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO in project OpenClinica by OpenClinica.

the class CrfBusinessLogicHelper method areAllRequiredCompleted.

protected boolean areAllRequiredCompleted(StudyEventBean seBean, StudyBean study) {
    EventDefinitionCRFDAO edcDao = new EventDefinitionCRFDAO(ds);
    EventCRFDAO eventCrfDao = new EventCRFDAO(ds);
    ArrayList allCRFs = eventCrfDao.findAllByStudyEvent(seBean);
    ArrayList allEDCs = (ArrayList) edcDao.findAllActiveByEventDefinitionId(study, seBean.getStudyEventDefinitionId());
    boolean eventRequiredCompleted = true;
    // while allEDCs return all event defs in an event
    for (int i = 0; i < allCRFs.size(); i++) {
        EventCRFBean ec = (EventCRFBean) allCRFs.get(i);
        EventDefinitionCRFBean edcBean = edcDao.findByStudyEventIdAndCRFVersionId(study, seBean.getId(), ec.getCRFVersionId());
        if (!ec.getStatus().equals(Status.UNAVAILABLE) && edcBean.isRequiredCRF()) {
            // if it's not done but required, return FALSE
            eventRequiredCompleted = false;
            break;
        }
    }
    if (allCRFs.size() < allEDCs.size()) {
        // since we found one that we didn't catch before
        for (int i = 0; i < allEDCs.size(); i++) {
            EventDefinitionCRFBean ec = (EventDefinitionCRFBean) allEDCs.get(i);
            if (ec.isRequiredCRF()) {
                eventRequiredCompleted = false;
                break;
            }
        }
    }
    logger.info("returning for event required completed: " + eventRequiredCompleted);
    return eventRequiredCompleted;
}
Also used : EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) ArrayList(java.util.ArrayList) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO)

Aggregations

EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)84 ArrayList (java.util.ArrayList)72 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)58 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)53 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)51 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)47 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)45 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)45 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)41 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)41 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)40 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)39 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)39 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)36 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)35 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)30 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)28 Date (java.util.Date)27 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)27 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)26