Search in sources :

Example 56 with EventCRFDAO

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

the class RemoveCRFServlet method processRequest.

@Override
public void processRequest() throws Exception {
    CRFDAO cdao = new CRFDAO(sm.getDataSource());
    CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
    FormProcessor fp = new FormProcessor(request);
    // checks which module the requests are from
    String module = fp.getString(MODULE);
    request.setAttribute(MODULE, module);
    int crfId = fp.getInt("id", true);
    String action = request.getParameter("action");
    if (crfId == 0) {
        addPageMessage(respage.getString("please_choose_a_CRF_to_remove"));
        forwardPage(Page.CRF_LIST_SERVLET);
    } else {
        CRFBean crf = (CRFBean) cdao.findByPK(crfId);
        ArrayList versions = cvdao.findAllByCRFId(crfId);
        crf.setVersions(versions);
        EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
        ArrayList edcs = (ArrayList) edcdao.findAllByCRF(crfId);
        SectionDAO secdao = new SectionDAO(sm.getDataSource());
        EventCRFDAO evdao = new EventCRFDAO(sm.getDataSource());
        ArrayList eventCRFs = evdao.findAllByCRF(crfId);
        StudyEventDAO seDao = new StudyEventDAO(sm.getDataSource());
        StudyEventDefinitionDAO sedDao = new StudyEventDefinitionDAO(sm.getDataSource());
        for (Object ecBean : eventCRFs) {
            StudyEventBean seBean = (StudyEventBean) seDao.findByPK(((EventCRFBean) ecBean).getStudyEventId());
            StudyEventDefinitionBean sedBean = (StudyEventDefinitionBean) sedDao.findByPK(seBean.getStudyEventDefinitionId());
            ((EventCRFBean) ecBean).setEventName(sedBean.getName());
        }
        if ("confirm".equalsIgnoreCase(action)) {
            request.setAttribute("crfToRemove", crf);
            request.setAttribute("eventCRFs", eventCRFs);
            forwardPage(Page.REMOVE_CRF);
        } else {
            logger.info("submit to remove the crf");
            crf.setStatus(Status.DELETED);
            crf.setUpdater(ub);
            crf.setUpdatedDate(new Date());
            cdao.update(crf);
            for (int i = 0; i < versions.size(); i++) {
                CRFVersionBean version = (CRFVersionBean) versions.get(i);
                if (!version.getStatus().equals(Status.DELETED)) {
                    version.setStatus(Status.AUTO_DELETED);
                    version.setUpdater(ub);
                    version.setUpdatedDate(new Date());
                    cvdao.update(version);
                    ArrayList sections = secdao.findAllByCRFVersionId(version.getId());
                    for (int j = 0; j < sections.size(); j++) {
                        SectionBean section = (SectionBean) sections.get(j);
                        if (!section.getStatus().equals(Status.DELETED)) {
                            section.setStatus(Status.AUTO_DELETED);
                            section.setUpdater(ub);
                            section.setUpdatedDate(new Date());
                            secdao.update(section);
                        }
                    }
                }
            }
            for (int i = 0; i < edcs.size(); i++) {
                EventDefinitionCRFBean edc = (EventDefinitionCRFBean) edcs.get(i);
                if (!edc.getStatus().equals(Status.DELETED)) {
                    edc.setStatus(Status.AUTO_DELETED);
                    edc.setUpdater(ub);
                    edc.setUpdatedDate(new Date());
                    edcdao.update(edc);
                }
            }
            ItemDataDAO idao = new ItemDataDAO(sm.getDataSource());
            for (int i = 0; i < eventCRFs.size(); i++) {
                EventCRFBean eventCRF = (EventCRFBean) eventCRFs.get(i);
                if (!eventCRF.getStatus().equals(Status.DELETED)) {
                    eventCRF.setStatus(Status.AUTO_DELETED);
                    eventCRF.setUpdater(ub);
                    eventCRF.setUpdatedDate(new Date());
                    evdao.update(eventCRF);
                    ArrayList items = idao.findAllByEventCRFId(eventCRF.getId());
                    for (int j = 0; j < items.size(); j++) {
                        ItemDataBean item = (ItemDataBean) items.get(j);
                        if (!item.getStatus().equals(Status.DELETED)) {
                            item.setStatus(Status.AUTO_DELETED);
                            item.setUpdater(ub);
                            item.setUpdatedDate(new Date());
                            idao.update(item);
                        }
                    }
                }
            }
            addPageMessage(respage.getString("the_CRF") + crf.getName() + " " + respage.getString("has_been_removed_succesfully"));
            forwardPage(Page.CRF_LIST_SERVLET);
        }
    }
}
Also used : EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) 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) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) Date(java.util.Date) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) SectionBean(org.akaza.openclinica.bean.submit.SectionBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) SectionDAO(org.akaza.openclinica.dao.submit.SectionDAO)

Example 57 with EventCRFDAO

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

the class RemoveCRFVersionServlet method processRequest.

@Override
public void processRequest() throws Exception {
    CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
    FormProcessor fp = new FormProcessor(request);
    int versionId = fp.getInt("id", true);
    String module = fp.getString("module");
    request.setAttribute("module", module);
    String action = fp.getString("action");
    if (versionId == 0) {
        addPageMessage(respage.getString("please_choose_a_CRF_version_to_remove"));
        forwardPage(Page.CRF_LIST_SERVLET);
    } else {
        if (StringUtil.isBlank(action)) {
            addPageMessage(respage.getString("no_action_specified"));
            forwardPage(Page.CRF_LIST_SERVLET);
            return;
        }
        CRFVersionBean version = (CRFVersionBean) cvdao.findByPK(versionId);
        if (!ub.isSysAdmin() && (version.getOwnerId() != ub.getId())) {
            addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
            forwardPage(Page.MENU_SERVLET);
            return;
        }
        SectionDAO secdao = new SectionDAO(sm.getDataSource());
        EventCRFDAO evdao = new EventCRFDAO(sm.getDataSource());
        // find all event crfs by version id
        ArrayList eventCRFs = evdao.findUndeletedWithStudySubjectsByCRFVersion(versionId);
        if ("confirm".equalsIgnoreCase(action)) {
            request.setAttribute("versionToRemove", version);
            request.setAttribute("eventCRFs", eventCRFs);
            forwardPage(Page.REMOVE_CRF_VERSION);
        } else {
            logger.info("submit to remove the crf version");
            // version
            version.setStatus(Status.DELETED);
            version.setUpdater(ub);
            version.setUpdatedDate(new Date());
            cvdao.update(version);
            // crfs in the second pass
            for (int ii = 0; ii < eventCRFs.size(); ii++) {
                EventCRFBean ecbean = (EventCRFBean) eventCRFs.get(ii);
                ecbean.setStatus(Status.AUTO_DELETED);
                ecbean.setUpdater(ub);
                ecbean.setUpdatedDate(new Date());
                evdao.update(ecbean);
            }
            // added above tbh 092007, to fix task
            // all sections
            ArrayList sections = secdao.findAllByCRFVersionId(version.getId());
            for (int j = 0; j < sections.size(); j++) {
                SectionBean section = (SectionBean) sections.get(j);
                if (!section.getStatus().equals(Status.DELETED)) {
                    section.setStatus(Status.AUTO_DELETED);
                    section.setUpdater(ub);
                    section.setUpdatedDate(new Date());
                    secdao.update(section);
                }
            }
            // all item data related to event crfs
            ItemDataDAO idao = new ItemDataDAO(sm.getDataSource());
            for (int i = 0; i < eventCRFs.size(); i++) {
                EventCRFBean eventCRF = (EventCRFBean) eventCRFs.get(i);
                if (!eventCRF.getStatus().equals(Status.DELETED)) {
                    eventCRF.setStatus(Status.AUTO_DELETED);
                    eventCRF.setUpdater(ub);
                    eventCRF.setUpdatedDate(new Date());
                    evdao.update(eventCRF);
                    ArrayList items = idao.findAllByEventCRFId(eventCRF.getId());
                    for (int j = 0; j < items.size(); j++) {
                        ItemDataBean item = (ItemDataBean) items.get(j);
                        if (!item.getStatus().equals(Status.DELETED)) {
                            item.setStatus(Status.AUTO_DELETED);
                            item.setUpdater(ub);
                            item.setUpdatedDate(new Date());
                            idao.update(item);
                        }
                    }
                }
            }
            ArrayList versionList = (ArrayList) cvdao.findAllByCRF(version.getCrfId());
            if (versionList.size() > 0) {
                EventDefinitionCRFDAO edCRFDao = new EventDefinitionCRFDAO(sm.getDataSource());
                ArrayList edcList = (ArrayList) edCRFDao.findAllByCRF(version.getCrfId());
                for (int i = 0; i < edcList.size(); i++) {
                    EventDefinitionCRFBean edcBean = (EventDefinitionCRFBean) edcList.get(i);
                    updateEventDef(edcBean, edCRFDao, versionList);
                }
            }
            addPageMessage(respage.getString("the_CRF") + version.getName() + " " + respage.getString("has_been_removed_succesfully"));
            forwardPage(Page.CRF_LIST_SERVLET);
        }
    }
}
Also used : CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) ArrayList(java.util.ArrayList) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) Date(java.util.Date) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) SectionBean(org.akaza.openclinica.bean.submit.SectionBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) SectionDAO(org.akaza.openclinica.dao.submit.SectionDAO)

Example 58 with EventCRFDAO

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

the class ViewNoteServlet method processRequest.

@Override
protected void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    Locale locale = LocaleResolver.getLocale(request);
    DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.DEFAULT, locale);
    DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(sm.getDataSource());
    dndao.setFetchMapping(true);
    int noteId = fp.getInt(NOTE_ID, true);
    DiscrepancyNoteBean note = (DiscrepancyNoteBean) dndao.findByPK(noteId);
    String entityType = note.getEntityType();
    if (note.getEntityId() > 0 && !entityType.equals("")) {
        if (!StringUtil.isBlank(entityType)) {
            if ("itemData".equalsIgnoreCase(entityType)) {
                ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
                ItemDataBean itemData = (ItemDataBean) iddao.findByPK(note.getEntityId());
                ItemDAO idao = new ItemDAO(sm.getDataSource());
                ItemBean item = (ItemBean) idao.findByPK(itemData.getItemId());
                note.setEntityValue(itemData.getValue());
                note.setEntityName(item.getName());
                //Mantis Issue 5165. It should be itemData.getId() instead of item.getId()
                note.setEntityId(itemData.getId());
                EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
                EventCRFBean ec = (EventCRFBean) ecdao.findByPK(itemData.getEventCRFId());
                StudyEventDAO sed = new StudyEventDAO(sm.getDataSource());
                StudyEventBean se = (StudyEventBean) sed.findByPK(ec.getStudyEventId());
                StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
                StudySubjectBean ssub = (StudySubjectBean) ssdao.findByPK(se.getStudySubjectId());
                note.setStudySub(ssub);
                StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
                StudyEventDefinitionBean sedb = (StudyEventDefinitionBean) seddao.findByPK(se.getStudyEventDefinitionId());
                se.setName(sedb.getName());
                note.setEvent(se);
                CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
                CRFVersionBean cv = (CRFVersionBean) cvdao.findByPK(ec.getCRFVersionId());
                CRFDAO cdao = new CRFDAO(sm.getDataSource());
                CRFBean crf = (CRFBean) cdao.findByPK(cv.getCrfId());
                note.setCrfName(crf.getName());
            } else if ("studySub".equalsIgnoreCase(entityType)) {
                StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
                StudySubjectBean ssub = (StudySubjectBean) ssdao.findByPK(note.getEntityId());
                note.setStudySub(ssub);
                // System.out.println("column" + note.getColumn());
                SubjectDAO sdao = new SubjectDAO(sm.getDataSource());
                SubjectBean sub = (SubjectBean) sdao.findByPK(ssub.getSubjectId());
                if (!StringUtil.isBlank(note.getColumn())) {
                    if ("enrollment_date".equalsIgnoreCase(note.getColumn())) {
                        if (ssub.getEnrollmentDate() != null) {
                            note.setEntityValue(dateFormatter.format(ssub.getEnrollmentDate()));
                        }
                        note.setEntityName(resword.getString("enrollment_date"));
                    } else if ("gender".equalsIgnoreCase(note.getColumn())) {
                        note.setEntityValue(sub.getGender() + "");
                        note.setEntityName(resword.getString("gender"));
                    } else if ("date_of_birth".equalsIgnoreCase(note.getColumn())) {
                        if (sub.getDateOfBirth() != null) {
                            note.setEntityValue(dateFormatter.format(sub.getDateOfBirth()));
                        }
                        note.setEntityName(resword.getString("date_of_birth"));
                    }
                }
            } else if ("subject".equalsIgnoreCase(entityType)) {
                SubjectDAO sdao = new SubjectDAO(sm.getDataSource());
                SubjectBean sub = (SubjectBean) sdao.findByPK(note.getEntityId());
                StudySubjectBean ssub = new StudySubjectBean();
                ssub.setLabel(sub.getUniqueIdentifier());
                note.setStudySub(ssub);
                if (!StringUtil.isBlank(note.getColumn())) {
                    if ("gender".equalsIgnoreCase(note.getColumn())) {
                        note.setEntityValue(sub.getGender() + "");
                        note.setEntityName(resword.getString("gender"));
                    } else if ("date_of_birth".equalsIgnoreCase(note.getColumn())) {
                        if (sub.getDateOfBirth() != null) {
                            note.setEntityValue(dateFormatter.format(sub.getDateOfBirth()));
                        }
                        note.setEntityName(resword.getString("date_of_birth"));
                    } else if ("unique_identifier".equalsIgnoreCase(note.getColumn())) {
                        note.setEntityName(resword.getString("unique_identifier"));
                        note.setEntityValue(sub.getUniqueIdentifier());
                    }
                }
            } else if ("studyEvent".equalsIgnoreCase(entityType)) {
                StudyEventDAO sed = new StudyEventDAO(sm.getDataSource());
                StudyEventBean se = (StudyEventBean) sed.findByPK(note.getEntityId());
                StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
                StudySubjectBean ssub = (StudySubjectBean) ssdao.findByPK(se.getStudySubjectId());
                note.setStudySub(ssub);
                StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
                StudyEventDefinitionBean sedb = (StudyEventDefinitionBean) seddao.findByPK(se.getStudyEventDefinitionId());
                se.setName(sedb.getName());
                note.setEvent(se);
                if (!StringUtil.isBlank(note.getColumn())) {
                    if ("location".equalsIgnoreCase(note.getColumn())) {
                        request.setAttribute("entityValue", se.getLocation());
                        request.setAttribute("entityName", resword.getString("location"));
                        note.setEntityName(resword.getString("location"));
                        note.setEntityValue(se.getLocation());
                    } else if ("date_start".equalsIgnoreCase(note.getColumn())) {
                        if (se.getDateStarted() != null) {
                            note.setEntityValue(dateFormatter.format(se.getDateStarted()));
                        }
                        note.setEntityName(resword.getString("start_date"));
                    } else if ("date_end".equalsIgnoreCase(note.getColumn())) {
                        if (se.getDateEnded() != null) {
                            note.setEntityValue(dateFormatter.format(se.getDateEnded()));
                        }
                        note.setEntityName(resword.getString("end_date"));
                    }
                }
            } else if ("eventCrf".equalsIgnoreCase(entityType)) {
                EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
                EventCRFBean ec = (EventCRFBean) ecdao.findByPK(note.getEntityId());
                StudySubjectBean ssub = (StudySubjectBean) new StudySubjectDAO(sm.getDataSource()).findByPK(ec.getStudySubjectId());
                note.setStudySub(ssub);
                StudyEventBean event = (StudyEventBean) new StudyEventDAO(sm.getDataSource()).findByPK(ec.getStudyEventId());
                note.setEvent(event);
                if (!StringUtil.isBlank(note.getColumn())) {
                    if ("date_interviewed".equals(note.getColumn())) {
                        if (ec.getDateInterviewed() != null) {
                            note.setEntityValue(dateFormatter.format(ec.getDateInterviewed()));
                        }
                        note.setEntityName(resword.getString("date_interviewed"));
                    } else if ("interviewer_name".equals(note.getColumn())) {
                        note.setEntityValue(ec.getInterviewerName());
                        note.setEntityName(resword.getString("interviewer_name"));
                    }
                }
            }
        }
    }
    // Mantis Issue 8495.
    if (note.getStudyId() != currentStudy.getId()) {
        if (currentStudy.getParentStudyId() > 0) {
            if (currentStudy.getId() != note.getStudySub().getStudyId()) {
                addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
                forwardPage(Page.MENU_SERVLET);
                return;
            }
        } else {
            // The SubjectStudy is not belong to currentstudy and current study is not a site.
            StudyDAO studydao = new StudyDAO(sm.getDataSource());
            Collection sites;
            sites = studydao.findOlnySiteIdsByStudy(currentStudy);
            if (!sites.contains(note.getStudySub().getStudyId())) {
                addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
                forwardPage(Page.MENU_SERVLET);
                return;
            }
        }
    }
    // Check end
    UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
    ArrayList<DiscrepancyNoteBean> notes = dndao.findAllEntityByPK(note.getEntityType(), noteId);
    Date lastUpdatedDate = note.getCreatedDate();
    UserAccountBean lastUpdator = (UserAccountBean) udao.findByPK(note.getOwnerId());
    /*
         * for (int i = 0; i < notes.size(); i++) { DiscrepancyNoteBean n =
         * (DiscrepancyNoteBean) notes.get(i); int pId = n.getParentDnId(); if
         * (pId == 0) { note = n; note.setLastUpdator((UserAccountBean)
         * udao.findByPK(n.getOwnerId()));
         * note.setLastDateUpdated(n.getCreatedDate()); lastUpdatedDate =
         * note.getLastDateUpdated(); lastUpdator = note.getLastUpdator(); } }
         */
    // BWP 3029 >> This algorithm needs to be changed to properly set
    // the parent note's status and updated date
    // First sort the notes on their ID; this will put the parent note
    // first; and
    // the note with the latest status and updated date last
    java.util.Collections.sort(notes);
    DiscrepancyNoteBean lastChild = notes.get(notes.size() - 1);
    lastUpdatedDate = lastChild.getCreatedDate();
    lastUpdator = (UserAccountBean) udao.findByPK(lastChild.getOwnerId());
    note.setLastUpdator(lastUpdator);
    note.setLastDateUpdated(lastUpdatedDate);
    note.setUpdatedDate(lastUpdatedDate);
    for (DiscrepancyNoteBean dnBean : notes) {
        if (dnBean.getParentDnId() > 0) {
            note.getChildren().add(dnBean);
        }
    }
    /*
         * for (int i = 0; i < notes.size(); i++) { DiscrepancyNoteBean n =
         * (DiscrepancyNoteBean) notes.get(i); int pId = n.getParentDnId(); if
         * (pId > 0) { note.getChildren().add(n);
         *
         * if (!n.getCreatedDate().before(lastUpdatedDate)) { lastUpdatedDate =
         * n.getCreatedDate(); lastUpdator = (UserAccountBean)
         * udao.findByPK(n.getOwnerId()); note.setLastUpdator(lastUpdator);
         * note.setLastDateUpdated(lastUpdatedDate);
         * note.setResolutionStatusId(n.getResolutionStatusId());
         * note.setResStatus(ResolutionStatus.get(n.getResolutionStatusId())); } } }
         */
    note.setNumChildren(note.getChildren().size());
    note.setDisType(DiscrepancyNoteType.get(note.getDiscrepancyNoteTypeId()));
    request.setAttribute(DIS_NOTE, note);
    forwardPage(Page.VIEW_SINGLE_NOTE);
}
Also used : Locale(java.util.Locale) ItemBean(org.akaza.openclinica.bean.submit.ItemBean) ItemDAO(org.akaza.openclinica.dao.submit.ItemDAO) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) SubjectDAO(org.akaza.openclinica.dao.submit.SubjectDAO) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) DiscrepancyNoteDAO(org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) Date(java.util.Date) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) SubjectBean(org.akaza.openclinica.bean.submit.SubjectBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) DateFormat(java.text.DateFormat) Collection(java.util.Collection) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean)

Example 59 with EventCRFDAO

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

the class ViewNotesServlet method processRequest.

/*
     * (non-Javadoc)
     *
     * @see org.akaza.openclinica.control.core.SecureController#processRequest()
     */
@Override
protected void processRequest() throws Exception {
    String module = request.getParameter("module");
    String moduleStr = "manage";
    if (module != null && module.trim().length() > 0) {
        if ("submit".equals(module)) {
            request.setAttribute("module", "submit");
            moduleStr = "submit";
        } else if ("admin".equals(module)) {
            request.setAttribute("module", "admin");
            moduleStr = "admin";
        } else {
            request.setAttribute("module", "manage");
        }
    }
    FormProcessor fp = new FormProcessor(request);
    if (fp.getString("showMoreLink").equals("")) {
        showMoreLink = true;
    } else {
        showMoreLink = Boolean.parseBoolean(fp.getString("showMoreLink"));
    }
    int oneSubjectId = fp.getInt("id");
    // BWP 11/03/2008 3029: This session attribute in removed in
    // ResolveDiscrepancyServlet.mayProceed() >>
    session.setAttribute("subjectId", oneSubjectId);
    // >>
    int resolutionStatusSubj = fp.getInt(RESOLUTION_STATUS);
    int discNoteType = 0;
    try {
        discNoteType = Integer.parseInt(request.getParameter("type"));
    } catch (NumberFormatException nfe) {
        // Show all DN's
        discNoteType = -1;
    }
    request.setAttribute(DISCREPANCY_NOTE_TYPE, discNoteType);
    boolean removeSession = fp.getBoolean("removeSession");
    // BWP 11/03/2008 3029: This session attribute in removed in
    // ResolveDiscrepancyServlet.mayProceed() >>
    session.setAttribute("module", module);
    // >>
    // Do we only want to view the notes for 1 subject?
    String viewForOne = fp.getString("viewForOne");
    boolean isForOneSubjectsNotes = "y".equalsIgnoreCase(viewForOne);
    DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(sm.getDataSource());
    StudyDAO studyDAO = new StudyDAO(sm.getDataSource());
    dndao.setFetchMapping(true);
    int resolutionStatus = 0;
    try {
        resolutionStatus = Integer.parseInt(request.getParameter("resolutionStatus"));
    } catch (NumberFormatException nfe) {
        // Show all DN's
        resolutionStatus = -1;
    }
    if (removeSession) {
        session.removeAttribute(WIN_LOCATION);
        session.removeAttribute(NOTES_TABLE);
    }
    // after resolving a note, user wants to go back to view notes page, we
    // save the current URL
    // so we can go back later
    session.setAttribute(WIN_LOCATION, "ViewNotes?viewForOne=" + viewForOne + "&id=" + oneSubjectId + "&module=" + module + " &removeSession=1");
    boolean hasAResolutionStatus = resolutionStatus >= 1 && resolutionStatus <= 6;
    Set<Integer> resolutionStatusIds = (HashSet) session.getAttribute(RESOLUTION_STATUS);
    // remove the session if there is no resolution status
    if (!hasAResolutionStatus && resolutionStatusIds != null) {
        session.removeAttribute(RESOLUTION_STATUS);
        resolutionStatusIds = null;
    }
    if (hasAResolutionStatus) {
        if (resolutionStatusIds == null) {
            resolutionStatusIds = new HashSet<Integer>();
        }
        resolutionStatusIds.add(resolutionStatus);
        session.setAttribute(RESOLUTION_STATUS, resolutionStatusIds);
    }
    StudySubjectDAO subdao = new StudySubjectDAO(sm.getDataSource());
    StudyDAO studyDao = new StudyDAO(sm.getDataSource());
    SubjectDAO sdao = new SubjectDAO(sm.getDataSource());
    UserAccountDAO uadao = new UserAccountDAO(sm.getDataSource());
    CRFVersionDAO crfVersionDao = new CRFVersionDAO(sm.getDataSource());
    CRFDAO crfDao = new CRFDAO(sm.getDataSource());
    StudyEventDAO studyEventDao = new StudyEventDAO(sm.getDataSource());
    StudyEventDefinitionDAO studyEventDefinitionDao = new StudyEventDefinitionDAO(sm.getDataSource());
    EventDefinitionCRFDAO eventDefinitionCRFDao = new EventDefinitionCRFDAO(sm.getDataSource());
    ItemDataDAO itemDataDao = new ItemDataDAO(sm.getDataSource());
    ItemDAO itemDao = new ItemDAO(sm.getDataSource());
    EventCRFDAO eventCRFDao = new EventCRFDAO(sm.getDataSource());
    ListNotesTableFactory factory = new ListNotesTableFactory(showMoreLink);
    factory.setSubjectDao(sdao);
    factory.setStudySubjectDao(subdao);
    factory.setUserAccountDao(uadao);
    factory.setStudyDao(studyDao);
    factory.setCurrentStudy(currentStudy);
    factory.setDiscrepancyNoteDao(dndao);
    factory.setCrfDao(crfDao);
    factory.setCrfVersionDao(crfVersionDao);
    factory.setStudyEventDao(studyEventDao);
    factory.setStudyEventDefinitionDao(studyEventDefinitionDao);
    factory.setEventDefinitionCRFDao(eventDefinitionCRFDao);
    factory.setItemDao(itemDao);
    factory.setItemDataDao(itemDataDao);
    factory.setEventCRFDao(eventCRFDao);
    factory.setModule(moduleStr);
    factory.setDiscNoteType(discNoteType);
    factory.setResolutionStatus(resolutionStatus);
    factory.setViewNotesService(resolveViewNotesService());
    // factory.setResolutionStatusIds(resolutionStatusIds);
    TableFacade tf = factory.createTable(request, response);
    Map<String, Map<String, String>> stats = generateDiscrepancyNotesSummary(factory.getNotesSummary());
    Map<String, String> totalMap = generateDiscrepancyNotesTotal(stats);
    int grandTotal = 0;
    for (String typeName : totalMap.keySet()) {
        String total = totalMap.get(typeName);
        grandTotal = total.equals("--") ? grandTotal + 0 : grandTotal + Integer.parseInt(total);
    }
    request.setAttribute("summaryMap", stats);
    tf.setTotalRows(grandTotal);
    String viewNotesHtml = tf.render();
    request.setAttribute("viewNotesHtml", viewNotesHtml);
    String viewNotesURL = this.getPageURL();
    session.setAttribute("viewNotesURL", viewNotesURL);
    String viewNotesPageFileName = this.getPageServletFileName();
    session.setAttribute("viewNotesPageFileName", viewNotesPageFileName);
    request.setAttribute("mapKeys", ResolutionStatus.getMembers());
    request.setAttribute("typeNames", DiscrepancyNoteUtil.getTypeNames());
    request.setAttribute("typeKeys", totalMap);
    request.setAttribute("grandTotal", grandTotal);
    if ("yes".equalsIgnoreCase(fp.getString(PRINT))) {
        List<DiscrepancyNoteBean> allNotes = factory.findAllNotes(tf);
        request.setAttribute("allNotes", allNotes);
        forwardPage(Page.VIEW_DISCREPANCY_NOTES_IN_STUDY_PRINT);
    } else {
        forwardPage(Page.VIEW_DISCREPANCY_NOTES_IN_STUDY);
    }
}
Also used : ItemDAO(org.akaza.openclinica.dao.submit.ItemDAO) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) SubjectDAO(org.akaza.openclinica.dao.submit.SubjectDAO) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) HashSet(java.util.HashSet) DiscrepancyNoteDAO(org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) TableFacade(org.jmesa.facade.TableFacade) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) HashMap(java.util.HashMap) Map(java.util.Map) ListNotesTableFactory(org.akaza.openclinica.control.submit.ListNotesTableFactory)

Example 60 with EventCRFDAO

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

the class TableOfContentsServlet method getEventCRFAndAction.

private void getEventCRFAndAction() {
    ecdao = new EventCRFDAO(sm.getDataSource());
    ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF_BEAN);
    if (ecb == null) {
        int ecid = fp.getInt(INPUT_ID, true);
        AuditableEntityBean aeb = ecdao.findByPKAndStudy(ecid, currentStudy);
        if (!aeb.isActive()) {
            ecb = new EventCRFBean();
        } else {
            ecb = (EventCRFBean) aeb;
        }
        action = fp.getString(INPUT_ACTION, true);
    } else {
        action = getActionForStage(ecb.getStage());
    }
}
Also used : EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) AuditableEntityBean(org.akaza.openclinica.bean.core.AuditableEntityBean) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO)

Aggregations

EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)106 ArrayList (java.util.ArrayList)80 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)76 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)73 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)71 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)57 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)51 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)51 Date (java.util.Date)50 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)49 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)49 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)47 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)45 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)45 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)43 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)41 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)37 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)34 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)32 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)24