Search in sources :

Example 11 with DisplayEventCRFBean

use of org.akaza.openclinica.bean.submit.DisplayEventCRFBean in project OpenClinica by OpenClinica.

the class StudySubjectServiceImpl method getDisplayEventCRFs.

private List<DisplayEventCRFBean> getDisplayEventCRFs(List eventCRFs, UserAccountBean ub, StudyUserRoleBean currentRole, SubjectEventStatus status, StudyBean study, Set<Integer> nonEmptyEventCrf, Map<Integer, FormLayoutBean> formLayoutById, Map<Integer, CRFBean> crfById, Integer studyEventDefinitionId, List eventDefinitionCRFs) {
    ArrayList<DisplayEventCRFBean> answer = new ArrayList<DisplayEventCRFBean>();
    for (int i = 0; i < eventCRFs.size(); i++) {
        EventCRFBean ecb = (EventCRFBean) eventCRFs.get(i);
        // populate the event CRF with its crf bean
        int formLayoutId = ecb.getFormLayoutId();
        FormLayoutBean flb = formLayoutById.get(formLayoutId);
        ecb.setFormLayout(flb);
        CRFBean cb = crfById.get(flb.getCrfId());
        ecb.setCrf(cb);
        EventDefinitionCRFBean edc = null;
        Iterator it = eventDefinitionCRFs.iterator();
        while (it.hasNext()) {
            EventDefinitionCRFBean edcBean = (EventDefinitionCRFBean) it.next();
            if (edcBean.getCrfId() == cb.getId()) {
                edc = edcBean;
                break;
            }
        }
        // rules updated 112007 tbh
        if (status.equals(SubjectEventStatus.LOCKED) || status.equals(SubjectEventStatus.SKIPPED) || status.equals(SubjectEventStatus.STOPPED)) {
            ecb.setStage(DataEntryStage.LOCKED);
        // we need to set a SED-wide flag here, because other edcs
        // in this event can be filled in and change the status, tbh
        } else if (status.equals(SubjectEventStatus.INVALID)) {
            ecb.setStage(DataEntryStage.LOCKED);
        } else if (!cb.getStatus().equals(Status.AVAILABLE)) {
            ecb.setStage(DataEntryStage.LOCKED);
        } else if (!flb.getStatus().equals(Status.AVAILABLE)) {
            ecb.setStage(DataEntryStage.LOCKED);
        }
        // TODO need to refactor since this is similar to other code, tbh
        if (edc != null) {
            // System.out.println("edc is not null, need to set flags");
            DisplayEventCRFBean dec = new DisplayEventCRFBean();
            dec.setEventDefinitionCRF(edc);
            // System.out.println("edc.isDoubleEntry()" +
            // edc.isDoubleEntry() + ecb.getId());
            dec.setFlags(ecb, ub, currentRole, edc.isDoubleEntry());
            if (dec.isLocked()) {
            // System.out.println("*** found a locked DEC:
            // "+edc.getCrfName());
            }
            if (nonEmptyEventCrf.contains(ecb.getId())) {
                // consider an event crf started only if item data get
                // created
                answer.add(dec);
            }
        }
    }
    return answer;
}
Also used : DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) FormLayoutBean(org.akaza.openclinica.bean.submit.FormLayoutBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 12 with DisplayEventCRFBean

use of org.akaza.openclinica.bean.submit.DisplayEventCRFBean in project OpenClinica by OpenClinica.

the class HideCRFManager method removeHiddenEventCRF.

public void removeHiddenEventCRF(DisplayStudyEventBean displayStudyEventBean) {
    List<DisplayEventCRFBean> eventCRFBeans = displayStudyEventBean.getAllEventCRFs();
    displayStudyEventBean.setAllEventCRFs(suppressHiddenEventCRFBeans(eventCRFBeans));
    eventCRFBeans = displayStudyEventBean.getDisplayEventCRFs();
    displayStudyEventBean.setDisplayEventCRFs(suppressHiddenEventCRFBeans(eventCRFBeans));
    List<DisplayEventDefinitionCRFBean> displayEventDefinitionCRFBeans = displayStudyEventBean.getUncompletedCRFs();
    ArrayList<DisplayEventDefinitionCRFBean> newDisplayEventDefinitionCRFBeans = new ArrayList<DisplayEventDefinitionCRFBean>();
    for (DisplayEventDefinitionCRFBean displayEventDefinitionCRFBean : displayEventDefinitionCRFBeans) {
        if (!displayEventDefinitionCRFBean.getEdc().isHideCrf()) {
            newDisplayEventDefinitionCRFBeans.add(displayEventDefinitionCRFBean);
        }
    }
    displayStudyEventBean.setUncompletedCRFs(newDisplayEventDefinitionCRFBeans);
}
Also used : DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) ArrayList(java.util.ArrayList) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean)

Example 13 with DisplayEventCRFBean

use of org.akaza.openclinica.bean.submit.DisplayEventCRFBean in project OpenClinica by OpenClinica.

the class StudyInfoPanel method generateTreeFromBeans.

/**
     * Generates a tree view in sdie info panel for submitting data page
     *
     * @param rows
     * @param displayData
     * @param studySubject
     * @param ecb
     * @return
     */
public ArrayList generateTreeFromBeans(ArrayList rows, ArrayList displayData, StudySubjectBean studySubject, EventCRFBean ecb) {
    Iterator itRows = rows.iterator();
    displayData.add(new StudyInfoPanelLine(resword.getString("study_events"), "(" + rows.size() + ")", true, false, false));
    while (itRows.hasNext()) {
        DisplayStudyEventBean dseBean = (DisplayStudyEventBean) itRows.next();
        StudyEventBean seBean = dseBean.getStudyEvent();
        // checks whether the event is the current one
        if (ecb != null && ecb.getStudyEventId() == seBean.getId()) {
            displayData.add(new StudyInfoPanelLine("Study Event", seBean.getStudyEventDefinition().getName(), true, false, true));
        } else {
            displayData.add(new StudyInfoPanelLine("Study Event", seBean.getStudyEventDefinition().getName(), true, false, false));
        }
        displayData.add(new StudyInfoPanelLine("<b>Status: </b>", "<a href='EnterDataForStudyEvent?eventId=" + seBean.getId() + "'>" + seBean.getSubjectEventStatus().getName() + "</a>", false, false, false));
        ArrayList displayCRFs = dseBean.getDisplayEventCRFs();
        int count = 0;
        Iterator displayIt = displayCRFs.iterator();
        while (displayIt.hasNext()) {
            DisplayEventCRFBean dec = (DisplayEventCRFBean) displayIt.next();
            if (count == displayCRFs.size() - 1 && dseBean.getUncompletedCRFs().size() == 0) {
                // it's the current crf
                if (ecb != null && ecb.getId() == dec.getEventCRF().getId()) {
                    // was
                    // getName(),
                    // tbh
                    displayData.add(new StudyInfoPanelLine("" + getStageImageText(dec.getStage()), "<span class='alert'>" + dec.getEventCRF().getCrf().getName() + " " + dec.getEventCRF().getCrfVersion().getName() + "</span>", false, true, true));
                } else {
                    displayData.add(new StudyInfoPanelLine("" + getStageImageText(dec.getStage()), "<a href='" + getTOCLink(dec) + "'>" + dec.getEventCRF().getCrf().getName() + " " + dec.getEventCRF().getCrfVersion().getName() + "</a>", false, true, false));
                }
            } else {
                if (ecb != null && ecb.getId() == dec.getEventCRF().getId()) {
                    displayData.add(new StudyInfoPanelLine("" + getStageImageText(dec.getStage()), "<span class='alert'>" + dec.getEventCRF().getCrf().getName() + " " + dec.getEventCRF().getCrfVersion().getName() + "</span>", false, false, true));
                } else {
                    displayData.add(new StudyInfoPanelLine("" + getStageImageText(dec.getStage()), "<a href='" + getTOCLink(dec) + "'>" + dec.getEventCRF().getCrf().getName() + " " + dec.getEventCRF().getCrfVersion().getName() + "</a>", false, false, false));
                }
            }
            count++;
        }
        count = 0;
        ArrayList uncompleted = dseBean.getUncompletedCRFs();
        Iterator uncompIt = uncompleted.iterator();
        while (uncompIt.hasNext()) {
            DisplayEventDefinitionCRFBean dedc = (DisplayEventDefinitionCRFBean) uncompIt.next();
            if (count == uncompleted.size() - 1) {
                if (ecb != null && ecb.getId() == dedc.getEventCRF().getId() && ecb.getCrf().getId() == dedc.getEventCRF().getCrf().getId()) {
                    // logger.info("ecb id*******" + ecb.getId() +
                    // dedc.getEventCRF().getId());
                    displayData.add(new StudyInfoPanelLine("<img src='images/icon_NotStarted.gif' alt='Not Started'/>", "<span class='alert'>" + dedc.getEdc().getCrf().getName() + "</span>", false, true, true));
                } else {
                    displayData.add(new StudyInfoPanelLine("<img src='images/icon_NotStarted.gif' alt='Not Started'/>", "<a href='InitialDataEntry?eventDefinitionCRFId=" + dedc.getEdc().getId() + "&studyEventId=" + seBean.getId() + "&subjectId=" + studySubject.getSubjectId() + "&eventCRFId=" + dedc.getEventCRF().getId() + "&crfVersionId=" + dedc.getEdc().getDefaultVersionId() + "'>" + dedc.getEdc().getCrf().getName() + "</a>", false, true, false));
                }
            } else {
                if (ecb != null && ecb.getId() == dedc.getEventCRF().getId()) {
                    // logger.info("ecb id*******" + ecb.getId() +
                    // dedc.getEventCRF().getId());
                    displayData.add(new StudyInfoPanelLine("<img src='images/icon_NotStarted.gif' alt='Not Started'/>", "<span class='alert'>" + dedc.getEdc().getCrf().getName() + "</span>", false, false, true));
                } else {
                    displayData.add(new StudyInfoPanelLine("<img src='images/icon_NotStarted.gif' alt='Not Started'/>", "<a href='InitialDataEntry?eventDefinitionCRFId=" + dedc.getEdc().getId() + "&studyEventId=" + seBean.getId() + "&subjectId=" + studySubject.getSubjectId() + "&eventCRFId=" + dedc.getEventCRF().getId() + "&crfVersionId=" + dedc.getEdc().getDefaultVersionId() + "'>" + dedc.getEdc().getCrf().getName() + "</a>", false, false, false));
                }
            }
            count++;
        }
    }
    return displayData;
}
Also used : DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) DisplayStudyEventBean(org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) DisplayStudyEventBean(org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean)

Example 14 with DisplayEventCRFBean

use of org.akaza.openclinica.bean.submit.DisplayEventCRFBean in project OpenClinica by OpenClinica.

the class RestoreEventCRFServlet method processRequest.

@Override
public void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    // eventCRFId
    int eventCRFId = fp.getInt("id");
    // studySubjectId
    int studySubId = fp.getInt("studySubId");
    checkStudyLocked("ViewStudySubject?id" + studySubId, respage.getString("current_study_locked"));
    StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
    StudySubjectDAO subdao = new StudySubjectDAO(sm.getDataSource());
    EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
    StudyDAO sdao = new StudyDAO(sm.getDataSource());
    if (eventCRFId == 0) {
        addPageMessage(respage.getString("please_choose_an_event_CRF_to_restore"));
        request.setAttribute("id", new Integer(studySubId).toString());
        forwardPage(Page.VIEW_STUDY_SUBJECT_SERVLET);
    } else {
        EventCRFBean eventCRF = (EventCRFBean) ecdao.findByPK(eventCRFId);
        StudySubjectBean studySub = (StudySubjectBean) subdao.findByPK(studySubId);
        // YW 11-07-2007, an event CRF could not be restored if its study
        // subject has been removed
        Status s = studySub.getStatus();
        if ("removed".equalsIgnoreCase(s.getName()) || "auto-removed".equalsIgnoreCase(s.getName())) {
            addPageMessage(resword.getString("event_CRF") + resterm.getString("could_not_be") + resterm.getString("restored") + "." + respage.getString("study_subject_has_been_deleted"));
            request.setAttribute("id", new Integer(studySubId).toString());
            forwardPage(Page.VIEW_STUDY_SUBJECT_SERVLET);
        }
        // YW
        request.setAttribute("studySub", studySub);
        // construct info needed on view event crf page
        CRFDAO cdao = new CRFDAO(sm.getDataSource());
        CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
        int crfVersionId = eventCRF.getCRFVersionId();
        CRFBean cb = cdao.findByVersionId(crfVersionId);
        eventCRF.setCrf(cb);
        CRFVersionBean cvb = (CRFVersionBean) cvdao.findByPK(crfVersionId);
        eventCRF.setCrfVersion(cvb);
        // then get the definition so we can call
        // DisplayEventCRFBean.setFlags
        int studyEventId = eventCRF.getStudyEventId();
        StudyEventBean event = (StudyEventBean) sedao.findByPK(studyEventId);
        int studyEventDefinitionId = sedao.getDefinitionIdFromStudyEventId(studyEventId);
        StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
        StudyEventDefinitionBean sed = (StudyEventDefinitionBean) seddao.findByPK(studyEventDefinitionId);
        event.setStudyEventDefinition(sed);
        request.setAttribute("event", event);
        EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
        StudyBean study = (StudyBean) sdao.findByPK(studySub.getStudyId());
        EventDefinitionCRFBean edc = edcdao.findByStudyEventDefinitionIdAndCRFId(study, studyEventDefinitionId, cb.getId());
        DisplayEventCRFBean dec = new DisplayEventCRFBean();
        dec.setEventCRF(eventCRF);
        dec.setFlags(eventCRF, ub, currentRole, edc.isDoubleEntry());
        // find all item data
        ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
        ArrayList itemData = iddao.findAllByEventCRFId(eventCRF.getId());
        request.setAttribute("items", itemData);
        String action = request.getParameter("action");
        if ("confirm".equalsIgnoreCase(action)) {
            if (!eventCRF.getStatus().equals(Status.DELETED) && !eventCRF.getStatus().equals(Status.AUTO_DELETED)) {
                addPageMessage(respage.getString("this_event_CRF_avilable_for_study") + " " + " " + respage.getString("please_contact_sysadmin_for_more_information"));
                request.setAttribute("id", new Integer(studySubId).toString());
                forwardPage(Page.VIEW_STUDY_SUBJECT_SERVLET);
                return;
            }
            request.setAttribute("displayEventCRF", dec);
            forwardPage(Page.RESTORE_EVENT_CRF);
        } else {
            logger.info("submit to restore the event CRF from study");
            eventCRF.setStatus(Status.AVAILABLE);
            eventCRF.setUpdater(ub);
            eventCRF.setUpdatedDate(new Date());
            ecdao.update(eventCRF);
            // restore all the item data
            for (int a = 0; a < itemData.size(); a++) {
                ItemDataBean item = (ItemDataBean) itemData.get(a);
                if (item.getStatus().equals(Status.AUTO_DELETED)) {
                    item.setStatus(Status.AVAILABLE);
                    item.setUpdater(ub);
                    item.setUpdatedDate(new Date());
                    iddao.update(item);
                }
            }
            String emailBody = respage.getString("the_event_CRF") + cb.getName() + " " + respage.getString("has_been_restored_to_the_event") + " " + event.getStudyEventDefinition().getName() + ".";
            addPageMessage(emailBody);
            sendEmail(emailBody);
            request.setAttribute("id", new Integer(studySubId).toString());
            forwardPage(Page.VIEW_STUDY_SUBJECT_SERVLET);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) Status(org.akaza.openclinica.bean.core.Status) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) Date(java.util.Date) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 15 with DisplayEventCRFBean

use of org.akaza.openclinica.bean.submit.DisplayEventCRFBean in project OpenClinica by OpenClinica.

the class ListEventsForSubjectServlet method processRequest.

@Override
public void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    // checks which module the requests are from
    String module = fp.getString(MODULE);
    request.setAttribute(MODULE, module);
    String pageNumber = fp.getString(ListStudySubjectServlet.SUBJECT_PAGE_NUMBER);
    String filterKeyword = fp.getString(ListStudySubjectServlet.FILTER_KEYWORD);
    String tmpSearch = fp.getString(ListStudySubjectServlet.SEARCH_SUBMITTED);
    boolean searchSubmitted = !(tmpSearch == null || "".equalsIgnoreCase(tmpSearch)) && !"".equalsIgnoreCase(filterKeyword);
    SubjectMatrixUtil matrixUtil = new SubjectMatrixUtil();
    String query = matrixUtil.createPaginatingQuery(pageNumber);
    StringBuilder extendedQuery = new StringBuilder(query);
    // URL encode the search keyword, since it will be a parameter in the
    // URL
    String filterKeywordURLEncode = java.net.URLEncoder.encode(filterKeyword, "UTF-8");
    if (searchSubmitted) {
        extendedQuery.append("&ebl_sortColumnInd=0&submitted=1&ebl_sortAscending=1&ebl_filtered=1");
        extendedQuery.append("&").append(ListStudySubjectServlet.FILTER_KEYWORD).append("=").append(filterKeywordURLEncode);
    }
    request.setAttribute(ListStudySubjectServlet.PAGINATING_QUERY, extendedQuery.toString());
    int definitionId = fp.getInt("defId");
    int tabId = fp.getInt("tab");
    if (definitionId <= 0) {
        addPageMessage(respage.getString("please_choose_an_ED_ta_to_vies_details"));
        forwardPage(Page.LIST_STUDY_SUBJECTS);
        return;
    }
    StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
    StudyEventDefinitionBean sed = (StudyEventDefinitionBean) seddao.findByPK(definitionId);
    StudySubjectDAO sdao = new StudySubjectDAO(sm.getDataSource());
    StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
    SubjectGroupMapDAO sgmdao = new SubjectGroupMapDAO(sm.getDataSource());
    StudyGroupClassDAO sgcdao = new StudyGroupClassDAO(sm.getDataSource());
    EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
    EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
    CRFDAO crfdao = new CRFDAO(sm.getDataSource());
    // find all the groups in the current study
    ArrayList studyGroupClasses = sgcdao.findAllActiveByStudy(currentStudy);
    // information for the event tabs
    ArrayList allDefs = seddao.findAllActiveByStudy(currentStudy);
    boolean isASite = false;
    if (currentStudy.getParentStudyId() > 0) {
        StudyDAO stdao = new StudyDAO(sm.getDataSource());
        StudyBean parent = (StudyBean) stdao.findByPK(currentStudy.getParentStudyId());
        allDefs = seddao.findAllActiveByStudy(parent);
    }
    ArrayList eventDefinitionCRFs = (ArrayList) edcdao.findAllActiveByEventDefinitionId(this.currentStudy, definitionId);
    for (int i = 0; i < eventDefinitionCRFs.size(); i++) {
        EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
        CRFBean crf = (CRFBean) crfdao.findByPK(edc.getCrfId());
        edc.setCrf(crf);
    }
    request.setAttribute("studyGroupClasses", studyGroupClasses);
    request.setAttribute("allDefsArray", allDefs);
    request.setAttribute("allDefsNumber", new Integer(allDefs.size()));
    request.setAttribute("groupSize", new Integer(studyGroupClasses.size()));
    request.setAttribute("eventDefCRFSize", new Integer(eventDefinitionCRFs.size()));
    request.setAttribute("tabId", new Integer(tabId));
    request.setAttribute("studyEventDef", sed);
    request.setAttribute("eventDefCRFs", eventDefinitionCRFs);
    // find all the subjects in current study
    ArrayList subjects = sdao.findAllByStudyId(currentStudy.getId());
    ArrayList displayStudySubs = new ArrayList();
    for (int i = 0; i < subjects.size(); i++) {
        StudySubjectBean studySub = (StudySubjectBean) subjects.get(i);
        ArrayList groups = (ArrayList) sgmdao.findAllByStudySubject(studySub.getId());
        ArrayList subGClasses = new ArrayList();
        for (int j = 0; j < studyGroupClasses.size(); j++) {
            StudyGroupClassBean sgc = (StudyGroupClassBean) studyGroupClasses.get(j);
            boolean hasClass = false;
            for (int k = 0; k < groups.size(); k++) {
                SubjectGroupMapBean sgmb = (SubjectGroupMapBean) groups.get(k);
                if (sgmb.getGroupClassName().equalsIgnoreCase(sgc.getName())) {
                    subGClasses.add(sgmb);
                    hasClass = true;
                    break;
                }
            }
            if (!hasClass) {
                subGClasses.add(new SubjectGroupMapBean());
            }
        }
        // find all eventcrfs for each event, for each event tab
        ArrayList displaySubjectEvents = new ArrayList();
        ArrayList<DisplayStudyEventBean> displayEvents = new ArrayList<DisplayStudyEventBean>();
        ArrayList events = sedao.findAllByStudySubjectAndDefinition(studySub, sed);
        for (int k = 0; k < events.size(); k++) {
            StudyEventBean seb = (StudyEventBean) events.get(k);
            DisplayStudyEventBean dseb = ListStudySubjectServlet.getDisplayStudyEventsForStudySubject(studySub, seb, sm.getDataSource(), ub, currentRole, this.currentStudy);
            // ArrayList eventCRFs = ecdao.findAllByStudyEvent(seb);
            // ArrayList al =
            // ViewStudySubjectServlet.getUncompletedCRFs(sm.getDataSource(),
            // eventDefinitionCRFs, eventCRFs);
            // dseb.getUncompletedCRFs().add(al);
            displayEvents.add(dseb);
        }
        ArrayList al = new ArrayList();
        for (int k = 0; k < displayEvents.size(); k++) {
            DisplayStudyEventBean dseb = displayEvents.get(k);
            ArrayList eventCRFs = dseb.getDisplayEventCRFs();
            for (int a = 0; a < eventDefinitionCRFs.size(); a++) {
                EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.get(a);
                int crfId = edc.getCrfId();
                boolean hasCRF = false;
                for (int b = 0; b < eventCRFs.size(); b++) {
                    DisplayEventCRFBean decb = (DisplayEventCRFBean) eventCRFs.get(b);
                    // decb.getStage().getName() );
                    if (decb.getEventCRF().getCrf().getId() == crfId) {
                        dseb.getAllEventCRFs().add(decb);
                        // logger.info("hasCRf" + crfId +
                        // decb.getEventCRF().getCrf().getName());
                        hasCRF = true;
                        break;
                    }
                }
                if (hasCRF == false) {
                    DisplayEventCRFBean db = new DisplayEventCRFBean();
                    db.setEventDefinitionCRF(edc);
                    db.getEventDefinitionCRF().setCrf(edc.getCrf());
                    dseb.getAllEventCRFs().add(db);
                // logger.info("noCRf" + crfId);
                }
            }
            // Issue 3212 BWP <<
            if (currentStudy.getParentStudyId() > 0) {
                // check each eventDefCRFBean and set its isHidden property
                // to true, if its
                // persistent/database-derived hideCrf is true (domain rule:
                // hide the CRF from users logged into a site)
                HideCRFManager hideCRFManager = HideCRFManager.createHideCRFManager();
                hideCRFManager.optionallyCheckHideCRFProperty(dseb);
                // remove a DisplayEventCRFBean from a DisplayStudyEventBean
                // in the list
                // if it contains a hidden CRF in its event definition
                hideCRFManager.removeHiddenEventCRF(dseb);
                // generate a boolean request attribute indicating whether
                // any of the CRFs
                // should be hidden
                boolean hideCRFs = hideCRFManager.studyEventHasAHideCRFProperty(dseb);
                request.setAttribute("hideCRFs", hideCRFs);
            }
        // >>
        }
        DisplayStudySubjectBean dssb = new DisplayStudySubjectBean();
        dssb.setStudySubject(studySub);
        dssb.setStudyGroups(subGClasses);
        dssb.setStudyEvents(displayEvents);
        if (definitionId > 0) {
            dssb.setSedId(definitionId);
        } else {
            dssb.setSedId(-1);
        }
        displayStudySubs.add(dssb);
    }
    EntityBeanTable table = fp.getEntityBeanTable();
    ArrayList allStudyRows = DisplayStudySubjectEventsRow.generateRowsFromBeans(displayStudySubs);
    ArrayList columnArray = new ArrayList();
    columnArray.add(resword.getString("ID"));
    columnArray.add(resword.getString("subject_status"));
    columnArray.add(resword.getString("gender"));
    for (int i = 0; i < studyGroupClasses.size(); i++) {
        StudyGroupClassBean sgc = (StudyGroupClassBean) studyGroupClasses.get(i);
        columnArray.add(sgc.getName());
    }
    // columnArray.add("Event Sequence");
    columnArray.add(resword.getString("event_status"));
    columnArray.add(resword.getString("event_date"));
    // Issue 3212 BWP <<
    HideCRFManager hideCRFMgr = HideCRFManager.createHideCRFManager();
    hideCRFMgr.hideSpecifiedEventCRFDefBeans(eventDefinitionCRFs);
    for (int i = 0; i < eventDefinitionCRFs.size(); i++) {
        EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
        // Issue 3212 BWP <<
        if (!(currentStudy.getParentStudyId() > 0)) {
            columnArray.add(edc.getCrf().getName());
        } else {
            if (!edc.isHideCrf()) {
                columnArray.add(edc.getCrf().getName());
            }
        }
    // >>
    }
    columnArray.add(resword.getString("actions"));
    String[] columns = new String[columnArray.size()];
    columnArray.toArray(columns);
    table.setColumns(new ArrayList(Arrays.asList(columns)));
    table.setQuery("ListEventsForSubject?module=" + module + "&defId=" + definitionId + "&tab=" + tabId, new HashMap());
    table.hideColumnLink(columnArray.size() - 1);
    // if(currentStudy.getStatus().isAvailable()){
    // table.addLink(resword.getString("add_new_subject"), "AddNewSubject");
    // }
    table.setRows(allStudyRows);
    if (filterKeyword != null && !"".equalsIgnoreCase(filterKeyword)) {
        table.setKeywordFilter(filterKeyword);
    }
    table.computeDisplay();
    request.setAttribute("table", table);
    forwardPage(Page.LIST_EVENTS_FOR_SUBJECT);
}
Also used : SubjectGroupMapBean(org.akaza.openclinica.bean.submit.SubjectGroupMapBean) HashMap(java.util.HashMap) StudyGroupClassDAO(org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO) EntityBeanTable(org.akaza.openclinica.web.bean.EntityBeanTable) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) DisplayStudyEventBean(org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean) DisplayStudySubjectBean(org.akaza.openclinica.bean.managestudy.DisplayStudySubjectBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) StudyGroupClassBean(org.akaza.openclinica.bean.managestudy.StudyGroupClassBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) SubjectGroupMapDAO(org.akaza.openclinica.dao.submit.SubjectGroupMapDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) HideCRFManager(org.akaza.openclinica.service.crfdata.HideCRFManager) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) DisplayStudyEventBean(org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) DisplayStudySubjectBean(org.akaza.openclinica.bean.managestudy.DisplayStudySubjectBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Aggregations

DisplayEventCRFBean (org.akaza.openclinica.bean.submit.DisplayEventCRFBean)18 ArrayList (java.util.ArrayList)15 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)13 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)12 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)11 DisplayEventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean)11 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)10 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)10 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)9 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)8 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)7 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)7 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)7 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)6 HashMap (java.util.HashMap)5 DisplayStudyEventBean (org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean)5 FormLayoutBean (org.akaza.openclinica.bean.submit.FormLayoutBean)5 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)4 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)4 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)4