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;
}
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;
}
Aggregations