public MyOrderInpatEpisVo getInpatientEpisode(PatientRefVo patient, PASEventRefVo pasEvent) { if (patient == null) throw new CodingRuntimeException("patient parameter is null method getInpatientEpisode"); DomainFactory factory = getDomainFactory(); String hql = ""; List inps = null; if(pasEvent != null) { hql = "from InpatientEpisode as inp where inp.pasEvent.patient.id = :idPatient and inp.pasEvent.location is not null and inp.pasEvent.id = :idPasEvent"; inps = factory.find(hql, new String[]{"idPatient", "idPasEvent"}, new Object[]{patient.getID_Patient(), pasEvent.getID_PASEvent()}); } else { hql = "from InpatientEpisode as inp where inp.pasEvent.patient.id = :idPatient and inp.pasEvent.location is not null"; inps = factory.find(hql, new String[]{"idPatient"}, new Object[]{patient.getID_Patient()}); } if (inps != null && inps.size() > 0) return MyOrderInpatEpisVoAssembler.create((InpatientEpisode) inps.get(0)); /* WDEV-16954 for merged patients you can have more than one inpatient records else if (inps != null && inps.size() > 1) throw new DomainRuntimeException("More than 1 current inpatient record found for patient with id = " + patient.getID_Patient()); */ return null; }
/** * WDEV-13890 * Function used to retrieve inpatient episode */ public MyOrderInpatEpisVo getInpatientEpisodeForPatient(PatientRefVo patient) { if (patient == null || !patient.getID_PatientIsNotNull()) return null; String query = "select ie from InpatientEpisode as ie left join ie.pasEvent as pe left join pe.patient as p where p.id = :PatId and ie.isRIE is null"; return MyOrderInpatEpisVoAssembler.create((InpatientEpisode) getDomainFactory().findFirst(query, "PatId", patient.getID_Patient())); }