Search in sources :

Example 1 with SubjectEventStatus

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

the class SignStudySubjectServlet method processRequest.

@Override
public void processRequest() throws Exception {
    SubjectDAO sdao = new SubjectDAO(sm.getDataSource());
    StudySubjectDAO subdao = new StudySubjectDAO(sm.getDataSource());
    FormProcessor fp = new FormProcessor(request);
    String action = fp.getString("action");
    // studySubjectId
    int studySubId = fp.getInt("id", true);
    String module = fp.getString(MODULE);
    request.setAttribute(MODULE, module);
    if (studySubId == 0) {
        addPageMessage(respage.getString("please_choose_a_subject_to_view"));
        forwardPage(Page.LIST_STUDY_SUBJECTS);
        return;
    }
    StudySubjectBean studySub = (StudySubjectBean) subdao.findByPK(studySubId);
    if (!permitSign(studySub, sm.getDataSource())) {
        addPageMessage(respage.getString("subject_event_cannot_signed"));
        // forwardPage(Page.SUBMIT_DATA_SERVLET);
        forwardPage(Page.LIST_STUDY_SUBJECTS_SERVLET);
        // >> changed tbh, 06/2009
        return;
    }
    if (action.equalsIgnoreCase("confirm")) {
        String username = request.getParameter("j_user");
        String password = request.getParameter("j_pass");
        SecurityManager securityManager = ((SecurityManager) SpringServletAccess.getApplicationContext(context).getBean("securityManager"));
        // String encodedUserPass =
        // org.akaza.openclinica.core.SecurityManager
        // .getInstance().encrytPassword(password);
        UserAccountBean ub = (UserAccountBean) session.getAttribute("userBean");
        if (securityManager.verifyPassword(password, getUserDetails()) && ub.getName().equals(username)) {
            if (signSubjectEvents(studySub, sm.getDataSource(), ub)) {
                // Making the StudySubject signed as all the events have
                // become signed.
                studySub.setStatus(Status.SIGNED);
                studySub.setUpdater(ub);
                subdao.update(studySub);
                addPageMessage(respage.getString("subject_event_signed"));
                // forwardPage(Page.SUBMIT_DATA_SERVLET);
                forwardPage(Page.LIST_STUDY_SUBJECTS_SERVLET);
                // >> changed tbh, 06/2009
                return;
            } else {
                addPageMessage(respage.getString("errors_in_submission_see_below"));
                forwardPage(Page.LIST_STUDY_SUBJECTS);
                return;
            }
        } else {
            request.setAttribute("id", new Integer(studySubId).toString());
            addPageMessage(restext.getString("password_match"));
            forwardPage(Page.LIST_STUDY_SUBJECTS);
            return;
        }
    }
    request.setAttribute("studySub", studySub);
    int studyId = studySub.getStudyId();
    int subjectId = studySub.getSubjectId();
    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);
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
    study.getStudyParameterConfig().setCollectDob(spvdao.findByHandleAndStudy(studyId, "collectDob").getValue());
    if (study.getParentStudyId() > 0) {
        // this is a site,find parent
        StudyBean parentStudy = (StudyBean) studydao.findByPK(study.getParentStudyId());
        request.setAttribute("parentStudy", parentStudy);
    } 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());
    EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
    // find all eventcrfs for each event
    EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
    ArrayList<DisplayStudyEventBean> displayEvents = getDisplayStudyEventsForStudySubject(study, studySub, sm.getDataSource(), ub, currentRole);
    DiscrepancyNoteUtil discNoteUtil = new DiscrepancyNoteUtil();
    // Don't filter for now; disc note beans are returned with eventCRFId
    // set
    discNoteUtil.injectParentDiscNotesIntoDisplayStudyEvents(displayEvents, new HashSet(), sm.getDataSource(), 0);
    // All the displaystudyevents for one subject
    request.setAttribute("displayStudyEvents", displayEvents);
    // 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
    Map discNoteByEventCRFid = discNoteUtil.createDiscNoteMapByEventCRF(displayEvents);
    request.setAttribute("discNoteByEventCRFid", discNoteByEventCRFid);
    EntityBeanTable table = fp.getEntityBeanTable();
    // sort by start date,
    table.setSortingIfNotExplicitlySet(1, false);
    // 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())) {
        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);
    AuditEventDAO aedao = new AuditEventDAO(sm.getDataSource());
    ArrayList logs = aedao.findEventStatusLogByStudySubject(studySubId);
    UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
    ArrayList eventLogs = new ArrayList();
    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) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        // logger.warning("^^^ caught NFE");
        }
        UserAccountBean updater = (UserAccountBean) udao.findByPK(avb.getUserId());
        sea.setUpdater(updater);
        eventLogs.add(sea);
    }
    // logger.warning("^^^ finished iteration");
    request.setAttribute("eventLogs", eventLogs);
    forwardPage(Page.SIGN_STUDY_SUBJECT);
}
Also used : SecurityManager(org.akaza.openclinica.core.SecurityManager) 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) DiscrepancyNoteUtil(org.akaza.openclinica.service.DiscrepancyNoteUtil) AuditEventBean(org.akaza.openclinica.bean.admin.AuditEventBean) StudyEventAuditBean(org.akaza.openclinica.bean.admin.StudyEventAuditBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) HashSet(java.util.HashSet) SubjectGroupMapDAO(org.akaza.openclinica.dao.submit.SubjectGroupMapDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) Calendar(java.util.Calendar) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) AuditEventDAO(org.akaza.openclinica.dao.admin.AuditEventDAO) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) Date(java.util.Date) 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) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with SubjectEventStatus

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

the class EventStatusStatisticsTableFactory method setDataAndLimitVariables.

@Override
public void setDataAndLimitVariables(TableFacade tableFacade) {
    Limit limit = tableFacade.getLimit();
    SubjectEventStatus[] subjectEventStatuses = { SubjectEventStatus.SCHEDULED, SubjectEventStatus.DATA_ENTRY_STARTED, SubjectEventStatus.COMPLETED, SubjectEventStatus.SIGNED, SubjectEventStatus.LOCKED, SubjectEventStatus.SKIPPED, SubjectEventStatus.STOPPED };
    Collection<HashMap<Object, Object>> theItems = new ArrayList<HashMap<Object, Object>>();
    /*
         * Because we are using the State feature (via stateAttr) we can do a
         * check to see if we have a complete limit already. See the State
         * feature for more details Very important to set the totalRow before
         * trying to get the row start and row end variables. Very important to
         * set the totalRow before trying to get the row start and row end
         * variables.
         */
    if (!limit.isComplete()) {
        int totalRows = subjectEventStatuses.length;
        tableFacade.setTotalRows(totalRows);
    }
    int rowStart = limit.getRowSelect().getRowStart();
    int rowEnd = limit.getRowSelect().getRowEnd();
    for (SubjectEventStatus subjectEventStatus : subjectEventStatuses) {
        Integer totalEventsByEventStatus = studyEventDao.getCountofEventsBasedOnEventStatus(currentStudy, subjectEventStatus);
        Integer totalEvents = studyEventDao.getCountofEvents(currentStudy);
        Long percentage = totalEvents == 0 ? 0 : Math.round((totalEventsByEventStatus.doubleValue() / totalEvents.doubleValue()) * 100);
        HashMap<Object, Object> theItem = new HashMap<Object, Object>();
        theItem.put("status", subjectEventStatus.getName());
        theItem.put("studySubjects", totalEventsByEventStatus);
        theItem.put("percentage", String.valueOf(percentage) + "%");
        theItems.add(theItem);
    }
    tableFacade.setItems(theItems);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Limit(org.jmesa.limit.Limit) SubjectEventStatus(org.akaza.openclinica.bean.core.SubjectEventStatus)

Example 3 with SubjectEventStatus

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

the class ListEventsForSubjectTableFactory method singleEventDivBuilder.

private void singleEventDivBuilder(HtmlBuilder eventDiv, SubjectBean subject, Integer rowCount, List<StudyEventBean> studyEvents, StudyEventDefinitionBean sed, StudySubjectBean studySubject) {
    String tableHeaderRowLeftStyleClass = "table_header_row_left";
    String click_for_more_options = resword.getString("click_for_more_options");
    String schedule = resword.getString("schedule");
    String view = resword.getString("view") + "/" + resword.getString("enter_data");
    String edit = resword.getString("edit");
    ;
    String remove = resword.getString("remove");
    ;
    String subjectText = resword.getString("subject");
    ;
    String eventText = resword.getString("event");
    ;
    SubjectEventStatus eventStatus = studyEvents.size() == 0 ? SubjectEventStatus.NOT_SCHEDULED : studyEvents.get(0).getSubjectEventStatus();
    // String studyEventName = studyEvents.size() == 0 ? "" : studyEvents.get(0).getName();
    String studyEventId = studyEvents.size() == 0 ? "" : String.valueOf(studyEvents.get(0).getId());
    Status eventSysStatus = studySubject.getStatus();
    String studySubjectLabel = studySubject.getLabel();
    eventDiv.td(0).styleClass(tableHeaderRowLeftStyleClass).close();
    eventDiv.append(subjectText).append(": ").append(studySubjectLabel).br();
    eventDiv.append(eventText).append(": ").append(sed.getName()).br();
    eventDiv.append(resword.getString("status")).append(":").append(eventStatus.getName()).br();
    eventDiv.tdEnd();
    eventDiv.td(0).styleClass(tableHeaderRowLeftStyleClass).align("right").close();
    linkBuilder(eventDiv, studySubjectLabel, rowCount, studyEvents, sed);
    eventDiv.tdEnd();
    eventDiv.trEnd(0);
    eventDiv.tr(0).id("S_Menu_off_" + studySubjectLabel + "_" + sed.getId() + "_" + rowCount).style("display: all").close();
    eventDiv.td(0).styleClass("table_cell_left").colspan("2").close().append("<i>").append(click_for_more_options).append("</i>").tdEnd();
    eventDiv.trEnd(0);
    eventDiv.tr(0).id("S_Menu_on_" + studySubjectLabel + "_" + sed.getId() + "_" + rowCount).style("display: none").close();
    eventDiv.td(0).colspan("2").close();
    eventDiv.table(0).border("0").cellpadding("0").cellspacing("0").width("100%").close();
    if (eventSysStatus.getId() == Status.AVAILABLE.getId() || eventSysStatus == Status.SIGNED) {
        if (eventStatus == SubjectEventStatus.NOT_SCHEDULED && currentRole.getRole() != Role.MONITOR && !studyBean.getStatus().isFrozen()) {
            eventDiv.tr(0).valign("top").close();
            eventDiv.td(0).styleClass("table_cell_left").close();
            createNewStudyEventLinkBuilder(eventDiv, studySubject.getId(), sed, schedule);
            eventDiv.tdEnd().trEnd(0);
        } else if (eventStatus == SubjectEventStatus.COMPLETED) {
            eventDiv.tr(0).valign("top").close();
            eventDiv.td(0).styleClass("table_cell_left").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_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);
            }
        } else if (eventStatus == SubjectEventStatus.LOCKED) {
            eventDiv.tdEnd().trEnd(0);
            if (currentRole.getRole() == Role.STUDYDIRECTOR || currentUser.isSysAdmin()) {
                eventDiv.tr(0).valign("top").close();
                eventDiv.td(0).styleClass("table_cell_left").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_left").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").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_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_left").close();
        enterDataForStudyEventLinkBuilder(eventDiv, studyEventId, view);
        eventDiv.tdEnd().trEnd(0);
    }
    eventDiv.tableEnd(0).tdEnd().trEnd(0);
    eventDiv.tableEnd(0);
    eventDiv.divEnd().divEnd().divEnd().divEnd().divEnd().divEnd().divEnd().divEnd().divEnd().divEnd().divEnd();
    iconLinkBuilder(eventDiv, studySubjectLabel, rowCount, studyEvents, sed);
}
Also used : Status(org.akaza.openclinica.bean.core.Status) SubjectEventStatus(org.akaza.openclinica.bean.core.SubjectEventStatus) SubjectEventStatus(org.akaza.openclinica.bean.core.SubjectEventStatus)

Example 4 with SubjectEventStatus

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

the class ListDiscNotesSubjectTableFactory method setDataAndLimitVariables.

@Override
public void setDataAndLimitVariables(TableFacade tableFacade) {
    StudyBean study = this.getStudyBean();
    Limit limit = tableFacade.getLimit();
    ListDiscNotesSubjectFilter subjectFilter = getSubjectFilter(limit);
    subjectFilter.addFilter("dn.discrepancy_note_type_id", this.discNoteType);
    StringBuffer constraints = new StringBuffer();
    if (this.discNoteType > 0 && this.discNoteType < 10) {
        constraints.append(" and dn.discrepancy_note_type_id=" + this.discNoteType);
    }
    if (this.resolutionStatusIds != null && this.resolutionStatusIds.size() > 0) {
        String s = " and (";
        for (Integer resolutionStatusId : this.resolutionStatusIds) {
            s += "dn.resolution_status_id = " + resolutionStatusId + " or ";
        }
        s = s.substring(0, s.length() - 3) + " )";
        subjectFilter.addFilter("dn.resolution_status_id", s);
        constraints.append(s);
    }
    if (!limit.isComplete()) {
        int totalRows = getStudySubjectDAO().getCountWithFilter(subjectFilter, study);
        tableFacade.setTotalRows(totalRows);
    }
    ListDiscNotesSubjectSort subjectSort = getSubjectSort(limit);
    int rowStart = limit.getRowSelect().getRowStart();
    int rowEnd = limit.getRowSelect().getRowEnd();
    Collection<StudySubjectBean> items = getStudySubjectDAO().getWithFilterAndSort(study, subjectFilter, subjectSort, rowStart, rowEnd);
    Collection<HashMap<Object, Object>> theItems = new ArrayList<HashMap<Object, Object>>();
    boolean hasDN = false;
    for (StudySubjectBean studySubjectBean : items) {
        HashMap<Object, Object> theItem = new HashMap<Object, Object>();
        theItem.put("studySubject", studySubjectBean);
        theItem.put("studySubject.label", studySubjectBean.getLabel());
        theItem.put("studySubject.status", studySubjectBean.getStatus());
        theItem.put("enrolledAt", ((StudyBean) getStudyDAO().findByPK(studySubjectBean.getStudyId())).getIdentifier());
        // Get All study events for this study subject and then put list in
        // HashMap with study event definition id as
        // key and a list of study events as the value.
        List<StudyEventBean> allStudyEventsForStudySubject = getStudyEventDAO().findAllByStudySubject(studySubjectBean);
        HashMap<Integer, List<StudyEventBean>> allStudyEventsForStudySubjectBySedId = new HashMap<Integer, List<StudyEventBean>>();
        theItem.put("isSignable", isSignable(allStudyEventsForStudySubject));
        for (StudyEventBean studyEventBean : allStudyEventsForStudySubject) {
            if (allStudyEventsForStudySubjectBySedId.get(studyEventBean.getStudyEventDefinitionId()) == null) {
                ArrayList<StudyEventBean> a = new ArrayList<StudyEventBean>();
                a.add(studyEventBean);
                allStudyEventsForStudySubjectBySedId.put(studyEventBean.getStudyEventDefinitionId(), a);
            } else {
                allStudyEventsForStudySubjectBySedId.get(studyEventBean.getStudyEventDefinitionId()).add(studyEventBean);
            }
        }
        for (StudyEventDefinitionBean studyEventDefinition : getStudyEventDefinitions()) {
            List<StudyEventBean> studyEvents = allStudyEventsForStudySubjectBySedId.get(studyEventDefinition.getId());
            SubjectEventStatus subjectEventStatus = null;
            HashMap<ResolutionStatus, Integer> discCounts = new HashMap<ResolutionStatus, Integer>();
            studyEvents = studyEvents == null ? new ArrayList<StudyEventBean>() : studyEvents;
            if (studyEvents.size() < 1) {
                subjectEventStatus = SubjectEventStatus.NOT_SCHEDULED;
            } else {
                for (StudyEventBean studyEventBean : studyEvents) {
                    discCounts = countAll(discCounts, studyEventBean, constraints, study.isSite(study.getParentStudyId()));
                    hasDN = hasDN == false ? discCounts.size() > 0 : hasDN;
                    if (studyEventBean.getSampleOrdinal() == 1) {
                        subjectEventStatus = studyEventBean.getSubjectEventStatus();
                    // break;
                    }
                }
            }
            theItem.put("sed_" + studyEventDefinition.getId() + "_discCounts", discCounts);
            theItem.put("sed_" + studyEventDefinition.getId(), subjectEventStatus.getId());
            theItem.put("sed_" + studyEventDefinition.getId() + "_studyEvents", studyEvents);
            theItem.put("sed_" + studyEventDefinition.getId() + "_object", studyEventDefinition);
        }
        theItems.add(theItem);
    }
    // Do not forget to set the items back on the tableFacade.
    tableFacade.setItems(theItems);
    setStudyHasDiscNotes(hasDN);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) SubjectEventStatus(org.akaza.openclinica.bean.core.SubjectEventStatus) ResolutionStatus(org.akaza.openclinica.bean.core.ResolutionStatus) List(java.util.List) ArrayList(java.util.ArrayList) ListDiscNotesSubjectFilter(org.akaza.openclinica.dao.managestudy.ListDiscNotesSubjectFilter) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ListDiscNotesSubjectSort(org.akaza.openclinica.dao.managestudy.ListDiscNotesSubjectSort) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) Limit(org.jmesa.limit.Limit)

Example 5 with SubjectEventStatus

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

the class ListDiscNotesSubjectTableFactory method singleEventDivBuilder.

private void singleEventDivBuilder(HtmlBuilder eventDiv, SubjectBean subject, Integer rowCount, List<StudyEventBean> studyEvents, StudyEventDefinitionBean sed, StudySubjectBean studySubject) {
    String tableHeaderRowStyleClass = "table_header_row";
    String tableHeaderRowLeftStyleClass = "table_header_row_left";
    String add_another_occurrence = resword.getString("add_another_occurrence");
    String click_for_more_options = resword.getString("click_for_more_options");
    String schedule = resword.getString("schedule");
    String view = resword.getString("view") + "/" + resword.getString("enter_data");
    String edit = resword.getString("edit");
    String remove = resword.getString("remove");
    String occurrence_x_of = resword.getString("ocurrence");
    String subjectText = resword.getString("subject");
    String eventText = resword.getString("event");
    String status = resword.getString("status");
    SubjectEventStatus eventStatus = studyEvents.size() == 0 ? SubjectEventStatus.NOT_SCHEDULED : studyEvents.get(0).getSubjectEventStatus();
    String studyEventName = studyEvents.size() == 0 ? "" : studyEvents.get(0).getName();
    String studyEventId = studyEvents.size() == 0 ? "" : String.valueOf(studyEvents.get(0).getId());
    Status eventSysStatus = studySubject.getStatus();
    String studySubjectLabel = studySubject.getLabel();
    eventDiv.td(0).styleClass(tableHeaderRowLeftStyleClass).close();
    eventDiv.append(subjectText).append(": ").append(studySubjectLabel).br();
    eventDiv.append(eventText).append(": ").append(sed.getName()).br();
    if (!sed.isRepeating()) {
        eventDiv.append(resword.getString("status")).append(":").append(eventStatus.getName()).br();
        eventDiv.tdEnd();
        eventDiv.td(0).styleClass(tableHeaderRowLeftStyleClass).align("right").close();
        linkBuilder(eventDiv, studySubjectLabel, rowCount, studyEvents, sed);
        eventDiv.tdEnd();
    } else {
        eventDiv.tdEnd();
        eventDiv.td(0).styleClass(tableHeaderRowLeftStyleClass).align("right").close();
        linkBuilder(eventDiv, studySubjectLabel, rowCount, studyEvents, sed);
        eventDiv.tdEnd();
        eventDiv.tr(0).valign("top").close();
        eventDiv.td(0).styleClass(tableHeaderRowStyleClass).colspan("2").close();
        eventDiv.bold().append(occurrence_x_of).append("#1 of 1").br();
        if (studyEvents.size() > 0) {
            eventDiv.append(formatDate(studyEvents.get(0).getDateStarted())).br();
            eventDiv.append(status + " : " + studyEvents.get(0).getSubjectEventStatus().getName());
        } else {
            eventDiv.append(status + " : " + SubjectEventStatus.NOT_SCHEDULED.getName());
        }
        eventDiv.boldEnd().tdEnd().trEnd(0);
        if (eventStatus != SubjectEventStatus.NOT_SCHEDULED && eventSysStatus != Status.DELETED && eventSysStatus != Status.AUTO_DELETED) {
            eventDiv.tr(0).close().td(0).styleClass("table_cell_left").close();
            eventDiv.ahref("CreateNewStudyEvent?studySubjectId=" + studySubject.getId() + "&studyEventDefinition=" + sed.getId(), add_another_occurrence);
            eventDiv.tdEnd().trEnd(0);
        }
    }
    eventDiv.trEnd(0);
    eventDiv.tr(0).id("Menu_off_" + studySubjectLabel + "_" + sed.getId() + "_" + rowCount).style("display: all").close();
    eventDiv.td(0).styleClass("table_cell_left").colspan("2").close().append("<i>").append(click_for_more_options).append("</i>").tdEnd();
    eventDiv.trEnd(0);
    eventDiv.tr(0).id("Menu_on_" + studySubjectLabel + "_" + sed.getId() + "_" + rowCount).style("display: none").close();
    eventDiv.td(0).colspan("2").close();
    eventDiv.table(0).border("0").cellpadding("0").cellspacing("0").close();
    if (eventSysStatus.getId() == Status.AVAILABLE.getId() || eventSysStatus == Status.SIGNED) {
        if (eventStatus == SubjectEventStatus.NOT_SCHEDULED && currentRole.getRole() != Role.MONITOR) {
            eventDiv.tr(0).valign("top").close();
            eventDiv.td(0).styleClass("table_cell_left").close();
            createNewStudyEventLinkBuilder(eventDiv, studySubject.getId(), sed, schedule);
            eventDiv.tdEnd().trEnd(0);
        } else if (eventStatus == SubjectEventStatus.COMPLETED) {
            eventDiv.tr(0).valign("top").close();
            eventDiv.td(0).styleClass("table_cell_left").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_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);
            }
        } else if (eventStatus == SubjectEventStatus.LOCKED) {
            eventDiv.tdEnd().trEnd(0);
            if (currentRole.getRole() == Role.STUDYDIRECTOR || currentUser.isSysAdmin()) {
                eventDiv.tr(0).valign("top").close();
                eventDiv.td(0).styleClass("table_cell_left").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_left").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_left").close();
        enterDataForStudyEventLinkBuilder(eventDiv, studyEventId, view);
        eventDiv.tdEnd().trEnd(0);
    }
    eventDiv.tableEnd(0).tdEnd().trEnd(0);
    eventDiv.tableEnd(0);
    eventDiv.divEnd().divEnd().divEnd().divEnd().divEnd().divEnd().divEnd().divEnd().divEnd().divEnd().divEnd();
    iconLinkBuilder(eventDiv, studySubjectLabel, rowCount, studyEvents, sed);
}
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)

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