Search in sources :

Example 76 with EventDefinitionCRFDAO

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

the class UpdateSubStudyServlet method submitSiteEventDefinitions.

private void submitSiteEventDefinitions(StudyBean site) throws MalformedURLException {
    FormProcessor fp = new FormProcessor(request);
    Validator v = new Validator(request);
    HashMap<String, Boolean> changes = new HashMap<String, Boolean>();
    HashMap<String, Boolean> changeStatus = (HashMap<String, Boolean>) session.getAttribute("changed");
    ArrayList<StudyEventDefinitionBean> seds = new ArrayList<StudyEventDefinitionBean>();
    ArrayList<EventDefinitionCRFBean> defCrfs = new ArrayList<EventDefinitionCRFBean>();
    StudyEventDefinitionDAO sedDao = new StudyEventDefinitionDAO(sm.getDataSource());
    CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
    FormLayoutDAO fldao = new FormLayoutDAO(sm.getDataSource());
    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<EventDefinitionCRFBean> toBeCreatedEventDefBean = new ArrayList<>();
    ArrayList<EventDefinitionCRFBean> toBeUpdatedEventDefBean = new ArrayList<>();
    ArrayList<EventDefinitionCRFBean> edcsInSession = new ArrayList<EventDefinitionCRFBean>();
    boolean changestate = false;
    seds = (ArrayList<StudyEventDefinitionBean>) session.getAttribute("definitions");
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
    String participateFormStatus = spvdao.findByHandleAndStudy(parentStudyBean.getId(), "participantPortal").getValue();
    if (participateFormStatus.equals("enabled"))
        baseUrl();
    request.setAttribute("participateFormStatus", participateFormStatus);
    for (StudyEventDefinitionBean sed : seds) {
        ArrayList<EventDefinitionCRFBean> edcs = sed.getCrfs();
        int start = 0;
        for (EventDefinitionCRFBean edcBean : edcs) {
            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);
                String participantForm = fp.getString("participantForm" + order);
                String allowAnonymousSubmission = fp.getString("allowAnonymousSubmission" + order);
                String submissionUrl = fp.getString("submissionUrl" + order);
                String offline = fp.getString("offline" + order);
                int sdvId = fp.getInt("sdvOption" + 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);
                }
                String sdvOption = fp.getString("sdvOption" + order);
                boolean changed = false;
                if (changeStatus != null && changeStatus.get(sed.getId() + "-" + edcBean.getId()) != null) {
                    changed = changeStatus.get(sed.getId() + "-" + edcBean.getId());
                    edcBean.setSubmissionUrl(submissionUrl);
                }
                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;
                System.out.println("crf name :" + edcBean.getCrfName());
                System.out.println("submissionUrl: " + submissionUrl);
                if (edcBean.getParentId() > 0) {
                    int dbDefaultVersionId = edcBean.getDefaultVersionId();
                    if (defaultVersionId != dbDefaultVersionId) {
                        changed = true;
                        FormLayoutBean defaultVersion = (FormLayoutBean) fldao.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())) {
                        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));
                    }
                    if (changed) {
                        edcBean.setUpdater(ub);
                        edcBean.setUpdatedDate(new Date());
                        logger.debug("update for site");
                        toBeUpdatedEventDefBean.add(edcBean);
                    // edcdao.update(edcBean);
                    }
                } else {
                    // only if definition-crf has been modified, will it be
                    // saved for the site
                    int defaultId = defaultVersionId > 0 ? defaultVersionId : edcBean.getDefaultVersionId();
                    int dbDefaultVersionId = edcBean.getDefaultVersionId();
                    if (defaultId == dbDefaultVersionId) {
                        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;
                                                        }
                                                    }
                                                } else {
                                                    changed = true;
                                                }
                                            }
                                        } else {
                                            changed = true;
                                        }
                                    } else {
                                        changed = true;
                                    }
                                } else {
                                    changed = true;
                                }
                            } else {
                                changed = true;
                            }
                        } else {
                            changed = true;
                        }
                    } else {
                        changed = true;
                    }
                    if (changed) {
                        CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(defaultId);
                        edcBean.setDefaultVersionId(defaultId);
                        edcBean.setDefaultVersionName(defaultVersion.getName());
                        edcBean.setRequiredCRF(isRequired);
                        edcBean.setDoubleEntry(isDouble);
                        edcBean.setElectronicSignature(hasPassword);
                        edcBean.setHideCrf(isHide);
                        edcBean.setSubmissionUrl(submissionUrl);
                        if (selectedVersionIdListSize > 0 && selectedVersionIdListSize != edcBean.getVersions().size()) {
                            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()) {
                            edcBean.setSourceDataVerification(SourceDataVerification.getByCode(sdvId));
                        }
                        // edcBean.setParentId(edcBean.getId());
                        edcBean.setStudyId(site.getId());
                        edcBean.setUpdater(ub);
                        edcBean.setUpdatedDate(new Date());
                        logger.debug("create for the site");
                        toBeCreatedEventDefBean.add(edcBean);
                    // edcdao.create(edcBean);
                    }
                }
                ++start;
                changes.put(sed.getId() + "-" + edcBean.getId(), changed);
            }
            edcsInSession.add(edcBean);
        }
        sed.setPopulated(false);
        eventDefCrfList = validateSubmissionUrl(edcsInSession, eventDefCrfList, v, sed);
        edcsInSession.clear();
    }
    errors = v.validate();
    if (!errors.isEmpty()) {
        logger.info("has errors");
        StudyBean study = createStudyBean();
        session.setAttribute("newStudy", study);
        request.setAttribute("formMessages", errors);
        session.setAttribute("changed", changes);
        forwardPage(Page.UPDATE_SUB_STUDY);
    } else {
        for (EventDefinitionCRFBean toBeCreated : toBeCreatedEventDefBean) {
            toBeCreated.setParentId(toBeCreated.getId());
            edcdao.create(toBeCreated);
        }
        for (EventDefinitionCRFBean toBeUpdated : toBeUpdatedEventDefBean) {
            edcdao.update(toBeUpdated);
        }
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) FormLayoutBean(org.akaza.openclinica.bean.submit.FormLayoutBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) Date(java.util.Date) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) FormLayoutDAO(org.akaza.openclinica.dao.submit.FormLayoutDAO) 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)

Example 77 with EventDefinitionCRFDAO

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

the class SignStudySubjectServlet method permitSign.

public static boolean permitSign(StudySubjectBean studySub, DataSource ds) {
    boolean sign = true;
    StudyEventDAO sedao = new StudyEventDAO(ds);
    EventCRFDAO ecdao = new EventCRFDAO(ds);
    EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(ds);
    StudyDAO sdao = new StudyDAO(ds);
    StudyBean studyBean = (StudyBean) sdao.findByPK(studySub.getStudyId());
    // DiscrepancyNoteDAO discDao = new DiscrepancyNoteDAO(ds);
    ArrayList studyEvents = sedao.findAllByStudySubject(studySub);
    for (int l = 0; l < studyEvents.size(); l++) {
        StudyEventBean studyEvent = (StudyEventBean) studyEvents.get(l);
        ArrayList eventCrfs = ecdao.findAllByStudyEvent(studyEvent);
        for (int i = 0; i < eventCrfs.size(); i++) {
            EventCRFBean ecrf = (EventCRFBean) eventCrfs.get(i);
            // ArrayList discList =
            // discDao.findAllItemNotesByEventCRF(ecrf.getId());
            // for (int j = 0; j < discList.size(); j++) {
            // DiscrepancyNoteBean discBean = (DiscrepancyNoteBean)
            // discList.get(j);
            // if
            //(discBean.getResStatus().equals(org.akaza.openclinica.bean.core
            // .ResolutionStatus.OPEN)
            // ||
            //discBean.getResStatus().equals(org.akaza.openclinica.bean.core
            // .ResolutionStatus.UPDATED))
            // {
            // sign = false;
            // break;
            // }
            // }
            EventDefinitionCRFBean edcBean = edcdao.findByStudyEventIdAndCRFVersionId(studyBean, studyEvent.getId(), ecrf.getCRFVersionId());
            if (ecrf.getStage().equals(DataEntryStage.INITIAL_DATA_ENTRY) || ecrf.getStage().equals(DataEntryStage.INITIAL_DATA_ENTRY_COMPLETE) && edcBean.isDoubleEntry() == true) {
                sign = false;
                break;
            }
        }
    }
    return sign;
}
Also used : EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) DisplayStudyEventBean(org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO)

Example 78 with EventDefinitionCRFDAO

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

the class UpdateEventDefinitionServlet method submitDefinition.

/**
     * Updates the definition
     * 
     */
private void submitDefinition() {
    ArrayList edcs = (ArrayList) session.getAttribute("eventDefinitionCRFs");
    StudyEventDefinitionBean sed = (StudyEventDefinitionBean) session.getAttribute("definition");
    StudyEventDefinitionDAO edao = new StudyEventDefinitionDAO(sm.getDataSource());
    if (sed != null)
        logger.info("Definition bean to be updated:" + sed.getName() + sed.getCategory());
    sed.setUpdater(ub);
    sed.setUpdatedDate(new Date());
    sed.setStatus(Status.AVAILABLE);
    edao.update(sed);
    EventDefinitionCRFDAO cdao = new EventDefinitionCRFDAO(sm.getDataSource());
    CRFDAO crfdao = new CRFDAO(sm.getDataSource());
    for (int i = 0; i < edcs.size(); i++) {
        EventDefinitionCRFBean edc = (EventDefinitionCRFBean) edcs.get(i);
        if (edc.getId() > 0) {
            // need to do update
            edc.setUpdater(ub);
            edc.setUpdatedDate(new Date());
            logger.info("Status:" + edc.getStatus().getName());
            logger.info("version:" + edc.getDefaultVersionId());
            logger.info("Electronic Signature [" + edc.isElectronicSignature() + "]");
            if (!sed.isRepeating()) {
                edc.setAllowAnonymousSubmission(false);
                edc.setSubmissionUrl("");
            }
            cdao.update(edc);
            String crfPath = sed.getOid() + "." + edc.getCrf().getOid();
            getEventDefinitionCrfTagService().saveEventDefnCrfOfflineTag(2, crfPath, edc, sed);
            ArrayList<EventDefinitionCRFBean> eventDefCrfBeans = cdao.findAllByCrfDefinitionInSiteOnly(edc.getStudyEventDefinitionId(), edc.getCrfId());
            for (EventDefinitionCRFBean eventDefCrfBean : eventDefCrfBeans) {
                eventDefCrfBean.setParticipantForm(edc.isParticipantForm());
                eventDefCrfBean.setAllowAnonymousSubmission(edc.isAllowAnonymousSubmission());
                cdao.update(eventDefCrfBean);
            }
            if (edc.getStatus().equals(Status.DELETED) || edc.getStatus().equals(Status.AUTO_DELETED)) {
                removeAllEventsItems(edc, sed);
            }
            if (edc.getOldStatus() != null && edc.getOldStatus().equals(Status.DELETED)) {
                restoreAllEventsItems(edc, sed);
            }
        } else {
            // to insert
            edc.setOwner(ub);
            edc.setCreatedDate(new Date());
            edc.setStatus(Status.AVAILABLE);
            if (!sed.isRepeating()) {
                edc.setAllowAnonymousSubmission(false);
                edc.setSubmissionUrl("");
            }
            cdao.create(edc);
            CRFBean cBean = (CRFBean) crfdao.findByPK(edc.getCrfId());
            String crfPath = sed.getOid() + "." + cBean.getOid();
            getEventDefinitionCrfTagService().saveEventDefnCrfOfflineTag(2, crfPath, edc, sed);
        }
    }
    session.removeAttribute("definition");
    session.removeAttribute("eventDefinitionCRFs");
    session.removeAttribute("tmpCRFIdMap");
    session.removeAttribute("crfsWithVersion");
    session.removeAttribute("eventDefinitionCRFs");
    addPageMessage(respage.getString("the_ED_has_been_updated_succesfully"));
    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) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) Date(java.util.Date) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 79 with EventDefinitionCRFDAO

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

the class UpdateEventDefinitionServlet method confirmDefinition.

/**
     * 
     * @throws Exception
     */
private void confirmDefinition() throws Exception {
    Validator v = new Validator(request);
    FormProcessor fp = new FormProcessor(request);
    StudyEventDefinitionBean sed = (StudyEventDefinitionBean) session.getAttribute("definition");
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
    String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
    if (participateFormStatus.equals("enabled"))
        baseUrl();
    request.setAttribute("participateFormStatus", participateFormStatus);
    v.addValidation("name", Validator.NO_BLANKS);
    v.addValidation("name", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 2000);
    v.addValidation("description", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 2000);
    v.addValidation("category", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 2000);
    ArrayList<EventDefinitionCRFBean> edcsInSession = (ArrayList<EventDefinitionCRFBean>) session.getAttribute("eventDefinitionCRFs");
    int parentStudyId = sed.getStudyId();
    EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
    ArrayList<EventDefinitionCRFBean> eventDefCrfList = (ArrayList<EventDefinitionCRFBean>) edcdao.findAllActiveSitesAndStudiesPerParentStudy(parentStudyId);
    // logger.info("no errors");
    sed.setName(fp.getString("name"));
    sed.setRepeating(fp.getBoolean("repeating"));
    sed.setCategory(fp.getString("category"));
    sed.setDescription(fp.getString("description"));
    sed.setType(fp.getString("type"));
    session.setAttribute("definition", sed);
    FormLayoutDAO fldao = new FormLayoutDAO(sm.getDataSource());
    ArrayList<EventDefinitionCRFBean> edcs = (ArrayList) session.getAttribute("eventDefinitionCRFs");
    for (int i = 0; i < edcs.size(); i++) {
        EventDefinitionCRFBean edcBean = (EventDefinitionCRFBean) edcs.get(i);
        if (!edcBean.getStatus().equals(Status.DELETED) && !edcBean.getStatus().equals(Status.AUTO_DELETED)) {
            // only get inputs from web page if AVAILABLE
            int defaultVersionId = fp.getInt("defaultVersionId" + i);
            edcBean.setDefaultVersionId(defaultVersionId);
            FormLayoutBean defaultVersion = (FormLayoutBean) fldao.findByPK(edcBean.getDefaultVersionId());
            edcBean.setDefaultVersionName(defaultVersion.getName());
            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 hideCRF = fp.getString("hideCRF" + i);
            int sdvId = fp.getInt("sdvOption" + 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);
            System.out.println("submission :" + submissionUrl);
            if (!StringUtil.isBlank(hideCRF) && "yes".equalsIgnoreCase(hideCRF.trim())) {
                edcBean.setHideCrf(true);
            } else {
                edcBean.setHideCrf(false);
            }
            if (!StringUtil.isBlank(requiredCRF) && "yes".equalsIgnoreCase(requiredCRF.trim())) {
                edcBean.setRequiredCRF(true);
            } else {
                edcBean.setRequiredCRF(false);
            }
            if (!StringUtil.isBlank(doubleEntry) && "yes".equalsIgnoreCase(doubleEntry.trim())) {
                edcBean.setDoubleEntry(true);
            } else {
                edcBean.setDoubleEntry(false);
            }
            if (!StringUtil.isBlank(electronicSignature) && "yes".equalsIgnoreCase(electronicSignature.trim())) {
                edcBean.setElectronicSignature(true);
            } else {
                edcBean.setElectronicSignature(false);
            }
            if (!StringUtil.isBlank(decisionCondition) && "yes".equalsIgnoreCase(decisionCondition.trim())) {
                edcBean.setDecisionCondition(true);
            } else {
                edcBean.setDecisionCondition(false);
            }
            if (!StringUtil.isBlank(participantForm) && "yes".equalsIgnoreCase(participantForm.trim())) {
                edcBean.setParticipantForm(true);
            } else {
                edcBean.setParticipantForm(false);
            }
            if (!StringUtils.isBlank(allowAnonymousSubmission) && "yes".equalsIgnoreCase(allowAnonymousSubmission.trim())) {
                edcBean.setAllowAnonymousSubmission(true);
            } else {
                edcBean.setAllowAnonymousSubmission(false);
            }
            edcBean.setSubmissionUrl(submissionUrl.trim());
            if (!StringUtils.isBlank(offline) && "yes".equalsIgnoreCase(offline.trim())) {
                edcBean.setOffline(true);
            } else {
                edcBean.setOffline(false);
            }
            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 (!StringUtil.isBlank(myNull) && "yes".equalsIgnoreCase(myNull.trim())) {
                    nullString = nullString + n.getName().toUpperCase() + ",";
                }
            }
            if (sdvId > 0 && (edcBean.getSourceDataVerification() == null || sdvId != edcBean.getSourceDataVerification().getCode())) {
                edcBean.setSourceDataVerification(SourceDataVerification.getByCode(sdvId));
            }
            edcBean.setNullValues(nullString);
            logger.info("found null values: " + nullString);
        }
    }
    validateSubmissionUrl(edcsInSession, eventDefCrfList, v);
    errors = v.validate();
    if (!errors.isEmpty()) {
        logger.info("has errors");
        session.setAttribute("eventDefinitionCRFs", edcs);
        request.setAttribute("formMessages", errors);
        forwardPage(Page.UPDATE_EVENT_DEFINITION1);
    }
    session.setAttribute("eventDefinitionCRFs", edcs);
    forwardPage(Page.UPDATE_EVENT_DEFINITION_CONFIRM);
}
Also used : FormProcessor(org.akaza.openclinica.control.form.FormProcessor) ArrayList(java.util.ArrayList) FormLayoutBean(org.akaza.openclinica.bean.submit.FormLayoutBean) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) NullValue(org.akaza.openclinica.bean.core.NullValue) FormLayoutDAO(org.akaza.openclinica.dao.submit.FormLayoutDAO) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) Validator(org.akaza.openclinica.control.form.Validator)

Example 80 with EventDefinitionCRFDAO

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

the class SignStudySubjectServlet method signSubjectEvents.

public static boolean signSubjectEvents(StudySubjectBean studySub, DataSource ds, UserAccountBean ub) {
    boolean updated = true;
    // StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(ds);
    StudyEventDAO sedao = new StudyEventDAO(ds);
    EventCRFDAO ecdao = new EventCRFDAO(ds);
    EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(ds);
    // StudySubjectDAO ssdao = new StudySubjectDAO(ds);
    DiscrepancyNoteDAO discDao = new DiscrepancyNoteDAO(ds);
    ArrayList studyEvents = sedao.findAllByStudySubject(studySub);
    for (int l = 0; l < studyEvents.size(); l++) {
        try {
            StudyEventBean studyEvent = (StudyEventBean) studyEvents.get(l);
            studyEvent.setUpdater(ub);
            studyEvent.setUpdatedDate(new Date());
            studyEvent.setSubjectEventStatus(SubjectEventStatus.SIGNED);
            sedao.update(studyEvent);
        } catch (Exception ex) {
            updated = false;
        }
    }
    return updated;
}
Also used : DiscrepancyNoteDAO(org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) ArrayList(java.util.ArrayList) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) DisplayStudyEventBean(org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) Date(java.util.Date) InsufficientPermissionException(org.akaza.openclinica.web.InsufficientPermissionException)

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