Java Code Examples for ims.core.admin.pas.domain.objects.BedSpaceState

The following are top voted examples for showing how to use ims.core.admin.pas.domain.objects.BedSpaceState. 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   File: BedInfoDialogImpl.java   Source Code and License 7 votes vote down vote up
public BedSpaceStateLiteVo getBedSpaceStateByInpatientEpisode(InpatientEpisodeRefVo inpat)
{
	if (inpat == null || inpat.getID_InpatientEpisode() == null)
		throw new CodingRuntimeException("inpat is null or id not provided in method getBedSpaceStateByInpatientEpisode");
	
	String hql = "from BedSpaceState as bed where bed.inpatientEpisode.id = " + inpat.getID_InpatientEpisode();
	List lstBeds = getDomainFactory().find(hql);
	if(lstBeds != null && lstBeds.size() == 1)
		return BedSpaceStateLiteVoAssembler.create((BedSpaceState) lstBeds.get(0));
	
	return null;
}
 
Example 2
Project: AvoinApotti   File: BedInfoDialogImpl.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 3
Project: AvoinApotti   File: ADTImpl.java   Source Code and License 6 votes vote down vote up
private void updateBed(DomainFactory factory, PASEvent peDo) throws StaleObjectException
{	
	BedSpaceState doBedSpaceState = getBedSpaceStateByPasEvent(peDo);
	if(doBedSpaceState != null)
	{
		doBedSpaceState.setPreviousBedStatus(doBedSpaceState.getCurrentBedStatus());
		doBedSpaceState.setCurrentBedStatus(new BedSpaceStateStatus());
		doBedSpaceState.getCurrentBedStatus().setBedStatus(getDomLookup(BedStatus.AVAILABLE));
		doBedSpaceState.getCurrentBedStatus().setStatusDateTime(new DateTime().getJavaDate());
		doBedSpaceState.setInpatientEpisode(null);
		factory.save(doBedSpaceState);	
	}
	
	// WDEV-12588 If CareContext linked to this pasevent, update the bed number there too
	if (ConfigFlag.HL7.INPATIENT_EPISODE_MANAGEMENT_FROM_PAS.getValue())
	{
		CareContext doCareContext = (CareContext) getDomainFactory().findFirst("from CareContext cc where cc.pasEvent.id = " + peDo.getId());
		if (doCareContext != null)
		{
			doCareContext.setBedNumber(null);
			factory.save(doCareContext);
		}
	}

}
 
Example 4
Project: openMAXIMS   File: ADTImpl.java   Source Code and License 6 votes vote down vote up
private void updateBed(DomainFactory factory, PASEvent peDo) throws StaleObjectException
{	
	BedSpaceState doBedSpaceState = getBedSpaceStateByPasEvent(peDo);
	if(doBedSpaceState != null)
	{
		doBedSpaceState.setPreviousBedStatus(doBedSpaceState.getCurrentBedStatus());
		doBedSpaceState.setCurrentBedStatus(new BedSpaceStateStatus());
		doBedSpaceState.getCurrentBedStatus().setBedStatus(getDomLookup(BedStatus.AVAILABLE));
		doBedSpaceState.getCurrentBedStatus().setStatusDateTime(new DateTime().getJavaDate());
		doBedSpaceState.setInpatientEpisode(null);
		factory.save(doBedSpaceState);	
	}
	
	// WDEV-12588 If CareContext linked to this pasevent, update the bed number there too
	if (ConfigFlag.HL7.INPATIENT_EPISODE_MANAGEMENT_FROM_PAS.getValue())
	{
		CareContext doCareContext = (CareContext) getDomainFactory().findFirst("from CareContext cc where cc.pasEvent.id = " + peDo.getId());
		if (doCareContext != null)
		{
			doCareContext.setBedNumber(null);
			factory.save(doCareContext);
		}
	}

}
 
Example 5
Project: openMAXIMS   File: BedInfoDialogImpl.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 6
Project: openMAXIMS   File: ADTImpl.java   Source Code and License 6 votes vote down vote up
private void updateBed(DomainFactory factory, PASEvent peDo) throws StaleObjectException
{	
	BedSpaceState doBedSpaceState = getBedSpaceStateByPasEvent(peDo);
	if(doBedSpaceState != null)
	{
		doBedSpaceState.setPreviousBedStatus(doBedSpaceState.getCurrentBedStatus());
		doBedSpaceState.setCurrentBedStatus(new BedSpaceStateStatus());
		doBedSpaceState.getCurrentBedStatus().setBedStatus(getDomLookup(BedStatus.AVAILABLE));
		doBedSpaceState.getCurrentBedStatus().setStatusDateTime(new DateTime().getJavaDate());
		doBedSpaceState.setInpatientEpisode(null);
		factory.save(doBedSpaceState);	
	}
	
	// WDEV-12588 If CareContext linked to this pasevent, update the bed number there too
	if (ConfigFlag.HL7.INPATIENT_EPISODE_MANAGEMENT_FROM_PAS.getValue())
	{
		CareContext doCareContext = (CareContext) getDomainFactory().findFirst("from CareContext cc where cc.pasEvent.id = " + peDo.getId());
		if (doCareContext != null)
		{
			doCareContext.setBedNumber(null);
			factory.save(doCareContext);
		}
	}

}
 
Example 7
Project: openmaxims-linux   File: BedInfoDialogImpl.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 8
Project: openmaxims-linux   File: ADTImpl.java   Source Code and License 6 votes vote down vote up
private void updateBed(DomainFactory factory, PASEvent peDo) throws StaleObjectException
{	
	BedSpaceState doBedSpaceState = getBedSpaceStateByPasEvent(peDo);
	if(doBedSpaceState != null)
	{
		doBedSpaceState.setPreviousBedStatus(doBedSpaceState.getCurrentBedStatus());
		doBedSpaceState.setCurrentBedStatus(new BedSpaceStateStatus());
		doBedSpaceState.getCurrentBedStatus().setBedStatus(getDomLookup(BedStatus.AVAILABLE));
		doBedSpaceState.getCurrentBedStatus().setStatusDateTime(new DateTime().getJavaDate());
		doBedSpaceState.setInpatientEpisode(null);
		factory.save(doBedSpaceState);	
	}
	
	// WDEV-12588 If CareContext linked to this pasevent, update the bed number there too
	if (ConfigFlag.HL7.INPATIENT_EPISODE_MANAGEMENT_FROM_PAS.getValue())
	{
		CareContext doCareContext = (CareContext) getDomainFactory().findFirst("from CareContext cc where cc.pasEvent.id = " + peDo.getId());
		if (doCareContext != null)
		{
			doCareContext.setBedNumber(null);
			factory.save(doCareContext);
		}
	}

}
 
Example 9
Project: AvoinApotti   File: BedInfoDialogImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo saveCloseBed(BedSpaceStateLiteVo bedSpaceState, String user, ReasonForBedClosure reason, DateTime estReOpen) throws StaleObjectException
{
	if(bedSpaceState == null)
		throw new CodingRuntimeException("bedSpaceState is null in method saveCloseBed");
	
	BedSpaceState doBedSpace = BedSpaceStateLiteVoAssembler.extractBedSpaceState(getDomainFactory(), bedSpaceState);
	doBedSpace.getCurrentBedStatus().setEstReopeningDateTime(estReOpen != null ? estReOpen.getJavaDate() : null);
	doBedSpace.getCurrentBedStatus().setReasonForClosure(getDomLookup(reason));
	doBedSpace.getCurrentBedStatus().getSystemInformation().setCreationUser(user);
	
	getDomainFactory().save(doBedSpace);
	return BedSpaceStateLiteVoAssembler.create(doBedSpace);
}
 
Example 10
Project: AvoinApotti   File: BedInfoDialogImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo getBedSpaceStateByInpatientEpisode(InpatientEpisodeRefVo inpat)
{
	if (inpat == null || inpat.getID_InpatientEpisode() == null)
		throw new CodingRuntimeException("inpat is null or id not provided in method getBedSpaceStateByInpatientEpisode");
	
	String hql = "from BedSpaceState as bed where bed.inpatientEpisode.id = " + inpat.getID_InpatientEpisode();
	List lstBeds = getDomainFactory().find(hql);
	if(lstBeds != null && lstBeds.size() == 1)
		return BedSpaceStateLiteVoAssembler.create((BedSpaceState) lstBeds.get(0));
	
	return null;
}
 
Example 11
Project: AvoinApotti   File: BedInfoDialogImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo getBedSpaceStateStatusByBedId(BedSpaceStateRefVo bedSpaceRef)
{
	if(bedSpaceRef == null || bedSpaceRef.getID_BedSpaceState() == null)
		throw new CodingRuntimeException("Cannot get BedSpaceState on null Id.");
	
	return BedSpaceStateLiteVoAssembler.create(	(BedSpaceState)		getDomainFactory().getDomainObject(BedSpaceState.class, bedSpaceRef.getID_BedSpaceState()));
}
 
Example 12
Project: AvoinApotti   File: ADTImpl.java   Source Code and License 5 votes vote down vote up
private BedSpaceState getBedSpaceStateByPasEvent(PASEvent peDo)
{
	if (peDo == null || peDo.getId() == null)
		throw new CodingRuntimeException("peDo is null or id not provided in method getBedSpaceStateByPasEvent");
	
	String hql = "from BedSpaceState as bed join fetch bed.inpatientEpisode.pasEvent as pe where pe.id = " + peDo.getId();
	List lstBeds = getDomainFactory().find(hql);
	if(lstBeds != null && lstBeds.size() == 1)
		return (BedSpaceState) lstBeds.get(0);
	
	return null;
}
 
Example 13
Project: AvoinApotti   File: BedAdmissionComponentImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo getBedSpaceState(BedSpaceStateRefVo bedRef)
{
	if(bedRef == null || bedRef.getID_BedSpaceState() == null)
		throw new CodingRuntimeException("Cannot get BedSpaceState on null Id.");
	
	return BedSpaceStateLiteVoAssembler.create(	(BedSpaceState)	getDomainFactory().getDomainObject(BedSpaceState.class, bedRef.getID_BedSpaceState()));
}
 
Example 14
Project: AvoinApotti   File: AvailableBedsImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo getBedSpaceState(BedSpaceRefVo bed) 
{
	if(bed == null )
		throw new DomainRuntimeException("Invalid BedRefVo");

	DomainFactory factory = getDomainFactory();
	BedSpaceState domBed = (BedSpaceState) factory.getDomainObject(BedSpaceState.class, bed.getID_BedSpace());
	return BedSpaceStateLiteVoAssembler.create(domBed);
}
 
Example 15
Project: AvoinApotti   File: AvailableBedsImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo getBedSpaceState(BedSpaceStateLiteVo bed) 
{
	if(bed == null )
		throw new DomainRuntimeException("Invalid BedRefVo");

	DomainFactory factory = getDomainFactory();
	BedSpaceState domBed = (BedSpaceState) factory.getDomainObject(BedSpaceState.class, bed.getID_BedSpaceState());
	return BedSpaceStateLiteVoAssembler.create(domBed);
}
 
Example 16
Project: AvoinApotti   File: AvailableBedsImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo saveBedSpaceState(BedSpaceStateLiteVo voBSS) throws DomainInterfaceException, StaleObjectException 
{
	if (!voBSS.isValidated())
		throw new CodingRuntimeException("BedSpaceStateLiteVo Record has not been validated");
	if(voBSS == null)
		throw new CodingRuntimeException("Cannot save null BedSpaceStateLiteVo");
	
	DomainFactory factory = getDomainFactory();
	
	BedSpaceState doBSS = BedSpaceStateLiteVoAssembler.extractBedSpaceState(factory, voBSS);
	factory.save(doBSS);
	return (BedSpaceStateLiteVoAssembler.create(doBSS));		
}
 
Example 17
Project: AvoinApotti   File: WardViewImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo getBedSpaceState(BedSpaceRefVo bed) 
{
	if(bed == null )
		throw new DomainRuntimeException("Invalid BedRefVo");
	
	String hql = "select bs from BedSpaceState as bs left join bs.bedSpace as bed where bed.id = " + bed.getID_BedSpace();
	List bedState = getDomainFactory().find(hql);
	
	//WDEV-11039
	boolean hasAlerts = false;
	if(bedState != null && bedState.size() > 0)
	{	
		BedSpaceState doBed = (BedSpaceState)bedState.get(0);
		if(doBed.getInpatientEpisode() != null && doBed.getInpatientEpisode().getPasEvent() != null && doBed.getInpatientEpisode().getPasEvent().getPatient() != null && doBed.getInpatientEpisode().getPasEvent().getPatient().getPatientAlerts() != null)
			if(doBed.getInpatientEpisode().getPasEvent().getPatient().getPatientAlerts().size() > 0 && isOneActive(doBed.getInpatientEpisode().getPasEvent().getPatient().getPatientAlerts(), true))
				hasAlerts = true;
	}
	
	BedSpaceStateLiteVoCollection voColl = BedSpaceStateLiteVoAssembler.createBedSpaceStateLiteVoCollectionFromBedSpaceState(bedState);
	
	if (voColl != null && voColl.size() > 0)
	{
		if(voColl.get(0).getInpatientEpisodeIsNotNull() && voColl.get(0).getInpatientEpisode().getPasEventIsNotNull() && voColl.get(0).getInpatientEpisode().getPasEvent().getPatientIsNotNull())
			voColl.get(0).getInpatientEpisode().getPasEvent().getPatient().setHasAlerts(hasAlerts);
		
		return voColl.get(0);		
	}
	return null;
}
 
Example 18
Project: openMAXIMS   File: WardViewPatientListImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo getSelectedBedSpaceState(BedSpaceStateRefVo bedSpaceRef)
{
	DomainFactory factory = getDomainFactory();
	 BedSpaceState doBedSpaceState = (BedSpaceState) factory.getDomainObject(BedSpaceState.class, bedSpaceRef.getID_BedSpaceState());
	 
	return doBedSpaceState != null ? BedSpaceStateLiteVoAssembler.create(doBedSpaceState) : null;
}
 
Example 19
Project: openMAXIMS   File: WardViewPatientListImpl.java   Source Code and License 5 votes vote down vote up
public void returnFromHomeLeaveToWard(InpatientEpisodeLiteVo voInpat, HomeLeaveVo voHomeLeave)	throws DomainInterfaceException, StaleObjectException
{
	if (voInpat == null)
		throw new CodingRuntimeException("voInpat argumment cannot be null in method returnFromHomeLeaveToWard()");
	
	BedAdmissionComponent impl = (BedAdmissionComponent) getDomainImpl(BedAdmissionComponentImpl.class);
	AdmissionDetailVo voAdmissionDetail = null;
	
	if (voInpat.getBedIsNotNull())
	{
		DomainFactory domainFactory = getDomainFactory();
		BedSpaceState doBedSpaceState = (BedSpaceState) domainFactory.getDomainObject(BedSpaceState.class, voInpat.getBed().getID_BedSpaceState());
		
		if (doBedSpaceState.getCurrentBedStatus() != null)
		{
			BedSpaceStateStatusLiteVo voBedSpaceStatus = BedSpaceStateStatusLiteVoAssembler.create(doBedSpaceState.getCurrentBedStatus());
			BedSpaceStateStatusLiteVo voPrevBedStatus = (BedSpaceStateStatusLiteVo) voBedSpaceStatus.clone();
			
			doBedSpaceState.setPreviousBedStatus(BedSpaceStateStatusLiteVoAssembler.extractBedSpaceStateStatus(domainFactory, voPrevBedStatus));
			doBedSpaceState.setCurrentBedStatus(new BedSpaceStateStatus());
			doBedSpaceState.getCurrentBedStatus().setStatusDateTime(new DateTime(voHomeLeave.getDateReturnedFromHomeLeave(),(voHomeLeave.getTimeReturnedFromHomeLeave() != null ? voHomeLeave.getTimeReturnedFromHomeLeave() : new Time(0,0))).getJavaDate());
			doBedSpaceState.getCurrentBedStatus().setBedStatus(getDomLookup(BedStatus.AVAILABLE));

			voHomeLeave.setVacatedBedNumber(doBedSpaceState.getBedSpace() != null ? doBedSpaceState.getBedSpace().getBedNumber() : null);
		}

		doBedSpaceState.setInpatientEpisode(null);
		domainFactory.save(doBedSpaceState);
	}
	
	if (voInpat != null && voInpat.getPasEventIsNotNull())
		voAdmissionDetail  = impl.getAdmissionDetailByPasEvent(voInpat.getPasEvent());
	impl.returnFromHomeLeaveToWardWaitingArea(voInpat, voAdmissionDetail, voHomeLeave);		
}
 
Example 20
Project: openMAXIMS   File: BedInfoDialogImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo saveCloseBed(BedSpaceStateLiteVo bedSpaceState, String user, ReasonForBedClosure reason, DateTime estReOpen) throws StaleObjectException
{
	if(bedSpaceState == null)
		throw new CodingRuntimeException("bedSpaceState is null in method saveCloseBed");
	
	BedSpaceState doBedSpace = BedSpaceStateLiteVoAssembler.extractBedSpaceState(getDomainFactory(), bedSpaceState);
	doBedSpace.getCurrentBedStatus().setEstReopeningDateTime(estReOpen != null ? estReOpen.getJavaDate() : null);
	doBedSpace.getCurrentBedStatus().setReasonForClosure(getDomLookup(reason));
	doBedSpace.getCurrentBedStatus().getSystemInformation().setCreationUser(user);
	
	getDomainFactory().save(doBedSpace);
	return BedSpaceStateLiteVoAssembler.create(doBedSpace);
}
 
Example 21
Project: openMAXIMS   File: BedInfoDialogImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo getBedSpaceStateByInpatientEpisode(InpatientEpisodeRefVo inpat)
{
	if (inpat == null || inpat.getID_InpatientEpisode() == null)
		throw new CodingRuntimeException("inpat is null or id not provided in method getBedSpaceStateByInpatientEpisode");
	
	String hql = "from BedSpaceState as bed where bed.inpatientEpisode.id = " + inpat.getID_InpatientEpisode();
	List lstBeds = getDomainFactory().find(hql);
	if(lstBeds != null && lstBeds.size() == 1)
		return BedSpaceStateLiteVoAssembler.create((BedSpaceState) lstBeds.get(0));
	
	return null;
}
 
Example 22
Project: openMAXIMS   File: BedInfoDialogImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo getBedSpaceStateStatusByBedId(BedSpaceStateRefVo bedSpaceRef)
{
	if(bedSpaceRef == null || bedSpaceRef.getID_BedSpaceState() == null)
		throw new CodingRuntimeException("Cannot get BedSpaceState on null Id.");
	
	return BedSpaceStateLiteVoAssembler.create(	(BedSpaceState)		getDomainFactory().getDomainObject(BedSpaceState.class, bedSpaceRef.getID_BedSpaceState()));
}
 
Example 23
Project: openMAXIMS   File: BedInfoDialogImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo getBedSpaceState(BedSpaceStateRefVo bedSpaceState)
{
	if (bedSpaceState == null || bedSpaceState.getID_BedSpaceState() == null)
		return null;
	
	return BedSpaceStateLiteVoAssembler.create((BedSpaceState) getDomainFactory().getDomainObject(BedSpaceState.class, bedSpaceState.getID_BedSpaceState()));
}
 
Example 24
Project: openMAXIMS   File: ADTImpl.java   Source Code and License 5 votes vote down vote up
private BedSpaceState getBedSpaceStateByPasEvent(PASEvent peDo)
{
	if (peDo == null || peDo.getId() == null)
		throw new CodingRuntimeException("peDo is null or id not provided in method getBedSpaceStateByPasEvent");
	
	String hql = "from BedSpaceState as bed join fetch bed.inpatientEpisode.pasEvent as pe where pe.id = " + peDo.getId();
	List lstBeds = getDomainFactory().find(hql);
	if(lstBeds != null && lstBeds.size() == 1)
		return (BedSpaceState) lstBeds.get(0);
	
	return null;
}
 
Example 25
Project: openMAXIMS   File: WardDataViewImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo getBedSpaceState(BedSpaceStateRefVo bedSpaceState)
{
	if (bedSpaceState == null || bedSpaceState.getID_BedSpaceState() == null)
		return null;

	return BedSpaceStateLiteVoAssembler.create((BedSpaceState) getDomainFactory().getDomainObject(BedSpaceState.class, bedSpaceState.getID_BedSpaceState()));
}
 
Example 26
Project: openMAXIMS   File: BedAdmissionComponentImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo getBedSpaceState(BedSpaceStateRefVo bedRef)
{
	if(bedRef == null || bedRef.getID_BedSpaceState() == null)
		throw new CodingRuntimeException("Cannot get BedSpaceState on null Id.");

	return BedSpaceStateLiteVoAssembler.create(	(BedSpaceState)	getDomainFactory().getDomainObject(BedSpaceState.class, bedRef.getID_BedSpaceState()));
}
 
Example 27
Project: openMAXIMS   File: AvailableBedsImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo getBedSpaceState(BedSpaceRefVo bed) 
{
	if(bed == null )
		throw new DomainRuntimeException("Invalid BedRefVo");

	DomainFactory factory = getDomainFactory();
	BedSpaceState domBed = (BedSpaceState) factory.getDomainObject(BedSpaceState.class, bed.getID_BedSpace());
	return BedSpaceStateLiteVoAssembler.create(domBed);
}
 
Example 28
Project: openMAXIMS   File: AvailableBedsImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo getBedSpaceState(BedSpaceStateLiteVo bed) 
{
	if(bed == null )
		throw new DomainRuntimeException("Invalid BedRefVo");

	DomainFactory factory = getDomainFactory();
	BedSpaceState domBed = (BedSpaceState) factory.getDomainObject(BedSpaceState.class, bed.getID_BedSpaceState());
	return BedSpaceStateLiteVoAssembler.create(domBed);
}
 
Example 29
Project: openMAXIMS   File: AvailableBedsImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo saveBedSpaceState(BedSpaceStateLiteVo voBSS) throws DomainInterfaceException, StaleObjectException 
{
	if (!voBSS.isValidated())
		throw new CodingRuntimeException("BedSpaceStateLiteVo Record has not been validated");
	if(voBSS == null)
		throw new CodingRuntimeException("Cannot save null BedSpaceStateLiteVo");
	
	DomainFactory factory = getDomainFactory();
	
	BedSpaceState doBSS = BedSpaceStateLiteVoAssembler.extractBedSpaceState(factory, voBSS);
	factory.save(doBSS);
	return (BedSpaceStateLiteVoAssembler.create(doBSS));		
}
 
Example 30
Project: openMAXIMS   File: BedInfoDialogImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo saveCloseBed(BedSpaceStateLiteVo bedSpaceState, String user, ReasonForBedClosure reason, DateTime estReOpen) throws StaleObjectException
{
	if(bedSpaceState == null)
		throw new CodingRuntimeException("bedSpaceState is null in method saveCloseBed");
	
	BedSpaceState doBedSpace = BedSpaceStateLiteVoAssembler.extractBedSpaceState(getDomainFactory(), bedSpaceState);
	doBedSpace.getCurrentBedStatus().setEstReopeningDateTime(estReOpen != null ? estReOpen.getJavaDate() : null);
	doBedSpace.getCurrentBedStatus().setReasonForClosure(getDomLookup(reason));
	doBedSpace.getCurrentBedStatus().getSystemInformation().setCreationUser(user);
	
	getDomainFactory().save(doBedSpace);
	return BedSpaceStateLiteVoAssembler.create(doBedSpace);
}
 
Example 31
Project: openMAXIMS   File: BedInfoDialogImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo getBedSpaceStateStatusByBedId(BedSpaceStateRefVo bedSpaceRef)
{
	if(bedSpaceRef == null || bedSpaceRef.getID_BedSpaceState() == null)
		throw new CodingRuntimeException("Cannot get BedSpaceState on null Id.");
	
	return BedSpaceStateLiteVoAssembler.create(	(BedSpaceState)		getDomainFactory().getDomainObject(BedSpaceState.class, bedSpaceRef.getID_BedSpaceState()));
}
 
Example 32
Project: openMAXIMS   File: ADTImpl.java   Source Code and License 5 votes vote down vote up
private BedSpaceState getBedSpaceStateByPasEvent(PASEvent peDo)
{
	if (peDo == null || peDo.getId() == null)
		throw new CodingRuntimeException("peDo is null or id not provided in method getBedSpaceStateByPasEvent");
	
	String hql = "from BedSpaceState as bed join fetch bed.inpatientEpisode.pasEvent as pe where pe.id = " + peDo.getId();
	List lstBeds = getDomainFactory().find(hql);
	if(lstBeds != null && lstBeds.size() == 1)
		return (BedSpaceState) lstBeds.get(0);
	
	return null;
}
 
Example 33
Project: openMAXIMS   File: BedAdmissionComponentImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo getBedSpaceState(BedSpaceStateRefVo bedRef)
{
	if(bedRef == null || bedRef.getID_BedSpaceState() == null)
		throw new CodingRuntimeException("Cannot get BedSpaceState on null Id.");
	
	return BedSpaceStateLiteVoAssembler.create(	(BedSpaceState)	getDomainFactory().getDomainObject(BedSpaceState.class, bedRef.getID_BedSpaceState()));
}
 
Example 34
Project: openMAXIMS   File: AvailableBedsImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo getBedSpaceState(BedSpaceRefVo bed) 
{
	if(bed == null )
		throw new DomainRuntimeException("Invalid BedRefVo");

	DomainFactory factory = getDomainFactory();
	BedSpaceState domBed = (BedSpaceState) factory.getDomainObject(BedSpaceState.class, bed.getID_BedSpace());
	return BedSpaceStateLiteVoAssembler.create(domBed);
}
 
Example 35
Project: openMAXIMS   File: AvailableBedsImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo getBedSpaceState(BedSpaceStateLiteVo bed) 
{
	if(bed == null )
		throw new DomainRuntimeException("Invalid BedRefVo");

	DomainFactory factory = getDomainFactory();
	BedSpaceState domBed = (BedSpaceState) factory.getDomainObject(BedSpaceState.class, bed.getID_BedSpaceState());
	return BedSpaceStateLiteVoAssembler.create(domBed);
}
 
Example 36
Project: openMAXIMS   File: AvailableBedsImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo saveBedSpaceState(BedSpaceStateLiteVo voBSS) throws DomainInterfaceException, StaleObjectException 
{
	if (!voBSS.isValidated())
		throw new CodingRuntimeException("BedSpaceStateLiteVo Record has not been validated");
	if(voBSS == null)
		throw new CodingRuntimeException("Cannot save null BedSpaceStateLiteVo");
	
	DomainFactory factory = getDomainFactory();
	
	BedSpaceState doBSS = BedSpaceStateLiteVoAssembler.extractBedSpaceState(factory, voBSS);
	factory.save(doBSS);
	return (BedSpaceStateLiteVoAssembler.create(doBSS));		
}
 
Example 37
Project: openMAXIMS   File: WardViewImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo getBedSpaceState(BedSpaceRefVo bed) 
{
	if(bed == null )
		throw new DomainRuntimeException("Invalid BedRefVo");
	
	String hql = "select bs from BedSpaceState as bs left join bs.bedSpace as bed where bed.id = " + bed.getID_BedSpace();
	List bedState = getDomainFactory().find(hql);
	
	//WDEV-11039
	boolean hasAlerts = false;
	if(bedState != null && bedState.size() > 0)
	{	
		BedSpaceState doBed = (BedSpaceState)bedState.get(0);
		if(doBed.getInpatientEpisode() != null && doBed.getInpatientEpisode().getPasEvent() != null && doBed.getInpatientEpisode().getPasEvent().getPatient() != null && doBed.getInpatientEpisode().getPasEvent().getPatient().getPatientAlerts() != null)
			if(doBed.getInpatientEpisode().getPasEvent().getPatient().getPatientAlerts().size() > 0 && isOneActive(doBed.getInpatientEpisode().getPasEvent().getPatient().getPatientAlerts(), true))
				hasAlerts = true;
	}
	
	BedSpaceStateLiteVoCollection voColl = BedSpaceStateLiteVoAssembler.createBedSpaceStateLiteVoCollectionFromBedSpaceState(bedState);
	
	if (voColl != null && voColl.size() > 0)
	{
		if(voColl.get(0).getInpatientEpisodeIsNotNull() && voColl.get(0).getInpatientEpisode().getPasEventIsNotNull() && voColl.get(0).getInpatientEpisode().getPasEvent().getPatientIsNotNull())
			voColl.get(0).getInpatientEpisode().getPasEvent().getPatient().setHasAlerts(hasAlerts);
		
		return voColl.get(0);		
	}
	return null;
}
 
Example 38
Project: openmaxims-linux   File: BedInfoDialogImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo saveCloseBed(BedSpaceStateLiteVo bedSpaceState, String user, ReasonForBedClosure reason, DateTime estReOpen) throws StaleObjectException
{
	if(bedSpaceState == null)
		throw new CodingRuntimeException("bedSpaceState is null in method saveCloseBed");
	
	BedSpaceState doBedSpace = BedSpaceStateLiteVoAssembler.extractBedSpaceState(getDomainFactory(), bedSpaceState);
	doBedSpace.getCurrentBedStatus().setEstReopeningDateTime(estReOpen != null ? estReOpen.getJavaDate() : null);
	doBedSpace.getCurrentBedStatus().setReasonForClosure(getDomLookup(reason));
	doBedSpace.getCurrentBedStatus().getSystemInformation().setCreationUser(user);
	
	getDomainFactory().save(doBedSpace);
	return BedSpaceStateLiteVoAssembler.create(doBedSpace);
}
 
Example 39
Project: openmaxims-linux   File: BedInfoDialogImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo getBedSpaceStateByInpatientEpisode(InpatientEpisodeRefVo inpat)
{
	if (inpat == null || inpat.getID_InpatientEpisode() == null)
		throw new CodingRuntimeException("inpat is null or id not provided in method getBedSpaceStateByInpatientEpisode");
	
	String hql = "from BedSpaceState as bed where bed.inpatientEpisode.id = " + inpat.getID_InpatientEpisode();
	List lstBeds = getDomainFactory().find(hql);
	if(lstBeds != null && lstBeds.size() == 1)
		return BedSpaceStateLiteVoAssembler.create((BedSpaceState) lstBeds.get(0));
	
	return null;
}
 
Example 40
Project: openmaxims-linux   File: BedInfoDialogImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo getBedSpaceStateStatusByBedId(BedSpaceStateRefVo bedSpaceRef)
{
	if(bedSpaceRef == null || bedSpaceRef.getID_BedSpaceState() == null)
		throw new CodingRuntimeException("Cannot get BedSpaceState on null Id.");
	
	return BedSpaceStateLiteVoAssembler.create(	(BedSpaceState)		getDomainFactory().getDomainObject(BedSpaceState.class, bedSpaceRef.getID_BedSpaceState()));
}
 
Example 41
Project: openmaxims-linux   File: ADTImpl.java   Source Code and License 5 votes vote down vote up
private BedSpaceState getBedSpaceStateByPasEvent(PASEvent peDo)
{
	if (peDo == null || peDo.getId() == null)
		throw new CodingRuntimeException("peDo is null or id not provided in method getBedSpaceStateByPasEvent");
	
	String hql = "from BedSpaceState as bed join fetch bed.inpatientEpisode.pasEvent as pe where pe.id = " + peDo.getId();
	List lstBeds = getDomainFactory().find(hql);
	if(lstBeds != null && lstBeds.size() == 1)
		return (BedSpaceState) lstBeds.get(0);
	
	return null;
}
 
Example 42
Project: openmaxims-linux   File: BedAdmissionComponentImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo getBedSpaceState(BedSpaceStateRefVo bedRef)
{
	if(bedRef == null || bedRef.getID_BedSpaceState() == null)
		throw new CodingRuntimeException("Cannot get BedSpaceState on null Id.");
	
	return BedSpaceStateLiteVoAssembler.create(	(BedSpaceState)	getDomainFactory().getDomainObject(BedSpaceState.class, bedRef.getID_BedSpaceState()));
}
 
Example 43
Project: openmaxims-linux   File: AvailableBedsImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo getBedSpaceState(BedSpaceRefVo bed) 
{
	if(bed == null )
		throw new DomainRuntimeException("Invalid BedRefVo");

	DomainFactory factory = getDomainFactory();
	BedSpaceState domBed = (BedSpaceState) factory.getDomainObject(BedSpaceState.class, bed.getID_BedSpace());
	return BedSpaceStateLiteVoAssembler.create(domBed);
}
 
Example 44
Project: openmaxims-linux   File: AvailableBedsImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo getBedSpaceState(BedSpaceStateLiteVo bed) 
{
	if(bed == null )
		throw new DomainRuntimeException("Invalid BedRefVo");

	DomainFactory factory = getDomainFactory();
	BedSpaceState domBed = (BedSpaceState) factory.getDomainObject(BedSpaceState.class, bed.getID_BedSpaceState());
	return BedSpaceStateLiteVoAssembler.create(domBed);
}
 
Example 45
Project: openmaxims-linux   File: AvailableBedsImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo saveBedSpaceState(BedSpaceStateLiteVo voBSS) throws DomainInterfaceException, StaleObjectException 
{
	if (!voBSS.isValidated())
		throw new CodingRuntimeException("BedSpaceStateLiteVo Record has not been validated");
	if(voBSS == null)
		throw new CodingRuntimeException("Cannot save null BedSpaceStateLiteVo");
	
	DomainFactory factory = getDomainFactory();
	
	BedSpaceState doBSS = BedSpaceStateLiteVoAssembler.extractBedSpaceState(factory, voBSS);
	factory.save(doBSS);
	return (BedSpaceStateLiteVoAssembler.create(doBSS));		
}
 
Example 46
Project: openmaxims-linux   File: WardViewImpl.java   Source Code and License 5 votes vote down vote up
public BedSpaceStateLiteVo getBedSpaceState(BedSpaceRefVo bed) 
{
	if(bed == null )
		throw new DomainRuntimeException("Invalid BedRefVo");
	
	String hql = "select bs from BedSpaceState as bs left join bs.bedSpace as bed where bed.id = " + bed.getID_BedSpace();
	List bedState = getDomainFactory().find(hql);
	
	//WDEV-11039
	boolean hasAlerts = false;
	if(bedState != null && bedState.size() > 0)
	{	
		BedSpaceState doBed = (BedSpaceState)bedState.get(0);
		if(doBed.getInpatientEpisode() != null && doBed.getInpatientEpisode().getPasEvent() != null && doBed.getInpatientEpisode().getPasEvent().getPatient() != null && doBed.getInpatientEpisode().getPasEvent().getPatient().getPatientAlerts() != null)
			if(doBed.getInpatientEpisode().getPasEvent().getPatient().getPatientAlerts().size() > 0 && isOneActive(doBed.getInpatientEpisode().getPasEvent().getPatient().getPatientAlerts(), true))
				hasAlerts = true;
	}
	
	BedSpaceStateLiteVoCollection voColl = BedSpaceStateLiteVoAssembler.createBedSpaceStateLiteVoCollectionFromBedSpaceState(bedState);
	
	if (voColl != null && voColl.size() > 0)
	{
		if(voColl.get(0).getInpatientEpisodeIsNotNull() && voColl.get(0).getInpatientEpisode().getPasEventIsNotNull() && voColl.get(0).getInpatientEpisode().getPasEvent().getPatientIsNotNull())
			voColl.get(0).getInpatientEpisode().getPasEvent().getPatient().setHasAlerts(hasAlerts);
		
		return voColl.get(0);		
	}
	return null;
}
 
Example 47
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 48
Project: AvoinApotti   File: BedAdmissionComponentImpl.java   Source Code and License 4 votes vote down vote up
public AdmissionDetailVo saveEmergencyAdmissionInElectiveCase(AdmissionDetailVo admission, CareSpellVo careSpell, CatsReferralEmergencyAdmissionVo catsReferral, BedSpaceStateLiteVo bedSpaceState, WardStayVo wardStay, ConsultantStayVo consultant) throws DomainInterfaceException, StaleObjectException
{
	if (admission == null)
		throw new CodingRuntimeException("Admission Details parameter is mandatory.");
	
	if (careSpell == null)
		throw new CodingRuntimeException("Care Spell parameter is mandatory.");
	
	if (catsReferral == null)
		throw new CodingRuntimeException("Cats Referral parameter is mandatory.");
	
	
	PatientPathwayJourneyRefVo journey = createPatientJourney(catsReferral, admission);
	catsReferral.setJourney(journey);
	
	@SuppressWarnings("rawtypes")
	HashMap domMap = new HashMap();
	AdmissionDetail domAdmissionDetail = AdmissionDetailVoAssembler.extractAdmissionDetail(getDomainFactory(), admission, domMap);
	CareSpell domCareSpell = CareSpellVoAssembler.extractCareSpell(getDomainFactory(), careSpell, domMap);
	CatsReferral domCatsReferral = CatsReferralEmergencyAdmissionVoAssembler.extractCatsReferral(getDomainFactory(), catsReferral, domMap);
	domCatsReferral.getCareContext().setPasEvent(domAdmissionDetail.getPasEvent());
	
	getDomainFactory().save(domAdmissionDetail);
	getDomainFactory().save(domCareSpell);
	getDomainFactory().save(domCatsReferral);

	InpatientEpisode inpatEpisode = new InpatientEpisode();
	inpatEpisode.setPasEvent(domAdmissionDetail.getPasEvent());
	inpatEpisode.getPasEvent().setConsultant(domAdmissionDetail.getConsultant());
	inpatEpisode.setAdmissionDateTime(domAdmissionDetail.getAdmissionDateTime());
	inpatEpisode.setEstDischargeDate(null);
	inpatEpisode.setWardType(domAdmissionDetail.getWardType());
	
	if (wardStay != null)
		inpatEpisode.getWardStays().add(WardStayVoAssembler.extractWardStay(getDomainFactory(), wardStay, domMap));
	if (consultant != null)
		inpatEpisode.getConsultantStays().add(ConsultantStayVoAssembler.extractConsultantStay(getDomainFactory(), consultant, domMap));
	
	BedSpaceState doBedSpaceState = BedSpaceStateLiteVoAssembler.extractBedSpaceState(getDomainFactory(), bedSpaceState, domMap);	
	if(doBedSpaceState != null)
	{
		doBedSpaceState.setInpatientEpisode(inpatEpisode);	
		inpatEpisode.setBed(doBedSpaceState);
		inpatEpisode.setBedNo(doBedSpaceState.getBedSpace().getBedNumber());
	}

	if (wardStay != null && wardStay.getWardIsNotNull() && ConfigFlag.UI.VTE_RISK_ASSESSMENT_FUNCTIONALITY.getValue() == true)
	{
		Location doloc = getLocation(wardStay.getWard().getID_Location(), getDomainFactory());
		if (doloc != null && !Boolean.TRUE.equals(doloc.isVTEAsessmentNotRequired()))
		{
			inpatEpisode.setVTEAssessmentStatus(getDomLookup(VTEAsessmentStatus.REQUIRED));
		}
	}
	
	getDomainFactory().save(inpatEpisode);

	return null;
}
 
Example 49
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 50
Project: openMAXIMS   File: WardViewPatientListImpl.java   Source Code and License 4 votes vote down vote up
public WardViewPatientListVoCollection listForPatientsOnTheWard(LocationRefVo ward, LocationRefVo bay)
{
	if (ward == null || ward.getID_Location() == null)
		return null;
	
	StringBuilder query = new StringBuilder("SELECT inpatEp, patient, bedSpaceState, ");
	query.append(" (select count(pt.id) from PendingTransfers as pt left join pt.inpatientEpisode as inp where inp.id = inpatEp.id and pt.currentStatus.id = :PENDING_TRANSF) ");
	query.append(" FROM BedSpaceState AS bedSpaceState LEFT JOIN bedSpaceState.inpatientEpisode AS inpatEp ");
	query.append(" LEFT JOIN inpatEp.pasEvent AS pas LEFT JOIN pas.patient AS patient ");
	
	query.append(" WHERE pas.location.id = :WARD_ID ");
	query.append(" AND inpatEp.bed is not null AND (inpatEp.isOnHomeLeave is null OR inpatEp.isOnHomeLeave = 0)");
	
	query.append(" ORDER BY patient.name.upperSurname, patient.name.upperForename ");
	
	
	List<?> results = getDomainFactory().find(query.toString(), new String[]{"PENDING_TRANSF",  "WARD_ID"}, new Object[] {TransferStatus.PENDING.getID(), ward.getID_Location()});
	
	if (results == null || results.size() == 0)
		return null;
	
	WardViewPatientListVoCollection wardViewPatientsCollection = new WardViewPatientListVoCollection();
	
	Iterator<?> iterator = results.iterator();
	
	while (iterator.hasNext())
	{
		Object[] item = (Object[]) iterator.next();
		
		InpatientEpisode doInpat = (InpatientEpisode) item[0];
		Patient doPatient = (Patient) item[1];
		BedSpaceState doBedSpace = (BedSpaceState) item[2];
		Long transferCount = (Long) item[3];
		
		WardViewPatientListVo wardViewPatient = new WardViewPatientListVo();
		
		if (doPatient != null && doPatient.getAssociatedPatient() != null)
		{	
			doPatient = doPatient.getAssociatedPatient();
		}	
		PatientLite_IdentifiersVo patient = PatientLite_IdentifiersVoAssembler.create(doPatient);
		wardViewPatient.setPatient(patient);
		
		if (doInpat != null)
		{
			wardViewPatient.setInpatientEpisode(InpatientEpisodeForWardPatientListVoAssembler.create(doInpat));
			wardViewPatient.setCanReopenHomeLeave(canReopenHomeLeave(doInpat));
		}
		
		if (doBedSpace != null)
		{
			wardViewPatient.setBedSpaceState(new BedSpaceStateRefVo(doBedSpace.getId(), doBedSpace.getVersion()));
		}
		
		if (transferCount != null)
		{
			wardViewPatient.setHasPendingTransfer(transferCount.intValue() > 0);
		}
		
		wardViewPatientsCollection.add(wardViewPatient);
	}
	
	return wardViewPatientsCollection;
}
 
Example 51
Project: openMAXIMS   File: WardViewPatientListImpl.java   Source Code and License 4 votes vote down vote up
public WardViewPatientListVoCollection listForPatientsAwaitingBed(LocationRefVo ward, LocationRefVo bay)
{
	if (ward == null || ward.getID_Location() == null)
		return null;
	
	StringBuilder query = new StringBuilder("SELECT inpatEp, patient, bedSpaceState, ");
	query.append(" (select count(pt.id) from PendingTransfers as pt left join pt.inpatientEpisode as inp where inp.id = inpatEp.id and pt.currentStatus.id = :PENDING_TRANSF) ");
	query.append(" FROM BedSpaceState AS bedSpaceState RIGHT JOIN bedSpaceState.inpatientEpisode AS inpatEp ");
	query.append(" LEFT JOIN inpatEp.pasEvent AS pas LEFT JOIN pas.patient AS patient ");
	query.append(" LEFT JOIN inpatEp.bed AS bed ");
	
	query.append(" WHERE pas.location.id = :WARD_ID AND bed is null AND (inpatEp.isOnHomeLeave is null OR inpatEp.isOnHomeLeave = 0) AND (inpatEp.isReadyToLeave is null OR inpatEp.isReadyToLeave = 0)");
	query.append(" ORDER BY patient.name.upperSurname, patient.name.upperForename ");
	
	List<?> results = getDomainFactory().find(query.toString(),  new String[] {"PENDING_TRANSF","WARD_ID"}, new Object[] {TransferStatus.PENDING.getID(), ward.getID_Location()});
	
	if (results == null || results.size() == 0)
		return null;
	
	WardViewPatientListVoCollection wardViewPatientsCollection = new WardViewPatientListVoCollection();
	
	Iterator<?> iterator = results.iterator();
	
	while (iterator.hasNext())
	{
		Object[] item = (Object[]) iterator.next();
		
		InpatientEpisode doInpat = (InpatientEpisode) item[0];
		Patient doPatient = (Patient) item[1];
		BedSpaceState doBedSpace = (BedSpaceState) item[2];
		Long transferCount = (Long) item[3];			
		
		WardViewPatientListVo wardViewPatient = new WardViewPatientListVo();
		
		if (doPatient != null && doPatient.getAssociatedPatient() != null)
		{	
			doPatient = doPatient.getAssociatedPatient();
		}	
		PatientLite_IdentifiersVo patient = PatientLite_IdentifiersVoAssembler.create(doPatient);
		wardViewPatient.setPatient(patient);
		
		if (doInpat != null)
		{
			wardViewPatient.setInpatientEpisode(InpatientEpisodeForWardPatientListVoAssembler.create(doInpat));
			wardViewPatient.setCanReopenHomeLeave(canReopenHomeLeave(doInpat));
		}
		
		if (doBedSpace != null)
		{
			wardViewPatient.setBedSpaceState(new BedSpaceStateRefVo(doBedSpace.getId(), doBedSpace.getVersion()));
		}
		
		if (transferCount != null)
		{
			wardViewPatient.setHasPendingTransfer(transferCount.intValue() > 0);
		}
		wardViewPatientsCollection.add(wardViewPatient);
	}
	
	return wardViewPatientsCollection;
}
 
Example 52
Project: openMAXIMS   File: WardViewPatientListImpl.java   Source Code and License 4 votes vote down vote up
public WardViewPatientListVoCollection listForPatientsOnHomeLeave(LocationRefVo ward, LocationRefVo bay)
{
	if (ward == null || ward.getID_Location() == null)
		return null;
	
	StringBuilder query = new StringBuilder("SELECT inpatEp, patient, bedSpaceState, ");
	query.append(" (select count(pt.id) from PendingTransfers as pt left join pt.inpatientEpisode as inp where inp.id = inpatEp.id and pt.currentStatus.id = :PENDING_TRANSF) ");
	query.append(" FROM BedSpaceState AS bedSpaceState RIGHT JOIN bedSpaceState.inpatientEpisode AS inpatEp ");
	query.append(" LEFT JOIN inpatEp.pasEvent AS pas LEFT JOIN pas.patient AS patient ");
	query.append(" LEFT JOIN inpatEp.homeLeaves AS hl ");
	query.append(" LEFT JOIN inpatEp.bed AS bed ");

	query.append(" WHERE pas.location.id = :WARD_ID AND inpatEp.isOnHomeLeave = 1 AND (hl.isRIE is null OR hl.isRIE = 0) AND (hl.bedRetained is null OR  hl.bedRetained = 0) AND hl.dateReturnedFromHomeLeave is null AND bed is null");
	query.append(" ORDER BY patient.name.upperSurname, patient.name.upperForename ");
	
	List<?> results = getDomainFactory().find(query.toString(),new String[]{"PENDING_TRANSF","WARD_ID"}, new Object[] {TransferStatus.PENDING.getID(),ward.getID_Location()});
	
	if (results == null || results.size() == 0)
		return null;
	
	WardViewPatientListVoCollection wardViewPatientsCollection = new WardViewPatientListVoCollection();
	
	Iterator<?> iterator = results.iterator();
	
	while (iterator.hasNext())
	{
		Object[] item = (Object[]) iterator.next();
		
		InpatientEpisode doInpat = (InpatientEpisode) item[0];
		Patient doPatient = (Patient) item[1];
		BedSpaceState doBedSpace = (BedSpaceState) item[2];
		Long transferCount = (Long) item[3];
		
		WardViewPatientListVo wardViewPatient = new WardViewPatientListVo();
		
		if (doPatient != null && doPatient.getAssociatedPatient() != null)
		{	
			doPatient = doPatient.getAssociatedPatient();
		}	
		PatientLite_IdentifiersVo patient = PatientLite_IdentifiersVoAssembler.create(doPatient);
		wardViewPatient.setPatient(patient);
		
		if (doInpat != null)
		{
			wardViewPatient.setInpatientEpisode(InpatientEpisodeForWardPatientListVoAssembler.create(doInpat));
		}
		
		if (doBedSpace != null)
		{
			wardViewPatient.setBedSpaceState(new BedSpaceStateRefVo(doBedSpace.getId(), doBedSpace.getVersion()));
		}			
		if (transferCount != null)
		{
			wardViewPatient.setHasPendingTransfer(transferCount.intValue() > 0);
		}
		
		wardViewPatientsCollection.add(wardViewPatient);
	}
	
	return wardViewPatientsCollection;
}
 
Example 53
Project: openMAXIMS   File: WardViewPatientListImpl.java   Source Code and License 4 votes vote down vote up
public WardViewPatientListVoCollection listForPatientsOnHomeLeaveWithBedsRetained(LocationRefVo ward, LocationRefVo bay)
{
	if (ward == null || ward.getID_Location() == null)
		return null;
	
	StringBuilder query = new StringBuilder("SELECT inpatEp, patient, bedSpaceState, ");
	query.append(" (select count(pt.id) from PendingTransfers as pt left join pt.inpatientEpisode as inp where inp.id = inpatEp.id and pt.currentStatus.id = :PENDING_TRANSF) ");
	query.append(" FROM BedSpaceState AS bedSpaceState LEFT JOIN bedSpaceState.inpatientEpisode AS inpatEp ");
	query.append(" LEFT JOIN inpatEp.pasEvent AS pas LEFT JOIN pas.patient AS patient ");
	
	query.append(" WHERE pas.location.id = :WARD_ID AND inpatEp.isOnHomeLeave = 1 ");
	query.append(" ORDER BY patient.name.upperSurname, patient.name.upperForename ");
	
	List<?> results = getDomainFactory().find(query.toString(), new String[] {"PENDING_TRANSF","WARD_ID"},new Object[] {TransferStatus.PENDING.getID(), ward.getID_Location()});
			
	if (results == null || results.size() == 0)
		return null;
	
	WardViewPatientListVoCollection wardViewPatientsCollection = new WardViewPatientListVoCollection();
	
	Iterator<?> iterator = results.iterator();
	
	while (iterator.hasNext())
	{
		Object[] item = (Object[]) iterator.next();
		
		InpatientEpisode doInpat = (InpatientEpisode) item[0];
		Patient doPatient = (Patient) item[1];
		BedSpaceState doBedSpace = (BedSpaceState) item[2];
		Long transferCount = (Long) item[3];
		
		WardViewPatientListVo wardViewPatient = new WardViewPatientListVo();
		
		if (doPatient != null && doPatient.getAssociatedPatient() != null)
		{	
			doPatient = doPatient.getAssociatedPatient();
		}
		PatientLite_IdentifiersVo patient = PatientLite_IdentifiersVoAssembler.create(doPatient);
		wardViewPatient.setPatient(patient);
		
		if (doInpat != null)
		{
			wardViewPatient.setInpatientEpisode(InpatientEpisodeForWardPatientListVoAssembler.create(doInpat));
		}
		
		if (doBedSpace != null)
		{
			wardViewPatient.setBedSpaceState(new BedSpaceStateRefVo(doBedSpace.getId(), doBedSpace.getVersion()));
		}
		if (transferCount != null)
		{
			wardViewPatient.setHasPendingTransfer(transferCount.intValue() > 0);
		}
		
		wardViewPatientsCollection.add(wardViewPatient);
	}
	
	return wardViewPatientsCollection;
}
 
Example 54
Project: openMAXIMS   File: WardViewPatientListImpl.java   Source Code and License 4 votes vote down vote up
public WardViewPatientListVoCollection listForPatientsToBeDischargedWithin24Hours(LocationRefVo ward, LocationRefVo bay)
{
	if (ward == null || ward.getID_Location() == null)
		return null;
	
	StringBuilder query = new StringBuilder("SELECT inpatEp, patient, bedSpaceState, ");
	query.append(" (select count(pt.id) from PendingTransfers as pt left join pt.inpatientEpisode as inp where inp.id = inpatEp.id and pt.currentStatus.id = :PENDING_TRANSF) ");
	query.append(" FROM BedSpaceState AS bedSpaceState RIGHT JOIN bedSpaceState.inpatientEpisode AS inpatEp ");
	query.append(" LEFT JOIN inpatEp.pasEvent AS pas LEFT JOIN pas.patient AS patient ");
	query.append(" LEFT JOIN inpatEp.bed AS bed ");
	//			WDEV-21316
	query.append(" WHERE pas.location.id = :WARD_ID AND inpatEp.estDischargeDate <= :DATE_24H AND ((inpatEp.isConfirmedDischarge = 0 OR inpatEp.isConfirmedDischarge is null) and inpatEp.confirmedDischargeDateTime is null) AND ((inpatEp.isReadyToLeave is null OR inpatEp.isReadyToLeave = 0) and inpatEp.readyToLeaveDecisionDateTime is null)");
	query.append(" ORDER BY patient.name.upperSurname, patient.name.upperForename ");
	
	ArrayList<String> paramNames = new ArrayList<String>();
	ArrayList<Object> paramValues = new ArrayList<Object>();
	
	paramNames.add("WARD_ID");			paramValues.add(ward.getID_Location());
	paramNames.add("DATE_24H");			paramValues.add(new ims.framework.utils.DateTime().addHours(24).getJavaDate());
	paramNames.add("PENDING_TRANSF");   paramValues.add(TransferStatus.PENDING.getID());
	
	List<?> results = getDomainFactory().find(query.toString(), paramNames, paramValues);
	
	if (results == null || results.size() == 0)
		return null;
	
	WardViewPatientListVoCollection wardViewPatientsCollection = new WardViewPatientListVoCollection();
	
	Iterator<?> iterator = results.iterator();
	
	while (iterator.hasNext())
	{
		Object[] item = (Object[]) iterator.next();
		
		InpatientEpisode doInpat = (InpatientEpisode) item[0];
		Patient doPatient = (Patient) item[1];
		BedSpaceState doBedSpace = (BedSpaceState) item[2];
		Long transferCount = (Long) item[3];
		
		WardViewPatientListVo wardViewPatient = new WardViewPatientListVo();
		
		if (doPatient != null && doPatient.getAssociatedPatient() != null)
		{	
			doPatient = doPatient.getAssociatedPatient();
		}	
		PatientLite_IdentifiersVo patient = PatientLite_IdentifiersVoAssembler.create(doPatient);
		wardViewPatient.setPatient(patient);
		
		if (doInpat != null)
		{
			wardViewPatient.setInpatientEpisode(InpatientEpisodeForWardPatientListVoAssembler.create(doInpat));
			wardViewPatient.setCanReopenHomeLeave(canReopenHomeLeave(doInpat));
		}
		
		if (doBedSpace != null)
		{
			wardViewPatient.setBedSpaceState(new BedSpaceStateRefVo(doBedSpace.getId(), doBedSpace.getVersion()));
		}
		
		if (transferCount != null)
		{
			wardViewPatient.setHasPendingTransfer(transferCount.intValue() > 0);
		}
		wardViewPatientsCollection.add(wardViewPatient);
	}
	
	return wardViewPatientsCollection;
}
 
Example 55
Project: openMAXIMS   File: WardViewPatientListImpl.java   Source Code and License 4 votes vote down vote up
public WardViewPatientListVoCollection listForPatientsWithDischargedConfirmedWithin24Hours(LocationRefVo ward, LocationRefVo bay)
{
	if (ward == null || ward.getID_Location() == null)
		return null;
	
	StringBuilder query = new StringBuilder("SELECT inpatEp, patient, bedSpaceState, ");
	query.append(" (select count(pt.id) from PendingTransfers as pt left join pt.inpatientEpisode as inp where inp.id = inpatEp.id and pt.currentStatus.id = :PENDING_TRANSF) ");
	query.append(" FROM BedSpaceState AS bedSpaceState RIGHT JOIN bedSpaceState.inpatientEpisode AS inpatEp ");
	query.append(" LEFT JOIN inpatEp.pasEvent AS pas LEFT JOIN pas.patient AS patient ");
	query.append(" LEFT JOIN inpatEp.bed AS bed ");
	
	query.append(" WHERE pas.location.id = :WARD_ID AND inpatEp.confirmedDischargeDateTime <= :DATE_24H AND inpatEp.isConfirmedDischarge = 1 AND ((inpatEp.isReadyToLeave is null OR inpatEp.isReadyToLeave = 0) AND inpatEp.readyToLeaveDecisionDateTime IS NULL)");
	query.append(" ORDER BY patient.name.upperSurname, patient.name.upperForename ");
	
	ArrayList<String> paramNames = new ArrayList<String>();
	ArrayList<Object> paramValues = new ArrayList<Object>();
	
	paramNames.add("WARD_ID");			paramValues.add(ward.getID_Location());
	paramNames.add("DATE_24H");			paramValues.add(new ims.framework.utils.DateTime().addHours(24).getJavaDate());
	paramNames.add("PENDING_TRANSF");   paramValues.add(TransferStatus.PENDING.getID());
	
	List<?> results = getDomainFactory().find(query.toString(), paramNames, paramValues);
	
	if (results == null || results.size() == 0)
		return null;
	
	WardViewPatientListVoCollection wardViewPatientsCollection = new WardViewPatientListVoCollection();
	
	Iterator<?> iterator = results.iterator();
	
	while (iterator.hasNext())
	{
		Object[] item = (Object[]) iterator.next();
		
		InpatientEpisode doInpat = (InpatientEpisode) item[0];
		Patient doPatient = (Patient) item[1];
		BedSpaceState doBedSpace = (BedSpaceState) item[2];			
		Long transferCount = (Long) item[3];
		
		WardViewPatientListVo wardViewPatient = new WardViewPatientListVo();
		
		if (doPatient != null && doPatient.getAssociatedPatient() != null)
		{	
			doPatient = doPatient.getAssociatedPatient();
		}	
		PatientLite_IdentifiersVo patient = PatientLite_IdentifiersVoAssembler.create(doPatient);
		wardViewPatient.setPatient(patient);
		
		if (doInpat != null)
		{
			wardViewPatient.setInpatientEpisode(InpatientEpisodeForWardPatientListVoAssembler.create(doInpat));
			wardViewPatient.setCanReopenHomeLeave(canReopenHomeLeave(doInpat));
		}
		
		if (doBedSpace != null)
		{
			wardViewPatient.setBedSpaceState(new BedSpaceStateRefVo(doBedSpace.getId(), doBedSpace.getVersion()));
		}			
		
		if (transferCount != null)
		{
			wardViewPatient.setHasPendingTransfer(transferCount.intValue() > 0);
		}
		
		wardViewPatientsCollection.add(wardViewPatient);
	}
	
	return wardViewPatientsCollection;
}
 
Example 56
Project: openMAXIMS   File: WardViewPatientListImpl.java   Source Code and License 4 votes vote down vote up
public WardViewPatientListVoCollection listForPatientsReadyToLeave(LocationRefVo ward, LocationRefVo bay)
{
	if (ward == null || ward.getID_Location() == null)
		return null;
	
	StringBuilder query = new StringBuilder("SELECT inpatEp, patient, bedSpaceState,");
	query.append(" (select count(pt.id) from PendingTransfers as pt left join pt.inpatientEpisode as inp where inp.id = inpatEp.id and pt.currentStatus.id = :PENDING_TRANSF) ");
	query.append(" FROM BedSpaceState AS bedSpaceState RIGHT JOIN bedSpaceState.inpatientEpisode AS inpatEp ");
	query.append(" LEFT JOIN inpatEp.pasEvent AS pas LEFT JOIN pas.patient AS patient ");
	query.append(" WHERE pas.location.id = :WARD_ID");
	query.append(" AND inpatEp.readyToLeaveDecisionDateTime <= :TODAY_HIGH AND inpatEp.isReadyToLeave = 1");
	query.append(" ORDER BY patient.name.upperSurname ");
	
	List<?> results = getDomainFactory().find(query.toString(), new String[]{"PENDING_TRANSF","WARD_ID","TODAY_HIGH"}, new Object[] {TransferStatus.PENDING.getID(),ward.getID_Location(), new DateTime().addHours(24).getJavaDate()});
	
	if (results == null || results.size() == 0)
		return null;
	
	WardViewPatientListVoCollection wardViewPatientsCollection = new WardViewPatientListVoCollection();
	
	Iterator<?> iterator = results.iterator();
	
	while (iterator.hasNext())
	{
		Object[] item = (Object[]) iterator.next();
		
		InpatientEpisode doInpat = (InpatientEpisode) item[0];
		Patient doPatient = (Patient) item[1];
		BedSpaceState doBedSpace = (BedSpaceState) item[2];
		Long transferCount = (Long) item[3];
					
		WardViewPatientListVo wardViewPatient = new WardViewPatientListVo();
		
		if (doPatient != null && doPatient.getAssociatedPatient() != null)
		{	
			doPatient = doPatient.getAssociatedPatient();
		}	
		PatientLite_IdentifiersVo patient = PatientLite_IdentifiersVoAssembler.create(doPatient);
		wardViewPatient.setPatient(patient);
		
		if (doInpat != null)
		{
			wardViewPatient.setInpatientEpisode(InpatientEpisodeForWardPatientListVoAssembler.create(doInpat));
			wardViewPatient.setCanReopenHomeLeave(canReopenHomeLeave(doInpat));
		}
		
		if (doBedSpace != null)
		{
			wardViewPatient.setBedSpaceState(new BedSpaceStateRefVo(doBedSpace.getId(), doBedSpace.getVersion()));
		}
		if (transferCount != null)
		{
			wardViewPatient.setHasPendingTransfer(transferCount.intValue() > 0);
		}
		
		wardViewPatientsCollection.add(wardViewPatient);
	}
	
	return wardViewPatientsCollection;
	
}
 
Example 57
Project: openMAXIMS   File: WardViewPatientListImpl.java   Source Code and License 4 votes vote down vote up
public WardViewPatientListVoCollection listForTransferOutPatients(LocationRefVo ward, LocationRefVo bay)
{
	if (ward == null || ward.getID_Location() == null)
		return null;

	StringBuilder query = new StringBuilder("SELECT inpat, patient, bedSpaceState, pendTrans ");
	query.append(" FROM PendingTransfers AS pendTrans ");
	query.append(" LEFT JOIN pendTrans.inpatientEpisode AS inpat LEFT JOIN inpat.pasEvent AS pas ");
	query.append(" LEFT JOIN pas.patient AS patient ");
	query.append(" LEFT JOIN inpat.bed AS bedSpaceState ");
	
	query.append(" WHERE pas.location.id = :WARD_ID AND pendTrans.currentStatus.id = :STATUS ");
	query.append(" ORDER BY patient.name.upperSurname ");
	
	ArrayList<String> paramNames = new ArrayList<String>();
	ArrayList<Object> paramValues = new ArrayList<Object>();
	
	paramNames.add("WARD_ID");		paramValues.add(ward.getID_Location());
	paramNames.add("STATUS");		paramValues.add(TransferStatus.PENDING.getID());
	
	List<?> results = getDomainFactory().find(query.toString(), paramNames, paramValues);
	
	if (results == null || results.size() == 0)
		return null;
	
	WardViewPatientListVoCollection wardViewPatientsCollection = new WardViewPatientListVoCollection();
	
	Iterator<?> iterator = results.iterator();
	
	while (iterator.hasNext())
	{
		Object[] item = (Object[]) iterator.next();
		
		InpatientEpisode doInpat = (InpatientEpisode) item[0];
		Patient doPatient = (Patient) item[1];
		BedSpaceState doBedSpace = (BedSpaceState) item[2];
		PendingTransfers doTransfer = (PendingTransfers) item[3];
					
		WardViewPatientListVo wardViewPatient = new WardViewPatientListVo();
		
		if (doPatient != null && doPatient.getAssociatedPatient() != null)
		{	
			doPatient = doPatient.getAssociatedPatient();
		}	
		PatientLite_IdentifiersVo patient = PatientLite_IdentifiersVoAssembler.create(doPatient);
		wardViewPatient.setPatient(patient);
		
		if (doInpat != null)
		{
			wardViewPatient.setInpatientEpisode(InpatientEpisodeForWardPatientListVoAssembler.create(doInpat));
		}
		
		if (doBedSpace != null)
		{
			wardViewPatient.setBedSpaceState(new BedSpaceStateRefVo(doBedSpace.getId(), doBedSpace.getVersion()));
		}
		
		if (doTransfer != null) //WDEV-21083
		{
			wardViewPatient.setPendingTransfer(PendingTransferForBedReadyDetailsVoAssembler.create(doTransfer));
		}			
		
		wardViewPatientsCollection.add(wardViewPatient);
	}
	
	return wardViewPatientsCollection;
}
 
Example 58
Project: openMAXIMS   File: WardViewPatientListImpl.java   Source Code and License 4 votes vote down vote up
public WardViewPatientListVoCollection listForTransferInPatients(LocationRefVo ward, LocationRefVo bay)
{
	if (ward == null || ward.getID_Location() == null)
		return null;
	
	StringBuilder query = new StringBuilder("SELECT inpat, patient, bedSpaceState, pendTrans ");
	
	query.append(" FROM PendingTransfers AS pendTrans ");
	query.append(" LEFT JOIN pendTrans.inpatientEpisode AS inpat LEFT JOIN inpat.pasEvent AS pas ");
	query.append(" LEFT JOIN pas.patient AS patient ");
	query.append(" LEFT JOIN inpat.bed AS bedSpaceState ");
	query.append(" WHERE pendTrans.destinationWard.id = :WARD_ID AND pendTrans.currentStatus.id = :STATUS ");
	query.append(" ORDER BY patient.name.upperSurname ");
	
	ArrayList<String> paramNames = new ArrayList<String>();
	ArrayList<Object> paramValues = new ArrayList<Object>();
	
	paramNames.add("WARD_ID");		paramValues.add(ward.getID_Location());
	paramNames.add("STATUS");		paramValues.add(TransferStatus.PENDING.getID());
	

	List<?> results = getDomainFactory().find(query.toString(), paramNames, paramValues);
	
	if (results == null || results.size() == 0)
		return null;
	
	WardViewPatientListVoCollection wardViewPatientsCollection = new WardViewPatientListVoCollection();
	
	Iterator<?> iterator = results.iterator();
	
	while (iterator.hasNext())
	{
		Object[] item = (Object[]) iterator.next();
		
		InpatientEpisode doInpat = (InpatientEpisode) item[0];
		Patient doPatient = (Patient) item[1];
		BedSpaceState doBedSpace = (BedSpaceState) item[2];
		PendingTransfers doTransfer = (PendingTransfers) item[3];			
		
		WardViewPatientListVo wardViewPatient = new WardViewPatientListVo();
		
		if (doPatient != null && doPatient.getAssociatedPatient() != null)
		{	
			doPatient = doPatient.getAssociatedPatient();
		}	
		PatientLite_IdentifiersVo patient = PatientLite_IdentifiersVoAssembler.create(doPatient);
		wardViewPatient.setPatient(patient);
		
		if (doInpat != null)
		{
			wardViewPatient.setInpatientEpisode(InpatientEpisodeForWardPatientListVoAssembler.create(doInpat));
		}
		
		if (doBedSpace != null)
		{
			wardViewPatient.setBedSpaceState(new BedSpaceStateRefVo(doBedSpace.getId(), doBedSpace.getVersion()));
		}
		
		if (doTransfer != null) //WDEV-21083 
		{
			wardViewPatient.setPendingTransfer(PendingTransferForBedReadyDetailsVoAssembler.create(doTransfer));
		}
		
		wardViewPatientsCollection.add(wardViewPatient);
	}
	
	return wardViewPatientsCollection;
}
 
Example 59
Project: openMAXIMS   File: BedInfoDialogImpl.java   Source Code and License 4 votes vote down vote up
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 60
Project: openMAXIMS   File: BedInfoDialogImpl.java   Source Code and License 4 votes vote down vote up
public void saveInternalTransfer(InpatientEpisodeLiteVo inpatEpis, BedSpaceStateLiteVo bedSpaceState, AdmissionReasonVo admissionReasonVo) 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);
	
	BedSpaceState domBed = BedSpaceStateBayOnlyVoAssembler.extractBedSpaceState(getDomainFactory(), inpatEpis.getBed());
	
	domBed.getCurrentBedStatus().setBedStatus(getDomLookup(BedStatus.AVAILABLE));
	domBed.setInpatientEpisode(null);
	getDomainFactory().save(domBed);
	
	InpatientEpisode doInpatEpis = InpatientEpisodeLiteVoAssembler.extractInpatientEpisode(getDomainFactory(), inpatEpis);
	
	doBedSpaceState.setInpatientEpisode(doInpatEpis);
	doBedSpaceState.getCurrentBedStatus().setBedStatus(getDomLookup(BedStatus.OCCUPIED));
	doInpatEpis.setBed(doBedSpaceState);
	
	// WDEV-19481 - Trigger creation of A08 Bed Move HL7 message
	if(inpatEpis.getPasEvent() !=null
			&& doBedSpaceState != null
			&& doBedSpaceState.getBedSpace() != null
			&& doBedSpaceState.getBedSpace().getBedNumber() != null)
	{
    	ADT adtimpl = (ADT) getDomainImpl(ADTImpl.class);
		adtimpl.triggerUpdateAdmissionEvent(inpatEpis.getPasEvent(),MsgUpdateType.ADMISSION);//http://jira/browse/WDEV-22831
	} //WDEV-19481
	
	//WDEV-20224
	if (admissionReasonVo != null && Boolean.TRUE.equals(admissionReasonVo.getIsPrivateBedAllocationValidated()) && Boolean.TRUE.equals(doBedSpaceState.getBedSpace().isPrivateBed()))
	{
		WardStay cws = getCurrentWardStay(doInpatEpis.getWardStays());
		
		if (cws != null)
		{
			cws.setReasonPrivateBedAllocated(admissionReasonVo.getReasonForPrivateBedAllocation() != null ? getDomLookup(admissionReasonVo.getReasonForPrivateBedAllocation()) : null);
			cws.setReasonPrivateBedAllocatedComment(admissionReasonVo.getReasonForPrivateBedAllocationComment());
		}
	}
	getDomainFactory().save(doInpatEpis);
	
	//WDEV-20217
	updateOccupiedBedsForWardAndBay(bedSpaceState.getWard(), bedSpaceState.getBay(), inpatEpis.getBed() != null ? inpatEpis.getBed().getBay() : null);
}