Search in sources :

Example 96 with EventCRFDAO

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

the class ChangeCRFVersionController method changeCRFVersionAction.

@RequestMapping("/managestudy/changeCRFVersion")
public // @RequestMapping("/managestudy/changeCRFVersionAction")
ModelMap changeCRFVersionAction(HttpServletRequest request, HttpServletResponse response, @RequestParam("crfId") int crfId, @RequestParam("crfName") String crfName, @RequestParam("formLayoutId") int formLayoutId, @RequestParam("formLayoutName") String formLayoutName, @RequestParam("studySubjectLabel") String studySubjectLabel, @RequestParam("studySubjectId") int studySubjectId, @RequestParam("eventCRFId") int eventCRFId, @RequestParam("eventDefinitionCRFId") int eventDefinitionCRFId, @RequestParam(value = "newFormLayoutId", required = true) int newFormLayoutId) {
    // to be removed for aquamarine
    if (!mayProceed(request)) {
        if (redirect(request, response, "/MainMenu?message=authentication_failed") == null)
            return null;
    }
    ArrayList<String> pageMessages = initPageMessages(request);
    setupResource(request);
    // update event_crf_id table
    try {
        EventCRFDAO event_crf_dao = new EventCRFDAO(dataSource);
        StudyEventDAO sedao = new StudyEventDAO(dataSource);
        EventCRFBean ev_bean = (EventCRFBean) event_crf_dao.findByPK(eventCRFId);
        StudyEventBean st_event_bean = (StudyEventBean) sedao.findByPK(ev_bean.getStudyEventId());
        Connection con = dataSource.getConnection();
        CoreResources.setSchema(con);
        con.setAutoCommit(false);
        event_crf_dao.updateFormLayoutID(eventCRFId, newFormLayoutId, getCurrentUser(request).getId(), con);
        String status_before_update = null;
        SubjectEventStatus eventStatus = null;
        Status subjectStatus = null;
        AuditDAO auditDao = new AuditDAO(dataSource);
        // event signed, check if subject is signed as well
        StudySubjectDAO studySubDao = new StudySubjectDAO(dataSource);
        StudySubjectBean studySubBean = (StudySubjectBean) studySubDao.findByPK(st_event_bean.getStudySubjectId());
        if (studySubBean.getStatus().isSigned()) {
            status_before_update = auditDao.findLastStatus("study_subject", studySubBean.getId(), "8");
            if (status_before_update != null && status_before_update.length() == 1) {
                int subject_status = Integer.parseInt(status_before_update);
                subjectStatus = Status.get(subject_status);
                studySubBean.setStatus(subjectStatus);
            }
            studySubBean.setUpdater(getCurrentUser(request));
            studySubDao.update(studySubBean, con);
        }
        st_event_bean.setUpdater(getCurrentUser(request));
        st_event_bean.setUpdatedDate(new Date());
        status_before_update = auditDao.findLastStatus("study_event", st_event_bean.getId(), "8");
        if (status_before_update != null && status_before_update.length() == 1) {
            int status = Integer.parseInt(status_before_update);
            eventStatus = SubjectEventStatus.get(status);
            st_event_bean.setSubjectEventStatus(eventStatus);
        }
        sedao.update(st_event_bean, con);
        con.commit();
        con.setAutoCommit(true);
        con.close();
        pageMessages.add(resword.getString("confirm_crf_version_ms"));
        String msg = resword.getString("confirm_crf_version_ms");
        redirect(request, response, "/ViewStudySubject?isFromCRFVersionChange=" + msg + "&id=" + studySubjectId);
    } catch (Exception e) {
        pageMessages.add(resword.getString("error_message_cannot_update_crf_version"));
    }
    return null;
}
Also used : Status(org.akaza.openclinica.bean.core.Status) SubjectEventStatus(org.akaza.openclinica.bean.core.SubjectEventStatus) Connection(java.sql.Connection) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) Date(java.util.Date) HttpSessionRequiredException(org.springframework.web.HttpSessionRequiredException) SubjectEventStatus(org.akaza.openclinica.bean.core.SubjectEventStatus) AuditDAO(org.akaza.openclinica.dao.admin.AuditDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 97 with EventCRFDAO

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

the class SecureController method getNoteInfo.

public DiscrepancyNoteBean getNoteInfo(DiscrepancyNoteBean note) {
    StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
    if ("itemData".equalsIgnoreCase(note.getEntityType())) {
        int itemDataId = note.getEntityId();
        ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
        ItemDataBean itemData = (ItemDataBean) iddao.findByPK(itemDataId);
        ItemDAO idao = new ItemDAO(sm.getDataSource());
        if (StringUtil.isBlank(note.getEntityName())) {
            ItemBean item = (ItemBean) idao.findByPK(itemData.getItemId());
            note.setEntityName(item.getName());
            request.setAttribute("item", item);
        }
        EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
        StudyEventDAO svdao = new StudyEventDAO(sm.getDataSource());
        EventCRFBean ec = (EventCRFBean) ecdao.findByPK(itemData.getEventCRFId());
        StudyEventBean event = (StudyEventBean) svdao.findByPK(ec.getStudyEventId());
        StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
        StudyEventDefinitionBean sed = (StudyEventDefinitionBean) seddao.findByPK(event.getStudyEventDefinitionId());
        note.setEventName(sed.getName());
        note.setEventStart(event.getDateStarted());
        CRFDAO cdao = new CRFDAO(sm.getDataSource());
        CRFBean crf = cdao.findByVersionId(ec.getCRFVersionId());
        note.setCrfName(crf.getName());
        note.setEventCRFId(ec.getId());
        if (StringUtil.isBlank(note.getSubjectName())) {
            StudySubjectBean ss = (StudySubjectBean) ssdao.findByPK(ec.getStudySubjectId());
            note.setSubjectName(ss.getName());
        }
        if (note.getDiscrepancyNoteTypeId() == 0) {
            // default
            note.setDiscrepancyNoteTypeId(DiscrepancyNoteType.FAILEDVAL.getId());
        // value
        }
    } else if ("eventCrf".equalsIgnoreCase(note.getEntityType())) {
        int eventCRFId = note.getEntityId();
        EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
        StudyEventDAO svdao = new StudyEventDAO(sm.getDataSource());
        EventCRFBean ec = (EventCRFBean) ecdao.findByPK(eventCRFId);
        StudyEventBean event = (StudyEventBean) svdao.findByPK(ec.getStudyEventId());
        StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
        StudyEventDefinitionBean sed = (StudyEventDefinitionBean) seddao.findByPK(event.getStudyEventDefinitionId());
        note.setEventName(sed.getName());
        note.setEventStart(event.getDateStarted());
        CRFDAO cdao = new CRFDAO(sm.getDataSource());
        CRFBean crf = cdao.findByVersionId(ec.getCRFVersionId());
        note.setCrfName(crf.getName());
        StudySubjectBean ss = (StudySubjectBean) ssdao.findByPK(ec.getStudySubjectId());
        note.setSubjectName(ss.getName());
        note.setEventCRFId(ec.getId());
    } else if ("studyEvent".equalsIgnoreCase(note.getEntityType())) {
        int eventId = note.getEntityId();
        StudyEventDAO svdao = new StudyEventDAO(sm.getDataSource());
        StudyEventBean event = (StudyEventBean) svdao.findByPK(eventId);
        StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
        StudyEventDefinitionBean sed = (StudyEventDefinitionBean) seddao.findByPK(event.getStudyEventDefinitionId());
        note.setEventName(sed.getName());
        note.setEventStart(event.getDateStarted());
        StudySubjectBean ss = (StudySubjectBean) ssdao.findByPK(event.getStudySubjectId());
        note.setSubjectName(ss.getName());
    } else if ("studySub".equalsIgnoreCase(note.getEntityType())) {
        int studySubjectId = note.getEntityId();
        StudySubjectBean ss = (StudySubjectBean) ssdao.findByPK(studySubjectId);
        note.setSubjectName(ss.getName());
    } else if ("Subject".equalsIgnoreCase(note.getEntityType())) {
        int subjectId = note.getEntityId();
        StudySubjectBean ss = ssdao.findBySubjectIdAndStudy(subjectId, currentStudy);
        note.setSubjectName(ss.getName());
    }
    return note;
}
Also used : ItemBean(org.akaza.openclinica.bean.submit.ItemBean) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) ItemDAO(org.akaza.openclinica.dao.submit.ItemDAO) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO)

Example 98 with EventCRFDAO

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

the class UpdateStudyEventServlet method processRequest.

@Override
public void processRequest() throws Exception {
    FormDiscrepancyNotes discNotes = null;
    FormProcessor fp = new FormProcessor(request);
    int studyEventId = fp.getInt(EVENT_ID, true);
    int studySubjectId = fp.getInt(STUDY_SUBJECT_ID, true);
    String module = fp.getString(MODULE);
    request.setAttribute(MODULE, module);
    String fromResolvingNotes = fp.getString("fromResolvingNotes", true);
    if (StringUtil.isBlank(fromResolvingNotes)) {
        session.removeAttribute(ViewNotesServlet.WIN_LOCATION);
        session.removeAttribute(ViewNotesServlet.NOTES_TABLE);
        checkStudyLocked(Page.MANAGE_STUDY, respage.getString("current_study_locked"));
        checkStudyFrozen(Page.MANAGE_STUDY, respage.getString("current_study_frozen"));
    }
    if (studyEventId == 0 || studySubjectId == 0) {
        addPageMessage(respage.getString("choose_a_study_event_to_edit"));
        request.setAttribute("id", new Integer(studySubjectId).toString());
        forwardPage(Page.VIEW_STUDY_SUBJECT_SERVLET);
        return;
    }
    StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
    StudySubjectBean ssub = null;
    if (studySubjectId > 0) {
        ssub = (StudySubjectBean) ssdao.findByPK(studySubjectId);
        request.setAttribute("studySubject", ssub);
        // for the workflow
        request.setAttribute("id", studySubjectId + "");
    // box, so it can
    // link back to view
    // study subject
    }
    // YW 11-07-2007, a study event could not be updated if its study
    // subject has been removed
    // Status s = ((StudySubjectBean)new
    // StudySubjectDAO(sm.getDataSource()).findByPK(studySubjectId)).getStatus();
    Status s = ssub.getStatus();
    if ("removed".equalsIgnoreCase(s.getName()) || "auto-removed".equalsIgnoreCase(s.getName())) {
        addPageMessage(resword.getString("study_event") + resterm.getString("could_not_be") + resterm.getString("updated") + "." + respage.getString("study_subject_has_been_deleted"));
        request.setAttribute("id", new Integer(studySubjectId).toString());
        forwardPage(Page.VIEW_STUDY_SUBJECT_SERVLET);
    }
    // YW
    request.setAttribute(STUDY_SUBJECT_ID, new Integer(studySubjectId).toString());
    StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
    EventCRFDAO ecrfdao = new EventCRFDAO(sm.getDataSource());
    StudyEventBean studyEvent = (StudyEventBean) sedao.findByPK(studyEventId);
    studyEvent.setEventCRFs(ecrfdao.findAllByStudyEvent(studyEvent));
    // only owner, admins, and study director/coordinator can update
    // if (ub.getId() != studyEvent.getOwnerId()) {
    // if (!ub.isSysAdmin() &&
    // !currentRole.getRole().equals(Role.STUDYDIRECTOR)
    // && !currentRole.getRole().equals(Role.COORDINATOR)) {
    // addPageMessage(respage.getString("no_have_correct_privilege_current_study")
    // + respage.getString("change_study_contact_sysadmin"));
    // request.setAttribute("id", new Integer(studySubjectId).toString());
    // forwardPage(Page.VIEW_STUDY_SUBJECT_SERVLET);
    // return;
    // }
    // }
    // above removed tbh 11162007
    ArrayList statuses = SubjectEventStatus.toArrayList();
    // remove more statuses here, tbh, 092007
    // ### updates to status setting, below added tbh 102007
    // following pieces of logic to be added:
    /*
         * REMOVED can happen at any step, COMPLETED can happen if the Subject
         * Event is already complete, COMPLETED can also happen if all required
         * CRFs in the Subject Event are completed, LOCKED can occur when all
         * Event CRFs are completed, or not started, or removed, LOCKED/REMOVED
         * are only options, however, when the user is study director or study
         * coordinator SKIPPED/STOPPED? Additional rules spelled out on Nov 16
         * 2007: STOPPED should only be in the list of choices after IDE has
         * been started, i.e. not when SCHEDULED SKIPPED should only be in the
         * list before IDE has been started, i.e. when SCHEDULED reminder about
         * LOCKED happening only when CRFs are completed (not as in the
         * above...) if a status is LOCKED already, it should allow a user to
         * set the event back to COMPLETED
         */
    StudyDAO sdao = new StudyDAO(this.sm.getDataSource());
    StudyBean studyBean = (StudyBean) sdao.findByPK(ssub.getStudyId());
    checkRoleByUserAndStudy(ub, studyBean.getParentStudyId(), studyBean.getId());
    // To remove signed status from the list
    EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
    boolean removeSign = false;
    // DiscrepancyNoteDAO discDao = new
    // DiscrepancyNoteDAO(sm.getDataSource());
    ArrayList eventCrfs = studyEvent.getEventCRFs();
    for (int i = 0; i < eventCrfs.size(); i++) {
        EventCRFBean ecrf = (EventCRFBean) eventCrfs.get(i);
        EventDefinitionCRFBean edcBean = edcdao.findByStudyEventIdAndCRFVersionId(studyBean, studyEventId, ecrf.getCRFVersionId());
        if (ecrf.getStage().equals(DataEntryStage.INITIAL_DATA_ENTRY) || ecrf.getStage().equals(DataEntryStage.INITIAL_DATA_ENTRY_COMPLETE) && edcBean.isDoubleEntry() == true) {
            removeSign = true;
            break;
        }
    }
    if (currentRole.isResearchAssistant()) {
        removeSign = true;
    }
    if (currentRole.isResearchAssistant2()) {
        removeSign = true;
    }
    if (removeSign == true || !currentRole.isInvestigator()) {
        statuses.remove(SubjectEventStatus.SIGNED);
    }
    /*
         * if(!studyEvent.getSubjectEventStatus().equals(SubjectEventStatus.
         * DATA_ENTRY_STARTED)) {
         * statuses.remove(SubjectEventStatus.DATA_ENTRY_STARTED);
         * //statuses.remove(SubjectEventStatus.SKIPPED); // per new rule
         * 11-2007 }
         */
    if (!studyEvent.getSubjectEventStatus().equals(SubjectEventStatus.NOT_SCHEDULED)) {
        statuses.remove(SubjectEventStatus.NOT_SCHEDULED);
    }
    if (!studyEvent.getSubjectEventStatus().equals(SubjectEventStatus.SCHEDULED)) {
        // can't lock a non-completed CRF, but removed above
        statuses.remove(SubjectEventStatus.SCHEDULED);
    // statuses.remove(SubjectEventStatus.SKIPPED);
    // addl rule: skipped should only be present before data starts
    // being entered
    }
    if (studyEvent.getSubjectEventStatus().equals(SubjectEventStatus.DATA_ENTRY_STARTED)) {
        statuses.remove(SubjectEventStatus.SKIPPED);
    }
    ArrayList getECRFs = studyEvent.getEventCRFs();
    // above removed tbh 102007, require to get all definitions, no matter
    // if they are filled in or now
    EventDefinitionCRFDAO edefcrfdao = new EventDefinitionCRFDAO(sm.getDataSource());
    ArrayList getAllECRFs = (ArrayList) edefcrfdao.findAllByDefinition(studyBean, studyEvent.getStudyEventDefinitionId());
    // does the study event have all complete CRFs which are required?
    logger.debug("found number of ecrfs: " + getAllECRFs.size());
    // may not be populated, only entered crfs seem to ping the list
    for (int u = 0; u < getAllECRFs.size(); u++) {
        EventDefinitionCRFBean ecrfBean = (EventDefinitionCRFBean) getAllECRFs.get(u);
        //
        logger.debug("found number of existing ecrfs: " + getECRFs.size());
        if (getECRFs.size() == 0) {
            statuses.remove(SubjectEventStatus.COMPLETED);
            statuses.remove(SubjectEventStatus.LOCKED);
        }
        // otherwise...
        for (int uv = 0; uv < getECRFs.size(); uv++) {
            EventCRFBean existingBean = (EventCRFBean) getECRFs.get(uv);
            logger.debug("***** found: " + existingBean.getCRFVersionId() + " " + existingBean.getCrf().getId() + " " + existingBean.getCrfVersion().getName() + " " + existingBean.getStatus().getName() + " " + existingBean.getStage().getName());
            logger.debug("***** comparing above to ecrfBean.DefaultVersionID: " + ecrfBean.getDefaultVersionId());
            // this is addressed in the if-clause above
            if (!existingBean.getStatus().equals(Status.UNAVAILABLE) && edefcrfdao.isRequiredInDefinition(existingBean.getCRFVersionId(), studyEvent)) {
                logger.debug("found that " + existingBean.getCrfVersion().getName() + " is required...");
                // that is, it's not completed but required to complete
                statuses.remove(SubjectEventStatus.COMPLETED);
                statuses.remove(SubjectEventStatus.LOCKED);
            // per new rule above 11-16-2007
            }
        // }
        }
    }
    // below added 092007, tbh, task #1390
    if (!ub.isSysAdmin() && !currentRole.getRole().equals(Role.STUDYDIRECTOR) && !currentRole.getRole().equals(Role.COORDINATOR)) {
        statuses.remove(SubjectEventStatus.LOCKED);
    }
    // scheduled
    if (studyEvent.getSubjectEventStatus().equals(SubjectEventStatus.DATA_ENTRY_STARTED)) {
        statuses.remove(SubjectEventStatus.NOT_SCHEDULED);
        statuses.remove(SubjectEventStatus.SCHEDULED);
    }
    // ### tbh, above modified 102007
    request.setAttribute("statuses", statuses);
    String action = fp.getString("action");
    StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
    StudyEventDefinitionBean sed = (StudyEventDefinitionBean) seddao.findByPK(studyEvent.getStudyEventDefinitionId());
    request.setAttribute(EVENT_DEFINITION_BEAN, sed);
    if (action.equalsIgnoreCase("submit")) {
        discNotes = (FormDiscrepancyNotes) session.getAttribute(AddNewSubjectServlet.FORM_DISCREPANCY_NOTES_NAME);
        DiscrepancyValidator v = new DiscrepancyValidator(request, discNotes);
        SubjectEventStatus ses = SubjectEventStatus.get(fp.getInt(SUBJECT_EVENT_STATUS_ID));
        studyEvent.setSubjectEventStatus(ses);
        EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
        ArrayList<EventCRFBean> eventCRFs = ecdao.findAllByStudyEvent(studyEvent);
        if (ses.equals(SubjectEventStatus.SKIPPED) || ses.equals(SubjectEventStatus.STOPPED)) {
            studyEvent.setStatus(Status.UNAVAILABLE);
            for (int i = 0; i < eventCRFs.size(); i++) {
                EventCRFBean ecb = eventCRFs.get(i);
                ecb.setOldStatus(ecb.getStatus());
                ecb.setStatus(Status.UNAVAILABLE);
                ecb.setUpdater(ub);
                ecb.setUpdatedDate(new Date());
                ecdao.update(ecb);
            }
        } else {
            for (int i = 0; i < eventCRFs.size(); i++) {
                EventCRFBean ecb = eventCRFs.get(i);
                ecb.setUpdater(ub);
                ecb.setUpdatedDate(new Date());
                ecdao.update(ecb);
            }
        }
        // YW 3-12-2008, 2220 fix
        String strEnd = fp.getDateTimeInputString(INPUT_ENDDATE_PREFIX);
        String strEndScheduled = fp.getDateTimeInputString(INPUT_ENDDATE_PREFIX);
        Date start = fp.getDateTime(INPUT_STARTDATE_PREFIX);
        Date end = null;
        v.addValidation(INPUT_STARTDATE_PREFIX, Validator.IS_DATE_TIME);
        v.alwaysExecuteLastValidation(INPUT_STARTDATE_PREFIX);
        if (!strEndScheduled.equals("")) {
            v.addValidation(INPUT_ENDDATE_PREFIX, Validator.IS_DATE_TIME);
            v.alwaysExecuteLastValidation(INPUT_ENDDATE_PREFIX);
        }
        //     v.addValidation(INPUT_LOCATION, Validator.NO_BLANKS); Disable validation on location, location can be empty when updating a study event
        HashMap errors = v.validate();
        // YW, 3-12-2008, 2220 fix <<
        if (!strEnd.equals("") && !errors.containsKey(INPUT_STARTDATE_PREFIX) && !errors.containsKey(INPUT_ENDDATE_PREFIX)) {
            end = fp.getDateTime(INPUT_ENDDATE_PREFIX);
            if (!fp.getString(INPUT_STARTDATE_PREFIX + "Date").equals(fp.getString(INPUT_ENDDATE_PREFIX + "Date"))) {
                if (end.before(start)) {
                    v.addError(errors, INPUT_ENDDATE_PREFIX, resexception.getString("input_provided_not_occure_after_previous_start_date_time"));
                }
            } else {
                // if in same date, only check when both had time entered
                if (fp.timeEntered(INPUT_STARTDATE_PREFIX) && fp.timeEntered(INPUT_ENDDATE_PREFIX)) {
                    if (end.before(start) || end.equals(start)) {
                        v.addError(errors, INPUT_ENDDATE_PREFIX, resexception.getString("input_provided_not_occure_after_previous_start_date_time"));
                    }
                }
            }
        }
        if (!errors.isEmpty()) {
            setInputMessages(errors);
            String[] prefixes = { INPUT_STARTDATE_PREFIX, INPUT_ENDDATE_PREFIX };
            fp.setCurrentDateTimeValuesAsPreset(prefixes);
            setPresetValues(fp.getPresetValues());
            studyEvent.setLocation(fp.getString(INPUT_LOCATION));
            request.setAttribute("changeDate", fp.getString("changeDate"));
            request.setAttribute(EVENT_BEAN, studyEvent);
            forwardPage(Page.UPDATE_STUDY_EVENT);
        } else if (studyEvent.getSubjectEventStatus().isSigned()) {
            // Checks if the status is signed
            // -----------------
            request.setAttribute(STUDY_SUBJECT_ID, new Integer(studySubjectId).toString());
            if (fp.getString(INPUT_STARTDATE_PREFIX + "Hour").equals("-1") && fp.getString(INPUT_STARTDATE_PREFIX + "Minute").equals("-1") && fp.getString(INPUT_STARTDATE_PREFIX + "Half").equals("")) {
                studyEvent.setStartTimeFlag(false);
            } else {
                studyEvent.setStartTimeFlag(true);
            }
            studyEvent.setDateStarted(start);
            if (!strEnd.equals("")) {
                studyEvent.setDateEnded(end);
                if (fp.getString(INPUT_ENDDATE_PREFIX + "Hour").equals("-1") && fp.getString(INPUT_ENDDATE_PREFIX + "Minute").equals("-1") && fp.getString(INPUT_ENDDATE_PREFIX + "Half").equals("")) {
                    studyEvent.setEndTimeFlag(false);
                } else {
                    studyEvent.setEndTimeFlag(true);
                }
            }
            studyEvent.setLocation(fp.getString(INPUT_LOCATION));
            studyEvent.setStudyEventDefinition(sed);
            // -------------------
            ssdao = new StudySubjectDAO(sm.getDataSource());
            StudySubjectBean ssb = (StudySubjectBean) ssdao.findByPK(studyEvent.getStudySubjectId());
            ecdao = new EventCRFDAO(sm.getDataSource());
            eventCRFs = ecdao.findAllByStudyEvent(studyEvent);
            ArrayList<Boolean> doRuleSetsExist = new ArrayList<Boolean>();
            RuleSetDAO ruleSetDao = new RuleSetDAO(sm.getDataSource());
            StudyBean study = (StudyBean) sdao.findByPK(ssb.getStudyId());
            ArrayList eventDefinitionCRFs = (ArrayList) edcdao.findAllActiveByEventDefinitionId(study, studyEvent.getStudyEventDefinitionId());
            ArrayList uncompletedEventDefinitionCRFs = getUncompletedCRFs(eventDefinitionCRFs, eventCRFs);
            populateUncompletedCRFsWithCRFAndVersions(uncompletedEventDefinitionCRFs);
            ArrayList displayEventCRFs = ViewStudySubjectServlet.getDisplayEventCRFs(sm.getDataSource(), eventCRFs, eventDefinitionCRFs, ub, currentRole, studyEvent.getSubjectEventStatus(), study);
            request.setAttribute("studySubject", ssb);
            request.setAttribute("uncompletedEventDefinitionCRFs", uncompletedEventDefinitionCRFs);
            request.setAttribute("displayEventCRFs", displayEventCRFs);
            request.setAttribute(EVENT_BEAN, studyEvent);
            session.setAttribute("eventSigned", studyEvent);
            DiscrepancyNoteUtil discNoteUtil = new DiscrepancyNoteUtil();
            DisplayStudyEventBean displayEvBean = new DisplayStudyEventBean();
            List<DisplayStudyEventBean> displayEvents = new ArrayList<DisplayStudyEventBean>();
            // Set up a Map for the JSP view, mapping the eventCRFId to
            // another Map: the
            // inner Map maps the resolution status name to the number of
            // notes for that
            // eventCRF id, as in New --> 2
            displayEvBean.setStudyEvent(studyEvent);
            displayEvents.add(displayEvBean);
            // Don't filter for res status or disc note type; disc note
            // beans are returned with eventCRFId set
            discNoteUtil.injectParentDiscNotesIntoDisplayStudyEvents(displayEvents, new HashSet(), sm.getDataSource(), 0);
            Map discNoteByEventCRFid = discNoteUtil.createDiscNoteMapByEventCRF(displayEvents);
            request.setAttribute("discNoteByEventCRFid", discNoteByEventCRFid);
            forwardPage(Page.UPDATE_STUDY_EVENT_SIGNED);
        } else {
            logger.debug("no validation error");
            // YW 08-17-2007 << update start_time_flag column
            if (fp.getString(INPUT_STARTDATE_PREFIX + "Hour").equals("-1") && fp.getString(INPUT_STARTDATE_PREFIX + "Minute").equals("-1") && fp.getString(INPUT_STARTDATE_PREFIX + "Half").equals("")) {
                studyEvent.setStartTimeFlag(false);
            } else {
                studyEvent.setStartTimeFlag(true);
            }
            // YW >>
            studyEvent.setDateStarted(start);
            // YW, 3-12-2008, 2220 fix which adding End datetime <<
            if (!strEnd.equals("")) {
                studyEvent.setDateEnded(end);
                if (fp.getString(INPUT_ENDDATE_PREFIX + "Hour").equals("-1") && fp.getString(INPUT_ENDDATE_PREFIX + "Minute").equals("-1") && fp.getString(INPUT_ENDDATE_PREFIX + "Half").equals("")) {
                    studyEvent.setEndTimeFlag(false);
                } else {
                    studyEvent.setEndTimeFlag(true);
                }
            }
            // YW >>
            studyEvent.setLocation(fp.getString(INPUT_LOCATION));
            logger.debug("update study event...");
            studyEvent.setUpdater(ub);
            studyEvent.setUpdatedDate(new Date());
            StudyEventBean updatedStudyEvent = (StudyEventBean) sedao.update(studyEvent);
            // save discrepancy notes into DB
            FormDiscrepancyNotes fdn = (FormDiscrepancyNotes) session.getAttribute(AddNewSubjectServlet.FORM_DISCREPANCY_NOTES_NAME);
            DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(sm.getDataSource());
            AddNewSubjectServlet.saveFieldNotes(INPUT_LOCATION, fdn, dndao, studyEvent.getId(), "studyEvent", currentStudy);
            AddNewSubjectServlet.saveFieldNotes(INPUT_STARTDATE_PREFIX, fdn, dndao, studyEvent.getId(), "studyEvent", currentStudy);
            AddNewSubjectServlet.saveFieldNotes(INPUT_ENDDATE_PREFIX, fdn, dndao, studyEvent.getId(), "studyEvent", currentStudy);
            //       getRuleSetService().runRulesInBeanProperty(createRuleSet(ssub,sed),currentStudy,ub,request,ssub);
            addPageMessage(respage.getString("study_event_updated"));
            request.setAttribute("id", new Integer(studySubjectId).toString());
            session.removeAttribute(AddNewSubjectServlet.FORM_DISCREPANCY_NOTES_NAME);
            forwardPage(Page.VIEW_STUDY_SUBJECT_SERVLET);
        // FORWARD SHOULD BE TO THE NEW PAGE
        }
    } else if (action.equalsIgnoreCase("confirm")) {
        // confirming the signed
        // status
        String username = request.getParameter("j_user");
        String password = request.getParameter("j_pass");
        //tring encodedUserPass = org.akaza.openclinica.core.SecurityManager.getInstance().encrytPassword(password);
        SecurityManager securityManager = ((SecurityManager) SpringServletAccess.getApplicationContext(context).getBean("securityManager"));
        UserAccountBean ub = (UserAccountBean) session.getAttribute("userBean");
        StudyEventBean seb = (StudyEventBean) session.getAttribute("eventSigned");
        if (securityManager.verifyPassword(password, getUserDetails()) && ub.getName().equals(username)) {
            seb.setUpdater(ub);
            seb.setUpdatedDate(new Date());
            sedao.update(seb);
            // If all the StudyEvents become signed we will make the
            // StudySubject signed as well
            List studyEvents = sedao.findAllByStudySubject(ssub);
            boolean allSigned = true;
            for (Iterator iterator = studyEvents.iterator(); iterator.hasNext(); ) {
                StudyEventBean temp = (StudyEventBean) iterator.next();
                if (!temp.getSubjectEventStatus().equals(SubjectEventStatus.SIGNED)) {
                    allSigned = false;
                    break;
                }
            }
            if (allSigned) {
                logger.debug("Signing StudySubject [" + ssub.getSubjectId() + "]");
                ssub.setStatus(Status.SIGNED);
                ssub.setUpdater(ub);
                ssdao.update(ssub);
            }
            // save discrepancy notes into DB
            FormDiscrepancyNotes fdn = (FormDiscrepancyNotes) session.getAttribute(AddNewSubjectServlet.FORM_DISCREPANCY_NOTES_NAME);
            DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(sm.getDataSource());
            AddNewSubjectServlet.saveFieldNotes(INPUT_LOCATION, fdn, dndao, studyEvent.getId(), "studyEvent", currentStudy);
            AddNewSubjectServlet.saveFieldNotes(INPUT_STARTDATE_PREFIX, fdn, dndao, studyEvent.getId(), "studyEvent", currentStudy);
            AddNewSubjectServlet.saveFieldNotes(INPUT_ENDDATE_PREFIX, fdn, dndao, studyEvent.getId(), "studyEvent", currentStudy);
            session.removeAttribute("eventSigned");
            request.setAttribute("id", new Integer(studySubjectId).toString());
            addPageMessage(respage.getString("study_event_updated"));
            forwardPage(Page.VIEW_STUDY_SUBJECT_SERVLET);
        } else {
            request.setAttribute(STUDY_SUBJECT_ID, new Integer(studySubjectId).toString());
            request.setAttribute("studyEvent", seb);
            // -------------------
            ssdao = new StudySubjectDAO(sm.getDataSource());
            StudySubjectBean ssb = (StudySubjectBean) ssdao.findByPK(studyEvent.getStudySubjectId());
            // prepare to figure out what the display should look like
            EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
            ArrayList<EventCRFBean> eventCRFs = ecdao.findAllByStudyEvent(studyEvent);
            ArrayList<Boolean> doRuleSetsExist = new ArrayList<Boolean>();
            RuleSetDAO ruleSetDao = new RuleSetDAO(sm.getDataSource());
            StudyBean study = (StudyBean) sdao.findByPK(ssb.getStudyId());
            ArrayList eventDefinitionCRFs = (ArrayList) edcdao.findAllActiveByEventDefinitionId(study, studyEvent.getStudyEventDefinitionId());
            ArrayList uncompletedEventDefinitionCRFs = getUncompletedCRFs(eventDefinitionCRFs, eventCRFs);
            populateUncompletedCRFsWithCRFAndVersions(uncompletedEventDefinitionCRFs);
            ArrayList displayEventCRFs = ViewStudySubjectServlet.getDisplayEventCRFs(sm.getDataSource(), eventCRFs, eventDefinitionCRFs, ub, currentRole, studyEvent.getSubjectEventStatus(), study);
            request.setAttribute("studySubject", ssb);
            request.setAttribute("uncompletedEventDefinitionCRFs", uncompletedEventDefinitionCRFs);
            request.setAttribute("displayEventCRFs", displayEventCRFs);
            // ------------------
            request.setAttribute("studyEvent", session.getAttribute("eventSigned"));
            addPageMessage(restext.getString("password_match"));
            forwardPage(Page.UPDATE_STUDY_EVENT_SIGNED);
        }
    } else {
        logger.debug("no action, go to update page");
        DiscrepancyNoteDAO discrepancyNoteDAO = new DiscrepancyNoteDAO(sm.getDataSource());
        StudySubjectBean studySubjectBean = (StudySubjectBean) ssdao.findByPK(studyEvent.getStudySubjectId());
        int studyId = studySubjectBean.getStudyId();
        boolean subjectStudyIsCurrentStudy = studyId == currentStudy.getId();
        boolean isParentStudy = studyBean.getParentStudyId() < 1;
        ArrayList<DiscrepancyNoteBean> allNotesforSubjectAndEvent = new ArrayList<DiscrepancyNoteBean>();
        if (subjectStudyIsCurrentStudy && isParentStudy) {
            allNotesforSubjectAndEvent = discrepancyNoteDAO.findAllStudyEventByStudyAndId(currentStudy, studySubjectBean.getId());
        } else {
            // findAllStudyEventByStudiesAndSubjectId
            if (!isParentStudy) {
                StudyBean stParent = (StudyBean) sdao.findByPK(studyBean.getParentStudyId());
                allNotesforSubjectAndEvent = discrepancyNoteDAO.findAllStudyEventByStudiesAndSubjectId(stParent, studyBean, studySubjectBean.getId());
            } else {
                allNotesforSubjectAndEvent = discrepancyNoteDAO.findAllStudyEventByStudiesAndSubjectId(currentStudy, studyBean, studySubjectBean.getId());
            }
        }
        if (!allNotesforSubjectAndEvent.isEmpty()) {
            setRequestAttributesForNotes(allNotesforSubjectAndEvent);
        }
        HashMap presetValues = new HashMap();
        // YW 08-17-2007 <<
        if (studyEvent.getStartTimeFlag() == true) {
            Calendar c = new GregorianCalendar();
            c.setTime(studyEvent.getDateStarted());
            presetValues.put(INPUT_STARTDATE_PREFIX + "Hour", new Integer(c.get(Calendar.HOUR_OF_DAY)));
            presetValues.put(INPUT_STARTDATE_PREFIX + "Minute", new Integer(c.get(Calendar.MINUTE)));
            // necessary.
            switch(c.get(Calendar.AM_PM)) {
                case 0:
                    presetValues.put(INPUT_STARTDATE_PREFIX + "Half", "am");
                    break;
                case 1:
                    presetValues.put(INPUT_STARTDATE_PREFIX + "Half", "pm");
                    break;
                default:
                    presetValues.put(INPUT_STARTDATE_PREFIX + "Half", "");
                    break;
            }
        } else {
            presetValues.put(INPUT_STARTDATE_PREFIX + "Hour", new Integer(-1));
            presetValues.put(INPUT_STARTDATE_PREFIX + "Minute", new Integer(-1));
            presetValues.put(INPUT_STARTDATE_PREFIX + "Half", "");
        }
        // YW >>
        String dateValue = local_df.format(studyEvent.getDateStarted());
        presetValues.put(INPUT_STARTDATE_PREFIX + "Date", dateValue);
        // YW 3-12-2008, add end datetime for 2220 fix<<
        presetValues.put(INPUT_ENDDATE_PREFIX + "Hour", new Integer(-1));
        presetValues.put(INPUT_ENDDATE_PREFIX + "Minute", new Integer(-1));
        presetValues.put(INPUT_ENDDATE_PREFIX + "Half", "");
        if (studyEvent.getDateEnded() != null) {
            if (studyEvent.getEndTimeFlag() == true) {
                Calendar c = new GregorianCalendar();
                c.setTime(studyEvent.getDateEnded());
                presetValues.put(INPUT_ENDDATE_PREFIX + "Hour", new Integer(c.get(Calendar.HOUR_OF_DAY)));
                presetValues.put(INPUT_ENDDATE_PREFIX + "Minute", new Integer(c.get(Calendar.MINUTE)));
                // necessary.
                switch(c.get(Calendar.AM_PM)) {
                    case 0:
                        presetValues.put(INPUT_ENDDATE_PREFIX + "Half", "am");
                        break;
                    case 1:
                        presetValues.put(INPUT_ENDDATE_PREFIX + "Half", "pm");
                        break;
                    default:
                        presetValues.put(INPUT_ENDDATE_PREFIX + "Half", "");
                        break;
                }
            }
            presetValues.put(INPUT_ENDDATE_PREFIX + "Date", local_df.format(studyEvent.getDateEnded()));
        }
        // YW >>
        setPresetValues(presetValues);
        request.setAttribute("studyEvent", studyEvent);
        request.setAttribute("studySubject", studySubjectBean);
        discNotes = new FormDiscrepancyNotes();
        session.setAttribute(AddNewSubjectServlet.FORM_DISCREPANCY_NOTES_NAME, discNotes);
        forwardPage(Page.UPDATE_STUDY_EVENT);
    }
// else
}
Also used : RuleSetDAO(org.akaza.openclinica.dao.rule.RuleSetDAO) SecurityManager(org.akaza.openclinica.core.SecurityManager) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) DisplayStudyEventBean(org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean) SubjectEventStatus(org.akaza.openclinica.bean.core.SubjectEventStatus) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) DiscrepancyNoteUtil(org.akaza.openclinica.service.DiscrepancyNoteUtil) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) HashSet(java.util.HashSet) Status(org.akaza.openclinica.bean.core.Status) SubjectEventStatus(org.akaza.openclinica.bean.core.SubjectEventStatus) DiscrepancyNoteDAO(org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO) FormDiscrepancyNotes(org.akaza.openclinica.control.form.FormDiscrepancyNotes) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) Date(java.util.Date) DiscrepancyValidator(org.akaza.openclinica.control.form.DiscrepancyValidator) DisplayStudyEventBean(org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) Map(java.util.Map) HashMap(java.util.HashMap)

Example 99 with EventCRFDAO

use of org.akaza.openclinica.dao.submit.EventCRFDAO 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 100 with EventCRFDAO

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

the class UpdateEventDefinitionServlet method removeAllEventsItems.

public void removeAllEventsItems(EventDefinitionCRFBean edc, StudyEventDefinitionBean sed) {
    StudyEventDAO seDao = new StudyEventDAO(sm.getDataSource());
    EventCRFDAO ecrfDao = new EventCRFDAO(sm.getDataSource());
    ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
    // Getting Study Events
    ArrayList seList = seDao.findAllByStudyEventDefinitionAndCrfOids(sed.getOid(), edc.getCrf().getOid());
    for (int j = 0; j < seList.size(); j++) {
        StudyEventBean seBean = (StudyEventBean) seList.get(j);
        // Getting Event CRFs
        ArrayList ecrfList = ecrfDao.findAllByStudyEventAndCrfOrCrfVersionOid(seBean, edc.getCrf().getOid());
        for (int k = 0; k < ecrfList.size(); k++) {
            EventCRFBean ecrfBean = (EventCRFBean) ecrfList.get(k);
            ecrfBean.setOldStatus(ecrfBean.getStatus());
            ecrfBean.setStatus(Status.AUTO_DELETED);
            ecrfBean.setUpdater(ub);
            ecrfBean.setUpdatedDate(new Date());
            ecrfDao.update(ecrfBean);
            // Getting Item Data
            ArrayList itemData = iddao.findAllByEventCRFId(ecrfBean.getId());
            // remove all the item data
            for (int a = 0; a < itemData.size(); a++) {
                ItemDataBean item = (ItemDataBean) itemData.get(a);
                if (!item.getStatus().equals(Status.DELETED)) {
                    item.setOldStatus(item.getStatus());
                    item.setStatus(Status.AUTO_DELETED);
                    item.setUpdater(ub);
                    item.setUpdatedDate(new Date());
                    iddao.update(item);
                    DiscrepancyNoteDAO dnDao = new DiscrepancyNoteDAO(sm.getDataSource());
                    List dnNotesOfRemovedItem = dnDao.findExistingNotesForItemData(item.getId());
                    if (!dnNotesOfRemovedItem.isEmpty()) {
                        DiscrepancyNoteBean itemParentNote = null;
                        for (Object obj : dnNotesOfRemovedItem) {
                            if (((DiscrepancyNoteBean) obj).getParentDnId() == 0) {
                                itemParentNote = (DiscrepancyNoteBean) obj;
                            }
                        }
                        DiscrepancyNoteBean dnb = new DiscrepancyNoteBean();
                        if (itemParentNote != null) {
                            dnb.setParentDnId(itemParentNote.getId());
                            dnb.setDiscrepancyNoteTypeId(itemParentNote.getDiscrepancyNoteTypeId());
                        }
                        dnb.setResolutionStatusId(ResolutionStatus.CLOSED.getId());
                        dnb.setStudyId(currentStudy.getId());
                        dnb.setAssignedUserId(ub.getId());
                        dnb.setOwner(ub);
                        dnb.setEntityType(DiscrepancyNoteBean.ITEM_DATA);
                        dnb.setEntityId(item.getId());
                        dnb.setColumn("value");
                        dnb.setCreatedDate(new Date());
                        dnb.setDescription("The item has been removed, this Discrepancy Note has been Closed.");
                        dnDao.create(dnb);
                        dnDao.createMapping(dnb);
                        itemParentNote.setResolutionStatusId(ResolutionStatus.CLOSED.getId());
                        dnDao.update(itemParentNote);
                    }
                }
            }
        }
    }
}
Also used : DiscrepancyNoteDAO(org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO) ArrayList(java.util.ArrayList) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) Date(java.util.Date) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) ArrayList(java.util.ArrayList) List(java.util.List) 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