public CopyCarePlanVoCollection listCarePlans(CareContextRefVo voCurrentCareContext, CarePlanStatus currentStatus, Boolean bCarePlansFromOtherContexts) { if (voCurrentCareContext == null || voCurrentCareContext.getID_CareContext()==null) throw new CodingRuntimeException("Current Care Context not available."); DomainFactory factory = getDomainFactory(); String hqlQuery = " from CarePlan cp "; StringBuffer condStr = new StringBuffer(); ArrayList<String> markerNames = new ArrayList<String>(); ArrayList<Integer> markerValues = new ArrayList<Integer>(); CopyCarePlanVoCollection voColl = null; condStr.append(" where "); if (voCurrentCareContext != null) { if (!bCarePlansFromOtherContexts) { condStr.append(" cp.careContext.id = :rcc"); markerNames.add("rcc"); markerValues.add(voCurrentCareContext.getID_CareContext()); } else { condStr.append(" cp.careContext.episodeOfCare.careSpell.patient.id = :patientId"); markerNames.add("patientId"); markerValues.add(getPatientId(voCurrentCareContext)); } } if (currentStatus != null) { if (currentStatus.getStatus() != null) { condStr.append(" and cp.currentCarePlanStatus.status.id = :status"); markerNames.add("status"); markerValues.add(new Integer(currentStatus.getStatus().getId())); } } hqlQuery += condStr.toString(); List<?> careplans = factory.find(hqlQuery, markerNames, markerValues); if (careplans != null) voColl = (CopyCarePlanVoAssembler.createCopyCarePlanVoCollectionFromCarePlan(careplans)); if (voColl != null) voColl.sort(SortOrder.ASCENDING); return voColl; }