Search in sources :

Example 11 with SubjectEventStatus

use of org.akaza.openclinica.bean.core.SubjectEventStatus in project OpenClinica by OpenClinica.

the class ExtractBean method getSEDCRFStatus.

// private String getSEDCRFName(int sedInd, int crfInd) {
// syncCRFIndex(sedInd, crfInd);
// return currentCRF.getName();
// }
// private String getSEDCRFVersionName(int h, int sedInd, int crfInd) {
// syncCRFIndex(sedInd, crfInd);
//
// StudyEventBean seb = getEvent(h, sedInd, crfInd);
//
// String returnMe = "";
// //ArrayList versions = currentCRF.getVersions();//returns zero results
// EventCRFBean eventCRF = null;
// if (seb.getEventCRFs().size() > 0) {
// logger.info("found getEventCRFs.size " + seb.getEventCRFs().size());
// for (int t = 0; t < seb.getEventCRFs().size(); t++) {
// eventCRF = (EventCRFBean) seb.getEventCRFs().get(t);
// returnMe = eventCRF.getCrfVersion().getName();
// //logger.info("found versions.size "+versions.size());
// //for (int s = 0; s < versions.size(); s++) {
// // CRFVersionBean version = (CRFVersionBean)versions.get(s);
// // if (version.getId()==eventCRF.getCRFVersionId()) {
// // returnMe = version.getName();
// //break;
// // }
// //}
// }
//
// }
// logger.info("returning the following for crf version name: " + returnMe);
// return returnMe;
// }
private String getSEDCRFStatus(int h, int sedInd, int crfInd) {
    // BADS Flag
    syncCRFIndex(sedInd, crfInd);
    StudyEventBean seb = getEvent(h, sedInd, crfInd);
    Status ecStatus = Status.AVAILABLE;
    EventCRFBean eventCRF = null;
    if (seb.getEventCRFs().size() > 0) {
        eventCRF = (EventCRFBean) seb.getEventCRFs().get(0);
    }
    String crfVersionStatus = "";
    SubjectEventStatus status = SubjectEventStatus.NOT_SCHEDULED;
    CRFVersionBean crfv = new CRFVersionBean();
    crfv.setStatus(Status.AVAILABLE);
    // modified stage so that crfVersionStatus could be the same as what it
    // shows in subject matrix - as required.
    DataEntryStage stage = DataEntryStage.INVALID;
    try {
        stage = eventCRF.getStage();
        ecStatus = eventCRF.getStatus();
        // SubjectEventStatus.get(
        status = seb.getSubjectEventStatus();
        // eventCRF
        // .getCompletionStatusId());
        crfv = eventCRF.getCrfVersion();
    } catch (NullPointerException e) {
        logger.info("exception hit, status set to not scheduled");
    }
    // currentCRF.getStatus().getName();
    //
    logger.info("event crf stage: " + stage.getName() + ", event crf status: " + ecStatus.getName() + ", STATUS: " + status.getName() + " crf version: " + crfv.getStatus().getName() + " data entry stage: " + stage.getName());
    if (stage.equals(DataEntryStage.INVALID) || ecStatus.equals(Status.INVALID)) {
        stage = DataEntryStage.UNCOMPLETED;
    }
    crfVersionStatus = stage.getName();
    if (status.equals(SubjectEventStatus.LOCKED) || status.equals(SubjectEventStatus.SKIPPED) || status.equals(SubjectEventStatus.STOPPED)) {
        crfVersionStatus = DataEntryStage.LOCKED.getName();
    } else if (status.equals(SubjectEventStatus.INVALID)) {
        crfVersionStatus = DataEntryStage.LOCKED.getName();
    } else if (!currentCRF.getStatus().equals(Status.AVAILABLE)) {
        crfVersionStatus = DataEntryStage.LOCKED.getName();
    } else if (!crfv.getStatus().equals(Status.AVAILABLE)) {
        crfVersionStatus = DataEntryStage.LOCKED.getName();
    }
    logger.info("returning: " + crfVersionStatus);
    return crfVersionStatus;
}
Also used : Status(org.akaza.openclinica.bean.core.Status) SubjectEventStatus(org.akaza.openclinica.bean.core.SubjectEventStatus) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) SubjectEventStatus(org.akaza.openclinica.bean.core.SubjectEventStatus) DataEntryStage(org.akaza.openclinica.bean.core.DataEntryStage)

Example 12 with SubjectEventStatus

use of org.akaza.openclinica.bean.core.SubjectEventStatus in project OpenClinica by OpenClinica.

the class ViewStudySubjectServlet method processRequest.

@Override
public void processRequest() throws Exception {
    SubjectDAO sdao = new SubjectDAO(sm.getDataSource());
    StudySubjectDAO subdao = new StudySubjectDAO(sm.getDataSource());
    CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
    FormProcessor fp = new FormProcessor(request);
    // studySubjectId
    int studySubId = fp.getInt("id", true);
    String from = fp.getString("from");
    String module = fp.getString(MODULE);
    request.setAttribute(MODULE, module);
    // if coming from change crf version -> display message
    String crfVersionChangeMsg = fp.getString("isFromCRFVersionChange");
    if (crfVersionChangeMsg != null && !crfVersionChangeMsg.equals("")) {
        addPageMessage(crfVersionChangeMsg);
    }
    if (studySubId == 0) {
        addPageMessage(respage.getString("please_choose_a_subject_to_view"));
        forwardPage(Page.LIST_STUDY_SUBJECTS);
    } else {
        if (!StringUtil.isBlank(from)) {
            // form ListSubject or
            request.setAttribute("from", from);
        // ListStudySubject
        } else {
            request.setAttribute("from", "");
        }
        StudySubjectBean studySub = (StudySubjectBean) subdao.findByPK(studySubId);
        request.setAttribute("studySub", studySub);
        request.setAttribute("originatingPage", URLEncoder.encode("ViewStudySubject?id=" + studySub.getId(), "UTF-8"));
        int studyId = studySub.getStudyId();
        int subjectId = studySub.getSubjectId();
        StudyDAO studydao = new StudyDAO(sm.getDataSource());
        StudyBean study = (StudyBean) studydao.findByPK(studyId);
        // Check if this StudySubject would be accessed from the Current Study
        if (studySub.getStudyId() != currentStudy.getId()) {
            if (currentStudy.getParentStudyId() > 0) {
                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.
                Collection sites = studydao.findOlnySiteIdsByStudy(currentStudy);
                if (!sites.contains(study.getId())) {
                    addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
                    forwardPage(Page.MENU_SERVLET);
                    return;
                }
            }
        }
        // If the study subject derives from a site, and is being viewed
        // from a parent study,
        // then the study IDs will be different. However, since each note is
        // saved with the specific
        // study ID, then its study ID may be different than the study
        // subject's ID.
        boolean subjectStudyIsCurrentStudy = studyId == currentStudy.getId();
        boolean isParentStudy = study.getParentStudyId() < 1;
        // Get any disc notes for this subject : studySubId
        DiscrepancyNoteDAO discrepancyNoteDAO = new DiscrepancyNoteDAO(sm.getDataSource());
        List<DiscrepancyNoteBean> allNotesforSubject = new ArrayList<DiscrepancyNoteBean>();
        // These methods return only parent disc notes
        if (subjectStudyIsCurrentStudy && isParentStudy) {
            allNotesforSubject = discrepancyNoteDAO.findAllSubjectByStudyAndId(study, subjectId);
            allNotesforSubject.addAll(discrepancyNoteDAO.findAllStudySubjectByStudyAndId(study, studySubId));
        } else {
            if (!isParentStudy) {
                StudyBean stParent = (StudyBean) studydao.findByPK(study.getParentStudyId());
                allNotesforSubject = discrepancyNoteDAO.findAllSubjectByStudiesAndSubjectId(stParent, study, subjectId);
                allNotesforSubject.addAll(discrepancyNoteDAO.findAllStudySubjectByStudiesAndStudySubjectId(stParent, study, studySubId));
            } else {
                allNotesforSubject = discrepancyNoteDAO.findAllSubjectByStudiesAndSubjectId(currentStudy, study, subjectId);
                allNotesforSubject.addAll(discrepancyNoteDAO.findAllStudySubjectByStudiesAndStudySubjectId(currentStudy, study, studySubId));
            }
        }
        if (!allNotesforSubject.isEmpty()) {
            setRequestAttributesForNotes(allNotesforSubject);
        }
        SubjectBean subject = (SubjectBean) sdao.findByPK(subjectId);
        if (currentStudy.getStudyParameterConfig().getCollectDob().equals("2")) {
            Date dob = subject.getDateOfBirth();
            if (dob != null) {
                Calendar cal = Calendar.getInstance();
                cal.setTime(dob);
                int year = cal.get(Calendar.YEAR);
                request.setAttribute("yearOfBirth", new Integer(year));
            } else {
                request.setAttribute("yearOfBirth", "");
            }
        }
        request.setAttribute("subject", subject);
        /*
             * StudyDAO studydao = new StudyDAO(sm.getDataSource()); StudyBean
             * study = (StudyBean) studydao.findByPK(studyId);
             */
        // YW 11-26-2007 <<
        StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
        study.getStudyParameterConfig().setCollectDob(spvdao.findByHandleAndStudy(studyId, "collectDob").getValue());
        // YW >>
        request.setAttribute("subjectStudy", study);
        if (study.getParentStudyId() > 0) {
            // this is a site,find parent
            StudyBean parentStudy2 = (StudyBean) studydao.findByPK(study.getParentStudyId());
            request.setAttribute("parentStudy", parentStudy2);
        } else {
            request.setAttribute("parentStudy", new StudyBean());
        }
        ArrayList children = (ArrayList) sdao.findAllChildrenByPK(subjectId);
        request.setAttribute("children", children);
        // find study events
        StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
        StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
        StudySubjectService studySubjectService = (StudySubjectService) WebApplicationContextUtils.getWebApplicationContext(getServletContext()).getBean("studySubjectService");
        List<DisplayStudyEventBean> displayEvents = studySubjectService.getDisplayStudyEventsForStudySubject(studySub, ub, currentRole);
        for (int i = 0; i < displayEvents.size(); i++) {
            DisplayStudyEventBean decb = displayEvents.get(i);
            if (!(currentRole.isDirector() || currentRole.isCoordinator()) && decb.getStudyEvent().getSubjectEventStatus().isLocked()) {
                decb.getStudyEvent().setEditable(false);
            }
        }
        if (currentStudy.getParentStudyId() > 0) {
            HideCRFManager hideCRFManager = HideCRFManager.createHideCRFManager();
            for (DisplayStudyEventBean displayStudyEventBean : displayEvents) {
                hideCRFManager.removeHiddenEventCRF(displayStudyEventBean);
            }
        }
        EntityBeanTable table = fp.getEntityBeanTable();
        // sort by start
        table.setSortingIfNotExplicitlySet(1, false);
        // date, desc
        ArrayList allEventRows = DisplayStudyEventRow.generateRowsFromBeans(displayEvents);
        String[] columns = { resword.getString("event") + " (" + resword.getString("occurrence_number") + ")", resword.getString("start_date1"), resword.getString("location"), resword.getString("status"), resword.getString("actions"), resword.getString("CRFs_atrib") };
        table.setColumns(new ArrayList(Arrays.asList(columns)));
        table.hideColumnLink(4);
        table.hideColumnLink(5);
        if (!"removed".equalsIgnoreCase(studySub.getStatus().getName()) && !"auto-removed".equalsIgnoreCase(studySub.getStatus().getName())) {
            if (currentStudy.getStatus().isAvailable() && !currentRole.getRole().equals(Role.MONITOR)) {
                table.addLink(resword.getString("add_new_event"), "CreateNewStudyEvent?" + CreateNewStudyEventServlet.INPUT_STUDY_SUBJECT_ID_FROM_VIEWSUBJECT + "=" + studySub.getId());
            }
        }
        HashMap args = new HashMap();
        args.put("id", new Integer(studySubId).toString());
        table.setQuery("ViewStudySubject", args);
        table.setRows(allEventRows);
        table.computeDisplay();
        request.setAttribute("table", table);
        SubjectGroupMapDAO sgmdao = new SubjectGroupMapDAO(sm.getDataSource());
        ArrayList groupMaps = (ArrayList) sgmdao.findAllByStudySubject(studySubId);
        request.setAttribute("groups", groupMaps);
        // find audit log for events
        AuditEventDAO aedao = new AuditEventDAO(sm.getDataSource());
        ArrayList logs = aedao.findEventStatusLogByStudySubject(studySubId);
        // logger.warning("^^^ retrieved logs");
        UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
        ArrayList eventLogs = new ArrayList();
        // logger.warning("^^^ starting to iterate");
        for (int i = 0; i < logs.size(); i++) {
            AuditEventBean avb = (AuditEventBean) logs.get(i);
            StudyEventAuditBean sea = new StudyEventAuditBean();
            sea.setAuditEvent(avb);
            StudyEventBean se = (StudyEventBean) sedao.findByPK(avb.getEntityId());
            StudyEventDefinitionBean sed = (StudyEventDefinitionBean) seddao.findByPK(se.getStudyEventDefinitionId());
            sea.setDefinition(sed);
            String old = avb.getOldValue().trim();
            try {
                if (!StringUtil.isBlank(old)) {
                    SubjectEventStatus oldStatus = SubjectEventStatus.get(new Integer(old).intValue());
                    sea.setOldSubjectEventStatus(oldStatus);
                }
                String newValue = avb.getNewValue().trim();
                if (!StringUtil.isBlank(newValue)) {
                    SubjectEventStatus newStatus = SubjectEventStatus.get(new Integer(newValue).intValue());
                    sea.setNewSubjectEventStatus(newStatus);
                }
            } catch (NumberFormatException e) {
                e.printStackTrace();
            }
            UserAccountBean updater = (UserAccountBean) udao.findByPK(avb.getUserId());
            sea.setUpdater(updater);
            eventLogs.add(sea);
        }
        request.setAttribute("eventLogs", eventLogs);
        forwardPage(Page.VIEW_STUDY_SUBJECT);
    }
}
Also used : HashMap(java.util.HashMap) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) SubjectDAO(org.akaza.openclinica.dao.submit.SubjectDAO) EntityBeanTable(org.akaza.openclinica.web.bean.EntityBeanTable) 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) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) AuditEventBean(org.akaza.openclinica.bean.admin.AuditEventBean) StudyEventAuditBean(org.akaza.openclinica.bean.admin.StudyEventAuditBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) DiscrepancyNoteDAO(org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) SubjectGroupMapDAO(org.akaza.openclinica.dao.submit.SubjectGroupMapDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) Calendar(java.util.Calendar) AuditEventDAO(org.akaza.openclinica.dao.admin.AuditEventDAO) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) HideCRFManager(org.akaza.openclinica.service.crfdata.HideCRFManager) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) Date(java.util.Date) StudySubjectService(org.akaza.openclinica.service.managestudy.StudySubjectService) SubjectBean(org.akaza.openclinica.bean.submit.SubjectBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) 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) Collection(java.util.Collection) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO)

Example 13 with SubjectEventStatus

use of org.akaza.openclinica.bean.core.SubjectEventStatus in project OpenClinica by OpenClinica.

the class ListDiscNotesSubjectTableFactory method linksDivBuilder.

private void linksDivBuilder(HtmlBuilder eventDiv, SubjectBean subject, Integer rowCount, List<StudyEventBean> studyEvents, StudyEventDefinitionBean sed, StudySubjectBean studySubject, StudyEventBean currentEvent) {
    Status eventSysStatus = studySubject.getStatus();
    SubjectEventStatus eventStatus = currentEvent.getSubjectEventStatus();
    String studyEventId = String.valueOf(currentEvent.getId());
    String view = resword.getString("view") + "/" + resword.getString("enter_data");
    String edit = resword.getString("edit");
    String remove = resword.getString("remove");
    ;
    if (eventSysStatus.getId() == Status.AVAILABLE.getId() || eventSysStatus == Status.SIGNED) {
        if (eventStatus == SubjectEventStatus.COMPLETED) {
            eventDiv.tr(0).valign("top").close();
            eventDiv.td(0).styleClass("table_cell").close();
            enterDataForStudyEventLinkBuilder(eventDiv, studyEventId, view);
            eventDiv.tdEnd().trEnd(0);
            if ((currentRole.getRole() == Role.STUDYDIRECTOR || currentUser.isSysAdmin()) && studyBean.getStatus() == Status.AVAILABLE) {
                eventDiv.tr(0).valign("top").close();
                eventDiv.td(0).styleClass("table_cell").close();
                updateStudyEventLinkBuilder(eventDiv, studySubject.getId(), studyEventId, edit);
                eventDiv.tdEnd().trEnd(0);
                eventDiv.tr(0).valign("top").close();
                eventDiv.td(0).styleClass("table_cell").close();
                removeStudyEventLinkBuilder(eventDiv, studySubject.getId(), studyEventId, remove);
                eventDiv.tdEnd().trEnd(0);
            }
        } else if (eventStatus == SubjectEventStatus.LOCKED) {
            if (currentRole.getRole() == Role.STUDYDIRECTOR || currentUser.isSysAdmin()) {
                eventDiv.tr(0).valign("top").close();
                eventDiv.td(0).styleClass("table_cell").close();
                enterDataForStudyEventLinkBuilder(eventDiv, studyEventId, view);
                eventDiv.tdEnd().trEnd(0);
                if (studyBean.getStatus() == Status.AVAILABLE) {
                    eventDiv.tr(0).valign("top").close();
                    eventDiv.td(0).styleClass("table_cell").close();
                    removeStudyEventLinkBuilder(eventDiv, studySubject.getId(), studyEventId, remove);
                    eventDiv.tdEnd().trEnd(0);
                }
            }
        } else {
            eventDiv.tr(0).valign("top").close();
            eventDiv.td(0).styleClass("table_cell_left");
            enterDataForStudyEventLinkBuilder(eventDiv, studyEventId, view);
            eventDiv.tdEnd().trEnd(0);
            if ((currentRole.getRole() == Role.STUDYDIRECTOR || currentUser.isSysAdmin()) && studyBean.getStatus() == Status.AVAILABLE) {
                eventDiv.tr(0).valign("top").close();
                eventDiv.td(0).styleClass("table_cell_left").close();
                updateStudyEventLinkBuilder(eventDiv, studySubject.getId(), studyEventId, edit);
                eventDiv.tdEnd().trEnd(0);
                eventDiv.tr(0).valign("top").close();
                eventDiv.td(0).styleClass("table_cell_left").close();
                removeStudyEventLinkBuilder(eventDiv, studySubject.getId(), studyEventId, remove);
                eventDiv.tdEnd().trEnd(0);
            }
        }
    }
    if (eventSysStatus == Status.DELETED || eventSysStatus == Status.AUTO_DELETED) {
        eventDiv.tr(0).valign("top").close();
        eventDiv.td(0).styleClass("table_cell").close();
        enterDataForStudyEventLinkBuilder(eventDiv, studyEventId, view);
        eventDiv.tdEnd().trEnd(0);
    }
}
Also used : Status(org.akaza.openclinica.bean.core.Status) ResolutionStatus(org.akaza.openclinica.bean.core.ResolutionStatus) SubjectEventStatus(org.akaza.openclinica.bean.core.SubjectEventStatus) SubjectEventStatus(org.akaza.openclinica.bean.core.SubjectEventStatus)

Example 14 with SubjectEventStatus

use of org.akaza.openclinica.bean.core.SubjectEventStatus 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 15 with SubjectEventStatus

use of org.akaza.openclinica.bean.core.SubjectEventStatus in project OpenClinica by OpenClinica.

the class DisplayStudySubjectRow method compareColumn.

// YW >>
/*
     * (non-Javadoc)
     *
     * @see org.akaza.openclinica.core.EntityBeanRow#compareColumn(java.lang.Object,
     *      int)
     */
@Override
protected int compareColumn(Object row, int sortingColumn) {
    if (!row.getClass().equals(DisplayStudySubjectRow.class)) {
        return 0;
    }
    DisplayStudySubjectBean thisStudy = (DisplayStudySubjectBean) bean;
    DisplayStudySubjectBean argStudy = (DisplayStudySubjectBean) ((DisplayStudySubjectRow) row).bean;
    int answer = 0;
    // YW <<
    int groupSize = thisStudy.getStudyGroups().size();
    int code;
    if (sortingColumn > 4 + groupSize) {
        if (thisStudy.getSedId() <= 0) {
            code = COL_STUDYEVENT;
        } else {
            code = -1;
        }
    } else if (sortingColumn > 4 && sortingColumn <= 4 + groupSize) {
        code = COL_STUDYGROUP;
    } else {
        code = sortingColumn;
    }
    switch(code) {
        // break;
        case COL_SUBJECT_LABEL:
            answer = thisStudy.getStudySubject().getLabel().toLowerCase().compareTo(argStudy.getStudySubject().getLabel().toLowerCase());
            break;
        case COL_GENDER:
            answer = (thisStudy.getStudySubject().getGender() + "").compareTo(argStudy.getStudySubject().getGender() + "");
            break;
        case COL_OID:
            answer = thisStudy.getStudySubject().getOid().toLowerCase().compareTo(argStudy.getStudySubject().getOid().toLowerCase());
            break;
        case COL_SECONDARY_LABEL:
            answer = thisStudy.getStudySubject().getSecondaryLabel().toLowerCase().compareTo(argStudy.getStudySubject().getSecondaryLabel().toLowerCase());
            break;
        /*
         * case COL_ENROLLMENTDATE: answer =
         * compareDate(thisStudy.getStudySubject().getEnrollmentDate(),argStudy.getStudySubject().getEnrollmentDate());
         * break;
         */
        case COL_STATUS:
            answer = thisStudy.getStudySubject().getStatus().compareTo(argStudy.getStudySubject().getStatus());
            break;
        // YW <<
        case COL_STUDYGROUP:
            answer = ((SubjectGroupMapBean) thisStudy.getStudyGroups().get(sortingColumn - 5)).getStudyGroupName().toLowerCase().compareTo(((SubjectGroupMapBean) argStudy.getStudyGroups().get(sortingColumn - 5)).getStudyGroupName().toLowerCase());
            break;
        case COL_STUDYEVENT:
            // studyEvent status comparision
            SubjectEventStatus thisSes = ((StudyEventBean) thisStudy.getStudyEvents().get(sortingColumn - 5 - groupSize)).getSubjectEventStatus();
            SubjectEventStatus argSes = ((StudyEventBean) argStudy.getStudyEvents().get(sortingColumn - 5 - groupSize)).getSubjectEventStatus();
            /*Subject event status is ordered in this sequence Not Started=2,Scheduled=1,Data Entry Started=3,
              Stopped=5,Skipped=6, Completed=4,Locked=7,Signed=8*/
            switch(thisSes.getId()) {
                //SubjectEventStatus.SCHEDULED
                case 1:
                    if (thisSes.getId() == argSes.getId()) {
                        answer = 0;
                    } else if (argSes.getId() == 2) {
                        answer = 1;
                    } else {
                        answer = -1;
                    }
                    break;
                //SubjectEventStatus.NOT_SCHEDULED
                case 2:
                    if (thisSes.getId() == argSes.getId()) {
                        answer = 0;
                    } else {
                        answer = -1;
                    }
                    break;
                //SubjectEventStatus.DATA_ENTRY_STARTED
                case 3:
                    if (thisSes.getId() == argSes.getId()) {
                        answer = 0;
                    } else if (argSes.getId() == 1 || argSes.getId() == 2) {
                        answer = 1;
                    } else {
                        answer = -1;
                    }
                    break;
                //SubjectEventStatus.COMPLETED
                case 4:
                    if (thisSes.getId() == argSes.getId()) {
                        answer = 0;
                    } else if (argSes.getId() == 7 || argSes.getId() == 8) {
                        answer = -1;
                    } else {
                        answer = 1;
                    }
                    break;
                //SubjectEventStatus.STOPPED
                case 5:
                    if (thisSes.getId() == argSes.getId()) {
                        answer = 0;
                    } else if (argSes.getId() == 1 || argSes.getId() == 2 || argSes.getId() == 3) {
                        answer = 1;
                    } else {
                        answer = -1;
                    }
                    break;
                //SubjectEventStatus.SKIPPED
                case 6:
                    if (thisSes.getId() == argSes.getId()) {
                        answer = 0;
                    } else if (argSes.getId() == 4 || argSes.getId() == 7 || argSes.getId() == 8) {
                        answer = -1;
                    } else {
                        answer = 1;
                    }
                    break;
                //SubjectEventStatus.LOCKED
                case 7:
                    if (thisSes.getId() == argSes.getId()) {
                        answer = 0;
                    } else if (argSes.getId() == 8) {
                        answer = -1;
                    } else {
                        answer = 1;
                    }
                    break;
                //SubjectEventStatus.SIGNED
                case 8:
                    if (thisSes.getId() == argSes.getId()) {
                        answer = 0;
                    } else {
                        answer = 1;
                    }
                default:
                    answer = 1;
            }
    }
    return answer;
}
Also used : DisplayStudySubjectBean(org.akaza.openclinica.bean.managestudy.DisplayStudySubjectBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) SubjectEventStatus(org.akaza.openclinica.bean.core.SubjectEventStatus)

Aggregations

SubjectEventStatus (org.akaza.openclinica.bean.core.SubjectEventStatus)16 Status (org.akaza.openclinica.bean.core.Status)9 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)8 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)6 Date (java.util.Date)5 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)5 ResolutionStatus (org.akaza.openclinica.bean.core.ResolutionStatus)4 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)4 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)4 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)4 Calendar (java.util.Calendar)3 List (java.util.List)3 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)3 DisplayStudyEventBean (org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean)3 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)3 SubjectBean (org.akaza.openclinica.bean.submit.SubjectBean)3 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)3 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)3