Search in sources :

Example 86 with CRFVersionDAO

use of org.akaza.openclinica.dao.submit.CRFVersionDAO in project OpenClinica by OpenClinica.

the class PrintEventCRFServlet method processRequest.

@Override
public void processRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
    FormProcessor fp = new FormProcessor(request);
    StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
    SectionBean sb = (SectionBean) request.getAttribute(SECTION_BEAN);
    // The PrintDataEntry servlet handles this parameter
    int eventCRFId = fp.getInt("ecId");
    // JN:The following were the the global variables, moved as local.
    EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
    StudyEventDefinitionDAO sedao = new StudyEventDefinitionDAO(getDataSource());
    int defId = fp.getInt("id", true);
    boolean isSubmitted = false;
    ArrayList<SectionBean> allSectionBeans;
    if (defId == 0) {
        addPageMessage(respage.getString("please_choose_a_definition_to_view"), request);
        forwardPage(Page.LIST_DEFINITION_SERVLET, request, response);
    } else {
        // definition id
        StudyEventDefinitionBean sed = (StudyEventDefinitionBean) sedao.findByPK(defId);
        EventDefinitionCRFDAO edao = new EventDefinitionCRFDAO(getDataSource());
        ArrayList eventDefinitionCRFs = (ArrayList) edao.findAllByDefinition(defId);
        CRFVersionDAO cvdao = new CRFVersionDAO(getDataSource());
        CRFDAO cdao = new CRFDAO(getDataSource());
        ArrayList defaultVersions = new ArrayList();
        for (int i = 0; i < eventDefinitionCRFs.size(); i++) {
            EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
            ArrayList versions = (ArrayList) cvdao.findAllByCRF(edc.getCrfId());
            edc.setVersions(versions);
            CRFBean crf = (CRFBean) cdao.findByPK(edc.getCrfId());
            // edc.setCrfLabel(crf.getLabel());
            edc.setCrfName(crf.getName());
            // to show/hide edit action on jsp page
            if (crf.getStatus().equals(Status.AVAILABLE)) {
                edc.setOwner(crf.getOwner());
            }
            CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(edc.getDefaultVersionId());
            // There could be separate EventDefinitionCRF objects with same default version id.
            if (defaultVersions.contains(defaultVersion)) {
                continue;
            }
            edc.setDefaultVersionName(defaultVersion.getName());
            if (edc.getStatus().isAvailable()) {
                defaultVersions.add(defaultVersion);
            }
        }
        // Whether IE6 or IE7 is involved
        String isIE = fp.getString("ie");
        if ("y".equalsIgnoreCase(isIE)) {
            request.setAttribute("isInternetExplorer", "true");
        }
        int eventDefinitionCRFId = fp.getInt("eventDefinitionCRFId");
        // EventDefinitionCRFDao findByStudyEventIdAndCRFVersionId(int
        // studyEventId, int crfVersionId)
        SectionDAO sdao = new SectionDAO(getDataSource());
        CRFVersionDAO crfVersionDAO = new CRFVersionDAO(getDataSource());
        CRFDAO crfDao = new CRFDAO(getDataSource());
        ArrayList printCrfBeans = new ArrayList();
        for (Iterator it = defaultVersions.iterator(); it.hasNext(); ) {
            allSectionBeans = new ArrayList<SectionBean>();
            ArrayList sectionBeans = new ArrayList();
            CRFVersionBean crfVersionBean = (CRFVersionBean) it.next();
            // The existing application doesn't print null values, even if they are
            // defined in the event definition
            // int crfVersionId = fp.getInt("id");
            // BWP 2/7/2008>> Find out if the CRF has grouped tables, and if so,
            // use
            // that dedicated JSP
            ItemGroupDAO itemGroupDao = new ItemGroupDAO(getDataSource());
            // Find truely grouped tables, not groups with a name of 'Ungrouped'
            List<ItemGroupBean> itemGroupBeans = itemGroupDao.findOnlyGroupsByCRFVersionID(crfVersionBean.getId());
            CRFBean crfBean = crfDao.findByVersionId(crfVersionBean.getId());
            if (itemGroupBeans.size() > 0) {
                // get a DisplaySectionBean for each section of the CRF, sort
                // them, then
                // dispatch the request to a print JSP. The constructor for this
                // handler takes
                // a boolean value depending on whether data is involved or not
                // ('false' in terms of this
                // servlet; see PrintDataEntryServlet).
                DisplaySectionBeanHandler handler = new DisplaySectionBeanHandler(false, getDataSource(), getServletContext());
                handler.setCrfVersionId(crfVersionBean.getId());
                handler.setEventCRFId(eventCRFId);
                List<DisplaySectionBean> displaySectionBeans = handler.getDisplaySectionBeans();
                request.setAttribute("listOfDisplaySectionBeans", displaySectionBeans);
                // Make available the CRF names and versions for
                // the web page's header
                CRFVersionBean crfverBean = (CRFVersionBean) crfVersionDAO.findByPK(crfVersionBean.getId());
                request.setAttribute("crfVersionBean", crfverBean);
                request.setAttribute("crfBean", crfBean);
                // Set an attribute signaling that data is not involved
                request.setAttribute("dataInvolved", "false");
                PrintCRFBean printCrfBean = new PrintCRFBean();
                printCrfBean.setDisplaySectionBeans(displaySectionBeans);
                printCrfBean.setCrfVersionBean(crfVersionBean);
                printCrfBean.setCrfBean(crfBean);
                printCrfBean.setEventCrfBean(ecb);
                printCrfBeans.add(printCrfBean);
                printCrfBean.setGrouped(true);
                // IllegalStateException
                continue;
            }
            ecb = new EventCRFBean();
            ecb.setCRFVersionId(crfVersionBean.getId());
            CRFVersionBean version = (CRFVersionBean) crfVersionDAO.findByPK(crfVersionBean.getId());
            ArrayList sects = (ArrayList) sdao.findByVersionId(version.getId());
            for (int i = 0; i < sects.size(); i++) {
                sb = (SectionBean) sects.get(i);
                // super.sb = sb;
                int sectId = sb.getId();
                if (sectId > 0) {
                    allSectionBeans.add((SectionBean) sdao.findByPK(sectId));
                }
            }
            request.setAttribute(ALL_SECTION_BEANS, allSectionBeans);
            request.setAttribute(INPUT_EVENT_CRF, ecb);
            sectionBeans = super.getAllDisplayBeans(request);
            request.setAttribute(SECTION_BEAN, sb);
            DisplaySectionBean dsb = super.getDisplayBean(false, false, request, isSubmitted);
            // request.setAttribute("allSections", sectionBeans);
            // request.setAttribute("displayAllCRF", "1");
            // request.setAttribute(BEAN_DISPLAY, dsb);
            // request.setAttribute(BEAN_ANNOTATIONS, ecb.getAnnotations());
            // request.setAttribute("sec", sb);
            // request.setAttribute("EventCRFBean", super.ecb);
            PrintCRFBean printCrfBean = new PrintCRFBean();
            printCrfBean.setAllSections(sectionBeans);
            printCrfBean.setDisplaySectionBean(dsb);
            printCrfBean.setEventCrfBean(ecb);
            printCrfBean.setCrfVersionBean(crfVersionBean);
            printCrfBean.setCrfBean(crfBean);
            printCrfBeans.add(printCrfBean);
            printCrfBean.setGrouped(false);
        }
        String studyName = null;
        String siteName = null;
        if (currentStudy.getParentStudyId() > 0) {
            studyName = currentStudy.getParentStudyName();
            siteName = currentStudy.getName();
        } else {
            studyName = currentStudy.getName();
        }
        request.setAttribute("printCrfBeans", printCrfBeans);
        request.setAttribute("studyName", studyName);
        request.setAttribute("site", siteName);
        request.setAttribute("eventDefinition", sed.getName());
        forwardPage(Page.VIEW_DEFAULT_CRF_VERSIONS_PRINT, request, response);
    }
}
Also used : ArrayList(java.util.ArrayList) ItemGroupDAO(org.akaza.openclinica.dao.submit.ItemGroupDAO) PrintCRFBean(org.akaza.openclinica.bean.managestudy.PrintCRFBean) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) Iterator(java.util.Iterator) DisplaySectionBeanHandler(org.akaza.openclinica.view.display.DisplaySectionBeanHandler) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) PrintCRFBean(org.akaza.openclinica.bean.managestudy.PrintCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) DisplaySectionBean(org.akaza.openclinica.bean.submit.DisplaySectionBean) SectionBean(org.akaza.openclinica.bean.submit.SectionBean) DisplaySectionBean(org.akaza.openclinica.bean.submit.DisplaySectionBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) DisplayItemGroupBean(org.akaza.openclinica.bean.submit.DisplayItemGroupBean) ItemGroupBean(org.akaza.openclinica.bean.submit.ItemGroupBean) SectionDAO(org.akaza.openclinica.dao.submit.SectionDAO)

Example 87 with CRFVersionDAO

use of org.akaza.openclinica.dao.submit.CRFVersionDAO in project OpenClinica by OpenClinica.

the class RemoveEventDefinitionServlet method processRequest.

@Override
public void processRequest() throws Exception {
    String idString = request.getParameter("id");
    int defId = Integer.valueOf(idString.trim()).intValue();
    StudyEventDefinitionDAO sdao = new StudyEventDefinitionDAO(sm.getDataSource());
    StudyEventDefinitionBean sed = (StudyEventDefinitionBean) sdao.findByPK(defId);
    // checkRoleByUserAndStudy(ub.getName(), sed.getStudyId(), 0);
    if (currentStudy.getId() != sed.getStudyId()) {
        addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
        forwardPage(Page.MENU_SERVLET);
        return;
    }
    // find all CRFs
    EventDefinitionCRFDAO edao = new EventDefinitionCRFDAO(sm.getDataSource());
    ArrayList eventDefinitionCRFs = (ArrayList) edao.findAllByDefinition(defId);
    CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
    CRFDAO cdao = new CRFDAO(sm.getDataSource());
    for (int i = 0; i < eventDefinitionCRFs.size(); i++) {
        EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
        ArrayList versions = (ArrayList) cvdao.findAllByCRF(edc.getCrfId());
        edc.setVersions(versions);
        CRFBean crf = (CRFBean) cdao.findByPK(edc.getCrfId());
        edc.setCrfName(crf.getName());
        CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(edc.getDefaultVersionId());
        edc.setDefaultVersionName(defaultVersion.getName());
        CRFBean cBean = (CRFBean) cdao.findByPK(edc.getCrfId());
        String crfPath = sed.getOid() + "." + cBean.getOid();
        edc.setOffline(getEventDefinitionCrfTagService().getEventDefnCrfOfflineStatus(2, crfPath, true));
    }
    // finds all events
    StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
    ArrayList events = (ArrayList) sedao.findAllByDefinition(sed.getId());
    String action = request.getParameter("action");
    if (StringUtil.isBlank(idString)) {
        addPageMessage(respage.getString("please_choose_a_SED_to_remove"));
        forwardPage(Page.LIST_DEFINITION_SERVLET);
    } else {
        if ("confirm".equalsIgnoreCase(action)) {
            if (!sed.getStatus().equals(Status.AVAILABLE)) {
                addPageMessage(respage.getString("this_SED_is_not_available_for_this_study") + respage.getString("please_contact_sysadmin_for_more_information"));
                forwardPage(Page.LIST_DEFINITION_SERVLET);
                return;
            }
            StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
            String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
            if (participateFormStatus.equals("enabled"))
                baseUrl();
            request.setAttribute("participateFormStatus", participateFormStatus);
            request.setAttribute("definitionToRemove", sed);
            request.setAttribute("eventDefinitionCRFs", eventDefinitionCRFs);
            request.setAttribute("events", events);
            forwardPage(Page.REMOVE_DEFINITION);
        } else {
            logger.info("submit to remove the definition");
            // remove definition
            sed.setStatus(Status.DELETED);
            sed.setUpdater(ub);
            sed.setUpdatedDate(new Date());
            sdao.update(sed);
            // remove all crfs
            for (int j = 0; j < eventDefinitionCRFs.size(); j++) {
                EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.get(j);
                if (!edc.getStatus().equals(Status.DELETED)) {
                    edc.setStatus(Status.AUTO_DELETED);
                    edc.setUpdater(ub);
                    edc.setUpdatedDate(new Date());
                    edao.update(edc);
                }
            }
            // remove all events
            EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
            for (int j = 0; j < events.size(); j++) {
                StudyEventBean event = (StudyEventBean) events.get(j);
                if (!event.getStatus().equals(Status.DELETED)) {
                    event.setStatus(Status.AUTO_DELETED);
                    event.setUpdater(ub);
                    event.setUpdatedDate(new Date());
                    sedao.update(event);
                    ArrayList eventCRFs = ecdao.findAllByStudyEvent(event);
                    // remove all the item data
                    ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
                    for (int k = 0; k < eventCRFs.size(); k++) {
                        EventCRFBean eventCRF = (EventCRFBean) eventCRFs.get(k);
                        if (!eventCRF.getStatus().equals(Status.DELETED)) {
                            eventCRF.setStatus(Status.AUTO_DELETED);
                            eventCRF.setUpdater(ub);
                            eventCRF.setUpdatedDate(new Date());
                            ecdao.update(eventCRF);
                            ArrayList itemDatas = iddao.findAllByEventCRFId(eventCRF.getId());
                            for (int a = 0; a < itemDatas.size(); a++) {
                                ItemDataBean item = (ItemDataBean) itemDatas.get(a);
                                if (!item.getStatus().equals(Status.DELETED)) {
                                    item.setStatus(Status.AUTO_DELETED);
                                    item.setUpdater(ub);
                                    item.setUpdatedDate(new Date());
                                    iddao.update(item);
                                }
                            }
                        }
                    }
                }
            }
            String emailBody = respage.getString("the_SED") + sed.getName() + " " + respage.getString("has_been_removed_from_the_study") + currentStudy.getName() + ".";
            addPageMessage(emailBody);
            // sendEmail(emailBody);
            forwardPage(Page.LIST_DEFINITION_SERVLET);
        }
    }
}
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) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) Date(java.util.Date) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO)

Example 88 with CRFVersionDAO

use of org.akaza.openclinica.dao.submit.CRFVersionDAO in project OpenClinica by OpenClinica.

the class SignStudySubjectServlet method getUncompletedCRFs.

/**
 * Finds all the event definitions for which no event CRF exists - which is
 * the list of event definitions with uncompleted event CRFs.
 *
 * @param eventDefinitionCRFs
 *            All of the event definition CRFs for this study event.
 * @param eventCRFs
 *            All of the event CRFs for this study event.
 * @return The list of event definitions for which no event CRF exists.
 */
public static ArrayList getUncompletedCRFs(DataSource ds, ArrayList eventDefinitionCRFs, ArrayList eventCRFs, SubjectEventStatus status) {
    int i;
    HashMap completed = new HashMap();
    HashMap startedButIncompleted = new HashMap();
    ArrayList answer = new ArrayList();
    for (i = 0; i < eventDefinitionCRFs.size(); i++) {
        EventDefinitionCRFBean edcrf = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
        completed.put(new Integer(edcrf.getCrfId()), Boolean.FALSE);
        startedButIncompleted.put(new Integer(edcrf.getCrfId()), new EventCRFBean());
    }
    CRFVersionDAO cvdao = new CRFVersionDAO(ds);
    ItemDataDAO iddao = new ItemDataDAO(ds);
    for (i = 0; i < eventCRFs.size(); i++) {
        EventCRFBean ecrf = (EventCRFBean) eventCRFs.get(i);
        int crfId = cvdao.getCRFIdFromCRFVersionId(ecrf.getCRFVersionId());
        ArrayList idata = iddao.findAllByEventCRFId(ecrf.getId());
        if (!idata.isEmpty()) {
            // this crf has data already
            completed.put(new Integer(crfId), Boolean.TRUE);
        } else {
            // event crf got created, but no data entered
            startedButIncompleted.put(new Integer(crfId), ecrf);
        }
    }
    // TODO possible relation to 1689 here, tbh
    for (i = 0; i < eventDefinitionCRFs.size(); i++) {
        DisplayEventDefinitionCRFBean dedc = new DisplayEventDefinitionCRFBean();
        EventDefinitionCRFBean edcrf = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
        // System.out.println("created dedc with edcrf
        // "+edcrf.getCrfName()+" default version "+
        // edcrf.getDefaultVersionName()+", id
        // "+edcrf.getDefaultVersionId());
        dedc.setEdc(edcrf);
        // below added tbh, 112007 to fix bug 1943
        if (status.equals(SubjectEventStatus.LOCKED)) {
            dedc.setStatus(Status.LOCKED);
        }
        Boolean b = (Boolean) completed.get(new Integer(edcrf.getCrfId()));
        EventCRFBean ev = (EventCRFBean) startedButIncompleted.get(new Integer(edcrf.getCrfId()));
        if (b == null || !b.booleanValue()) {
            // System.out.println("entered boolean loop with ev
            // "+ev.getId()+" crf version id "+
            // ev.getCRFVersionId());
            dedc.setEventCRF(ev);
            answer.add(dedc);
        // System.out.println("just added dedc to answer");
        // removed, tbh, since this is proving nothing, 11-2007
        /*
                 * if (dedc.getEdc().getDefaultVersionId() !=
                 * dedc.getEventCRF().getId()) { System.out.println("ID
                 * MISMATCH: edc name "+dedc.getEdc().getName()+ ", default
                 * version id "+dedc.getEdc().getDefaultVersionId()+ " event crf
                 * id "+dedc.getEventCRF().getId()); }
                 */
        }
    }
    return answer;
}
Also used : EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean)

Example 89 with CRFVersionDAO

use of org.akaza.openclinica.dao.submit.CRFVersionDAO 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 90 with CRFVersionDAO

use of org.akaza.openclinica.dao.submit.CRFVersionDAO in project OpenClinica by OpenClinica.

the class SignStudySubjectServlet method populateUncompletedCRFsWithCRFAndVersions.

public static void populateUncompletedCRFsWithCRFAndVersions(DataSource ds, ArrayList uncompletedEventDefinitionCRFs) {
    CRFDAO cdao = new CRFDAO(ds);
    CRFVersionDAO cvdao = new CRFVersionDAO(ds);
    int size = uncompletedEventDefinitionCRFs.size();
    for (int i = 0; i < size; i++) {
        DisplayEventDefinitionCRFBean dedcrf = (DisplayEventDefinitionCRFBean) uncompletedEventDefinitionCRFs.get(i);
        CRFBean cb = (CRFBean) cdao.findByPK(dedcrf.getEdc().getCrfId());
        dedcrf.getEdc().setCrf(cb);
        ArrayList versions = (ArrayList) cvdao.findAllActiveByCRF(dedcrf.getEdc().getCrfId());
        dedcrf.getEdc().setVersions(versions);
        uncompletedEventDefinitionCRFs.set(i, dedcrf);
    }
}
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) ArrayList(java.util.ArrayList) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) 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)

Aggregations

CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)105 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)83 ArrayList (java.util.ArrayList)80 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)68 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)63 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)60 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)58 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)56 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)54 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)52 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)48 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)46 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)42 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)41 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)35 HashMap (java.util.HashMap)34 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)34 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)31 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)26 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)25