public EpisodeDetailsVo getEmergencyEpisode(EmergencyEpisodeRefVo episodeId) { if( episodeId == null) throw new CodingRuntimeException("EmergencyEpisodeRefVo not provided"); DomainFactory factory = getDomainFactory(); String hsql = "select e1_1 from EmergencyEpisode as e1_1 where (e1_1.id = :id)"; List emergency = factory.find(hsql, new String[] {"id"}, new Object[] {episodeId.getID_EmergencyEpisode()}); if(emergency != null && emergency.size() > 0) { EpisodeDetailsVoCollection EpisodeColl = EpisodeDetailsVoAssembler.createEpisodeDetailsVoCollectionFromEmergencyEpisode(emergency); if(EpisodeColl != null && EpisodeColl.size() > 0) return EpisodeColl.get(0); } return null; }
public EpisodeDetailsVo getEmergencyEpisodeByCareContext(CareContextRefVo careContextRef) { if(careContextRef == null || careContextRef.getID_CareContext() == null) throw new CodingRuntimeException("CareContext not provided"); DomainFactory factory = getDomainFactory(); String query = "select e1_1.emergencyEpisode from EmergencyAttendance as e1_1 where ( e1_1.careContext.id = :careContextID ) "; List<?> list= factory.find(query, new String[] {"careContextID"}, new Object[] {careContextRef.getID_CareContext()}); if(list == null || list.size() == 0 ) { return null; } return EpisodeDetailsVoAssembler.create((EmergencyEpisode) list.get(0)); }
public EpisodeDetailsVoCollection listEmergencyEpisodeByPatient(PatientRefVo patientRefVo, Integer maxRecords, AttendanceHistoryDialog type, DateTime scheduledDate, DateTime unscheduledDate) { if(patientRefVo == null || patientRefVo.getID_Patient() == null) throw new CodingRuntimeException("Patient not provided"); DomainFactory factory = getDomainFactory(); String hsql = " select e1_1 from EmergencyEpisode as e1_1 "; hsql += " left join e1_1.episodeOfCare as e2_1 "; hsql += " left join e2_1.careSpell as c1_1 "; hsql += " left join c1_1.patient as p1_1 "; hsql += " where e1_1.isRIE is null and p1_1.id = :idPatient"; if (type != null) { if (type.equals(AttendanceHistoryDialog.SCHEDULED)) { hsql += " and e1_1.injuryDateTime >= :scheduledDate"; } if (type.equals(AttendanceHistoryDialog.UNSCHEDULED)) { hsql += " and (e1_1.injuryDateTime >= :unscheduledDate and e1_1.injuryDateTime < :scheduledDate)"; } } hsql += " order by e2_1.startDate desc"; //wdev-16070 List episodeDetails = null; if (maxRecords != 0) { if (type != null) { if (type.equals(AttendanceHistoryDialog.SCHEDULED)) { episodeDetails = factory.find(hsql, new String[] {"scheduledDate","idPatient"}, new Object[] {scheduledDate.getJavaDate(), patientRefVo.getID_Patient()},maxRecords); } if (type.equals(AttendanceHistoryDialog.UNSCHEDULED)) { episodeDetails = factory.find(hsql, new String[] {"scheduledDate","unscheduledDate","idPatient"}, new Object[] {scheduledDate.getJavaDate(), unscheduledDate.getJavaDate(), patientRefVo.getID_Patient()},maxRecords); } } else { episodeDetails = factory.find(hsql, new String[] {"idPatient"}, new Object[] {patientRefVo.getID_Patient()},maxRecords); } } else { if (type != null) { if (type.equals(AttendanceHistoryDialog.SCHEDULED)) { episodeDetails = factory.find(hsql, new String[] {"scheduledDate","idPatient"}, new Object[] {scheduledDate.getJavaDate(), patientRefVo.getID_Patient()}); } if (type.equals(AttendanceHistoryDialog.UNSCHEDULED)) { episodeDetails = factory.find(hsql, new String[] {"scheduledDate","unscheduledDate","idPatient"}, new Object[] {scheduledDate.getJavaDate(), unscheduledDate.getJavaDate(), patientRefVo.getID_Patient()}); } } else { episodeDetails = factory.find(hsql, new String[] {"idPatient"}, new Object[] {patientRefVo.getID_Patient()}); } } if ( episodeDetails != null && episodeDetails.size() > 0) return EpisodeDetailsVoAssembler.createEpisodeDetailsVoCollectionFromEmergencyEpisode(episodeDetails).sort(SortOrder.DESCENDING); return null; }