use of org.akaza.openclinica.dao.managestudy.ListEventsForSubjectSort in project OpenClinica by OpenClinica.
the class ListEventsForSubjectTableFactory method getListEventsForSubjectSort.
protected ListEventsForSubjectSort getListEventsForSubjectSort(Limit limit) {
ListEventsForSubjectSort listEventsForSubjectSort = new ListEventsForSubjectSort();
SortSet sortSet = limit.getSortSet();
Collection<Sort> sorts = sortSet.getSorts();
for (Sort sort : sorts) {
String property = sort.getProperty();
String order = sort.getOrder().toParam();
listEventsForSubjectSort.addSort(property, order);
}
return listEventsForSubjectSort;
}
use of org.akaza.openclinica.dao.managestudy.ListEventsForSubjectSort in project OpenClinica by OpenClinica.
the class ListEventsForSubjectTableFactory method setDataAndLimitVariables.
@SuppressWarnings("unchecked")
@Override
public void setDataAndLimitVariables(TableFacade tableFacade) {
Limit limit = tableFacade.getLimit();
ListEventsForSubjectFilter eventsForSubjectFilter = getListEventsForSubjectFilter(limit);
// Used on Initial sort without filters
if (!limit.isComplete()) {
int totalRows = getStudySubjectDAO().getCountWithFilter(eventsForSubjectFilter, getStudyBean());
tableFacade.setTotalRows(totalRows);
}
// Preprocess the studysubjectbean list to find subjects with crf status
ListEventsForSubjectSort eventsForSubjectSort = getListEventsForSubjectSort(limit);
int rowStart = limit.getRowSelect().getRowStart();
int rowEnd = limit.getRowSelect().getRowEnd();
Collection<StudySubjectBean> items = getStudySubjectDAO().getWithFilterAndSort(getStudyBean(), eventsForSubjectFilter, eventsForSubjectSort, rowStart, rowEnd);
Collection<HashMap<Object, Object>> theItems = new ArrayList<HashMap<Object, Object>>();
for (StudySubjectBean studySubjectBean : items) {
HashMap<Object, Object> theItem = new HashMap<Object, Object>();
theItem.put("studySubject", studySubjectBean);
theItem.put("studySubject.label", studySubjectBean.getLabel());
theItem.put("studySubject.status", studySubjectBean.getStatus());
theItem.put("enrolledAt", ((StudyBean) getStudyDAO().findByPK(studySubjectBean.getStudyId())).getIdentifier());
SubjectBean subjectBean = (SubjectBean) getSubjectDAO().findByPK(studySubjectBean.getSubjectId());
theItem.put("subject", subjectBean);
theItem.put("subject.charGender", subjectBean.getGender());
// study group classes
SubjectGroupMapBean subjectGroupMapBean = new SubjectGroupMapBean();
for (StudyGroupClassBean studyGroupClass : getStudyGroupClasses()) {
subjectGroupMapBean = getSubjectGroupMapDAO().findAllByStudySubjectAndStudyGroupClass(studySubjectBean.getId(), studyGroupClass.getId());
if (null != subjectGroupMapBean) {
theItem.put("sgc_" + studyGroupClass.getId(), subjectGroupMapBean.getStudyGroupId());
theItem.put("grpName_sgc_" + studyGroupClass.getId(), subjectGroupMapBean.getStudyGroupName());
}
}
subjectGroupMapBean = null;
HashMap<String, EventCRFBean> crfAsKeyEventCrfAsValue = getEventsCrfsForStudySubject(studySubjectBean);
// Get the event Status
List<StudyEventBean> eventsForStudySubjectAndEventDefinitions = getStudyEventDAO().findAllByDefinitionAndSubject(selectedStudyEventDefinition, studySubjectBean);
List<DisplayBean> events = new ArrayList<DisplayBean>();
// study event size < 1
if (eventsForStudySubjectAndEventDefinitions.size() < 1) {
DisplayBean d = new DisplayBean();
d.getProps().put("event", null);
d.getProps().put("event.status", SubjectEventStatus.NOT_SCHEDULED);
d.getProps().put("studySubject.createdDate", null);
for (int i = 0; i < getCrfs(selectedStudyEventDefinition).size(); i++) {
CRFBean crf = getCrfs(selectedStudyEventDefinition).get(i);
d.getProps().put("crf_" + crf.getId(), DataEntryStage.UNCOMPLETED);
d.getProps().put("crf_" + crf.getId() + "_eventCrf", null);
d.getProps().put("crf_" + crf.getId() + "_crf", crf);
// d.getProps().put("crf_" + crf.getId() + "_eventDefinitionCrf", eventDefinitionCrfs.get(i));
d.getProps().put("crf_" + crf.getId() + "_eventDefinitionCrf", getEventDefinitionCRFBean(selectedStudyEventDefinition.getId(), crf, studySubjectBean));
theItem.put("crf_" + crf.getId(), "");
}
events.add(d);
}
// study event size >0
for (StudyEventBean studyEventBean : eventsForStudySubjectAndEventDefinitions) {
DisplayBean d = new DisplayBean();
d.getProps().put("event", studyEventBean);
d.getProps().put("event.status", studyEventBean.getSubjectEventStatus());
d.getProps().put("studySubject.createdDate", studyEventBean.getDateStarted());
for (int i = 0; i < getCrfs(selectedStudyEventDefinition).size(); i++) {
CRFBean crf = getCrfs(selectedStudyEventDefinition).get(i);
EventCRFBean eventCRFBean = crfAsKeyEventCrfAsValue.get(crf.getId() + "_" + studyEventBean.getId());
if (eventCRFBean != null) {
d.getProps().put("crf_" + crf.getId(), eventCRFBean.getStage());
d.getProps().put("crf_" + crf.getId() + "_eventCrf", eventCRFBean);
} else {
d.getProps().put("crf_" + crf.getId(), DataEntryStage.UNCOMPLETED);
d.getProps().put("crf_" + crf.getId() + "_eventCrf", null);
}
d.getProps().put("crf_" + crf.getId() + "_crf", crf);
// d.getProps().put("crf_" + crf.getId() + "_eventDefinitionCrf", eventDefinitionCrfs.get(i));
d.getProps().put("crf_" + crf.getId() + "_eventDefinitionCrf", getEventDefinitionCRFBean(selectedStudyEventDefinition.getId(), crf, studySubjectBean));
theItem.put("crf_" + crf.getId(), "");
}
events.add(d);
}
theItem.put("events", events);
theItem.put("event.status", "");
theItem.put("studySubject.createdDate", "");
theItem.put("webappContext", tableFacade.getWebContext().getContextPath());
theItems.add(theItem);
}
// Do not forget to set the items back on the tableFacade.
tableFacade.setItems(theItems);
}
Aggregations