Search in sources :

Example 1 with DiscrepancyNoteDAO

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

the class DiscrepancyNoteUtil method injectDiscNotesIntoDisplayStudyEvents.

/**
     * This method is an overloaded version of the previous method, with the
     * only difference being the resolutionStatusIds parameter in this method.
     * This method adds the associated discrepancy notes to the appropriate
     * StudyEventBean (contained by DisplayStudyBeans).
     *
     * @param displayStudyBeans
     *            A List of DisplayStudyEventBeans.
     * @param resolutionStatusIds
     *            A HashSet object consisting of resolution status ids (i.e.,
     *            1,2,3).
     * @param dataSource
     *            A DataSource object, for use with the DAO methods.
     * @param discNoteType
     *            An int discrepancy note type, for filtering the discrepancy
     *            notes that
     * @param discrepancyNoteThreads
     *            A List of DiscrepancyNoteThreads
     */
public void injectDiscNotesIntoDisplayStudyEvents(List<DisplayStudyEventBean> displayStudyBeans, Set<Integer> resolutionStatusIds, DataSource dataSource, int discNoteType, List<DiscrepancyNoteThread> discrepancyNoteThreads) {
    if (displayStudyBeans == null) {
        return;
    }
    // booleans representing whether this method should only get
    // DiscrepancyNoteBeans with
    // certain resolution status or discrepancyNoteTypeId number.
    boolean hasResolutionStatus = this.checkResolutionStatus(resolutionStatusIds);
    boolean hasDiscNoteType = discNoteType >= 1 && discNoteType <= 4;
    EventCRFDAO eventCRFDAO = new EventCRFDAO(dataSource);
    DiscrepancyNoteDAO discrepancyNoteDAO = new DiscrepancyNoteDAO(dataSource);
    StudyEventBean studyEventBean;
    List<EventCRFBean> eventCRFBeans = new ArrayList<EventCRFBean>();
    List<DiscrepancyNoteBean> foundDiscNotes = new ArrayList<DiscrepancyNoteBean>();
    for (DisplayStudyEventBean dStudyEventBean : displayStudyBeans) {
        studyEventBean = dStudyEventBean.getStudyEvent();
        // All EventCRFs for a study event
        eventCRFBeans = eventCRFDAO.findAllByStudyEvent(studyEventBean);
        for (EventCRFBean eventCrfBean : eventCRFBeans) {
            // Find ItemData type notes associated with an event crf
            foundDiscNotes = discrepancyNoteDAO.findItemDataDNotesFromEventCRF(eventCrfBean);
            // return only parent beans
            foundDiscNotes = filterDiscNotesForOnlyParents(foundDiscNotes, discrepancyNoteThreads);
            // update the resolution status of these parent discrepancy
            // notes
            updateStatusUsingThread(foundDiscNotes, discrepancyNoteThreads);
            // filter for any specified disc note type
            if (!foundDiscNotes.isEmpty() && hasDiscNoteType) {
                // only include disc notes that have the specified disc note
                // type id
                foundDiscNotes = filterforDiscNoteType(foundDiscNotes, discNoteType);
            }
            if (!foundDiscNotes.isEmpty()) {
                if (!hasResolutionStatus) {
                    studyEventBean.getDiscBeanList().addAll(foundDiscNotes);
                } else {
                    // session variable
                    for (DiscrepancyNoteBean discBean : foundDiscNotes) {
                        for (int statusId : resolutionStatusIds) {
                            if (discBean.getResolutionStatusId() == statusId) {
                                studyEventBean.getDiscBeanList().add(discBean);
                            }
                        }
                    }
                }
            }
        // 3014: Not for now; Find EventCRF type notes
        /*
                 * foundDiscNotes =
                 * discrepancyNoteDAO.findEventCRFDNotesFromEventCRF(eventCrfBean);
                 * //filter for any specified disc note type if((!
                 * foundDiscNotes.isEmpty()) && hasDiscNoteType){ foundDiscNotes =
                 * filterforDiscNoteType(foundDiscNotes,discNoteType); }
                 *
                 * if(! foundDiscNotes.isEmpty()){ if(! hasResolutionStatus) {
                 * studyEventBean.getDiscBeanList().addAll(foundDiscNotes); }
                 * else { //Only include disc notes with a particular resolution
                 * status, specified by //the parameter passed to the servlet
                 * for(DiscrepancyNoteBean discBean : foundDiscNotes) { for(int
                 * statusId : resolutionStatusIds){
                 * if(discBean.getResolutionStatusId() == statusId){
                 * studyEventBean.getDiscBeanList().add(discBean); } } } } }
                 */
        // end if(! foundDiscNotes.isEmpty()){
        }
    // end for(EventCRFBean...
    }
// end for (DisplayStudyEventBean
}
Also used : DiscrepancyNoteDAO(org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) DisplayStudyEventBean(org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) ArrayList(java.util.ArrayList) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) DisplayStudyEventBean(org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO)

Example 2 with DiscrepancyNoteDAO

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

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

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

Example 5 with DiscrepancyNoteDAO

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

the class DiscrepancyNoteUtil method createThreadsOfParents.

public List<DiscrepancyNoteThread> createThreadsOfParents(List<DiscrepancyNoteBean> allDiscNotes, DataSource dataSource, StudyBean currentStudy, Set<Integer> resolutionStatusIds, int discNoteType, boolean includeEventCRFNotes) {
    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 = discrepancyNoteDAO.findAllItemDataByStudyAndParent(currentStudy, discBean);
        if (includeEventCRFNotes) {
            eventCRFChildDiscBeans = discrepancyNoteDAO.findAllEventCRFByStudyAndParent(currentStudy, discBean);
        }
        if (!eventCRFChildDiscBeans.isEmpty()) {
            childDiscBeans.addAll(eventCRFChildDiscBeans);
            // sort the discnote beans, because we have eventCRF and
            // ItemDate types mixed here.
            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

DiscrepancyNoteDAO (org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO)44 DiscrepancyNoteBean (org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean)34 ArrayList (java.util.ArrayList)32 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)22 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)20 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)19 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)18 Date (java.util.Date)17 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)17 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)17 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)17 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)17 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)16 HashMap (java.util.HashMap)14 FormDiscrepancyNotes (org.akaza.openclinica.control.form.FormDiscrepancyNotes)13 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)13 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)11 SubjectDAO (org.akaza.openclinica.dao.submit.SubjectDAO)11 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)10 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)10