Search in sources :

Example 91 with StudyEventDAO

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

the class FindStudyEventServlet method processRequest.

/*
     * (non-Javadoc)
     *
     * @see org.akaza.openclinica.control.core.SecureController#processRequest()
     */
@Override
protected void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    String browseBy = fp.getString(INPUT_BROWSEBY);
    int id = fp.getInt(INPUT_ID);
    // User is going to Step 1
    if (browseBy.equals("")) {
        forwardPage(Page.FIND_STUDY_EVENTS_STEP1);
    } else if (invalidBrowseBy(browseBy)) {
        addPageMessage(respage.getString("must_browse_study_events_by_subject_or_event_definition"));
        forwardPage(Page.FIND_STUDY_EVENTS_STEP1);
    } else // User was at Step 1, is going to Step 2
    if (id <= 0) {
        int pageNum = fp.getInt(INPUT_PAGENUM);
        ArrayList allDisplayEntities = new ArrayList();
        if (browseBy.equals(ARG_BROWSEBY_SUBJECT)) {
            StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
            allDisplayEntities = ssdao.findAllWithStudyEvent(currentStudy);
        } else {
            StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
            allDisplayEntities = seddao.findAllWithStudyEvent(currentStudy);
        }
        if (pageNum < 0) {
            pageNum = 0;
        } else if (pageNum > allDisplayEntities.size() / NUM_ENTITIES_PER_PAGE) {
            pageNum = allDisplayEntities.size() / NUM_ENTITIES_PER_PAGE;
        }
        int firstIndex = NUM_ENTITIES_PER_PAGE * pageNum;
        int lastIndex = NUM_ENTITIES_PER_PAGE * (pageNum + 1);
        if (allDisplayEntities.size() > lastIndex) {
            request.setAttribute(BEAN_DISPLAY_NEXT_PAGE, ARG_DISPLAY_NEXT_PAGE_YES);
        } else {
            request.setAttribute(BEAN_DISPLAY_NEXT_PAGE, ARG_DISPLAY_NEXT_PAGE_NO);
            lastIndex = allDisplayEntities.size();
        }
        List displayEntities = allDisplayEntities.subList(firstIndex, lastIndex);
        request.setAttribute(INPUT_BROWSEBY, browseBy);
        request.setAttribute(BEAN_DISPLAY_ENTITIES, displayEntities);
        request.setAttribute(INPUT_PAGENUM, new Integer(pageNum));
        forwardPage(Page.FIND_STUDY_EVENTS_STEP2);
    } else // User is coming from Step 2, is going to Step 3
    {
        StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
        ArrayList events = new ArrayList();
        EntityBean entityWithStudyEvents;
        if (browseBy.equals(ARG_BROWSEBY_SUBJECT)) {
            events = sedao.findAllByStudyAndStudySubjectId(currentStudy, id);
            StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
            entityWithStudyEvents = ssdao.findByPK(id);
        } else {
            events = sedao.findAllByStudyAndEventDefinitionId(currentStudy, id);
            StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
            entityWithStudyEvents = seddao.findByPK(id);
        }
        request.setAttribute(INPUT_BROWSEBY, browseBy);
        request.setAttribute(BEAN_DISPLAY_ENTITIES, events);
        request.setAttribute(BEAN_ENTITY_WITH_STUDY_EVENTS, entityWithStudyEvents);
        forwardPage(Page.FIND_STUDY_EVENTS_STEP3);
    }
}
Also used : StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) EntityBean(org.akaza.openclinica.bean.core.EntityBean) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO)

Example 92 with StudyEventDAO

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

the class ChangeCRFVersionController method chooseCRFVersion.

/*
     * Allows user to select new CRF version
     * 
     */
// @RequestMapping(value="/managestudy/chooseCRFVersion", method = RequestMethod.GET)
@RequestMapping(value = "/managestudy/chooseCRFVersion", method = RequestMethod.GET)
public ModelMap chooseCRFVersion(HttpServletRequest request, HttpServletResponse response, @RequestParam("crfId") int crfId, @RequestParam("crfName") String crfName, @RequestParam("formLayoutId") int formLayoutId, @RequestParam("formLayoutName") String formLayoutName, @RequestParam("studySubjectLabel") String studySubjectLabel, @RequestParam("studySubjectId") int studySubjectId, @RequestParam("eventCRFId") int eventCRFId, @RequestParam("eventDefinitionCRFId") int eventDefinitionCRFId) {
    // to be removed for aquamarine
    if (!mayProceed(request)) {
        try {
            response.sendRedirect(request.getContextPath() + "/MainMenu?message=authentication_failed");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    resetPanel(request);
    ModelMap gridMap = new ModelMap();
    request.setAttribute("eventCRFId", eventCRFId);
    request.setAttribute("studySubjectLabel", studySubjectLabel);
    request.setAttribute("eventDefinitionCRFId", eventDefinitionCRFId);
    request.setAttribute("studySubjectId", studySubjectId);
    request.setAttribute("crfId", crfId);
    request.setAttribute("crfName", crfName);
    request.setAttribute("formLayoutId", formLayoutId);
    request.setAttribute("formLayoutName", formLayoutName.trim());
    ArrayList<String> pageMessages = initPageMessages(request);
    Object errorMessage = request.getParameter("errorMessage");
    if (errorMessage != null) {
        pageMessages.add((String) errorMessage);
    }
    // get CRF by ID with all versions
    // create List of all versions (label + value)
    // set default CRF version label
    setupResource(request);
    // from event_crf get
    StudyBean study = (StudyBean) request.getSession().getAttribute("study");
    CRFDAO cdao = new CRFDAO(dataSource);
    CRFBean crfBean = (CRFBean) cdao.findByPK(crfId);
    FormLayoutDAO formLayoutDao = new FormLayoutDAO(dataSource);
    ArrayList<FormLayoutBean> formLayouts = (ArrayList<FormLayoutBean>) formLayoutDao.findAllActiveByCRF(crfId);
    StudyEventDefinitionDAO sfed = new StudyEventDefinitionDAO(dataSource);
    StudyEventDefinitionBean sedb = sfed.findByEventDefinitionCRFId(eventDefinitionCRFId);
    request.setAttribute("eventName", sedb.getName());
    EventCRFDAO ecdao = new EventCRFDAO(dataSource);
    EventCRFBean ecb = (EventCRFBean) ecdao.findByPK(eventCRFId);
    StudyEventDAO sedao = new StudyEventDAO(dataSource);
    StudyEventBean seb = (StudyEventBean) sedao.findByPK(ecb.getStudyEventId());
    request.setAttribute("eventCreateDate", formatDate(seb.getCreatedDate()));
    if (sedb.isRepeating()) {
        request.setAttribute("eventOrdinal", seb.getSampleOrdinal());
    }
    if (study.getParentStudyId() > 0) {
        EventDefinitionCRFDAO edfdao = new EventDefinitionCRFDAO(dataSource);
        EventDefinitionCRFBean edf = (EventDefinitionCRFBean) edfdao.findByPK(eventDefinitionCRFId);
        if (!edf.getSelectedVersionIds().equals("")) {
            String[] version_ids = edf.getSelectedVersionIds().split(",");
            HashMap<String, String> tmp = new HashMap<String, String>(version_ids.length);
            for (String vs : version_ids) {
                tmp.put(vs, vs);
            }
            ArrayList<FormLayoutBean> site_versions = new ArrayList<FormLayoutBean>(formLayouts.size());
            for (FormLayoutBean vs : formLayouts) {
                if (tmp.get(String.valueOf(vs.getId())) != null) {
                    site_versions.add(vs);
                }
            }
            formLayouts = site_versions;
        }
    }
    crfBean.setVersions(formLayouts);
    gridMap.addAttribute("numberOfVersions", crfBean.getVersions().size() + 1);
    gridMap.addAttribute("crfBean", crfBean);
    return gridMap;
}
Also used : EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) HashMap(java.util.HashMap) ModelMap(org.springframework.ui.ModelMap) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) FormLayoutBean(org.akaza.openclinica.bean.submit.FormLayoutBean) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) HttpSessionRequiredException(org.springframework.web.HttpSessionRequiredException) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) FormLayoutDAO(org.akaza.openclinica.dao.submit.FormLayoutDAO) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 93 with StudyEventDAO

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

the class ChangeCRFVersionController method changeCRFVersionAction.

@RequestMapping("/managestudy/changeCRFVersion")
public // @RequestMapping("/managestudy/changeCRFVersionAction")
ModelMap changeCRFVersionAction(HttpServletRequest request, HttpServletResponse response, @RequestParam("crfId") int crfId, @RequestParam("crfName") String crfName, @RequestParam("formLayoutId") int formLayoutId, @RequestParam("formLayoutName") String formLayoutName, @RequestParam("studySubjectLabel") String studySubjectLabel, @RequestParam("studySubjectId") int studySubjectId, @RequestParam("eventCRFId") int eventCRFId, @RequestParam("eventDefinitionCRFId") int eventDefinitionCRFId, @RequestParam(value = "newFormLayoutId", required = true) int newFormLayoutId) {
    // to be removed for aquamarine
    if (!mayProceed(request)) {
        if (redirect(request, response, "/MainMenu?message=authentication_failed") == null)
            return null;
    }
    ArrayList<String> pageMessages = initPageMessages(request);
    setupResource(request);
    // update event_crf_id table
    try {
        EventCRFDAO event_crf_dao = new EventCRFDAO(dataSource);
        StudyEventDAO sedao = new StudyEventDAO(dataSource);
        EventCRFBean ev_bean = (EventCRFBean) event_crf_dao.findByPK(eventCRFId);
        StudyEventBean st_event_bean = (StudyEventBean) sedao.findByPK(ev_bean.getStudyEventId());
        Connection con = dataSource.getConnection();
        CoreResources.setSchema(con);
        con.setAutoCommit(false);
        event_crf_dao.updateFormLayoutID(eventCRFId, newFormLayoutId, getCurrentUser(request).getId(), con);
        String status_before_update = null;
        SubjectEventStatus eventStatus = null;
        Status subjectStatus = null;
        AuditDAO auditDao = new AuditDAO(dataSource);
        // event signed, check if subject is signed as well
        StudySubjectDAO studySubDao = new StudySubjectDAO(dataSource);
        StudySubjectBean studySubBean = (StudySubjectBean) studySubDao.findByPK(st_event_bean.getStudySubjectId());
        if (studySubBean.getStatus().isSigned()) {
            status_before_update = auditDao.findLastStatus("study_subject", studySubBean.getId(), "8");
            if (status_before_update != null && status_before_update.length() == 1) {
                int subject_status = Integer.parseInt(status_before_update);
                subjectStatus = Status.get(subject_status);
                studySubBean.setStatus(subjectStatus);
            }
            studySubBean.setUpdater(getCurrentUser(request));
            studySubDao.update(studySubBean, con);
        }
        st_event_bean.setUpdater(getCurrentUser(request));
        st_event_bean.setUpdatedDate(new Date());
        status_before_update = auditDao.findLastStatus("study_event", st_event_bean.getId(), "8");
        if (status_before_update != null && status_before_update.length() == 1) {
            int status = Integer.parseInt(status_before_update);
            eventStatus = SubjectEventStatus.get(status);
            st_event_bean.setSubjectEventStatus(eventStatus);
        }
        sedao.update(st_event_bean, con);
        con.commit();
        con.setAutoCommit(true);
        con.close();
        pageMessages.add(resword.getString("confirm_crf_version_ms"));
        String msg = resword.getString("confirm_crf_version_ms");
        redirect(request, response, "/ViewStudySubject?isFromCRFVersionChange=" + msg + "&id=" + studySubjectId);
    } catch (Exception e) {
        pageMessages.add(resword.getString("error_message_cannot_update_crf_version"));
    }
    return null;
}
Also used : Status(org.akaza.openclinica.bean.core.Status) SubjectEventStatus(org.akaza.openclinica.bean.core.SubjectEventStatus) Connection(java.sql.Connection) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) Date(java.util.Date) HttpSessionRequiredException(org.springframework.web.HttpSessionRequiredException) SubjectEventStatus(org.akaza.openclinica.bean.core.SubjectEventStatus) AuditDAO(org.akaza.openclinica.dao.admin.AuditDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 94 with StudyEventDAO

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

the class DiscrepancyNoteController method buidDiscrepancyNote.

@RequestMapping(value = "/dnote", method = RequestMethod.POST)
public ResponseEntity buidDiscrepancyNote(@RequestBody HashMap<String, String> map, HttpServletRequest request) throws Exception {
    ResourceBundleProvider.updateLocale(new Locale("en_US"));
    System.out.println("I'm in EnketoForm DN Rest Method");
    org.springframework.http.HttpStatus httpStatus = null;
    String se_oid = map.get("EntityID");
    String ordinal = map.get("Ordinal");
    // start_date , end_date , location
    String entityName = map.get("EntityName");
    String studySubjectOid = map.get("SS_OID");
    String noteType = map.get("NoteType");
    String resolutionStatus = map.get("Status");
    String assignedUser = map.get("AssignedUser");
    String owner = map.get("Owner");
    String description = map.get("Description");
    String detailedNotes = map.get("DetailedNote");
    String dn_id = map.get("DN_Id");
    dn_id = dn_id != null ? dn_id.replaceFirst("DN_", "") : dn_id;
    UserAccountDAO udao = new UserAccountDAO(dataSource);
    StudySubjectDAO ssdao = new StudySubjectDAO(dataSource);
    StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(dataSource);
    StudyEventDAO sedao = new StudyEventDAO(dataSource);
    DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(dataSource);
    UserAccountBean assignedUserBean = (UserAccountBean) udao.findByUserName(assignedUser);
    UserAccountBean ownerBean = (UserAccountBean) request.getSession().getAttribute("userBean");
    StudySubjectBean ssBean = ssdao.findByOid(studySubjectOid);
    StudyEventDefinitionBean sedBean = seddao.findByOid(se_oid);
    StudyBean studyBean = getStudy(sedBean.getStudyId());
    StudyEventBean seBean = (StudyEventBean) sedao.findByStudySubjectIdAndDefinitionIdAndOrdinal(ssBean.getId(), sedBean.getId(), Integer.valueOf(ordinal));
    String entityType = "studyEvent";
    DiscrepancyNoteBean parent = (DiscrepancyNoteBean) dndao.findByPK(Integer.valueOf(dn_id));
    if (!mayProceed(resolutionStatus, noteType, seBean, entityName, parent, ownerBean)) {
        httpStatus = org.springframework.http.HttpStatus.BAD_REQUEST;
        return new ResponseEntity(httpStatus);
    }
    if (!parent.isActive()) {
        saveFieldNotes(description, detailedNotes, seBean.getId(), entityType, studyBean, ownerBean, assignedUserBean, resolutionStatus, noteType, entityName);
        httpStatus = org.springframework.http.HttpStatus.OK;
    } else {
        createDiscrepancyNoteBean(description, detailedNotes, seBean.getId(), entityType, studyBean, ownerBean, assignedUserBean, parent.getId(), resolutionStatus, noteType, entityName);
        httpStatus = org.springframework.http.HttpStatus.OK;
    }
    return new ResponseEntity(httpStatus);
}
Also used : Locale(java.util.Locale) DiscrepancyNoteDAO(org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) ResponseEntity(org.springframework.http.ResponseEntity) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 95 with StudyEventDAO

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

the class DiscrepancyNoteOutputServlet method populateRowsWithAttachedData.

private ArrayList<DiscrepancyNoteBean> populateRowsWithAttachedData(ArrayList<DiscrepancyNoteBean> noteRows) {
    Locale l = LocaleResolver.getLocale(request);
    resword = ResourceBundleProvider.getWordsBundle(l);
    resformat = ResourceBundleProvider.getFormatBundle(l);
    SimpleDateFormat sdf = new SimpleDateFormat(resformat.getString("date_format_string"), ResourceBundleProvider.getLocale());
    DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(sm.getDataSource());
    StudySubjectDAO studySubjectDAO = new StudySubjectDAO(sm.getDataSource());
    StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
    CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
    CRFDAO cdao = new CRFDAO(sm.getDataSource());
    StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
    EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
    ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
    ItemDAO idao = new ItemDAO(sm.getDataSource());
    StudyDAO studyDao = new StudyDAO(sm.getDataSource());
    ItemGroupMetadataDAO<String, ArrayList> igmdao = new ItemGroupMetadataDAO<String, ArrayList>(sm.getDataSource());
    ItemGroupDAO<String, ArrayList> igdao = new ItemGroupDAO<String, ArrayList>(sm.getDataSource());
    ArrayList<DiscrepancyNoteBean> allNotes = new ArrayList<DiscrepancyNoteBean>();
    for (int i = 0; i < noteRows.size(); i++) {
        DiscrepancyNoteBean dnb = noteRows.get(i);
        dnb.setCreatedDateString(dnb.getCreatedDate() == null ? "" : sdf.format(dnb.getCreatedDate()));
        if (dnb.getParentDnId() == 0) {
            ArrayList children = dndao.findAllByStudyAndParent(currentStudy, dnb.getId());
            children = children == null ? new ArrayList() : children;
            dnb.setNumChildren(children.size());
            dnb.setChildren(children);
            int lastDnId = dnb.getId();
            int lastChild = 0;
            for (int j = 0; j < children.size(); j++) {
                DiscrepancyNoteBean child = (DiscrepancyNoteBean) children.get(j);
                child.setCreatedDateString(child.getCreatedDate() == null ? "" : sdf.format(child.getCreatedDate()));
                child.setUpdatedDateString(child.getCreatedDate() != null ? sdf.format(child.getCreatedDate()) : "");
                if (child.getId() > lastDnId) {
                    lastDnId = child.getId();
                    lastChild = j;
                }
            }
            if (children.size() > 0) {
                DiscrepancyNoteBean lastdn = (DiscrepancyNoteBean) children.get(lastChild);
                //dnb.setResStatus(ResolutionStatus.get(lastdn.getResolutionStatusId()));
                /*
                     * The update date is the date created of the latest child
                     * note
                     */
                dnb.setUpdatedDate(lastdn.getCreatedDate());
                dnb.setUpdatedDateString(dnb.getUpdatedDate() != null ? sdf.format(dnb.getUpdatedDate()) : "");
            }
        }
        String entityType = dnb.getEntityType();
        if (dnb.getEntityId() > 0 && !entityType.equals("")) {
            AuditableEntityBean aeb = dndao.findEntity(dnb);
            dnb.setEntityName(aeb.getName());
            if (entityType.equalsIgnoreCase("subject")) {
                //                    allNotes.add(dnb);
                SubjectBean sb = (SubjectBean) aeb;
                StudySubjectBean ssb = studySubjectDAO.findBySubjectIdAndStudy(sb.getId(), currentStudy);
                dnb.setStudySub(ssb);
                dnb.setSubjectName(ssb.getLabel());
                String column = dnb.getColumn().trim();
                if (!StringUtil.isBlank(column)) {
                    if ("gender".equalsIgnoreCase(column)) {
                        dnb.setEntityValue(sb.getGender() + "");
                        dnb.setEntityName(resword.getString("gender"));
                    } else if ("date_of_birth".equals(column)) {
                        if (sb.getDateOfBirth() != null) {
                            dnb.setEntityValue(sb.getDateOfBirth().toString());
                        }
                        dnb.setEntityName(resword.getString("date_of_birth"));
                    } else if ("unique_identifier".equalsIgnoreCase(column)) {
                        dnb.setEntityName(resword.getString("unique_identifier"));
                        dnb.setEntityValue(sb.getUniqueIdentifier());
                    }
                }
            } else if (entityType.equalsIgnoreCase("studySub")) {
                //                    allNotes.add(dnb);
                StudySubjectBean ssb = (StudySubjectBean) aeb;
                dnb.setStudySub(ssb);
                dnb.setSubjectName(ssb.getLabel());
                String column = dnb.getColumn().trim();
                if (!StringUtil.isBlank(column)) {
                    if ("enrollment_date".equals(column)) {
                        if (ssb.getEnrollmentDate() != null) {
                            dnb.setEntityValue(ssb.getEnrollmentDate().toString());
                        }
                        dnb.setEntityName(resword.getString("enrollment_date"));
                    }
                }
            } else if (entityType.equalsIgnoreCase("eventCRF")) {
                StudyEventBean se = (StudyEventBean) sedao.findByPK(dnb.getEntityId());
                StudyEventDefinitionBean sedb = (StudyEventDefinitionBean) seddao.findByPK(se.getStudyEventDefinitionId());
                EventCRFBean ecb = (EventCRFBean) aeb;
                CRFVersionBean cvb = (CRFVersionBean) cvdao.findByPK(ecb.getCRFVersionId());
                CRFBean cb = (CRFBean) cdao.findByPK(cvb.getCrfId());
                dnb.setStageId(ecb.getStage().getId());
                dnb.setEntityName(cb.getName() + " (" + cvb.getName() + ")");
                StudySubjectBean ssub = (StudySubjectBean) studySubjectDAO.findByPK(ecb.getStudySubjectId());
                dnb.setStudySub(ssub);
                dnb.setSubjectName(ssub.getLabel());
                if (se != null) {
                    dnb.setEventStart(se.getDateStarted());
                    dnb.setEventName(se.getName());
                }
                dnb.setCrfName(cb.getName());
                String crfStatus = resword.getString(ecb.getStage().getNameRaw());
                if (crfStatus.equals("Invalid")) {
                    crfStatus = "";
                } else if (crfStatus.equals("Data Entry Complete")) {
                    crfStatus = "Complete";
                }
                dnb.setCrfStatus(crfStatus);
                String column = dnb.getColumn().trim();
                if (!StringUtil.isBlank(column)) {
                    if ("date_interviewed".equals(column)) {
                        if (ecb.getDateInterviewed() != null) {
                            dnb.setEntityValue(ecb.getDateInterviewed().toString());
                        }
                        dnb.setEntityName(resword.getString("date_interviewed"));
                    } else if ("interviewer_name".equals(column)) {
                        dnb.setEntityValue(ecb.getInterviewerName());
                        dnb.setEntityName(resword.getString("interviewer_name"));
                    }
                }
                dnb.setEvent(se);
                dnb.setStudyEventDefinitionBean(sedb);
            // }
            } else if (entityType.equalsIgnoreCase("studyEvent")) {
                //                    allNotes.add(dnb);
                StudyEventBean se = (StudyEventBean) sedao.findByPK(dnb.getEntityId());
                StudyEventDefinitionBean sedb = (StudyEventDefinitionBean) seddao.findByPK(se.getStudyEventDefinitionId());
                se.setName(sedb.getName());
                dnb.setEntityName(sedb.getName());
                StudySubjectBean ssub = (StudySubjectBean) studySubjectDAO.findByPK(se.getStudySubjectId());
                dnb.setStudySub(ssub);
                dnb.setEventStart(se.getDateStarted());
                dnb.setEventName(se.getName());
                dnb.setSubjectName(ssub.getLabel());
                String column = dnb.getColumn().trim();
                if (!StringUtil.isBlank(column)) {
                    if ("date_start".equals(column)) {
                        if (se.getDateStarted() != null) {
                            dnb.setEntityValue(se.getDateStarted().toString());
                        }
                        dnb.setEntityName(resword.getString("start_date"));
                    } else if ("date_end".equals(column)) {
                        if (se.getDateEnded() != null) {
                            dnb.setEntityValue(se.getDateEnded().toString());
                        }
                        dnb.setEntityName(resword.getString("end_date"));
                    } else if ("location".equals(column)) {
                        dnb.setEntityValue(se.getLocation());
                        dnb.setEntityName(resword.getString("location"));
                    }
                }
                dnb.setEvent(se);
                dnb.setStudyEventDefinitionBean(sedb);
            } else if (entityType.equalsIgnoreCase("itemData")) {
                ItemDataBean idb = (ItemDataBean) iddao.findByPK(dnb.getEntityId());
                ItemBean ib = (ItemBean) idao.findByPK(idb.getItemId());
                EventCRFBean ec = (EventCRFBean) ecdao.findByPK(idb.getEventCRFId());
                CRFVersionBean cvb = (CRFVersionBean) cvdao.findByPK(ec.getCRFVersionId());
                CRFBean cb = (CRFBean) cdao.findByPK(cvb.getCrfId());
                ItemGroupMetadataBean itemGroupMetadataBean = (ItemGroupMetadataBean) igmdao.findByItemAndCrfVersion(ib.getId(), cvb.getId());
                Boolean isRepeatForSure = itemGroupMetadataBean.isRepeatingGroup();
                if (isRepeatForSure) {
                    ItemGroupBean ig = (ItemGroupBean) igdao.findByPK(itemGroupMetadataBean.getItemGroupId());
                    dnb.setItemDataOrdinal(idb.getOrdinal());
                    dnb.setItemGroupName(ig.getName());
                }
                //                    allNotes.add(dnb);
                dnb.setStageId(ec.getStage().getId());
                dnb.setEntityName(ib.getName());
                dnb.setEntityValue(idb.getValue());
                StudyEventBean se = (StudyEventBean) sedao.findByPK(ec.getStudyEventId());
                StudyEventDefinitionBean sedb = (StudyEventDefinitionBean) seddao.findByPK(se.getStudyEventDefinitionId());
                se.setName(sedb.getName());
                StudySubjectBean ssub = (StudySubjectBean) studySubjectDAO.findByPK(ec.getStudySubjectId());
                dnb.setStudySub(ssub);
                dnb.setSubjectName(ssub.getLabel());
                dnb.setEventStart(se.getDateStarted());
                dnb.setEventName(se.getName());
                dnb.setCrfName(cb.getName());
                String crfStatus = resword.getString(ec.getStage().getNameRaw());
                if (crfStatus.equals("Invalid")) {
                    crfStatus = "";
                } else if (crfStatus.equals("Data Entry Complete")) {
                    crfStatus = "Complete";
                }
                dnb.setCrfStatus(crfStatus);
                dnb.setEvent(se);
                dnb.setStudyEventDefinitionBean(sedb);
            }
        }
        dnb.setStudy((StudyBean) studyDao.findByPK(dnb.getStudyId()));
        if (dnb.getParentDnId() == 0 && dnb.getChildren().size() > 0) {
            ArrayList<DiscrepancyNoteBean> children = dnb.getChildren();
            int childrenSize = children.size();
            for (int j = 0; j < childrenSize; j++) {
                DiscrepancyNoteBean child = children.get(j);
                child.setSubjectName(dnb.getSubjectName());
                child.setEventName(dnb.getEventName());
                child.setCrfName(dnb.getCrfName());
                child.setCrfStatus(dnb.getCrfStatus());
                child.setEntityName(dnb.getEntityName());
                child.setEntityValue(dnb.getEntityValue());
                child.setStudySub(dnb.getStudySub());
                child.setStudy(dnb.getStudy());
            }
        }
        allNotes.add(dnb);
    }
    return allNotes;
}
Also used : Locale(java.util.Locale) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) DiscrepancyNoteDAO(org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) AuditableEntityBean(org.akaza.openclinica.bean.core.AuditableEntityBean) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)107 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)90 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)80 ArrayList (java.util.ArrayList)76 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)69 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)69 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)62 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)61 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)57 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)57 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)51 Date (java.util.Date)49 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)49 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)41 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)40 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)38 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)35 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)35 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)33 HashMap (java.util.HashMap)29