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

The following are top voted examples for showing how to use ims.core.admin.pas.domain.objects.InpatientEpisode. 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: ADTAdmissionDetailsComponentImpl.java   Source Code and License 7 votes vote down vote up
public AdmissionType getAdmissionTypeFromInpatientEpisode(PASEventRefVo pasEventRef)
{
	if(pasEventRef == null || pasEventRef.getID_PASEvent()==null)
		throw new CodingRuntimeException("Cannot get PasEvent value on null pasEventRef.");
	
	StringBuffer hql = new StringBuffer("select inpEpisode from InpatientEpisode as inpEpisode left join inpEpisode.pasEvent as pasEvent where pasEvent.id= :pasEventID ");
	
	DomainFactory factory = getDomainFactory();
	List<?> list = factory.find(hql.toString(), new String[] {"pasEventID"}, new Object[] {pasEventRef.getID_PASEvent()});
	
	if (list!=null && list.size()>0)
	{	
		return (InpatientEpisodeVoAssembler.create((InpatientEpisode) list.get(0))).getAdmissionType();
	}
	
	return null;
}
 
Example 2
Project: AvoinApotti   File: STHKCurrentInpatientListComponentImpl.java   Source Code and License 6 votes vote down vote up
public STHKCurrentInpatientListVo saveIP(STHKCurrentInpatientListVo voIP) throws DomainInterfaceException, StaleObjectException 
{
	if(voIP == null)
		throw new CodingRuntimeException("Cannot save null STHKCurrentInpatientListVo");
	
	if (!voIP.isValidated())
		throw new CodingRuntimeException("Inpatient Record has not been validated");
	
	DomainFactory factory = getDomainFactory();
	
	InpatientEpisode doIP = STHKCurrentInpatientListVoAssembler.extractInpatientEpisode(factory, voIP);
	
	//WDEV-18059 patient was discharged form another session.
	if (doIP == null)
		throw new StaleObjectException(doIP);
		
	factory.save(doIP);
	return (STHKCurrentInpatientListVoAssembler.create(doIP));		
}
 
Example 3
Project: AvoinApotti   File: ADTAdmissionDetailsComponentImpl.java   Source Code and License 6 votes vote down vote up
public InpatientEpisodeVo getInpatientEpisode(PASEventRefVo pasEventRef)
{
	if(pasEventRef == null || pasEventRef.getID_PASEvent()==null)
		throw new CodingRuntimeException("Cannot get PasEvent value on null pasEventRef.");
	
	StringBuffer hql = new StringBuffer("select inpEpisode from InpatientEpisode as inpEpisode left join inpEpisode.pasEvent as pasEvent where pasEvent.id= :pasEventID ");
	
	DomainFactory factory = getDomainFactory();
	List<?> list = factory.find(hql.toString(), new String[] {"pasEventID"}, new Object[] {pasEventRef.getID_PASEvent()});
	
	if (list!=null && list.size()>0)
	{	
		return InpatientEpisodeVoAssembler.create((InpatientEpisode) list.get(0));
	}
	
	return null;
}
 
Example 4
Project: AvoinApotti   File: ADTAdmissionDetailsComponentImpl.java   Source Code and License 6 votes vote down vote up
public AdmissionType getAdmissionTypeFromInpatientEpisode(PASEventRefVo pasEventRef)
{
	if(pasEventRef == null || pasEventRef.getID_PASEvent()==null)
		throw new CodingRuntimeException("Cannot get PasEvent value on null pasEventRef.");
	
	StringBuffer hql = new StringBuffer("select inpEpisode from InpatientEpisode as inpEpisode left join inpEpisode.pasEvent as pasEvent where pasEvent.id= :pasEventID ");
	
	DomainFactory factory = getDomainFactory();
	List<?> list = factory.find(hql.toString(), new String[] {"pasEventID"}, new Object[] {pasEventRef.getID_PASEvent()});
	
	if (list!=null && list.size()>0)
	{	
		return (InpatientEpisodeVoAssembler.create((InpatientEpisode) list.get(0))).getAdmissionType();
	}
	
	return null;
}
 
Example 5
Project: AvoinApotti   File: BedInfoDialogImpl.java   Source Code and License 6 votes vote down vote up
private Date getMostRecentConsultantStayTransferDate(InpatientEpisode inpatientEpisode)
{
	if(inpatientEpisode == null)
		throw new CodingRuntimeException("inpatientEpisode is null in method getMostRecentConsultantStayTransferDate");
	
	Date transferDate = null;
	if(inpatientEpisode.getConsultantStays() != null && inpatientEpisode.getConsultantStays().size() > 0)
	{
		Iterator it = inpatientEpisode.getConsultantStays().iterator();
		while(it.hasNext())
		{	
			ConsultantStay consStay = (ConsultantStay)it.next();
			if(consStay.getTransferDateTime() != null)
			{
				if(transferDate == null || transferDate.before(consStay.getTransferDateTime()))
					transferDate = consStay.getTransferDateTime();
			}
		}
	}			
		
	return transferDate;
}
 
Example 6
Project: AvoinApotti   File: BedInfoDialogImpl.java   Source Code and License 6 votes vote down vote up
private Date getMostRecentWardStayTransferDate(InpatientEpisode inpatientEpisode)
{
	if(inpatientEpisode == null)
		throw new CodingRuntimeException("inpatientEpisode is null in method getMostRecentWardStayTransferDate");

	Date transferDate = null;
	if(inpatientEpisode.getWardStays() != null && inpatientEpisode.getWardStays().size() > 0)
	{
		Iterator it = inpatientEpisode.getWardStays().iterator();
		while(it.hasNext())
		{	
			WardStay wardStay = (WardStay)it.next();
			//**********************************************
			if(wardStay == null || wardStay.getTransferDateTime()== null)
			   continue;
			//**********************************************
			if(transferDate == null || transferDate.before(wardStay.getTransferDateTime()))
				transferDate = wardStay.getTransferDateTime();
		}
	}			
		
	return transferDate;
}
 
Example 7
Project: AvoinApotti   File: BedInfoDialogImpl.java   Source Code and License 6 votes vote down vote up
private String getPatientIdValue(InpatientEpisode doInpatientEpisode, PatIdType type) 
{
	if(doInpatientEpisode == null)
		return null;
	
	if(doInpatientEpisode.getPasEvent() != null && doInpatientEpisode.getPasEvent().getPatient() != null && doInpatientEpisode.getPasEvent().getPatient().getIdentifiers() != null)
	{
		Iterator it = doInpatientEpisode.getPasEvent().getPatient().getIdentifiers().iterator();
		while(it.hasNext())
		{
			PatientId patId = (PatientId) it.next();
			if(patId.getType().equals( getDomLookup(type)))
				return patId.getValue();
		}
	}
	
	return null;
}
 
Example 8
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 9
Project: AvoinApotti   File: ADTImpl.java   Source Code and License 6 votes vote down vote up
public ims.core.vo.InpatientEpisodeVo transferPatient(PatientRefVo patVo, HcpRefVo hcp, LocationRefVo ward,Integer stay,LocationRefVo fromWard, DateTime transferDateTime, DateTime transactionDT, LookupInstVo specialty) throws ims.domain.exceptions.DomainInterfaceException, ims.domain.exceptions.StaleObjectException
{
	if (patVo == null)
	{
		throw new DomainRuntimeException("Patient cannot be null!");
	}
	InpatientEpisode ipDo = getCurrentAdmission(patVo);
	if (ipDo == null)
	{
		//Patient is not currently an inpatient, so ignore transfer event.
		return null;	
	}	
	performTransfer(ipDo, patVo, hcp, ward,stay,fromWard,transferDateTime,transactionDT,specialty);
	
	return InpatientEpisodeVoAssembler.create(ipDo);
}
 
Example 10
Project: AvoinApotti   File: ADTImpl.java   Source Code and License 6 votes vote down vote up
public void cancelInpatientLeave(PatientShort patient) throws StaleObjectException
{
	DomainFactory factory = getDomainFactory();

	Patient domPatient = PatientShortAssembler.extractPatient(factory, patient);
	InpatientEpisode epis = getCurrentAdmission(factory, patient);
	if (epis != null)
	{
	PASEvent pasevent=epis.getPasEvent();
	Location loc=(Location)factory.getDomainObject(Location.class, domPatient.getWard().getId());
	pasevent.setLocation(loc);
	epis.setPasEvent(pasevent);

	epis.setIsOnLeave(Boolean.FALSE);
	factory.save(epis);
	}
}
 
Example 11
Project: AvoinApotti   File: DischargeSummaryWardPacuImpl.java   Source Code and License 6 votes vote down vote up
public InpatientEpisodeVo getInpatientEpisode(CatsReferralRefVo referral)
{
	if (referral == null || referral.getID_CatsReferral() == null)
		throw new CodingRuntimeException("Logical error - provided referral is null or has no id");
	
	DomainFactory factory = getDomainFactory();
	
	String hql = "from InpatientEpisode as ip where (ip.isRIE is null and ip.pasEvent.id in (select cr.careContext.pasEvent.id from CatsReferral as cr where cr.id = :refID))";
	
	ArrayList<String> paramNames = new ArrayList<String>();
	paramNames.add("refID");
	
	ArrayList<Object> paramValues = new ArrayList<Object>();
	paramValues.add(referral.getID_CatsReferral());
	
	return InpatientEpisodeVoAssembler.create((InpatientEpisode) factory.findFirst(hql, paramNames, paramValues));
}
 
Example 12
Project: AvoinApotti   File: EDischargeSummarySthkComponentImpl.java   Source Code and License 6 votes vote down vote up
public InpatientEpisodeEDischargeVo getInpatientEpisodeByCareContext(CareContextRefVo careContext)
{
	if (careContext == null || careContext.getID_CareContext() == null)
		throw new CodingRuntimeException("careContext is null or id not provided in method getInpatientEpisodeByCareContext");
	
	List items = getDomainFactory().find(" select cc.pasEvent.id from CareContext as cc where cc.id = " +  careContext.getID_CareContext());
	if(items != null && items.size() > 0)
	{
		Integer eventId = (Integer) items.get(0);
	
		if(eventId!= null && eventId  > 0)
		{
			List ieItems = getDomainFactory().find(" from InpatientEpisode ie where ie.pasEvent.id = " +  eventId);
			if(ieItems != null && ieItems.size() > 0)
				return InpatientEpisodeEDischargeVoAssembler.create((InpatientEpisode) ieItems.get(0));
		}	
	}
	
	return null;
}
 
Example 13
Project: AvoinApotti   File: ClinicListwithICPActionsImpl.java   Source Code and License 6 votes vote down vote up
public Boolean isInpatientCareContext(PatientRefVo patientRef, CareContextRefVo careContextRef)
{
	if (patientRef == null || !patientRef.getID_PatientIsNotNull())
		throw new CodingRuntimeException("Logical Error - Patient expected");
	
	if (careContextRef == null || !careContextRef.getID_CareContextIsNotNull())
		throw new CodingRuntimeException("Logical Error - Care Context expected");
	
	String hql = "from InpatientEpisode as ip where (ip.pasEvent.id in (select cc.pasEvent.id from CareContext as cc where cc.id = :refID))";
	ArrayList<String> paramNames = new ArrayList<String>();
	paramNames.add("refID");
	
	ArrayList<Object> paramValues = new ArrayList<Object>();
	paramValues.add(careContextRef.getID_CareContext());
	
	InpatientEpisodeLiteVo inpatientEpisode = InpatientEpisodeLiteVoAssembler.create((InpatientEpisode) getDomainFactory().findFirst(hql, paramNames, paramValues));
	
	if (inpatientEpisode == null)
		return Boolean.FALSE;
	
	return Boolean.TRUE;
}
 
Example 14
Project: AvoinApotti   File: AdmissionDetailsImpl.java   Source Code and License 6 votes vote down vote up
/**
* Method used to retrieve Admission Details.
*/
public AdmissionDetailLiteWithInpatientEpisodeVo getAdmission(AdmissionDetailRefVo admission)
{
	// Check admission record parameter
	if (admission == null || !admission.getID_AdmissionDetailIsNotNull())
		return null;
	
	AdmissionDetailLiteWithInpatientEpisodeVo admissionDetails = AdmissionDetailLiteWithInpatientEpisodeVoAssembler.create((AdmissionDetail) getDomainFactory().getDomainObject(AdmissionDetail.class, admission.getID_AdmissionDetail()));

	// Get Inpatient episode if exists
	String query = "SELECT inpEp FROM InpatientEpisode AS inpEp LEFT JOIN inpEp.pasEvent AS pas1, AdmissionDetail AS admtDetail LEFT JOIN admtDetail.pasEvent AS pas2 WHERE pas1.id = pas2.id AND admtDetail.id = :ADM_ID AND inpEp.isRIE is null";
	
	ArrayList<String> paramNames = new ArrayList<String>();
	ArrayList<Object> paramValues = new ArrayList<Object>();
	
	paramNames.add("ADM_ID");
	paramValues.add(admissionDetails.getID_AdmissionDetail());
	
	InpatientEpisodeBedNumberUpdateVo inpatientEpisode = InpatientEpisodeBedNumberUpdateVoAssembler.create((InpatientEpisode) getDomainFactory().findFirst(query, paramNames, paramValues));
	
	admissionDetails.setInpatientEpisode(inpatientEpisode);
	
	return admissionDetails;
}
 
Example 15
Project: openMAXIMS   File: ADTImpl.java   Source Code and License 6 votes vote down vote up
public ims.core.vo.InpatientEpisodeVo transferPatient(PatientRefVo patVo, HcpRefVo hcp, LocationRefVo ward,Integer stay,LocationRefVo fromWard, DateTime transferDateTime, DateTime transactionDT, LookupInstVo specialty) throws ims.domain.exceptions.DomainInterfaceException, ims.domain.exceptions.StaleObjectException
{
	if (patVo == null)
	{
		throw new DomainRuntimeException("Patient cannot be null!");
	}
	InpatientEpisode ipDo = getCurrentAdmission(patVo);
	if (ipDo == null)
	{
		//Patient is not currently an inpatient, so ignore transfer event.
		return null;	
	}	
	performTransfer(ipDo, patVo, hcp, ward,stay,fromWard,transferDateTime,transactionDT,specialty);
	
	return InpatientEpisodeVoAssembler.create(ipDo);
}
 
Example 16
Project: openMAXIMS   File: STHKCurrentInpatientListComponentImpl.java   Source Code and License 6 votes vote down vote up
public STHKCurrentInpatientListVo saveIP(STHKCurrentInpatientListVo voIP) throws DomainInterfaceException, StaleObjectException 
{
	if(voIP == null)
		throw new CodingRuntimeException("Cannot save null STHKCurrentInpatientListVo");
	
	if (!voIP.isValidated())
		throw new CodingRuntimeException("Inpatient Record has not been validated");
	
	DomainFactory factory = getDomainFactory();
	
	InpatientEpisode doIP = STHKCurrentInpatientListVoAssembler.extractInpatientEpisode(factory, voIP);
	
	//WDEV-18059 patient was discharged form another session.
	if (doIP == null)
		throw new StaleObjectException(doIP);
		
	factory.save(doIP);
	return (STHKCurrentInpatientListVoAssembler.create(doIP));		
}
 
Example 17
Project: openmaxims-linux   File: ClinicListwithICPActionsImpl.java   Source Code and License 6 votes vote down vote up
public Boolean isInpatientCareContext(PatientRefVo patientRef, CareContextRefVo careContextRef)
{
	if (patientRef == null || !patientRef.getID_PatientIsNotNull())
		throw new CodingRuntimeException("Logical Error - Patient expected");
	
	if (careContextRef == null || !careContextRef.getID_CareContextIsNotNull())
		throw new CodingRuntimeException("Logical Error - Care Context expected");
	
	String hql = "from InpatientEpisode as ip where (ip.pasEvent.id in (select cc.pasEvent.id from CareContext as cc where cc.id = :refID))";
	ArrayList<String> paramNames = new ArrayList<String>();
	paramNames.add("refID");
	
	ArrayList<Object> paramValues = new ArrayList<Object>();
	paramValues.add(careContextRef.getID_CareContext());
	
	InpatientEpisodeLiteVo inpatientEpisode = InpatientEpisodeLiteVoAssembler.create((InpatientEpisode) getDomainFactory().findFirst(hql, paramNames, paramValues));
	
	if (inpatientEpisode == null)
		return Boolean.FALSE;
	
	return Boolean.TRUE;
}
 
Example 18
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 19
Project: openmaxims-linux   File: BedInfoDialogImpl.java   Source Code and License 6 votes vote down vote up
private String getPatientIdValue(InpatientEpisode doInpatientEpisode, PatIdType type) 
{
	if(doInpatientEpisode == null)
		return null;
	
	if(doInpatientEpisode.getPasEvent() != null && doInpatientEpisode.getPasEvent().getPatient() != null && doInpatientEpisode.getPasEvent().getPatient().getIdentifiers() != null)
	{
		Iterator it = doInpatientEpisode.getPasEvent().getPatient().getIdentifiers().iterator();
		while(it.hasNext())
		{
			PatientId patId = (PatientId) it.next();
			if(patId.getType().equals( getDomLookup(type)))
				return patId.getValue();
		}
	}
	
	return null;
}
 
Example 20
Project: openmaxims-linux   File: ADTImpl.java   Source Code and License 6 votes vote down vote up
public void cancelInpatientLeave(PatientShort patient) throws StaleObjectException
{
	DomainFactory factory = getDomainFactory();

	Patient domPatient = PatientShortAssembler.extractPatient(factory, patient);
	InpatientEpisode epis = getCurrentAdmission(factory, patient);
	if (epis != null)
	{
	PASEvent pasevent=epis.getPasEvent();
	Location loc=(Location)factory.getDomainObject(Location.class, domPatient.getWard().getId());
	pasevent.setLocation(loc);
	epis.setPasEvent(pasevent);

	epis.setIsOnLeave(Boolean.FALSE);
	factory.save(epis);
	}
}
 
Example 21
Project: openMAXIMS   File: ADTAdmissionDetailsComponentImpl.java   Source Code and License 6 votes vote down vote up
public InpatientEpisodeVo getInpatientEpisode(PASEventRefVo pasEventRef)
{
	if(pasEventRef == null || pasEventRef.getID_PASEvent()==null)
		throw new CodingRuntimeException("Cannot get PasEvent value on null pasEventRef.");
	
	StringBuffer hql = new StringBuffer("select inpEpisode from InpatientEpisode as inpEpisode left join inpEpisode.pasEvent as pasEvent where pasEvent.id= :pasEventID ");
	
	DomainFactory factory = getDomainFactory();
	List<?> list = factory.find(hql.toString(), new String[] {"pasEventID"}, new Object[] {pasEventRef.getID_PASEvent()});
	
	if (list!=null && list.size()>0)
	{	
		return InpatientEpisodeVoAssembler.create((InpatientEpisode) list.get(0));
	}
	
	return null;
}
 
Example 22
Project: openMAXIMS   File: ADTAdmissionDetailsComponentImpl.java   Source Code and License 6 votes vote down vote up
public AdmissionType getAdmissionTypeFromInpatientEpisode(PASEventRefVo pasEventRef)
{
	if(pasEventRef == null || pasEventRef.getID_PASEvent()==null)
		throw new CodingRuntimeException("Cannot get PasEvent value on null pasEventRef.");
	
	StringBuffer hql = new StringBuffer("select inpEpisode from InpatientEpisode as inpEpisode left join inpEpisode.pasEvent as pasEvent where pasEvent.id= :pasEventID ");
	
	DomainFactory factory = getDomainFactory();
	List<?> list = factory.find(hql.toString(), new String[] {"pasEventID"}, new Object[] {pasEventRef.getID_PASEvent()});
	
	if (list!=null && list.size()>0)
	{	
		return (InpatientEpisodeVoAssembler.create((InpatientEpisode) list.get(0))).getAdmissionType();
	}
	
	return null;
}
 
Example 23
Project: openMAXIMS   File: BedInfoDialogImpl.java   Source Code and License 6 votes vote down vote up
private void addConsultantStay(InpatientEpisode doInpat, PatientStatus patientCategory)
{
	Date transferDate = getMostRecentWardStayTransferDate(doInpat);
	LookupInstance patientCategoryForStay  = patientCategory != null ? getDomLookup(patientCategory) : doInpat.getPasEvent().getPatient().getPatientCategory();
	ConsultantStay oldCS = updateCurrentConsultantStay(doInpat.getConsultantStays());
	if(oldCS != null)
	{
		oldCS.setEndDateTime(transferDate);
	}
		
	ConsultantStay doConsStay = new ConsultantStay();
	doConsStay.setConsultant(doInpat.getPasEvent().getConsultant());
	doConsStay.setTransferDateTime(transferDate);
	doConsStay.setSpecialty(doInpat.getPasEvent().getSpecialty());
	doConsStay.setService(doInpat.getPasEvent().getService());
	doConsStay.setPatientStatus(patientCategoryForStay);
	
	doInpat.getConsultantStays().add(doConsStay);
}
 
Example 24
Project: openmaxims-linux   File: ADTImpl.java   Source Code and License 6 votes vote down vote up
public ims.core.vo.InpatientEpisodeVo transferPatient(PatientRefVo patVo, HcpRefVo hcp, LocationRefVo ward,Integer stay,LocationRefVo fromWard, DateTime transferDateTime, DateTime transactionDT, LookupInstVo specialty) throws ims.domain.exceptions.DomainInterfaceException, ims.domain.exceptions.StaleObjectException
{
	if (patVo == null)
	{
		throw new DomainRuntimeException("Patient cannot be null!");
	}
	InpatientEpisode ipDo = getCurrentAdmission(patVo);
	if (ipDo == null)
	{
		//Patient is not currently an inpatient, so ignore transfer event.
		return null;	
	}	
	performTransfer(ipDo, patVo, hcp, ward,stay,fromWard,transferDateTime,transactionDT,specialty);
	
	return InpatientEpisodeVoAssembler.create(ipDo);
}
 
Example 25
Project: openMAXIMS   File: BedInfoDialogImpl.java   Source Code and License 6 votes vote down vote up
private Date getMostRecentWardStayTransferDate(InpatientEpisode inpatientEpisode)
{
	if(inpatientEpisode == null)
		throw new CodingRuntimeException("inpatientEpisode is null in method getMostRecentWardStayTransferDate");

	Date transferDate = null;
	if(inpatientEpisode.getWardStays() != null && inpatientEpisode.getWardStays().size() > 0)
	{
		Iterator it = inpatientEpisode.getWardStays().iterator();
		while(it.hasNext())
		{	
			WardStay wardStay = (WardStay)it.next();
			//**********************************************
			if(wardStay == null || wardStay.getTransferDateTime()== null)
			   continue;
			//**********************************************
			if(transferDate == null || transferDate.before(wardStay.getTransferDateTime()))
				transferDate = wardStay.getTransferDateTime();
		}
	}			
		
	return transferDate;
}
 
Example 26
Project: openMAXIMS   File: BedInfoDialogImpl.java   Source Code and License 6 votes vote down vote up
private String getPatientIdValue(InpatientEpisode doInpatientEpisode, PatIdType type) 
{
	if(doInpatientEpisode == null)
		return null;
	
	if(doInpatientEpisode.getPasEvent() != null && doInpatientEpisode.getPasEvent().getPatient() != null && doInpatientEpisode.getPasEvent().getPatient().getIdentifiers() != null)
	{
		Iterator it = doInpatientEpisode.getPasEvent().getPatient().getIdentifiers().iterator();
		while(it.hasNext())
		{
			PatientId patId = (PatientId) it.next();
			if(patId.getType().equals( getDomLookup(type)))
				return patId.getValue();
		}
	}
	
	return null;
}
 
Example 27
Project: openMAXIMS   File: BedInfoDialogImpl.java   Source Code and License 6 votes vote down vote up
private InpatientEpisode closeCurrentHomeLeaveAndUpdateEpisode(InpatientEpisode doInpatEpis, HomeLeaveVo voHl)
{
	HomeLeave currentHomeLeaveDO = null;
	if (doInpatEpis == null || !Boolean.TRUE.equals(doInpatEpis.isIsOnHomeLeave()) ||  doInpatEpis.getHomeLeaves() == null)
		return 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.getDateOnHomeLeave().equals(doInpatEpis.getDateOnHomeLeave()))
		 {
			 currentHomeLeaveDO = doHL;
			 break;
		 }			 
	}

	if (currentHomeLeaveDO != null)
	{	
		currentHomeLeaveDO.setDateReturnedFromHomeLeave(voHl.getDateReturnedFromHomeLeaveIsNotNull() ? voHl.getDateReturnedFromHomeLeave().getDate() : null);
		currentHomeLeaveDO.setTimeReturnedFromHomeLeave(voHl.getTimeReturnedFromHomeLeaveIsNotNull() ? voHl.getTimeReturnedFromHomeLeave().toString() : null);

		doInpatEpis.getHomeLeaves().set(doInpatEpis.getHomeLeaves().indexOf(currentHomeLeaveDO), currentHomeLeaveDO);	 
	} 
	
	return doInpatEpis;
}
 
Example 28
Project: openMAXIMS   File: BedInfoDialogImpl.java   Source Code and License 6 votes vote down vote up
public InpatientEpisodeTrackingMoveVo saveInpatientEpisodeTrackingMovement(InpatientEpisodeTrackingMoveVo inpatientEpisodeTrackingMove) throws StaleObjectException
{
	if (inpatientEpisodeTrackingMove == null)
		throw new CodingRuntimeException("Cannot save null record");
	
	if (!inpatientEpisodeTrackingMove.isValidated())
		throw new CodingRuntimeException("Cannot save records not validated");
	
	@SuppressWarnings("rawtypes")
	HashMap map =  new HashMap();
	InpatientEpisode domInpatientEpisode = InpatientEpisodeTrackingMoveVoAssembler.extractInpatientEpisode(getDomainFactory(), inpatientEpisodeTrackingMove, map);
	
	getDomainFactory().save(domInpatientEpisode);

	return InpatientEpisodeTrackingMoveVoAssembler.create(domInpatientEpisode);
}
 
Example 29
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 30
Project: openMAXIMS   File: ADTImpl.java   Source Code and License 6 votes vote down vote up
public ims.core.vo.InpatientEpisodeVo transferPatient(PatientRefVo patVo, HcpRefVo hcp, LocationRefVo ward,Integer stay,LocationRefVo fromWard, DateTime transferDateTime, DateTime transactionDT, LookupInstVo specialty) throws ims.domain.exceptions.DomainInterfaceException, ims.domain.exceptions.StaleObjectException
{
	if (patVo == null)
	{
		throw new DomainRuntimeException("Patient cannot be null!");
	}
	InpatientEpisode ipDo = getCurrentAdmission(patVo);
	if (ipDo == null)
	{
		//Patient is not currently an inpatient, so ignore transfer event.
		return null;	
	}	
	performTransfer(ipDo, patVo, hcp, ward,stay,fromWard,transferDateTime,transactionDT,specialty);
	
	return InpatientEpisodeVoAssembler.create(ipDo);
}
 
Example 31
Project: openMAXIMS   File: ADTImpl.java   Source Code and License 6 votes vote down vote up
void RestorePreOpVTEAssessmentToSummaryRecord(PatientSummaryRecord patientSummaryRecord,InpatientEpisode episode)
{
	if(episode!=null
			&&episode.getVTERiskAssessment()!=null
			&&episode.getVTERiskAssessment().getContextType().equals(getDomLookup(VTEAssessmentContextType.PREOP)))
	{
		patientSummaryRecord.setPreOpVTEAssessment(episode.getVTERiskAssessment());
		patientSummaryRecord.getPreOpVTEAssessment().setValidatedInformation(null);
		if(patientSummaryRecord.getPreOpVTEAssessment().getVTEAssessmentStatus().equals(getDomLookup(VTEAsessmentStatus.VALIDATED)))
		{
			patientSummaryRecord.getPreOpVTEAssessment().setVTEAssessmentStatus(getDomLookup(VTEAsessmentStatus.COMPLETED));
		}
		patientSummaryRecord.setPreOpVTEValidationDate(null);
		if(patientSummaryRecord.getPreOpVTEAssessment().getRecordingInformation()!=null)
		{
			patientSummaryRecord.setPreOpVTECompletedDate(patientSummaryRecord.getPreOpVTEAssessment().getRecordingInformation().getRecordingDateTime());
		}
	}
}
 
Example 32
Project: openmaxims-linux   File: AdmissionDetailsImpl.java   Source Code and License 6 votes vote down vote up
/**
* Method used to retrieve Admission Details.
*/
public AdmissionDetailLiteWithInpatientEpisodeVo getAdmission(AdmissionDetailRefVo admission)
{
	// Check admission record parameter
	if (admission == null || !admission.getID_AdmissionDetailIsNotNull())
		return null;
	
	AdmissionDetailLiteWithInpatientEpisodeVo admissionDetails = AdmissionDetailLiteWithInpatientEpisodeVoAssembler.create((AdmissionDetail) getDomainFactory().getDomainObject(AdmissionDetail.class, admission.getID_AdmissionDetail()));

	// Get Inpatient episode if exists
	String query = "SELECT inpEp FROM InpatientEpisode AS inpEp LEFT JOIN inpEp.pasEvent AS pas1, AdmissionDetail AS admtDetail LEFT JOIN admtDetail.pasEvent AS pas2 WHERE pas1.id = pas2.id AND admtDetail.id = :ADM_ID AND inpEp.isRIE is null";
	
	ArrayList<String> paramNames = new ArrayList<String>();
	ArrayList<Object> paramValues = new ArrayList<Object>();
	
	paramNames.add("ADM_ID");
	paramValues.add(admissionDetails.getID_AdmissionDetail());
	
	InpatientEpisodeBedNumberUpdateVo inpatientEpisode = InpatientEpisodeBedNumberUpdateVoAssembler.create((InpatientEpisode) getDomainFactory().findFirst(query, paramNames, paramValues));
	
	admissionDetails.setInpatientEpisode(inpatientEpisode);
	
	return admissionDetails;
}
 
Example 33
Project: openMAXIMS   File: DischargeSummaryWardPacuImpl.java   Source Code and License 6 votes vote down vote up
public InpatientEpisodeVo getInpatientEpisode(CatsReferralRefVo referral)
{
	if (referral == null || referral.getID_CatsReferral() == null)
		throw new CodingRuntimeException("Logical error - provided referral is null or has no id");
	
	DomainFactory factory = getDomainFactory();
	
	String hql = "from InpatientEpisode as ip where (ip.isRIE is null and ip.pasEvent.id in (select cr.careContext.pasEvent.id from CatsReferral as cr where cr.id = :refID))";
	
	ArrayList<String> paramNames = new ArrayList<String>();
	paramNames.add("refID");
	
	ArrayList<Object> paramValues = new ArrayList<Object>();
	paramValues.add(referral.getID_CatsReferral());
	
	return InpatientEpisodeVoAssembler.create((InpatientEpisode) factory.findFirst(hql, paramNames, paramValues));
}
 
Example 34
Project: openMAXIMS   File: EDischargeSummarySthkComponentImpl.java   Source Code and License 6 votes vote down vote up
public InpatientEpisodeEDischargeVo getInpatientEpisodeByCareContext(CareContextRefVo careContext)
{
	if (careContext == null || careContext.getID_CareContext() == null)
		throw new CodingRuntimeException("careContext is null or id not provided in method getInpatientEpisodeByCareContext");
	
	List items = getDomainFactory().find(" select cc.pasEvent.id from CareContext as cc where cc.id = " +  careContext.getID_CareContext());
	if(items != null && items.size() > 0)
	{
		Integer eventId = (Integer) items.get(0);
	
		if(eventId!= null && eventId  > 0)
		{
			List ieItems = getDomainFactory().find(" from InpatientEpisode ie where ie.pasEvent.id = " +  eventId);
			if(ieItems != null && ieItems.size() > 0)
				return InpatientEpisodeEDischargeVoAssembler.create((InpatientEpisode) ieItems.get(0));
		}	
	}
	
	return null;
}
 
Example 35
Project: openMAXIMS   File: ClinicListwithICPActionsImpl.java   Source Code and License 6 votes vote down vote up
public Boolean isInpatientCareContext(PatientRefVo patientRef, CareContextRefVo careContextRef)
{
	if (patientRef == null || !patientRef.getID_PatientIsNotNull())
		throw new CodingRuntimeException("Logical Error - Patient expected");
	
	if (careContextRef == null || !careContextRef.getID_CareContextIsNotNull())
		throw new CodingRuntimeException("Logical Error - Care Context expected");
	
	String hql = "from InpatientEpisode as ip where (ip.pasEvent.id in (select cc.pasEvent.id from CareContext as cc where cc.id = :refID))";
	ArrayList<String> paramNames = new ArrayList<String>();
	paramNames.add("refID");
	
	ArrayList<Object> paramValues = new ArrayList<Object>();
	paramValues.add(careContextRef.getID_CareContext());
	
	InpatientEpisodeLiteVo inpatientEpisode = InpatientEpisodeLiteVoAssembler.create((InpatientEpisode) getDomainFactory().findFirst(hql, paramNames, paramValues));
	
	if (inpatientEpisode == null)
		return Boolean.FALSE;
	
	return Boolean.TRUE;
}
 
Example 36
Project: openmaxims-linux   File: ADTAdmissionDetailsComponentImpl.java   Source Code and License 6 votes vote down vote up
public InpatientEpisodeVo getInpatientEpisode(PASEventRefVo pasEventRef)
{
	if(pasEventRef == null || pasEventRef.getID_PASEvent()==null)
		throw new CodingRuntimeException("Cannot get PasEvent value on null pasEventRef.");
	
	StringBuffer hql = new StringBuffer("select inpEpisode from InpatientEpisode as inpEpisode left join inpEpisode.pasEvent as pasEvent where pasEvent.id= :pasEventID ");
	
	DomainFactory factory = getDomainFactory();
	List<?> list = factory.find(hql.toString(), new String[] {"pasEventID"}, new Object[] {pasEventRef.getID_PASEvent()});
	
	if (list!=null && list.size()>0)
	{	
		return InpatientEpisodeVoAssembler.create((InpatientEpisode) list.get(0));
	}
	
	return null;
}
 
Example 37
Project: openMAXIMS   File: AdmissionDetailsImpl.java   Source Code and License 6 votes vote down vote up
/**
* Method used to retrieve Admission Details.
*/
public AdmissionDetailLiteWithInpatientEpisodeVo getAdmission(AdmissionDetailRefVo admission)
{
	// Check admission record parameter
	if (admission == null || !admission.getID_AdmissionDetailIsNotNull())
		return null;
	
	AdmissionDetailLiteWithInpatientEpisodeVo admissionDetails = AdmissionDetailLiteWithInpatientEpisodeVoAssembler.create((AdmissionDetail) getDomainFactory().getDomainObject(AdmissionDetail.class, admission.getID_AdmissionDetail()));

	// Get Inpatient episode if exists
	String query = "SELECT inpEp FROM InpatientEpisode AS inpEp LEFT JOIN inpEp.pasEvent AS pas1, AdmissionDetail AS admtDetail LEFT JOIN admtDetail.pasEvent AS pas2 WHERE pas1.id = pas2.id AND admtDetail.id = :ADM_ID AND inpEp.isRIE is null";
	
	ArrayList<String> paramNames = new ArrayList<String>();
	ArrayList<Object> paramValues = new ArrayList<Object>();
	
	paramNames.add("ADM_ID");
	paramValues.add(admissionDetails.getID_AdmissionDetail());
	
	InpatientEpisodeBedNumberUpdateVo inpatientEpisode = InpatientEpisodeBedNumberUpdateVoAssembler.create((InpatientEpisode) getDomainFactory().findFirst(query, paramNames, paramValues));
	
	admissionDetails.setInpatientEpisode(inpatientEpisode);
	
	return admissionDetails;
}
 
Example 38
Project: openMAXIMS   File: BedInfoDialogImpl.java   Source Code and License 6 votes vote down vote up
private Date getMostRecentConsultantStayTransferDate(InpatientEpisode inpatientEpisode)
{
	if(inpatientEpisode == null)
		throw new CodingRuntimeException("inpatientEpisode is null in method getMostRecentConsultantStayTransferDate");
	
	Date transferDate = null;
	if(inpatientEpisode.getConsultantStays() != null && inpatientEpisode.getConsultantStays().size() > 0)
	{
		Iterator it = inpatientEpisode.getConsultantStays().iterator();
		while(it.hasNext())
		{	
			ConsultantStay consStay = (ConsultantStay)it.next();
			if(consStay.getTransferDateTime() != null)
			{
				if(transferDate == null || transferDate.before(consStay.getTransferDateTime()))
					transferDate = consStay.getTransferDateTime();
			}
		}
	}			
		
	return transferDate;
}
 
Example 39
Project: openMAXIMS   File: BedInfoDialogImpl.java   Source Code and License 6 votes vote down vote up
private String getPatientIdValue(InpatientEpisode doInpatientEpisode, PatIdType type) 
{
	if(doInpatientEpisode == null)
		return null;
	
	if(doInpatientEpisode.getPasEvent() != null && doInpatientEpisode.getPasEvent().getPatient() != null && doInpatientEpisode.getPasEvent().getPatient().getIdentifiers() != null)
	{
		Iterator it = doInpatientEpisode.getPasEvent().getPatient().getIdentifiers().iterator();
		while(it.hasNext())
		{
			PatientId patId = (PatientId) it.next();
			if(patId.getType().equals( getDomLookup(type)))
				return patId.getValue();
		}
	}
	
	return null;
}
 
Example 40
Project: AvoinApotti   File: BatchUpdatePatientListsImpl.java   Source Code and License 5 votes vote down vote up
public void saveInpatientEpisodes(InpatientEpisodeVoCollection collInpatientEpisodeVo, MemberOfStaffShortVo mos) throws DomainInterfaceException, StaleObjectException {
	for(int i=0; i<collInpatientEpisodeVo.size(); i++){
		if (!collInpatientEpisodeVo.get(i).isValidated())
		{
			throw new DomainRuntimeException("Episode VO has not been validated!");
		}
	
		DomainFactory factory = getDomainFactory();		
		InpatientEpisode ipDo = InpatientEpisodeVoAssembler.extractInpatientEpisode(factory, collInpatientEpisodeVo.get(i));
		
		factory.save(ipDo);
		saveDocumentStatus(collInpatientEpisodeVo.get(i).getPasEvent().getCspDocumentStatus(), collInpatientEpisodeVo.get(i).getPasEvent(), mos);
	}
}