Search in sources :

Example 1 with ListEventsForSubjectSort

use of org.akaza.openclinica.dao.managestudy.ListEventsForSubjectSort in project OpenClinica by OpenClinica.

the class ListEventsForSubjectTableFactory method getListEventsForSubjectSort.

protected ListEventsForSubjectSort getListEventsForSubjectSort(Limit limit) {
    ListEventsForSubjectSort listEventsForSubjectSort = new ListEventsForSubjectSort();
    SortSet sortSet = limit.getSortSet();
    Collection<Sort> sorts = sortSet.getSorts();
    for (Sort sort : sorts) {
        String property = sort.getProperty();
        String order = sort.getOrder().toParam();
        listEventsForSubjectSort.addSort(property, order);
    }
    return listEventsForSubjectSort;
}
Also used : ListEventsForSubjectSort(org.akaza.openclinica.dao.managestudy.ListEventsForSubjectSort) Sort(org.jmesa.limit.Sort) ListEventsForSubjectSort(org.akaza.openclinica.dao.managestudy.ListEventsForSubjectSort) SortSet(org.jmesa.limit.SortSet)

Example 2 with ListEventsForSubjectSort

use of org.akaza.openclinica.dao.managestudy.ListEventsForSubjectSort in project OpenClinica by OpenClinica.

the class ListEventsForSubjectTableFactory method setDataAndLimitVariables.

@SuppressWarnings("unchecked")
@Override
public void setDataAndLimitVariables(TableFacade tableFacade) {
    Limit limit = tableFacade.getLimit();
    ListEventsForSubjectFilter eventsForSubjectFilter = getListEventsForSubjectFilter(limit);
    // Used on Initial sort without filters
    if (!limit.isComplete()) {
        int totalRows = getStudySubjectDAO().getCountWithFilter(eventsForSubjectFilter, getStudyBean());
        tableFacade.setTotalRows(totalRows);
    }
    // Preprocess the studysubjectbean list to find subjects with crf status
    ListEventsForSubjectSort eventsForSubjectSort = getListEventsForSubjectSort(limit);
    int rowStart = limit.getRowSelect().getRowStart();
    int rowEnd = limit.getRowSelect().getRowEnd();
    Collection<StudySubjectBean> items = getStudySubjectDAO().getWithFilterAndSort(getStudyBean(), eventsForSubjectFilter, eventsForSubjectSort, 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());
        SubjectBean subjectBean = (SubjectBean) getSubjectDAO().findByPK(studySubjectBean.getSubjectId());
        theItem.put("subject", subjectBean);
        theItem.put("subject.charGender", subjectBean.getGender());
        // study group classes
        SubjectGroupMapBean subjectGroupMapBean = new 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;
        HashMap<String, EventCRFBean> crfAsKeyEventCrfAsValue = getEventsCrfsForStudySubject(studySubjectBean);
        // 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("studySubject.createdDate", null);
            for (int i = 0; i < getCrfs(selectedStudyEventDefinition).size(); i++) {
                CRFBean crf = getCrfs(selectedStudyEventDefinition).get(i);
                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() + "_eventDefinitionCrf", getEventDefinitionCRFBean(selectedStudyEventDefinition.getId(), crf, studySubjectBean));
                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("studySubject.createdDate", studyEventBean.getDateStarted());
            for (int i = 0; i < getCrfs(selectedStudyEventDefinition).size(); i++) {
                CRFBean crf = getCrfs(selectedStudyEventDefinition).get(i);
                EventCRFBean eventCRFBean = crfAsKeyEventCrfAsValue.get(crf.getId() + "_" + studyEventBean.getId());
                if (eventCRFBean != null) {
                    d.getProps().put("crf_" + crf.getId(), eventCRFBean.getStage());
                    d.getProps().put("crf_" + crf.getId() + "_eventCrf", eventCRFBean);
                } else {
                    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() + "_eventDefinitionCrf", getEventDefinitionCRFBean(selectedStudyEventDefinition.getId(), crf, studySubjectBean));
                theItem.put("crf_" + crf.getId(), "");
            }
            events.add(d);
        }
        theItem.put("events", events);
        theItem.put("event.status", "");
        theItem.put("studySubject.createdDate", "");
        theItem.put("webappContext", tableFacade.getWebContext().getContextPath());
        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) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ListEventsForSubjectSort(org.akaza.openclinica.dao.managestudy.ListEventsForSubjectSort) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) 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) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) ListEventsForSubjectFilter(org.akaza.openclinica.dao.managestudy.ListEventsForSubjectFilter) StudyGroupClassBean(org.akaza.openclinica.bean.managestudy.StudyGroupClassBean) Limit(org.jmesa.limit.Limit)

Aggregations

ListEventsForSubjectSort (org.akaza.openclinica.dao.managestudy.ListEventsForSubjectSort)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)1 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)1 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)1 StudyGroupClassBean (org.akaza.openclinica.bean.managestudy.StudyGroupClassBean)1 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)1 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)1 SubjectBean (org.akaza.openclinica.bean.submit.SubjectBean)1 SubjectGroupMapBean (org.akaza.openclinica.bean.submit.SubjectGroupMapBean)1 ListEventsForSubjectFilter (org.akaza.openclinica.dao.managestudy.ListEventsForSubjectFilter)1 Limit (org.jmesa.limit.Limit)1 Sort (org.jmesa.limit.Sort)1 SortSet (org.jmesa.limit.SortSet)1