Search in sources :

Example 76 with DiscrepancyNoteBean

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

the class DiscrepancyNoteDAO method findExistingNotesForItemData.

public ArrayList findExistingNotesForItemData(int itemDataId) {
    this.setTypesExpected();
    ArrayList alist = new ArrayList();
    HashMap variables = new HashMap();
    variables.put(Integer.valueOf(1), Integer.valueOf(itemDataId));
    alist = this.select(digester.getQuery("findExistingNotesForItemData"), variables);
    ArrayList<DiscrepancyNoteBean> al = new ArrayList<DiscrepancyNoteBean>();
    Iterator it = alist.iterator();
    while (it.hasNext()) {
        HashMap hm = (HashMap) it.next();
        DiscrepancyNoteBean eb = (DiscrepancyNoteBean) this.getEntityFromHashMap(hm);
        al.add(eb);
    }
    return al;
}
Also used : HashMap(java.util.HashMap) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Example 77 with DiscrepancyNoteBean

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

the class DiscrepancyNoteUtil method filterDiscNotesForOnlyParents.

/**
     * Take a List of DiscrepancyNoteBeans, and filter the List to return only
     * "parent" DiscrepancyNoteBeans. the parameter List<DiscrepancyNoteThread>
     * contains each parent the DiscrepancyNoteBeans are compared to in order to
     * filter the original List.
     *
     * @param dnBeans
     *            A List of DiscrepancyNoteBeans.
     * @param dnThreads
     *            A List of DiscrepancyNoteThreads.
     * @return The filtered List of DiscrepancyNoteBeans.
     */
public List<DiscrepancyNoteBean> filterDiscNotesForOnlyParents(List<DiscrepancyNoteBean> dnBeans, List<DiscrepancyNoteThread> dnThreads) {
    // Take the parent of each thread, and compare it to each passed
    // in DiscrepancyNoteBean; only return a DiscrepancyNoteBean if it
    // equals a parent bean
    List<DiscrepancyNoteBean> newBeans = new ArrayList<DiscrepancyNoteBean>();
    DiscrepancyNoteBean tempBean;
    outer: for (DiscrepancyNoteBean noteBean : dnBeans) {
        for (DiscrepancyNoteThread dnThread : dnThreads) {
            // the parent...
            tempBean = dnThread.getLinkedNoteList().getFirst();
            if (tempBean != null) {
                if (tempBean.getId() == noteBean.getId()) {
                    newBeans.add(noteBean);
                    // next noteBean
                    continue outer;
                }
            }
        }
    }
    return newBeans;
}
Also used : DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) ArrayList(java.util.ArrayList)

Example 78 with DiscrepancyNoteBean

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

the class DiscrepancyNoteUtil method injectParentDiscNotesIntoDisplayStudyEvents.

public void injectParentDiscNotesIntoDisplayStudyEvents(List<DisplayStudyEventBean> displayStudyBeans, Set<Integer> resolutionStatusIds, DataSource dataSource, int discNoteType) {
    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.findParentItemDataDNotesFromEventCRF(eventCrfBean);
            // 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);
                            }
                        }
                    }
                }
            }
        }
    // 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 79 with DiscrepancyNoteBean

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

the class DiscrepancyNoteUtil method injectDiscNotesIntoStudyEvents.

/**
     * This method links discrepancy notes to the study event and study subject
     * associated with those notes
     *
     * @param studyBeans
     *            A List of StudyEventBeans.
     * @param allDiscNotes
     *            A List of DiscrepancyNoteBeans associated with a single study.
     * @param dataSource
     *            A DataSource used to get from the database a study subject
     *            associated with a study event.
     */
public void injectDiscNotesIntoStudyEvents(List<StudyEventBean> studyBeans, List<DiscrepancyNoteBean> allDiscNotes, DataSource dataSource) {
    if (studyBeans == null || allDiscNotes == null) {
        return;
    }
    StudySubjectDAO studySubjDAO = new StudySubjectDAO(dataSource);
    StudySubjectBean studySubjBean = new StudySubjectBean();
    for (StudyEventBean sbean : studyBeans) {
        // Get the StudySubjectBean associated with the study event
        studySubjBean = (StudySubjectBean) studySubjDAO.findByPK(sbean.getStudySubjectId());
        // equals the StudySubjectBean's name
        for (DiscrepancyNoteBean discBean : allDiscNotes) {
            if (sbean.getStudyEventDefinition().getName().equalsIgnoreCase(discBean.getEventName()) && studySubjBean.getLabel().equalsIgnoreCase(discBean.getSubjectName())) {
                // add discrepancy note to the study event list of notes
                // Each study bean has a List property containing its
                // associated
                // DiscrepancyNoteBeans
                sbean.getDiscBeanList().add(discBean);
            }
        }
    }
}
Also used : StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) DisplayStudyEventBean(org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO)

Example 80 with DiscrepancyNoteBean

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

the class DiscrepancyNoteUtil method updateStatusOfParents.

/**
     * Take a List of "parent" DiscrepancyNoteBeans and if they have any
     * "children," make sure that the resolution status id of the parent matches
     * that of the last child DiscrepancyNoteBean.
     *
     * @param allDiscNotes
     *            A List of DiscrepancyNoteBeans.
     * @param dataSource
     *            The DataSource the DAO uses.
     * @param currentStudy
     *            A StudyBean representing the current study.
     */
public void updateStatusOfParents(List<DiscrepancyNoteBean> allDiscNotes, DataSource dataSource, StudyBean currentStudy) {
    if (allDiscNotes == null || allDiscNotes.isEmpty()) {
        return;
    }
    List<DiscrepancyNoteBean> childDiscBeans = new ArrayList<DiscrepancyNoteBean>();
    DiscrepancyNoteDAO discrepancyNoteDAO = new DiscrepancyNoteDAO(dataSource);
    DiscrepancyNoteBean lastChild = new DiscrepancyNoteBean();
    int resolutionStatusId = 0;
    for (DiscrepancyNoteBean discBean : allDiscNotes) {
        childDiscBeans = discrepancyNoteDAO.findAllByStudyAndParent(currentStudy, discBean.getId());
        if (!childDiscBeans.isEmpty()) {
            lastChild = childDiscBeans.get(childDiscBeans.size() - 1);
            resolutionStatusId = lastChild.getResolutionStatusId();
            if (discBean.getResolutionStatusId() != resolutionStatusId) {
                discBean.setResolutionStatusId(resolutionStatusId);
            }
        }
        // clear the List for the next iteration
        if (childDiscBeans != null) {
            childDiscBeans.clear();
        }
    }
}
Also used : DiscrepancyNoteDAO(org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) 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