public MiniNutritionalAssessmentCollection listAssessments(Date dateFrom,Date dateTo, CareContextLiteVo careContextref) throws DomainInterfaceException { DomainFactory factory = getDomainFactory(); String filter = " from MiniNutritionalAssessment mna "; StringBuffer filterString = new StringBuffer(); boolean conditionFound = false; ArrayList markerNames = new ArrayList(); ArrayList markerValues = new ArrayList(); if (dateFrom != null && dateTo != null) { filterString.append(" mna.dateTimeInitiated > :fromDate and mna.dateTimeInitiated < :toDate "); conditionFound = true; markerNames.add("fromDate"); markerNames.add("toDate"); markerValues.add(dateFrom.addDay(-1).getDate()); markerValues.add(dateTo.addDay(1).getDate()); } else if (dateFrom != null) { filterString.append(" mna.dateTimeInitiated > :fromDate "); conditionFound = true; markerNames.add("fromDate"); markerValues.add(dateFrom.addDay(-1).getDate()); } if (careContextref != null) { if (conditionFound) filterString.append(" and "); filterString.append(" mna.careContext.id = :careContext "); markerNames.add("careContext"); markerValues.add(careContextref.getID_CareContext()); } String[] names = new String[markerNames.size()]; markerNames.toArray(names); filter += " where "; filter += filterString.toString(); List procs = factory.find(filter, markerNames, markerValues); return MiniNutritionalAssessmentAssembler.createMiniNutritionalAssessmentCollectionFromMiniNutritionalAssessment(procs).sort(); }
private void filterValueChanged() { MiniNutritionalAssessmentCollection mnas = null; Date dateFrom = null; Date dateTo = null; if (form.cmbFilter().getValue().equals(LAST_WEEK)) { dateFrom = new Date(); dateFrom.addDay(-7); } else if (form.cmbFilter().getValue().equals(LAST_MONTH)) { dateFrom = new Date(); dateFrom.addDay(-31); } else if (form.cmbFilter().getValue().equals(LAST_YEAR)) { dateFrom = new Date(); dateFrom.addDay(-365); } try { mnas = domain.listAssessments(dateFrom, dateTo, form.getGlobalContext().Core.getCurrentCareContext()); } catch (DomainInterfaceException e) { engine.showMessage(e.getMessage()); } form.getLocalContext().setMNAAssessments(mnas); form.getLocalContext().setGroupIndex(new Integer(0)); populateScreenFromData(); try { onCmbRecordToUpdateValueChanged(); } catch (PresentationLogicException e1) { engine.showMessage(e1.getMessage()); } }