use of org.jmesa.limit.Limit in project OpenClinica by OpenClinica.
the class DiscNotesSubjectStatisticsFactory method setDataAndLimitVariables.
@Override
public void setDataAndLimitVariables(TableFacade tableFacade) {
StudyBean study = this.getStudyBean();
Limit limit = tableFacade.getLimit();
ListDiscNotesSubjectFilter subjectFilter = getSubjectFilter(limit);
// subjectFilter.addFilter("dn.discrepancy_note_type_id", this.discNoteType);
StringBuffer constraints = new StringBuffer();
/* if (this.discNoteType > 0 && this.discNoteType < 10) {
constraints.append(" and dn.discrepancy_note_type_id=" + this.discNoteType);
}
if (this.resolutionStatusIds != null && this.resolutionStatusIds.size() > 0) {
String s = " and (";
for (Integer resolutionStatusId : this.resolutionStatusIds) {
s += "dn.resolution_status_id = " + resolutionStatusId + " or ";
}
s = s.substring(0, s.length() - 3) + " )";
subjectFilter.addFilter("dn.resolution_status_id", s);
constraints.append(s);
}
*/
if (!limit.isComplete()) {
// int totalRows = getStudySubjectDAO().getCountWithFilter(subjectFilter, study);
tableFacade.setTotalRows(6);
}
int rowStart = limit.getRowSelect().getRowStart();
int rowEnd = 6;
ListDiscNotesSubjectSort subjectSort = getSubjectSort(limit);
HashMap<Object, Map> items = (HashMap<Object, Map>) getDiscrepancyMap();
Collection<HashMap<Object, Object>> theItems = new ArrayList<HashMap<Object, Object>>();
Collection<HashMap<Object, Object>> theItemsKeys = new ArrayList<HashMap<Object, Object>>();
Collection<HashMap<Object, Object>> theItemsVals = new ArrayList<HashMap<Object, Object>>();
Iterator keyIt = null;
if (items.values().iterator().hasNext())
keyIt = items.values().iterator().next().keySet().iterator();
HashMap<Object, Object> theItem = new HashMap();
Set theKeys = items.keySet();
List<Object> existingKey = new ArrayList();
Iterator theKeysItr = theKeys.iterator();
while (keyIt.hasNext()) {
String key = "", val = "";
key = keyIt.next().toString();
for (Map<String, String[]> firstVals : items.values()) {
theItem = new HashMap();
Iterator it = firstVals.values().iterator();
// keyIt = firstVals.keySet().iterator();
String label = (String) theKeysItr.next();
while (it.hasNext()) {
theItem.put("_", key);
theItem.put(label, it.next());
}
theItems.add(theItem);
}
theItemsVals.addAll(theItems);
tableFacade.setItems(theItemsVals);
}
}
use of org.jmesa.limit.Limit in project OpenClinica by OpenClinica.
the class ListDiscNotesSubjectTableFactory method setDataAndLimitVariables.
@Override
public void setDataAndLimitVariables(TableFacade tableFacade) {
StudyBean study = this.getStudyBean();
Limit limit = tableFacade.getLimit();
ListDiscNotesSubjectFilter subjectFilter = getSubjectFilter(limit);
subjectFilter.addFilter("dn.discrepancy_note_type_id", this.discNoteType);
StringBuffer constraints = new StringBuffer();
if (this.discNoteType > 0 && this.discNoteType < 10) {
constraints.append(" and dn.discrepancy_note_type_id=" + this.discNoteType);
}
if (this.resolutionStatusIds != null && this.resolutionStatusIds.size() > 0) {
String s = " and (";
for (Integer resolutionStatusId : this.resolutionStatusIds) {
s += "dn.resolution_status_id = " + resolutionStatusId + " or ";
}
s = s.substring(0, s.length() - 3) + " )";
subjectFilter.addFilter("dn.resolution_status_id", s);
constraints.append(s);
}
if (!limit.isComplete()) {
int totalRows = getStudySubjectDAO().getCountWithFilter(subjectFilter, study);
tableFacade.setTotalRows(totalRows);
}
ListDiscNotesSubjectSort subjectSort = getSubjectSort(limit);
int rowStart = limit.getRowSelect().getRowStart();
int rowEnd = limit.getRowSelect().getRowEnd();
Collection<StudySubjectBean> items = getStudySubjectDAO().getWithFilterAndSort(study, subjectFilter, subjectSort, rowStart, rowEnd);
Collection<HashMap<Object, Object>> theItems = new ArrayList<HashMap<Object, Object>>();
boolean hasDN = false;
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());
// Get All study events for this study subject and then put list in
// HashMap with study event definition id as
// key and a list of study events as the value.
List<StudyEventBean> allStudyEventsForStudySubject = getStudyEventDAO().findAllByStudySubject(studySubjectBean);
HashMap<Integer, List<StudyEventBean>> allStudyEventsForStudySubjectBySedId = new HashMap<Integer, List<StudyEventBean>>();
theItem.put("isSignable", isSignable(allStudyEventsForStudySubject));
for (StudyEventBean studyEventBean : allStudyEventsForStudySubject) {
if (allStudyEventsForStudySubjectBySedId.get(studyEventBean.getStudyEventDefinitionId()) == null) {
ArrayList<StudyEventBean> a = new ArrayList<StudyEventBean>();
a.add(studyEventBean);
allStudyEventsForStudySubjectBySedId.put(studyEventBean.getStudyEventDefinitionId(), a);
} else {
allStudyEventsForStudySubjectBySedId.get(studyEventBean.getStudyEventDefinitionId()).add(studyEventBean);
}
}
for (StudyEventDefinitionBean studyEventDefinition : getStudyEventDefinitions()) {
List<StudyEventBean> studyEvents = allStudyEventsForStudySubjectBySedId.get(studyEventDefinition.getId());
SubjectEventStatus subjectEventStatus = null;
HashMap<ResolutionStatus, Integer> discCounts = new HashMap<ResolutionStatus, Integer>();
studyEvents = studyEvents == null ? new ArrayList<StudyEventBean>() : studyEvents;
if (studyEvents.size() < 1) {
subjectEventStatus = SubjectEventStatus.NOT_SCHEDULED;
} else {
for (StudyEventBean studyEventBean : studyEvents) {
discCounts = countAll(discCounts, studyEventBean, constraints, study.isSite(study.getParentStudyId()));
hasDN = hasDN == false ? discCounts.size() > 0 : hasDN;
if (studyEventBean.getSampleOrdinal() == 1) {
subjectEventStatus = studyEventBean.getSubjectEventStatus();
// break;
}
}
}
theItem.put("sed_" + studyEventDefinition.getId() + "_discCounts", discCounts);
theItem.put("sed_" + studyEventDefinition.getId(), subjectEventStatus.getId());
theItem.put("sed_" + studyEventDefinition.getId() + "_studyEvents", studyEvents);
theItem.put("sed_" + studyEventDefinition.getId() + "_object", studyEventDefinition);
}
theItems.add(theItem);
}
// Do not forget to set the items back on the tableFacade.
tableFacade.setItems(theItems);
setStudyHasDiscNotes(hasDN);
}
use of org.jmesa.limit.Limit in project OpenClinica by OpenClinica.
the class ListDiscNotesForCRFTableFactory method setDataAndLimitVariables.
@SuppressWarnings("unchecked")
@Override
public void setDataAndLimitVariables(TableFacade tableFacade) {
Limit limit = tableFacade.getLimit();
ListDiscNotesForCRFFilter listDiscNotesForCRF = getListEventsForSubjectFilter(limit);
listDiscNotesForCRF.addFilter("dn.discrepancy_note_type_id", this.discNoteType);
StringBuffer constraints = new StringBuffer();
if (this.discNoteType > 0 && this.discNoteType < 10) {
constraints.append(" and dn.discrepancy_note_type_id=" + this.discNoteType);
}
if (this.resolutionStatusIds != null && this.resolutionStatusIds.size() > 0) {
String s = " and (";
for (Integer resolutionStatusId : this.resolutionStatusIds) {
s += "dn.resolution_status_id = " + resolutionStatusId + " or ";
}
s = s.substring(0, s.length() - 3) + " )";
listDiscNotesForCRF.addFilter("dn.resolution_status_id", s);
constraints.append(s);
}
if (!limit.isComplete()) {
int totalRows = getStudySubjectDAO().getCountWithFilter(listDiscNotesForCRF, getStudyBean());
tableFacade.setTotalRows(totalRows);
}
ListDiscNotesForCRFSort eventsForSubjectSort = getListEventsForSubjectSort(limit);
int rowStart = limit.getRowSelect().getRowStart();
int rowEnd = limit.getRowSelect().getRowEnd();
Collection<StudySubjectBean> items = getStudySubjectDAO().getWithFilterAndSort(getStudyBean(), listDiscNotesForCRF, eventsForSubjectSort, rowStart, rowEnd);
Collection<HashMap<Object, Object>> theItems = new ArrayList<HashMap<Object, Object>>();
boolean hasDN = false;
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());
SubjectBean subjectBean = (SubjectBean) getSubjectDAO().findByPK(studySubjectBean.getSubjectId());
theItem.put("subject", subjectBean);
theItem.put("subject.charGender", subjectBean.getGender());
// Get EventCrfs for study Subject
List<EventCRFBean> eventCrfs = getEventCRFDAO().findAllByStudySubject(studySubjectBean.getId());
HashMap<String, EventCRFBean> crfAsKeyEventCrfAsValue = new HashMap<String, EventCRFBean>();
for (EventCRFBean eventCRFBean : eventCrfs) {
CRFBean crf = getCrfDAO().findByVersionId(eventCRFBean.getCRFVersionId());
crfAsKeyEventCrfAsValue.put(crf.getId() + "_" + eventCRFBean.getStudyEventId(), eventCRFBean);
}
// 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("event.startDate", null);
for (int i = 0; i < getCrfs(selectedStudyEventDefinition).size(); i++) {
CRFBean crf = getCrfs(selectedStudyEventDefinition).get(i);
HashMap<ResolutionStatus, Integer> discCounts = new HashMap<ResolutionStatus, Integer>();
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() + "_discCounts", discCounts);
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("event.startDate", studyEventBean.getCreatedDate());
for (int i = 0; i < getCrfs(selectedStudyEventDefinition).size(); i++) {
CRFBean crf = getCrfs(selectedStudyEventDefinition).get(i);
EventCRFBean eventCRFBean = crfAsKeyEventCrfAsValue.get(crf.getId() + "_" + studyEventBean.getId());
HashMap<ResolutionStatus, Integer> discCounts = new HashMap<ResolutionStatus, Integer>();
if (eventCRFBean != null) {
d.getProps().put("crf_" + crf.getId(), eventCRFBean.getStage());
d.getProps().put("crf_" + crf.getId() + "_eventCrf", eventCRFBean);
// List<DiscrepancyNoteBean> discs =
// getDiscrepancyNoteDAO().findAllByStudyEvent(studyEventBean);
List<DiscrepancyNoteBean> discs = getDiscrepancyNoteDAO().findAllParentItemNotesByEventCRFWithConstraints(eventCRFBean.getId(), constraints);
hasDN = hasDN == false ? discs != null && discs.size() > 0 : hasDN;
for (DiscrepancyNoteBean discrepancyNoteBean : discs) {
Integer value = discCounts.get(discrepancyNoteBean.getResStatus());
if (value != null) {
discCounts.put(discrepancyNoteBean.getResStatus(), ++value);
} else {
discCounts.put(discrepancyNoteBean.getResStatus(), 1);
}
}
d.getProps().put("crf_" + crf.getId() + "_discCounts", discCounts);
} else {
d.getProps().put("crf_" + crf.getId(), DataEntryStage.UNCOMPLETED);
d.getProps().put("crf_" + crf.getId() + "_eventCrf", null);
d.getProps().put("crf_" + crf.getId() + "_discCounts", discCounts);
}
d.getProps().put("crf_" + crf.getId() + "_crf", crf);
d.getProps().put("crf_" + crf.getId() + "_eventDefinitionCrf", eventDefinitionCrfs.get(i));
theItem.put("crf_" + crf.getId(), "");
}
events.add(d);
}
theItem.put("events", events);
theItem.put("event.status", "");
theItem.put("event.startDate", "");
theItems.add(theItem);
}
// Do not forget to set the items back on the tableFacade.
tableFacade.setItems(theItems);
this.setStudyHasDiscNotes(hasDN);
}
use of org.jmesa.limit.Limit in project OpenClinica by OpenClinica.
the class ListNotesTableFactory method setDataAndLimitVariables.
@Override
public void setDataAndLimitVariables(TableFacade tableFacade) {
// initialize i18n
resword = ResourceBundleProvider.getWordsBundle(getLocale());
resformat = ResourceBundleProvider.getFormatBundle(getLocale());
int parentStudyId = 0;
Limit limit = tableFacade.getLimit();
if (!limit.isComplete()) {
parentStudyId = currentStudy.getId();
//Build row count of various DN types
int totalRows = getDiscrepancyNoteDao().getSubjectDNCountWithFilter(getListNoteFilter(limit), parentStudyId);
totalRows += getDiscrepancyNoteDao().getStudySubjectDNCountWithFilter(getListNoteFilter(limit), parentStudyId);
totalRows += getDiscrepancyNoteDao().getStudyEventDNCountWithFilter(getListNoteFilter(limit), parentStudyId);
totalRows += getDiscrepancyNoteDao().getEventCrfDNCountWithFilter(getListNoteFilter(limit), parentStudyId);
totalRows += getDiscrepancyNoteDao().getItemDataDNCountWithFilter(getListNoteFilter(limit), parentStudyId);
tableFacade.setTotalRows(totalRows);
}
ViewNotesFilterCriteria filter = ViewNotesFilterCriteria.buildFilterCriteria(limit, getDateFormat(), discrepancyNoteTypeDropdown.getDecoder(), resolutionStatusDropdown.getDecoder());
notesSummary = getViewNotesService().calculateNotesSummary(getCurrentStudy(), filter);
int pageSize = limit.getRowSelect().getMaxRows();
int firstRecordShown = (limit.getRowSelect().getPage() - 1) * pageSize;
if (firstRecordShown > notesSummary.getTotal() && notesSummary.getTotal() != 0) {
// The page selected goes beyond the dataset size
// Move to the last page
limit.getRowSelect().setPage((int) Math.ceil((double) notesSummary.getTotal() / pageSize));
filter = ViewNotesFilterCriteria.buildFilterCriteria(limit, getDateFormat(), discrepancyNoteTypeDropdown.getDecoder(), resolutionStatusDropdown.getDecoder());
}
List<DiscrepancyNoteBean> items = getViewNotesService().listNotes(getCurrentStudy(), filter, ViewNotesSortCriteria.buildFilterCriteria(limit.getSortSet()));
this.setAllNotes(items);
Collection<HashMap<Object, Object>> theItems = new ArrayList<HashMap<Object, Object>>();
for (DiscrepancyNoteBean discrepancyNoteBean : items) {
HashMap<Object, Object> h = new HashMap<Object, Object>();
h.put("studySubject", discrepancyNoteBean.getStudySub());
h.put("studySubject.label", discrepancyNoteBean.getStudySub().getLabel());
h.put("discrepancyNoteBean.disType", discrepancyNoteBean.getDisType());
h.put("discrepancyNoteBean.resolutionStatus", discrepancyNoteBean.getResStatus());
h.put("age", discrepancyNoteBean.getAge());
h.put("days", discrepancyNoteBean.getDays());
h.put("siteId", discrepancyNoteBean.getSiteId());
h.put("discrepancyNoteBean", discrepancyNoteBean);
h.put("discrepancyNoteBean.createdDate", discrepancyNoteBean.getCreatedDate());
h.put("discrepancyNoteBean.updatedDate", discrepancyNoteBean.getUpdatedDate());
h.put("eventName", discrepancyNoteBean.getEventName());
h.put("eventStartDate", discrepancyNoteBean.getEventStart());
h.put("crfName", discrepancyNoteBean.getCrfName());
h.put("crfStatus", discrepancyNoteBean.getCrfStatus());
h.put("entityName", discrepancyNoteBean.getEntityName());
h.put("entityValue", discrepancyNoteBean.getEntityValue());
h.put("discrepancyNoteBean", discrepancyNoteBean);
h.put("discrepancyNoteBean.description", discrepancyNoteBean.getDescription());
h.put("discrepancyNoteBean.detailedNotes", discrepancyNoteBean.getDetailedNotes());
h.put("numberOfNotes", discrepancyNoteBean.getNumChildren());
h.put("discrepancyNoteBean.user", discrepancyNoteBean.getAssignedUser());
h.put("discrepancyNoteBean.entityType", discrepancyNoteBean.getEntityType());
h.put("discrepancyNoteBean.owner", discrepancyNoteBean.getOwner());
theItems.add(h);
setStudyHasDiscNotes(true);
}
tableFacade.setItems(theItems);
}
use of org.jmesa.limit.Limit in project OpenClinica by OpenClinica.
the class ListStudySubjectTableFactory method setDataAndLimitVariables.
@Override
public void setDataAndLimitVariables(TableFacade tableFacade) {
Limit limit = tableFacade.getLimit();
FindSubjectsFilter subjectFilter = getSubjectFilter(limit);
if (!limit.isComplete()) {
int totalRows = getStudySubjectDAO().getCountWithFilter(subjectFilter, getStudyBean());
tableFacade.setTotalRows(totalRows);
}
FindSubjectsSort subjectSort = getSubjectSort(limit);
int rowStart = limit.getRowSelect().getRowStart();
int rowEnd = limit.getRowSelect().getRowEnd();
Collection<StudySubjectBean> items = getStudySubjectDAO().getWithFilterAndSort(getStudyBean(), subjectFilter, subjectSort, 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());
theItem.put("studySubject.oid", studySubjectBean.getOid());
theItem.put("studySubject.secondaryLabel", studySubjectBean.getSecondaryLabel());
SubjectBean subjectBean = (SubjectBean) getSubjectDAO().findByPK(studySubjectBean.getSubjectId());
theItem.put("subject", subjectBean);
theItem.put("subject.charGender", subjectBean.getGender());
// Get All study events for this study subject and then put list in
// HashMap with study event definition id as
// key and a list of study events as the value.
List<StudyEventBean> allStudyEventsForStudySubject = getStudyEventDAO().findAllByStudySubject(studySubjectBean);
HashMap<Integer, List<StudyEventBean>> allStudyEventsForStudySubjectBySedId = new HashMap<Integer, List<StudyEventBean>>();
theItem.put("isSignable", isSignable(allStudyEventsForStudySubject, studySubjectBean));
for (StudyEventBean studyEventBean : allStudyEventsForStudySubject) {
if (allStudyEventsForStudySubjectBySedId.get(studyEventBean.getStudyEventDefinitionId()) == null) {
ArrayList<StudyEventBean> a = new ArrayList<StudyEventBean>();
a.add(studyEventBean);
allStudyEventsForStudySubjectBySedId.put(studyEventBean.getStudyEventDefinitionId(), a);
} else {
allStudyEventsForStudySubjectBySedId.get(studyEventBean.getStudyEventDefinitionId()).add(studyEventBean);
}
}
SubjectGroupMapBean 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;
for (StudyEventDefinitionBean studyEventDefinition : getStudyEventDefinitions()) {
List<StudyEventBean> studyEvents = allStudyEventsForStudySubjectBySedId.get(studyEventDefinition.getId());
SubjectEventStatus subjectEventStatus = null;
studyEvents = studyEvents == null ? new ArrayList<StudyEventBean>() : studyEvents;
if (studyEvents.size() < 1) {
subjectEventStatus = SubjectEventStatus.NOT_SCHEDULED;
} else {
for (StudyEventBean studyEventBean : studyEvents) {
if (studyEventBean.getSampleOrdinal() == 1) {
subjectEventStatus = studyEventBean.getSubjectEventStatus();
break;
}
}
}
theItem.put("sed_" + studyEventDefinition.getId(), subjectEventStatus.getId());
theItem.put("sed_" + studyEventDefinition.getId() + "_studyEvents", studyEvents);
theItem.put("sed_" + studyEventDefinition.getId() + "_object", studyEventDefinition);
}
theItems.add(theItem);
}
// Do not forget to set the items back on the tableFacade.
tableFacade.setItems(theItems);
}
Aggregations