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

	public ClientVo()
	{
	}
	public ClientVo(Integer id, int version)
	{
		super(id, version);
	}
	public ClientVo(ims.pci.vo.beans.ClientVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.name = bean.getName() == null ? null : bean.getName().buildVo();
		this.sex = bean.getSex() == null ? null : ims.core.vo.lookups.Sex.buildLookup(bean.getSex());
		this.age = bean.getAge();
		this.agetext = bean.getAgeText();
		this.address = bean.getAddress() == null ? null : bean.getAddress().buildVo();
		this.dob = bean.getDob() == null ? null : bean.getDob().buildPartialDate();
		this.dod = bean.getDod() == null ? null : bean.getDod().buildDate();
		this.ward = bean.getWard() == null ? null : bean.getWard().buildVo();
		this.religion = bean.getReligion() == null ? null : ims.core.vo.lookups.Religion.buildLookup(bean.getReligion());
		this.hasallergies = bean.getHasAllergies();
		this.hasalerts = bean.getHasAlerts();
		this.identifiers = ims.core.vo.PatientIdCollection.buildFromBeanCollection(bean.getIdentifiers());
		this.isactive = bean.getIsActive();
		this.associatedpatient = bean.getAssociatedPatient() == null ? null : bean.getAssociatedPatient().buildVo();
		this.commchannels = ims.core.vo.CommChannelVoCollection.buildFromBeanCollection(bean.getCommChannels());
		this.ethnicorigin = bean.getEthnicOrigin() == null ? null : ims.core.vo.lookups.EthnicOrigin.buildLookup(bean.getEthnicOrigin());
		this.maritalstatus = bean.getMaritalStatus() == null ? null : ims.core.vo.lookups.MaritalStatus.buildLookup(bean.getMaritalStatus());
		this.scn = bean.getSCN();
		this.sourceofinformation = bean.getSourceOfInformation() == null ? null : ims.core.vo.lookups.RegistrationSourceOfInfo.buildLookup(bean.getSourceOfInformation());
		this.sysinfo = bean.getSysInfo() == null ? null : bean.getSysInfo().buildSystemInformation();
		this.hasactivealerts = bean.getHasActiveAlerts();
		this.timeofdeath = bean.getTimeOfDeath() == null ? null : bean.getTimeOfDeath().buildTime();
		this.isquickregistrationpatient = bean.getIsQuickRegistrationPatient();
		this.ocsnotification = bean.getOCSNotification() == null ? null : bean.getOCSNotification().buildVo();
		this.currentresponsibleconsultant = bean.getCurrentResponsibleConsultant() == null ? null : new ims.core.resource.people.vo.MedicRefVo(new Integer(bean.getCurrentResponsibleConsultant().getId()), bean.getCurrentResponsibleConsultant().getVersion());
		this.dementiabreachdatetime = bean.getDementiaBreachDateTime() == null ? null : bean.getDementiaBreachDateTime().buildDateTime();
		this.dementiaworkliststatus = bean.getDementiaWorklistStatus() == null ? null : ims.core.vo.lookups.DementiaWorklistStatus.buildLookup(bean.getDementiaWorklistStatus());
		this.mrnstatus = bean.getMRNStatus() == null ? null : ims.core.vo.lookups.MRNStatus.buildLookup(bean.getMRNStatus());
		this.hasscannedcasenotefolders = bean.getHasScannedCaseNoteFolders();
		this.isconfidential = bean.getIsConfidential();
		this.timeofbirth = bean.getTimeOfBirth() == null ? null : bean.getTimeOfBirth().buildTime();
		this.isselfadmitpatient = bean.getIsSelfAdmitPatient();
		this.patientcategory = bean.getPatientCategory() == null ? null : ims.core.vo.lookups.PatientStatus.buildLookup(bean.getPatientCategory());
		this.pdspatientgp = bean.getPDSPatientGP() == null ? null : bean.getPDSPatientGP().buildVo();
		this.hasalertcategory1 = bean.getHasAlertCategory1();
		this.hasalertcategory2 = bean.getHasAlertCategory2();
		this.hasalertcategory3 = bean.getHasAlertCategory3();
		this.hasalertcategory4 = bean.getHasAlertCategory4();
		this.hasalertcategoryother = bean.getHasAlertCategoryOther();
		this.futureapptscancelonmarkdeceasedanswer = bean.getFutureApptsCancelOnMarkDeceasedAnswer();
		this.ischild = bean.getIsChild();
		this.nationality = bean.getNationality() == null ? null : ims.core.vo.lookups.Nationality.buildLookup(bean.getNationality());
		this.dodsource = bean.getDodSource() == null ? null : ims.core.vo.lookups.DodSource.buildLookup(bean.getDodSource());
		this.addresses = ims.core.vo.PersonAddressCollection.buildFromBeanCollection(bean.getAddresses());
		this.gp = bean.getGp() == null ? null : bean.getGp().buildVo();
		this.gpsurgery = bean.getGpSurgery() == null ? null : new ims.core.resource.place.vo.LocSiteRefVo(new Integer(bean.getGpSurgery().getId()), bean.getGpSurgery().getVersion());
		this.clientparent = bean.getClientParent() == null ? null : new ims.core.patient.vo.PatientRefVo(new Integer(bean.getClientParent().getId()), bean.getClientParent().getVersion());
		this.communitycare = bean.getCommunityCare() == null ? null : bean.getCommunityCare().buildVo();
		this.othernames = ims.core.vo.PersonNameCollection.buildFromBeanCollection(bean.getOtherNames());
		this.confidentialreason = bean.getConfidentialReason() == null ? null : ims.core.vo.lookups.ConfidentialReason.buildLookup(bean.getConfidentialReason());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.pci.vo.beans.ClientVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.name = bean.getName() == null ? null : bean.getName().buildVo(map);
		this.sex = bean.getSex() == null ? null : ims.core.vo.lookups.Sex.buildLookup(bean.getSex());
		this.age = bean.getAge();
		this.agetext = bean.getAgeText();
		this.address = bean.getAddress() == null ? null : bean.getAddress().buildVo(map);
		this.dob = bean.getDob() == null ? null : bean.getDob().buildPartialDate();
		this.dod = bean.getDod() == null ? null : bean.getDod().buildDate();
		this.ward = bean.getWard() == null ? null : bean.getWard().buildVo(map);
		this.religion = bean.getReligion() == null ? null : ims.core.vo.lookups.Religion.buildLookup(bean.getReligion());
		this.hasallergies = bean.getHasAllergies();
		this.hasalerts = bean.getHasAlerts();
		this.identifiers = ims.core.vo.PatientIdCollection.buildFromBeanCollection(bean.getIdentifiers());
		this.isactive = bean.getIsActive();
		this.associatedpatient = bean.getAssociatedPatient() == null ? null : bean.getAssociatedPatient().buildVo(map);
		this.commchannels = ims.core.vo.CommChannelVoCollection.buildFromBeanCollection(bean.getCommChannels());
		this.ethnicorigin = bean.getEthnicOrigin() == null ? null : ims.core.vo.lookups.EthnicOrigin.buildLookup(bean.getEthnicOrigin());
		this.maritalstatus = bean.getMaritalStatus() == null ? null : ims.core.vo.lookups.MaritalStatus.buildLookup(bean.getMaritalStatus());
		this.scn = bean.getSCN();
		this.sourceofinformation = bean.getSourceOfInformation() == null ? null : ims.core.vo.lookups.RegistrationSourceOfInfo.buildLookup(bean.getSourceOfInformation());
		this.sysinfo = bean.getSysInfo() == null ? null : bean.getSysInfo().buildSystemInformation();
		this.hasactivealerts = bean.getHasActiveAlerts();
		this.timeofdeath = bean.getTimeOfDeath() == null ? null : bean.getTimeOfDeath().buildTime();
		this.isquickregistrationpatient = bean.getIsQuickRegistrationPatient();
		this.ocsnotification = bean.getOCSNotification() == null ? null : bean.getOCSNotification().buildVo(map);
		this.currentresponsibleconsultant = bean.getCurrentResponsibleConsultant() == null ? null : new ims.core.resource.people.vo.MedicRefVo(new Integer(bean.getCurrentResponsibleConsultant().getId()), bean.getCurrentResponsibleConsultant().getVersion());
		this.dementiabreachdatetime = bean.getDementiaBreachDateTime() == null ? null : bean.getDementiaBreachDateTime().buildDateTime();
		this.dementiaworkliststatus = bean.getDementiaWorklistStatus() == null ? null : ims.core.vo.lookups.DementiaWorklistStatus.buildLookup(bean.getDementiaWorklistStatus());
		this.mrnstatus = bean.getMRNStatus() == null ? null : ims.core.vo.lookups.MRNStatus.buildLookup(bean.getMRNStatus());
		this.hasscannedcasenotefolders = bean.getHasScannedCaseNoteFolders();
		this.isconfidential = bean.getIsConfidential();
		this.timeofbirth = bean.getTimeOfBirth() == null ? null : bean.getTimeOfBirth().buildTime();
		this.isselfadmitpatient = bean.getIsSelfAdmitPatient();
		this.patientcategory = bean.getPatientCategory() == null ? null : ims.core.vo.lookups.PatientStatus.buildLookup(bean.getPatientCategory());
		this.pdspatientgp = bean.getPDSPatientGP() == null ? null : bean.getPDSPatientGP().buildVo(map);
		this.hasalertcategory1 = bean.getHasAlertCategory1();
		this.hasalertcategory2 = bean.getHasAlertCategory2();
		this.hasalertcategory3 = bean.getHasAlertCategory3();
		this.hasalertcategory4 = bean.getHasAlertCategory4();
		this.hasalertcategoryother = bean.getHasAlertCategoryOther();
		this.futureapptscancelonmarkdeceasedanswer = bean.getFutureApptsCancelOnMarkDeceasedAnswer();
		this.ischild = bean.getIsChild();
		this.nationality = bean.getNationality() == null ? null : ims.core.vo.lookups.Nationality.buildLookup(bean.getNationality());
		this.dodsource = bean.getDodSource() == null ? null : ims.core.vo.lookups.DodSource.buildLookup(bean.getDodSource());
		this.addresses = ims.core.vo.PersonAddressCollection.buildFromBeanCollection(bean.getAddresses());
		this.gp = bean.getGp() == null ? null : bean.getGp().buildVo(map);
		this.gpsurgery = bean.getGpSurgery() == null ? null : new ims.core.resource.place.vo.LocSiteRefVo(new Integer(bean.getGpSurgery().getId()), bean.getGpSurgery().getVersion());
		this.clientparent = bean.getClientParent() == null ? null : new ims.core.patient.vo.PatientRefVo(new Integer(bean.getClientParent().getId()), bean.getClientParent().getVersion());
		this.communitycare = bean.getCommunityCare() == null ? null : bean.getCommunityCare().buildVo(map);
		this.othernames = ims.core.vo.PersonNameCollection.buildFromBeanCollection(bean.getOtherNames());
		this.confidentialreason = bean.getConfidentialReason() == null ? null : ims.core.vo.lookups.ConfidentialReason.buildLookup(bean.getConfidentialReason());
	}
	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.ClientVoBean bean = null;
		if(map != null)
			bean = (ims.pci.vo.beans.ClientVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.pci.vo.beans.ClientVoBean();
			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("ADDRESSES"))
			return getAddresses();
		if(fieldName.equals("GP"))
			return getGp();
		if(fieldName.equals("GPSURGERY"))
			return getGpSurgery();
		if(fieldName.equals("CLIENTPARENT"))
			return getClientParent();
		if(fieldName.equals("COMMUNITYCARE"))
			return getCommunityCare();
		if(fieldName.equals("OTHERNAMES"))
			return getOtherNames();
		if(fieldName.equals("CONFIDENTIALREASON"))
			return getConfidentialReason();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getAddressesIsNotNull()
	{
		return this.addresses != null;
	}
	public ims.core.vo.PersonAddressCollection getAddresses()
	{
		return this.addresses;
	}
	public void setAddresses(ims.core.vo.PersonAddressCollection value)
	{
		this.isValidated = false;
		this.addresses = value;
	}
	public boolean getGpIsNotNull()
	{
		return this.gp != null;
	}
	public ims.core.vo.GpShortVo getGp()
	{
		return this.gp;
	}
	public void setGp(ims.core.vo.GpShortVo value)
	{
		this.isValidated = false;
		this.gp = value;
	}
	public boolean getGpSurgeryIsNotNull()
	{
		return this.gpsurgery != null;
	}
	public ims.core.resource.place.vo.LocSiteRefVo getGpSurgery()
	{
		return this.gpsurgery;
	}
	public void setGpSurgery(ims.core.resource.place.vo.LocSiteRefVo value)
	{
		this.isValidated = false;
		this.gpsurgery = value;
	}
	public boolean getClientParentIsNotNull()
	{
		return this.clientparent != null;
	}
	public ims.core.patient.vo.PatientRefVo getClientParent()
	{
		return this.clientparent;
	}
	public void setClientParent(ims.core.patient.vo.PatientRefVo value)
	{
		this.isValidated = false;
		this.clientparent = value;
	}
	public boolean getCommunityCareIsNotNull()
	{
		return this.communitycare != null;
	}
	public ims.pci.vo.CommunityCareVo getCommunityCare()
	{
		return this.communitycare;
	}
	public void setCommunityCare(ims.pci.vo.CommunityCareVo value)
	{
		this.isValidated = false;
		this.communitycare = value;
	}
	public boolean getOtherNamesIsNotNull()
	{
		return this.othernames != null;
	}
	public ims.core.vo.PersonNameCollection getOtherNames()
	{
		return this.othernames;
	}
	public void setOtherNames(ims.core.vo.PersonNameCollection value)
	{
		this.isValidated = false;
		this.othernames = value;
	}
	public boolean getConfidentialReasonIsNotNull()
	{
		return this.confidentialreason != null;
	}
	public ims.core.vo.lookups.ConfidentialReason getConfidentialReason()
	{
		return this.confidentialreason;
	}
	public void setConfidentialReason(ims.core.vo.lookups.ConfidentialReason value)
	{
		this.isValidated = false;
		this.confidentialreason = value;
	}
	/**
	* validateCustomRulesPCI() - used to validate the registration date (extend for other custom validations)
	*/
	public String[] validateCustomRulesPCI()
	{
		return validateCustomRulesPCI(null);
	}
	
	/**
	* validateCustomRulesPCI(String[] existingErrors) - used to validate PCI custom rules (registred date - extend for other custom validation rules)
	*/
	public String[] validateCustomRulesPCI(String[] existingErrors)
	{
		existingErrors = this.validate(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.communitycare != null)
		{
			if (this.communitycare.registeredgp != null)
			{
				if (this.communitycare.gpregistrationdate == null)
				{
					listOfErrors.add("Date Registred is mandatory");
				}
			}
		}
	
	
		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 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.ward != null)
		{
			if(!this.ward.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.identifiers != null)
		{
			if(!this.identifiers.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.associatedpatient != null)
		{
			if(!this.associatedpatient.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.commchannels != null)
		{
			if(!this.commchannels.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.pdspatientgp != null)
		{
			if(!this.pdspatientgp.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.addresses != null)
		{
			if(!this.addresses.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.gp != null)
		{
			if(!this.gp.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.communitycare != null)
		{
			if(!this.communitycare.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.othernames != null)
		{
			if(!this.othernames.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.ward != null)
		{
			String[] listOfOtherErrors = this.ward.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.identifiers != null)
		{
			String[] listOfOtherErrors = this.identifiers.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.associatedpatient != null)
		{
			String[] listOfOtherErrors = this.associatedpatient.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.commchannels != null)
		{
			String[] listOfOtherErrors = this.commchannels.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.pdspatientgp != null)
		{
			String[] listOfOtherErrors = this.pdspatientgp.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.addresses != null)
		{
			String[] listOfOtherErrors = this.addresses.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]);
				}
			}
		}
		if(this.communitycare != null)
		{
			String[] listOfOtherErrors = this.communitycare.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.othernames != null)
		{
			String[] listOfOtherErrors = this.othernames.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;
	
		ClientVo clone = new ClientVo(this.id, this.version);
		
		if(this.name == null)
			clone.name = null;
		else
			clone.name = (ims.core.vo.PersonName)this.name.clone();
		if(this.sex == null)
			clone.sex = null;
		else
			clone.sex = (ims.core.vo.lookups.Sex)this.sex.clone();
		clone.age = this.age;
		clone.agetext = this.agetext;
		if(this.address == null)
			clone.address = null;
		else
			clone.address = (ims.core.vo.PersonAddress)this.address.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.ward == null)
			clone.ward = null;
		else
			clone.ward = (ims.core.vo.LocationLiteVo)this.ward.clone();
		if(this.religion == null)
			clone.religion = null;
		else
			clone.religion = (ims.core.vo.lookups.Religion)this.religion.clone();
		clone.hasallergies = this.hasallergies;
		clone.hasalerts = this.hasalerts;
		if(this.identifiers == null)
			clone.identifiers = null;
		else
			clone.identifiers = (ims.core.vo.PatientIdCollection)this.identifiers.clone();
		clone.isactive = this.isactive;
		if(this.associatedpatient == null)
			clone.associatedpatient = null;
		else
			clone.associatedpatient = (ims.core.vo.PatientShort)this.associatedpatient.clone();
		if(this.commchannels == null)
			clone.commchannels = null;
		else
			clone.commchannels = (ims.core.vo.CommChannelVoCollection)this.commchannels.clone();
		if(this.ethnicorigin == null)
			clone.ethnicorigin = null;
		else
			clone.ethnicorigin = (ims.core.vo.lookups.EthnicOrigin)this.ethnicorigin.clone();
		if(this.maritalstatus == null)
			clone.maritalstatus = null;
		else
			clone.maritalstatus = (ims.core.vo.lookups.MaritalStatus)this.maritalstatus.clone();
		clone.scn = this.scn;
		if(this.sourceofinformation == null)
			clone.sourceofinformation = null;
		else
			clone.sourceofinformation = (ims.core.vo.lookups.RegistrationSourceOfInfo)this.sourceofinformation.clone();
		if(this.sysinfo == null)
			clone.sysinfo = null;
		else
			clone.sysinfo = (ims.vo.SystemInformation)this.sysinfo.clone();
		clone.hasactivealerts = this.hasactivealerts;
		if(this.timeofdeath == null)
			clone.timeofdeath = null;
		else
			clone.timeofdeath = (ims.framework.utils.Time)this.timeofdeath.clone();
		clone.isquickregistrationpatient = this.isquickregistrationpatient;
		if(this.ocsnotification == null)
			clone.ocsnotification = null;
		else
			clone.ocsnotification = (ims.core.vo.PatientNotificationsFillerOnlyVo)this.ocsnotification.clone();
		clone.currentresponsibleconsultant = this.currentresponsibleconsultant;
		if(this.dementiabreachdatetime == null)
			clone.dementiabreachdatetime = null;
		else
			clone.dementiabreachdatetime = (ims.framework.utils.DateTime)this.dementiabreachdatetime.clone();
		if(this.dementiaworkliststatus == null)
			clone.dementiaworkliststatus = null;
		else
			clone.dementiaworkliststatus = (ims.core.vo.lookups.DementiaWorklistStatus)this.dementiaworkliststatus.clone();
		if(this.mrnstatus == null)
			clone.mrnstatus = null;
		else
			clone.mrnstatus = (ims.core.vo.lookups.MRNStatus)this.mrnstatus.clone();
		clone.hasscannedcasenotefolders = this.hasscannedcasenotefolders;
		clone.isconfidential = this.isconfidential;
		if(this.timeofbirth == null)
			clone.timeofbirth = null;
		else
			clone.timeofbirth = (ims.framework.utils.Time)this.timeofbirth.clone();
		clone.isselfadmitpatient = this.isselfadmitpatient;
		if(this.patientcategory == null)
			clone.patientcategory = null;
		else
			clone.patientcategory = (ims.core.vo.lookups.PatientStatus)this.patientcategory.clone();
		if(this.pdspatientgp == null)
			clone.pdspatientgp = null;
		else
			clone.pdspatientgp = (ims.core.vo.PDSPatientGPVo)this.pdspatientgp.clone();
		clone.hasalertcategory1 = this.hasalertcategory1;
		clone.hasalertcategory2 = this.hasalertcategory2;
		clone.hasalertcategory3 = this.hasalertcategory3;
		clone.hasalertcategory4 = this.hasalertcategory4;
		clone.hasalertcategoryother = this.hasalertcategoryother;
		clone.futureapptscancelonmarkdeceasedanswer = this.futureapptscancelonmarkdeceasedanswer;
		clone.ischild = this.ischild;
		if(this.nationality == null)
			clone.nationality = null;
		else
			clone.nationality = (ims.core.vo.lookups.Nationality)this.nationality.clone();
		if(this.dodsource == null)
			clone.dodsource = null;
		else
			clone.dodsource = (ims.core.vo.lookups.DodSource)this.dodsource.clone();
		if(this.addresses == null)
			clone.addresses = null;
		else
			clone.addresses = (ims.core.vo.PersonAddressCollection)this.addresses.clone();
		if(this.gp == null)
			clone.gp = null;
		else
			clone.gp = (ims.core.vo.GpShortVo)this.gp.clone();
		clone.gpsurgery = this.gpsurgery;
		clone.clientparent = this.clientparent;
		if(this.communitycare == null)
			clone.communitycare = null;
		else
			clone.communitycare = (ims.pci.vo.CommunityCareVo)this.communitycare.clone();
		if(this.othernames == null)
			clone.othernames = null;
		else
			clone.othernames = (ims.core.vo.PersonNameCollection)this.othernames.clone();
		if(this.confidentialreason == null)
			clone.confidentialreason = null;
		else
			clone.confidentialreason = (ims.core.vo.lookups.ConfidentialReason)this.confidentialreason.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 (!(ClientVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A ClientVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((ClientVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((ClientVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = super.countFieldsWithValue();
		if(this.addresses != null)
			count++;
		if(this.gp != null)
			count++;
		if(this.gpsurgery != null)
			count++;
		if(this.clientparent != null)
			count++;
		if(this.communitycare != null)
			count++;
		if(this.othernames != null)
			count++;
		if(this.confidentialreason != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return super.countValueObjectFields() + 7;
	}
	protected ims.core.vo.PersonAddressCollection addresses;
	protected ims.core.vo.GpShortVo gp;
	protected ims.core.resource.place.vo.LocSiteRefVo gpsurgery;
	protected ims.core.patient.vo.PatientRefVo clientparent;
	protected ims.pci.vo.CommunityCareVo communitycare;
	protected ims.core.vo.PersonNameCollection othernames;
	protected ims.core.vo.lookups.ConfidentialReason confidentialreason;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
