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

	public PatientDetailsComponentVo()
	{
	}
	public PatientDetailsComponentVo(ims.core.vo.beans.PatientDetailsComponentVoBean bean)
	{
		this.title = bean.getTitle() == null ? null : ims.core.vo.lookups.PersonTitle.buildLookup(bean.getTitle());
		this.forename = bean.getForename();
		this.middlename = bean.getMiddleName();
		this.surname = bean.getSurname();
		this.sex = bean.getSex() == null ? null : ims.core.vo.lookups.Sex.buildLookup(bean.getSex());
		this.dob = bean.getDob() == null ? null : bean.getDob().buildPartialDate();
		this.dod = bean.getDod() == null ? null : bean.getDod().buildDate();
		this.maritalstatus = bean.getMaritalStatus() == null ? null : ims.core.vo.lookups.MaritalStatus.buildLookup(bean.getMaritalStatus());
		this.occupation = bean.getOccupation() == null ? null : ims.core.vo.lookups.Occupation.buildLookup(bean.getOccupation());
		this.religion = bean.getReligion() == null ? null : ims.core.vo.lookups.Religion.buildLookup(bean.getReligion());
		this.ethnicorigin = bean.getEthnicOrigin() == null ? null : ims.core.vo.lookups.EthnicOrigin.buildLookup(bean.getEthnicOrigin());
		this.timeofdeath = bean.getTimeOfDeath() == null ? null : bean.getTimeOfDeath().buildTime();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.PatientDetailsComponentVoBean bean)
	{
		this.title = bean.getTitle() == null ? null : ims.core.vo.lookups.PersonTitle.buildLookup(bean.getTitle());
		this.forename = bean.getForename();
		this.middlename = bean.getMiddleName();
		this.surname = bean.getSurname();
		this.sex = bean.getSex() == null ? null : ims.core.vo.lookups.Sex.buildLookup(bean.getSex());
		this.dob = bean.getDob() == null ? null : bean.getDob().buildPartialDate();
		this.dod = bean.getDod() == null ? null : bean.getDod().buildDate();
		this.maritalstatus = bean.getMaritalStatus() == null ? null : ims.core.vo.lookups.MaritalStatus.buildLookup(bean.getMaritalStatus());
		this.occupation = bean.getOccupation() == null ? null : ims.core.vo.lookups.Occupation.buildLookup(bean.getOccupation());
		this.religion = bean.getReligion() == null ? null : ims.core.vo.lookups.Religion.buildLookup(bean.getReligion());
		this.ethnicorigin = bean.getEthnicOrigin() == null ? null : ims.core.vo.lookups.EthnicOrigin.buildLookup(bean.getEthnicOrigin());
		this.timeofdeath = bean.getTimeOfDeath() == null ? null : bean.getTimeOfDeath().buildTime();
	}
	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.PatientDetailsComponentVoBean bean = null;
		if(map != null)
			bean = (ims.core.vo.beans.PatientDetailsComponentVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.core.vo.beans.PatientDetailsComponentVoBean();
			map.addValueObjectBean(this, bean);
			bean.populate(map, this);
		}
		return bean;
	}
	public boolean getTitleIsNotNull()
	{
		return this.title != null;
	}
	public ims.core.vo.lookups.PersonTitle getTitle()
	{
		return this.title;
	}
	public void setTitle(ims.core.vo.lookups.PersonTitle value)
	{
		this.isValidated = false;
		this.title = value;
	}
	public boolean getForenameIsNotNull()
	{
		return this.forename != null;
	}
	public String getForename()
	{
		return this.forename;
	}
	public static int getForenameMaxLength()
	{
		return 255;
	}
	public void setForename(String value)
	{
		this.isValidated = false;
		this.forename = value;
	}
	public boolean getMiddleNameIsNotNull()
	{
		return this.middlename != null;
	}
	public String getMiddleName()
	{
		return this.middlename;
	}
	public static int getMiddleNameMaxLength()
	{
		return 255;
	}
	public void setMiddleName(String value)
	{
		this.isValidated = false;
		this.middlename = value;
	}
	public boolean getSurnameIsNotNull()
	{
		return this.surname != null;
	}
	public String getSurname()
	{
		return this.surname;
	}
	public static int getSurnameMaxLength()
	{
		return 255;
	}
	public void setSurname(String value)
	{
		this.isValidated = false;
		this.surname = value;
	}
	public boolean getSexIsNotNull()
	{
		return this.sex != null;
	}
	public ims.core.vo.lookups.Sex getSex()
	{
		return this.sex;
	}
	public void setSex(ims.core.vo.lookups.Sex value)
	{
		this.isValidated = false;
		this.sex = value;
	}
	public boolean getDobIsNotNull()
	{
		return this.dob != null;
	}
	public ims.framework.utils.PartialDate getDob()
	{
		return this.dob;
	}
	public void setDob(ims.framework.utils.PartialDate value)
	{
		this.isValidated = false;
		this.dob = value;
	}
	public boolean getDodIsNotNull()
	{
		return this.dod != null;
	}
	public ims.framework.utils.Date getDod()
	{
		return this.dod;
	}
	public void setDod(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.dod = value;
	}
	public boolean getMaritalStatusIsNotNull()
	{
		return this.maritalstatus != null;
	}
	public ims.core.vo.lookups.MaritalStatus getMaritalStatus()
	{
		return this.maritalstatus;
	}
	public void setMaritalStatus(ims.core.vo.lookups.MaritalStatus value)
	{
		this.isValidated = false;
		this.maritalstatus = value;
	}
	public boolean getOccupationIsNotNull()
	{
		return this.occupation != null;
	}
	public ims.core.vo.lookups.Occupation getOccupation()
	{
		return this.occupation;
	}
	public void setOccupation(ims.core.vo.lookups.Occupation value)
	{
		this.isValidated = false;
		this.occupation = value;
	}
	public boolean getReligionIsNotNull()
	{
		return this.religion != null;
	}
	public ims.core.vo.lookups.Religion getReligion()
	{
		return this.religion;
	}
	public void setReligion(ims.core.vo.lookups.Religion value)
	{
		this.isValidated = false;
		this.religion = value;
	}
	public boolean getEthnicOriginIsNotNull()
	{
		return this.ethnicorigin != null;
	}
	public ims.core.vo.lookups.EthnicOrigin getEthnicOrigin()
	{
		return this.ethnicorigin;
	}
	public void setEthnicOrigin(ims.core.vo.lookups.EthnicOrigin value)
	{
		this.isValidated = false;
		this.ethnicorigin = value;
	}
	public boolean getTimeOfDeathIsNotNull()
	{
		return this.timeofdeath != null;
	}
	public ims.framework.utils.Time getTimeOfDeath()
	{
		return this.timeofdeath;
	}
	public void setTimeOfDeath(ims.framework.utils.Time value)
	{
		this.isValidated = false;
		this.timeofdeath = 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 PatientDetailsComponentVo))
			return false;
		PatientDetailsComponentVo compareObj = (PatientDetailsComponentVo)obj;
		if(this.getForename() == null && compareObj.getForename() != null)
			return false;
		if(this.getForename() != null && compareObj.getForename() == null)
			return false;
		if(this.getForename() != null && compareObj.getForename() != null)
			if(!this.getForename().equals(compareObj.getForename()))
				return false;
		if(this.getMiddleName() == null && compareObj.getMiddleName() != null)
			return false;
		if(this.getMiddleName() != null && compareObj.getMiddleName() == null)
			return false;
		if(this.getMiddleName() != null && compareObj.getMiddleName() != null)
			if(!this.getMiddleName().equals(compareObj.getMiddleName()))
				return false;
		if(this.getSurname() == null && compareObj.getSurname() != null)
			return false;
		if(this.getSurname() != null && compareObj.getSurname() == null)
			return false;
		if(this.getSurname() != null && compareObj.getSurname() != null)
			return this.getSurname().equals(compareObj.getSurname());
		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;
	
		PatientDetailsComponentVo clone = new PatientDetailsComponentVo();
		
		if(this.title == null)
			clone.title = null;
		else
			clone.title = (ims.core.vo.lookups.PersonTitle)this.title.clone();
		clone.forename = this.forename;
		clone.middlename = this.middlename;
		clone.surname = this.surname;
		if(this.sex == null)
			clone.sex = null;
		else
			clone.sex = (ims.core.vo.lookups.Sex)this.sex.clone();
		if(this.dob == null)
			clone.dob = null;
		else
			clone.dob = (ims.framework.utils.PartialDate)this.dob.clone();
		if(this.dod == null)
			clone.dod = null;
		else
			clone.dod = (ims.framework.utils.Date)this.dod.clone();
		if(this.maritalstatus == null)
			clone.maritalstatus = null;
		else
			clone.maritalstatus = (ims.core.vo.lookups.MaritalStatus)this.maritalstatus.clone();
		if(this.occupation == null)
			clone.occupation = null;
		else
			clone.occupation = (ims.core.vo.lookups.Occupation)this.occupation.clone();
		if(this.religion == null)
			clone.religion = null;
		else
			clone.religion = (ims.core.vo.lookups.Religion)this.religion.clone();
		if(this.ethnicorigin == null)
			clone.ethnicorigin = null;
		else
			clone.ethnicorigin = (ims.core.vo.lookups.EthnicOrigin)this.ethnicorigin.clone();
		if(this.timeofdeath == null)
			clone.timeofdeath = null;
		else
			clone.timeofdeath = (ims.framework.utils.Time)this.timeofdeath.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 (!(PatientDetailsComponentVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A PatientDetailsComponentVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		PatientDetailsComponentVo compareObj = (PatientDetailsComponentVo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getSurname() == null && compareObj.getSurname() != null)
				return -1;
			if(this.getSurname() != null && compareObj.getSurname() == null)
				return 1;
			if(this.getSurname() != null && compareObj.getSurname() != null)
			{
				if(caseInsensitive)
					retVal = this.getSurname().toLowerCase().compareTo(compareObj.getSurname().toLowerCase());
				else
					retVal = this.getSurname().compareTo(compareObj.getSurname());
			}
		}
		if (retVal == 0)
		{
			if(this.getForename() == null && compareObj.getForename() != null)
				return -1;
			if(this.getForename() != null && compareObj.getForename() == null)
				return 1;
			if(this.getForename() != null && compareObj.getForename() != null)
			{
				if(caseInsensitive)
					retVal = this.getForename().toLowerCase().compareTo(compareObj.getForename().toLowerCase());
				else
					retVal = this.getForename().compareTo(compareObj.getForename());
			}
		}
		if (retVal == 0)
		{
			if(this.getMiddleName() == null && compareObj.getMiddleName() != null)
				return -1;
			if(this.getMiddleName() != null && compareObj.getMiddleName() == null)
				return 1;
			if(this.getMiddleName() != null && compareObj.getMiddleName() != null)
			{
				if(caseInsensitive)
					retVal = this.getMiddleName().toLowerCase().compareTo(compareObj.getMiddleName().toLowerCase());
				else
					retVal = this.getMiddleName().compareTo(compareObj.getMiddleName());
			}
		}
		if (retVal == 0)
		{
			if(this.getDob() == null && compareObj.getDob() != null)
				return -1;
			if(this.getDob() != null && compareObj.getDob() == null)
				return 1;
			if(this.getDob() != null && compareObj.getDob() != null)
				retVal = this.getDob().compareTo(compareObj.getDob());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.title != null)
			count++;
		if(this.forename != null)
			count++;
		if(this.middlename != null)
			count++;
		if(this.surname != null)
			count++;
		if(this.sex != null)
			count++;
		if(this.dob != null)
			count++;
		if(this.dod != null)
			count++;
		if(this.maritalstatus != null)
			count++;
		if(this.occupation != null)
			count++;
		if(this.religion != null)
			count++;
		if(this.ethnicorigin != null)
			count++;
		if(this.timeofdeath != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 12;
	}
	protected ims.core.vo.lookups.PersonTitle title;
	protected String forename;
	protected String middlename;
	protected String surname;
	protected ims.core.vo.lookups.Sex sex;
	protected ims.framework.utils.PartialDate dob;
	protected ims.framework.utils.Date dod;
	protected ims.core.vo.lookups.MaritalStatus maritalstatus;
	protected ims.core.vo.lookups.Occupation occupation;
	protected ims.core.vo.lookups.Religion religion;
	protected ims.core.vo.lookups.EthnicOrigin ethnicorigin;
	protected ims.framework.utils.Time timeofdeath;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
