use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class PrintTableTag method doTag.
/**
* This JSP Tag API method creates a instance of PrintHorizontalFormBuilder,
* then generates that class's XHTML output into the web page. The tag shows
* all sections of a CRF.
*
* @throws JspException
* @throws IOException
*/
@Override
public void doTag() throws JspException, IOException {
JspContext context = getJspContext();
JspWriter tagWriter = context.getOut();
// This request attribute is generated by the PrintCRf or PrintDataEntry
// servlets
List<DisplaySectionBean> listOfDisplayBeans = (ArrayList) context.findAttribute("listOfDisplaySectionBeans");
StudyBean studyBean = (StudyBean) context.findAttribute("study");
// EventCRFBean
EventCRFBean eventCRFBean = (EventCRFBean) context.findAttribute("EventCRFBean");
String isInternetExplorer = (String) context.findAttribute("isInternetExplorer");
if (listOfDisplayBeans != null) {
PrintHorizontalFormBuilder printFormBuilder = new PrintHorizontalFormBuilder();
// Provide the form-building code with the list of display section
// beans
printFormBuilder.setDisplaySectionBeans(listOfDisplayBeans);
// The body content of the tag contains 'true' or 'false', depending
// on whether the
// printed CRF involves data entry (and possible saved data) or not.
JspFragment fragment = this.getJspBody();
Writer stringWriter = new StringWriter();
fragment.invoke(stringWriter);
if ("true".equalsIgnoreCase(stringWriter.toString())) {
printFormBuilder.setInvolvesDataEntry(true);
}
printFormBuilder.setEventCRFbean(eventCRFBean);
if ("true".equalsIgnoreCase(isInternetExplorer)) {
printFormBuilder.setInternetExplorer(true);
}
if (studyBean != null) {
printFormBuilder.setStudyBean(studyBean);
}
if ("true".equalsIgnoreCase(stringWriter.toString())) {
tagWriter.println(printFormBuilder.createMarkup());
} else
tagWriter.println(printFormBuilder.createMarkupNoDE());
} else {
tagWriter.println("The application could not generate the markup for the printable form.<br />" + "This error may have been caused by the altering of the web page's URL; the URL needs " + "an 'id' or an 'ecId' value in its query string at the URL end.");
}
}
use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class SubjectIdSDVFactory method getRow.
private SubjectAggregateContainer getRow(StudySubjectBean studySubjectBean) {
SubjectAggregateContainer row = new SubjectAggregateContainer();
EventCRFDAO eventCRFDAO = new EventCRFDAO(dataSource);
StudyDAO studyDAO = new StudyDAO(dataSource);
StudySubjectDAO studySubjectDAO = new StudySubjectDAO(dataSource);
StudyGroupDAO studyGroupDAO = new StudyGroupDAO(dataSource);
row.setStudySubjectId(studySubjectBean.getLabel());
row.setPersonId(studySubjectBean.getUniqueIdentifier());
row.setStudySubjectStatus(studySubjectBean.getStatus().getName());
int numberEventCRFs = eventCRFDAO.countEventCRFsByStudySubject(studySubjectBean.getId(), studySubjectBean.getStudyId(), studySubjectBean.getStudyId());
row.setTotalEventCRF(numberEventCRFs + "");
StudyBean studyBean = (StudyBean) studyDAO.findByPK(studySubjectBean.getStudyId());
row.setSiteId(studyBean.getIdentifier());
List<EventCRFBean> eventCRFBeans = eventCRFDAO.getEventCRFsByStudySubject(studySubjectBean.getId(), studySubjectBean.getStudyId(), studySubjectBean.getStudyId());
HashMap<String, Integer> stats = getEventCRFStats(eventCRFBeans, studySubjectBean);
//int numberCRFComplete = getNumberCompletedEventCRFs(eventCRFBeans);
//row.setNumberCRFComplete(numberCRFComplete + "");
row.setNumberCRFComplete(stats.get("numberOfCompletedEventCRFs") + "");
row.setNumberOfCRFsSDV(stats.get("numberOfSDVdEventCRFs") + "");
//row.setNumberOfCRFsSDV(getNumberSDVdEventCRFs(eventCRFBeans) + "");
//boolean studySubjectSDVd = eventCRFDAO.countEventCRFsByByStudySubjectCompleteOrLockedAndNotSDVd(studySubjectBean.getId()) == 0 && numberCRFComplete > 0;
boolean studySubjectSDVd = stats.get("areEventCRFsSDVd") == -1 || stats.get("areEventCRFsSDVd") == 1 ? false : true;
StringBuilder sdvStatus = new StringBuilder("");
if (stats.get("shouldDisplaySDVButton") == 0) {
sdvStatus.append("");
} else if (studySubjectSDVd) {
sdvStatus.append("<center><a href='javascript:void(0)' onclick='prompt(document.sdvForm,");
sdvStatus.append(studySubjectBean.getId());
sdvStatus.append(")'>");
sdvStatus.append(getIconForCrfStatusPrefix()).append("DoubleCheck").append(ICON_FORCRFSTATUS_SUFFIX).append("</a></center>");
} else {
sdvStatus.append("<center><input style='margin-right: 5px' type='checkbox' ").append("class='sdvCheck'").append(" name='").append("sdvCheck_").append(studySubjectBean.getId()).append("' /></center>");
}
row.setSdvStatus(sdvStatus.toString());
List<StudyGroupBean> studyGroupBeans = studyGroupDAO.getGroupByStudySubject(studySubjectBean.getId(), studySubjectBean.getStudyId(), studySubjectBean.getStudyId());
if (studyGroupBeans != null && !studyGroupBeans.isEmpty()) {
row.setGroup(studyGroupBeans.get(0).getName());
}
StringBuilder actions = new StringBuilder("<table><tr><td>");
StringBuilder urlPrefix = new StringBuilder("<a href=\"");
StringBuilder path = new StringBuilder(contextPath).append("/pages/viewAllSubjectSDVtmp?studyId=").append(studyId).append("&sdv_f_studySubjectId=");
path.append(studySubjectBean.getLabel());
urlPrefix.append(path).append("\">");
actions.append(urlPrefix).append(SDVUtil.VIEW_ICON_HTML).append("</a></td>");
if (!studySubjectSDVd && stats.get("shouldDisplaySDVButton") == 1) {
StringBuilder jsCodeString = new StringBuilder("this.form.method='GET'; this.form.action='").append(contextPath).append("/pages/sdvStudySubject").append("';").append("this.form.theStudySubjectId.value='").append(studySubjectBean.getId()).append("';").append("this.form.submit();");
actions.append("<td><input type=\"submit\" class=\"button\" value=\"SDV\" name=\"sdvSubmit\" ").append("onclick=\"").append(jsCodeString.toString()).append("\" /></td>");
} else if (!studySubjectSDVd) {
actions.append("<td> SDV N/A</td>");
}
actions.append("</tr></table>");
row.setActions(actions.toString());
return row;
}
use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class SDVUtil method getFilteredItems.
@SuppressWarnings("unchecked")
private Collection<SubjectSDVContainer> getFilteredItems(EventCRFSDVFilter filterSet, EventCRFSDVSort sortSet, int rowStart, int rowEnd, int studyId, HttpServletRequest request) {
EventCRFDAO eventCRFDAO = new EventCRFDAO(dataSource);
List<EventCRFBean> eventCRFBeans = new ArrayList<EventCRFBean>();
/*
StudyEventDAO studyEventDAO = new StudyEventDAO(dataSource);
StudyDAO studyDAO = new StudyDAO(dataSource);
StudyBean studyBean = (StudyBean) studyDAO.findByPK(studyId);
String label = "";
String eventName = "";
String eventDate = "";
String sdvStatus = "";
String crfStatus = "";
String studyIdentifier = "";
String sdvRequirement = "";
SourceDataVerification sourceDataVerification = null;
if (filterSet.getFilter("studySubjectId") != null) {
label = filterSet.getFilter("studySubjectId").getValue().trim();
eventCRFBeans = eventCRFDAO.getEventCRFsByStudySubjectLabelLimit(label, studyId, studyId, rowEnd - rowStart, rowStart);
} else if (filterSet.getFilter("eventName") != null) {
eventName = filterSet.getFilter("eventName").getValue().trim();
eventCRFBeans = eventCRFDAO.getEventCRFsByEventNameLimit(eventName, rowEnd - rowStart, rowStart);
} else if (filterSet.getFilter("eventDate") != null) {
eventDate = filterSet.getFilter("eventDate").getValue().trim();
eventCRFBeans = eventCRFDAO.getEventCRFsByEventDateLimit(studyId, eventDate, rowEnd - rowStart, rowStart);
} else if (filterSet.getFilter("crfStatus") != null) {
//
//SubjectEventStatus.getSubjectEventStatusIdByName(crfStatus)
crfStatus = filterSet.getFilter("crfStatus").getValue().trim();
//Get the study event for the event crf
eventCRFBeans = eventCRFDAO.getEventCRFsByCRFStatus(studyId, Integer.parseInt(crfStatus), rowEnd - rowStart, rowStart);
} else if (filterSet.getFilter("sdvStatus") != null) {
sdvStatus = filterSet.getFilter("sdvStatus").getValue().trim();
eventCRFBeans = eventCRFDAO.getEventCRFsByStudySDV(studyId, ("complete".equalsIgnoreCase(sdvStatus)), rowEnd - rowStart, rowStart);
} else if (filterSet.getFilter("studyIdentifier") != null) {
studyIdentifier = filterSet.getFilter("studyIdentifier").getValue().trim();
eventCRFBeans = eventCRFDAO.getEventCRFsByStudyIdentifier(studyId, studyId, studyIdentifier, rowEnd - rowStart, rowStart);
} else if (filterSet.getFilter("sdvRequirementDefinition") != null) {
ArrayList<Integer> reqs = new ArrayList<Integer>();
sdvRequirement = filterSet.getFilter("sdvRequirementDefinition").getValue().trim();
if (sdvRequirement.contains("&")) {
for (String requirement : sdvRequirement.split("&")) {
reqs.add(SourceDataVerification.getByI18nDescription(requirement.trim()).getCode());
}
} else {
reqs.add(SourceDataVerification.getByI18nDescription(sdvRequirement.trim()).getCode());
}
if (reqs.size() > 0) {
Integer[] a = { 1 };
eventCRFBeans = eventCRFDAO.getEventCRFsBySDVRequirement(studyId, studyId, rowEnd - rowStart, rowStart, reqs.toArray(a));
}
} else {
eventCRFBeans = eventCRFDAO.getEventCRFsByStudy(studyId, studyId, rowEnd - rowStart, rowStart);
}
*/
eventCRFBeans = eventCRFDAO.getWithFilterAndSort(studyId, studyId, filterSet, sortSet, rowStart, rowEnd);
return getSubjectRows(eventCRFBeans, request);
}
use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class SDVUtil method prepareSDVSelectElements.
public void prepareSDVSelectElements(HttpServletRequest request, StudyBean studyBean) {
//Study event statuses
List<String> studyEventStatuses = new ArrayList<String>();
for (org.akaza.openclinica.domain.Status stat : org.akaza.openclinica.domain.Status.values()) {
studyEventStatuses.add(stat.getDescription());
}
request.setAttribute("studyEventStatuses", studyEventStatuses);
//SDV requirements
List<String> sdvRequirements = new ArrayList<String>();
for (SourceDataVerification sdvRequire : SourceDataVerification.values()) {
sdvRequirements.add(sdvRequire.getDescription());
}
request.setAttribute("sdvRequirements", SourceDataVerification.values());
//study event definitions
StudyEventDefinitionDAO studyEventDefinitionDAO = new StudyEventDefinitionDAO(dataSource);
List<StudyEventDefinitionBean> studyEventDefinitionBeans = new ArrayList<StudyEventDefinitionBean>();
studyEventDefinitionBeans = studyEventDefinitionDAO.findAllByStudy(studyBean);
request.setAttribute("studyEventDefinitions", studyEventDefinitionBeans);
//study event status
request.setAttribute("studyEventStatuses", Status.toArrayList());
//event CRF status
request.setAttribute("eventCRFDStatuses", SubjectEventStatus.toArrayList());
StudyEventDAO studyEventDAO = new StudyEventDAO(dataSource);
List<StudyEventBean> studyEventBeans = studyEventDAO.findAllByStudy(studyBean);
List<EventCRFBean> eventCRFBeans = getAllEventCRFs(studyEventBeans);
SortedSet<String> eventCRFNames = new TreeSet<String>();
for (EventCRFBean bean : eventCRFBeans) {
eventCRFNames.add(getCRFName(bean.getCRFVersionId()));
}
request.setAttribute("eventCRFNames", eventCRFNames);
}
use of org.akaza.openclinica.bean.submit.EventCRFBean 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