/** * Lists Clinic Notes for the given EpisodeId and Date Range - also receives * a filter for all or active only true = all false = active only */ public NursingClinicalNotesListVoCollection listClinicNotes(Date fromDate,Date toDate, Boolean activeOnly, CareContextShortVo careContextVo) { DomainFactory factory = getDomainFactory(); String filter = "from NursingClinicalNotes t "; String andStr = " "; ArrayList markerNames = new ArrayList(); ArrayList markerValues = new ArrayList(); StringBuffer filterString = new StringBuffer(); boolean conditionFound = false; if (fromDate != null && toDate != null) { filterString.append(" t.recordingDateTime >= :fromDate and t.recordingDateTime < :toDate "); conditionFound = true; markerNames.add("fromDate"); markerValues.add(fromDate.getDate()); // Adding a day to the toDate will ensure everything up to 23:59:59 // recorded on toDate will be returned markerNames.add("toDate"); markerValues.add(toDate.copy().addDay(1).getDate()); andStr = " and "; } else if (fromDate != null) { filterString.append(" t.recordingDateTime >= :fromDate "); filterString.append(" and t.recordingDateTime < :toDate "); conditionFound = true; markerNames.add("fromDate"); markerNames.add("toDate"); markerValues.add(fromDate.getDate()); markerValues.add(fromDate.copy().addDay(1).getDate()); andStr = " and "; } if (careContextVo != null) { if (conditionFound) filterString.append(" and "); filterString.append(" t.careContext.id = :CareContext "); markerNames.add("CareContext"); markerValues.add(careContextVo.getID_CareContext()); andStr = " and "; // commented out as attribute no longer part of BO if (activeOnly != null && activeOnly.booleanValue()) { //filterString.append(andStr + " t.currentStatus.correctionConfirmed != :isActive"); filterString.append(andStr + " t.isCorrected <> :isActive"); //WDEV-15049 markerNames.add("isActive"); markerValues.add(Boolean.TRUE); } } // We only want to list Nursing Clinical notes here. // filterString.append(andStr + " t.class = NursingClinicalNotes"); String[] names = new String[markerNames.size()]; markerNames.toArray(names); filter += " where "; filter += filterString.toString(); List notes = factory.find(filter, markerNames, markerValues,1000); return NursingClinicalNotesListVoAssembler.createNursingClinicalNotesListVoCollectionFromNursingClinicalNotes(notes).sort(SortOrder.DESCENDING); }