use of org.akaza.openclinica.controller.helper.table.SubjectSDVContainer in project OpenClinica by OpenClinica.
the class SDVUtil method setDataAndLimitVariablesSubjects.
public int setDataAndLimitVariablesSubjects(TableFacade tableFacade, int studyId, int studySubjectId, HttpServletRequest request) {
Limit limit = tableFacade.getLimit();
FilterSet filterSet = limit.getFilterSet();
int totalRows = getTotalRowCountSubjects(filterSet, studyId, studySubjectId);
tableFacade.setTotalRows(totalRows);
SortSet sortSet = limit.getSortSet();
int rowStart = limit.getRowSelect().getRowStart();
int rowEnd = limit.getRowSelect().getRowEnd();
Collection<SubjectSDVContainer> items = getFilteredItemsSubject(filterSet, sortSet, rowStart, rowEnd, studyId, studySubjectId, request);
tableFacade.setItems(items);
return totalRows;
}
use of org.akaza.openclinica.controller.helper.table.SubjectSDVContainer in project OpenClinica by OpenClinica.
the class SDVUtil method getSubjectAggregateRows.
public Collection<SubjectSDVContainer> getSubjectAggregateRows(List<StudySubjectBean> studySubjectBeans) {
if (studySubjectBeans == null || studySubjectBeans.isEmpty()) {
return new ArrayList<SubjectSDVContainer>();
}
Collection<SubjectSDVContainer> allRows = new ArrayList<SubjectSDVContainer>();
SubjectSDVContainer tempSDVBean = null;
//The first row is the "select all" checkbox row
tempSDVBean = new SubjectSDVContainer();
String firstRowActions = "Select All <input type=checkbox name='checkAll' onclick='selectAllChecks(this.form)'/>";
tempSDVBean.setSdvStatusActions(firstRowActions);
allRows.add(tempSDVBean);
StringBuilder actions;
for (StudySubjectBean studySubjectBean : studySubjectBeans) {
tempSDVBean = new SubjectSDVContainer();
tempSDVBean.setStudySubjectId(studySubjectBean.getId() + "");
//studySubjectBean.getStatus().getName() : TODO: fix ResourceBundle problem
tempSDVBean.setStudySubjectStatus("subject status");
tempSDVBean.setNumberOfCRFsSDV("0");
tempSDVBean.setPercentageOfCRFsSDV("0");
tempSDVBean.setGroup("group");
actions = new StringBuilder("<input class='sdvCheckbox' type='checkbox' name=");
actions.append("'sdvCheck").append(studySubjectBean.getId()).append("'/>  ");
actions.append(VIEW_ICON_FORSUBJECT_PREFIX).append(studySubjectBean.getId()).append(getIconForSubjectSufix());
tempSDVBean.setSdvStatusActions(actions.toString());
allRows.add(tempSDVBean);
}
return allRows;
}
use of org.akaza.openclinica.controller.helper.table.SubjectSDVContainer in project OpenClinica by OpenClinica.
the class SDVUtil method setDataAndLimitVariables.
public void setDataAndLimitVariables(TableFacade tableFacade, int studyId, HttpServletRequest request) {
Limit limit = tableFacade.getLimit();
EventCRFSDVFilter eventCRFSDVFilter = getEventCRFSDVFilter(limit, studyId);
WebContext context = tableFacade.getWebContext();
String restore = request.getAttribute(limit.getId() + "_restore") + "";
if (!limit.isComplete()) {
int totalRows = getTotalRowCount(eventCRFSDVFilter, studyId);
tableFacade.setTotalRows(totalRows);
} else if (restore != null && "true".equalsIgnoreCase(restore)) {
int totalRows = getTotalRowCount(eventCRFSDVFilter, studyId);
int pageNum = limit.getRowSelect().getPage();
int maxRows = limit.getRowSelect().getMaxRows();
tableFacade.setMaxRows(maxRows);
tableFacade.setTotalRows(totalRows);
limit.getRowSelect().setPage(pageNum);
}
EventCRFSDVSort eventCRFSDVSort = getEventCRFSDVSort(limit);
int rowStart = limit.getRowSelect().getRowStart();
int rowEnd = limit.getRowSelect().getRowEnd();
//Collection<StudySubjectBean> items = getStudySubjectDAO().getWithFilterAndSort(getStudyBean(), studySubjectSDVFilter, subjectSort, rowStart, rowEnd);
Collection<SubjectSDVContainer> items = getFilteredItems(eventCRFSDVFilter, eventCRFSDVSort, rowStart, rowEnd, studyId, request);
tableFacade.setItems(items);
/*
Limit limit = tableFacade.getLimit();
FilterSet filterSet = limit.getFilterSet();
int totalRows = getTotalRowCount(filterSet, studyId);
tableFacade.setTotalRows(totalRows);
SortSet sortSet = limit.getSortSet();
int rowStart = limit.getRowSelect().getRowStart();
int rowEnd = limit.getRowSelect().getRowEnd();
Collection<SubjectSDVContainer> items = getFilteredItems(filterSet, sortSet, rowStart, rowEnd, studyId, request);
tableFacade.setItems(items);
*/
}
use of org.akaza.openclinica.controller.helper.table.SubjectSDVContainer in project OpenClinica by OpenClinica.
the class SDVUtil method getSubjectRows.
/*
Generate the rows for the study table. Each row represents an Event CRF.
*/
public Collection<SubjectSDVContainer> getSubjectRows(List<EventCRFBean> eventCRFBeans, HttpServletRequest request) {
if (eventCRFBeans == null || eventCRFBeans.isEmpty()) {
return new ArrayList<SubjectSDVContainer>();
}
getEventNamesForEventCRFs(eventCRFBeans);
StudySubjectDAO studySubjectDAO = new StudySubjectDAO(dataSource);
SubjectDAO subjectDAO = new SubjectDAO(dataSource);
StudyDAO studyDAO = new StudyDAO(dataSource);
StudyEventDAO studyEventDAO = new StudyEventDAO(dataSource);
EventDefinitionCRFDAO eventDefinitionCRFDAO = new EventDefinitionCRFDAO(dataSource);
StudySubjectBean studySubjectBean = null;
SubjectBean subjectBean = null;
StudyEventBean studyEventBean = null;
StudyBean studyBean = null;
EventDefinitionCRFBean eventDefinitionCRFBean = null;
Collection<SubjectSDVContainer> allRows = new ArrayList<SubjectSDVContainer>();
SubjectSDVContainer tempSDVBean = null;
StringBuilder actions = new StringBuilder("");
for (EventCRFBean crfBean : eventCRFBeans) {
tempSDVBean = new SubjectSDVContainer();
studySubjectBean = (StudySubjectBean) studySubjectDAO.findByPK(crfBean.getStudySubjectId());
studyEventBean = (StudyEventBean) studyEventDAO.findByPK(crfBean.getStudyEventId());
subjectBean = (SubjectBean) subjectDAO.findByPK(studySubjectBean.getSubjectId());
//find out the study's identifier
studyBean = (StudyBean) studyDAO.findByPK(studySubjectBean.getStudyId());
tempSDVBean.setStudyIdentifier(studyBean.getIdentifier());
eventDefinitionCRFBean = eventDefinitionCRFDAO.findByStudyEventIdAndCRFVersionId(studyBean, studyEventBean.getId(), crfBean.getCRFVersionId());
SourceDataVerification sourceData = eventDefinitionCRFBean.getSourceDataVerification();
if (sourceData != null) {
tempSDVBean.setSdvRequirementDefinition(sourceData.toString());
} else {
tempSDVBean.setSdvRequirementDefinition("");
}
tempSDVBean.setCrfNameVersion(getCRFName(crfBean.getCRFVersionId()) + "/ " + getCRFVersionName(crfBean.getCRFVersionId()));
if (crfBean.getStatus() != null) {
Integer status = crfBean.getStage().getId();
if (studyEventBean.getSubjectEventStatus() == SubjectEventStatus.LOCKED || studyEventBean.getSubjectEventStatus() == SubjectEventStatus.STOPPED || studyEventBean.getSubjectEventStatus() == SubjectEventStatus.SKIPPED) {
status = DataEntryStage.LOCKED.getId();
}
tempSDVBean.setCrfStatus(getCRFStatusIconPath(status, request, studySubjectBean.getId(), crfBean.getId(), crfBean.getCRFVersionId()));
}
tempSDVBean.setStudyEventStatus(studyEventBean.getStatus().getName());
//TODO: I18N Date must be formatted properly
Locale locale = LocaleResolver.getLocale(request);
SimpleDateFormat sdformat = I18nFormatUtil.getDateFormat(locale);
if (studySubjectBean.getEnrollmentDate() != null) {
tempSDVBean.setEnrollmentDate(sdformat.format(studySubjectBean.getEnrollmentDate()));
} else {
//tempSDVBean.setEnrollmentDate("unknown");
}
//TODO: I18N Date must be formatted properly
//Fix OC 1888
StudyEventDAO sedao = new StudyEventDAO(dataSource);
StudyEventBean seBean = (StudyEventBean) sedao.findByPK(crfBean.getStudyEventId());
tempSDVBean.setEventDate(sdformat.format(seBean.getDateStarted()));
// if (crfBean.getCreatedDate() != null) {
// tempSDVBean.setEventDate(sdformat.format(crfBean.getCreatedDate()));
// } else {
// //tempSDVBean.setEventDate("unknown");
//
// }
//crfBean.getEventName()
tempSDVBean.setEventName(crfBean.getEventName());
//The checkbox is next to the study subject id
StringBuilder sdvStatus = new StringBuilder("");
//"This Event CRF has been Source Data Verified. If you uncheck this box, you are removing Source Data Verification for the Event CRF and you will have to repeat the process. Select OK to continue and Cancel to cancel this transaction."
if (crfBean.isSdvStatus()) {
sdvStatus.append("<center><a href='javascript:void(0)' onclick='prompt(document.sdvForm,");
sdvStatus.append(crfBean.getId());
sdvStatus.append(")'>");
sdvStatus.append(getIconForSdvStatusPrefix()).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(CHECKBOX_NAME).append(crfBean.getId()).append("' /></center>");
}
//sdvStatus.append(studySubjectBean.getLabel());
tempSDVBean.setSdvStatus(sdvStatus.toString());
tempSDVBean.setStudySubjectId(studySubjectBean.getLabel());
if (subjectBean != null) {
tempSDVBean.setPersonId(subjectBean.getUniqueIdentifier());
} else {
tempSDVBean.setPersonId("");
}
//studySubjectBean.getSecondaryLabel()
tempSDVBean.setSecondaryId(studySubjectBean.getSecondaryLabel());
String statusName = studySubjectBean.getStatus().getName();
int statusId = studySubjectBean.getStatus().getId();
if (statusName != null) {
tempSDVBean.setStudySubjectStatus(statusName);
}
//TODO: I18N Date must be formatted properly
if (crfBean.getUpdatedDate() != null) {
tempSDVBean.setLastUpdatedDate(sdformat.format(crfBean.getUpdatedDate()));
} else {
tempSDVBean.setLastUpdatedDate("unknown");
}
if (crfBean.getUpdater() != null) {
tempSDVBean.setLastUpdatedBy(crfBean.getUpdater().getFirstName() + " " + crfBean.getUpdater().getLastName());
}
actions = new StringBuilder("");
//append("<input type='hidden' name='crfId' value='").append(crfBean.getId()).append("'").append("/> ")
if (!crfBean.isSdvStatus()) {
StringBuilder jsCodeString = new StringBuilder("this.form.method='GET'; this.form.action='").append(request.getContextPath()).append("/pages/handleSDVGet").append("';").append("this.form.crfId.value='").append(crfBean.getId()).append("';").append("this.form.submit();");
actions.append("<input type=\"submit\" class=\"button_medium\" value=\"SDV\" name=\"sdvSubmit\" ").append("onclick=\"").append(jsCodeString.toString()).append("\" />");
}
//Only implement the view icon if it is a event crf request
/*String bool = (String) request.getAttribute("isViewSubjectRequest");
if(! "y".equalsIgnoreCase(bool)){
StringBuilder urlPrefix = new StringBuilder("<a href='javascript:void(0)' onclick=\"document.location.href='");
StringBuilder path = new StringBuilder(request.getContextPath()).append("/pages/viewAllSubjectSDV?studyId=").append(studySubjectBean.getStudyId()).append("&studySubjectId=");
path.append(studySubjectBean.getId());
urlPrefix.append(path).append("'\">");
actions.append(" ").append(urlPrefix).append(VIEW_ICON_HTML).append("</a>");
}*/
tempSDVBean.setSdvStatusActions(actions.toString());
allRows.add(tempSDVBean);
}
return allRows;
}
use of org.akaza.openclinica.controller.helper.table.SubjectSDVContainer in project OpenClinica by OpenClinica.
the class SDVUtil method renderSubjectsAggregateTable.
public String renderSubjectsAggregateTable(int studyId, HttpServletRequest request) {
List<StudySubjectBean> studySubjectBeans = new ArrayList<StudySubjectBean>();
StudySubjectDAO studySubjectDAO = new StudySubjectDAO(dataSource);
studySubjectBeans = studySubjectDAO.findAllByStudyId(studyId);
Collection<SubjectSDVContainer> items = getSubjectAggregateRows(studySubjectBeans);
//The number of items represents the total number of returned rows
int totalRowCount = 0;
if (items != null && items.size() > 0) {
totalRowCount = items.size();
}
TableFacade tableFacade = createTableFacade("sdv", request);
//set to the total row count
if (totalRowCount > 1) {
tableFacade.setMaxRowsIncrements(15, 50, totalRowCount);
}
tableFacade.setColumnProperties("studySubjectId", "studySubjectStatus", "numberOfCRFsSDV", "percentageOfCRFsSDV", "group", "sdvStatusActions");
tableFacade.setItems(items);
//Fix column titles
HtmlTable table = (HtmlTable) tableFacade.getTable();
//i18n caption; TODO: convert to Spring messages
ResourceBundle resword = ResourceBundle.getBundle("org.akaza.openclinica.i18n.words", LocaleResolver.getLocale(request));
String[] allTitles = { resword.getString("study_subject_ID"), resword.getString("study_subject_status"), resword.getString("num_CRFs_SDV"), resword.getString("porc_CRFs_SDV"), resword.getString("group") };
setTitles(allTitles, table);
table.getTableRenderer().setWidth("800");
return tableFacade.render();
}
Aggregations