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; }
private void processMessage(Message msg, ProviderSystemVo providerSystem) throws Exception { RF1 rf1 = (RF1) msg.get("RF1"); // Identify the Patient, Register if required Patient patient = savePatient(msg, providerSystem); // Get the external referral identifier which is unique per referral String rkey = rf1.getOriginatingReferralIdentifier().getEntityIdentifier().getValue(); // See if a referral exists for this patient and referral key // if so, we will update it, if not, create it HL7ReferralVo referral = hL7PathwayIf.getReferralByPatientAndRKEY(patient, rkey); // If this message is an instance of I13 and the referral is not found, reject // the message as I13 is a referral update message if (referral == null) throw new HL7Exception("Referral not found, this referral cannot be cancelled"); referral.setIsActive(Boolean.FALSE); String[] errors = referral.validate(); if (errors != null && errors.length > 0) { StringBuffer errStr = new StringBuffer(); for (int i=0; i<errors.length; i++) { if (i >0) errStr.append(". "); errStr.append(errors[i]); } throw new HL7Exception("Referral Validation Failed - " + errStr.toString()); } hL7PathwayIf.saveReferral(referral); // Message Processed return; }
private EventResponse processMessage(Message msg, ProviderSystemVo providerSystem, EventResponse response) throws Exception //WDEV-20112 { RF1 rf1 = (RF1) msg.get("RF1"); // Identify the Patient, Register if required Patient patient = savePatient(msg, providerSystem); // Get the external referral identifier which is unique per referral String rkey = rf1.getOriginatingReferralIdentifier().getEntityIdentifier().getValue(); // See if a referral exists for this patient and referral key // if so, we will update it, if not, create it HL7ReferralVo referral = hL7PathwayIf.getReferralByPatientAndRKEY(patient, rkey); // If this message is an instance of I13 and the referral is not found, reject // the message as I13 is a referral update message if (referral == null) throw new HL7Exception("Referral not found, this referral cannot be cancelled"); referral.setIsActive(Boolean.FALSE); String[] errors = referral.validate(); if (errors != null && errors.length > 0) { StringBuffer errStr = new StringBuffer(); for (int i=0; i<errors.length; i++) { if (i >0) errStr.append(". "); errStr.append(errors[i]); } throw new HL7Exception("Referral Validation Failed - " + errStr.toString()); } hL7PathwayIf.saveReferral(referral); // Message Processed //WDEV-20112 // return; response.setPatient(referral.getPatient()); return response; //WEDEV-20112 }
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); }