public EnvironmentalVisitVo getEnvironmentalVisitByClinicalContact(ClinicalContactRefVo voClinicalContactRef) { if(voClinicalContactRef == null || voClinicalContactRef.getID_ClinicalContact() == null) throw new DomainRuntimeException("Contact not provided for get call. "); DomainFactory factory = getDomainFactory(); java.util.List environVisitList = factory.find("from EnvironmentalVisit environList where environList.clinicalContact.id = :contactId ", new String[]{"contactId"}, new Object[]{voClinicalContactRef.getID_ClinicalContact()}); EnvironmentalVisitVoCollection coll = null; if ((environVisitList != null) && (environVisitList.size()>0)) coll = EnvironmentalVisitVoAssembler.createEnvironmentalVisitVoCollectionFromEnvironmentalVisit(environVisitList); if(coll != null && coll.size()>0) return coll.get(0); return null; }
public EnvironmentalVisitVo saveEnvironmentalVisit(EnvironmentalVisitVo voEnvironmentalVisit) throws StaleObjectException, UniqueKeyViolationException { DomainFactory factory = getDomainFactory(); if (!voEnvironmentalVisit.isValidated()) { throw new DomainRuntimeException("This EnvironmentalVisitVo has not been validated"); } if(voEnvironmentalVisit.getID_EnvironmentalVisit() == null) { if(voEnvironmentalVisit.getCareContextIsNotNull()) { EnvironmentalVisitVoCollection coll = getEnvironmentalVisitVoByCareContext(voEnvironmentalVisit.getCareContext()); if(coll != null && coll.size()>0) throw new UniqueKeyViolationException("A Environmental Visit record already exists for this CareContext. "); } } EnvironmentalVisit domEnvironmentalVisit = EnvironmentalVisitVoAssembler.extractEnvironmentalVisit(factory, voEnvironmentalVisit); factory.save(domEnvironmentalVisit); return EnvironmentalVisitVoAssembler.create(domEnvironmentalVisit); }
private EnvironmentalVisitVoCollection getEnvironmentalVisitVoByCareContext(CareContextRefVo voCareContext) { String hql = new String("from EnvironmentalVisit ev where ev.careContext.id = :CARECONTEXT_ID"); java.util.List list = getDomainFactory().find(hql, "CARECONTEXT_ID", voCareContext.getID_CareContext()); return EnvironmentalVisitVoAssembler.createEnvironmentalVisitVoCollectionFromEnvironmentalVisit(list); }