Search in sources :

Example 61 with StudyEventDefinitionDAO

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

the class ViewEventDefinitionServlet method processRequest.

@Override
public void processRequest() throws Exception {
    StudyEventDefinitionDAO sdao = new StudyEventDefinitionDAO(sm.getDataSource());
    StudyDAO studyDao = new StudyDAO(sm.getDataSource());
    FormProcessor fp = new FormProcessor(request);
    int defId = fp.getInt("id", true);
    if (defId == 0) {
        addPageMessage(respage.getString("please_choose_a_definition_to_view"));
        forwardPage(Page.LIST_DEFINITION_SERVLET);
    } else {
        // definition id
        StudyEventDefinitionBean sed = (StudyEventDefinitionBean) sdao.findByPK(defId);
        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;
        }
        checkRoleByUserAndStudy(ub, sed.getStudyId(), 0);
        EventDefinitionCRFDAO edao = new EventDefinitionCRFDAO(sm.getDataSource());
        ArrayList eventDefinitionCRFs = (ArrayList) edao.findAllByDefinition(this.currentStudy, 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.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());
            edc.setDefaultVersionName(defaultVersion.getName());
            CRFBean cBean = (CRFBean) cdao.findByPK(edc.getCrfId());
            String crfPath = sed.getOid() + "." + cBean.getOid();
            edc.setOffline(getEventDefinitionCrfTagService().getEventDefnCrfOfflineStatus(2, crfPath, true));
        }
        StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
        String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
        request.setAttribute("participateFormStatus", participateFormStatus);
        if (participateFormStatus.equals("enabled"))
            baseUrl();
        request.setAttribute("participateFormStatus", participateFormStatus);
        request.setAttribute("definition", sed);
        request.setAttribute("eventDefinitionCRFs", eventDefinitionCRFs);
        request.setAttribute("defSize", new Integer(eventDefinitionCRFs.size()));
        // request.setAttribute("eventDefinitionCRFs", new
        // ArrayList(tm.values()));
        forwardPage(Page.VIEW_EVENT_DEFINITION);
    }
}
Also used : 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) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 62 with StudyEventDefinitionDAO

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

the class SDVUtil method getEventNamesForEventCRFs.

public void getEventNamesForEventCRFs(List<EventCRFBean> eventCRFBeans) {
    if (eventCRFBeans == null || eventCRFBeans.isEmpty())
        return;
    StudyEventDAO studyEventDAO = new StudyEventDAO(dataSource);
    StudyEventDefinitionDAO studyEventDefinitionDAO = new StudyEventDefinitionDAO(dataSource);
    StudyEventBean studyEventBean = null;
    StudyEventDefinitionBean studyEventDefBean = null;
    //Provide a value for the eventName property of the EventCRF
    for (EventCRFBean eventCRFBean : eventCRFBeans) {
        if ("".equalsIgnoreCase(eventCRFBean.getEventName())) {
            studyEventBean = (StudyEventBean) studyEventDAO.findByPK(eventCRFBean.getStudyEventId());
            studyEventDefBean = (StudyEventDefinitionBean) studyEventDefinitionDAO.findByPK(studyEventBean.getStudyEventDefinitionId());
            eventCRFBean.setEventName(studyEventDefBean.getName() + "(" + studyEventBean.getSampleOrdinal() + ")");
        }
    }
}
Also used : EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean)

Example 63 with StudyEventDefinitionDAO

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

the class CreateSubStudyServlet method createSiteEventDefinitions.

private ArrayList<StudyEventDefinitionBean> createSiteEventDefinitions(StudyBean site, Validator v) throws MalformedURLException {
    FormProcessor fp = new FormProcessor(request);
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
    ArrayList<EventDefinitionCRFBean> edcsInSession = new ArrayList<EventDefinitionCRFBean>();
    StudyBean parentStudyBean;
    if (site.getParentStudyId() == 0) {
        parentStudyBean = site;
    } else {
        StudyDAO studyDAO = new StudyDAO(sm.getDataSource());
        parentStudyBean = (StudyBean) studyDAO.findByPK(site.getParentStudyId());
    }
    EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
    ArrayList<EventDefinitionCRFBean> eventDefCrfList = (ArrayList<EventDefinitionCRFBean>) edcdao.findAllActiveSitesAndStudiesPerParentStudy(parentStudyBean.getId());
    ArrayList<StudyEventDefinitionBean> seds = new ArrayList<StudyEventDefinitionBean>();
    StudyBean parentStudy = (StudyBean) new StudyDAO(sm.getDataSource()).findByPK(site.getParentStudyId());
    seds = (ArrayList<StudyEventDefinitionBean>) session.getAttribute("definitions");
    if (seds == null || seds.size() <= 0) {
        StudyEventDefinitionDAO sedDao = new StudyEventDefinitionDAO(sm.getDataSource());
        seds = sedDao.findAllByStudy(parentStudy);
    }
    CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
    HashMap<String, Boolean> changes = new HashMap<String, Boolean>();
    for (StudyEventDefinitionBean sed : seds) {
        String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
        if (participateFormStatus.equals("enabled"))
            baseUrl();
        request.setAttribute("participateFormStatus", participateFormStatus);
        // EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
        ArrayList<EventDefinitionCRFBean> edcs = sed.getCrfs();
        int start = 0;
        for (EventDefinitionCRFBean edcBean : edcs) {
            EventDefinitionCRFBean persistEventDefBean = (EventDefinitionCRFBean) edcdao.findByPK(edcBean.getId());
            int edcStatusId = edcBean.getStatus().getId();
            if (edcStatusId == 5 || edcStatusId == 7) {
            } else {
                String order = start + "-" + edcBean.getId();
                int defaultVersionId = fp.getInt("defaultVersionId" + order);
                String requiredCRF = fp.getString("requiredCRF" + order);
                String doubleEntry = fp.getString("doubleEntry" + order);
                String electronicSignature = fp.getString("electronicSignature" + order);
                String hideCRF = fp.getString("hideCRF" + order);
                int sdvId = fp.getInt("sdvOption" + order);
                String participantForm = fp.getString("participantForm" + order);
                String allowAnonymousSubmission = fp.getString("allowAnonymousSubmission" + order);
                String submissionUrl = fp.getString("submissionUrl" + order);
                String offline = fp.getString("offline" + order);
                ArrayList<String> selectedVersionIdList = fp.getStringArray("versionSelection" + order);
                int selectedVersionIdListSize = selectedVersionIdList.size();
                String selectedVersionIds = "";
                if (selectedVersionIdListSize > 0) {
                    for (String id : selectedVersionIdList) {
                        selectedVersionIds += id + ",";
                    }
                    selectedVersionIds = selectedVersionIds.substring(0, selectedVersionIds.length() - 1);
                }
                boolean changed = false;
                boolean isRequired = !StringUtil.isBlank(requiredCRF) && "yes".equalsIgnoreCase(requiredCRF.trim()) ? true : false;
                boolean isDouble = !StringUtil.isBlank(doubleEntry) && "yes".equalsIgnoreCase(doubleEntry.trim()) ? true : false;
                boolean hasPassword = !StringUtil.isBlank(electronicSignature) && "yes".equalsIgnoreCase(electronicSignature.trim()) ? true : false;
                boolean isHide = !StringUtil.isBlank(hideCRF) && "yes".equalsIgnoreCase(hideCRF.trim()) ? true : false;
                if (edcBean.getParentId() > 0) {
                    int dbDefaultVersionId = edcBean.getDefaultVersionId();
                    if (defaultVersionId != dbDefaultVersionId) {
                        changed = true;
                        CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(defaultVersionId);
                        edcBean.setDefaultVersionId(defaultVersionId);
                        edcBean.setDefaultVersionName(defaultVersion.getName());
                    }
                    if (isRequired != edcBean.isRequiredCRF()) {
                        changed = true;
                        edcBean.setRequiredCRF(isRequired);
                    }
                    if (isDouble != edcBean.isDoubleEntry()) {
                        changed = true;
                        edcBean.setDoubleEntry(isDouble);
                    }
                    if (hasPassword != edcBean.isElectronicSignature()) {
                        changed = true;
                        edcBean.setElectronicSignature(hasPassword);
                    }
                    if (isHide != edcBean.isHideCrf()) {
                        changed = true;
                        edcBean.setHideCrf(isHide);
                    }
                    if (!submissionUrl.equals(edcBean.getSubmissionUrl()) || !submissionUrl.equals(persistEventDefBean.getSubmissionUrl())) {
                        changed = true;
                        edcBean.setSubmissionUrl(submissionUrl);
                    }
                    if (!StringUtil.isBlank(selectedVersionIds) && !selectedVersionIds.equals(edcBean.getSelectedVersionIds())) {
                        changed = true;
                        String[] ids = selectedVersionIds.split(",");
                        ArrayList<Integer> idList = new ArrayList<Integer>();
                        for (String id : ids) {
                            idList.add(Integer.valueOf(id));
                        }
                        edcBean.setSelectedVersionIdList(idList);
                        edcBean.setSelectedVersionIds(selectedVersionIds);
                    }
                    if (sdvId > 0 && sdvId != edcBean.getSourceDataVerification().getCode()) {
                        changed = true;
                        edcBean.setSourceDataVerification(SourceDataVerification.getByCode(sdvId));
                    }
                } else {
                    // only if definition-crf has been modified, will it be
                    // saved for the site
                    int defaultId = defaultVersionId > 0 ? defaultVersionId : edcBean.getDefaultVersionId();
                    if (defaultId == defaultVersionId) {
                        if (isRequired == edcBean.isRequiredCRF()) {
                            if (isDouble == edcBean.isDoubleEntry()) {
                                if (hasPassword == edcBean.isElectronicSignature()) {
                                    if (isHide == edcBean.isHideCrf()) {
                                        if (submissionUrl.equals("")) {
                                            if (selectedVersionIdListSize > 0) {
                                                if (selectedVersionIdListSize == edcBean.getVersions().size()) {
                                                    if (sdvId > 0) {
                                                        if (sdvId != edcBean.getSourceDataVerification().getCode()) {
                                                            changed = true;
                                                            edcBean.setSourceDataVerification(SourceDataVerification.getByCode(sdvId));
                                                            edcBean.setSubmissionUrl(submissionUrl);
                                                        }
                                                    }
                                                } else {
                                                    changed = true;
                                                    String[] ids = selectedVersionIds.split(",");
                                                    ArrayList<Integer> idList = new ArrayList<Integer>();
                                                    for (String id : ids) {
                                                        idList.add(Integer.valueOf(id));
                                                    }
                                                    edcBean.setSelectedVersionIdList(idList);
                                                    edcBean.setSelectedVersionIds(selectedVersionIds);
                                                    edcBean.setSubmissionUrl(submissionUrl);
                                                }
                                            }
                                        } else {
                                            changed = true;
                                            edcBean.setSubmissionUrl(submissionUrl);
                                        }
                                    } else {
                                        changed = true;
                                        edcBean.setHideCrf(isHide);
                                        edcBean.setSubmissionUrl(submissionUrl);
                                    }
                                } else {
                                    changed = true;
                                    edcBean.setElectronicSignature(hasPassword);
                                    edcBean.setSubmissionUrl(submissionUrl);
                                }
                            } else {
                                changed = true;
                                edcBean.setDoubleEntry(isDouble);
                                edcBean.setSubmissionUrl(submissionUrl);
                            }
                        } else {
                            changed = true;
                            edcBean.setRequiredCRF(isRequired);
                            edcBean.setSubmissionUrl(submissionUrl);
                        }
                    } else {
                        changed = true;
                        CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(defaultVersionId);
                        edcBean.setDefaultVersionId(defaultVersionId);
                        edcBean.setDefaultVersionName(defaultVersion.getName());
                    }
                }
                changes.put(sed.getId() + "-" + edcBean.getId(), changed);
                ++start;
            }
            edcsInSession.add(edcBean);
        }
        sed.setPopulated(false);
        eventDefCrfList = validateSubmissionUrl(edcsInSession, eventDefCrfList, v, sed);
        edcsInSession.clear();
    }
    errors = v.validate();
    StudyDAO studyDAO = new StudyDAO(sm.getDataSource());
    ArrayList<StudyBean> allStudies = (ArrayList<StudyBean>) studyDAO.findAll();
    for (StudyBean thisBean : allStudies) {
        if (fp.getString("uniqueProId").trim().equals(thisBean.getIdentifier())) {
            v.addError(errors, "uniqueProId", resexception.getString("unique_protocol_id_existed"));
        }
    }
    // << tbh #3999 08/2009
    if (fp.getString("name").trim().length() > 100) {
    // Validator.addError(errors, "name", resexception.getString("maximum_lenght_name_100"));
    }
    if (fp.getString("uniqueProId").trim().length() > 30) {
        Validator.addError(errors, "uniqueProId", resexception.getString("maximum_lenght_unique_protocol_30"));
    }
    if (fp.getString("description").trim().length() > 255) {
        Validator.addError(errors, "description", resexception.getString("maximum_lenght_brief_summary_255"));
    }
    if (fp.getString("prinInvestigator").trim().length() > 255) {
        Validator.addError(errors, "prinInvestigator", resexception.getString("maximum_lenght_principal_investigator_255"));
    }
    if (fp.getInt("expectedTotalEnrollment") <= 0) {
        Validator.addError(errors, "expectedTotalEnrollment", respage.getString("expected_total_enrollment_must_be_a_positive_number"));
    }
    if (!errors.isEmpty()) {
        // logger.info("has errors");
        StudyBean study = createStudyBean();
        session.setAttribute("newStudy", study);
        session.setAttribute("definitions", seds);
        request.setAttribute("formMessages", errors);
        /*
             * try {
             * local_df.parse(fp.getString(INPUT_START_DATE));
             * fp.addPresetValue(INPUT_START_DATE, local_df.format(fp.getDate(INPUT_START_DATE)));
             * } catch (ParseException pe) {
             * fp.addPresetValue(INPUT_START_DATE, fp.getString(INPUT_START_DATE));
             * }
             * try {
             * local_df.parse(fp.getString(INPUT_END_DATE));
             * fp.addPresetValue(INPUT_END_DATE, local_df.format(fp.getDate(INPUT_END_DATE)));
             * } catch (ParseException pe) {
             * fp.addPresetValue(INPUT_END_DATE, fp.getString(INPUT_END_DATE));
             * }
             * try {
             * local_df.parse(fp.getString(INPUT_VER_DATE));
             * fp.addPresetValue(INPUT_VER_DATE, local_df.format(fp.getDate(INPUT_VER_DATE)));
             * } catch (ParseException pe) {
             * fp.addPresetValue(INPUT_VER_DATE, fp.getString(INPUT_VER_DATE));
             * }
             */
        // setPresetValues(fp.getPresetValues());
        logger.info("has validation errors");
        // request.setAttribute("formMessages", errors);
        // request.setAttribute("facRecruitStatusMap",
        // CreateStudyServlet.facRecruitStatusMap);
        // request.setAttribute("statuses", Status.toActiveArrayList());
        // forwardPage(Page.CREATE_SUB_STUDY);
        forwardPage(Page.CREATE_SUB_STUDY);
    }
    session.setAttribute("changed", changes);
    return seds;
}
Also used : CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) HashMap(java.util.HashMap) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 64 with StudyEventDefinitionDAO

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

the class ChangeDefinitionOrdinalServlet method processRequest.

@Override
public void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    int current = fp.getInt("current");
    int previous = fp.getInt("previous");
    StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
    increase(current, previous, seddao);
    String url = response.encodeRedirectURL("ListEventDefinition");
    response.sendRedirect(url);
//        forwardPage(Page.LIST_DEFINITION_SERVLET);
}
Also used : StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor)

Example 65 with StudyEventDefinitionDAO

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

the class CreateDiscrepancyNoteServlet method getStudyEventDefinition.

private StudyEventDefinitionBean getStudyEventDefinition(int eventCRFId) {
    StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
    StudyEventDefinitionBean sed = (StudyEventDefinitionBean) seddao.findByPK(getStudyEvent(eventCRFId).getStudyEventDefinitionId());
    return sed;
}
Also used : StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)

Aggregations

StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)101 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)85 ArrayList (java.util.ArrayList)76 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)69 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)62 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)59 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)57 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)55 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)55 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)51 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)50 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)45 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)44 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)43 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)41 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)39 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)37 Date (java.util.Date)36 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)32 HashMap (java.util.HashMap)28