public MobilisationsVo getMobilisation(ClinicalContactShortVo voClinicalContact) { if (voClinicalContact == null) throw new RuntimeException("Cannot get Mobilisation record for null Clinical Contact"); StringBuffer query = new StringBuffer("from Mobilisations as m1_1 where m1_1.clinicalContact.id = :CCID order by m1_1.systemInformation.creationDateTime desc "); //wdev-13564 List list = getDomainFactory().find(query.toString(), "CCID", voClinicalContact.getID_ClinicalContact()); if (list == null || list.size() == 0) return null; //else if (list.size() > 1) // throw new RuntimeException("More than one Mobilisation found for the current Clinical Contact"); MobilisationsVoCollection voList = MobilisationsVoAssembler.createMobilisationsVoCollectionFromMobilisations(list); if (voList.size() > 0) return voList.get(0); return null; }
public MobilisationsVo save(MobilisationsVo voMobilisations)throws StaleObjectException, UniqueKeyViolationException { if(!voMobilisations.isValidated()) throw new DomainRuntimeException("This Mobilisation has not been validated"); DomainFactory factory = getDomainFactory(); StringBuffer hql = new StringBuffer("from Mobilisations as mb "); if(voMobilisations.getID_Mobilisations() == null) hql.append(" where (mb.clinicalContact.id = " + voMobilisations.getClinicalContact().getID_ClinicalContact() + ")"); else hql.append(" where (mb.clinicalContact.id = " + voMobilisations.getClinicalContact().getID_ClinicalContact() + ") and mb.id <> " + voMobilisations.getID_Mobilisations()); List list = (factory.find(hql.toString())); if(list.size() > 0) { MobilisationsVoCollection tempCol = MobilisationsVoAssembler.createMobilisationsVoCollectionFromMobilisations(list); //wdev-13513 if(tempCol != null && tempCol.size() > 0) //wdev-13513 throw new DomainRuntimeException("A record exists for this clinical contact, the screen will be refreshed"); } ims.therapies.treatment.domain.objects.Mobilisations domMobilisation = MobilisationsVoAssembler.extractMobilisations(factory, voMobilisations); factory.save(domMobilisation); return MobilisationsVoAssembler.create(domMobilisation); }