Search in sources :

Example 1 with ListDiscNotesSubjectSort

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

the class DiscNotesSubjectStatisticsFactory method getSubjectSort.

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

Example 2 with ListDiscNotesSubjectSort

use of org.akaza.openclinica.dao.managestudy.ListDiscNotesSubjectSort 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 3 with ListDiscNotesSubjectSort

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

the class ListDiscNotesSubjectTableFactory method getSubjectSort.

/**
     * A very custom way to sort the items. The PresidentSort acts as a command
     * for the Hibernate criteria object. There are probably many ways to do
     * this, but this is the most flexible way I have found. The point is you
     * need to somehow take the Limit information and sort the rows.
     *
     * @param limit
     *            The Limit to use.
     */
protected ListDiscNotesSubjectSort getSubjectSort(Limit limit) {
    ListDiscNotesSubjectSort listDiscNotesSubjectSort = new ListDiscNotesSubjectSort();
    SortSet sortSet = limit.getSortSet();
    Collection<Sort> sorts = sortSet.getSorts();
    for (Sort sort : sorts) {
        String property = sort.getProperty();
        String order = sort.getOrder().toParam();
        listDiscNotesSubjectSort.addSort(property, order);
    }
    return listDiscNotesSubjectSort;
}
Also used : ListDiscNotesSubjectSort(org.akaza.openclinica.dao.managestudy.ListDiscNotesSubjectSort) Sort(org.jmesa.limit.Sort) ListDiscNotesSubjectSort(org.akaza.openclinica.dao.managestudy.ListDiscNotesSubjectSort) SortSet(org.jmesa.limit.SortSet)

Example 4 with ListDiscNotesSubjectSort

use of org.akaza.openclinica.dao.managestudy.ListDiscNotesSubjectSort 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)

Aggregations

ListDiscNotesSubjectSort (org.akaza.openclinica.dao.managestudy.ListDiscNotesSubjectSort)4 SortSet (org.jmesa.limit.SortSet)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)2 ListDiscNotesSubjectFilter (org.akaza.openclinica.dao.managestudy.ListDiscNotesSubjectFilter)2 Limit (org.jmesa.limit.Limit)2 Sort (org.jmesa.limit.Sort)2 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 ResolutionStatus (org.akaza.openclinica.bean.core.ResolutionStatus)1 SubjectEventStatus (org.akaza.openclinica.bean.core.SubjectEventStatus)1 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)1 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)1 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)1 FilterSet (org.jmesa.limit.FilterSet)1