Java Code Examples for ims.core.vo.BedSpaceStateLiteVo.setPreviousBedStatus()

The following are Jave code examples for showing how to use setPreviousBedStatus() of the ims.core.vo.BedSpaceStateLiteVo class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: AvoinApotti   File: Logic.java   Source Code and License Vote up 5 votes
private DischargedEpisodeADTVo createInfantDischarge(InpatientEpisodeLiteVo voInpat)
{
	DischargedEpisodeADTVo voDischargedEpisode = new DischargedEpisodeADTVo();

	voDischargedEpisode.setDischargeDateTime(form.lyrDetail().tabDischarge().dtimDischarge().getValue());
	voDischargedEpisode.setDischargeDestination(form.lyrDetail().tabDischarge().cmbDischargeDestination().getValue());
	voDischargedEpisode.setMethodOfDischarge(form.lyrDetail().tabDischarge().cmbMethodDischarge().getValue());

	BedSpaceStateLiteVo voBedSpaceState = domain.getBedSpaceStateByInpatientEpisode(voInpat);
	if (voBedSpaceState != null && voBedSpaceState.getInpatientEpisodeIsNotNull())
	{
		voDischargedEpisode.setPasEvent(voBedSpaceState.getInpatientEpisode().getPasEvent());
		voDischargedEpisode.setConsultantStays(voBedSpaceState.getInpatientEpisode().getConsultantStays());
		voDischargedEpisode.setWardStays(voBedSpaceState.getInpatientEpisode().getWardStays());
	}
	else
		voDischargedEpisode.setPasEvent(voInpat.getPasEvent());

	// move to previous
	if (voBedSpaceState != null && voBedSpaceState.getCurrentBedStatusIsNotNull())
	{
		voBedSpaceState.setPreviousBedStatus((BedSpaceStateStatusLiteVo) voBedSpaceState.getCurrentBedStatus().clone());
		voBedSpaceState.setCurrentBedStatus(new BedSpaceStateStatusLiteVo());
		voBedSpaceState.getCurrentBedStatus().setStatusDateTime(new DateTime());
		voBedSpaceState.getCurrentBedStatus().setBedStatus(form.lyrDetail().tabDischarge().chkAllocateForCleaning().getValue() ? BedStatus.FOR_CLEANING : BedStatus.AVAILABLE);
	}

	voDischargedEpisode.setIsActive(true);
	voDischargedEpisode.setBedSpaceForInfant(voBedSpaceState);
	return voDischargedEpisode;
}
 
Example 2
Project: AvoinApotti   File: Logic.java   Source Code and License Vote up 5 votes
@Override
protected void onBtnCloseClick() throws PresentationLogicException
{
	BedSpaceStateLiteVo voBedSpaceState = form.getGlobalContext().Core.getSelectedBedSpaceState();

	if (voBedSpaceState == null)
		throw new CodingRuntimeException("voBedSpaceState is null in method onBtnCloseClick");

	// move to previous
	if (voBedSpaceState.getCurrentBedStatusIsNotNull())
	{
		voBedSpaceState.setPreviousBedStatus((BedSpaceStateStatusLiteVo) voBedSpaceState.getCurrentBedStatus().clone());
		voBedSpaceState.setCurrentBedStatus(new BedSpaceStateStatusLiteVo());
		voBedSpaceState.getCurrentBedStatus().setStatusDateTime(form.lyrDetail().tabCloseBed().dtimClose().getValue());
		voBedSpaceState.getCurrentBedStatus().setBedStatus(BedStatus.CLOSED);
	}

	String[] arrErrors = voBedSpaceState.validate(getUIValidationForCloseBed());
	if (arrErrors != null)
	{
		engine.showErrors(arrErrors);
		return;
	}

	try
	{
		domain.saveCloseBed(voBedSpaceState, form.lyrDetail().tabCloseBed().cmbUser().getValue(), form.lyrDetail().tabCloseBed().cmbCloseReason().getValue(), form.lyrDetail().tabCloseBed().dtimEstReOpen().getValue());
	}
	catch (StaleObjectException e)
	{
		engine.showMessage(ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue());
		initialise();
		engine.close(DialogResult.OK);
		return;
	}

	engine.close(DialogResult.OK);
}
 
Example 3
Project: openMAXIMS   File: Logic.java   Source Code and License Vote up 5 votes
private DischargedEpisodeADTVo createInfantDischarge(InpatientEpisodeLiteVo voInpat)
{
	DischargedEpisodeADTVo voDischargedEpisode = new DischargedEpisodeADTVo();

	voDischargedEpisode.setDischargeDateTime(form.lyrDetail().tabDischarge().dtimDischarge().getValue());
	voDischargedEpisode.setDischargeDestination(form.lyrDetail().tabDischarge().cmbDischargeDestination().getValue());
	voDischargedEpisode.setMethodOfDischarge(form.lyrDetail().tabDischarge().cmbMethodDischarge().getValue());

	BedSpaceStateLiteVo voBedSpaceState = domain.getBedSpaceStateByInpatientEpisode(voInpat);
	if (voBedSpaceState != null && voBedSpaceState.getInpatientEpisodeIsNotNull())
	{
		voDischargedEpisode.setPasEvent(voBedSpaceState.getInpatientEpisode().getPasEvent());
		voDischargedEpisode.setConsultantStays(voBedSpaceState.getInpatientEpisode().getConsultantStays());
		voDischargedEpisode.setWardStays(voBedSpaceState.getInpatientEpisode().getWardStays());
	}
	else
		voDischargedEpisode.setPasEvent(voInpat.getPasEvent());

	// move to previous
	if (voBedSpaceState != null && voBedSpaceState.getCurrentBedStatusIsNotNull())
	{
		voBedSpaceState.setPreviousBedStatus((BedSpaceStateStatusLiteVo) voBedSpaceState.getCurrentBedStatus().clone());
		voBedSpaceState.setCurrentBedStatus(new BedSpaceStateStatusLiteVo());
		voBedSpaceState.getCurrentBedStatus().setStatusDateTime(new DateTime());
		voBedSpaceState.getCurrentBedStatus().setBedStatus(form.lyrDetail().tabDischarge().chkAllocateForCleaning().getValue() ? BedStatus.FOR_CLEANING : BedStatus.AVAILABLE);
	}

	voDischargedEpisode.setIsActive(true);
	voDischargedEpisode.setBedSpaceForInfant(voBedSpaceState);
	return voDischargedEpisode;
}
 
Example 4
Project: openMAXIMS   File: Logic.java   Source Code and License Vote up 5 votes
@Override
protected void onBtnCloseClick() throws PresentationLogicException
{
	BedSpaceStateLiteVo voBedSpaceState = form.getGlobalContext().Core.getSelectedBedSpaceState();

	if (voBedSpaceState == null)
		throw new CodingRuntimeException("voBedSpaceState is null in method onBtnCloseClick");

	// move to previous
	if (voBedSpaceState.getCurrentBedStatusIsNotNull())
	{
		voBedSpaceState.setPreviousBedStatus((BedSpaceStateStatusLiteVo) voBedSpaceState.getCurrentBedStatus().clone());
		voBedSpaceState.setCurrentBedStatus(new BedSpaceStateStatusLiteVo());
		voBedSpaceState.getCurrentBedStatus().setStatusDateTime(form.lyrDetail().tabCloseBed().dtimClose().getValue());
		voBedSpaceState.getCurrentBedStatus().setBedStatus(BedStatus.CLOSED);
	}

	String[] arrErrors = voBedSpaceState.validate(getUIValidationForCloseBed());
	if (arrErrors != null)
	{
		engine.showErrors(arrErrors);
		return;
	}

	try
	{
		domain.saveCloseBed(voBedSpaceState, form.lyrDetail().tabCloseBed().cmbUser().getValue(), form.lyrDetail().tabCloseBed().cmbCloseReason().getValue(), form.lyrDetail().tabCloseBed().dtimEstReOpen().getValue());
	}
	catch (StaleObjectException e)
	{
		engine.showMessage(ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue());
		initialise(false, false); //WDEV-17662
		engine.close(DialogResult.OK);
		return;
	}

	engine.close(DialogResult.OK);
}
 
Example 5
Project: openMAXIMS   File: Logic.java   Source Code and License Vote up 5 votes
private DischargedEpisodeADTVo createInfantDischarge(InpatientEpisodeLiteVo voInpat)
{
	DischargedEpisodeADTVo voDischargedEpisode = new DischargedEpisodeADTVo();

	voDischargedEpisode.setDischargeDateTime(form.lyrDetail().tabDischarge().dtimDischarge().getValue());
	voDischargedEpisode.setDischargeDestination(form.lyrDetail().tabDischarge().cmbDischargeDestination().getValue());
	voDischargedEpisode.setMethodOfDischarge(form.lyrDetail().tabDischarge().cmbMethodDischarge().getValue());

	BedSpaceStateLiteVo voBedSpaceState = domain.getBedSpaceStateByInpatientEpisode(voInpat);
	if (voBedSpaceState != null && voBedSpaceState.getInpatientEpisodeIsNotNull())
	{
		voDischargedEpisode.setPasEvent(voBedSpaceState.getInpatientEpisode().getPasEvent());
		voDischargedEpisode.setConsultantStays(voBedSpaceState.getInpatientEpisode().getConsultantStays());
		voDischargedEpisode.setWardStays(voBedSpaceState.getInpatientEpisode().getWardStays());
	}
	else
		voDischargedEpisode.setPasEvent(voInpat.getPasEvent());

	// move to previous
	if (voBedSpaceState != null && voBedSpaceState.getCurrentBedStatusIsNotNull())
	{
		voBedSpaceState.setPreviousBedStatus((BedSpaceStateStatusLiteVo) voBedSpaceState.getCurrentBedStatus().clone());
		voBedSpaceState.setCurrentBedStatus(new BedSpaceStateStatusLiteVo());
		voBedSpaceState.getCurrentBedStatus().setStatusDateTime(new DateTime());
		voBedSpaceState.getCurrentBedStatus().setBedStatus(form.lyrDetail().tabDischarge().chkAllocateForCleaning().getValue() ? BedStatus.FOR_CLEANING : BedStatus.AVAILABLE);
	}

	voDischargedEpisode.setIsActive(true);
	voDischargedEpisode.setBedSpaceForInfant(voBedSpaceState);
	return voDischargedEpisode;
}
 
Example 6
Project: openMAXIMS   File: Logic.java   Source Code and License Vote up 5 votes
@Override
protected void onBtnCloseClick() throws PresentationLogicException
{
	BedSpaceStateLiteVo voBedSpaceState = form.getGlobalContext().Core.getSelectedBedSpaceState();

	if (voBedSpaceState == null)
		throw new CodingRuntimeException("voBedSpaceState is null in method onBtnCloseClick");

	// move to previous
	if (voBedSpaceState.getCurrentBedStatusIsNotNull())
	{
		voBedSpaceState.setPreviousBedStatus((BedSpaceStateStatusLiteVo) voBedSpaceState.getCurrentBedStatus().clone());
		voBedSpaceState.setCurrentBedStatus(new BedSpaceStateStatusLiteVo());
		voBedSpaceState.getCurrentBedStatus().setStatusDateTime(form.lyrDetail().tabCloseBed().dtimClose().getValue());
		voBedSpaceState.getCurrentBedStatus().setBedStatus(BedStatus.CLOSED);
	}

	String[] arrErrors = voBedSpaceState.validate(getUIValidationForCloseBed());
	if (arrErrors != null)
	{
		engine.showErrors(arrErrors);
		return;
	}

	try
	{
		domain.saveCloseBed(voBedSpaceState, form.lyrDetail().tabCloseBed().cmbUser().getValue(), form.lyrDetail().tabCloseBed().cmbCloseReason().getValue(), form.lyrDetail().tabCloseBed().dtimEstReOpen().getValue());
	}
	catch (StaleObjectException e)
	{
		engine.showMessage(ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue());
		initialise();
		engine.close(DialogResult.OK);
		return;
	}

	engine.close(DialogResult.OK);
}
 
Example 7
Project: openmaxims-linux   File: Logic.java   Source Code and License Vote up 5 votes
private DischargedEpisodeADTVo createInfantDischarge(InpatientEpisodeLiteVo voInpat)
{
	DischargedEpisodeADTVo voDischargedEpisode = new DischargedEpisodeADTVo();

	voDischargedEpisode.setDischargeDateTime(form.lyrDetail().tabDischarge().dtimDischarge().getValue());
	voDischargedEpisode.setDischargeDestination(form.lyrDetail().tabDischarge().cmbDischargeDestination().getValue());
	voDischargedEpisode.setMethodOfDischarge(form.lyrDetail().tabDischarge().cmbMethodDischarge().getValue());

	BedSpaceStateLiteVo voBedSpaceState = domain.getBedSpaceStateByInpatientEpisode(voInpat);
	if (voBedSpaceState != null && voBedSpaceState.getInpatientEpisodeIsNotNull())
	{
		voDischargedEpisode.setPasEvent(voBedSpaceState.getInpatientEpisode().getPasEvent());
		voDischargedEpisode.setConsultantStays(voBedSpaceState.getInpatientEpisode().getConsultantStays());
		voDischargedEpisode.setWardStays(voBedSpaceState.getInpatientEpisode().getWardStays());
	}
	else
		voDischargedEpisode.setPasEvent(voInpat.getPasEvent());

	// move to previous
	if (voBedSpaceState != null && voBedSpaceState.getCurrentBedStatusIsNotNull())
	{
		voBedSpaceState.setPreviousBedStatus((BedSpaceStateStatusLiteVo) voBedSpaceState.getCurrentBedStatus().clone());
		voBedSpaceState.setCurrentBedStatus(new BedSpaceStateStatusLiteVo());
		voBedSpaceState.getCurrentBedStatus().setStatusDateTime(new DateTime());
		voBedSpaceState.getCurrentBedStatus().setBedStatus(form.lyrDetail().tabDischarge().chkAllocateForCleaning().getValue() ? BedStatus.FOR_CLEANING : BedStatus.AVAILABLE);
	}

	voDischargedEpisode.setIsActive(true);
	voDischargedEpisode.setBedSpaceForInfant(voBedSpaceState);
	return voDischargedEpisode;
}
 
Example 8
Project: openmaxims-linux   File: Logic.java   Source Code and License Vote up 5 votes
@Override
protected void onBtnCloseClick() throws PresentationLogicException
{
	BedSpaceStateLiteVo voBedSpaceState = form.getGlobalContext().Core.getSelectedBedSpaceState();

	if (voBedSpaceState == null)
		throw new CodingRuntimeException("voBedSpaceState is null in method onBtnCloseClick");

	// move to previous
	if (voBedSpaceState.getCurrentBedStatusIsNotNull())
	{
		voBedSpaceState.setPreviousBedStatus((BedSpaceStateStatusLiteVo) voBedSpaceState.getCurrentBedStatus().clone());
		voBedSpaceState.setCurrentBedStatus(new BedSpaceStateStatusLiteVo());
		voBedSpaceState.getCurrentBedStatus().setStatusDateTime(form.lyrDetail().tabCloseBed().dtimClose().getValue());
		voBedSpaceState.getCurrentBedStatus().setBedStatus(BedStatus.CLOSED);
	}

	String[] arrErrors = voBedSpaceState.validate(getUIValidationForCloseBed());
	if (arrErrors != null)
	{
		engine.showErrors(arrErrors);
		return;
	}

	try
	{
		domain.saveCloseBed(voBedSpaceState, form.lyrDetail().tabCloseBed().cmbUser().getValue(), form.lyrDetail().tabCloseBed().cmbCloseReason().getValue(), form.lyrDetail().tabCloseBed().dtimEstReOpen().getValue());
	}
	catch (StaleObjectException e)
	{
		engine.showMessage(ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue());
		initialise();
		engine.close(DialogResult.OK);
		return;
	}

	engine.close(DialogResult.OK);
}
 
Example 9
Project: AvoinApotti   File: Logic.java   Source Code and License Vote up 4 votes
private void saveReOpenOrAssign(BedStatus status)
{
	////WDEV-17935
	if (BedStatus.FOR_CLEANING.equals(status))
	{
		String[] errCleaningBed = getUIValidationForCloseBed();
		if (errCleaningBed != null)
		{
			engine.showErrors(errCleaningBed);
			return;
		}
	}
	
	BedSpaceStateLiteVo voBedSpaceState = form.getGlobalContext().Core.getSelectedBedSpaceState();

	if (voBedSpaceState == null)
		throw new CodingRuntimeException("voBedSpaceState is null in method saveReOpenOrAssign");

	// move to previous
	if (voBedSpaceState.getCurrentBedStatusIsNotNull())
	{
		voBedSpaceState.setPreviousBedStatus((BedSpaceStateStatusLiteVo) voBedSpaceState.getCurrentBedStatus().clone());
		voBedSpaceState.setCurrentBedStatus(new BedSpaceStateStatusLiteVo());
		voBedSpaceState.getCurrentBedStatus().setStatusDateTime(new DateTime());
		voBedSpaceState.getCurrentBedStatus().setBedStatus(status);
		
		//WDEV-17935
		if (BedStatus.FOR_CLEANING.equals(status))
		{
			voBedSpaceState.getCurrentBedStatus().setReasonForClosure(form.lyrDetail().tabCloseBed().cmbCloseReason().getValue());
			voBedSpaceState.getCurrentBedStatus().setEstReopeningDateTime(form.lyrDetail().tabCloseBed().dtimEstReOpen().getValue());
		}
	}

	String[] arrErrors = voBedSpaceState.validate();
	if (arrErrors != null)
	{
		engine.showErrors(arrErrors);
		return;
	}

	try
	{
		domain.saveReOpenOrAssignBed(voBedSpaceState);
	}
	catch (StaleObjectException e)
	{
		engine.showMessage(ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue());
		initialise();
		return;
	}

	engine.close(DialogResult.OK);
}
 
Example 10
Project: openMAXIMS   File: Logic.java   Source Code and License Vote up 4 votes
private void saveReOpenOrAssign(BedStatus status)
{
	////WDEV-17935
	if (BedStatus.FOR_CLEANING.equals(status))
	{
		String[] errCleaningBed = getUIValidationForCloseBed();
		if (errCleaningBed != null)
		{
			engine.showErrors(errCleaningBed);
			return;
		}
	}
	
	BedSpaceStateLiteVo voBedSpaceState = form.getGlobalContext().Core.getSelectedBedSpaceState();

	if (voBedSpaceState == null)
		throw new CodingRuntimeException("voBedSpaceState is null in method saveReOpenOrAssign");

	// move to previous
	if (voBedSpaceState.getCurrentBedStatusIsNotNull())
	{
		voBedSpaceState.setPreviousBedStatus((BedSpaceStateStatusLiteVo) voBedSpaceState.getCurrentBedStatus().clone());
		voBedSpaceState.setCurrentBedStatus(new BedSpaceStateStatusLiteVo());
		voBedSpaceState.getCurrentBedStatus().setStatusDateTime(form.lyrDetail().tabCloseBed().dtimClose().getValue()); // WDEV-22423 - take date from screen
		voBedSpaceState.getCurrentBedStatus().setBedStatus(status);
		
		//WDEV-17935
		if (BedStatus.FOR_CLEANING.equals(status))
		{
			voBedSpaceState.getCurrentBedStatus().setReasonForClosure(form.lyrDetail().tabCloseBed().cmbCloseReason().getValue());
			voBedSpaceState.getCurrentBedStatus().setEstReopeningDateTime(form.lyrDetail().tabCloseBed().dtimEstReOpen().getValue());
		}
	}

	String[] arrErrors = voBedSpaceState.validate();
	if (arrErrors != null)
	{
		engine.showErrors(arrErrors);
		return;
	}

	try
	{
		domain.saveReOpenOrAssignBed(voBedSpaceState);
	}
	catch (StaleObjectException e)
	{
		engine.showMessage(ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue());
		initialise(false, false); //WDEV-17662
		return;
	}

	engine.close(DialogResult.OK);
}
 
Example 11
Project: openMAXIMS   File: BedInfoDialogImpl.java   Source Code and License Vote up 4 votes
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");
	}
}
 
Example 12
Project: openMAXIMS   File: BedInfoDialogImpl.java   Source Code and License Vote up 4 votes
public void cancelHomeLeaveReturn(InpatientEpisodeLiteVo voInpat,BedSpaceStateLiteVo voBedSpaceState, HomeLeaveVo voHlToReOpen) throws DomainInterfaceException,StaleObjectException
{
	if (voInpat == null)
		throw new CodingRuntimeException("The InpatientEpisodeLiteVo argument cannot be null in method cancelHomeLeaveReturn()");
	if (voHlToReOpen == null)
		throw new CodingRuntimeException("The HomeLeaveVo argument cannot be null in method cancelHomeLeaveReturn()");
	if (!voHlToReOpen.isValidated())
		throw new CodingRuntimeException("The HomeLeaveVo is not validated in method cancelHomeLeaveReturn()");
	DomainFactory factory = getDomainFactory();

	InpatientEpisode inpatEpisodeDO = (InpatientEpisode) factory.getDomainObject(InpatientEpisode.class, voInpat.getID_InpatientEpisode());
	
	if (inpatEpisodeDO == null)
		throw new DomainInterfaceException("This patient is no longer an inpatient. The screen will be refreshed.");
	if (inpatEpisodeDO != null && inpatEpisodeDO.getVersion() > voInpat.getVersion_InpatientEpisode() &&  Boolean.TRUE.equals(inpatEpisodeDO.isIsOnHomeLeave()))
		throw new DomainInterfaceException("This inpatient has been sent on home leave or their home leave return was cancelled by another user. The screen will be refreshed.");
	
	if (inpatEpisodeDO.getHomeLeaves() != null && !inpatEpisodeDO.getHomeLeaves().isEmpty())
	{	
		HomeLeave homeLeaveDO = HomeLeaveVoAssembler.extractHomeLeave(factory, voHlToReOpen);
		
		if (homeLeaveDO != null)
		{
			if (inpatEpisodeDO.getHomeLeaves().contains(homeLeaveDO))
				inpatEpisodeDO.getHomeLeaves().set(inpatEpisodeDO.getHomeLeaves().indexOf(homeLeaveDO), homeLeaveDO);
			
			inpatEpisodeDO.setIsOnHomeLeave(true);
			inpatEpisodeDO.setDateOnHomeLeave(homeLeaveDO.getDateOnHomeLeave() != null ? homeLeaveDO.getDateOnHomeLeave() : null);
			inpatEpisodeDO.setTimeOnHomeLeave(homeLeaveDO.getTimeOnHomeLeave() != null ? homeLeaveDO.getTimeOnHomeLeave() : null);
			inpatEpisodeDO.setExpectedDateOfReturn(homeLeaveDO.getExpectedDateOfReturn() != null ? homeLeaveDO.getExpectedDateOfReturn() : null);
			inpatEpisodeDO.setExpectedTimeOfReturn(homeLeaveDO.getExpectedTimeOfReturn() != null ? homeLeaveDO.getExpectedTimeOfReturn()  : null);
			inpatEpisodeDO.setVacatedBedNumber(homeLeaveDO.getVacatedBedNumber() != null ? homeLeaveDO.getVacatedBedNumber() : null);

			if (voBedSpaceState != null && !Boolean.TRUE.equals(homeLeaveDO.isBedRetained()))
			{
				if (voBedSpaceState.getCurrentBedStatusIsNotNull())
				{
					voBedSpaceState.setPreviousBedStatus((BedSpaceStateStatusLiteVo) voBedSpaceState.getCurrentBedStatus().clone());
					voBedSpaceState.setCurrentBedStatus(new BedSpaceStateStatusLiteVo());
					voBedSpaceState.getCurrentBedStatus().setStatusDateTime(new DateTime());
					voBedSpaceState.getCurrentBedStatus().setBedStatus(BedStatus.AVAILABLE);						
				}
							
				voBedSpaceState.setInpatientEpisode(null);
				
				inpatEpisodeDO.setBed(null);
			}
		}
		if (inpatEpisodeDO.getPasEvent() != null)
		{
			ADT adtimpl = (ADT) getDomainImpl(ADTImpl.class);
			adtimpl.triggerCancelReturnFromLeaveOfAbsenceEvent(new PASEventRefVo(inpatEpisodeDO.getPasEvent().getId(), inpatEpisodeDO.getPasEvent().getVersion()));
		}
		factory.save(inpatEpisodeDO);

		if (voBedSpaceState != null)
		{
			BedSpaceState doBed = BedSpaceStateLiteVoAssembler.extractBedSpaceState(factory, voBedSpaceState);
			factory.save(doBed);				
		}

		if (voBedSpaceState != null && !Boolean.TRUE.equals(voHlToReOpen.getBedRetained()))
			updateOccupiedBedsForWardAndBay(voBedSpaceState.getWard(), voBedSpaceState.getBay(), null);
		
		if (ConfigFlag.UI.BED_INFO_UI_TYPE.getValue().equals("MAXIMS") && voBedSpaceState != null && !Boolean.TRUE.equals(voHlToReOpen.getBedRetained()))
		{
			Sex tempGender = voInpat.getPasEvent() != null && voInpat.getPasEvent().getPatientIsNotNull() && voInpat.getPasEvent().getPatient().getSexIsNotNull() && !Sex.UNKNOWN.equals(voInpat.getPasEvent().getPatient().getSex())? voInpat.getPasEvent().getPatient().getSex() : null;
			checkAndUpdateBayConfig(factory, voBedSpaceState,tempGender);
		}
	}		
}
 
Example 13
Project: openMAXIMS   File: Logic.java   Source Code and License Vote up 4 votes
private void saveReOpenOrAssign(BedStatus status)
{
	////WDEV-17935
	if (BedStatus.FOR_CLEANING.equals(status))
	{
		String[] errCleaningBed = getUIValidationForCloseBed();
		if (errCleaningBed != null)
		{
			engine.showErrors(errCleaningBed);
			return;
		}
	}
	
	BedSpaceStateLiteVo voBedSpaceState = form.getGlobalContext().Core.getSelectedBedSpaceState();

	if (voBedSpaceState == null)
		throw new CodingRuntimeException("voBedSpaceState is null in method saveReOpenOrAssign");

	// move to previous
	if (voBedSpaceState.getCurrentBedStatusIsNotNull())
	{
		voBedSpaceState.setPreviousBedStatus((BedSpaceStateStatusLiteVo) voBedSpaceState.getCurrentBedStatus().clone());
		voBedSpaceState.setCurrentBedStatus(new BedSpaceStateStatusLiteVo());
		voBedSpaceState.getCurrentBedStatus().setStatusDateTime(new DateTime());
		voBedSpaceState.getCurrentBedStatus().setBedStatus(status);
		
		//WDEV-17935
		if (BedStatus.FOR_CLEANING.equals(status))
		{
			voBedSpaceState.getCurrentBedStatus().setReasonForClosure(form.lyrDetail().tabCloseBed().cmbCloseReason().getValue());
			voBedSpaceState.getCurrentBedStatus().setEstReopeningDateTime(form.lyrDetail().tabCloseBed().dtimEstReOpen().getValue());
		}
	}

	String[] arrErrors = voBedSpaceState.validate();
	if (arrErrors != null)
	{
		engine.showErrors(arrErrors);
		return;
	}

	try
	{
		domain.saveReOpenOrAssignBed(voBedSpaceState);
	}
	catch (StaleObjectException e)
	{
		engine.showMessage(ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue());
		initialise();
		return;
	}

	engine.close(DialogResult.OK);
}
 
Example 14
Project: openmaxims-linux   File: Logic.java   Source Code and License Vote up 4 votes
private void saveReOpenOrAssign(BedStatus status)
{
	////WDEV-17935
	if (BedStatus.FOR_CLEANING.equals(status))
	{
		String[] errCleaningBed = getUIValidationForCloseBed();
		if (errCleaningBed != null)
		{
			engine.showErrors(errCleaningBed);
			return;
		}
	}
	
	BedSpaceStateLiteVo voBedSpaceState = form.getGlobalContext().Core.getSelectedBedSpaceState();

	if (voBedSpaceState == null)
		throw new CodingRuntimeException("voBedSpaceState is null in method saveReOpenOrAssign");

	// move to previous
	if (voBedSpaceState.getCurrentBedStatusIsNotNull())
	{
		voBedSpaceState.setPreviousBedStatus((BedSpaceStateStatusLiteVo) voBedSpaceState.getCurrentBedStatus().clone());
		voBedSpaceState.setCurrentBedStatus(new BedSpaceStateStatusLiteVo());
		voBedSpaceState.getCurrentBedStatus().setStatusDateTime(new DateTime());
		voBedSpaceState.getCurrentBedStatus().setBedStatus(status);
		
		//WDEV-17935
		if (BedStatus.FOR_CLEANING.equals(status))
		{
			voBedSpaceState.getCurrentBedStatus().setReasonForClosure(form.lyrDetail().tabCloseBed().cmbCloseReason().getValue());
			voBedSpaceState.getCurrentBedStatus().setEstReopeningDateTime(form.lyrDetail().tabCloseBed().dtimEstReOpen().getValue());
		}
	}

	String[] arrErrors = voBedSpaceState.validate();
	if (arrErrors != null)
	{
		engine.showErrors(arrErrors);
		return;
	}

	try
	{
		domain.saveReOpenOrAssignBed(voBedSpaceState);
	}
	catch (StaleObjectException e)
	{
		engine.showMessage(ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue());
		initialise();
		return;
	}

	engine.close(DialogResult.OK);
}