Search in sources :

Example 31 with DiscrepancyNoteBean

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

Example 32 with DiscrepancyNoteBean

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

the class DiscrepancyNoteUtil method injectDiscNotesIntoDisplayStudyEvents.

/**
     * Add associated discrepancy notes to the appropriate StudyEventBean
     * (contained by DisplayStudyBeans). A StudyEventBean has a List of
     * DiscrepancyNoteBeans.
     *
     * @param displayStudyBeans
     *            A List of DisplayStudyEventBeans
     * @param resolutionStatus
     *            An int representing the resolution status, if we are filtering
     *            the DiscrepancyNoteBeans based on their resolutionStatus id
     *            number.
     * @param dataSource
     *            A DataSource used for the DAO methods.
     * @param discNoteType
     *            An int representing the discrepancy note type, if we are
     *            filtering the DiscrepancyNoteBeans based on their
     *            discrepancyNoteTypeId number.
     */
public void injectDiscNotesIntoDisplayStudyEvents(List<DisplayStudyEventBean> displayStudyBeans, int resolutionStatus, 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 = resolutionStatus >= 1 && resolutionStatus <= 5;
    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 iwth an event crf
            foundDiscNotes = discrepancyNoteDAO.findItemDataDNotesFromEventCRF(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 {
                    // the parameter passed to the servlet
                    for (DiscrepancyNoteBean discBean : foundDiscNotes) {
                        if (discBean.getResolutionStatusId() == resolutionStatus) {
                            studyEventBean.getDiscBeanList().add(discBean);
                        }
                    }
                }
            }
            // 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 {
                    // the parameter passed to the servlet
                    for (DiscrepancyNoteBean discBean : foundDiscNotes) {
                        if (discBean.getResolutionStatusId() == resolutionStatus) {
                            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 33 with DiscrepancyNoteBean

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

the class DiscrepancyNoteService method saveFieldNotes.

public void saveFieldNotes(String description, int entityId, String entityType, StudyBean sb, UserAccountBean ub) {
    // Create a new thread each time
    DiscrepancyNoteBean parent = createDiscrepancyNoteBean(description, entityId, entityType, sb, ub, null);
    createDiscrepancyNoteBean(description, entityId, entityType, sb, ub, parent.getId());
}
Also used : DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean)

Example 34 with DiscrepancyNoteBean

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

the class DiscrepancyNoteService method createDiscrepancyNoteBean.

private DiscrepancyNoteBean createDiscrepancyNoteBean(String description, int entityId, String entityType, StudyBean sb, UserAccountBean ub, Integer parentId) {
    DiscrepancyNoteBean dnb = new DiscrepancyNoteBean();
    dnb.setEntityId(entityId);
    dnb.setStudyId(sb.getId());
    dnb.setEntityType(entityType);
    dnb.setDescription(description);
    dnb.setDiscrepancyNoteTypeId(1);
    dnb.setResolutionStatusId(1);
    dnb.setColumn("value");
    dnb.setOwner(ub);
    if (parentId != null) {
        dnb.setParentDnId(parentId);
    }
    dnb = (DiscrepancyNoteBean) getDiscrepancyNoteDao().create(dnb);
    getDiscrepancyNoteDao().createMapping(dnb);
    return dnb;
}
Also used : DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean)

Example 35 with DiscrepancyNoteBean

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

the class DeleteEventCRFServlet method createDiscrepancyNoteBean.

private void createDiscrepancyNoteBean(String description, String detailedNotes, int itemDataId, StudyBean studyBean, UserAccountBean ub, DiscrepancyNoteBean parentDiscrepancyNote) {
    DiscrepancyNoteBean dnb = new DiscrepancyNoteBean();
    // this is needed for DN Map object
    dnb.setEntityId(itemDataId);
    dnb.setStudyId(studyBean.getId());
    dnb.setEntityType(DiscrepancyNoteBean.ITEM_DATA);
    dnb.setDescription(description);
    dnb.setDetailedNotes(detailedNotes);
    // set to parent DN Type Id
    dnb.setDiscrepancyNoteTypeId(parentDiscrepancyNote.getDiscrepancyNoteTypeId());
    // set to closed
    dnb.setResolutionStatusId(4);
    // this is needed for DN Map object
    dnb.setColumn("value");
    dnb.setAssignedUserId(ub.getId());
    dnb.setOwner(ub);
    dnb.setParentDnId(parentDiscrepancyNote.getId());
    dnb.setActivated(false);
    // create child DN
    dnb = (DiscrepancyNoteBean) getDnDao().create(dnb);
    // create DN mapping
    getDnDao().createMapping(dnb);
    DiscrepancyNoteBean itemParentNote = (DiscrepancyNoteBean) getDnDao().findByPK(dnb.getParentDnId());
    itemParentNote.setResolutionStatusId(ResolutionStatus.CLOSED.getId());
    itemParentNote.setAssignedUserId(ub.getId());
    itemParentNote.setOwner(ub);
    // update parent DN
    getDnDao().update(itemParentNote);
    // update parent DN assigned user
    getDnDao().updateAssignedUser(itemParentNote);
}
Also used : DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean)

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