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

/**
 * Linked to clinical.ReferralsRecording business object (ID: 1072100062).
 */
public class ReferralsRecordingVo extends ims.clinical.vo.ReferralsRecordingShortVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public ReferralsRecordingVo()
	{
	}
	public ReferralsRecordingVo(Integer id, int version)
	{
		super(id, version);
	}
	public ReferralsRecordingVo(ims.clinical.vo.beans.ReferralsRecordingVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.referraltype = bean.getReferralType() == null ? null : ims.clinical.vo.lookups.TypeOfReferral.buildLookup(bean.getReferralType());
		this.referralsource = bean.getReferralSource() == null ? null : ims.clinical.vo.lookups.ReferralSource.buildLookup(bean.getReferralSource());
		this.datesent = bean.getDateSent() == null ? null : bean.getDateSent().buildDate();
		this.details = bean.getDetails();
		this.reforgacode = bean.getRefOrgaCode() == null ? null : bean.getRefOrgaCode().buildVo();
		this.datefirstseen = bean.getDateFirstSeen() == null ? null : bean.getDateFirstSeen().buildDate();
		this.referralhcp = bean.getReferralHCP() == null ? null : bean.getReferralHCP().buildVo();
		this.datereceived = bean.getDateReceived() == null ? null : bean.getDateReceived().buildDate();
		this.referredby = bean.getReferredBy() == null ? null : bean.getReferredBy().buildVo();
		this.referralpriority = bean.getReferralPriority() == null ? null : ims.core.vo.lookups.ReferralPriority.buildLookup(bean.getReferralPriority());
		this.reasonforreferral = bean.getReasonForReferral() == null ? null : ims.core.vo.lookups.ReasonForReferral.buildLookup(bean.getReasonForReferral());
		this.specialtyfunctioncode = bean.getSpecialtyFunctionCode() == null ? null : ims.clinical.vo.lookups.SpecialtyFunctionCode.buildLookup(bean.getSpecialtyFunctionCode());
		this.referredbygp = bean.getReferredByGP() == null ? null : bean.getReferredByGP().buildVo();
		this.referralcategory = bean.getReferralCategory() == null ? null : ims.clinical.vo.lookups.ReferralCategory.buildLookup(bean.getReferralCategory());
		this.primarypreceeding = bean.getPrimaryPreceeding() == null ? null : ims.clinical.vo.lookups.PrimaryPreceeding.buildLookup(bean.getPrimaryPreceeding());
		this.authoringinfo = bean.getAuthoringInfo() == null ? null : bean.getAuthoringInfo().buildVo();
		this.carespell = bean.getCareSpell() == null ? null : new ims.core.admin.vo.CareSpellRefVo(new Integer(bean.getCareSpell().getId()), bean.getCareSpell().getVersion());
		this.carecontext = bean.getCareContext() == null ? null : new ims.core.admin.vo.CareContextRefVo(new Integer(bean.getCareContext().getId()), bean.getCareContext().getVersion());
		this.clinicalcontact = bean.getClinicalContact() == null ? null : new ims.core.admin.vo.ClinicalContactRefVo(new Integer(bean.getClinicalContact().getId()), bean.getClinicalContact().getVersion());
		this.suppliedreferralprofessional = bean.getSuppliedReferralProfessional() == null ? null : bean.getSuppliedReferralProfessional().buildVo();
		this.referredtolocation = bean.getReferredtoLocation() == null ? null : bean.getReferredtoLocation().buildVo();
		this.referralstatus = bean.getReferralStatus() == null ? null : ims.core.vo.lookups.CoreReferralStatus.buildLookup(bean.getReferralStatus());
		this.urgentcancerreferraltype = bean.getUrgentCancerReferralType() == null ? null : ims.core.vo.lookups.UrgentCancerReferralType.buildLookup(bean.getUrgentCancerReferralType());
		this.cancerstatus = bean.getCancerStatus() == null ? null : ims.core.vo.lookups.CancerStatus.buildLookup(bean.getCancerStatus());
		this.delayreasongpurgentreferral = bean.getDelayReasonGPUrgentReferral() == null ? null : ims.clinical.vo.lookups.DelayReasonGPUrgentReferral.buildLookup(bean.getDelayReasonGPUrgentReferral());
		this.delayreasontext = bean.getDelayReasonText();
		this.sysinfo = bean.getSysInfo() == null ? null : bean.getSysInfo().buildSystemInformation();
		this.recordingmos = bean.getRecordingMOS() == null ? null : bean.getRecordingMOS().buildVo();
		this.discipline = bean.getDiscipline() == null ? null : ims.clinical.vo.lookups.ReferralDiscipline.buildLookup(bean.getDiscipline());
		this.preceedingreferrals = ims.clinical.vo.ReferralsRecordingVoCollection.buildFromBeanCollection(bean.getPreceedingReferrals());
		this.reasonforreferraltext = bean.getReasonForReferralText();
		this.suppliedreferraldetails = bean.getSuppliedReferralDetails() == null ? null : bean.getSuppliedReferralDetails().buildVo();
		this.assessment = bean.getAssessment() == null ? null : bean.getAssessment().buildVo();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.clinical.vo.beans.ReferralsRecordingVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.referraltype = bean.getReferralType() == null ? null : ims.clinical.vo.lookups.TypeOfReferral.buildLookup(bean.getReferralType());
		this.referralsource = bean.getReferralSource() == null ? null : ims.clinical.vo.lookups.ReferralSource.buildLookup(bean.getReferralSource());
		this.datesent = bean.getDateSent() == null ? null : bean.getDateSent().buildDate();
		this.details = bean.getDetails();
		this.reforgacode = bean.getRefOrgaCode() == null ? null : bean.getRefOrgaCode().buildVo(map);
		this.datefirstseen = bean.getDateFirstSeen() == null ? null : bean.getDateFirstSeen().buildDate();
		this.referralhcp = bean.getReferralHCP() == null ? null : bean.getReferralHCP().buildVo(map);
		this.datereceived = bean.getDateReceived() == null ? null : bean.getDateReceived().buildDate();
		this.referredby = bean.getReferredBy() == null ? null : bean.getReferredBy().buildVo(map);
		this.referralpriority = bean.getReferralPriority() == null ? null : ims.core.vo.lookups.ReferralPriority.buildLookup(bean.getReferralPriority());
		this.reasonforreferral = bean.getReasonForReferral() == null ? null : ims.core.vo.lookups.ReasonForReferral.buildLookup(bean.getReasonForReferral());
		this.specialtyfunctioncode = bean.getSpecialtyFunctionCode() == null ? null : ims.clinical.vo.lookups.SpecialtyFunctionCode.buildLookup(bean.getSpecialtyFunctionCode());
		this.referredbygp = bean.getReferredByGP() == null ? null : bean.getReferredByGP().buildVo(map);
		this.referralcategory = bean.getReferralCategory() == null ? null : ims.clinical.vo.lookups.ReferralCategory.buildLookup(bean.getReferralCategory());
		this.primarypreceeding = bean.getPrimaryPreceeding() == null ? null : ims.clinical.vo.lookups.PrimaryPreceeding.buildLookup(bean.getPrimaryPreceeding());
		this.authoringinfo = bean.getAuthoringInfo() == null ? null : bean.getAuthoringInfo().buildVo(map);
		this.carespell = bean.getCareSpell() == null ? null : new ims.core.admin.vo.CareSpellRefVo(new Integer(bean.getCareSpell().getId()), bean.getCareSpell().getVersion());
		this.carecontext = bean.getCareContext() == null ? null : new ims.core.admin.vo.CareContextRefVo(new Integer(bean.getCareContext().getId()), bean.getCareContext().getVersion());
		this.clinicalcontact = bean.getClinicalContact() == null ? null : new ims.core.admin.vo.ClinicalContactRefVo(new Integer(bean.getClinicalContact().getId()), bean.getClinicalContact().getVersion());
		this.suppliedreferralprofessional = bean.getSuppliedReferralProfessional() == null ? null : bean.getSuppliedReferralProfessional().buildVo(map);
		this.referredtolocation = bean.getReferredtoLocation() == null ? null : bean.getReferredtoLocation().buildVo(map);
		this.referralstatus = bean.getReferralStatus() == null ? null : ims.core.vo.lookups.CoreReferralStatus.buildLookup(bean.getReferralStatus());
		this.urgentcancerreferraltype = bean.getUrgentCancerReferralType() == null ? null : ims.core.vo.lookups.UrgentCancerReferralType.buildLookup(bean.getUrgentCancerReferralType());
		this.cancerstatus = bean.getCancerStatus() == null ? null : ims.core.vo.lookups.CancerStatus.buildLookup(bean.getCancerStatus());
		this.delayreasongpurgentreferral = bean.getDelayReasonGPUrgentReferral() == null ? null : ims.clinical.vo.lookups.DelayReasonGPUrgentReferral.buildLookup(bean.getDelayReasonGPUrgentReferral());
		this.delayreasontext = bean.getDelayReasonText();
		this.sysinfo = bean.getSysInfo() == null ? null : bean.getSysInfo().buildSystemInformation();
		this.recordingmos = bean.getRecordingMOS() == null ? null : bean.getRecordingMOS().buildVo(map);
		this.discipline = bean.getDiscipline() == null ? null : ims.clinical.vo.lookups.ReferralDiscipline.buildLookup(bean.getDiscipline());
		this.preceedingreferrals = ims.clinical.vo.ReferralsRecordingVoCollection.buildFromBeanCollection(bean.getPreceedingReferrals());
		this.reasonforreferraltext = bean.getReasonForReferralText();
		this.suppliedreferraldetails = bean.getSuppliedReferralDetails() == null ? null : bean.getSuppliedReferralDetails().buildVo(map);
		this.assessment = bean.getAssessment() == null ? null : bean.getAssessment().buildVo(map);
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.clinical.vo.beans.ReferralsRecordingVoBean bean = null;
		if(map != null)
			bean = (ims.clinical.vo.beans.ReferralsRecordingVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.clinical.vo.beans.ReferralsRecordingVoBean();
			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("PRECEEDINGREFERRALS"))
			return getPreceedingReferrals();
		if(fieldName.equals("REASONFORREFERRALTEXT"))
			return getReasonForReferralText();
		if(fieldName.equals("SUPPLIEDREFERRALDETAILS"))
			return getSuppliedReferralDetails();
		if(fieldName.equals("ASSESSMENT"))
			return getAssessment();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getPreceedingReferralsIsNotNull()
	{
		return this.preceedingreferrals != null;
	}
	public ims.clinical.vo.ReferralsRecordingVoCollection getPreceedingReferrals()
	{
		return this.preceedingreferrals;
	}
	public void setPreceedingReferrals(ims.clinical.vo.ReferralsRecordingVoCollection value)
	{
		this.isValidated = false;
		this.preceedingreferrals = value;
	}
	public boolean getReasonForReferralTextIsNotNull()
	{
		return this.reasonforreferraltext != null;
	}
	public String getReasonForReferralText()
	{
		return this.reasonforreferraltext;
	}
	public static int getReasonForReferralTextMaxLength()
	{
		return 1000;
	}
	public void setReasonForReferralText(String value)
	{
		this.isValidated = false;
		this.reasonforreferraltext = value;
	}
	public boolean getSuppliedReferralDetailsIsNotNull()
	{
		return this.suppliedreferraldetails != null;
	}
	public ims.clinical.vo.SuppliedReferralDetailsVo getSuppliedReferralDetails()
	{
		return this.suppliedreferraldetails;
	}
	public void setSuppliedReferralDetails(ims.clinical.vo.SuppliedReferralDetailsVo value)
	{
		this.isValidated = false;
		this.suppliedreferraldetails = value;
	}
	public boolean getAssessmentIsNotNull()
	{
		return this.assessment != null;
	}
	public ims.assessment.vo.PatientAssessmentVo getAssessment()
	{
		return this.assessment;
	}
	public void setAssessment(ims.assessment.vo.PatientAssessmentVo value)
	{
		this.isValidated = false;
		this.assessment = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.referredby != null)
		{
			if(!this.referredby.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.referredbygp != null)
		{
			if(!this.referredbygp.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.authoringinfo != null)
		{
			if(!this.authoringinfo.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.suppliedreferralprofessional != null)
		{
			if(!this.suppliedreferralprofessional.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.referredtolocation != null)
		{
			if(!this.referredtolocation.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.recordingmos != null)
		{
			if(!this.recordingmos.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.preceedingreferrals != null)
		{
			if(!this.preceedingreferrals.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.suppliedreferraldetails != null)
		{
			if(!this.suppliedreferraldetails.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.assessment != null)
		{
			if(!this.assessment.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.datesent == null)
			listOfErrors.add("Date Decision to Refer is mandatory");
		if(this.details != null)
			if(this.details.length() > 1000)
				listOfErrors.add("The length of the field [details] in the value object [ims.clinical.vo.ReferralsRecordingVo] is too big. It should be less or equal to 1000");
		if(this.referredby != null)
		{
			String[] listOfOtherErrors = this.referredby.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.referredbygp != null)
		{
			String[] listOfOtherErrors = this.referredbygp.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.referralcategory == null)
			listOfErrors.add("ReferralCategory is mandatory");
		if(this.authoringinfo == null)
			listOfErrors.add("AuthoringInfo is mandatory");
		if(this.authoringinfo != null)
		{
			String[] listOfOtherErrors = this.authoringinfo.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.carecontext == null)
			listOfErrors.add("CareContext is mandatory");
		if(this.suppliedreferralprofessional != null)
		{
			String[] listOfOtherErrors = this.suppliedreferralprofessional.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.referredtolocation != null)
		{
			String[] listOfOtherErrors = this.referredtolocation.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.delayreasontext != null)
			if(this.delayreasontext.length() > 1000)
				listOfErrors.add("The length of the field [delayreasontext] in the value object [ims.clinical.vo.ReferralsRecordingVo] is too big. It should be less or equal to 1000");
		if(this.recordingmos != null)
		{
			String[] listOfOtherErrors = this.recordingmos.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.preceedingreferrals != null)
		{
			String[] listOfOtherErrors = this.preceedingreferrals.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.reasonforreferraltext != null)
			if(this.reasonforreferraltext.length() > 1000)
				listOfErrors.add("The length of the field [reasonforreferraltext] in the value object [ims.clinical.vo.ReferralsRecordingVo] is too big. It should be less or equal to 1000");
		if(this.suppliedreferraldetails != null)
		{
			String[] listOfOtherErrors = this.suppliedreferraldetails.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.assessment != null)
		{
			String[] listOfOtherErrors = this.assessment.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;
	
		ReferralsRecordingVo clone = new ReferralsRecordingVo(this.id, this.version);
		
		if(this.referraltype == null)
			clone.referraltype = null;
		else
			clone.referraltype = (ims.clinical.vo.lookups.TypeOfReferral)this.referraltype.clone();
		if(this.referralsource == null)
			clone.referralsource = null;
		else
			clone.referralsource = (ims.clinical.vo.lookups.ReferralSource)this.referralsource.clone();
		if(this.datesent == null)
			clone.datesent = null;
		else
			clone.datesent = (ims.framework.utils.Date)this.datesent.clone();
		clone.details = this.details;
		if(this.reforgacode == null)
			clone.reforgacode = null;
		else
			clone.reforgacode = (ims.core.vo.OrgLiteVo)this.reforgacode.clone();
		if(this.datefirstseen == null)
			clone.datefirstseen = null;
		else
			clone.datefirstseen = (ims.framework.utils.Date)this.datefirstseen.clone();
		if(this.referralhcp == null)
			clone.referralhcp = null;
		else
			clone.referralhcp = (ims.core.vo.MemberOfStaffShortVo)this.referralhcp.clone();
		if(this.datereceived == null)
			clone.datereceived = null;
		else
			clone.datereceived = (ims.framework.utils.Date)this.datereceived.clone();
		if(this.referredby == null)
			clone.referredby = null;
		else
			clone.referredby = (ims.core.vo.Hcp)this.referredby.clone();
		if(this.referralpriority == null)
			clone.referralpriority = null;
		else
			clone.referralpriority = (ims.core.vo.lookups.ReferralPriority)this.referralpriority.clone();
		if(this.reasonforreferral == null)
			clone.reasonforreferral = null;
		else
			clone.reasonforreferral = (ims.core.vo.lookups.ReasonForReferral)this.reasonforreferral.clone();
		if(this.specialtyfunctioncode == null)
			clone.specialtyfunctioncode = null;
		else
			clone.specialtyfunctioncode = (ims.clinical.vo.lookups.SpecialtyFunctionCode)this.specialtyfunctioncode.clone();
		if(this.referredbygp == null)
			clone.referredbygp = null;
		else
			clone.referredbygp = (ims.core.vo.GpShortVo)this.referredbygp.clone();
		if(this.referralcategory == null)
			clone.referralcategory = null;
		else
			clone.referralcategory = (ims.clinical.vo.lookups.ReferralCategory)this.referralcategory.clone();
		if(this.primarypreceeding == null)
			clone.primarypreceeding = null;
		else
			clone.primarypreceeding = (ims.clinical.vo.lookups.PrimaryPreceeding)this.primarypreceeding.clone();
		if(this.authoringinfo == null)
			clone.authoringinfo = null;
		else
			clone.authoringinfo = (ims.core.vo.AuthoringInformationVo)this.authoringinfo.clone();
		clone.carespell = this.carespell;
		clone.carecontext = this.carecontext;
		clone.clinicalcontact = this.clinicalcontact;
		if(this.suppliedreferralprofessional == null)
			clone.suppliedreferralprofessional = null;
		else
			clone.suppliedreferralprofessional = (ims.clinical.vo.ReferralProffessionalDetailVo)this.suppliedreferralprofessional.clone();
		if(this.referredtolocation == null)
			clone.referredtolocation = null;
		else
			clone.referredtolocation = (ims.core.vo.LocShortVo)this.referredtolocation.clone();
		if(this.referralstatus == null)
			clone.referralstatus = null;
		else
			clone.referralstatus = (ims.core.vo.lookups.CoreReferralStatus)this.referralstatus.clone();
		if(this.urgentcancerreferraltype == null)
			clone.urgentcancerreferraltype = null;
		else
			clone.urgentcancerreferraltype = (ims.core.vo.lookups.UrgentCancerReferralType)this.urgentcancerreferraltype.clone();
		if(this.cancerstatus == null)
			clone.cancerstatus = null;
		else
			clone.cancerstatus = (ims.core.vo.lookups.CancerStatus)this.cancerstatus.clone();
		if(this.delayreasongpurgentreferral == null)
			clone.delayreasongpurgentreferral = null;
		else
			clone.delayreasongpurgentreferral = (ims.clinical.vo.lookups.DelayReasonGPUrgentReferral)this.delayreasongpurgentreferral.clone();
		clone.delayreasontext = this.delayreasontext;
		if(this.sysinfo == null)
			clone.sysinfo = null;
		else
			clone.sysinfo = (ims.vo.SystemInformation)this.sysinfo.clone();
		if(this.recordingmos == null)
			clone.recordingmos = null;
		else
			clone.recordingmos = (ims.core.vo.MemberOfStaffLiteVo)this.recordingmos.clone();
		if(this.discipline == null)
			clone.discipline = null;
		else
			clone.discipline = (ims.clinical.vo.lookups.ReferralDiscipline)this.discipline.clone();
		if(this.preceedingreferrals == null)
			clone.preceedingreferrals = null;
		else
			clone.preceedingreferrals = (ims.clinical.vo.ReferralsRecordingVoCollection)this.preceedingreferrals.clone();
		clone.reasonforreferraltext = this.reasonforreferraltext;
		if(this.suppliedreferraldetails == null)
			clone.suppliedreferraldetails = null;
		else
			clone.suppliedreferraldetails = (ims.clinical.vo.SuppliedReferralDetailsVo)this.suppliedreferraldetails.clone();
		if(this.assessment == null)
			clone.assessment = null;
		else
			clone.assessment = (ims.assessment.vo.PatientAssessmentVo)this.assessment.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 (!(ReferralsRecordingVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A ReferralsRecordingVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		ReferralsRecordingVo compareObj = (ReferralsRecordingVo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getDateSent() == null && compareObj.getDateSent() != null)
				return -1;
			if(this.getDateSent() != null && compareObj.getDateSent() == null)
				return 1;
			if(this.getDateSent() != null && compareObj.getDateSent() != null)
				retVal = this.getDateSent().compareTo(compareObj.getDateSent());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = super.countFieldsWithValue();
		if(this.preceedingreferrals != null)
			count++;
		if(this.reasonforreferraltext != null)
			count++;
		if(this.suppliedreferraldetails != null)
			count++;
		if(this.assessment != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return super.countValueObjectFields() + 4;
	}
	protected ims.clinical.vo.ReferralsRecordingVoCollection preceedingreferrals;
	protected String reasonforreferraltext;
	protected ims.clinical.vo.SuppliedReferralDetailsVo suppliedreferraldetails;
	protected ims.assessment.vo.PatientAssessmentVo assessment;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
