/FileExtraction/Java_unseen/IMS-MAXIMS_openMAXIMS/Source Library/openmaxims_workspace/ValueObjects/src/ims/core/vo/PendingElectiveAdmissionListFilterVo.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 PendingElectiveAdmissionListFilterVo extends ims.core.vo.BaseListFilterVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public PendingElectiveAdmissionListFilterVo()
	{
	}
	public PendingElectiveAdmissionListFilterVo(ims.core.vo.beans.PendingElectiveAdmissionListFilterVoBean bean)
	{
		this.surname = bean.getSurname();
		this.forename = bean.getForename();
		this.hospnum = bean.getHospNum();
		this.ward = bean.getWard() == null ? null : new ims.core.resource.place.vo.LocationRefVo(new Integer(bean.getWard().getId()), bean.getWard().getVersion());
		this.consultant = bean.getConsultant() == null ? null : new ims.core.resource.people.vo.HcpRefVo(new Integer(bean.getConsultant().getId()), bean.getConsultant().getVersion());
		this.alert = bean.getAlert() == null ? null : ims.core.vo.lookups.AlertType.buildLookup(bean.getAlert());
		this.hospital = bean.getHospital() == null ? null : new ims.core.resource.place.vo.LocationRefVo(new Integer(bean.getHospital().getId()), bean.getHospital().getVersion());
		this.tci = bean.getTCI() == null ? null : bean.getTCI().buildDate();
		this.specialty = bean.getSpecialty() == null ? null : ims.core.vo.lookups.Specialty.buildLookup(bean.getSpecialty());
		this.tcidateonly = bean.getTCIDateOnly();
		this.idtype = bean.getIDType() == null ? null : ims.core.vo.lookups.PatIdType.buildLookup(bean.getIDType());
		this.electiveadmissiontype = bean.getElectiveAdmissionType() == null ? null : ims.RefMan.vo.lookups.ElectiveAdmissionType.buildLookup(bean.getElectiveAdmissionType());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.PendingElectiveAdmissionListFilterVoBean bean)
	{
		this.surname = bean.getSurname();
		this.forename = bean.getForename();
		this.hospnum = bean.getHospNum();
		this.ward = bean.getWard() == null ? null : new ims.core.resource.place.vo.LocationRefVo(new Integer(bean.getWard().getId()), bean.getWard().getVersion());
		this.consultant = bean.getConsultant() == null ? null : new ims.core.resource.people.vo.HcpRefVo(new Integer(bean.getConsultant().getId()), bean.getConsultant().getVersion());
		this.alert = bean.getAlert() == null ? null : ims.core.vo.lookups.AlertType.buildLookup(bean.getAlert());
		this.hospital = bean.getHospital() == null ? null : new ims.core.resource.place.vo.LocationRefVo(new Integer(bean.getHospital().getId()), bean.getHospital().getVersion());
		this.tci = bean.getTCI() == null ? null : bean.getTCI().buildDate();
		this.specialty = bean.getSpecialty() == null ? null : ims.core.vo.lookups.Specialty.buildLookup(bean.getSpecialty());
		this.tcidateonly = bean.getTCIDateOnly();
		this.idtype = bean.getIDType() == null ? null : ims.core.vo.lookups.PatIdType.buildLookup(bean.getIDType());
		this.electiveadmissiontype = bean.getElectiveAdmissionType() == null ? null : ims.RefMan.vo.lookups.ElectiveAdmissionType.buildLookup(bean.getElectiveAdmissionType());
	}
	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.PendingElectiveAdmissionListFilterVoBean bean = null;
		if(map != null)
			bean = (ims.core.vo.beans.PendingElectiveAdmissionListFilterVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.core.vo.beans.PendingElectiveAdmissionListFilterVoBean();
			map.addValueObjectBean(this, bean);
			bean.populate(map, this);
		}
		return bean;
	}
	public boolean getTCIIsNotNull()
	{
		return this.tci != null;
	}
	public ims.framework.utils.Date getTCI()
	{
		return this.tci;
	}
	public void setTCI(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.tci = value;
	}
	public boolean getSpecialtyIsNotNull()
	{
		return this.specialty != null;
	}
	public ims.core.vo.lookups.Specialty getSpecialty()
	{
		return this.specialty;
	}
	public void setSpecialty(ims.core.vo.lookups.Specialty value)
	{
		this.isValidated = false;
		this.specialty = value;
	}
	public boolean getTCIDateOnlyIsNotNull()
	{
		return this.tcidateonly != null;
	}
	public Boolean getTCIDateOnly()
	{
		return this.tcidateonly;
	}
	public void setTCIDateOnly(Boolean value)
	{
		this.isValidated = false;
		this.tcidateonly = value;
	}
	public boolean getIDTypeIsNotNull()
	{
		return this.idtype != null;
	}
	public ims.core.vo.lookups.PatIdType getIDType()
	{
		return this.idtype;
	}
	public void setIDType(ims.core.vo.lookups.PatIdType value)
	{
		this.isValidated = false;
		this.idtype = value;
	}
	public boolean getElectiveAdmissionTypeIsNotNull()
	{
		return this.electiveadmissiontype != null;
	}
	public ims.RefMan.vo.lookups.ElectiveAdmissionType getElectiveAdmissionType()
	{
		return this.electiveadmissiontype;
	}
	public void setElectiveAdmissionType(ims.RefMan.vo.lookups.ElectiveAdmissionType value)
	{
		this.isValidated = false;
		this.electiveadmissiontype = value;
	}
	public boolean equals(Object obj)
	{
		if(obj == null)
			return false;
		if(!(obj instanceof PendingElectiveAdmissionListFilterVo))
			return false;
		PendingElectiveAdmissionListFilterVo compareObj = (PendingElectiveAdmissionListFilterVo)obj;
		if(this.getWard() == null && compareObj.getWard() != null)
			return false;
		if(this.getWard() != null && compareObj.getWard() == null)
			return false;
		if(this.getWard() != null && compareObj.getWard() != null)
			return this.getWard().equals(compareObj.getWard());
		return super.equals(obj);
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.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]);
			}
		}
		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;
	
		PendingElectiveAdmissionListFilterVo clone = new PendingElectiveAdmissionListFilterVo();
		
		clone.surname = this.surname;
		clone.forename = this.forename;
		clone.hospnum = this.hospnum;
		clone.ward = this.ward;
		clone.consultant = this.consultant;
		if(this.alert == null)
			clone.alert = null;
		else
			clone.alert = (ims.core.vo.lookups.AlertType)this.alert.clone();
		clone.hospital = this.hospital;
		if(this.tci == null)
			clone.tci = null;
		else
			clone.tci = (ims.framework.utils.Date)this.tci.clone();
		if(this.specialty == null)
			clone.specialty = null;
		else
			clone.specialty = (ims.core.vo.lookups.Specialty)this.specialty.clone();
		clone.tcidateonly = this.tcidateonly;
		if(this.idtype == null)
			clone.idtype = null;
		else
			clone.idtype = (ims.core.vo.lookups.PatIdType)this.idtype.clone();
		if(this.electiveadmissiontype == null)
			clone.electiveadmissiontype = null;
		else
			clone.electiveadmissiontype = (ims.RefMan.vo.lookups.ElectiveAdmissionType)this.electiveadmissiontype.clone();
		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 (!(PendingElectiveAdmissionListFilterVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A PendingElectiveAdmissionListFilterVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		PendingElectiveAdmissionListFilterVo compareObj = (PendingElectiveAdmissionListFilterVo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getConsultant() == null && compareObj.getConsultant() != null)
				return -1;
			if(this.getConsultant() != null && compareObj.getConsultant() == null)
				return 1;
			if(this.getConsultant() != null && compareObj.getConsultant() != null)
				retVal = this.getConsultant().compareTo(compareObj.getConsultant());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = super.countFieldsWithValue();
		if(this.tci != null)
			count++;
		if(this.specialty != null)
			count++;
		if(this.tcidateonly != null)
			count++;
		if(this.idtype != null)
			count++;
		if(this.electiveadmissiontype != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return super.countValueObjectFields() + 5;
	}
	protected ims.framework.utils.Date tci;
	protected ims.core.vo.lookups.Specialty specialty;
	protected Boolean tcidateonly;
	protected ims.core.vo.lookups.PatIdType idtype;
	protected ims.RefMan.vo.lookups.ElectiveAdmissionType electiveadmissiontype;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
