/** * Save a rehab Record for a Clinical Contact */ public ims.therapies.vo.RehabilitationVo saveRehabVo(ims.therapies.vo.RehabilitationVo voRehab) throws ims.domain.exceptions.StaleObjectException, ims.domain.exceptions.UniqueKeyViolationException { // Ensure the value object has been validated if (!voRehab.isValidated()) throw new DomainRuntimeException("Rehabilitation has not been validated"); if (voRehab.getID_Rehabilitation() == null && getRehabVo(voRehab.getClinicalContact()) != null) throw new UniqueKeyViolationException("The screen will be refreshed."); DomainFactory factory = getDomainFactory(); Rehabilitation doRehab = RehabilitationVoAssembler.extractRehabilitation(factory, voRehab); factory.save(doRehab); return RehabilitationVoAssembler.create(doRehab); }
/** * Get the current Rehab record for the Clinical Contact */ public ims.therapies.vo.RehabilitationVo getRehabVo(ims.core.vo.ClinicalContactShortVo voClinicalContactShort) { RehabilitationVoCollection voRehabColl = new RehabilitationVoCollection(); DomainFactory factory = getDomainFactory(); String hql = " from Rehabilitation rehab "; StringBuffer condStr = new StringBuffer(); String andStr = " "; ArrayList markers = new ArrayList(); ArrayList values = new ArrayList(); if(voClinicalContactShort !=null) { condStr.append(andStr + " rehab.clinicalContact.id = :id_ClinicalContact"); markers.add("id_ClinicalContact"); values.add(voClinicalContactShort.getID_ClinicalContact()); andStr = " and "; } if (andStr.equals(" and ")) hql += " where "; hql += condStr.toString(); voRehabColl = RehabilitationVoAssembler.createRehabilitationVoCollectionFromRehabilitation(factory.find(hql, markers, values)); if(voRehabColl.size()>0) return voRehabColl.get(0); else return null; }
public RehabilitationVo getRehabById(RehabilitationRefVo recordref) { if( recordref == null) return null; Rehabilitation doRehabilitation = (Rehabilitation) getDomainFactory().getDomainObject(Rehabilitation.class, recordref.getID_Rehabilitation()); return RehabilitationVoAssembler.create(doRehabilitation); }