Search in sources :

Example 6 with EventDefinitionCRFBean

use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.

the class AddCRFToDefinitionServlet method processRequest.

@Override
public void processRequest() throws Exception {
    String actionName = request.getParameter("actionName");
    String submit = request.getParameter("Submit");
    CRFDAO cdao = new CRFDAO(sm.getDataSource());
    ArrayList crfs = (ArrayList) cdao.findAllByStatus(Status.AVAILABLE);
    ArrayList edcs = (ArrayList) session.getAttribute("eventDefinitionCRFs");
    if (edcs == null) {
        edcs = new ArrayList();
    }
    HashMap crfIds = new HashMap();
    for (int i = 0; i < edcs.size(); i++) {
        EventDefinitionCRFBean edc = (EventDefinitionCRFBean) edcs.get(i);
        Integer crfId = new Integer(edc.getCrfId());
        crfIds.put(crfId, edc);
    }
    for (int i = 0; i < crfs.size(); i++) {
        CRFBean crf = (CRFBean) crfs.get(i);
        if (crfIds.containsKey(new Integer(crf.getId()))) {
            crf.setSelected(true);
        }
    }
    session.setAttribute("crfsWithVersion", crfs);
    if (submit != null) {
        addCRF();
    } else {
        if (StringUtil.isBlank(actionName)) {
            FormProcessor fp = new FormProcessor(request);
            EntityBeanTable table = fp.getEntityBeanTable();
            ArrayList allRows = CRFRow.generateRowsFromBeans(crfs);
            String[] columns = { resword.getString("CRF_name"), resword.getString("date_created"), resword.getString("owner"), resword.getString("date_updated"), resword.getString("last_updated_by"), resword.getString("selected") };
            table.setColumns(new ArrayList(Arrays.asList(columns)));
            table.hideColumnLink(5);
            table.setQuery("AddCRFToDefinition", new HashMap());
            table.setRows(allRows);
            table.computeDisplay();
            request.setAttribute("table", table);
            forwardPage(Page.UPDATE_EVENT_DEFINITION2);
        } else if (actionName.equalsIgnoreCase("next")) {
            Integer pageNumber = Integer.valueOf(request.getParameter("pageNum"));
            if (pageNumber != null) {
                if (pageNumber.intValue() == 2) {
                    String nextListPage = request.getParameter("next_list_page");
                    if (nextListPage != null && nextListPage.equalsIgnoreCase("true")) {
                        confirmDefinition();
                    }
                } else {
                    confirmDefinition();
                }
            }
        }
    }
}
Also used : CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) EntityBeanTable(org.akaza.openclinica.web.bean.EntityBeanTable) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 7 with EventDefinitionCRFBean

use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.

the class AddCRFToDefinitionServlet method addCRF.

private void addCRF() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    CRFVersionDAO vdao = new CRFVersionDAO(sm.getDataSource());
    ArrayList crfArray = new ArrayList();
    Map tmpCRFIdMap = (HashMap) session.getAttribute("tmpCRFIdMap");
    if (tmpCRFIdMap == null) {
        tmpCRFIdMap = new HashMap();
    }
    ArrayList crfsWithVersion = (ArrayList) session.getAttribute("crfsWithVersion");
    for (int i = 0; i < crfsWithVersion.size(); i++) {
        int id = fp.getInt("id" + i);
        String name = fp.getString("name" + i);
        String selected = fp.getString("selected" + i);
        if (!StringUtil.isBlank(selected) && "yes".equalsIgnoreCase(selected.trim())) {
            logger.info("one crf selected");
            CRFBean cb = new CRFBean();
            cb.setId(id);
            cb.setName(name);
            // only find active verions
            ArrayList versions = (ArrayList) vdao.findAllActiveByCRF(cb.getId());
            cb.setVersions(versions);
            crfArray.add(cb);
        } else {
            if (tmpCRFIdMap.containsKey(id)) {
                tmpCRFIdMap.remove(id);
            }
        }
    }
    for (Iterator tmpCRFIterator = tmpCRFIdMap.keySet().iterator(); tmpCRFIterator.hasNext(); ) {
        int id = (Integer) tmpCRFIterator.next();
        String name = (String) tmpCRFIdMap.get(id);
        boolean isExists = false;
        for (Iterator it = crfArray.iterator(); it.hasNext(); ) {
            CRFBean cb = (CRFBean) it.next();
            if (id == cb.getId()) {
                isExists = true;
            }
        }
        if (!isExists) {
            CRFBean cb = new CRFBean();
            cb.setId(id);
            cb.setName(name);
            // only find active verions
            ArrayList versions = (ArrayList) vdao.findAllActiveByCRF(cb.getId());
            cb.setVersions(versions);
            crfArray.add(cb);
        }
    }
    session.removeAttribute("tmpCRFIdMap");
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
    if (crfArray.size() == 0) {
        // no crf seleted
        addPageMessage(respage.getString("no_new_CRF_added"));
        StudyEventDefinitionBean sed = (StudyEventDefinitionBean) session.getAttribute("definition");
        String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
        request.setAttribute("participateFormStatus", participateFormStatus);
        sed.setCrfs(new ArrayList());
        session.setAttribute("definition", sed);
        forwardPage(Page.UPDATE_EVENT_DEFINITION1);
    } else {
        StudyEventDefinitionBean sed = (StudyEventDefinitionBean) session.getAttribute("definition");
        String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
        if (participateFormStatus.equals("enabled"))
            baseUrl();
        request.setAttribute("participateFormStatus", participateFormStatus);
        ArrayList edcs = (ArrayList) session.getAttribute("eventDefinitionCRFs");
        int ordinalForNewCRF = edcs.size();
        for (int i = 0; i < crfArray.size(); i++) {
            CRFBean crf = (CRFBean) crfArray.get(i);
            EventDefinitionCRFBean edcBean = new EventDefinitionCRFBean();
            edcBean.setCrfId(crf.getId());
            edcBean.setCrfName(crf.getName());
            edcBean.setStudyId(ub.getActiveStudyId());
            edcBean.setStatus(Status.AVAILABLE);
            edcBean.setStudyEventDefinitionId(sed.getId());
            edcBean.setStudyId(ub.getActiveStudyId());
            edcBean.setSourceDataVerification(SourceDataVerification.NOTREQUIRED);
            ordinalForNewCRF = ordinalForNewCRF + 1;
            edcBean.setOrdinal(ordinalForNewCRF);
            edcBean.setVersions(crf.getVersions());
            CRFVersionBean defaultVersion1 = (CRFVersionBean) vdao.findByPK(edcBean.getDefaultVersionId());
            edcBean.setDefaultVersionName(defaultVersion1.getName());
            ordinalForNewCRF++;
            edcs.add(edcBean);
        }
        session.setAttribute("eventDefinitionCRFs", edcs);
        ArrayList<String> sdvOptions = new ArrayList<String>();
        sdvOptions.add(SourceDataVerification.AllREQUIRED.toString());
        sdvOptions.add(SourceDataVerification.PARTIALREQUIRED.toString());
        sdvOptions.add(SourceDataVerification.NOTREQUIRED.toString());
        sdvOptions.add(SourceDataVerification.NOTAPPLICABLE.toString());
        request.setAttribute("sdvOptions", sdvOptions);
        addPageMessage(respage.getString("has_have_been_added_need_confirmation"));
        forwardPage(Page.UPDATE_EVENT_DEFINITION1);
    }
}
Also used : CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 8 with EventDefinitionCRFBean

use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.

the class ListEventsForSubjectTableFactory method getCrfs.

@SuppressWarnings("unchecked")
private ArrayList<CRFBean> getCrfs(StudyEventDefinitionBean eventDefinition) {
    if (this.crfBeans == null) {
        crfBeans = new ArrayList<CRFBean>();
        eventDefinitionCrfs = new ArrayList<EventDefinitionCRFBean>();
        for (EventDefinitionCRFBean eventDefinitionCrf : (List<EventDefinitionCRFBean>) getEventDefintionCRFDAO().findAllActiveByEventDefinitionId(eventDefinition.getId())) {
            CRFBean crfBean = (CRFBean) getCrfDAO().findByPK(eventDefinitionCrf.getCrfId());
            ArrayList<CRFVersionBean> crfVersions = (ArrayList<CRFVersionBean>) getCrfVersionDAO().findAllByCRFId(eventDefinitionCrf.getCrfId());
            crfBean.setVersions(crfVersions);
            if (eventDefinitionCrf.getParentId() == 0) {
                crfBeans.add(crfBean);
                eventDefinitionCrfs.add(eventDefinitionCrf);
            }
        }
        return crfBeans;
    }
    return crfBeans;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean)

Example 9 with EventDefinitionCRFBean

use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.

the class ListEventsForSubjectTableFactory method getEventDefinitionCRFBean.

private EventDefinitionCRFBean getEventDefinitionCRFBean(Integer studyEventDefinitionId, CRFBean crfBean, StudySubjectBean studySubject) {
    EventDefinitionCRFBean eventDefinitionCrf = getEventDefintionCRFDAO().findByStudyEventDefinitionIdAndCRFIdAndStudyId(studyEventDefinitionId, crfBean.getId(), studySubject.getStudyId());
    if (eventDefinitionCrf.getId() == 0) {
        eventDefinitionCrf = getEventDefintionCRFDAO().findForStudyByStudyEventDefinitionIdAndCRFId(studyEventDefinitionId, crfBean.getId());
    }
    CRFVersionBean defaultVersion = (CRFVersionBean) getCrfVersionDAO().findByPK(eventDefinitionCrf.getDefaultVersionId());
    eventDefinitionCrf.setDefaultCRF(defaultVersion);
    return eventDefinitionCrf;
}
Also used : CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 10 with EventDefinitionCRFBean

use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.

the class DefineStudyEventServlet method confirmWholeDefinition.

/**
 * Validates the entire definition
 *
 * @throws Exception
 */
private void confirmWholeDefinition() throws Exception {
    Validator v = new Validator(request);
    FormProcessor fp = new FormProcessor(request);
    StudyEventDefinitionBean sed = (StudyEventDefinitionBean) session.getAttribute("definition");
    ArrayList eventDefinitionCRFs = new ArrayList();
    CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
    for (int i = 0; i < sed.getCrfs().size(); i++) {
        EventDefinitionCRFBean edcBean = new EventDefinitionCRFBean();
        int crfId = fp.getInt("crfId" + i);
        int defaultVersionId = fp.getInt("defaultVersionId" + i);
        edcBean.setCrfId(crfId);
        edcBean.setDefaultVersionId(defaultVersionId);
        CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(edcBean.getDefaultVersionId());
        edcBean.setDefaultVersionName(defaultVersion.getName());
        String crfName = fp.getString("crfName" + i);
        // String crfLabel = fp.getString("crfLabel" + i);
        edcBean.setCrfName(crfName);
        // edcBean.setCrfLabel(crfLabel);
        String requiredCRF = fp.getString("requiredCRF" + i);
        String doubleEntry = fp.getString("doubleEntry" + i);
        String decisionCondition = fp.getString("decisionCondition" + i);
        String electronicSignature = fp.getString("electronicSignature" + i);
        String participantForm = fp.getString("participantForm" + i);
        String allowAnonymousSubmission = fp.getString("allowAnonymousSubmission" + i);
        String submissionUrl = fp.getString("submissionUrl" + i);
        String offline = fp.getString("offline" + i);
        // issue 312 BWP<<
        String hiddenCrf = fp.getString("hiddenCrf" + i);
        // hideCRF is false by default in the bean
        if (!StringUtil.isBlank(hiddenCrf) && "yes".equalsIgnoreCase(hiddenCrf.trim())) {
            edcBean.setHideCrf(true);
        } else {
            edcBean.setHideCrf(false);
        }
        // >>
        String sdvOption = fp.getString("sdvOption" + i);
        if (!StringUtils.isBlank(sdvOption)) {
            int id = Integer.valueOf(sdvOption);
            edcBean.setSourceDataVerification(SourceDataVerification.getByCode(id));
        }
        if (!StringUtils.isBlank(requiredCRF) && "yes".equalsIgnoreCase(requiredCRF.trim())) {
            edcBean.setRequiredCRF(true);
        } else {
            edcBean.setRequiredCRF(false);
        }
        if (!StringUtils.isBlank(participantForm) && "yes".equalsIgnoreCase(participantForm.trim())) {
            edcBean.setParticipantForm(true);
        } else {
            edcBean.setParticipantForm(false);
        }
        // when participant form is not selected, force allow anonymous to be not selected
        if (edcBean.isParticipantForm() && !StringUtils.isBlank(allowAnonymousSubmission) && "yes".equalsIgnoreCase(allowAnonymousSubmission.trim())) {
            edcBean.setAllowAnonymousSubmission(true);
        } else {
            edcBean.setAllowAnonymousSubmission(false);
        }
        if (!StringUtils.isBlank(offline) && "yes".equalsIgnoreCase(offline.trim())) {
            edcBean.setOffline(true);
        } else {
            edcBean.setOffline(false);
        }
        if (!StringUtils.isBlank(doubleEntry) && "yes".equalsIgnoreCase(doubleEntry.trim())) {
            edcBean.setDoubleEntry(true);
        } else {
            edcBean.setDoubleEntry(false);
        }
        if (!StringUtils.isBlank(decisionCondition) && "yes".equalsIgnoreCase(decisionCondition.trim())) {
            edcBean.setDecisionCondition(true);
        } else {
            edcBean.setDecisionCondition(false);
        }
        if (!StringUtils.isBlank(electronicSignature) && "yes".equalsIgnoreCase(electronicSignature.trim())) {
            edcBean.setElectronicSignature(true);
        } else {
            edcBean.setElectronicSignature(false);
        }
        // also useful to protect from naughty submission not coming from our html form
        if (edcBean.isParticipantForm() && edcBean.isAllowAnonymousSubmission()) {
            edcBean.setSubmissionUrl(submissionUrl.trim());
        }
        ArrayList<CRFVersionBean> versions = cvdao.findAllByCRFId(crfId);
        edcBean.setVersions(versions);
        String nullString = "";
        // process null values
        ArrayList nulls = NullValue.toArrayList();
        for (int a = 0; a < nulls.size(); a++) {
            NullValue n = (NullValue) nulls.get(a);
            String myNull = fp.getString(n.getName().toLowerCase() + i);
            if (!StringUtils.isBlank(myNull) && "yes".equalsIgnoreCase(myNull.trim())) {
                nullString = nullString + n.getName().toUpperCase() + ",";
            }
        }
        edcBean.setNullValues(nullString);
        edcBean.setStudyId(ub.getActiveStudyId());
        eventDefinitionCRFs.add(edcBean);
    }
    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("eventDefinitionCRFs", eventDefinitionCRFs);
    // not used on page
    session.setAttribute("edCRFs", eventDefinitionCRFs);
    ArrayList<EventDefinitionCRFBean> edcsInSession = (ArrayList<EventDefinitionCRFBean>) session.getAttribute("edCRFs");
    int parentStudyId = sed.getStudyId();
    EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
    ArrayList<EventDefinitionCRFBean> eventDefCrfList = (ArrayList<EventDefinitionCRFBean>) edcdao.findAllActiveSitesAndStudiesPerParentStudy(parentStudyId);
    if (eventDefCrfList.size() != 0)
        validateSubmissionUrl(edcsInSession, eventDefCrfList, v);
    errors = v.validate();
    if (!errors.isEmpty()) {
        ArrayList<String> sdvOptions = new ArrayList<String>();
        sdvOptions.add(SourceDataVerification.AllREQUIRED.toString());
        sdvOptions.add(SourceDataVerification.PARTIALREQUIRED.toString());
        sdvOptions.add(SourceDataVerification.NOTREQUIRED.toString());
        sdvOptions.add(SourceDataVerification.NOTAPPLICABLE.toString());
        request.setAttribute("sdvOptions", sdvOptions);
        logger.info("has errors");
        session.setAttribute("eventDefinitionCRFs", eventDefinitionCRFs);
        request.setAttribute("formMessages", errors);
        forwardPage(Page.DEFINE_STUDY_EVENT4);
    }
    forwardPage(Page.DEFINE_STUDY_EVENT_CONFIRM);
}
Also used : 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) NullValue(org.akaza.openclinica.bean.core.NullValue) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) Validator(org.akaza.openclinica.control.form.Validator)

Aggregations

EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)146 ArrayList (java.util.ArrayList)112 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)67 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)65 HashMap (java.util.HashMap)57 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)50 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)50 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)49 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)48 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)43 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)42 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)38 Iterator (java.util.Iterator)36 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)35 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)35 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)32 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)30 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)28 DisplayEventCRFBean (org.akaza.openclinica.bean.submit.DisplayEventCRFBean)26 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)26