/FileExtraction/Java_unseen/IMS-MAXIMS_openMAXIMS/Source Library/openmaxims_workspace/ValueObjects/src/ims/pci/vo/ClientLiteVo.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.pci.vo;

/**
 * Linked to core.patient.Patient business object (ID: 1001100000).
 */
public class ClientLiteVo extends ims.core.patient.vo.PatientRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public ClientLiteVo()
	{
	}
	public ClientLiteVo(Integer id, int version)
	{
		super(id, version);
	}
	public ClientLiteVo(ims.pci.vo.beans.ClientLiteVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.name = bean.getName() == null ? null : bean.getName().buildVo();
		this.address = bean.getAddress() == null ? null : bean.getAddress().buildVo();
		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.dodsource = bean.getDodSource() == null ? null : ims.core.vo.lookups.DodSource.buildLookup(bean.getDodSource());
		this.nationality = bean.getNationality() == null ? null : ims.core.vo.lookups.Nationality.buildLookup(bean.getNationality());
		this.ethnicorigin = bean.getEthnicOrigin() == null ? null : ims.core.vo.lookups.EthnicOrigin.buildLookup(bean.getEthnicOrigin());
		this.religion = bean.getReligion() == null ? null : ims.core.vo.lookups.Religion.buildLookup(bean.getReligion());
		this.language = bean.getLanguage() == null ? null : ims.core.vo.lookups.Language.buildLookup(bean.getLanguage());
		this.occupation = bean.getOccupation() == null ? null : ims.core.vo.lookups.Occupation.buildLookup(bean.getOccupation());
		this.maritalstatus = bean.getMaritalStatus() == null ? null : ims.core.vo.lookups.MaritalStatus.buildLookup(bean.getMaritalStatus());
		this.isactive = bean.getIsActive();
		this.isconfidential = bean.getIsConfidential();
		this.sourceofinformation = bean.getSourceOfInformation() == null ? null : ims.core.vo.lookups.RegistrationSourceOfInfo.buildLookup(bean.getSourceOfInformation());
		this.ischild = bean.getIsChild();
		this.gp = bean.getGp() == null ? null : bean.getGp().buildVo();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.pci.vo.beans.ClientLiteVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.name = bean.getName() == null ? null : bean.getName().buildVo(map);
		this.address = bean.getAddress() == null ? null : bean.getAddress().buildVo(map);
		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.dodsource = bean.getDodSource() == null ? null : ims.core.vo.lookups.DodSource.buildLookup(bean.getDodSource());
		this.nationality = bean.getNationality() == null ? null : ims.core.vo.lookups.Nationality.buildLookup(bean.getNationality());
		this.ethnicorigin = bean.getEthnicOrigin() == null ? null : ims.core.vo.lookups.EthnicOrigin.buildLookup(bean.getEthnicOrigin());
		this.religion = bean.getReligion() == null ? null : ims.core.vo.lookups.Religion.buildLookup(bean.getReligion());
		this.language = bean.getLanguage() == null ? null : ims.core.vo.lookups.Language.buildLookup(bean.getLanguage());
		this.occupation = bean.getOccupation() == null ? null : ims.core.vo.lookups.Occupation.buildLookup(bean.getOccupation());
		this.maritalstatus = bean.getMaritalStatus() == null ? null : ims.core.vo.lookups.MaritalStatus.buildLookup(bean.getMaritalStatus());
		this.isactive = bean.getIsActive();
		this.isconfidential = bean.getIsConfidential();
		this.sourceofinformation = bean.getSourceOfInformation() == null ? null : ims.core.vo.lookups.RegistrationSourceOfInfo.buildLookup(bean.getSourceOfInformation());
		this.ischild = bean.getIsChild();
		this.gp = bean.getGp() == null ? null : bean.getGp().buildVo(map);
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.pci.vo.beans.ClientLiteVoBean bean = null;
		if(map != null)
			bean = (ims.pci.vo.beans.ClientLiteVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.pci.vo.beans.ClientLiteVoBean();
			map.addValueObjectBean(this, bean);
			bean.populate(map, this);
		}
		return bean;
	}
	public Object getFieldValueByFieldName(String fieldName)
	{
		if(fieldName == null)
			throw new ims.framework.exceptions.CodingRuntimeException("Invalid field name");
		fieldName = fieldName.toUpperCase();
		if(fieldName.equals("NAME"))
			return getName();
		if(fieldName.equals("ADDRESS"))
			return getAddress();
		if(fieldName.equals("SEX"))
			return getSex();
		if(fieldName.equals("DOB"))
			return getDob();
		if(fieldName.equals("DOD"))
			return getDod();
		if(fieldName.equals("DODSOURCE"))
			return getDodSource();
		if(fieldName.equals("NATIONALITY"))
			return getNationality();
		if(fieldName.equals("ETHNICORIGIN"))
			return getEthnicOrigin();
		if(fieldName.equals("RELIGION"))
			return getReligion();
		if(fieldName.equals("LANGUAGE"))
			return getLanguage();
		if(fieldName.equals("OCCUPATION"))
			return getOccupation();
		if(fieldName.equals("MARITALSTATUS"))
			return getMaritalStatus();
		if(fieldName.equals("ISACTIVE"))
			return getIsActive();
		if(fieldName.equals("ISCONFIDENTIAL"))
			return getIsConfidential();
		if(fieldName.equals("SOURCEOFINFORMATION"))
			return getSourceOfInformation();
		if(fieldName.equals("ISCHILD"))
			return getIsChild();
		if(fieldName.equals("GP"))
			return getGp();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getNameIsNotNull()
	{
		return this.name != null;
	}
	public ims.core.vo.PersonName getName()
	{
		return this.name;
	}
	public void setName(ims.core.vo.PersonName value)
	{
		this.isValidated = false;
		this.name = value;
	}
	public boolean getAddressIsNotNull()
	{
		return this.address != null;
	}
	public ims.core.vo.PersonAddress getAddress()
	{
		return this.address;
	}
	public void setAddress(ims.core.vo.PersonAddress value)
	{
		this.isValidated = false;
		this.address = 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 getDodSourceIsNotNull()
	{
		return this.dodsource != null;
	}
	public ims.core.vo.lookups.DodSource getDodSource()
	{
		return this.dodsource;
	}
	public void setDodSource(ims.core.vo.lookups.DodSource value)
	{
		this.isValidated = false;
		this.dodsource = value;
	}
	public boolean getNationalityIsNotNull()
	{
		return this.nationality != null;
	}
	public ims.core.vo.lookups.Nationality getNationality()
	{
		return this.nationality;
	}
	public void setNationality(ims.core.vo.lookups.Nationality value)
	{
		this.isValidated = false;
		this.nationality = 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 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 getLanguageIsNotNull()
	{
		return this.language != null;
	}
	public ims.core.vo.lookups.Language getLanguage()
	{
		return this.language;
	}
	public void setLanguage(ims.core.vo.lookups.Language value)
	{
		this.isValidated = false;
		this.language = 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 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 getIsActiveIsNotNull()
	{
		return this.isactive != null;
	}
	public Boolean getIsActive()
	{
		return this.isactive;
	}
	public void setIsActive(Boolean value)
	{
		this.isValidated = false;
		this.isactive = value;
	}
	public boolean getIsConfidentialIsNotNull()
	{
		return this.isconfidential != null;
	}
	public Boolean getIsConfidential()
	{
		return this.isconfidential;
	}
	public void setIsConfidential(Boolean value)
	{
		this.isValidated = false;
		this.isconfidential = value;
	}
	public boolean getSourceOfInformationIsNotNull()
	{
		return this.sourceofinformation != null;
	}
	public ims.core.vo.lookups.RegistrationSourceOfInfo getSourceOfInformation()
	{
		return this.sourceofinformation;
	}
	public void setSourceOfInformation(ims.core.vo.lookups.RegistrationSourceOfInfo value)
	{
		this.isValidated = false;
		this.sourceofinformation = value;
	}
	public boolean getIsChildIsNotNull()
	{
		return this.ischild != null;
	}
	public Boolean getIsChild()
	{
		return this.ischild;
	}
	public void setIsChild(Boolean value)
	{
		this.isValidated = false;
		this.ischild = value;
	}
	public boolean getGpIsNotNull()
	{
		return this.gp != null;
	}
	public ims.core.vo.GpLiteWithNameVo getGp()
	{
		return this.gp;
	}
	public void setGp(ims.core.vo.GpLiteWithNameVo value)
	{
		this.isValidated = false;
		this.gp = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.name != null)
		{
			if(!this.name.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.address != null)
		{
			if(!this.address.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.gp != null)
		{
			if(!this.gp.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.name != null)
		{
			String[] listOfOtherErrors = this.name.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.address != null)
		{
			String[] listOfOtherErrors = this.address.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.gp != null)
		{
			String[] listOfOtherErrors = this.gp.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 void clearIDAndVersion()
	{
		this.id = null;
		this.version = 0;
	}
	public Object clone()
	{
		if(this.isBusy)
			return this;
		this.isBusy = true;
	
		ClientLiteVo clone = new ClientLiteVo(this.id, this.version);
		
		if(this.name == null)
			clone.name = null;
		else
			clone.name = (ims.core.vo.PersonName)this.name.clone();
		if(this.address == null)
			clone.address = null;
		else
			clone.address = (ims.core.vo.PersonAddress)this.address.clone();
		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.dodsource == null)
			clone.dodsource = null;
		else
			clone.dodsource = (ims.core.vo.lookups.DodSource)this.dodsource.clone();
		if(this.nationality == null)
			clone.nationality = null;
		else
			clone.nationality = (ims.core.vo.lookups.Nationality)this.nationality.clone();
		if(this.ethnicorigin == null)
			clone.ethnicorigin = null;
		else
			clone.ethnicorigin = (ims.core.vo.lookups.EthnicOrigin)this.ethnicorigin.clone();
		if(this.religion == null)
			clone.religion = null;
		else
			clone.religion = (ims.core.vo.lookups.Religion)this.religion.clone();
		if(this.language == null)
			clone.language = null;
		else
			clone.language = (ims.core.vo.lookups.Language)this.language.clone();
		if(this.occupation == null)
			clone.occupation = null;
		else
			clone.occupation = (ims.core.vo.lookups.Occupation)this.occupation.clone();
		if(this.maritalstatus == null)
			clone.maritalstatus = null;
		else
			clone.maritalstatus = (ims.core.vo.lookups.MaritalStatus)this.maritalstatus.clone();
		clone.isactive = this.isactive;
		clone.isconfidential = this.isconfidential;
		if(this.sourceofinformation == null)
			clone.sourceofinformation = null;
		else
			clone.sourceofinformation = (ims.core.vo.lookups.RegistrationSourceOfInfo)this.sourceofinformation.clone();
		clone.ischild = this.ischild;
		if(this.gp == null)
			clone.gp = null;
		else
			clone.gp = (ims.core.vo.GpLiteWithNameVo)this.gp.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 (!(ClientLiteVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A ClientLiteVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((ClientLiteVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((ClientLiteVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.name != null)
			count++;
		if(this.address != null)
			count++;
		if(this.sex != null)
			count++;
		if(this.dob != null)
			count++;
		if(this.dod != null)
			count++;
		if(this.dodsource != null)
			count++;
		if(this.nationality != null)
			count++;
		if(this.ethnicorigin != null)
			count++;
		if(this.religion != null)
			count++;
		if(this.language != null)
			count++;
		if(this.occupation != null)
			count++;
		if(this.maritalstatus != null)
			count++;
		if(this.isactive != null)
			count++;
		if(this.isconfidential != null)
			count++;
		if(this.sourceofinformation != null)
			count++;
		if(this.ischild != null)
			count++;
		if(this.gp != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 17;
	}
	protected ims.core.vo.PersonName name;
	protected ims.core.vo.PersonAddress address;
	protected ims.core.vo.lookups.Sex sex;
	protected ims.framework.utils.PartialDate dob;
	protected ims.framework.utils.Date dod;
	protected ims.core.vo.lookups.DodSource dodsource;
	protected ims.core.vo.lookups.Nationality nationality;
	protected ims.core.vo.lookups.EthnicOrigin ethnicorigin;
	protected ims.core.vo.lookups.Religion religion;
	protected ims.core.vo.lookups.Language language;
	protected ims.core.vo.lookups.Occupation occupation;
	protected ims.core.vo.lookups.MaritalStatus maritalstatus;
	protected Boolean isactive;
	protected Boolean isconfidential;
	protected ims.core.vo.lookups.RegistrationSourceOfInfo sourceofinformation;
	protected Boolean ischild;
	protected ims.core.vo.GpLiteWithNameVo gp;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
