/** * get admission assessment, which will include assessment component care plans */ public AdmissionAssessmentVo getAdmissionAssessmentByCareContext(CareContextRefVo voCareContextRef) { DomainFactory factory = getDomainFactory(); // get admission assessment String hql = " from AdmissionAssessment admAss"; hql += (" where admAss.careContext.id = " + voCareContextRef.getID_CareContext() + " and admAss.isRIE is null "); AdmissionAssessmentVo admissionAssessmentVo = null; List admAss = factory.find(hql); for (Iterator iter = admAss.iterator(); iter.hasNext();) { AdmissionAssessment domAdmissionAssess = (AdmissionAssessment) iter.next(); admissionAssessmentVo = AdmissionAssessmentVoAssembler.create(domAdmissionAssess); break; } if (admissionAssessmentVo == null) return null; // now get associated care plans //String hqlQuery = " from CarePlan cp "; String hqlQuery = "select c1_1 from CarePlan as c1_1 left join c1_1.assessmentComponent as a1_1 left join a1_1.assessment as a2_1 "; StringBuffer condStr = new StringBuffer(); ArrayList<String> markerNames = new ArrayList<String>(); ArrayList<Integer> markerValues = new ArrayList<Integer>(); if(voCareContextRef != null) { condStr.append(" c1_1.careContext.id = :care and c1_1.assessmentComponent is not null "); markerNames.add("care"); markerValues.add(voCareContextRef.getID_CareContext()); } condStr.append(" and a2_1.isRIE is null "); if (markerNames.size() > 0) hqlQuery += " where "; hqlQuery += condStr.toString(); List careplans = factory.find(hqlQuery,markerNames,markerValues); // now that we have care plans, create assessment component care plans, set in vo, and return admissionAssessmentVo.setComponentCarePlans(AssessmentComponentCarePlansAssembler.createAssessmentComponentCarePlansCollectionFromCarePlan(careplans).sort(SortOrder.ASCENDING)); return admissionAssessmentVo; }