public void saveInternalTransfer(InpatientEpisodeLiteVo inpatEpis, BedSpaceStateLiteVo bedSpaceState) throws StaleObjectException { if (bedSpaceState == null) throw new CodingRuntimeException("bedSpaceState is null in method saveInternalTransfer"); if (inpatEpis == null) throw new CodingRuntimeException("inpatEpis is null in method saveInternalTransfer"); BedSpaceState doBedSpaceState = BedSpaceStateLiteVoAssembler.extractBedSpaceState(getDomainFactory(), bedSpaceState); InpatientEpisode doInpatEpis = InpatientEpisodeLiteVoAssembler.extractInpatientEpisode(getDomainFactory(), inpatEpis); doInpatEpis.getBed().getCurrentBedStatus().setBedStatus(getDomLookup(BedStatus.AVAILABLE)); doInpatEpis.getBed().setInpatientEpisode(null); getDomainFactory().save(doInpatEpis); doBedSpaceState.setInpatientEpisode(doInpatEpis); doBedSpaceState.getCurrentBedStatus().setBedStatus(getDomLookup(BedStatus.OCCUPIED)); doInpatEpis.setBed(doBedSpaceState); getDomainFactory().save(doInpatEpis); }
public Boolean isInpatientCareContext(PatientRefVo patientRef, CareContextRefVo careContextRef) { if (patientRef == null || !patientRef.getID_PatientIsNotNull()) throw new CodingRuntimeException("Logical Error - Patient expected"); if (careContextRef == null || !careContextRef.getID_CareContextIsNotNull()) throw new CodingRuntimeException("Logical Error - Care Context expected"); String hql = "from InpatientEpisode as ip where (ip.pasEvent.id in (select cc.pasEvent.id from CareContext as cc where cc.id = :refID))"; ArrayList<String> paramNames = new ArrayList<String>(); paramNames.add("refID"); ArrayList<Object> paramValues = new ArrayList<Object>(); paramValues.add(careContextRef.getID_CareContext()); InpatientEpisodeLiteVo inpatientEpisode = InpatientEpisodeLiteVoAssembler.create((InpatientEpisode) getDomainFactory().findFirst(hql, paramNames, paramValues)); if (inpatientEpisode == null) return Boolean.FALSE; return Boolean.TRUE; }
public InpatientEpisodeLiteVoCollection listInpatientEpisodeByWard(LocationRefVo ward, PatientRefVo patient) { if(ward == null || ward.getID_Location() == null) throw new CodingRuntimeException("ward is null or id not provide in method listInpatientEpisodeByWard"); ArrayList<String> paramNames = new ArrayList<String>(); ArrayList<Object> paramValues = new ArrayList<Object>(); String hql = "from InpatientEpisode inpat join fetch inpat.bed as bed where inpat.pasEvent.location.id = :idWard and bed is not null"; paramNames.add("idWard"); paramValues.add(ward.getID_Location()); if(patient != null && patient.getID_Patient() != null) { hql += " and inpat.pasEvent.patient.id <> :PatientId"; paramNames.add("PatientId"); paramValues.add(patient.getID_Patient()); } hql += " order by bed.bay asc, inpat.pasEvent.patient.name.upperSurname asc,inpat.pasEvent.patient.name.upperForename asc"; List inpatEpis = getDomainFactory().find(hql, paramNames, paramValues); return InpatientEpisodeLiteVoAssembler.createInpatientEpisodeLiteVoCollectionFromInpatientEpisode(inpatEpis); }
public InpatientEpisodeLiteVo getInpatientEpisodes(PatientRefVo patientId) { DomainFactory factory = getDomainFactory(); String hql; ArrayList markers = new ArrayList(); ArrayList values = new ArrayList(); hql = " from InpatientEpisode ip "; StringBuffer condStr = new StringBuffer(); String andStr = " "; if (patientId != null) { condStr.append(andStr + " ip.pasEvent.patient.id = :patient"); markers.add("patient"); values.add(patientId.getID_Patient()); andStr = " and "; } if (andStr.equals(" and ")) { hql += " where "; } hql += condStr.toString(); List ips = factory.find(hql, markers, values); if(ips != null && ips.size() > 0) { InpatientEpisodeLiteVoCollection tempColl = InpatientEpisodeLiteVoAssembler.createInpatientEpisodeLiteVoCollectionFromInpatientEpisode(ips); if(tempColl != null && tempColl.size() > 0) return tempColl.get(0); else return null; } else return null; }
public InpatientEpisodeLiteVoCollection listInfantsForSelectedPatient(PatientRefVo patient) { if (patient == null || patient.getID_Patient() == null) throw new CodingRuntimeException("patient is null or id not provided in method countInfants"); String hql = "select inpatEpis from InpatientEpisode as inpatEpis left join inpatEpis.pasEvent as pE where (pE.patient.id in (select pat.id from Patient as pat where (pat.clientParent.id = " + patient.getID_Patient() + ")))"; List lstEpisodes = getDomainFactory().find(hql); if(lstEpisodes != null) return InpatientEpisodeLiteVoAssembler.createInpatientEpisodeLiteVoCollectionFromInpatientEpisode(lstEpisodes); return null; }
public InpatientEpisodeLiteVo geInpatientEpisodeLiteVoById( InpatientEpisodeRefVo inparEpRef) { if( inparEpRef == null || inparEpRef.getID_InpatientEpisode() == null) return null; DomainFactory factory = getDomainFactory(); InpatientEpisode doInpatientEpisode = (InpatientEpisode) factory.getDomainObject(InpatientEpisode.class, inparEpRef.getID_InpatientEpisode()); return InpatientEpisodeLiteVoAssembler.create(doInpatientEpisode); }
public InpatientEpisodeLiteVoCollection listHomeLeavesByWard(LocationRefVo ward) { if(ward == null || ward.getID_Location() == null) throw new CodingRuntimeException("ward is null or id not provide in method listInpatientEpisodeByWard"); String hql = getHomeLeavesQuery(false);// WDEV-14563 List<?> inpatEpis = getDomainFactory().find(hql, new String[]{"idWard", "bTRUE","idWard2", "status"}, new Object[]{ward.getID_Location(), Boolean.TRUE, ward.getID_Location(),getDomLookup(TransferStatus.PENDING) }); return InpatientEpisodeLiteVoAssembler.createInpatientEpisodeLiteVoCollectionFromInpatientEpisode(inpatEpis); }
public InpatientEpisodeLiteVo getInpatientEpisode(InpatientEpisodeRefVo inpatientRef) { if(inpatientRef == null) { throw new CodingRuntimeException("Cannot get InpatientEpisode on null Id."); } return InpatientEpisodeLiteVoAssembler.create((InpatientEpisode) getDomainFactory().getDomainObject(InpatientEpisode.class, inpatientRef.getID_InpatientEpisode())); }
public InpatientEpisodeLiteVoCollection listInpatientEpisodeByWard(LocationRefVo ward) { if(ward == null || ward.getID_Location() == null) throw new CodingRuntimeException("ward is null or id not provide in method listInpatientEpisodeByWard"); String hql = "from InpatientEpisode inpat join fetch inpat.bed as bed where (inpat.pasEvent.location.id = :idWard and bed is not null) order by bed.bay asc, inpat.pasEvent.patient.name.upperSurname asc,inpat.pasEvent.patient.name.upperForename asc"; List inpatEpis = getDomainFactory().find(hql, new String[]{"idWard"}, new Object[]{ward.getID_Location()}); return InpatientEpisodeLiteVoAssembler.createInpatientEpisodeLiteVoCollectionFromInpatientEpisode(inpatEpis); }
public InpatientEpisodeLiteVoCollection listWaitingAreaPatientsByWard(LocationRefVo ward) { if(ward == null || ward.getID_Location() == null) throw new CodingRuntimeException("ward is null or id not provided in method listWaitingAreaPatientsByWard"); String hql = "from InpatientEpisode inpat left join fetch inpat.bed as bedspace where inpat.pasEvent.location.id = :idWard and bedspace is null and (inpat.isOnHomeLeave is null or inpat.isOnHomeLeave = :bFalse) order by inpat.pasEvent.patient.name.upperSurname "; List inpatEpis = getDomainFactory().find(hql, new String[]{"idWard", "bFalse"}, new Object[]{ward.getID_Location(), Boolean.FALSE}); return InpatientEpisodeLiteVoAssembler.createInpatientEpisodeLiteVoCollectionFromInpatientEpisode(inpatEpis); }
public InpatientEpisodeLiteVo getInpatientEpisodeLite(InpatientEpisodeRefVo inpatientEpisode) { if (inpatientEpisode == null || inpatientEpisode.getID_InpatientEpisode() == null) return null; return InpatientEpisodeLiteVoAssembler.create((InpatientEpisode) getDomainFactory().getDomainObject(InpatientEpisode.class, inpatientEpisode.getID_InpatientEpisode())); }
public void undoReadyToLeave(InpatientEpisodeLiteVo voInpatToUpdate) throws DomainInterfaceException, StaleObjectException { if (voInpatToUpdate == null || voInpatToUpdate.getID_InpatientEpisode() == null) throw new CodingRuntimeException("voInpatToUpdate argument is null in method undoReadyToLeave()"); DomainFactory factory = getDomainFactory(); InpatientEpisode inpatDO = (InpatientEpisode) factory.getDomainObject(InpatientEpisode.class, voInpatToUpdate.getID_InpatientEpisode()); if (inpatDO == null || !Boolean.TRUE.equals(inpatDO.isIsReadyToLeave())) { throw new DomainInterfaceException((inpatDO == null ? "This inpatient has been discharged by another user." : "This inpatient has been removed from Ready To Leave list by another user.") + " The screen will be refreshed."); } InpatientEpisode inpatForSaveDO = InpatientEpisodeLiteVoAssembler.extractInpatientEpisode(factory, voInpatToUpdate); factory.save(inpatForSaveDO); }
public InpatientEpisodeLiteVo getInpatientEpisodeLiteVoById(InpatientEpisodeRefVo inpatEpRef) { if (inpatEpRef == null || inpatEpRef.getID_InpatientEpisode() == null) return null; DomainFactory factory = getDomainFactory(); InpatientEpisode doInpatientEpisode = (InpatientEpisode) factory.getDomainObject(InpatientEpisode.class, inpatEpRef.getID_InpatientEpisode()); return InpatientEpisodeLiteVoAssembler.create(doInpatientEpisode); }
public InpatientEpisodeLiteVoCollection listHomeLeavesByWard(LocationRefVo ward) { if(ward == null || ward.getID_Location() == null) throw new CodingRuntimeException("ward is null or id not provide in method listInpatientEpisodeByWard"); String hql = getHomeLeavesQuery(false, true);// WDEV-14563 List<?> inpatEpis = getDomainFactory().find(hql, new String[]{"idWard", "bTRUE","idWard2", "status"}, new Object[]{ward.getID_Location(), Boolean.TRUE, ward.getID_Location(),getDomLookup(TransferStatus.PENDING) }); return InpatientEpisodeLiteVoAssembler.createInpatientEpisodeLiteVoCollectionFromInpatientEpisode(inpatEpis); }
public InpatientEpisodeLiteVoCollection listWaitingAreaPatientsByWard(LocationRefVo ward) { if(ward == null || ward.getID_Location() == null) throw new CodingRuntimeException("ward is null or id not provided in method listWaitingAreaPatientsByWard"); String hql = "from InpatientEpisode inpat left join fetch inpat.bed as bedspace where inpat.pasEvent.location.id = :idWard and bedspace is null and (inpat.isOnHomeLeave is null or inpat.isOnHomeLeave = :bFalse) and (inpat.isReadyToLeave is null or inpat.isReadyToLeave = :bFalse) and inpat.id not in (select inp.id from PendingTransfers pt left join pt.inpatientEpisode as inp where inp.pasEvent.location.id = :idWard) order by inpat.pasEvent.patient.name.upperSurname "; List<?> inpatEpis = getDomainFactory().find(hql, new String[]{"idWard", "bFalse"}, new Object[]{ward.getID_Location(), Boolean.FALSE}); return InpatientEpisodeLiteVoAssembler.createInpatientEpisodeLiteVoCollectionFromInpatientEpisode(inpatEpis); }
public void allocateBed(BedSpaceStateLiteVo bedSpace, InpatientEpisodeLiteVo inpatientEpisode, AdmissionDetailVo admissionDetail, HomeLeaveVo voHomeLeave) throws StaleObjectException, DomainInterfaceException { if (inpatientEpisode == null) throw new CodingRuntimeException("inpatientEpisode is null in method allocateBed"); if (bedSpace == null) throw new CodingRuntimeException("bedSpace is null in method allocateBed"); if (admissionDetail == null) throw new CodingRuntimeException("admissionDetail is null in method allocateBed"); BedSpaceState doBedSpaceState = BedSpaceStateLiteVoAssembler.extractBedSpaceState(getDomainFactory(), bedSpace); InpatientEpisode doInpatEpis = InpatientEpisodeLiteVoAssembler.extractInpatientEpisode(getDomainFactory(), inpatientEpisode); AdmissionDetail doAdmissionDetail = AdmissionDetailVoAssembler.extractAdmissionDetail(getDomainFactory(), admissionDetail); if(doBedSpaceState != null) { doBedSpaceState.setInpatientEpisode(doInpatEpis); doInpatEpis.setBed(doBedSpaceState); } if(voHomeLeave != null) { for(int i = 0 ; doInpatEpis.getHomeLeaves().size() > 0 && i < doInpatEpis.getHomeLeaves().size() ; i++) { HomeLeave doHL = (HomeLeave)doInpatEpis.getHomeLeaves().get(i); if (doHL != null && doHL.getDateReturnedFromHomeLeave() == null) { doHL.setDateReturnedFromHomeLeave(voHomeLeave.getDateReturnedFromHomeLeaveIsNotNull() ? voHomeLeave.getDateReturnedFromHomeLeave().getDate() : null); doHL.setTimeReturnedFromHomeLeave(voHomeLeave.getTimeReturnedFromHomeLeaveIsNotNull() ? voHomeLeave.getTimeReturnedFromHomeLeave().toString() : null); doInpatEpis.getHomeLeaves().set(i, doHL); } } doInpatEpis.setIsOnHomeLeave(false); doInpatEpis.setDateOnHomeLeave(null); doInpatEpis.setTimeOnHomeLeave(null); doInpatEpis.setExpectedDateOfReturn(null); doInpatEpis.setExpectedTimeOfReturn(null); doInpatEpis.setVacatedBedNumber(null); //UPDATE PAS THAT NO LONGER ON HOME LEAVE if (Boolean.FALSE.equals(ConfigFlag.GEN.USE_ELECTIVE_LIST_FUNCTIONALITY.getValue())) { Homeleave hlRec = (Homeleave)getDTOInstance(Homeleave.class); hlRec.DataCollection.add(); copyHomeLeaveToDto(hlRec, doAdmissionDetail, voHomeLeave); Result res = hlRec.update(); if (res != null && res.getId() < 0 ) { if (res.getId() == -5) throw new DomainInterfaceException("Error occurred saving Home Leave record to PAS " + res.getMessage()); else throw new DTODomainInterfaceException(res.getId(), "Error occurred saving Home Leave record to PAS " + res.getMessage()); } } } getDomainFactory().save(doInpatEpis); if(doBedSpaceState != null) doAdmissionDetail.setBed(doBedSpaceState.getBedSpace()); getDomainFactory().save(doAdmissionDetail); }
public ims.core.vo.InpatientEpisodeLiteVo getInpatientEpisodeLite(ims.core.admin.pas.vo.InpatientEpisodeRefVo voInpat) { if (voInpat == null) return null; return InpatientEpisodeLiteVoAssembler.create((InpatientEpisode) getDomainFactory().getDomainObject(InpatientEpisode.class, voInpat.getID_InpatientEpisode())); }