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

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

	public PatRelative()
	{
	}
	public PatRelative(Integer id, int version)
	{
		super(id, version);
	}
	public PatRelative(ims.core.vo.beans.PatRelativeBean 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.relationship = bean.getRelationship() == null ? null : ims.core.vo.lookups.PersonRelationship.buildLookup(bean.getRelationship());
		this.commchannels = ims.core.vo.CommChannelVoCollection.buildFromBeanCollection(bean.getCommChannels());
		this.pdsupdatemode = bean.getPdsUpdateMode() == null ? null : ims.core.vo.lookups.PDSUpdateMode.buildLookup(bean.getPdsUpdateMode());
		this.objectidentifier = bean.getObjectidentifier();
		this.role = bean.getRole() == null ? null : ims.core.vo.lookups.PDSPersonRole.buildLookup(bean.getRole());
		this.nhsnum = bean.getNhsNum();
		this.contactrank = bean.getContactRank();
		this.nokind = bean.getNokInd();
		this.cpycorresp = bean.getCpyCorresp();
		this.callbckcons = bean.getCallbckCons() == null ? null : ims.core.vo.lookups.PDSConsent.buildLookup(bean.getCallbckCons());
		this.beffdatecnf = bean.getBeffdatecnf();
		this.betdatecnf = bean.getBetdatecnf();
		this.beffdate = bean.getBeffdate() == null ? null : bean.getBeffdate().buildDate();
		this.betdate = bean.getBetdate() == null ? null : bean.getBetdate().buildDate();
		this.dob = bean.getDob() == null ? null : bean.getDob().buildPartialDate();
		this.active = bean.getActive();
		this.pdscontactpreferences = bean.getPDScontactPreferences() == null ? null : bean.getPDScontactPreferences().buildVo();
		this.pdslanguage = bean.getPDSlanguage() == null ? null : ims.core.vo.lookups.PDSPreferredCommunicationLanguage.buildLookup(bean.getPDSlanguage());
		this.pdsinterpreterrequired = bean.getPDSInterpreterRequired();
		this.pending = bean.getPending();
		this.isconfidential = bean.getIsConfidential();
		this.timestamp = bean.getTimestamp();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.PatRelativeBean 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.relationship = bean.getRelationship() == null ? null : ims.core.vo.lookups.PersonRelationship.buildLookup(bean.getRelationship());
		this.commchannels = ims.core.vo.CommChannelVoCollection.buildFromBeanCollection(bean.getCommChannels());
		this.pdsupdatemode = bean.getPdsUpdateMode() == null ? null : ims.core.vo.lookups.PDSUpdateMode.buildLookup(bean.getPdsUpdateMode());
		this.objectidentifier = bean.getObjectidentifier();
		this.role = bean.getRole() == null ? null : ims.core.vo.lookups.PDSPersonRole.buildLookup(bean.getRole());
		this.nhsnum = bean.getNhsNum();
		this.contactrank = bean.getContactRank();
		this.nokind = bean.getNokInd();
		this.cpycorresp = bean.getCpyCorresp();
		this.callbckcons = bean.getCallbckCons() == null ? null : ims.core.vo.lookups.PDSConsent.buildLookup(bean.getCallbckCons());
		this.beffdatecnf = bean.getBeffdatecnf();
		this.betdatecnf = bean.getBetdatecnf();
		this.beffdate = bean.getBeffdate() == null ? null : bean.getBeffdate().buildDate();
		this.betdate = bean.getBetdate() == null ? null : bean.getBetdate().buildDate();
		this.dob = bean.getDob() == null ? null : bean.getDob().buildPartialDate();
		this.active = bean.getActive();
		this.pdscontactpreferences = bean.getPDScontactPreferences() == null ? null : bean.getPDScontactPreferences().buildVo(map);
		this.pdslanguage = bean.getPDSlanguage() == null ? null : ims.core.vo.lookups.PDSPreferredCommunicationLanguage.buildLookup(bean.getPDSlanguage());
		this.pdsinterpreterrequired = bean.getPDSInterpreterRequired();
		this.pending = bean.getPending();
		this.isconfidential = bean.getIsConfidential();
		this.timestamp = bean.getTimestamp();
	}
	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.PatRelativeBean bean = null;
		if(map != null)
			bean = (ims.core.vo.beans.PatRelativeBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.core.vo.beans.PatRelativeBean();
			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("RELATIONSHIP"))
			return getRelationship();
		if(fieldName.equals("COMMCHANNELS"))
			return getCommChannels();
		if(fieldName.equals("PDSUPDATEMODE"))
			return getPdsUpdateMode();
		if(fieldName.equals("OBJECTIDENTIFIER"))
			return getObjectidentifier();
		if(fieldName.equals("ROLE"))
			return getRole();
		if(fieldName.equals("NHSNUM"))
			return getNhsNum();
		if(fieldName.equals("CONTACTRANK"))
			return getContactRank();
		if(fieldName.equals("NOKIND"))
			return getNokInd();
		if(fieldName.equals("CPYCORRESP"))
			return getCpyCorresp();
		if(fieldName.equals("CALLBCKCONS"))
			return getCallbckCons();
		if(fieldName.equals("BEFFDATECNF"))
			return getBeffdatecnf();
		if(fieldName.equals("BETDATECNF"))
			return getBetdatecnf();
		if(fieldName.equals("BEFFDATE"))
			return getBeffdate();
		if(fieldName.equals("BETDATE"))
			return getBetdate();
		if(fieldName.equals("DOB"))
			return getDob();
		if(fieldName.equals("ACTIVE"))
			return getActive();
		if(fieldName.equals("PDSCONTACTPREFERENCES"))
			return getPDScontactPreferences();
		if(fieldName.equals("PDSLANGUAGE"))
			return getPDSlanguage();
		if(fieldName.equals("PDSINTERPRETERREQUIRED"))
			return getPDSInterpreterRequired();
		if(fieldName.equals("PENDING"))
			return getPending();
		if(fieldName.equals("ISCONFIDENTIAL"))
			return getIsConfidential();
		if(fieldName.equals("TIMESTAMP"))
			return getTimestamp();
		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 getRelationshipIsNotNull()
	{
		return this.relationship != null;
	}
	public ims.core.vo.lookups.PersonRelationship getRelationship()
	{
		return this.relationship;
	}
	public void setRelationship(ims.core.vo.lookups.PersonRelationship value)
	{
		this.isValidated = false;
		this.relationship = value;
	}
	public boolean getCommChannelsIsNotNull()
	{
		return this.commchannels != null;
	}
	public ims.core.vo.CommChannelVoCollection getCommChannels()
	{
		return this.commchannels;
	}
	public void setCommChannels(ims.core.vo.CommChannelVoCollection value)
	{
		this.isValidated = false;
		this.commchannels = value;
	}
	public boolean getPdsUpdateModeIsNotNull()
	{
		return this.pdsupdatemode != null;
	}
	public ims.core.vo.lookups.PDSUpdateMode getPdsUpdateMode()
	{
		return this.pdsupdatemode;
	}
	public void setPdsUpdateMode(ims.core.vo.lookups.PDSUpdateMode value)
	{
		this.isValidated = false;
		this.pdsupdatemode = value;
	}
	public boolean getObjectidentifierIsNotNull()
	{
		return this.objectidentifier != null;
	}
	public String getObjectidentifier()
	{
		return this.objectidentifier;
	}
	public static int getObjectidentifierMaxLength()
	{
		return 14;
	}
	public void setObjectidentifier(String value)
	{
		this.isValidated = false;
		this.objectidentifier = value;
	}
	public boolean getRoleIsNotNull()
	{
		return this.role != null;
	}
	public ims.core.vo.lookups.PDSPersonRole getRole()
	{
		return this.role;
	}
	public void setRole(ims.core.vo.lookups.PDSPersonRole value)
	{
		this.isValidated = false;
		this.role = value;
	}
	public boolean getNhsNumIsNotNull()
	{
		return this.nhsnum != null;
	}
	public String getNhsNum()
	{
		return this.nhsnum;
	}
	public static int getNhsNumMaxLength()
	{
		return 50;
	}
	public void setNhsNum(String value)
	{
		this.isValidated = false;
		this.nhsnum = value;
	}
	public boolean getContactRankIsNotNull()
	{
		return this.contactrank != null;
	}
	public String getContactRank()
	{
		return this.contactrank;
	}
	public static int getContactRankMaxLength()
	{
		return 2;
	}
	public void setContactRank(String value)
	{
		this.isValidated = false;
		this.contactrank = value;
	}
	public boolean getNokIndIsNotNull()
	{
		return this.nokind != null;
	}
	public Boolean getNokInd()
	{
		return this.nokind;
	}
	public void setNokInd(Boolean value)
	{
		this.isValidated = false;
		this.nokind = value;
	}
	public boolean getCpyCorrespIsNotNull()
	{
		return this.cpycorresp != null;
	}
	public Boolean getCpyCorresp()
	{
		return this.cpycorresp;
	}
	public void setCpyCorresp(Boolean value)
	{
		this.isValidated = false;
		this.cpycorresp = value;
	}
	public boolean getCallbckConsIsNotNull()
	{
		return this.callbckcons != null;
	}
	public ims.core.vo.lookups.PDSConsent getCallbckCons()
	{
		return this.callbckcons;
	}
	public void setCallbckCons(ims.core.vo.lookups.PDSConsent value)
	{
		this.isValidated = false;
		this.callbckcons = value;
	}
	public boolean getBeffdatecnfIsNotNull()
	{
		return this.beffdatecnf != null;
	}
	public Boolean getBeffdatecnf()
	{
		return this.beffdatecnf;
	}
	public void setBeffdatecnf(Boolean value)
	{
		this.isValidated = false;
		this.beffdatecnf = value;
	}
	public boolean getBetdatecnfIsNotNull()
	{
		return this.betdatecnf != null;
	}
	public Boolean getBetdatecnf()
	{
		return this.betdatecnf;
	}
	public void setBetdatecnf(Boolean value)
	{
		this.isValidated = false;
		this.betdatecnf = value;
	}
	public boolean getBeffdateIsNotNull()
	{
		return this.beffdate != null;
	}
	public ims.framework.utils.Date getBeffdate()
	{
		return this.beffdate;
	}
	public void setBeffdate(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.beffdate = value;
	}
	public boolean getBetdateIsNotNull()
	{
		return this.betdate != null;
	}
	public ims.framework.utils.Date getBetdate()
	{
		return this.betdate;
	}
	public void setBetdate(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.betdate = 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 getActiveIsNotNull()
	{
		return this.active != null;
	}
	public Boolean getActive()
	{
		return this.active;
	}
	public void setActive(Boolean value)
	{
		this.isValidated = false;
		this.active = value;
	}
	public boolean getPDScontactPreferencesIsNotNull()
	{
		return this.pdscontactpreferences != null;
	}
	public ims.core.vo.PDSRelativeContactPrefVo getPDScontactPreferences()
	{
		return this.pdscontactpreferences;
	}
	public void setPDScontactPreferences(ims.core.vo.PDSRelativeContactPrefVo value)
	{
		this.isValidated = false;
		this.pdscontactpreferences = value;
	}
	public boolean getPDSlanguageIsNotNull()
	{
		return this.pdslanguage != null;
	}
	public ims.core.vo.lookups.PDSPreferredCommunicationLanguage getPDSlanguage()
	{
		return this.pdslanguage;
	}
	public void setPDSlanguage(ims.core.vo.lookups.PDSPreferredCommunicationLanguage value)
	{
		this.isValidated = false;
		this.pdslanguage = value;
	}
	public boolean getPDSInterpreterRequiredIsNotNull()
	{
		return this.pdsinterpreterrequired != null;
	}
	public Boolean getPDSInterpreterRequired()
	{
		return this.pdsinterpreterrequired;
	}
	public void setPDSInterpreterRequired(Boolean value)
	{
		this.isValidated = false;
		this.pdsinterpreterrequired = value;
	}
	public boolean getPendingIsNotNull()
	{
		return this.pending != null;
	}
	public Boolean getPending()
	{
		return this.pending;
	}
	public void setPending(Boolean value)
	{
		this.isValidated = false;
		this.pending = 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 getTimestampIsNotNull()
	{
		return this.timestamp != null;
	}
	public String getTimestamp()
	{
		return this.timestamp;
	}
	public static int getTimestampMaxLength()
	{
		return 255;
	}
	public void setTimestamp(String value)
	{
		this.isValidated = false;
		this.timestamp = value;
	}
	/**
	* pdsEquals
	*/
			public boolean pdsEquals(Object obj)
			{
				if (this == obj)
					return true;
				if (obj == null)
					return false;
				if (getClass() != obj.getClass())
					return false;
				PatRelative other = (PatRelative) obj;
				if (active == null)
				{
					if (other.active != null)
						return false;
				}
				else if (!active.equals(other.active))
					return false;
				if (address == null)
				{
					if (other.address != null)
						return false;
				}
				else if (!address.pdsEquals(other.address))
					return false;
				if (beffdate == null)
				{
					if (other.beffdate != null)
						return false;
				}
				else if (!beffdate.equals(other.beffdate))
					return false;
				if (beffdatecnf == null)
				{
					if (other.beffdatecnf != null)
						return false;
				}
				else if (!beffdatecnf.equals(other.beffdatecnf))
					return false;
				if (betdate == null)
				{
					if (other.betdate != null)
						return false;
				}
				else if (!betdate.equals(other.betdate))
					return false;
				if (betdatecnf == null)
				{
					if (other.betdatecnf != null)
						return false;
				}
				else if (!betdatecnf.equals(other.betdatecnf))
					return false;
				if (callbckcons == null)
				{
					if (other.callbckcons != null)
						return false;
				}
				else if (!callbckcons.equals(other.callbckcons))
					return false;
				if (contactrank == null)
				{
					if (other.contactrank != null)
						return false;
				}
				else if (!contactrank.equals(other.contactrank))
					return false;
				if (cpycorresp == null)
				{
					if (other.cpycorresp != null)
						return false;
				}
				else if (!cpycorresp.equals(other.cpycorresp))
					return false;
				if (dob == null)
				{
					if (other.dob != null)
						return false;
				}
				else if (!dob.equals(other.dob))
					return false;
				if (name == null)
				{
					if (other.name != null)
						return false;
				}
				else if (!name.pdsEquals(other.name))
					return false;
				if (nhsnum == null)
				{
					if (other.nhsnum != null)
						return false;
				}
				else if (!nhsnum.equals(other.nhsnum))
					return false;
				if (nokind == null)
				{
					if (other.nokind != null)
						return false;
				}
				else if (!nokind.equals(other.nokind))
					return false;
				if (pdscontactpreferences == null)
				{
					if (other.pdscontactpreferences != null)
						return false;
				}
				else if (!pdscontactpreferences.pdsEquals(other.pdscontactpreferences))
					return false;
				if (pdsinterpreterrequired == null)
				{
					if (other.pdsinterpreterrequired != null)
						return false;
				}
				else if (!pdsinterpreterrequired.equals(other.pdsinterpreterrequired))
					return false;
				if (pdslanguage == null)
				{
					if (other.pdslanguage != null)
						return false;
				}
				else if (!pdslanguage.equals(other.pdslanguage))
					return false;
				if (relationship == null)
				{
					if (other.relationship != null)
						return false;
				}
				else if (!relationship.equals(other.relationship))
					return false;
				if (role == null)
				{
					if (other.role != null)
						return false;
				}
				else if (!role.equals(other.role))
					return false;
				
				if (commchannels == null)
				{
					if (other.commchannels != null)
						return false;
				}
				else 
				{
					if(other.commchannels == null)
						return false;
					
					if (commchannels.size() != other.commchannels.size())
						return false;
					
					for(CommChannelVo cc : commchannels)
					{
						// every CommChannel should have an Objectidentifier
						//if Objectidentifier is null we assume there is a new record added and flag it as such 
						if(cc.getObjectidentifier() == null)
							return false;
						
						boolean foundCco = false;
						
						for(CommChannelVo cco : other.commchannels)
						{
							if(cc.getObjectidentifier().equals(cco.getObjectidentifier()))
							{
								if(!cc.pdsEquals(obj))
									return false;
								else
								{
									foundCco = true;
									break;
								}
							}
						}
						
						if(!foundCco)
							return false;
					}
				}
				
				
				return true;
			}
	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.commchannels != null)
		{
			if(!this.commchannels.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.pdscontactpreferences != null)
		{
			if(!this.pdscontactpreferences.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.commchannels != null)
		{
			String[] listOfOtherErrors = this.commchannels.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.objectidentifier != null)
			if(this.objectidentifier.length() > 14)
				listOfErrors.add("The length of the field [objectidentifier] in the value object [ims.core.vo.PatRelative] is too big. It should be less or equal to 14");
		if(this.nhsnum != null)
			if(this.nhsnum.length() > 50)
				listOfErrors.add("The length of the field [nhsnum] in the value object [ims.core.vo.PatRelative] is too big. It should be less or equal to 50");
		if(this.contactrank != null)
			if(this.contactrank.length() > 2)
				listOfErrors.add("The length of the field [contactrank] in the value object [ims.core.vo.PatRelative] is too big. It should be less or equal to 2");
		if(this.pdscontactpreferences != null)
		{
			String[] listOfOtherErrors = this.pdscontactpreferences.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;
	
		PatRelative clone = new PatRelative(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.relationship == null)
			clone.relationship = null;
		else
			clone.relationship = (ims.core.vo.lookups.PersonRelationship)this.relationship.clone();
		if(this.commchannels == null)
			clone.commchannels = null;
		else
			clone.commchannels = (ims.core.vo.CommChannelVoCollection)this.commchannels.clone();
		if(this.pdsupdatemode == null)
			clone.pdsupdatemode = null;
		else
			clone.pdsupdatemode = (ims.core.vo.lookups.PDSUpdateMode)this.pdsupdatemode.clone();
		clone.objectidentifier = this.objectidentifier;
		if(this.role == null)
			clone.role = null;
		else
			clone.role = (ims.core.vo.lookups.PDSPersonRole)this.role.clone();
		clone.nhsnum = this.nhsnum;
		clone.contactrank = this.contactrank;
		clone.nokind = this.nokind;
		clone.cpycorresp = this.cpycorresp;
		if(this.callbckcons == null)
			clone.callbckcons = null;
		else
			clone.callbckcons = (ims.core.vo.lookups.PDSConsent)this.callbckcons.clone();
		clone.beffdatecnf = this.beffdatecnf;
		clone.betdatecnf = this.betdatecnf;
		if(this.beffdate == null)
			clone.beffdate = null;
		else
			clone.beffdate = (ims.framework.utils.Date)this.beffdate.clone();
		if(this.betdate == null)
			clone.betdate = null;
		else
			clone.betdate = (ims.framework.utils.Date)this.betdate.clone();
		if(this.dob == null)
			clone.dob = null;
		else
			clone.dob = (ims.framework.utils.PartialDate)this.dob.clone();
		clone.active = this.active;
		if(this.pdscontactpreferences == null)
			clone.pdscontactpreferences = null;
		else
			clone.pdscontactpreferences = (ims.core.vo.PDSRelativeContactPrefVo)this.pdscontactpreferences.clone();
		if(this.pdslanguage == null)
			clone.pdslanguage = null;
		else
			clone.pdslanguage = (ims.core.vo.lookups.PDSPreferredCommunicationLanguage)this.pdslanguage.clone();
		clone.pdsinterpreterrequired = this.pdsinterpreterrequired;
		clone.pending = this.pending;
		clone.isconfidential = this.isconfidential;
		clone.timestamp = this.timestamp;
		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 (!(PatRelative.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A PatRelative object cannot be compared an Object of type " + obj.getClass().getName());
		}
		PatRelative compareObj = (PatRelative)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getName() == null && compareObj.getName() != null)
				return -1;
			if(this.getName() != null && compareObj.getName() == null)
				return 1;
			if(this.getName() != null && compareObj.getName() != null)
				retVal = this.getName().compareTo(compareObj.getName());
		}
		return retVal;
	}
	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.relationship != null)
			count++;
		if(this.commchannels != null)
			count++;
		if(this.pdsupdatemode != null)
			count++;
		if(this.objectidentifier != null)
			count++;
		if(this.role != null)
			count++;
		if(this.nhsnum != null)
			count++;
		if(this.contactrank != null)
			count++;
		if(this.nokind != null)
			count++;
		if(this.cpycorresp != null)
			count++;
		if(this.callbckcons != null)
			count++;
		if(this.beffdatecnf != null)
			count++;
		if(this.betdatecnf != null)
			count++;
		if(this.beffdate != null)
			count++;
		if(this.betdate != null)
			count++;
		if(this.dob != null)
			count++;
		if(this.active != null)
			count++;
		if(this.pdscontactpreferences != null)
			count++;
		if(this.pdslanguage != null)
			count++;
		if(this.pdsinterpreterrequired != null)
			count++;
		if(this.pending != null)
			count++;
		if(this.isconfidential != null)
			count++;
		if(this.timestamp != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 24;
	}
	protected ims.core.vo.PersonName name;
	protected ims.core.vo.PersonAddress address;
	protected ims.core.vo.lookups.PersonRelationship relationship;
	protected ims.core.vo.CommChannelVoCollection commchannels;
	protected ims.core.vo.lookups.PDSUpdateMode pdsupdatemode;
	protected String objectidentifier;
	protected ims.core.vo.lookups.PDSPersonRole role;
	protected String nhsnum;
	protected String contactrank;
	protected Boolean nokind;
	protected Boolean cpycorresp;
	protected ims.core.vo.lookups.PDSConsent callbckcons;
	protected Boolean beffdatecnf;
	protected Boolean betdatecnf;
	protected ims.framework.utils.Date beffdate;
	protected ims.framework.utils.Date betdate;
	protected ims.framework.utils.PartialDate dob;
	protected Boolean active;
	protected ims.core.vo.PDSRelativeContactPrefVo pdscontactpreferences;
	protected ims.core.vo.lookups.PDSPreferredCommunicationLanguage pdslanguage;
	protected Boolean pdsinterpreterrequired;
	protected Boolean pending;
	protected Boolean isconfidential;
	protected String timestamp;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
