Search in sources :

Example 6 with Limit

use of org.jmesa.limit.Limit in project OpenClinica by OpenClinica.

the class DiscNotesSubjectStatisticsFactory 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(6);
    }
    int rowStart = limit.getRowSelect().getRowStart();
    int rowEnd = 6;
    ListDiscNotesSubjectSort subjectSort = getSubjectSort(limit);
    HashMap<Object, Map> items = (HashMap<Object, Map>) getDiscrepancyMap();
    Collection<HashMap<Object, Object>> theItems = new ArrayList<HashMap<Object, Object>>();
    Collection<HashMap<Object, Object>> theItemsKeys = new ArrayList<HashMap<Object, Object>>();
    Collection<HashMap<Object, Object>> theItemsVals = new ArrayList<HashMap<Object, Object>>();
    Iterator keyIt = null;
    if (items.values().iterator().hasNext())
        keyIt = items.values().iterator().next().keySet().iterator();
    HashMap<Object, Object> theItem = new HashMap();
    Set theKeys = items.keySet();
    List<Object> existingKey = new ArrayList();
    Iterator theKeysItr = theKeys.iterator();
    while (keyIt.hasNext()) {
        String key = "", val = "";
        key = keyIt.next().toString();
        for (Map<String, String[]> firstVals : items.values()) {
            theItem = new HashMap();
            Iterator it = firstVals.values().iterator();
            // keyIt = firstVals.keySet().iterator();
            String label = (String) theKeysItr.next();
            while (it.hasNext()) {
                theItem.put("_", key);
                theItem.put(label, it.next());
            }
            theItems.add(theItem);
        }
        theItemsVals.addAll(theItems);
        tableFacade.setItems(theItemsVals);
    }
}
Also used : ListDiscNotesSubjectFilter(org.akaza.openclinica.dao.managestudy.ListDiscNotesSubjectFilter) FilterSet(org.jmesa.limit.FilterSet) Set(java.util.Set) SortSet(org.jmesa.limit.SortSet) HashMap(java.util.HashMap) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) ListDiscNotesSubjectSort(org.akaza.openclinica.dao.managestudy.ListDiscNotesSubjectSort) Iterator(java.util.Iterator) Limit(org.jmesa.limit.Limit) HashMap(java.util.HashMap) Map(java.util.Map)

Example 7 with Limit

use of org.jmesa.limit.Limit 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 8 with Limit

use of org.jmesa.limit.Limit in project OpenClinica by OpenClinica.

the class ListDiscNotesForCRFTableFactory method setDataAndLimitVariables.

@SuppressWarnings("unchecked")
@Override
public void setDataAndLimitVariables(TableFacade tableFacade) {
    Limit limit = tableFacade.getLimit();
    ListDiscNotesForCRFFilter listDiscNotesForCRF = getListEventsForSubjectFilter(limit);
    listDiscNotesForCRF.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) + " )";
        listDiscNotesForCRF.addFilter("dn.resolution_status_id", s);
        constraints.append(s);
    }
    if (!limit.isComplete()) {
        int totalRows = getStudySubjectDAO().getCountWithFilter(listDiscNotesForCRF, getStudyBean());
        tableFacade.setTotalRows(totalRows);
    }
    ListDiscNotesForCRFSort eventsForSubjectSort = getListEventsForSubjectSort(limit);
    int rowStart = limit.getRowSelect().getRowStart();
    int rowEnd = limit.getRowSelect().getRowEnd();
    Collection<StudySubjectBean> items = getStudySubjectDAO().getWithFilterAndSort(getStudyBean(), listDiscNotesForCRF, eventsForSubjectSort, 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());
        SubjectBean subjectBean = (SubjectBean) getSubjectDAO().findByPK(studySubjectBean.getSubjectId());
        theItem.put("subject", subjectBean);
        theItem.put("subject.charGender", subjectBean.getGender());
        // Get EventCrfs for study Subject
        List<EventCRFBean> eventCrfs = getEventCRFDAO().findAllByStudySubject(studySubjectBean.getId());
        HashMap<String, EventCRFBean> crfAsKeyEventCrfAsValue = new HashMap<String, EventCRFBean>();
        for (EventCRFBean eventCRFBean : eventCrfs) {
            CRFBean crf = getCrfDAO().findByVersionId(eventCRFBean.getCRFVersionId());
            crfAsKeyEventCrfAsValue.put(crf.getId() + "_" + eventCRFBean.getStudyEventId(), eventCRFBean);
        }
        // Get the event Status
        List<StudyEventBean> eventsForStudySubjectAndEventDefinitions = getStudyEventDAO().findAllByDefinitionAndSubject(selectedStudyEventDefinition, studySubjectBean);
        List<DisplayBean> events = new ArrayList<DisplayBean>();
        // study event size < 1
        if (eventsForStudySubjectAndEventDefinitions.size() < 1) {
            DisplayBean d = new DisplayBean();
            d.getProps().put("event", null);
            d.getProps().put("event.status", SubjectEventStatus.NOT_SCHEDULED);
            d.getProps().put("event.startDate", null);
            for (int i = 0; i < getCrfs(selectedStudyEventDefinition).size(); i++) {
                CRFBean crf = getCrfs(selectedStudyEventDefinition).get(i);
                HashMap<ResolutionStatus, Integer> discCounts = new HashMap<ResolutionStatus, Integer>();
                d.getProps().put("crf_" + crf.getId(), DataEntryStage.UNCOMPLETED);
                d.getProps().put("crf_" + crf.getId() + "_eventCrf", null);
                d.getProps().put("crf_" + crf.getId() + "_crf", crf);
                d.getProps().put("crf_" + crf.getId() + "_eventDefinitionCrf", eventDefinitionCrfs.get(i));
                d.getProps().put("crf_" + crf.getId() + "_discCounts", discCounts);
                theItem.put("crf_" + crf.getId(), "");
            }
            events.add(d);
        }
        // study event size >0
        for (StudyEventBean studyEventBean : eventsForStudySubjectAndEventDefinitions) {
            DisplayBean d = new DisplayBean();
            d.getProps().put("event", studyEventBean);
            d.getProps().put("event.status", studyEventBean.getSubjectEventStatus());
            d.getProps().put("event.startDate", studyEventBean.getCreatedDate());
            for (int i = 0; i < getCrfs(selectedStudyEventDefinition).size(); i++) {
                CRFBean crf = getCrfs(selectedStudyEventDefinition).get(i);
                EventCRFBean eventCRFBean = crfAsKeyEventCrfAsValue.get(crf.getId() + "_" + studyEventBean.getId());
                HashMap<ResolutionStatus, Integer> discCounts = new HashMap<ResolutionStatus, Integer>();
                if (eventCRFBean != null) {
                    d.getProps().put("crf_" + crf.getId(), eventCRFBean.getStage());
                    d.getProps().put("crf_" + crf.getId() + "_eventCrf", eventCRFBean);
                    // List<DiscrepancyNoteBean> discs =
                    // getDiscrepancyNoteDAO().findAllByStudyEvent(studyEventBean);
                    List<DiscrepancyNoteBean> discs = getDiscrepancyNoteDAO().findAllParentItemNotesByEventCRFWithConstraints(eventCRFBean.getId(), constraints);
                    hasDN = hasDN == false ? discs != null && discs.size() > 0 : hasDN;
                    for (DiscrepancyNoteBean discrepancyNoteBean : discs) {
                        Integer value = discCounts.get(discrepancyNoteBean.getResStatus());
                        if (value != null) {
                            discCounts.put(discrepancyNoteBean.getResStatus(), ++value);
                        } else {
                            discCounts.put(discrepancyNoteBean.getResStatus(), 1);
                        }
                    }
                    d.getProps().put("crf_" + crf.getId() + "_discCounts", discCounts);
                } else {
                    d.getProps().put("crf_" + crf.getId(), DataEntryStage.UNCOMPLETED);
                    d.getProps().put("crf_" + crf.getId() + "_eventCrf", null);
                    d.getProps().put("crf_" + crf.getId() + "_discCounts", discCounts);
                }
                d.getProps().put("crf_" + crf.getId() + "_crf", crf);
                d.getProps().put("crf_" + crf.getId() + "_eventDefinitionCrf", eventDefinitionCrfs.get(i));
                theItem.put("crf_" + crf.getId(), "");
            }
            events.add(d);
        }
        theItem.put("events", events);
        theItem.put("event.status", "");
        theItem.put("event.startDate", "");
        theItems.add(theItem);
    }
    // Do not forget to set the items back on the tableFacade.
    tableFacade.setItems(theItems);
    this.setStudyHasDiscNotes(hasDN);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) ResolutionStatus(org.akaza.openclinica.bean.core.ResolutionStatus) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) ListDiscNotesForCRFSort(org.akaza.openclinica.dao.managestudy.ListDiscNotesForCRFSort) ListDiscNotesForCRFFilter(org.akaza.openclinica.dao.managestudy.ListDiscNotesForCRFFilter) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) SubjectBean(org.akaza.openclinica.bean.submit.SubjectBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) Limit(org.jmesa.limit.Limit)

Example 9 with Limit

use of org.jmesa.limit.Limit in project OpenClinica by OpenClinica.

the class ListNotesTableFactory method setDataAndLimitVariables.

@Override
public void setDataAndLimitVariables(TableFacade tableFacade) {
    // initialize i18n
    resword = ResourceBundleProvider.getWordsBundle(getLocale());
    resformat = ResourceBundleProvider.getFormatBundle(getLocale());
    int parentStudyId = 0;
    Limit limit = tableFacade.getLimit();
    if (!limit.isComplete()) {
        parentStudyId = currentStudy.getId();
        //Build row count of various DN types
        int totalRows = getDiscrepancyNoteDao().getSubjectDNCountWithFilter(getListNoteFilter(limit), parentStudyId);
        totalRows += getDiscrepancyNoteDao().getStudySubjectDNCountWithFilter(getListNoteFilter(limit), parentStudyId);
        totalRows += getDiscrepancyNoteDao().getStudyEventDNCountWithFilter(getListNoteFilter(limit), parentStudyId);
        totalRows += getDiscrepancyNoteDao().getEventCrfDNCountWithFilter(getListNoteFilter(limit), parentStudyId);
        totalRows += getDiscrepancyNoteDao().getItemDataDNCountWithFilter(getListNoteFilter(limit), parentStudyId);
        tableFacade.setTotalRows(totalRows);
    }
    ViewNotesFilterCriteria filter = ViewNotesFilterCriteria.buildFilterCriteria(limit, getDateFormat(), discrepancyNoteTypeDropdown.getDecoder(), resolutionStatusDropdown.getDecoder());
    notesSummary = getViewNotesService().calculateNotesSummary(getCurrentStudy(), filter);
    int pageSize = limit.getRowSelect().getMaxRows();
    int firstRecordShown = (limit.getRowSelect().getPage() - 1) * pageSize;
    if (firstRecordShown > notesSummary.getTotal() && notesSummary.getTotal() != 0) {
        // The page selected goes beyond the dataset size
        // Move to the last page
        limit.getRowSelect().setPage((int) Math.ceil((double) notesSummary.getTotal() / pageSize));
        filter = ViewNotesFilterCriteria.buildFilterCriteria(limit, getDateFormat(), discrepancyNoteTypeDropdown.getDecoder(), resolutionStatusDropdown.getDecoder());
    }
    List<DiscrepancyNoteBean> items = getViewNotesService().listNotes(getCurrentStudy(), filter, ViewNotesSortCriteria.buildFilterCriteria(limit.getSortSet()));
    this.setAllNotes(items);
    Collection<HashMap<Object, Object>> theItems = new ArrayList<HashMap<Object, Object>>();
    for (DiscrepancyNoteBean discrepancyNoteBean : items) {
        HashMap<Object, Object> h = new HashMap<Object, Object>();
        h.put("studySubject", discrepancyNoteBean.getStudySub());
        h.put("studySubject.label", discrepancyNoteBean.getStudySub().getLabel());
        h.put("discrepancyNoteBean.disType", discrepancyNoteBean.getDisType());
        h.put("discrepancyNoteBean.resolutionStatus", discrepancyNoteBean.getResStatus());
        h.put("age", discrepancyNoteBean.getAge());
        h.put("days", discrepancyNoteBean.getDays());
        h.put("siteId", discrepancyNoteBean.getSiteId());
        h.put("discrepancyNoteBean", discrepancyNoteBean);
        h.put("discrepancyNoteBean.createdDate", discrepancyNoteBean.getCreatedDate());
        h.put("discrepancyNoteBean.updatedDate", discrepancyNoteBean.getUpdatedDate());
        h.put("eventName", discrepancyNoteBean.getEventName());
        h.put("eventStartDate", discrepancyNoteBean.getEventStart());
        h.put("crfName", discrepancyNoteBean.getCrfName());
        h.put("crfStatus", discrepancyNoteBean.getCrfStatus());
        h.put("entityName", discrepancyNoteBean.getEntityName());
        h.put("entityValue", discrepancyNoteBean.getEntityValue());
        h.put("discrepancyNoteBean", discrepancyNoteBean);
        h.put("discrepancyNoteBean.description", discrepancyNoteBean.getDescription());
        h.put("discrepancyNoteBean.detailedNotes", discrepancyNoteBean.getDetailedNotes());
        h.put("numberOfNotes", discrepancyNoteBean.getNumChildren());
        h.put("discrepancyNoteBean.user", discrepancyNoteBean.getAssignedUser());
        h.put("discrepancyNoteBean.entityType", discrepancyNoteBean.getEntityType());
        h.put("discrepancyNoteBean.owner", discrepancyNoteBean.getOwner());
        theItems.add(h);
        setStudyHasDiscNotes(true);
    }
    tableFacade.setItems(theItems);
}
Also used : HashMap(java.util.HashMap) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) ViewNotesFilterCriteria(org.akaza.openclinica.service.managestudy.ViewNotesFilterCriteria) ArrayList(java.util.ArrayList) Limit(org.jmesa.limit.Limit)

Example 10 with Limit

use of org.jmesa.limit.Limit in project OpenClinica by OpenClinica.

the class ListStudySubjectTableFactory method setDataAndLimitVariables.

@Override
public void setDataAndLimitVariables(TableFacade tableFacade) {
    Limit limit = tableFacade.getLimit();
    FindSubjectsFilter subjectFilter = getSubjectFilter(limit);
    if (!limit.isComplete()) {
        int totalRows = getStudySubjectDAO().getCountWithFilter(subjectFilter, getStudyBean());
        tableFacade.setTotalRows(totalRows);
    }
    FindSubjectsSort subjectSort = getSubjectSort(limit);
    int rowStart = limit.getRowSelect().getRowStart();
    int rowEnd = limit.getRowSelect().getRowEnd();
    Collection<StudySubjectBean> items = getStudySubjectDAO().getWithFilterAndSort(getStudyBean(), subjectFilter, subjectSort, rowStart, rowEnd);
    Collection<HashMap<Object, Object>> theItems = new ArrayList<HashMap<Object, Object>>();
    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());
        theItem.put("studySubject.oid", studySubjectBean.getOid());
        theItem.put("studySubject.secondaryLabel", studySubjectBean.getSecondaryLabel());
        SubjectBean subjectBean = (SubjectBean) getSubjectDAO().findByPK(studySubjectBean.getSubjectId());
        theItem.put("subject", subjectBean);
        theItem.put("subject.charGender", subjectBean.getGender());
        // 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, studySubjectBean));
        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);
            }
        }
        SubjectGroupMapBean subjectGroupMapBean;
        for (StudyGroupClassBean studyGroupClass : getStudyGroupClasses()) {
            subjectGroupMapBean = getSubjectGroupMapDAO().findAllByStudySubjectAndStudyGroupClass(studySubjectBean.getId(), studyGroupClass.getId());
            if (null != subjectGroupMapBean) {
                theItem.put("sgc_" + studyGroupClass.getId(), subjectGroupMapBean.getStudyGroupId());
                theItem.put("grpName_sgc_" + studyGroupClass.getId(), subjectGroupMapBean.getStudyGroupName());
            }
        }
        subjectGroupMapBean = null;
        for (StudyEventDefinitionBean studyEventDefinition : getStudyEventDefinitions()) {
            List<StudyEventBean> studyEvents = allStudyEventsForStudySubjectBySedId.get(studyEventDefinition.getId());
            SubjectEventStatus subjectEventStatus = null;
            studyEvents = studyEvents == null ? new ArrayList<StudyEventBean>() : studyEvents;
            if (studyEvents.size() < 1) {
                subjectEventStatus = SubjectEventStatus.NOT_SCHEDULED;
            } else {
                for (StudyEventBean studyEventBean : studyEvents) {
                    if (studyEventBean.getSampleOrdinal() == 1) {
                        subjectEventStatus = studyEventBean.getSubjectEventStatus();
                        break;
                    }
                }
            }
            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);
}
Also used : SubjectGroupMapBean(org.akaza.openclinica.bean.submit.SubjectGroupMapBean) FindSubjectsSort(org.akaza.openclinica.dao.managestudy.FindSubjectsSort) 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) SubjectBean(org.akaza.openclinica.bean.submit.SubjectBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyGroupClassBean(org.akaza.openclinica.bean.managestudy.StudyGroupClassBean) List(java.util.List) ArrayList(java.util.ArrayList) Limit(org.jmesa.limit.Limit) FindSubjectsFilter(org.akaza.openclinica.dao.managestudy.FindSubjectsFilter)

Aggregations

Limit (org.jmesa.limit.Limit)24 ArrayList (java.util.ArrayList)14 HashMap (java.util.HashMap)13 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)6 SubjectBean (org.akaza.openclinica.bean.submit.SubjectBean)5 List (java.util.List)4 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)4 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)4 SubjectEventStatus (org.akaza.openclinica.bean.core.SubjectEventStatus)3 DiscrepancyNoteBean (org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean)3 Date (java.util.Date)2 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)2 ResolutionStatus (org.akaza.openclinica.bean.core.ResolutionStatus)2 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)2 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)2 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)2 StudyGroupClassBean (org.akaza.openclinica.bean.managestudy.StudyGroupClassBean)2 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)2 SubjectGroupMapBean (org.akaza.openclinica.bean.submit.SubjectGroupMapBean)2 SubjectSDVContainer (org.akaza.openclinica.controller.helper.table.SubjectSDVContainer)2