/FileExtraction/Java_unseen/IMS-MAXIMS_openMAXIMS/Source Library/openmaxims_workspace/ValueObjects/src/ims/core/vo/WardViewPatientListVo.java
//#############################################################################
//#                                                                           #
//#  Copyright (C) <2015>  <IMS MAXIMS>                                       #
//#                                                                           #
//#  This program is free software: you can redistribute it and/or modify     #
//#  it under the terms of the GNU Affero General Public License as           #
//#  published by the Free Software Foundation, either version 3 of the       #
//#  License, or (at your option) any later version.                          # 
//#                                                                           #
//#  This program is distributed in the hope that it will be useful,          #
//#  but WITHOUT ANY WARRANTY; without even the implied warranty of           #
//#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            #
//#  GNU Affero General Public License for more details.                      #
//#                                                                           #
//#  You should have received a copy of the GNU Affero General Public License #
//#  along with this program.  If not, see <http://www.gnu.org/licenses/>.    #
//#                                                                           #
//#  IMS MAXIMS provides absolutely NO GUARANTEE OF THE CLINICAL SAFTEY of    #
//#  this program.  Users of this software do so entirely at their own risk.  #
//#  IMS MAXIMS only ensures the Clinical Safety of unaltered run-time        #
//#  software that it builds, deploys and maintains.                          #
//#                                                                           #
//#############################################################################
//#EOH
// This code was generated by Barbara Worwood using IMS Development Environment (version 1.80 build 5589.25814)
// Copyright (C) 1995-2015 IMS MAXIMS. All rights reserved.
// WARNING: DO NOT MODIFY the content of this file

package ims.core.vo;


public class WardViewPatientListVo extends ims.vo.ValueObject implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public WardViewPatientListVo()
	{
	}
	public WardViewPatientListVo(ims.core.vo.beans.WardViewPatientListVoBean bean)
	{
		this.patient = bean.getPatient() == null ? null : bean.getPatient().buildVo();
		this.inpatientepisode = bean.getInpatientEpisode() == null ? null : bean.getInpatientEpisode().buildVo();
		this.bedspacestate = bean.getBedSpaceState() == null ? null : new ims.core.admin.pas.vo.BedSpaceStateRefVo(new Integer(bean.getBedSpaceState().getId()), bean.getBedSpaceState().getVersion());
		this.pendingtransfer = bean.getPendingTransfer() == null ? null : bean.getPendingTransfer().buildVo();
		this.latestpatientsecs = bean.getLatestPatientSECS() == null ? null : bean.getLatestPatientSECS().buildVo();
		this.canreopenhomeleave = bean.getCanReopenHomeLeave();
		this.bayavailabilitystatus = bean.getBayAvailabilityStatus() == null ? null : ims.core.vo.lookups.WardBayStatus.buildLookup(bean.getBayAvailabilityStatus());
		this.haspendingtransfer = bean.getHasPendingTransfer();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.WardViewPatientListVoBean bean)
	{
		this.patient = bean.getPatient() == null ? null : bean.getPatient().buildVo(map);
		this.inpatientepisode = bean.getInpatientEpisode() == null ? null : bean.getInpatientEpisode().buildVo(map);
		this.bedspacestate = bean.getBedSpaceState() == null ? null : new ims.core.admin.pas.vo.BedSpaceStateRefVo(new Integer(bean.getBedSpaceState().getId()), bean.getBedSpaceState().getVersion());
		this.pendingtransfer = bean.getPendingTransfer() == null ? null : bean.getPendingTransfer().buildVo(map);
		this.latestpatientsecs = bean.getLatestPatientSECS() == null ? null : bean.getLatestPatientSECS().buildVo(map);
		this.canreopenhomeleave = bean.getCanReopenHomeLeave();
		this.bayavailabilitystatus = bean.getBayAvailabilityStatus() == null ? null : ims.core.vo.lookups.WardBayStatus.buildLookup(bean.getBayAvailabilityStatus());
		this.haspendingtransfer = bean.getHasPendingTransfer();
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.core.vo.beans.WardViewPatientListVoBean bean = null;
		if(map != null)
			bean = (ims.core.vo.beans.WardViewPatientListVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.core.vo.beans.WardViewPatientListVoBean();
			map.addValueObjectBean(this, bean);
			bean.populate(map, this);
		}
		return bean;
	}
	public boolean getPatientIsNotNull()
	{
		return this.patient != null;
	}
	public ims.core.vo.PatientLite_IdentifiersVo getPatient()
	{
		return this.patient;
	}
	public void setPatient(ims.core.vo.PatientLite_IdentifiersVo value)
	{
		this.isValidated = false;
		this.patient = value;
	}
	public boolean getInpatientEpisodeIsNotNull()
	{
		return this.inpatientepisode != null;
	}
	public ims.core.vo.InpatientEpisodeForWardPatientListVo getInpatientEpisode()
	{
		return this.inpatientepisode;
	}
	public void setInpatientEpisode(ims.core.vo.InpatientEpisodeForWardPatientListVo value)
	{
		this.isValidated = false;
		this.inpatientepisode = value;
	}
	public boolean getBedSpaceStateIsNotNull()
	{
		return this.bedspacestate != null;
	}
	public ims.core.admin.pas.vo.BedSpaceStateRefVo getBedSpaceState()
	{
		return this.bedspacestate;
	}
	public void setBedSpaceState(ims.core.admin.pas.vo.BedSpaceStateRefVo value)
	{
		this.isValidated = false;
		this.bedspacestate = value;
	}
	public boolean getPendingTransferIsNotNull()
	{
		return this.pendingtransfer != null;
	}
	public ims.core.vo.PendingTransferForBedReadyDetailsVo getPendingTransfer()
	{
		return this.pendingtransfer;
	}
	public void setPendingTransfer(ims.core.vo.PendingTransferForBedReadyDetailsVo value)
	{
		this.isValidated = false;
		this.pendingtransfer = value;
	}
	public boolean getLatestPatientSECSIsNotNull()
	{
		return this.latestpatientsecs != null;
	}
	public ims.clinical.vo.PatientSECSLiteVo getLatestPatientSECS()
	{
		return this.latestpatientsecs;
	}
	public void setLatestPatientSECS(ims.clinical.vo.PatientSECSLiteVo value)
	{
		this.isValidated = false;
		this.latestpatientsecs = value;
	}
	public boolean getCanReopenHomeLeaveIsNotNull()
	{
		return this.canreopenhomeleave != null;
	}
	public Boolean getCanReopenHomeLeave()
	{
		return this.canreopenhomeleave;
	}
	public void setCanReopenHomeLeave(Boolean value)
	{
		this.isValidated = false;
		this.canreopenhomeleave = value;
	}
	public boolean getBayAvailabilityStatusIsNotNull()
	{
		return this.bayavailabilitystatus != null;
	}
	public ims.core.vo.lookups.WardBayStatus getBayAvailabilityStatus()
	{
		return this.bayavailabilitystatus;
	}
	public void setBayAvailabilityStatus(ims.core.vo.lookups.WardBayStatus value)
	{
		this.isValidated = false;
		this.bayavailabilitystatus = value;
	}
	public boolean getHasPendingTransferIsNotNull()
	{
		return this.haspendingtransfer != null;
	}
	public Boolean getHasPendingTransfer()
	{
		return this.haspendingtransfer;
	}
	public void setHasPendingTransfer(Boolean value)
	{
		this.isValidated = false;
		this.haspendingtransfer = value;
	}
	public final String getIItemText()
	{
		return toString();
	}
	public final Integer getBoId() 
	{
		return null;
	}
	public final String getBoClassName()
	{
		return null;
	}
	public boolean equals(Object obj)
	{
		if(obj == null)
			return false;
		if(!(obj instanceof WardViewPatientListVo))
			return false;
		WardViewPatientListVo compareObj = (WardViewPatientListVo)obj;
		if(this.getPatient() == null && compareObj.getPatient() != null)
			return false;
		if(this.getPatient() != null && compareObj.getPatient() == null)
			return false;
		if(this.getPatient() != null && compareObj.getPatient() != null)
			if(!this.getPatient().equals(compareObj.getPatient()))
				return false;
		if(this.getInpatientEpisode() == null && compareObj.getInpatientEpisode() != null)
			return false;
		if(this.getInpatientEpisode() != null && compareObj.getInpatientEpisode() == null)
			return false;
		if(this.getInpatientEpisode() != null && compareObj.getInpatientEpisode() != null)
			return this.getInpatientEpisode().equals(compareObj.getInpatientEpisode());
		return super.equals(obj);
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.pendingtransfer != null)
		{
			if(!this.pendingtransfer.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		this.isBusy = false;
		return true;
	}
	public String[] validate()
	{
		return validate(null);
	}
	public String[] validate(String[] existingErrors)
	{
		if(this.isBusy)
			return null;
		this.isBusy = true;
	
		java.util.ArrayList<String> listOfErrors = new java.util.ArrayList<String>();
		if(existingErrors != null)
		{
			for(int x = 0; x < existingErrors.length; x++)
			{
				listOfErrors.add(existingErrors[x]);
			}
		}
		if(this.pendingtransfer != null)
		{
			String[] listOfOtherErrors = this.pendingtransfer.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		int errorCount = listOfErrors.size();
		if(errorCount == 0)
		{
			this.isBusy = false;
			this.isValidated = true;
			return null;
		}
		String[] result = new String[errorCount];
		for(int x = 0; x < errorCount; x++)
			result[x] = (String)listOfErrors.get(x);
		this.isBusy = false;
		this.isValidated = false;
		return result;
	}
	public Object clone()
	{
		if(this.isBusy)
			return this;
		this.isBusy = true;
	
		WardViewPatientListVo clone = new WardViewPatientListVo();
		
		if(this.patient == null)
			clone.patient = null;
		else
			clone.patient = (ims.core.vo.PatientLite_IdentifiersVo)this.patient.clone();
		if(this.inpatientepisode == null)
			clone.inpatientepisode = null;
		else
			clone.inpatientepisode = (ims.core.vo.InpatientEpisodeForWardPatientListVo)this.inpatientepisode.clone();
		clone.bedspacestate = this.bedspacestate;
		if(this.pendingtransfer == null)
			clone.pendingtransfer = null;
		else
			clone.pendingtransfer = (ims.core.vo.PendingTransferForBedReadyDetailsVo)this.pendingtransfer.clone();
		if(this.latestpatientsecs == null)
			clone.latestpatientsecs = null;
		else
			clone.latestpatientsecs = (ims.clinical.vo.PatientSECSLiteVo)this.latestpatientsecs.clone();
		clone.canreopenhomeleave = this.canreopenhomeleave;
		if(this.bayavailabilitystatus == null)
			clone.bayavailabilitystatus = null;
		else
			clone.bayavailabilitystatus = (ims.core.vo.lookups.WardBayStatus)this.bayavailabilitystatus.clone();
		clone.haspendingtransfer = this.haspendingtransfer;
		clone.isValidated = this.isValidated;
		
		this.isBusy = false;
		return clone;
	}
	public int compareTo(Object obj)
	{
		return compareTo(obj, true);
	}
	public int compareTo(Object obj, boolean caseInsensitive)
	{
		if (obj == null)
		{
			return -1;
		}
		if(caseInsensitive); // this is to avoid eclipse warning only.
		if (!(WardViewPatientListVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A WardViewPatientListVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		WardViewPatientListVo compareObj = (WardViewPatientListVo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getPatient() == null && compareObj.getPatient() != null)
				return -1;
			if(this.getPatient() != null && compareObj.getPatient() == null)
				return 1;
			if(this.getPatient() != null && compareObj.getPatient() != null)
				retVal = this.getPatient().compareTo(compareObj.getPatient());
		}
		if (retVal == 0)
		{
			if(this.getBedSpaceState() == null && compareObj.getBedSpaceState() != null)
				return -1;
			if(this.getBedSpaceState() != null && compareObj.getBedSpaceState() == null)
				return 1;
			if(this.getBedSpaceState() != null && compareObj.getBedSpaceState() != null)
				retVal = this.getBedSpaceState().compareTo(compareObj.getBedSpaceState());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.patient != null)
			count++;
		if(this.inpatientepisode != null)
			count++;
		if(this.bedspacestate != null)
			count++;
		if(this.pendingtransfer != null)
			count++;
		if(this.latestpatientsecs != null)
			count++;
		if(this.canreopenhomeleave != null)
			count++;
		if(this.bayavailabilitystatus != null)
			count++;
		if(this.haspendingtransfer != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 8;
	}
	protected ims.core.vo.PatientLite_IdentifiersVo patient;
	protected ims.core.vo.InpatientEpisodeForWardPatientListVo inpatientepisode;
	protected ims.core.admin.pas.vo.BedSpaceStateRefVo bedspacestate;
	protected ims.core.vo.PendingTransferForBedReadyDetailsVo pendingtransfer;
	protected ims.clinical.vo.PatientSECSLiteVo latestpatientsecs;
	protected Boolean canreopenhomeleave;
	protected ims.core.vo.lookups.WardBayStatus bayavailabilitystatus;
	protected Boolean haspendingtransfer;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
