@SuppressWarnings("rawtypes") public PatientDocumentForICPReportsVoCollection getPatientDocuments(PatientICPRefVo patientICPRef) { if(patientICPRef == null || !patientICPRef.getID_PatientICPIsNotNull()) throw new CodingRuntimeException("Parameter patientIcpRef cannot be null !"); Integer careContextId = null; DomainFactory factory = getDomainFactory(); String hql = "select p1_1.careContext.id from PatientICP as p1_1 where (p1_1.id = :ID)"; List list = factory.find(hql, new String[] {"ID"}, new Object[] {patientICPRef.getID_PatientICP()}); if(list != null && list.size() > 0) { careContextId = (Integer)list.get(0); } if(careContextId == null) { //it should never get here as every patientICP has a care context System.out.println("Could not get careContext for patientICP " + patientICPRef.getID_PatientICP()); } hql = "select pdoc from CatsReferral as cats join cats.referralDocuments as pdoc where (cats.careContext.id = :CCID)"; list = factory.find(hql, new String[] {"CCID"}, new Object[] {careContextId}); return PatientDocumentForICPReportsVoAssembler.createPatientDocumentForICPReportsVoCollectionFromPatientDocument(list); }