public AttendanceDetailsVo getLastAttendance(PatientRefVo patientRef) { if(patientRef == null) throw new CodingRuntimeException("Patient not provided"); DomainFactory factory = getDomainFactory(); String hsql = "select e3_1 from EmergencyEpisode as e1_1 left join e1_1.episodeOfCare as e2_1 left join e2_1.careSpell as c1_1 left join c1_1.patient as p1_1 left join e1_1.emergencyAttendances as e3_1 where (e3_1.arrivalDateTime = " + "(select max (xe3_1.arrivalDateTime) from EmergencyEpisode as xe1_1 left join xe1_1.episodeOfCare as xe2_1 left join xe2_1.careSpell as xc1_1 left join xc1_1.patient as xp1_1 left join xe1_1.emergencyAttendances as xe3_1 " + "where (xc1_1.patient.id =:idPatient )) and c1_1.patient.id =:idPatient1 )"; List attendances = factory.find(hsql, new String[] {"idPatient","idPatient1"}, new Object[] {patientRef.getID_Patient(),patientRef.getID_Patient()}); if(attendances != null && attendances.size() > 0) { AttendanceDetailsVoCollection attColl = AttendanceDetailsVoAssembler.createAttendanceDetailsVoCollectionFromEmergencyAttendance(attendances); if( attColl != null && attColl.size() > 0) return attColl.get(0); } return null; }
public AttendanceDetailsVoCollection listAttendanceByEpisodeDetails(EmergencyEpisodeRefVo voRef) { if(voRef == null || voRef.getID_EmergencyEpisode() == null) throw new CodingRuntimeException("EmergencyEpisode not provided"); DomainFactory factory = getDomainFactory(); String hsql = " select e1_1 from EmergencyAttendance as e1_1 "; hsql += " left join e1_1.emergencyEpisode as e2_1 "; hsql += " where e1_1.isRIE is null and e2_1.id = :idEpisode"; hsql += " order by e1_1.registrationDateTime desc"; List attendances = factory.find(hsql, new String[] {"idEpisode"}, new Object[] {voRef.getID_EmergencyEpisode()}); if (attendances != null && attendances.size() > 0) return AttendanceDetailsVoAssembler.createAttendanceDetailsVoCollectionFromEmergencyAttendance(attendances).sort(SortOrder.DESCENDING); return null; }
public AttendanceDetailsVo getLastAttendance(PatientRefVo patientRef) { if (patientRef == null) throw new CodingRuntimeException("Patient not provided"); DomainFactory factory = getDomainFactory(); // Query to list back the latest StringBuilder query = new StringBuilder("SELECT erAttend "); query.append("FROM EmergencyEpisode AS erEp LEFT JOIN erEp.patient AS pat LEFT JOIN erEp.emergencyAttendances AS erAttend "); query.append("WHERE (erAttend.isRIE is null OR erAttend.isRIE = 0) AND pat.id = :PATIENT_ID AND "); query.append("(erAttend.arrivalDateTime = "); query.append("(SELECT MAX(erAttend2.arrivalDateTime) FROM EmergencyEpisode AS erEp2 LEFT JOIN erEp2.patient AS patient2 LEFT JOIN erEp2.emergencyAttendances AS erAttend2 "); query.append(" WHERE patient2.id = :PATIENT_ID)) "); return AttendanceDetailsVoAssembler.create((EmergencyAttendance) factory.findFirst(query.toString(), "PATIENT_ID", patientRef.getID_Patient())); }
public AttendanceDetailsVo getAttendanceDetails(EmergencyAttendanceRefVo attendanceDetailsRef) { if (attendanceDetailsRef == null || attendanceDetailsRef.getID_EmergencyAttendance() == null) { throw new CodingRuntimeException("Cannot get AttendanceDetailsVo on null Id "); } DomainFactory factory = getDomainFactory(); EmergencyAttendance domainEmergAttDet = (EmergencyAttendance) factory.getDomainObject(EmergencyAttendance.class, attendanceDetailsRef.getID_EmergencyAttendance()); return AttendanceDetailsVoAssembler.create(domainEmergAttDet); }
public AttendanceDetailsVo getEmergencyAttendance(EmergencyAttendanceRefVo emergencyAttendanceRef) { if(emergencyAttendanceRef == null || emergencyAttendanceRef.getID_EmergencyAttendance() == null) throw new CodingRuntimeException("The emergencyAttendanceRef paramater cannot be null !"); DomainFactory domainFactory = getDomainFactory(); return AttendanceDetailsVoAssembler.create((EmergencyAttendance)domainFactory.loadDomainObject(EmergencyAttendance.class, emergencyAttendanceRef.getID_EmergencyAttendance())); }
public AttendanceDetailsVo getLastDischargedAttendance(PatientRefVo patientRef) { if(patientRef == null) throw new CodingRuntimeException("Patient not provided"); DomainFactory factory = getDomainFactory(); String hsql = "select attDet from EmergencyAttendance as attDet where (attDet.patient.id =:idPatient and attDet.dischargeDateTime is not null) order by attDet.dischargeDateTime desc "; List list = factory.find(hsql, new String[] {"idPatient"}, new Object[] {patientRef.getID_Patient()}); if(list == null || list.size() == 0) return null; return AttendanceDetailsVoAssembler.create((EmergencyAttendance)list.get(0)); }