public void saveTransferOut(PendingTransfersLiteVo pendingTransfer) throws StaleObjectException, DomainInterfaceException { if(pendingTransfer == null) throw new CodingRuntimeException("pendingTransfer is null in method saveTransferOut"); if(!pendingTransfer.isValidated()) throw new CodingRuntimeException("pendingTransfer has not been validated in method saveTransferOut"); //WDEV-9192 if(pendingTransfer.getInpatientEpisodeIsNotNull()) { String currentTransfer = ""; if(pendingTransfer.getID_PendingTransfers() != null) currentTransfer = " and pt.id <> '" + pendingTransfer.getID_PendingTransfers() + "'"; List existingPTs = getDomainFactory().find("from PendingTransfers pt where pt.inpatientEpisode.id = '" + pendingTransfer.getInpatientEpisode().getID_InpatientEpisode() + "'" + currentTransfer); if(existingPTs != null && existingPTs.size() > 0) throw new DomainInterfaceException("Patient already has a transfer pending, the screen will be refreshed"); } //WDEV-10421 PendingTransfers doTransfer = PendingTransfersLiteVoAssembler.extractPendingTransfers(getDomainFactory(), pendingTransfer); //get the admission detail record and update its history for transfers AdmissionDetail doAdmissionDetail = populateTransferHistory(doTransfer, TRANSFEROUT, null); try { getDomainFactory().save(doTransfer); if(doAdmissionDetail != null) getDomainFactory().save(doAdmissionDetail); } catch (IllegalArgumentException e) { //where object has been deleted - this happens when a transfer in has been deleted (transfer complete) and this user has the old pending transfer record and is trying to update it throw new DomainInterfaceException("Patient's transfer has already been processed, the screen will be refreshed"); } }
public PendingTransfersLiteVo getPendingTransferForInpatient(InpatientEpisodeRefVo inpatEpis) { if (inpatEpis == null || inpatEpis.getID_InpatientEpisode() == null) throw new CodingRuntimeException("inpatEpis is null or id not provided in method getPendingTransferForInpatient"); List transfers = getDomainFactory().find("from PendingTransfers pTrans where pTrans.inpatientEpisode.id = " + inpatEpis.getID_InpatientEpisode()); if(transfers != null && transfers.size() == 1) return PendingTransfersLiteVoAssembler.create((PendingTransfers) transfers.get(0)); return null; }
public PendingTransfersLiteVoCollection listPendingTransfersInByWard(LocationRefVo destWard) { if(destWard == null || destWard.getID_Location() == null) throw new CodingRuntimeException("destWard is null or id not provided in method listPendingTransfersInByWard"); String hql = "from PendingTransfers pend where pend.destinationWard.id = :idWard and pend.currentStatus = :status"; List pendingTrans = getDomainFactory().find(hql, new String[]{"idWard","status"}, new Object[]{destWard.getID_Location(), getDomLookup(TransferStatus.PENDING)}); return PendingTransfersLiteVoAssembler.createPendingTransfersLiteVoCollectionFromPendingTransfers(pendingTrans); }
public PendingTransfersLiteVoCollection listPendingTransfersOutByWard(LocationRefVo currentLocation) { if(currentLocation == null || currentLocation.getID_Location() == null) throw new CodingRuntimeException("currentLocation is null or id not provided in method listPendingTransfersOutByWard"); String hql = "from PendingTransfers pend where pend.inpatientEpisode.pasEvent.location.id = :idWard and pend.currentStatus = :status order by pend.inpatientEpisode.pasEvent.patient.name.upperSurname asc, pend.inpatientEpisode.pasEvent.patient.name.upperForename asc"; List pendingTrans = getDomainFactory().find(hql, new String[]{"idWard","status"}, new Object[]{currentLocation.getID_Location(), getDomLookup(TransferStatus.PENDING)}); return PendingTransfersLiteVoAssembler.createPendingTransfersLiteVoCollectionFromPendingTransfers(pendingTrans); }
public PendingTransfersLiteVo getPendingTransferLite(PendingTransfersRefVo transfer) { if (transfer == null || transfer.getID_PendingTransfers() == null) return null; return PendingTransfersLiteVoAssembler.create((PendingTransfers) getDomainFactory().getDomainObject(PendingTransfers.class, transfer.getID_PendingTransfers())); }
public void updatePendingTransfer(PendingTransfersLiteVo pendingTransf) throws StaleObjectException { if(pendingTransf == null) throw new CodingRuntimeException("pendingTransfer is null in method updatePendingTransfer"); PendingTransfers doTransfer = PendingTransfersLiteVoAssembler.extractPendingTransfers(getDomainFactory(), pendingTransf); getDomainFactory().save(doTransfer); }
public PendingTransfersLiteVo getPendingTransferForInpatient(InpatientEpisodeRefVo inpatEpis) { if (inpatEpis == null || inpatEpis.getID_InpatientEpisode() == null) return null; List<?> transfers = getDomainFactory().find("from PendingTransfers pTrans WHERE pTrans.inpatientEpisode.id = " + inpatEpis.getID_InpatientEpisode() + " AND pTrans.currentStatus.id = " + TransferStatus.PENDING.getId()); if(transfers != null && transfers.size() == 1) return PendingTransfersLiteVoAssembler.create((PendingTransfers) transfers.get(0)); return null; }
public PendingTransfersLiteVo getPendingTransfer(PendingTransfersRefVo pendingTransferRef) { if (pendingTransferRef == null) return null; DomainFactory factory = getDomainFactory(); PendingTransfers doPendingTransfer = (PendingTransfers) factory.getDomainObject(PendingTransfers.class, pendingTransferRef.getID_PendingTransfers()); if (doPendingTransfer != null && TransferStatus.PENDING.getID() == doPendingTransfer.getCurrentStatus().getId()) return PendingTransfersLiteVoAssembler.create(doPendingTransfer); return null; }
public void saveTransferOut(PendingTransfersLiteVo pendingTransfer) throws StaleObjectException, DomainInterfaceException //WDEV-20023 { if(pendingTransfer == null) throw new CodingRuntimeException("pendingTransfer is null in method saveTransferOut"); if(!pendingTransfer.isValidated()) throw new CodingRuntimeException("pendingTransfer has not been validated in method saveTransferOut"); DomainFactory domainFactory = getDomainFactory(); //WDEV-9192 if(pendingTransfer.getInpatientEpisodeIsNotNull()) { String currentTransfer = ""; if(pendingTransfer.getID_PendingTransfers() != null) currentTransfer = " and pt.id <> '" + pendingTransfer.getID_PendingTransfers() + "'"; List existingPTs = getDomainFactory().find("from PendingTransfers pt where pt.inpatientEpisode.id = '" + pendingTransfer.getInpatientEpisode().getID_InpatientEpisode() + "'" + currentTransfer); if(existingPTs != null && existingPTs.size() > 0) throw new DomainInterfaceException("Patient already has a transfer pending, the screen will be refreshed"); } //WDEV-10421 PendingTransfers doTransfer = PendingTransfersLiteVoAssembler.extractPendingTransfers(getDomainFactory(), pendingTransfer); //get the admission detail record and update its history for transfers AdmissionDetail doAdmissionDetail = populateTransferHistory(doTransfer, TRANSFEROUT, null, null); //WDEV-20291 - starts here BedSpaceStateLiteVo bedSpaceVo = null; if (Boolean.TRUE.equals(pendingTransfer.getNoLongerInBed())) { InpatientEpisode doInpatEp = doTransfer.getInpatientEpisode(); if (doInpatEp != null && doInpatEp.getBed() != null) { bedSpaceVo = BedSpaceStateLiteVoAssembler.create(doInpatEp.getBed()); if (bedSpaceVo.getCurrentBedStatusIsNotNull()) { bedSpaceVo.setPreviousBedStatus((BedSpaceStateStatusLiteVo) bedSpaceVo.getCurrentBedStatus().clone()); BedSpaceStateStatusLiteVo bedStatusVo = new BedSpaceStateStatusLiteVo(); bedStatusVo.setBedStatus(BedStatus.AVAILABLE); bedStatusVo.setStatusDateTime(pendingTransfer.getTransferRequestDateTime()); bedSpaceVo.setCurrentBedStatus(bedStatusVo); } bedSpaceVo.setInpatientEpisode(null); updateOccupiedBedsForWardAndBay(LocationLiteVoAssembler.create(doInpatEp.getBed().getWard()), LocationLiteVoAssembler.create(doInpatEp.getBed().getBay()), null); } doInpatEp.setBedNo(null); //WDEV-20291 } try { if (bedSpaceVo != null && Boolean.TRUE.equals(pendingTransfer.getNoLongerInBed())) { BedSpaceState bedDO = BedSpaceStateLiteVoAssembler.extractBedSpaceState(domainFactory, bedSpaceVo); domainFactory.save(bedDO); } domainFactory.save(doTransfer); // WDEV-19774 - Trigger creation of A15 Pending Transfer HL7 message InpatientEpisodeVo inpatEpisodeVo = InpatientEpisodeVoAssembler.create(doTransfer.getInpatientEpisode()); if(inpatEpisodeVo.getPasEvent()!=null) { ADT adtimpl = (ADT) getDomainImpl(ADTImpl.class); adtimpl.triggerPendingTransferEvent(inpatEpisodeVo.getPasEvent()); } //WDEV-19974 if(doAdmissionDetail != null) getDomainFactory().save(doAdmissionDetail); } catch (IllegalArgumentException e) { //where object has been deleted - this happens when a transfer in has been deleted (transfer complete) and this user has the old pending transfer record and is trying to update it throw new DomainInterfaceException("Patient's transfer has already been processed, the screen will be refreshed"); } }
public ims.core.vo.PendingTransfersLiteVo getPendingTransfer(ims.core.admin.pas.vo.PendingTransfersRefVo pendingTransfersRef) { if (pendingTransfersRef == null) throw new CodingRuntimeException("Invalid argument specified."); DomainFactory factory = getDomainFactory(); PendingTransfers pendingTransferDO = (PendingTransfers) factory.getDomainObject(PendingTransfers.class, pendingTransfersRef.getID_PendingTransfers()); if (pendingTransferDO == null) return null; return PendingTransfersLiteVoAssembler.create(pendingTransferDO); }