public HL7ReferralVo getReferralByPatientAndRKEY(PatientRefVo patient,String referralKey) throws DomainInterfaceException { DomainFactory factory = getDomainFactory(); StringBuffer hql = new StringBuffer(" from Referral ref where ref.patient.id = :patient and ref.extReferralKey =:refKey"); ArrayList<String> labels = new ArrayList<String>(); ArrayList<Object> values = new ArrayList<Object>(); labels.add("patient"); labels.add("refKey"); values.add(patient.getID_Patient()); values.add(referralKey); List lst = factory.find(hql.toString(), labels, values); if (lst != null && lst.size() == 1) { return HL7ReferralVoAssembler.create((Referral) lst.get(0)); } if (lst != null && lst.size() > 1) { throw new DomainInterfaceException("More than one referral found for this patient and referral key"); } return null; }
public HL7ReferralVo saveReferral(HL7ReferralVo referral) throws StaleObjectException { if (!referral.isValidated()) throw new CodingRuntimeException("Referral has not been validated!"); DomainFactory factory = getDomainFactory(); Referral refBo = HL7ReferralVoAssembler.extractReferral(factory, referral); factory.save(refBo); return HL7ReferralVoAssembler.create(refBo); }