Search in sources :

Example 26 with DiscrepancyNoteBean

use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.

the class DiscrepancyNoteUtil method getDNotesForStudyAsThreads.

public List<DiscrepancyNoteThread> getDNotesForStudyAsThreads(StudyBean currentStudy, Set<Integer> resolutionStatusIds, DataSource dataSource, int discNoteType) {
    List<DiscrepancyNoteBean> allDiscNotes = new ArrayList<DiscrepancyNoteBean>();
    List<DiscrepancyNoteThread> threadedNotes = new ArrayList<DiscrepancyNoteThread>();
    if (currentStudy == null)
        return threadedNotes;
    // Do the returned DN's have to be filtered? A valid resolution status
    // has to be between 1 and 5; 0 is "invalid";
    // -1 means that no resolutionStatus parameter was passed into the
    // servlet
    boolean filterDiscNotes = checkResolutionStatus(resolutionStatusIds);
    boolean filterforDiscNoteType = discNoteType >= 1 && discNoteType <= 4;
    DiscrepancyNoteDAO discrepancyNoteDAO = new DiscrepancyNoteDAO(dataSource);
    // what is the purpose of this data member?
    discrepancyNoteDAO.setFetchMapping(true);
    // method finds only parents
    ArrayList itemDataNotes = discrepancyNoteDAO.findAllItemDataByStudy(currentStudy);
    // ArrayList eventCRFNotes =
    // discrepancyNoteDAO.findAllEventCRFByStudy(currentStudy);
    allDiscNotes.addAll(itemDataNotes);
    // not doing this for now allDiscNotes.addAll(eventCRFNotes);
    // make sure that any "parent" notes have the last resolution status of
    // any
    // of their child notes
    updateStatusOfParents(allDiscNotes, dataSource, currentStudy);
    if (filterDiscNotes) {
        // filter for the resolution status
        allDiscNotes = filterDiscNotes(allDiscNotes, resolutionStatusIds);
    }
    if (filterforDiscNoteType) {
        // filter for the ddiscrepancyNoteTypeId
        allDiscNotes = filterforDiscNoteType(allDiscNotes, discNoteType);
    }
    // convert or encapsulate List of notes in List of disc note thread
    // objects
    threadedNotes = createThreadsOfParents(allDiscNotes, dataSource, currentStudy, null, 0, false);
    return threadedNotes;
}
Also used : DiscrepancyNoteDAO(org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) ArrayList(java.util.ArrayList)

Example 27 with DiscrepancyNoteBean

use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.

the class DiscrepancyNoteUtil method getThreadedDNotesForStudy.

/**
     * Get all discrepancy notes for a study, including "threads" of parent and
     * child discrepancy notes.
     *
     * @param currentStudy
     *            A StudyBean object.
     * @param resolutionStatusIds
     *            A HashSet object consisting of resolution status ids (i.e.,
     *            1,2,3).
     * @param dataSource
     *            A DataSource used for various DAO methods.
     * @param discNoteType
     *            An int discrepancy note type id; only DiscrepancyNoteBeans
     *            will be returned if they have this discrepancyNoteTypeId.
     * @param updateStatusOfParents
     * @return A List of DiscrepancyNoteBeans.
     */
public List<DiscrepancyNoteBean> getThreadedDNotesForStudy(StudyBean currentStudy, Set<Integer> resolutionStatusIds, DataSource dataSource, int discNoteType, boolean updateStatusOfParents) {
    List<DiscrepancyNoteBean> allDiscNotes = new ArrayList<DiscrepancyNoteBean>();
    if (currentStudy == null)
        return allDiscNotes;
    // Do the returned DN's have to be filtered? A valid resolution status
    // has to be between 1 and 5; 0 is "invalid";
    // -1 means that no resolutionStatus parameter was passed into the
    // servlet
    boolean filterDiscNotes = checkResolutionStatus(resolutionStatusIds);
    boolean filterforDiscNoteType = discNoteType >= 1 && discNoteType <= 4;
    DiscrepancyNoteDAO discrepancyNoteDAO = new DiscrepancyNoteDAO(dataSource);
    StudyDAO studyDAO = new StudyDAO(dataSource);
    // what is the purpose of this data member?
    discrepancyNoteDAO.setFetchMapping(true);
    int parentStudyId = currentStudy.getParentStudyId();
    Set<String> hiddenCrfNames = new TreeSet<String>();
    if (parentStudyId > 0) {
        hiddenCrfNames = new EventDefinitionCRFDAO(dataSource).findHiddenCrfNamesBySite(currentStudy);
    }
    allDiscNotes = discrepancyNoteDAO.findAllDiscrepancyNotesDataByStudy(currentStudy);
    if (filterDiscNotes) {
        // filter for the resolution status
        allDiscNotes = filterDiscNotes(allDiscNotes, resolutionStatusIds);
    }
    if (filterforDiscNoteType) {
        // filter for the ddiscrepancyNoteTypeId
        allDiscNotes = filterforDiscNoteType(allDiscNotes, discNoteType);
    }
    return allDiscNotes;
}
Also used : DiscrepancyNoteDAO(org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 28 with DiscrepancyNoteBean

use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.

the class DiscrepancyNoteUtil method filterDiscNotesBySubject.

/**
     * Filter a List of DiscrepancyNoteBeans by subject id.
     *
     * @param allDiscNotes
     *            A List of DiscrepancyNoteBeans prior to filtering.
     * @param subjectId
     *            An int subject id.
     * @param dataSource
     *            A DataSource object used by DAO methods.
     * @return The filtered List of DiscrepancyNoteBeans.
     */
public List<DiscrepancyNoteBean> filterDiscNotesBySubject(List<DiscrepancyNoteBean> allDiscNotes, int subjectId, DataSource dataSource) {
    // Do not filter this List if the subjectId < 1
    if (!(subjectId >= 1)) {
        return allDiscNotes;
    }
    StudySubjectDAO studySubjDAO = new StudySubjectDAO(dataSource);
    StudySubjectBean studySubjBean = new StudySubjectBean();
    studySubjBean = (StudySubjectBean) studySubjDAO.findByPK(subjectId);
    List<DiscrepancyNoteBean> newDiscNotes = new ArrayList<DiscrepancyNoteBean>();
    for (DiscrepancyNoteBean dnBean : allDiscNotes) {
        if (dnBean.getSubjectName().equalsIgnoreCase(studySubjBean.getLabel())) {
            newDiscNotes.add(dnBean);
        }
    }
    return newDiscNotes;
}
Also used : StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) ArrayList(java.util.ArrayList) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO)

Example 29 with DiscrepancyNoteBean

use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.

the class DiscrepancyNoteUtil method getDiscNoteCountFromDisplayEvents.

private Map<String, Integer> getDiscNoteCountFromDisplayEvents(List<DisplayStudyEventBean> disBeans, int eventCRFId) {
    Map<String, Integer> discNoteMap = new HashMap<String, Integer>();
    if (eventCRFId == 0 || disBeans == null) {
        return discNoteMap;
    }
    List<DiscrepancyNoteBean> dnBeans;
    for (DisplayStudyEventBean eventBean : disBeans) {
        dnBeans = eventBean.getStudyEvent().getDiscBeanList();
        for (String statusName : RESOLUTION_STATUS.keySet()) {
            discNoteMap.put(statusName, getDiscNoteCountByStatusEventCRFId(dnBeans, RESOLUTION_STATUS.get(statusName), eventCRFId));
        }
    }
    return discNoteMap;
}
Also used : DisplayStudyEventBean(org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean) HashMap(java.util.HashMap) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean)

Example 30 with DiscrepancyNoteBean

use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.

the class DiscrepancyNoteUtil method createThreads.

public List<DiscrepancyNoteThread> createThreads(List<DiscrepancyNoteBean> allDiscNotes, DataSource dataSource, StudyBean currentStudy) {
    List<DiscrepancyNoteThread> dnThreads = new ArrayList<DiscrepancyNoteThread>();
    if (allDiscNotes == null || allDiscNotes.isEmpty()) {
        return dnThreads;
    }
    if (currentStudy == null) {
        currentStudy = new StudyBean();
    }
    List<DiscrepancyNoteBean> childDiscBeans = new ArrayList<DiscrepancyNoteBean>();
    List<DiscrepancyNoteBean> eventCRFChildDiscBeans = new ArrayList<DiscrepancyNoteBean>();
    DiscrepancyNoteDAO discrepancyNoteDAO = new DiscrepancyNoteDAO(dataSource);
    DiscrepancyNoteThread tempDNThread = null;
    int resolutionStatusId = 0;
    for (DiscrepancyNoteBean discBean : allDiscNotes) {
        tempDNThread = new DiscrepancyNoteThread();
        tempDNThread.setStudyId(currentStudy.getId());
        tempDNThread.getLinkedNoteList().addFirst(discBean);
        // childDiscBeans should be empty here
        if (!childDiscBeans.isEmpty()) {
            childDiscBeans.clear();
        }
        childDiscBeans = discBean.getChildren();
        Collections.sort(childDiscBeans);
        resolutionStatusId = discBean.getResolutionStatusId();
        // the thread's status id is the parent's in this case, when there
        // are no children
        tempDNThread.setLatestResolutionStatus(this.getResolutionStatusName(resolutionStatusId));
        if (!childDiscBeans.isEmpty()) {
            for (DiscrepancyNoteBean childBean : childDiscBeans) {
                /*
                    if (childBean.getResolutionStatusId() != resolutionStatusId) {
                        // BWP issue 3468 WHO 5/2009: this local variable needs
                        // to be updated>>
                        resolutionStatusId = childBean.getResolutionStatusId();
                        // <<
                        tempDNThread.setLatestResolutionStatus(this.getResolutionStatusName(childBean.getResolutionStatusId()));
                    }
                    */
                tempDNThread.getLinkedNoteList().offer(childBean);
            }
        }
        dnThreads.add(tempDNThread);
    }
    /*
                // Do the filtering here; remove any DN threads that do not have any
                // notes
                LinkedList<DiscrepancyNoteBean> linkedList = null;

                if (resolutionStatusIds != null && !resolutionStatusIds.isEmpty()) {

                    for (DiscrepancyNoteThread dnThread : dnThreads) {
                        linkedList = new LinkedList<DiscrepancyNoteBean>();
                        for (DiscrepancyNoteBean discBean : dnThread.getLinkedNoteList()) {
                            for (int statusId : resolutionStatusIds) {
                                if (discBean.getResolutionStatusId() == statusId) {
                                    linkedList.offer(discBean);
                                }
                            }
                        }
                        dnThread.setLinkedNoteList(linkedList);
                    }
                    dnThreads = removeEmptyDNThreads(dnThreads);
                }
                if (discNoteType >= 1 && discNoteType <= 5) {

                    for (DiscrepancyNoteThread dnThread : dnThreads) {
                        linkedList = new LinkedList<DiscrepancyNoteBean>();
                        for (DiscrepancyNoteBean discBean : dnThread.getLinkedNoteList()) {
                            if (discBean.getDiscrepancyNoteTypeId() == discNoteType) {
                                linkedList.offer(discBean);
                            }
                        }
                        dnThread.setLinkedNoteList(linkedList);
                    }
                    dnThreads = removeEmptyDNThreads(dnThreads);
                }
        */
    return dnThreads;
}
Also used : DiscrepancyNoteDAO(org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList)

Aggregations

DiscrepancyNoteBean (org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean)122 ArrayList (java.util.ArrayList)81 HashMap (java.util.HashMap)62 Iterator (java.util.Iterator)44 DiscrepancyNoteDAO (org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO)34 Date (java.util.Date)20 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)20 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)20 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)20 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)18 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)18 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)15 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)14 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)14 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)13 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)11 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)11 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)11 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)10 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)10