Search in sources :

Example 1 with StudyParameterValueDAO

use of org.akaza.openclinica.dao.service.StudyParameterValueDAO in project OpenClinica by OpenClinica.

the class RandomizeActionProcessor method mayProceed.

private boolean mayProceed(String studyOid) throws Exception {
    boolean accessPermission = false;
    StudyBean siteStudy = getStudy(studyOid);
    StudyBean study = getParentStudy(studyOid);
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(ds);
    StudyParameterValueBean pStatus = spvdao.findByHandleAndStudy(study.getId(), "randomization");
    randomizationRegistrar = new RandomizationRegistrar();
    SeRandomizationDTO seRandomizationDTO = randomizationRegistrar.getCachedRandomizationDTOObject(study.getOid().toString(), false);
    String randomizationStatusFromOCUI = seRandomizationDTO.getStatus();
    // enabled , disabled
    String randomizationStatusFromOC = pStatus.getValue().toString();
    // available , pending , frozen , locked
    String studyStatus = study.getStatus().getName().toString();
    // available , pending , frozen , locked
    String siteStatus = siteStudy.getStatus().getName().toString();
    System.out.println("randomizationStatusFromOCUI: " + randomizationStatusFromOCUI + "  randomizationStatusFromOC: " + randomizationStatusFromOC + "   studyStatus: " + studyStatus + "   siteStatus: " + siteStatus);
    logger.info("randomizationStatusFromOCUI: " + randomizationStatusFromOCUI + "  randomizationStatusFromOC: " + randomizationStatusFromOC + "   studyStatus: " + studyStatus + "   siteStatus: " + siteStatus);
    if (randomizationStatusFromOC.equalsIgnoreCase("enabled") && studyStatus.equalsIgnoreCase("available") && siteStatus.equalsIgnoreCase("available") && randomizationStatusFromOCUI.equalsIgnoreCase("ACTIVE")) {
        accessPermission = true;
    }
    return accessPermission;
}
Also used : StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) RandomizationRegistrar(org.akaza.openclinica.service.pmanage.RandomizationRegistrar) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) SeRandomizationDTO(org.akaza.openclinica.service.pmanage.SeRandomizationDTO)

Example 2 with StudyParameterValueDAO

use of org.akaza.openclinica.dao.service.StudyParameterValueDAO in project OpenClinica by OpenClinica.

the class MetadataUnit method collectMetaDataVersion.

private void collectMetaDataVersion() {
    ArrayList<StudyEventDefinitionBean> sedBeansInStudy = (ArrayList<StudyEventDefinitionBean>) studyBase.getSedBeansInStudy();
    if (sedBeansInStudy == null || sedBeansInStudy.size() < 1) {
        logger.info("null, because there is no study event definition in this study.");
        return;
    }
    StudyBean study = studyBase.getStudy();
    StudyConfigService studyConfig = new StudyConfigService(this.ds);
    study = studyConfig.setParametersForStudy(study);
    MetaDataVersionBean metadata = this.odmStudy.getMetaDataVersion();
    metadata.setStudy(study);
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(this.ds);
    int parentId = study.getParentStudyId() > 0 ? study.getParentStudyId() : study.getId();
    StudyParameterValueBean spv = spvdao.findByHandleAndStudy(parentId, "discrepancyManagement");
    metadata.setSoftHard(spv.getValue().equalsIgnoreCase("true") ? "Hard" : "Soft");
    OdmExtractDAO oedao = new OdmExtractDAO(this.ds);
    int studyId = study.getId();
    int parentStudyId = study.getParentStudyId() > 0 ? study.getParentStudyId() : studyId;
    if (this.getCategory() == 1 && study.isSite(study.getParentStudyId())) {
        // populate MetaDataVersion attributes
        if (dataset != null) {
            metadata.setOid(dataset.getODMMetaDataVersionOid() + "-" + study.getOid());
            metadata.setName(dataset.getODMMetaDataVersionName() + "-" + study.getOid());
            this.setParentMetaDataVersionOid(dataset.getODMMetaDataVersionOid());
        }
        if (metadata.getOid() == null || metadata.getOid().length() <= 0) {
            metadata.setOid("v1.0.0" + "-" + study.getOid());
            this.setParentMetaDataVersionOid("v1.0.0");
        }
        if (metadata.getName() == null || metadata.getName().length() <= 0) {
            metadata.setName("MetaDataVersion_v1.0.0" + "-" + study.getOid());
        }
        // populate Include
        this.collectIncludeFromParentInSameFile();
        // populate protocol
        oedao.getUpdatedSiteMetadata(parentStudyId, studyId, metadata, this.odmBean.getODMVersion());
    } else {
        if (dataset != null) {
            metadata.setOid(dataset.getODMMetaDataVersionOid());
            metadata.setName(dataset.getODMMetaDataVersionName());
        }
        if (metadata.getOid() == null || metadata.getOid().length() <= 0) {
            metadata.setOid("v1.0.0");
        }
        if (metadata.getName() == null || metadata.getName().length() <= 0) {
            metadata.setName("MetaDataVersion_v1.0.0");
        }
        // populate Include
        String psOid = new String();
        String pmOid = new String();
        if (dataset != null) {
            psOid = dataset.getODMPriorStudyOid();
            pmOid = dataset.getODMPriorMetaDataVersionOid();
        }
        if (pmOid != null && pmOid.length() > 0) {
            MetaDataVersionIncludeBean ib = metadata.getInclude();
            ib.setMetaDataVersionOID(pmOid);
            if (psOid != null && psOid.length() > 0) {
                ib.setStudyOID(psOid);
            } else {
                ib.setStudyOID(study.getOid());
            }
        }
        // populate protocol
        // Set<Integer> nullCodeSet = oedao.getMetadata(parentStudyId,
        // studyId,
        // metadata, this.getODMBean().getODMVersion());
        // studyBase.setNullClSet(nullCodeSet);
        oedao.getMetadata(parentStudyId, studyId, metadata, this.odmBean.getODMVersion());
        metadata.setRuleSetRules(getRuleSetRuleDao().findByRuleSetStudyIdAndStatusAvail(parentStudyId));
    }
}
Also used : StudyConfigService(org.akaza.openclinica.dao.service.StudyConfigService) StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) MetaDataVersionIncludeBean(org.akaza.openclinica.bean.odmbeans.MetaDataVersionIncludeBean) MetaDataVersionBean(org.akaza.openclinica.bean.odmbeans.MetaDataVersionBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) OdmStudyBean(org.akaza.openclinica.bean.odmbeans.OdmStudyBean) ArrayList(java.util.ArrayList) OdmExtractDAO(org.akaza.openclinica.dao.extract.OdmExtractDAO) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO)

Example 3 with StudyParameterValueDAO

use of org.akaza.openclinica.dao.service.StudyParameterValueDAO in project OpenClinica by OpenClinica.

the class ListStudySubjectServlet method processRequest.

// >>
// < ResourceBundleresword;
@Override
public void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    locale = LocaleResolver.getLocale(request);
    // < resword =
    // ResourceBundle.getBundle("org.akaza.openclinica.i18n.words",locale);
    // BWP 3098 << close the info side panel and show icons
    request.setAttribute("closeInfoShowIcons", true);
    // >>
    // BWP 3195, 3330 : designed to address pagination issues
    String pageNumber = fp.getString(SUBJECT_PAGE_NUMBER);
    StringBuilder paginatingQuery = new StringBuilder("");
    String filterKeyword = fp.getString(FILTER_KEYWORD);
    String tmpSearch = fp.getString(SEARCH_SUBMITTED);
    boolean searchSubmitted = !(tmpSearch == null || "".equalsIgnoreCase(tmpSearch)) && !"".equalsIgnoreCase(filterKeyword) && !"+".equalsIgnoreCase(filterKeyword);
    if (pageNumber != null && !"".equalsIgnoreCase(pageNumber)) {
        int tempNum = 0;
        try {
            tempNum = Integer.parseInt(pageNumber);
        } catch (NumberFormatException nfe) {
        // tempNum is already initialized to 0
        }
        if (tempNum > 0) {
            paginatingQuery = new StringBuilder(SUBJECT_PAGE_NUMBER).append("=").append(pageNumber);
            paginatingQuery.append("&ebl_paginated=1");
        }
    }
    // URL encode the search keyword, since it will be a parameter in the
    // URL
    String filterKeywordURLEncode = java.net.URLEncoder.encode(filterKeyword, "UTF-8");
    if (searchSubmitted) {
        paginatingQuery.append("&ebl_sortColumnInd=0&submitted=1&ebl_sortAscending=1&ebl_filtered=1");
        paginatingQuery.append("&").append(FILTER_KEYWORD).append("=").append(filterKeywordURLEncode);
    }
    request.setAttribute(PAGINATING_QUERY, paginatingQuery.toString());
    StudyDAO stdao = new StudyDAO(sm.getDataSource());
    StudySubjectDAO sdao = new StudySubjectDAO(sm.getDataSource());
    StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
    StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
    SubjectGroupMapDAO sgmdao = new SubjectGroupMapDAO(sm.getDataSource());
    StudyGroupClassDAO sgcdao = new StudyGroupClassDAO(sm.getDataSource());
    StudyGroupDAO sgdao = new StudyGroupDAO(sm.getDataSource());
    StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
    // YW << update study parameters of current study.
    // "collectDob" and "genderRequired" are set as the same as the parent
    // study
    // tbh, also add the params "subjectPersonIdRequired",
    // "subjectIdGeneration", "subjectIdPrefixSuffix"
    int parentStudyId = currentStudy.getParentStudyId();
    ArrayList studyGroupClasses = new ArrayList();
    ArrayList allDefs = new ArrayList();
    // tbh
    if (parentStudyId > 0) {
        StudyBean parentStudy = (StudyBean) stdao.findByPK(parentStudyId);
        studyGroupClasses = sgcdao.findAllActiveByStudy(parentStudy);
        allDefs = seddao.findAllActiveByStudy(parentStudy);
    } else {
        parentStudyId = currentStudy.getId();
        studyGroupClasses = sgcdao.findAllActiveByStudy(currentStudy);
        allDefs = seddao.findAllActiveByStudy(currentStudy);
    }
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
    StudyParameterValueBean parentSPV = spvdao.findByHandleAndStudy(parentStudyId, "collectDob");
    currentStudy.getStudyParameterConfig().setCollectDob(parentSPV.getValue());
    parentSPV = spvdao.findByHandleAndStudy(parentStudyId, "genderRequired");
    currentStudy.getStudyParameterConfig().setGenderRequired(parentSPV.getValue());
    parentSPV = spvdao.findByHandleAndStudy(parentStudyId, "subjectPersonIdRequired");
    currentStudy.getStudyParameterConfig().setSubjectPersonIdRequired(parentSPV.getValue());
    parentSPV = spvdao.findByHandleAndStudy(parentStudyId, "subjectIdGeneration");
    currentStudy.getStudyParameterConfig().setSubjectIdGeneration(parentSPV.getValue());
    parentSPV = spvdao.findByHandleAndStudy(parentStudyId, "subjectIdPrefixSuffix");
    currentStudy.getStudyParameterConfig().setSubjectIdPrefixSuffix(parentSPV.getValue());
    // for all the study groups for each group class
    for (int i = 0; i < studyGroupClasses.size(); i++) {
        StudyGroupClassBean sgc = (StudyGroupClassBean) studyGroupClasses.get(i);
        ArrayList groups = sgdao.findAllByGroupClass(sgc);
        sgc.setStudyGroups(groups);
    }
    request.setAttribute("studyGroupClasses", studyGroupClasses);
    // information for the event tabs
    session.setAttribute("allDefsArray", allDefs);
    session.setAttribute("allDefsNumber", new Integer(allDefs.size()));
    session.setAttribute("groupSize", new Integer(studyGroupClasses.size()));
    // find all the subjects in current study
    ArrayList subjects = sdao.findAllByStudyId(currentStudy.getId());
    ArrayList<DisplayStudySubjectBean> displayStudySubs = new ArrayList<DisplayStudySubjectBean>();
    // BEGIN LOOPING THROUGH SUBJECTS
    for (int i = 0; i < subjects.size(); i++) {
        StudySubjectBean studySub = (StudySubjectBean) subjects.get(i);
        ArrayList groups = (ArrayList) sgmdao.findAllByStudySubject(studySub.getId());
        ArrayList subGClasses = new ArrayList();
        for (int j = 0; j < studyGroupClasses.size(); j++) {
            StudyGroupClassBean sgc = (StudyGroupClassBean) studyGroupClasses.get(j);
            boolean hasClass = false;
            for (int k = 0; k < groups.size(); k++) {
                SubjectGroupMapBean sgmb = (SubjectGroupMapBean) groups.get(k);
                if (sgmb.getGroupClassName().equalsIgnoreCase(sgc.getName())) {
                    subGClasses.add(sgmb);
                    hasClass = true;
                    break;
                }
            }
            if (!hasClass) {
                subGClasses.add(new SubjectGroupMapBean());
            }
        }
        ArrayList subEvents = new ArrayList();
        // find all events order by definition ordinal
        ArrayList events = sedao.findAllByStudySubject(studySub);
        for (int j = 0; j < allDefs.size(); j++) {
            StudyEventDefinitionBean sed = (StudyEventDefinitionBean) allDefs.get(j);
            boolean hasDef = false;
            // logger.info("...set blank to "+blankid);
            for (int k = 0; k < events.size(); k++) {
                StudyEventBean se = (StudyEventBean) events.get(k);
                if (se.getStudyEventDefinitionId() == sed.getId()) {
                    se.setStudyEventDefinition(sed);
                    // logger.info(">>>found assigned id "+sed.getId()+" sed
                    // name: "+sed.getName()+" "+se.getId());
                    subEvents.add(se);
                    hasDef = true;
                }
            }
            if (!hasDef) {
                StudyEventBean blank = new StudyEventBean();
                blank.setSubjectEventStatus(SubjectEventStatus.NOT_SCHEDULED);
                blank.setStudyEventDefinitionId(sed.getId());
                // how can we set the following:
                // logger.info("...resetting blank id: "+blank.getId()+" to
                // "+blankid);
                // blank.setId(blankid);
                blank.setStudyEventDefinition(sed);
                // logger.info(">>>blank id: "+blank.getId());
                // logger.info(">>>found unassigned id "+sed.getId()+" sed
                // name: "+sed.getName()+" ");
                subEvents.add(blank);
            }
        }
        // logger.info("subevents size after all adds: "+subEvents.size());
        // reorganize the events and find the repeating ones
        // subEvents:[aa bbb cc d ee]
        // finalEvents:[a(2) b(3) c(2) d e(2)]
        int prevDefId = 0;
        int currDefId = 0;
        ArrayList finalEvents = new ArrayList();
        int repeatingNum = 1;
        int count = 0;
        StudyEventBean event = new StudyEventBean();
        // begin looping through subject events
        for (int j = 0; j < subEvents.size(); j++) {
            StudyEventBean se = (StudyEventBean) subEvents.get(j);
            currDefId = se.getStudyEventDefinitionId();
            if (currDefId != prevDefId) {
                // find a new event
                if (repeatingNum > 1) {
                    event.setRepeatingNum(repeatingNum);
                    repeatingNum = 1;
                }
                // add current event to final
                finalEvents.add(se);
                event = se;
                count++;
            // logger.info("event id? "+event.getId());
            } else {
                // repeating event
                repeatingNum++;
                event.getRepeatEvents().add(se);
                // event.getRepeatEvents().size());
                if (j == subEvents.size() - 1) {
                    event.setRepeatingNum(repeatingNum);
                    repeatingNum = 1;
                }
            }
            prevDefId = currDefId;
        }
        // end looping through subject events
        DisplayStudySubjectBean dssb = new DisplayStudySubjectBean();
        // logger.info("final events size: "+finalEvents.size());
        dssb.setStudyEvents(finalEvents);
        dssb.setStudySubject(studySub);
        dssb.setStudyGroups(subGClasses);
        displayStudySubs.add(dssb);
    }
    // END LOOPING THROUGH SUBJECTS
    // Set a subject property to determine whether to show a signed-type
    // icon (electronic signature)
    // in the JSP view or not
    // Get all event crfs by studyevent id; then use
    // EventDefinitionCRFDAO.isRequired to
    // determine whether any uncompleted CRFs are required.
    boolean isRequiredUncomplete = false;
    for (DisplayStudySubjectBean subject : displayStudySubs) {
        for (Iterator it = subject.getStudyEvents().iterator(); it.hasNext(); ) {
            StudyEventBean event = (StudyEventBean) it.next();
            if (event.getSubjectEventStatus() != null && event.getSubjectEventStatus().getId() == 3) {
                // disallow the subject from signing any studies
                subject.setStudySignable(false);
                break;
            } else {
                // determine whether the subject has any required,
                // uncompleted event CRFs
                isRequiredUncomplete = eventHasRequiredUncompleteCRFs(event);
                if (isRequiredUncomplete) {
                    subject.setStudySignable(false);
                    break;
                }
            }
        }
    }
    fp = new FormProcessor(request);
    EntityBeanTable table = fp.getEntityBeanTable();
    ArrayList allStudyRows = DisplayStudySubjectRow.generateRowsFromBeans(displayStudySubs);
    ArrayList columnArray = new ArrayList();
    columnArray.add(resword.getString("study_subject_ID"));
    columnArray.add(resword.getString("subject_status"));
    columnArray.add(resword.getString("OID"));
    columnArray.add(resword.getString("gender"));
    // new
    columnArray.add(resword.getString("secondary_ID"));
    for (int i = 0; i < studyGroupClasses.size(); i++) {
        StudyGroupClassBean sgc = (StudyGroupClassBean) studyGroupClasses.get(i);
        columnArray.add(sgc.getName());
    }
    for (int i = 0; i < allDefs.size(); i++) {
        StudyEventDefinitionBean sed = (StudyEventDefinitionBean) allDefs.get(i);
        columnArray.add(sed.getName());
    }
    columnArray.add(resword.getString("actions"));
    String[] columns = new String[columnArray.size()];
    columnArray.toArray(columns);
    // String[] columns = {"ID", "Subject Status", "Gender", "Enrollment
    // Date",
    // "Study Events", "Actions" };
    table.setColumns(new ArrayList(Arrays.asList(columns)));
    table.setQuery(getBaseURL(), new HashMap());
    table.hideColumnLink(columnArray.size() - 1);
    // table.addLink("Enroll a new subject",
    // "javascript:leftnavExpand('addSubjectRowExpress');");
    table.setRows(allStudyRows);
    if (filterKeyword != null && !"".equalsIgnoreCase(filterKeyword)) {
        table.setKeywordFilter(filterKeyword);
    }
    table.computeDisplay();
    request.setAttribute("table", table);
    // request.setAttribute("subjects", subjects);
    String idSetting = currentStudy.getStudyParameterConfig().getSubjectIdGeneration();
    // set up auto study subject id
    if (idSetting.equals("auto editable") || idSetting.equals("auto non-editable")) {
        // Shaoyu Su
        // int nextLabel = ssdao.findTheGreatestLabel() + 1;
        // request.setAttribute("label", new Integer(nextLabel).toString());
        request.setAttribute("label", resword.getString("id_generated_Save_Add"));
    }
    FormDiscrepancyNotes discNotes = new FormDiscrepancyNotes();
    session.setAttribute(AddNewSubjectServlet.FORM_DISCREPANCY_NOTES_NAME, discNotes);
    forwardPage(getJSP());
}
Also used : SubjectGroupMapBean(org.akaza.openclinica.bean.submit.SubjectGroupMapBean) HashMap(java.util.HashMap) StudyGroupClassDAO(org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO) EntityBeanTable(org.akaza.openclinica.web.bean.EntityBeanTable) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) StudyGroupDAO(org.akaza.openclinica.dao.managestudy.StudyGroupDAO) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) DisplayStudyEventBean(org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean) StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) DisplayStudySubjectBean(org.akaza.openclinica.bean.managestudy.DisplayStudySubjectBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) StudyGroupClassBean(org.akaza.openclinica.bean.managestudy.StudyGroupClassBean) Iterator(java.util.Iterator) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) SubjectGroupMapDAO(org.akaza.openclinica.dao.submit.SubjectGroupMapDAO) FormDiscrepancyNotes(org.akaza.openclinica.control.form.FormDiscrepancyNotes) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) DisplayStudySubjectBean(org.akaza.openclinica.bean.managestudy.DisplayStudySubjectBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO)

Example 4 with StudyParameterValueDAO

use of org.akaza.openclinica.dao.service.StudyParameterValueDAO 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 5 with StudyParameterValueDAO

use of org.akaza.openclinica.dao.service.StudyParameterValueDAO 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

StudyParameterValueDAO (org.akaza.openclinica.dao.service.StudyParameterValueDAO)55 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)37 ArrayList (java.util.ArrayList)36 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)29 StudyParameterValueBean (org.akaza.openclinica.bean.service.StudyParameterValueBean)28 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)22 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)21 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)17 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)16 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)16 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)15 Date (java.util.Date)13 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)13 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)10 ParticipantPortalRegistrar (org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar)10 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)9 HashMap (java.util.HashMap)8 Iterator (java.util.Iterator)7 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)7 StudyConfigService (org.akaza.openclinica.dao.service.StudyConfigService)7