public BradenScale getLastCompletedBradenScale(CareContextRefVo voCareContextRef) { DomainFactory factory = getDomainFactory(); StringBuffer hql = new StringBuffer("from BradenScale bs"); ArrayList markers = new ArrayList(); ArrayList values = new ArrayList(); if (voCareContextRef != null) { hql.append(" where "); hql.append(" bs.careContext.id = :cc"); markers.add("cc"); values.add(voCareContextRef.getID_CareContext()); } hql.append(" order by bs.dateTimeInitiated desc "); List list = factory.find(hql.toString(), markers, values); //Get only the first record (to optimise the work of the assembler) if(list != null && list.size() > 1) { Object firstItem = list.get(0); list.removeAll(list); list.add(firstItem); } BradenScaleCollection voBradenScaleColl = BradenScaleAssembler.createBradenScaleCollectionFromBradenScale(list); if (voBradenScaleColl != null && voBradenScaleColl.size() > 0) return voBradenScaleColl.get(0); return null; }
/** * lists Assessments */ public BradenScaleCollection listAssessments(Date dateFrom, Date dateTo, CareContextRefVo voCareContextRef) throws DomainInterfaceException { DomainFactory factory = getDomainFactory(); StringBuffer hql = new StringBuffer(" "); String query = "from BradenScale bs "; ArrayList markers = new ArrayList(); ArrayList values = new ArrayList(); String andStr = " "; boolean conditionFound = false; if (dateFrom != null && dateTo != null) { hql.append(" bs.dateTimeInitiated > :fromDate and bs.dateTimeInitiated < :toDate "); conditionFound = true; markers.add("fromDate"); markers.add("toDate"); values.add(dateFrom.addDay(-1).getDate()); values.add(dateTo.addDay(1).getDate()); // andStr = " and "; } else if (dateFrom != null) { hql.append(" bs.dateTimeInitiated > :fromDate "); conditionFound = true; markers.add("fromDate"); values.add(dateFrom.addDay(-1).getDate()); // andStr = " and "; } if (voCareContextRef != null) { if (conditionFound) hql.append(" and "); hql.append(andStr + " bs.careContext.id = :cc"); markers.add("cc"); values.add(voCareContextRef.getID_CareContext()); andStr = " and "; } if (markers.size() > 0) query += " where "; query += hql.toString(); List braden = factory.find(query, markers, values); return (BradenScaleAssembler.createBradenScaleCollectionFromBradenScale(braden).sort()); }
private void filterValueChanged() { //WDEV-2446 if (form.cmbFilter().getValue() != null) { BradenScaleCollection bradens = null; Date dateFrom = null; Date dateTo = null; if (form.cmbFilter().getValue().equals(LAST_WEEK)) { dateFrom = new Date(); dateFrom.addDay(-7); // dateTo = new Date(); } else if (form.cmbFilter().getValue().equals(LAST_MONTH)) { dateFrom = new Date(); dateFrom.addDay(-31); // dateTo = new Date(); } else if (form.cmbFilter().getValue().equals(LAST_YEAR)) { dateFrom = new Date(); dateFrom.addDay(-365); // dateTo = new Date(); } try { bradens = domain.listAssessments(dateFrom, dateTo, form.getGlobalContext().Core.getCurrentCareContext()); } catch (DomainInterfaceException e) { engine.showMessage(e.getMessage()); } form.getLocalContext().setBradenAssessments(bradens); form.getLocalContext().setGroupIndex(new Integer(0)); populateScreenFromData(); try { onCmbRecordToUpdateValueChanged(); } catch (PresentationLogicException e1) { engine.showMessage(e1.getMessage()); } form.getGlobalContext().Nursing.setBradenScaleSearchCriteria(getSearchCriteria());//WDEV-19389 } else { clearGridRows(); form.cmbRecordToUpdate().clear(); form.cmbRecordToUpdate().setValue(null); form.getLocalContext().setBradenAssessments(new BradenScaleCollection()); form.getLocalContext().setGroupIndex(new Integer(0)); populateScreenFromData(); form.getGlobalContext().Nursing.setBradenScaleSearchCriteria(null);//WDEV-19389 } }
private void filterValueChanged() { //WDEV-2446 if (form.cmbFilter().getValue() != null) { BradenScaleCollection bradens = null; Date dateFrom = null; Date dateTo = null; if (form.cmbFilter().getValue().equals(LAST_WEEK)) { dateFrom = new Date(); dateFrom.addDay(-7); // dateTo = new Date(); } else if (form.cmbFilter().getValue().equals(LAST_MONTH)) { dateFrom = new Date(); dateFrom.addDay(-31); // dateTo = new Date(); } else if (form.cmbFilter().getValue().equals(LAST_YEAR)) { dateFrom = new Date(); dateFrom.addDay(-365); // dateTo = new Date(); } try { bradens = domain.listAssessments(dateFrom, dateTo, form.getGlobalContext().Core.getCurrentCareContext()); } catch (DomainInterfaceException e) { engine.showMessage(e.getMessage()); } form.getLocalContext().setBradenAssessments(bradens); form.getLocalContext().setGroupIndex(new Integer(0)); populateScreenFromData(); try { onCmbRecordToUpdateValueChanged(); } catch (PresentationLogicException e1) { engine.showMessage(e1.getMessage()); } } else { clearGridRows(); form.cmbRecordToUpdate().clear(); form.cmbRecordToUpdate().setValue(null); form.getLocalContext().setBradenAssessments(new BradenScaleCollection()); form.getLocalContext().setGroupIndex(new Integer(0)); populateScreenFromData(); } }