public WheelchairAssessmentVo saveWheelchairAssessment(WheelchairAssessmentVo wheelchairAssessment) throws StaleObjectException, UniqueKeyViolationException { DomainFactory factory = getDomainFactory(); if (!wheelchairAssessment.isValidated()) { throw new DomainRuntimeException("This WheelchairAssessmentVo has not been validated"); } if (wheelchairAssessment.getID_WheelchairAssessment() == null)//Inserting a record { WheelchairAssessmentVoCollection voWA = getWheelchairAssessment(wheelchairAssessment.getClinicalContact().getID_ClinicalContact()); //wdev-13410 WheelchairAssessmentVo tempVo = null; //wdev-13410 if(voWA != null && voWA.size() > 0) //wdev-13410 { tempVo = voWA.get(0); } else { tempVo = null; } if(tempVo != null ) throw new UniqueKeyViolationException("A record exists for this clinical contact, the screen will be refreshed"); } WheelchairAssessment domWheelchairAssessment = WheelchairAssessmentVoAssembler.extractWheelchairAssessment(factory, wheelchairAssessment); factory.save(domWheelchairAssessment); return WheelchairAssessmentVoAssembler.create(domWheelchairAssessment); }
public WheelchairAssessmentVoCollection getWheelchairAssessment(Integer contactId) { DomainFactory factory = getDomainFactory(); StringBuffer hql = new StringBuffer(" "); String query = "from WheelchairAssessment w "; ArrayList markers = new ArrayList(); ArrayList values = new ArrayList(); String andStr = " "; if (contactId != null) { hql.append(andStr + " w.clinicalContact.id = :id_ClinicalContact order by w.id desc"); //wdev-13410 markers.add("id_ClinicalContact"); values.add(contactId); andStr = " and "; } if (markers.size() > 0) query += " where "; query += hql.toString(); List assessments = factory.find(query, markers, values); WheelchairAssessmentVoCollection collHomeVisitVo = WheelchairAssessmentVoAssembler.createWheelchairAssessmentVoCollectionFromWheelchairAssessment(assessments); //if(collHomeVisitVo!=null && collHomeVisitVo.size()>0) return collHomeVisitVo; //wdev-13410 //return collHomeVisitVo.get(0); //return null; }