Java Code Examples for ims.domain.exceptions.DTODomainInterfaceException

The following are top voted examples for showing how to use ims.domain.exceptions.DTODomainInterfaceException. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: openmaxims-linux   File: ExternalAuthUserProvider.java   Source Code and License 6 votes vote down vote up
private void changeMaximsPassword(IAppUser user, String newPassword, java.util.Date pwdExpDate) throws DTODomainInterfaceException, Exception, StaleObjectException
{
	App_users userRec = (App_users)super.getDTOInstance(App_users.class);
	
	userRec.Filter.clear();
	userRec.Filter.Uname = user.getUsername();
	userRec.Filter.User_id = user.getUserId() + "";
			
	Result res = userRec.get();
	if (res != null && res.getId() != DtoErrorCode.NO_DATA_FOUND)
	{
		throw new DTODomainInterfaceException(res.getId(), "Error occurred getting user to DTO server." + res.getMessage());
	}


	userRec.DataCollection.get(0).Upass=Configuration.getHash(newPassword);
	userRec.DataCollection.get(0).Uname=user.getUsername();
	userRec.DataCollection.get(0).User_id = user.getUserId() + "";
	userRec.EditFilter.IncludeDbname=false;
	userRec.EditFilter.IncludeDbpass=false;
	if (pwdExpDate != null)
		userRec.DataCollection.get(0).Passwd_exp=new Date(pwdExpDate).toString(DateFormat.ISO);
	res = userRec.update();
	if (res != null && res.getId() != DtoErrorCode.NO_DATA_FOUND)
	{
		throw new DTODomainInterfaceException(res.getId(), "Error occurred updating password remotely. (" + res.getId() + ")" + res.getMessage());
	}


}
 
Example 2
Project: AvoinApotti   File: ExternalAuthUserProvider.java   Source Code and License 5 votes vote down vote up
private void changeMaximsPassword(IAppUser user, String newPassword, java.util.Date pwdExpDate) throws DTODomainInterfaceException, Exception, StaleObjectException
{
	App_users userRec = (App_users)super.getDTOInstance(App_users.class);
	
	userRec.Filter.clear();
	userRec.Filter.Uname = user.getUsername();
	userRec.Filter.User_id = user.getUserId() + "";
			
	Result res = userRec.get();
	if (res != null && res.getId() != DtoErrorCode.NO_DATA_FOUND)
	{
		throw new DTODomainInterfaceException(res.getId(), "Error occurred getting user to DTO server." + res.getMessage());
	}


	userRec.DataCollection.get(0).Upass=Configuration.getHash(newPassword);
	userRec.DataCollection.get(0).Uname=user.getUsername();
	userRec.DataCollection.get(0).User_id = user.getUserId() + "";
	userRec.EditFilter.IncludeDbname=false;
	userRec.EditFilter.IncludeDbpass=false;
	if (pwdExpDate != null)
		userRec.DataCollection.get(0).Passwd_exp=new Date(pwdExpDate).toString(DateFormat.ISO);
	res = userRec.update();
	if (res != null && res.getId() != DtoErrorCode.NO_DATA_FOUND)
	{
		throw new DTODomainInterfaceException(res.getId(), "Error occurred updating password remotely. (" + res.getId() + ")" + res.getMessage());
	}


}
 
Example 3
Project: AvoinApotti   File: ApplicationUsersImpl.java   Source Code and License 5 votes vote down vote up
private void replicateUserToDtoServer(AppUser user) throws DTODomainInterfaceException
{
	if (user.getUsername() == null || user.getUsername().length() == 0)
		throw new DomainRuntimeException("Username cannot be empty");
	
	App_users userRec = (App_users)getDTOInstance(App_users.class);
	userRec.Filter.clear();
	userRec.Filter.Uname = user.getUsername();
	userRec.Filter.User_id = user.getId() + "";
	
	Result res = userRec.get();
	if (res != null && res.getId() != DtoErrorCode.NO_DATA_FOUND)
	{
		throw new DTODomainInterfaceException(res.getId(), "Error occurred replicating user to DTO server." + res.getMessage());
	}

	if (res != null && res.getId() == DtoErrorCode.NO_DATA_FOUND)
	{
		userRec.DataCollection.add();
		copyUserToDto(userRec, user);
		res = userRec.insert();
		if (res != null && res.getId() < 0 )
		{
			throw new DTODomainInterfaceException(res.getId(), "Error occurred replicating user to DTO server." + res.getMessage());
		}
	}
	else
	{
		copyUserToDto(userRec, user);
		res = userRec.update();
		if (res != null && res.getId() != DtoErrorCode.NO_DATA_FOUND)
		{
			throw new DTODomainInterfaceException(res.getId(), "Error occurred replicating user to DTO server." + res.getMessage());
		}
	}
}
 
Example 4
Project: openMAXIMS   File: ExternalAuthUserProvider.java   Source Code and License 5 votes vote down vote up
private void changeMaximsPassword(IAppUser user, String newPassword, java.util.Date pwdExpDate) throws DTODomainInterfaceException, Exception, StaleObjectException
{
	App_users userRec = (App_users)super.getDTOInstance(App_users.class);
	
	userRec.Filter.clear();
	userRec.Filter.Uname = user.getUsername();
	userRec.Filter.User_id = user.getUserId() + "";
			
	Result res = userRec.get();
	if (res != null && res.getId() != DtoErrorCode.NO_DATA_FOUND)
	{
		throw new DTODomainInterfaceException(res.getId(), "Error occurred getting user to DTO server." + res.getMessage());
	}


	userRec.DataCollection.get(0).Upass=Configuration.getHash(newPassword);
	userRec.DataCollection.get(0).Uname=user.getUsername();
	userRec.DataCollection.get(0).User_id = user.getUserId() + "";
	userRec.EditFilter.IncludeDbname=false;
	userRec.EditFilter.IncludeDbpass=false;
	if (pwdExpDate != null)
		userRec.DataCollection.get(0).Passwd_exp=new Date(pwdExpDate).toString(DateFormat.ISO);
	res = userRec.update();
	if (res != null && res.getId() != DtoErrorCode.NO_DATA_FOUND)
	{
		throw new DTODomainInterfaceException(res.getId(), "Error occurred updating password remotely. (" + res.getId() + ")" + res.getMessage());
	}


}
 
Example 5
Project: openMAXIMS   File: ApplicationUsersImpl.java   Source Code and License 5 votes vote down vote up
private void replicateUserToDtoServer(AppUser user) throws DTODomainInterfaceException
{
	if (user.getUsername() == null || user.getUsername().length() == 0)
		throw new DomainRuntimeException("Username cannot be empty");
	
	App_users userRec = (App_users)getDTOInstance(App_users.class);
	userRec.Filter.clear();
	userRec.Filter.Uname = user.getUsername();
	userRec.Filter.User_id = user.getId() + "";
	
	Result res = userRec.get();
	if (res != null && res.getId() != DtoErrorCode.NO_DATA_FOUND)
	{
		throw new DTODomainInterfaceException(res.getId(), "Error occurred replicating user to DTO server." + res.getMessage());
	}

	if (res != null && res.getId() == DtoErrorCode.NO_DATA_FOUND)
	{
		userRec.DataCollection.add();
		copyUserToDto(userRec, user);
		res = userRec.insert();
		if (res != null && res.getId() < 0 )
		{
			throw new DTODomainInterfaceException(res.getId(), "Error occurred replicating user to DTO server." + res.getMessage());
		}
	}
	else
	{
		copyUserToDto(userRec, user);
		res = userRec.update();
		if (res != null && res.getId() != DtoErrorCode.NO_DATA_FOUND)
		{
			throw new DTODomainInterfaceException(res.getId(), "Error occurred replicating user to DTO server." + res.getMessage());
		}
	}
}
 
Example 6
Project: openMAXIMS   File: ExternalAuthUserProvider.java   Source Code and License 5 votes vote down vote up
private void changeMaximsPassword(IAppUser user, String newPassword, java.util.Date pwdExpDate) throws DTODomainInterfaceException, Exception, StaleObjectException
{
	App_users userRec = (App_users)super.getDTOInstance(App_users.class);
	
	userRec.Filter.clear();
	userRec.Filter.Uname = user.getUsername();
	userRec.Filter.User_id = user.getUserId() + "";
			
	Result res = userRec.get();
	if (res != null && res.getId() != DtoErrorCode.NO_DATA_FOUND)
	{
		throw new DTODomainInterfaceException(res.getId(), "Error occurred getting user to DTO server." + res.getMessage());
	}


	userRec.DataCollection.get(0).Upass=Configuration.getHash(newPassword);
	userRec.DataCollection.get(0).Uname=user.getUsername();
	userRec.DataCollection.get(0).User_id = user.getUserId() + "";
	userRec.EditFilter.IncludeDbname=false;
	userRec.EditFilter.IncludeDbpass=false;
	if (pwdExpDate != null)
		userRec.DataCollection.get(0).Passwd_exp=new Date(pwdExpDate).toString(DateFormat.ISO);
	res = userRec.update();
	if (res != null && res.getId() != DtoErrorCode.NO_DATA_FOUND)
	{
		throw new DTODomainInterfaceException(res.getId(), "Error occurred updating password remotely. (" + res.getId() + ")" + res.getMessage());
	}


}
 
Example 7
Project: openMAXIMS   File: ApplicationUsersImpl.java   Source Code and License 5 votes vote down vote up
private void replicateUserToDtoServer(AppUser user) throws DTODomainInterfaceException
{
	if (user.getUsername() == null || user.getUsername().length() == 0)
		throw new DomainRuntimeException("Username cannot be empty");
	
	App_users userRec = (App_users)getDTOInstance(App_users.class);
	userRec.Filter.clear();
	userRec.Filter.Uname = user.getUsername();
	userRec.Filter.User_id = user.getId() + "";
	
	Result res = userRec.get();
	if (res != null && res.getId() != DtoErrorCode.NO_DATA_FOUND)
	{
		throw new DTODomainInterfaceException(res.getId(), "Error occurred replicating user to DTO server." + res.getMessage());
	}

	if (res != null && res.getId() == DtoErrorCode.NO_DATA_FOUND)
	{
		userRec.DataCollection.add();
		copyUserToDto(userRec, user);
		res = userRec.insert();
		if (res != null && res.getId() < 0 )
		{
			throw new DTODomainInterfaceException(res.getId(), "Error occurred replicating user to DTO server." + res.getMessage());
		}
	}
	else
	{
		copyUserToDto(userRec, user);
		res = userRec.update();
		if (res != null && res.getId() != DtoErrorCode.NO_DATA_FOUND)
		{
			throw new DTODomainInterfaceException(res.getId(), "Error occurred replicating user to DTO server." + res.getMessage());
		}
	}
}
 
Example 8
Project: openmaxims-linux   File: ApplicationUsersImpl.java   Source Code and License 5 votes vote down vote up
private void replicateUserToDtoServer(AppUser user) throws DTODomainInterfaceException
{
	if (user.getUsername() == null || user.getUsername().length() == 0)
		throw new DomainRuntimeException("Username cannot be empty");
	
	App_users userRec = (App_users)getDTOInstance(App_users.class);
	userRec.Filter.clear();
	userRec.Filter.Uname = user.getUsername();
	userRec.Filter.User_id = user.getId() + "";
	
	Result res = userRec.get();
	if (res != null && res.getId() != DtoErrorCode.NO_DATA_FOUND)
	{
		throw new DTODomainInterfaceException(res.getId(), "Error occurred replicating user to DTO server." + res.getMessage());
	}

	if (res != null && res.getId() == DtoErrorCode.NO_DATA_FOUND)
	{
		userRec.DataCollection.add();
		copyUserToDto(userRec, user);
		res = userRec.insert();
		if (res != null && res.getId() < 0 )
		{
			throw new DTODomainInterfaceException(res.getId(), "Error occurred replicating user to DTO server." + res.getMessage());
		}
	}
	else
	{
		copyUserToDto(userRec, user);
		res = userRec.update();
		if (res != null && res.getId() != DtoErrorCode.NO_DATA_FOUND)
		{
			throw new DTODomainInterfaceException(res.getId(), "Error occurred replicating user to DTO server." + res.getMessage());
		}
	}
}
 
Example 9
Project: AvoinApotti   File: BedInfoDialogImpl.java   Source Code and License 4 votes vote down vote up
public CareContextShortVo saveHomeLeave(BedSpaceStateLiteVo voBedSpaceStateLite, InPatientEpisodeADTVo inpatientEpisode, HomeLeaveVo homeLeaveVo) throws DomainInterfaceException, StaleObjectException 
{
	if(inpatientEpisode == null)
		throw new CodingRuntimeException("inpatientEpisode is null in method saveTransfer");
	if(!inpatientEpisode.isValidated())
		throw new CodingRuntimeException("inpatientEpisode has not been validated in method saveTransfer");
	
	if(homeLeaveVo == null)
		throw new CodingRuntimeException("homeLeaveVo is null in method saveHomeLeave");

	DomainFactory factory = getDomainFactory();
	
	if (Boolean.FALSE.equals(ConfigFlag.GEN.USE_ELECTIVE_LIST_FUNCTIONALITY.getValue()))
	{
		Homeleave hlRec = (Homeleave)getDTOInstance(Homeleave.class);
		hlRec.DataCollection.add();
		
		copyHomeleaveToDto(hlRec, homeLeaveVo, inpatientEpisode);
		
		//Update Home Leave on PAS 
		Result res = hlRec.insert();
		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());	
		}
	}		
	//Save MAXIMS HomeLeave
	HomeLeave doHL = HomeLeaveVoAssembler.extractHomeLeave(factory, homeLeaveVo);
	
	//Save IP details
	InpatientEpisode doInpatEpis = InPatientEpisodeADTVoAssembler.extractInpatientEpisode(getDomainFactory(), inpatientEpisode);
	doInpatEpis.getHomeLeaves().add(doHL);
	
	doInpatEpis.setIsOnHomeLeave(true);
	doInpatEpis.setDateOnHomeLeave(homeLeaveVo.getDateOnHomeLeaveIsNotNull() ? homeLeaveVo.getDateOnHomeLeave().getDate() : null);
	doInpatEpis.setTimeOnHomeLeave(homeLeaveVo.getTimeOnHomeLeaveIsNotNull() ? homeLeaveVo.getTimeOnHomeLeave().toString() : null);
	doInpatEpis.setExpectedDateOfReturn(homeLeaveVo.getExpectedDateOfReturnIsNotNull() ? homeLeaveVo.getExpectedDateOfReturn().getDate() : null);
	doInpatEpis.setExpectedTimeOfReturn(homeLeaveVo.getExpectedTimeOfReturnIsNotNull() ? homeLeaveVo.getExpectedTimeOfReturn().toString() : null);
	doInpatEpis.setVacatedBedNumber(homeLeaveVo.getVacatedBedNumberIsNotNull() ? homeLeaveVo.getVacatedBedNumber() : "");
	
	factory.save(doInpatEpis);

	//Vacate the bed.
	if(voBedSpaceStateLite != null)
	{
		BedSpaceState doBed = BedSpaceStateLiteVoAssembler.extractBedSpaceState(factory, voBedSpaceStateLite);
		factory.save(doBed);
	}
	return null;
}
 
Example 10
Project: AvoinApotti   File: BedAdmissionComponentImpl.java   Source Code and License 4 votes vote down vote up
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);
}
 
Example 11
Project: openMAXIMS   File: BedInfoDialogImpl.java   Source Code and License 4 votes vote down vote up
public CareContextShortVo saveHomeLeave(BedSpaceStateLiteVo voBedSpaceStateLite, InPatientEpisodeADTVo inpatientEpisode, HomeLeaveVo homeLeaveVo) throws DomainInterfaceException, StaleObjectException 
{
	if(inpatientEpisode == null)
		throw new CodingRuntimeException("inpatientEpisode is null in method saveTransfer");
	if(!inpatientEpisode.isValidated())
		throw new CodingRuntimeException("inpatientEpisode has not been validated in method saveTransfer");
	
	if(homeLeaveVo == null)
		throw new CodingRuntimeException("homeLeaveVo is null in method saveHomeLeave");

	DomainFactory factory = getDomainFactory();
	
	if (Boolean.FALSE.equals(ConfigFlag.GEN.USE_ELECTIVE_LIST_FUNCTIONALITY.getValue()))
	{
		Homeleave hlRec = (Homeleave)getDTOInstance(Homeleave.class);
		hlRec.DataCollection.add();
		
		copyHomeleaveToDto(hlRec, homeLeaveVo, inpatientEpisode);
		
		//Update Home Leave on PAS 
		Result res = hlRec.insert();
		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());	
		}
	}		
	//Save MAXIMS HomeLeave
	HomeLeave doHL = HomeLeaveVoAssembler.extractHomeLeave(factory, homeLeaveVo);
	
	//Save IP details
	InpatientEpisode doInpatEpis = InPatientEpisodeADTVoAssembler.extractInpatientEpisode(getDomainFactory(), inpatientEpisode);
	doInpatEpis.getHomeLeaves().add(doHL);
	
	doInpatEpis.setIsOnHomeLeave(true);
	doInpatEpis.setDateOnHomeLeave(homeLeaveVo.getDateOnHomeLeaveIsNotNull() ? homeLeaveVo.getDateOnHomeLeave().getDate() : null);
	doInpatEpis.setTimeOnHomeLeave(homeLeaveVo.getTimeOnHomeLeaveIsNotNull() ? homeLeaveVo.getTimeOnHomeLeave().toString() : null);
	doInpatEpis.setExpectedDateOfReturn(homeLeaveVo.getExpectedDateOfReturnIsNotNull() ? homeLeaveVo.getExpectedDateOfReturn().getDate() : null);
	doInpatEpis.setExpectedTimeOfReturn(homeLeaveVo.getExpectedTimeOfReturnIsNotNull() ? homeLeaveVo.getExpectedTimeOfReturn().toString() : null);
	doInpatEpis.setVacatedBedNumber(homeLeaveVo.getVacatedBedNumberIsNotNull() ? homeLeaveVo.getVacatedBedNumber() : "");
	
	factory.save(doInpatEpis);

	//Vacate the bed.
	if(voBedSpaceStateLite != null)
	{
		BedSpaceState doBed = BedSpaceStateLiteVoAssembler.extractBedSpaceState(factory, voBedSpaceStateLite);
		factory.save(doBed);
	}
	return null;
}
 
Example 12
Project: openMAXIMS   File: BedAdmissionComponentImpl.java   Source Code and License 4 votes vote down vote up
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);
}
 
Example 13
Project: openmaxims-linux   File: BedInfoDialogImpl.java   Source Code and License 4 votes vote down vote up
public CareContextShortVo saveHomeLeave(BedSpaceStateLiteVo voBedSpaceStateLite, InPatientEpisodeADTVo inpatientEpisode, HomeLeaveVo homeLeaveVo) throws DomainInterfaceException, StaleObjectException 
{
	if(inpatientEpisode == null)
		throw new CodingRuntimeException("inpatientEpisode is null in method saveTransfer");
	if(!inpatientEpisode.isValidated())
		throw new CodingRuntimeException("inpatientEpisode has not been validated in method saveTransfer");
	
	if(homeLeaveVo == null)
		throw new CodingRuntimeException("homeLeaveVo is null in method saveHomeLeave");

	DomainFactory factory = getDomainFactory();
	
	if (Boolean.FALSE.equals(ConfigFlag.GEN.USE_ELECTIVE_LIST_FUNCTIONALITY.getValue()))
	{
		Homeleave hlRec = (Homeleave)getDTOInstance(Homeleave.class);
		hlRec.DataCollection.add();
		
		copyHomeleaveToDto(hlRec, homeLeaveVo, inpatientEpisode);
		
		//Update Home Leave on PAS 
		Result res = hlRec.insert();
		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());	
		}
	}		
	//Save MAXIMS HomeLeave
	HomeLeave doHL = HomeLeaveVoAssembler.extractHomeLeave(factory, homeLeaveVo);
	
	//Save IP details
	InpatientEpisode doInpatEpis = InPatientEpisodeADTVoAssembler.extractInpatientEpisode(getDomainFactory(), inpatientEpisode);
	doInpatEpis.getHomeLeaves().add(doHL);
	
	doInpatEpis.setIsOnHomeLeave(true);
	doInpatEpis.setDateOnHomeLeave(homeLeaveVo.getDateOnHomeLeaveIsNotNull() ? homeLeaveVo.getDateOnHomeLeave().getDate() : null);
	doInpatEpis.setTimeOnHomeLeave(homeLeaveVo.getTimeOnHomeLeaveIsNotNull() ? homeLeaveVo.getTimeOnHomeLeave().toString() : null);
	doInpatEpis.setExpectedDateOfReturn(homeLeaveVo.getExpectedDateOfReturnIsNotNull() ? homeLeaveVo.getExpectedDateOfReturn().getDate() : null);
	doInpatEpis.setExpectedTimeOfReturn(homeLeaveVo.getExpectedTimeOfReturnIsNotNull() ? homeLeaveVo.getExpectedTimeOfReturn().toString() : null);
	doInpatEpis.setVacatedBedNumber(homeLeaveVo.getVacatedBedNumberIsNotNull() ? homeLeaveVo.getVacatedBedNumber() : "");
	
	factory.save(doInpatEpis);

	//Vacate the bed.
	if(voBedSpaceStateLite != null)
	{
		BedSpaceState doBed = BedSpaceStateLiteVoAssembler.extractBedSpaceState(factory, voBedSpaceStateLite);
		factory.save(doBed);
	}
	return null;
}
 
Example 14
Project: openmaxims-linux   File: BedAdmissionComponentImpl.java   Source Code and License 4 votes vote down vote up
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);
}