/** * getSystemReview for a clinical contact. */ public ims.clinical.vo.SystemReviewVo getSystemReview(ims.core.vo.ClinicalContactShortVo voClinicalContactShort) { if(voClinicalContactShort == null || voClinicalContactShort.getID_ClinicalContact() == null) throw new DomainRuntimeException("Contact not provided for get call. "); DomainFactory factory = getDomainFactory(); List sysReviewList = factory.find(" from SystemReview sr where sr.clinicalContact.id = :idCC )", new String[]{"idCC" }, new Object[]{ voClinicalContactShort.getID_ClinicalContact()}); SystemReviewVoCollection voColl = SystemReviewVoAssembler.createSystemReviewVoCollectionFromSystemReview(sysReviewList); if(voColl.size()>0) return voColl.get(0); else return null; }
/** * saveSystemReview */ public ims.clinical.vo.SystemReviewVo saveSystemReview(ims.clinical.vo.SystemReviewVo voSystemReview) throws StaleObjectException { if (!voSystemReview.isValidated()) { throw new DomainRuntimeException("Systemreview VO has not been validated."); } DomainFactory factory = getDomainFactory(); StringBuffer hql = new StringBuffer("from SystemReview sr "); if(voSystemReview.getID_SystemReview() == null) hql.append(" where (sr.clinicalContact.id = " + voSystemReview.getClinicalContact().getID_ClinicalContact() + ")"); else hql.append(" where (sr.clinicalContact.id = " + voSystemReview.getClinicalContact().getID_ClinicalContact() + ") and sr.id <> " + voSystemReview.getID_SystemReview()); List list = (factory.find(hql.toString())); if(list.size() > 0) throw new DomainRuntimeException("A record exists for this clinical contact, the screen will be refreshed"); SystemReview doSystemReview = SystemReviewVoAssembler.extractSystemReview(factory, voSystemReview); factory.save(doSystemReview); return SystemReviewVoAssembler.create(doSystemReview); }