/** * A list of all the occupied beds and associated inpatients across a ward */ public WardDataViewVoCollection listInpatientsInBedsByWard(LocationRefVo ward) { if (ward == null || ward.getID_Location() == null) throw new CodingRuntimeException("ward is null or id not provided in method listInpatientsInBedsByWard"); WardDataViewVoCollection voCollWdv = new WardDataViewVoCollection(); String hql = "select bed, pat, bay, pe,inpatEpis from BedSpaceState as bedSpaceState left join bedSpaceState.bedSpace as bed left join bedSpaceState.currentBedStatus as currentStatus left join bedSpaceState.inpatientEpisode as inpatEpis left join inpatEpis.pasEvent as pe left join pe.patient as pat left join bedSpaceState.bay as bay " + "where (bedSpaceState.ward.id = :wardId and bedSpaceState.inpatientEpisode is not null and currentStatus.bedStatus = :occupied)"; List wdvList = getDomainFactory().find(hql, new String[]{"wardId","occupied"}, new Object[]{ward.getID_Location(), getDomLookup(BedStatus.OCCUPIED)}); if(wdvList != null && wdvList.size() > 0) { Iterator it = wdvList.iterator(); while(it.hasNext()) { Object[] item = (Object[])it.next(); BedSpace doBed = (BedSpace) item[0]; Patient doPat = (Patient) item[1]; Location doBay = (Location) item[2]; PASEvent doPe = (PASEvent) item[3]; InpatientEpisode doInpat = (InpatientEpisode) item[4]; //wdev-14784 WardDataViewVo voWardDv = new WardDataViewVo(); voWardDv.setBed(BedSpaceVoAssembler.create(doBed)); voWardDv.setBay(LocationLiteVoAssembler.create(doBay)); voWardDv.setPatient(PatientShortAssembler.create(doPat)); voWardDv.getPatient().setHasAlerts(doPat.getPatientAlerts() != null && doPat.getPatientAlerts().size() > 0 ? true : false); voWardDv.setInpatEpisode(InpatientEpisodeForVTERiskAsessmentVoAssembler.create(doInpat)); //wdev-14784 //wdev-11083 Iterator<ims.core.clinical.domain.objects.PatientAlert> patAlert = doPat.getPatientAlerts().iterator(); boolean flagHasAlerts = false; while(patAlert != null && patAlert.hasNext()) { if(Boolean.TRUE.equals(patAlert.next().isIsCurrentlyActiveAlert())) { flagHasAlerts = true; break; } } voWardDv.getPatient().setHasActiveAlerts(flagHasAlerts); //end wdev-11083 voWardDv.setPasEvent(PasEventADTVoAssembler.create(doPe)); voCollWdv.add(voWardDv); } } voCollWdv.sort(); return voCollWdv; }
/** * A list of all the occupied beds and associated inpatients across a ward */ public WardDataViewVoCollection listInpatientsInBedsByWard(LocationRefVo ward) { if (ward == null || ward.getID_Location() == null) throw new CodingRuntimeException("ward is null or id not provided in method listInpatientsInBedsByWard"); WardDataViewVoCollection voCollWdv = new WardDataViewVoCollection(); String hql = "select bed, pat, bay, pe,inpatEpis from BedSpaceState as bedSpaceState left join bedSpaceState.bedSpace as bed left join bedSpaceState.currentBedStatus as currentStatus left join bedSpaceState.inpatientEpisode as inpatEpis left join inpatEpis.pasEvent as pe left join pe.patient as pat left join bedSpaceState.bay as bay " + "where (bedSpaceState.ward.id = :wardId and bedSpaceState.inpatientEpisode is not null and currentStatus.bedStatus = :occupied)"; List wdvList = getDomainFactory().find(hql, new String[]{"wardId","occupied"}, new Object[]{ward.getID_Location(), getDomLookup(BedStatus.OCCUPIED)}); if(wdvList != null && wdvList.size() > 0) { Iterator it = wdvList.iterator(); while(it.hasNext()) { Object[] item = (Object[])it.next(); BedSpace doBed = (BedSpace) item[0]; Patient doPat = (Patient) item[1]; Location doBay = (Location) item[2]; PASEvent doPe = (PASEvent) item[3]; InpatientEpisode doInpat = (InpatientEpisode) item[4]; //wdev-14784 WardDataViewVo voWardDv = new WardDataViewVo(); voWardDv.setBed(BedSpaceVoAssembler.create(doBed)); voWardDv.setBay(LocationLiteVoAssembler.create(doBay)); voWardDv.setPatient(PatientLite_IdentifiersVoAssembler.create(doPat)); voWardDv.getPatient().setHasAlerts(doPat.getPatientAlerts() != null && doPat.getPatientAlerts().size() > 0 ? true : false); voWardDv.setInpatEpisode(InpatientEpisodeForVTERiskAsessmentVoAssembler.create(doInpat)); //wdev-14784 //wdev-11083 Iterator<ims.core.clinical.domain.objects.PatientAlert> patAlert = doPat.getPatientAlerts().iterator(); boolean flagHasAlerts = false; while(patAlert != null && patAlert.hasNext()) { if(Boolean.TRUE.equals(patAlert.next().isIsCurrentlyActiveAlert())) { flagHasAlerts = true; break; } } voWardDv.getPatient().setHasAlerts(flagHasAlerts); //end wdev-11083 voWardDv.setPasEvent(PasEventADTVoAssembler.create(doPe)); voCollWdv.add(voWardDv); } } voCollWdv.sort(); return voCollWdv; }