Search in sources :

Example 1 with SdvFilterDataBean

use of org.akaza.openclinica.controller.helper.SdvFilterDataBean in project OpenClinica by OpenClinica.

the class SDVController method viewAllSubjectFormHandler.

@RequestMapping("/viewAllSubjectSDVform")
public ModelMap viewAllSubjectFormHandler(HttpServletRequest request, HttpServletResponse response, @RequestParam("studyId") int studyId) {
    ModelMap gridMap = new ModelMap();
    StudyDAO studyDAO = new StudyDAO(dataSource);
    // StudyEventDAO studyEventDAO = new StudyEventDAO(dataSource);
    StudyBean studyBean = (StudyBean) studyDAO.findByPK(studyId);
    String pattern = "MM/dd/yyyy";
    SimpleDateFormat sdf = new SimpleDateFormat(pattern);
    // List<StudyEventBean> studyEventBeans = studyEventDAO.findAllByStudy(studyBean);
    // List<EventCRFBean> eventCRFBeans = sdvUtil.getAllEventCRFs(studyEventBeans);
    // set up the parameters to take part in filtering
    ServletRequestDataBinder dataBinder = new ServletRequestDataBinder(new SdvFilterDataBean());
    dataBinder.setAllowedFields(new String[] { "study_subject_id", "studyEventDefinition", "studyEventStatus", "eventCRFStatus", "sdvRequirement", "eventcrfSDVStatus", "startUpdatedDate", "endDate", "eventCRFName" });
    dataBinder.registerCustomEditor(java.util.Date.class, new CustomDateEditor(sdf, true));
    dataBinder.bind(request);
    BindingResult bindingResult = dataBinder.getBindingResult();
    // eventCRFBeans = sdvUtil.filterEventCRFs(eventCRFBeans,bindingResult);
    // set up request attributes for sidebar
    // Not necessary when using old page design...
    // setUpSidebar(request);
    request.setAttribute("studyId", studyId);
    // We need a study subject id for the first tab; take it somewhat arbitrarily from the first study event bean
    /* int studySubjectId = 0;

        StudyEventBean studyBeanUrl = studyEventBeans.get(0);
        if(studyBeanUrl != null) {
            studySubjectId= studyBeanUrl.getStudySubjectId();
        }
        request.setAttribute("studySubjectId",studySubjectId);*/
    // set up the elements for the view's filter box
    /*sdvUtil.prepareSDVSelectElements(request,studyBean);*/
    ArrayList<String> pageMessages = (ArrayList<String>) request.getAttribute("pageMessages");
    if (pageMessages == null) {
        pageMessages = new ArrayList<String>();
    }
    request.setAttribute("pageMessages", pageMessages);
    String sdvMatrix = sdvUtil.renderEventCRFTableWithLimit(request, studyId, "");
    gridMap.addAttribute(SUBJECT_SDV_TABLE_ATTRIBUTE, sdvMatrix);
    return gridMap;
}
Also used : BindingResult(org.springframework.validation.BindingResult) CustomDateEditor(org.springframework.beans.propertyeditors.CustomDateEditor) ModelMap(org.springframework.ui.ModelMap) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ServletRequestDataBinder(org.springframework.web.bind.ServletRequestDataBinder) ArrayList(java.util.ArrayList) SdvFilterDataBean(org.akaza.openclinica.controller.helper.SdvFilterDataBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) SimpleDateFormat(java.text.SimpleDateFormat) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with SdvFilterDataBean

use of org.akaza.openclinica.controller.helper.SdvFilterDataBean in project OpenClinica by OpenClinica.

the class SDVUtil method filterEventCRFs.

public List<EventCRFBean> filterEventCRFs(List<EventCRFBean> eventCRFBeans, BindingResult bindingResult) {
    /*
         * study_subject_id=Subject+D&eventCRF=0&studyEventDefinition=0&
         * studyEventStatus=-1&eventCRFStatus=-1&eventcrfSDVStatus=None&
         * sdvRequirement=0&startUpdatedDate=&endDate=&submit=Apply+Filter
         */
    List<EventCRFBean> newList = new ArrayList<EventCRFBean>();
    if (eventCRFBeans == null || eventCRFBeans.isEmpty() || bindingResult == null) {
        return eventCRFBeans;
    }
    SdvFilterDataBean filterBean = (SdvFilterDataBean) bindingResult.getTarget();
    StudySubjectBean studySubjectBean = null;
    StudyEventBean studyEventBean = null;
    StudySubjectDAO studySubjectDAO = new StudySubjectDAO(dataSource);
    StudyEventDAO studyEventDAO = new StudyEventDAO(dataSource);
    boolean studySub = true, studyEventDef = true, studyEventStatus = true, eventCRFStatusBool = true, eventcrfSDVStatus = true, eventCRFNameBool = true, upDatedDateBool = true, sdvRequirementBool = true;
    for (EventCRFBean eventCBean : eventCRFBeans) {
        // filter study subject
        if (filterBean.getStudy_subject_id().length() > 0) {
            studySubjectBean = (StudySubjectBean) studySubjectDAO.findByPK(eventCBean.getStudySubjectId());
            studySub = filterBean.getStudy_subject_id().equalsIgnoreCase(studySubjectBean.getLabel());
        }
        if (filterBean.getStudyEventDefinition() > 0) {
            studyEventBean = (StudyEventBean) studyEventDAO.findByPK(eventCBean.getStudyEventId());
            studyEventDef = filterBean.getStudyEventDefinition() == studyEventBean.getStudyEventDefinitionId();
        }
        // Event CRF status
        if (filterBean.getStudyEventStatus() > 0) {
            studyEventStatus = filterBean.getStudyEventStatus() == eventCBean.getStatus().getId();
        }
        // Event CRF subject event status
        if (filterBean.getEventCRFStatus() > 0) {
            studyEventBean = (StudyEventBean) studyEventDAO.findByPK(eventCBean.getStudyEventId());
            eventCRFStatusBool = filterBean.getEventCRFStatus() == studyEventBean.getSubjectEventStatus().getId();
        }
        // Event CRF SDV status; true or false
        if (!filterBean.getEventcrfSDVStatus().equalsIgnoreCase("N/A")) {
            boolean sdvBool = filterBean.getEventcrfSDVStatus().equalsIgnoreCase("complete");
            eventcrfSDVStatus = eventCBean.isSdvStatus() == sdvBool;
        }
        // Event CRF name match
        if (filterBean.getEventCRFName().length() > 0) {
            String tmpName = getCRFName(eventCBean.getCRFVersionId());
            eventCRFNameBool = tmpName.equalsIgnoreCase(filterBean.getEventCRFName());
        }
        // event CRF updated date
        if (eventCBean.getUpdatedDate() != null && filterBean.getStartUpdatedDate() != null && filterBean.getEndDate() != null) {
            GregorianCalendar calStart = new GregorianCalendar();
            calStart.setTime(filterBean.getStartUpdatedDate());
            GregorianCalendar calendarEnd = new GregorianCalendar();
            calendarEnd.setTime(filterBean.getEndDate());
            GregorianCalendar calendarNow = new GregorianCalendar();
            calendarNow.setTime(eventCBean.getUpdatedDate());
            upDatedDateBool = calendarNow.after(calStart) && calendarNow.before(calendarEnd) || calendarNow.equals(calStart) || calendarNow.equals(calendarEnd);
        }
        if (upDatedDateBool && eventCRFNameBool && eventcrfSDVStatus && eventCRFStatusBool && studyEventStatus && studyEventDef && studySub) {
            newList.add(eventCBean);
        }
    }
    return newList;
}
Also used : EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) ArrayList(java.util.ArrayList) GregorianCalendar(java.util.GregorianCalendar) SdvFilterDataBean(org.akaza.openclinica.controller.helper.SdvFilterDataBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO)

Aggregations

ArrayList (java.util.ArrayList)2 SdvFilterDataBean (org.akaza.openclinica.controller.helper.SdvFilterDataBean)2 SimpleDateFormat (java.text.SimpleDateFormat)1 GregorianCalendar (java.util.GregorianCalendar)1 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)1 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)1 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)1 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)1 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)1 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)1 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)1 CustomDateEditor (org.springframework.beans.propertyeditors.CustomDateEditor)1 ModelMap (org.springframework.ui.ModelMap)1 BindingResult (org.springframework.validation.BindingResult)1 ServletRequestDataBinder (org.springframework.web.bind.ServletRequestDataBinder)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1