Java Code Examples for ims.core.vo.domain.BedSpaceStateLiteVoAssembler

The following are top voted examples for showing how to use ims.core.vo.domain.BedSpaceStateLiteVoAssembler. 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: WardBayConfigDialogImpl.java   Source Code and License 6 votes vote down vote up
private BedSpaceStateLiteVo getBedSpaceState(BedSpace bed) 
{
	if (bed == null || bed.getId() == null)
		return null;
	
	String hql = "select bs from BedSpaceState as bs left join bs.bedSpace as bed where bed.id = " + bed.getId();
	List bedState = getDomainFactory().find(hql);
	
	BedSpaceStateLiteVoCollection voColl = BedSpaceStateLiteVoAssembler.createBedSpaceStateLiteVoCollectionFromBedSpaceState(bedState);
	
	if (voColl != null &&
			voColl.size() > 0)
		return voColl.get(0);		
	
	return null;
}
 
Example 3
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 4
Project: openMAXIMS   File: WardBayConfigDialogImpl.java   Source Code and License 6 votes vote down vote up
private BedSpaceStateLiteVo getBedSpaceState(BedSpace bed) 
{
	if (bed == null || bed.getId() == null)
		return null;
	
	String hql = "select bs from BedSpaceState as bs left join bs.bedSpace as bed where bed.id = " + bed.getId();
	List<?> bedState = getDomainFactory().find(hql);
	
	BedSpaceStateLiteVoCollection voColl = BedSpaceStateLiteVoAssembler.createBedSpaceStateLiteVoCollectionFromBedSpaceState(bedState);
	
	if (voColl != null &&
			voColl.size() > 0)
		return voColl.get(0);		
	
	return null;
}
 
Example 5
Project: openMAXIMS   File: AssignBedToHomeLeaveInpatientImpl.java   Source Code and License 6 votes vote down vote up
public ims.core.vo.BedSpaceStateLiteVoCollection listAvailableBedSpaces(ims.core.resource.place.vo.LocationRefVo wardRef)
{
	if (wardRef == null)
		return null;
	
	StringBuilder hql = new StringBuilder();
	DomainFactory factory = getDomainFactory();
	hql.append("select bedspacest from BedSpaceState as bedspacest left join bedspacest.ward as ward left join bedspacest.bay as bay left join bedspacest.currentBedStatus as currentStatus left join currentStatus.bedStatus as status where ward.id = :WARD_ID and status.id = :AVAILABLE_BED_STATUS and bay.isActive = :IS_ACTIVE AND bay.id in (select bayloc.id from BayConfig bconfig left join bconfig.bay as bayloc left join bconfig.floorBedSpaceLayout as flayout left join flayout.status as stat where stat.id = :STATUS_ID) ");
	
	List<?> recordList = factory.find(hql.toString(), new String[]{"WARD_ID", "AVAILABLE_BED_STATUS", "IS_ACTIVE", "STATUS_ID"}, new Object[]{wardRef.getID_Location(),BedStatus.AVAILABLE.getID(), Boolean.TRUE,PreActiveActiveInactiveStatus.ACTIVE.getID()});
	
	if (recordList == null || recordList.isEmpty())
		return null;
	
	return BedSpaceStateLiteVoAssembler.createBedSpaceStateLiteVoCollectionFromBedSpaceState(recordList);
}
 
Example 6
Project: openMAXIMS   File: WardBayConfigDialogImpl.java   Source Code and License 6 votes vote down vote up
private BedSpaceStateLiteVo getBedSpaceState(BedSpace bed) 
{
	if (bed == null || bed.getId() == null)
		return null;
	
	String hql = "select bs from BedSpaceState as bs left join bs.bedSpace as bed where bed.id = " + bed.getId();
	List bedState = getDomainFactory().find(hql);
	
	BedSpaceStateLiteVoCollection voColl = BedSpaceStateLiteVoAssembler.createBedSpaceStateLiteVoCollectionFromBedSpaceState(bedState);
	
	if (voColl != null &&
			voColl.size() > 0)
		return voColl.get(0);		
	
	return null;
}
 
Example 7
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 8
Project: openmaxims-linux   File: WardBayConfigDialogImpl.java   Source Code and License 6 votes vote down vote up
private BedSpaceStateLiteVo getBedSpaceState(BedSpace bed) 
{
	if (bed == null || bed.getId() == null)
		return null;
	
	String hql = "select bs from BedSpaceState as bs left join bs.bedSpace as bed where bed.id = " + bed.getId();
	List bedState = getDomainFactory().find(hql);
	
	BedSpaceStateLiteVoCollection voColl = BedSpaceStateLiteVoAssembler.createBedSpaceStateLiteVoCollectionFromBedSpaceState(bedState);
	
	if (voColl != null &&
			voColl.size() > 0)
		return voColl.get(0);		
	
	return null;
}
 
Example 9
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 10
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 11
Project: AvoinApotti   File: BedInfoDialogImpl.java   Source Code and License 5 votes vote down vote up
public void saveReOpenOrAssignBed(BedSpaceStateLiteVo bedSpaceState) throws StaleObjectException
{
	if(bedSpaceState == null)
		throw new CodingRuntimeException("bedSpaceState is null in method saveReOpenOrAssignBed");
	
	//WDEV-8507
	bedSpaceState.setInpatientEpisode(null);
	
	getDomainFactory().save(BedSpaceStateLiteVoAssembler.extractBedSpaceState(getDomainFactory(), bedSpaceState));	
}
 
Example 12
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 13
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 14
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 15
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 16
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 17
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 18
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 19
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 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 void saveReOpenOrAssignBed(BedSpaceStateLiteVo bedSpaceState) throws StaleObjectException
{
	if(bedSpaceState == null)
		throw new CodingRuntimeException("bedSpaceState is null in method saveReOpenOrAssignBed");
	
	//WDEV-8507
	bedSpaceState.setInpatientEpisode(null);
	
	getDomainFactory().save(BedSpaceStateLiteVoAssembler.extractBedSpaceState(getDomainFactory(), bedSpaceState));	
}
 
Example 22
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 23
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 24
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 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 void saveReOpenOrAssignBed(BedSpaceStateLiteVo bedSpaceState) throws StaleObjectException
{
	if(bedSpaceState == null)
		throw new CodingRuntimeException("bedSpaceState is null in method saveReOpenOrAssignBed");
	
	//WDEV-8507
	bedSpaceState.setInpatientEpisode(null);
	
	getDomainFactory().save(BedSpaceStateLiteVoAssembler.extractBedSpaceState(getDomainFactory(), bedSpaceState));	
}
 
Example 32
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 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 void saveReOpenOrAssignBed(BedSpaceStateLiteVo bedSpaceState) throws StaleObjectException
{
	if(bedSpaceState == null)
		throw new CodingRuntimeException("bedSpaceState is null in method saveReOpenOrAssignBed");
	
	//WDEV-8507
	bedSpaceState.setInpatientEpisode(null);
	
	getDomainFactory().save(BedSpaceStateLiteVoAssembler.extractBedSpaceState(getDomainFactory(), bedSpaceState));	
}
 
Example 40
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 41
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 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: 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 51
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);
}
 
Example 52
Project: openMAXIMS   File: BedInfoDialogImpl.java   Source Code and License 4 votes vote down vote up
public void cancelHomeLeaveReturn(InpatientEpisodeLiteVo voInpat,BedSpaceStateLiteVo voBedSpaceState, HomeLeaveVo voHlToReOpen) throws DomainInterfaceException,StaleObjectException
{
	if (voInpat == null)
		throw new CodingRuntimeException("The InpatientEpisodeLiteVo argument cannot be null in method cancelHomeLeaveReturn()");
	if (voHlToReOpen == null)
		throw new CodingRuntimeException("The HomeLeaveVo argument cannot be null in method cancelHomeLeaveReturn()");
	if (!voHlToReOpen.isValidated())
		throw new CodingRuntimeException("The HomeLeaveVo is not validated in method cancelHomeLeaveReturn()");
	DomainFactory factory = getDomainFactory();

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

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

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

		if (voBedSpaceState != null && !Boolean.TRUE.equals(voHlToReOpen.getBedRetained()))
			updateOccupiedBedsForWardAndBay(voBedSpaceState.getWard(), voBedSpaceState.getBay(), null);
		
		if (ConfigFlag.UI.BED_INFO_UI_TYPE.getValue().equals("MAXIMS") && voBedSpaceState != null && !Boolean.TRUE.equals(voHlToReOpen.getBedRetained()))
		{
			Sex tempGender = voInpat.getPasEvent() != null && voInpat.getPasEvent().getPatientIsNotNull() && voInpat.getPasEvent().getPatient().getSexIsNotNull() && !Sex.UNKNOWN.equals(voInpat.getPasEvent().getPatient().getSex())? voInpat.getPasEvent().getPatient().getSex() : null;
			checkAndUpdateBayConfig(factory, voBedSpaceState,tempGender);
		}
	}		
}
 
Example 53
Project: openMAXIMS   File: BedInfoDialogImpl.java   Source Code and License 4 votes vote down vote up
public void vacateBedSpace(InPatientEpisodeADTVo voInpat, BedSpaceStateLiteVo voBedSpaceStateLite, HomeLeaveVo voCurrentHomeLeave) throws DomainInterfaceException, StaleObjectException
{
	if (voInpat == null)
		throw new CodingRuntimeException("InPatientEpisodeADTVo argument cannot be null in method vacateBedSpace()");

	if (voCurrentHomeLeave == null)
		throw new CodingRuntimeException("HomeLeaveVo argument cannot be null in method vacateBedSpace()");

	DomainFactory domainFactory = getDomainFactory();

	InpatientEpisode inpatientEpisodeDO = (InpatientEpisode) domainFactory.getDomainObject(InpatientEpisode.class, voInpat.getID_InpatientEpisode());

	if (inpatientEpisodeDO == null || inpatientEpisodeDO.getVersion() > voInpat.getVersion_InpatientEpisode())
		throw new DomainInterfaceException("The patient record was updated by another user. The screen will refresh.");
	if (inpatientEpisodeDO.getBed() == null)
		throw new DomainInterfaceException("The bed was vacated by another user. The screen will refresh.");

	InpatientEpisode doInpat = InPatientEpisodeADTVoAssembler.extractInpatientEpisode(domainFactory, voInpat);
	HomeLeave doHomeLeave = HomeLeaveVoAssembler.extractHomeLeave(domainFactory, voCurrentHomeLeave);
	
	int currentHomeLeaveIndex = -1;
	if (doHomeLeave != null)
	{	
		currentHomeLeaveIndex = doInpat.getHomeLeaves().indexOf(doHomeLeave);
		if (currentHomeLeaveIndex != -1)
		{
			HomeLeave doHLForUpdate = (HomeLeave) doInpat.getHomeLeaves().get(currentHomeLeaveIndex);
			if (doHLForUpdate != null)
			{	
				doHLForUpdate.setBedRetained(doHomeLeave.isBedRetained());
			}	
		}
	}
	else
	{
		throw new DomainInterfaceException("The home leave was cancelled by another user. The screen will refresh.");
	}
	
	domainFactory.save(doInpat);

	if (voBedSpaceStateLite != null)
	{	
		BedSpaceState doBedSpaceState = BedSpaceStateLiteVoAssembler.extractBedSpaceState(domainFactory,voBedSpaceStateLite);
		domainFactory.save(doBedSpaceState);
	}
	updateOccupiedBedsForWardAndBay(voBedSpaceStateLite.getWard(), voBedSpaceStateLite.getBay(), null);			

	if (ConfigFlag.UI.BED_INFO_UI_TYPE.getValue().equals("MAXIMS") && voBedSpaceStateLite != null )
	{
		Sex tempGender = voInpat.getPasEvent() != null && voInpat.getPasEvent().getPatientIsNotNull() && voInpat.getPasEvent().getPatient().getSexIsNotNull() && !Sex.UNKNOWN.equals(voInpat.getPasEvent().getPatient().getSex())  ? voInpat.getPasEvent().getPatient().getSex() : null;
		checkAndUpdateBayConfig(domainFactory, voBedSpaceStateLite,tempGender);
	}
}
 
Example 54
Project: openMAXIMS   File: WardViewImpl.java   Source Code and License 4 votes vote down vote up
public BedSpaceStateLiteVo getBedSpaceState(BedSpaceRefVo bed) 
{
	if(bed == null )
		throw new DomainRuntimeException("Invalid BedRefVo");
	
	String hql = "select bs,(select adm.healthyLodger from AdmissionDetail as adm where adm.pasEvent.id = bs.inpatientEpisode.pasEvent.id) from BedSpaceState as bs left join bs.bedSpace as bed where bed.id = " + bed.getID_BedSpace();
	
	List<?> bedState = null;
	
	//WDEV-23014 - Catch the Lock error and retry the entire transaction. After two retries, throw a SOE message. 

	try
	{
		bedState = getDomainFactory().find(hql);
	}
	catch (RuntimeException e) {
		if (e instanceof LockAcquisitionException) 
		{
			try
			{
				bedState = getDomainFactory().find(hql);
			}
			catch (RuntimeException e1) 
			{
				if (e1 instanceof LockAcquisitionException) 
				{
					throw new StaleStateException(ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue());
				}
			}
		}
	}
	//WDEV-23014 ends here
	
	//WDEV-11039
	boolean hasAlerts = false;
	BedSpaceStateLiteVoCollection voColl  = new BedSpaceStateLiteVoCollection();
	if (bedState != null && bedState.size() > 0 && bedState.get(0) instanceof Object[])
	{
		Object[] recordDO = (Object[]) bedState.get(0);
		BedSpaceStateLiteVo bs = null;
		for (int i =0;i<recordDO.length;i++)
		{				
			if (recordDO[0] instanceof BedSpaceState)
			{	
				BedSpaceState doBed = (BedSpaceState)recordDO[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;

				bs  = BedSpaceStateLiteVoAssembler.create((BedSpaceState)recordDO[0]);
			}	
			if (bs.getInpatientEpisodeIsNotNull() && recordDO[1] != null && recordDO[1] instanceof HealthyLodger)
				bs.getInpatientEpisode().setHealthyLodgerDetails(HealthyLodgerVoAssembler.create((HealthyLodger)recordDO[1]));
		}
		if (bs != null)
			voColl.add(bs);

	}
	//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 55
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 56
Project: openMAXIMS   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 57
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 58
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 59
Project: openmaxims-linux   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 60
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);
}