Search in sources :

Example 1 with EventDefinitionCRFDAO

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

the class SignStudySubjectServlet method getDisplayStudyEventsForStudySubject.

public static ArrayList getDisplayStudyEventsForStudySubject(StudyBean study, StudySubjectBean studySub, DataSource ds, UserAccountBean ub, StudyUserRoleBean currentRole) {
    StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(ds);
    StudyEventDAO sedao = new StudyEventDAO(ds);
    EventCRFDAO ecdao = new EventCRFDAO(ds);
    EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(ds);
    StudySubjectDAO ssdao = new StudySubjectDAO(ds);
    ArrayList events = sedao.findAllByStudySubject(studySub);
    ArrayList displayEvents = new ArrayList();
    for (int i = 0; i < events.size(); i++) {
        StudyEventBean event = (StudyEventBean) events.get(i);
        StudyEventDefinitionBean sed = (StudyEventDefinitionBean) seddao.findByPK(event.getStudyEventDefinitionId());
        event.setStudyEventDefinition(sed);
        // find all active crfs in the definition
        ArrayList eventDefinitionCRFs = (ArrayList) edcdao.findAllActiveByEventDefinitionId(study, sed.getId());
        ArrayList eventCRFs = ecdao.findAllByStudyEvent(event);
        // construct info needed on view study event page
        DisplayStudyEventBean de = new DisplayStudyEventBean();
        de.setStudyEvent(event);
        de.setDisplayEventCRFs(getDisplayEventCRFs(study, ds, eventCRFs, ub, currentRole, event.getSubjectEventStatus()));
        ArrayList al = getUncompletedCRFs(ds, eventDefinitionCRFs, eventCRFs, event.getSubjectEventStatus());
        populateUncompletedCRFsWithCRFAndVersions(ds, al);
        de.setUncompletedCRFs(al);
        StudySubjectBean studySubject = (StudySubjectBean) ssdao.findByPK(event.getStudySubjectId());
        de.setMaximumSampleOrdinal(sedao.getMaxSampleOrdinal(sed, studySubject));
        displayEvents.add(de);
    // event.setEventCRFs(createAllEventCRFs(eventCRFs,
    // eventDefinitionCRFs));
    }
    return displayEvents;
}
Also used : DisplayStudyEventBean(org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) DisplayStudyEventBean(org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO)

Example 2 with EventDefinitionCRFDAO

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

the class SignStudySubjectServlet method processRequest.

@Override
public void processRequest() throws Exception {
    SubjectDAO sdao = new SubjectDAO(sm.getDataSource());
    StudySubjectDAO subdao = new StudySubjectDAO(sm.getDataSource());
    FormProcessor fp = new FormProcessor(request);
    String action = fp.getString("action");
    // studySubjectId
    int studySubId = fp.getInt("id", true);
    String module = fp.getString(MODULE);
    request.setAttribute(MODULE, module);
    if (studySubId == 0) {
        addPageMessage(respage.getString("please_choose_a_subject_to_view"));
        forwardPage(Page.LIST_STUDY_SUBJECTS);
        return;
    }
    StudySubjectBean studySub = (StudySubjectBean) subdao.findByPK(studySubId);
    if (!permitSign(studySub, sm.getDataSource())) {
        addPageMessage(respage.getString("subject_event_cannot_signed"));
        // forwardPage(Page.SUBMIT_DATA_SERVLET);
        forwardPage(Page.LIST_STUDY_SUBJECTS_SERVLET);
        // >> changed tbh, 06/2009
        return;
    }
    if (action.equalsIgnoreCase("confirm")) {
        String username = request.getParameter("j_user");
        String password = request.getParameter("j_pass");
        SecurityManager securityManager = ((SecurityManager) SpringServletAccess.getApplicationContext(context).getBean("securityManager"));
        // String encodedUserPass =
        // org.akaza.openclinica.core.SecurityManager
        // .getInstance().encrytPassword(password);
        UserAccountBean ub = (UserAccountBean) session.getAttribute("userBean");
        if (securityManager.verifyPassword(password, getUserDetails()) && ub.getName().equals(username)) {
            if (signSubjectEvents(studySub, sm.getDataSource(), ub)) {
                // Making the StudySubject signed as all the events have
                // become signed.
                studySub.setStatus(Status.SIGNED);
                studySub.setUpdater(ub);
                subdao.update(studySub);
                addPageMessage(respage.getString("subject_event_signed"));
                // forwardPage(Page.SUBMIT_DATA_SERVLET);
                forwardPage(Page.LIST_STUDY_SUBJECTS_SERVLET);
                // >> changed tbh, 06/2009
                return;
            } else {
                addPageMessage(respage.getString("errors_in_submission_see_below"));
                forwardPage(Page.LIST_STUDY_SUBJECTS);
                return;
            }
        } else {
            request.setAttribute("id", new Integer(studySubId).toString());
            addPageMessage(restext.getString("password_match"));
            forwardPage(Page.LIST_STUDY_SUBJECTS);
            return;
        }
    }
    request.setAttribute("studySub", studySub);
    int studyId = studySub.getStudyId();
    int subjectId = studySub.getSubjectId();
    SubjectBean subject = (SubjectBean) sdao.findByPK(subjectId);
    if (currentStudy.getStudyParameterConfig().getCollectDob().equals("2")) {
        Date dob = subject.getDateOfBirth();
        if (dob != null) {
            Calendar cal = Calendar.getInstance();
            cal.setTime(dob);
            int year = cal.get(Calendar.YEAR);
            request.setAttribute("yearOfBirth", new Integer(year));
        } else {
            request.setAttribute("yearOfBirth", "");
        }
    }
    request.setAttribute("subject", subject);
    StudyDAO studydao = new StudyDAO(sm.getDataSource());
    StudyBean study = (StudyBean) studydao.findByPK(studyId);
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
    study.getStudyParameterConfig().setCollectDob(spvdao.findByHandleAndStudy(studyId, "collectDob").getValue());
    if (study.getParentStudyId() > 0) {
        // this is a site,find parent
        StudyBean parentStudy = (StudyBean) studydao.findByPK(study.getParentStudyId());
        request.setAttribute("parentStudy", parentStudy);
    } else {
        request.setAttribute("parentStudy", new StudyBean());
    }
    ArrayList children = (ArrayList) sdao.findAllChildrenByPK(subjectId);
    request.setAttribute("children", children);
    // find study events
    StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
    StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
    EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
    // find all eventcrfs for each event
    EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
    ArrayList<DisplayStudyEventBean> displayEvents = getDisplayStudyEventsForStudySubject(study, studySub, sm.getDataSource(), ub, currentRole);
    DiscrepancyNoteUtil discNoteUtil = new DiscrepancyNoteUtil();
    // Don't filter for now; disc note beans are returned with eventCRFId
    // set
    discNoteUtil.injectParentDiscNotesIntoDisplayStudyEvents(displayEvents, new HashSet(), sm.getDataSource(), 0);
    // All the displaystudyevents for one subject
    request.setAttribute("displayStudyEvents", displayEvents);
    // Set up a Map for the JSP view, mapping the eventCRFId to another Map:
    // the
    // inner Map maps the resolution status name to the number of notes for
    // that
    // eventCRF id, as in New --> 2
    Map discNoteByEventCRFid = discNoteUtil.createDiscNoteMapByEventCRF(displayEvents);
    request.setAttribute("discNoteByEventCRFid", discNoteByEventCRFid);
    EntityBeanTable table = fp.getEntityBeanTable();
    // sort by start date,
    table.setSortingIfNotExplicitlySet(1, false);
    // desc
    ArrayList allEventRows = DisplayStudyEventRow.generateRowsFromBeans(displayEvents);
    String[] columns = { resword.getString("event") + " (" + resword.getString("occurrence_number") + ")", resword.getString("start_date1"), resword.getString("location"), resword.getString("status"), resword.getString("actions"), resword.getString("CRFs_atrib") };
    table.setColumns(new ArrayList(Arrays.asList(columns)));
    table.hideColumnLink(4);
    table.hideColumnLink(5);
    if (!"removed".equalsIgnoreCase(studySub.getStatus().getName()) && !"auto-removed".equalsIgnoreCase(studySub.getStatus().getName())) {
        table.addLink(resword.getString("add_new_event"), "CreateNewStudyEvent?" + CreateNewStudyEventServlet.INPUT_STUDY_SUBJECT_ID_FROM_VIEWSUBJECT + "=" + studySub.getId());
    }
    HashMap args = new HashMap();
    args.put("id", new Integer(studySubId).toString());
    table.setQuery("ViewStudySubject", args);
    table.setRows(allEventRows);
    table.computeDisplay();
    request.setAttribute("table", table);
    SubjectGroupMapDAO sgmdao = new SubjectGroupMapDAO(sm.getDataSource());
    ArrayList groupMaps = (ArrayList) sgmdao.findAllByStudySubject(studySubId);
    request.setAttribute("groups", groupMaps);
    AuditEventDAO aedao = new AuditEventDAO(sm.getDataSource());
    ArrayList logs = aedao.findEventStatusLogByStudySubject(studySubId);
    UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
    ArrayList eventLogs = new ArrayList();
    for (int i = 0; i < logs.size(); i++) {
        AuditEventBean avb = (AuditEventBean) logs.get(i);
        StudyEventAuditBean sea = new StudyEventAuditBean();
        sea.setAuditEvent(avb);
        StudyEventBean se = (StudyEventBean) sedao.findByPK(avb.getEntityId());
        StudyEventDefinitionBean sed = (StudyEventDefinitionBean) seddao.findByPK(se.getStudyEventDefinitionId());
        sea.setDefinition(sed);
        String old = avb.getOldValue().trim();
        try {
            if (!StringUtil.isBlank(old)) {
                SubjectEventStatus oldStatus = SubjectEventStatus.get(new Integer(old).intValue());
                sea.setOldSubjectEventStatus(oldStatus);
            }
            String newValue = avb.getNewValue().trim();
            if (!StringUtil.isBlank(newValue)) {
                SubjectEventStatus newStatus = SubjectEventStatus.get(new Integer(newValue).intValue());
                sea.setNewSubjectEventStatus(newStatus);
            }
        } catch (NumberFormatException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        // logger.warning("^^^ caught NFE");
        }
        UserAccountBean updater = (UserAccountBean) udao.findByPK(avb.getUserId());
        sea.setUpdater(updater);
        eventLogs.add(sea);
    }
    // logger.warning("^^^ finished iteration");
    request.setAttribute("eventLogs", eventLogs);
    forwardPage(Page.SIGN_STUDY_SUBJECT);
}
Also used : SecurityManager(org.akaza.openclinica.core.SecurityManager) HashMap(java.util.HashMap) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) SubjectDAO(org.akaza.openclinica.dao.submit.SubjectDAO) EntityBeanTable(org.akaza.openclinica.web.bean.EntityBeanTable) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) DisplayStudyEventBean(org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean) SubjectEventStatus(org.akaza.openclinica.bean.core.SubjectEventStatus) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) DiscrepancyNoteUtil(org.akaza.openclinica.service.DiscrepancyNoteUtil) AuditEventBean(org.akaza.openclinica.bean.admin.AuditEventBean) StudyEventAuditBean(org.akaza.openclinica.bean.admin.StudyEventAuditBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) HashSet(java.util.HashSet) SubjectGroupMapDAO(org.akaza.openclinica.dao.submit.SubjectGroupMapDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) Calendar(java.util.Calendar) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) AuditEventDAO(org.akaza.openclinica.dao.admin.AuditEventDAO) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) Date(java.util.Date) SubjectBean(org.akaza.openclinica.bean.submit.SubjectBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) DisplayStudyEventBean(org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) Map(java.util.Map) HashMap(java.util.HashMap)

Example 3 with EventDefinitionCRFDAO

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

the class StudyAuditLogServlet method processRequest.

/*
     * (non-Javadoc) Assume that we get the user id automatically. We will jump
     * from the edit user page if the user is an admin, they can get to see the
     * users' log
     * @see org.akaza.openclinica.control.core.SecureController#processRequest()
     */
/*
     * (non-Javadoc) redo this servlet to run the audits per study subject for
     * the study; need to add a studyId param and then use the
     * StudySubjectDAO.findAllByStudyOrderByLabel() method to grab a lot of
     * study subject beans and then return them much like in
     * ViewStudySubjectAuditLogServet.process() currentStudy instead of studyId?
     */
@Override
protected void processRequest() throws Exception {
    int studyId = currentStudy.getId();
    StudySubjectDAO subdao = new StudySubjectDAO(sm.getDataSource());
    SubjectDAO sdao = new SubjectDAO(sm.getDataSource());
    AuditDAO adao = new AuditDAO(sm.getDataSource());
    UserAccountDAO uadao = new UserAccountDAO(sm.getDataSource());
    FormProcessor fp = new FormProcessor(request);
    StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
    StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
    EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
    EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
    StudyDAO studydao = new StudyDAO(sm.getDataSource());
    CRFDAO cdao = new CRFDAO(sm.getDataSource());
    CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
    StudyAuditLogTableFactory factory = new StudyAuditLogTableFactory();
    factory.setSubjectDao(sdao);
    factory.setStudySubjectDao(subdao);
    factory.setUserAccountDao(uadao);
    factory.setCurrentStudy(currentStudy);
    String auditLogsHtml = factory.createTable(request, response).render();
    request.setAttribute("auditLogsHtml", auditLogsHtml);
    forwardPage(Page.AUDIT_LOGS_STUDY);
}
Also used : EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) SubjectDAO(org.akaza.openclinica.dao.submit.SubjectDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) AuditDAO(org.akaza.openclinica.dao.admin.AuditDAO) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO)

Example 4 with EventDefinitionCRFDAO

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

the class UnlockEventDefinitionServlet method processRequest.

@Override
public void processRequest() throws Exception {
    String idString = request.getParameter("id");
    int defId = Integer.valueOf(idString.trim()).intValue();
    StudyEventDefinitionDAO sdao = new StudyEventDefinitionDAO(sm.getDataSource());
    StudyEventDefinitionBean sed = (StudyEventDefinitionBean) sdao.findByPK(defId);
    // find all CRFs
    EventDefinitionCRFDAO edao = new EventDefinitionCRFDAO(sm.getDataSource());
    ArrayList eventDefinitionCRFs = (ArrayList) edao.findAllByDefinition(defId);
    CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
    CRFDAO cdao = new CRFDAO(sm.getDataSource());
    for (int i = 0; i < eventDefinitionCRFs.size(); i++) {
        EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
        ArrayList versions = (ArrayList) cvdao.findAllByCRF(edc.getCrfId());
        edc.setVersions(versions);
        CRFBean crf = (CRFBean) cdao.findByPK(edc.getCrfId());
        edc.setCrfName(crf.getName());
    }
    // finds all events
    StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
    ArrayList events = (ArrayList) sedao.findAllByDefinition(sed.getId());
    String action = request.getParameter("action");
    if (StringUtil.isBlank(idString)) {
        addPageMessage(respage.getString("please_choose_a_SED_to_unlock"));
        forwardPage(Page.LIST_DEFINITION_SERVLET);
    } else {
        if ("confirm".equalsIgnoreCase(action)) {
            if (!sed.getStatus().equals(Status.LOCKED)) {
                addPageMessage(respage.getString("this_SED_cannot_be_unlocked") + " " + respage.getString("please_contact_sysadmin_for_more_information"));
                forwardPage(Page.LIST_DEFINITION_SERVLET);
                return;
            }
            request.setAttribute("definitionToUnlock", sed);
            request.setAttribute("eventDefinitionCRFs", eventDefinitionCRFs);
            request.setAttribute("events", events);
            forwardPage(Page.UNLOCK_DEFINITION);
        } else {
            logger.info("submit to lock the definition");
            // unlock definition
            sed.setStatus(Status.AVAILABLE);
            sed.setUpdater(ub);
            sed.setUpdatedDate(new Date());
            sdao.update(sed);
            // lock all crfs
            for (int j = 0; j < eventDefinitionCRFs.size(); j++) {
                EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.get(j);
                edc.setStatus(Status.AVAILABLE);
                edc.setUpdater(ub);
                edc.setUpdatedDate(new Date());
                edao.update(edc);
            }
            // unlock all events
            EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
            for (int j = 0; j < events.size(); j++) {
                StudyEventBean event = (StudyEventBean) events.get(j);
                event.setStatus(Status.AVAILABLE);
                event.setUpdater(ub);
                event.setUpdatedDate(new Date());
                sedao.update(event);
                ArrayList eventCRFs = ecdao.findAllByStudyEvent(event);
                // unlock all the item data
                ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
                for (int k = 0; k < eventCRFs.size(); k++) {
                    EventCRFBean eventCRF = (EventCRFBean) eventCRFs.get(k);
                    eventCRF.setStatus(Status.AVAILABLE);
                    eventCRF.setUpdater(ub);
                    eventCRF.setUpdatedDate(new Date());
                    ecdao.update(eventCRF);
                    ArrayList itemDatas = iddao.findAllByEventCRFId(eventCRF.getId());
                    for (int a = 0; a < itemDatas.size(); a++) {
                        ItemDataBean item = (ItemDataBean) itemDatas.get(a);
                        item.setStatus(Status.AVAILABLE);
                        item.setUpdater(ub);
                        item.setUpdatedDate(new Date());
                        iddao.update(item);
                    }
                }
            }
            String emailBody = respage.getString("the_SED") + " " + sed.getName() + respage.getString("has_been_unlocked_for_the_study") + " " + currentStudy.getName() + ". " + respage.getString("subject_event_data_is_as_it_was_before");
            addPageMessage(emailBody);
            sendEmail(emailBody);
            forwardPage(Page.LIST_DEFINITION_SERVLET);
        }
    }
}
Also used : EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) Date(java.util.Date) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO)

Example 5 with EventDefinitionCRFDAO

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

Aggregations

EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)84 ArrayList (java.util.ArrayList)72 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)58 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)53 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)51 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)47 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)45 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)45 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)41 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)41 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)40 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)39 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)39 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)36 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)35 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)30 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)28 Date (java.util.Date)27 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)27 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)26