/FileExtraction/Java_unseen/IMS-MAXIMS_openMAXIMS/Source Library/openmaxims_workspace/ValueObjects/src/ims/clinical/vo/ClinicalReferralsVo.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.ClinicalReferrals business object (ID: 1072100112).
 */
public class ClinicalReferralsVo extends ims.clinical.vo.ClinicalReferralsRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public ClinicalReferralsVo()
	{
	}
	public ClinicalReferralsVo(Integer id, int version)
	{
		super(id, version);
	}
	public ClinicalReferralsVo(ims.clinical.vo.beans.ClinicalReferralsVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.referraltype = bean.getReferralType() == null ? null : ims.clinical.vo.lookups.ClinicalReferralType.buildLookup(bean.getReferralType());
		this.currentreferralstatus = bean.getCurrentReferralStatus() == null ? null : bean.getCurrentReferralStatus().buildVo();
		this.historyofreferralstatus = ims.clinical.vo.ClinicalReferralStatusVoCollection.buildFromBeanCollection(bean.getHistoryOfReferralStatus());
		this.referringhcp = bean.getReferringHCP() == null ? null : bean.getReferringHCP().buildVo();
		this.refertoservice = bean.getReferToService() == null ? null : bean.getReferToService().buildVo();
		this.refertohcp = bean.getReferToHCP() == null ? null : bean.getReferToHCP().buildVo();
		this.urgentreferral = bean.getUrgentReferral();
		this.newcondition = bean.getNewCondition();
		this.requiresauthorisation = bean.getRequiresAuthorisation();
		this.servicespecificanswers = ims.assessment.vo.PatientAssessmentQuestionVoCollection.buildFromBeanCollection(bean.getServiceSpecificAnswers());
		this.reasonforreferral = bean.getReasonForReferral();
		this.datedecisiontorefer = bean.getDateDecisionToRefer() == null ? null : bean.getDateDecisionToRefer().buildDate();
		this.pathwayid = bean.getPathwayID();
		this.recordinginfo = bean.getRecordingInfo() == null ? null : bean.getRecordingInfo().buildVo();
		if(bean.getReferralDocument() != null)
		{
			this.referraldocument = new ims.core.documents.vo.PatientDocumentRefVoCollection();
			for(int referraldocument_i = 0; referraldocument_i < bean.getReferralDocument().length; referraldocument_i++)
			{
				this.referraldocument.add(new ims.core.documents.vo.PatientDocumentRefVo(new Integer(bean.getReferralDocument()[referraldocument_i].getId()), bean.getReferralDocument()[referraldocument_i].getVersion()));
			}
		}
		this.clinicalreferralnotes = ims.clinical.vo.ClinicalReferralNotesVoCollection.buildFromBeanCollection(bean.getClinicalReferralNotes());
		this.acknowledgerejection = bean.getAcknowledgeRejection();
		this.patient = bean.getPatient() == null ? null : new ims.core.patient.vo.PatientRefVo(new Integer(bean.getPatient().getId()), bean.getPatient().getVersion());
		this.referringservice = bean.getReferringService() == null ? null : bean.getReferringService().buildVo();
		this.authorisinginfo = bean.getAuthorisingInfo() == null ? null : bean.getAuthorisingInfo().buildVo();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.clinical.vo.beans.ClinicalReferralsVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.referraltype = bean.getReferralType() == null ? null : ims.clinical.vo.lookups.ClinicalReferralType.buildLookup(bean.getReferralType());
		this.currentreferralstatus = bean.getCurrentReferralStatus() == null ? null : bean.getCurrentReferralStatus().buildVo(map);
		this.historyofreferralstatus = ims.clinical.vo.ClinicalReferralStatusVoCollection.buildFromBeanCollection(bean.getHistoryOfReferralStatus());
		this.referringhcp = bean.getReferringHCP() == null ? null : bean.getReferringHCP().buildVo(map);
		this.refertoservice = bean.getReferToService() == null ? null : bean.getReferToService().buildVo(map);
		this.refertohcp = bean.getReferToHCP() == null ? null : bean.getReferToHCP().buildVo(map);
		this.urgentreferral = bean.getUrgentReferral();
		this.newcondition = bean.getNewCondition();
		this.requiresauthorisation = bean.getRequiresAuthorisation();
		this.servicespecificanswers = ims.assessment.vo.PatientAssessmentQuestionVoCollection.buildFromBeanCollection(bean.getServiceSpecificAnswers());
		this.reasonforreferral = bean.getReasonForReferral();
		this.datedecisiontorefer = bean.getDateDecisionToRefer() == null ? null : bean.getDateDecisionToRefer().buildDate();
		this.pathwayid = bean.getPathwayID();
		this.recordinginfo = bean.getRecordingInfo() == null ? null : bean.getRecordingInfo().buildVo(map);
		if(bean.getReferralDocument() != null)
		{
			this.referraldocument = new ims.core.documents.vo.PatientDocumentRefVoCollection();
			for(int referraldocument_i = 0; referraldocument_i < bean.getReferralDocument().length; referraldocument_i++)
			{
				this.referraldocument.add(new ims.core.documents.vo.PatientDocumentRefVo(new Integer(bean.getReferralDocument()[referraldocument_i].getId()), bean.getReferralDocument()[referraldocument_i].getVersion()));
			}
		}
		this.clinicalreferralnotes = ims.clinical.vo.ClinicalReferralNotesVoCollection.buildFromBeanCollection(bean.getClinicalReferralNotes());
		this.acknowledgerejection = bean.getAcknowledgeRejection();
		this.patient = bean.getPatient() == null ? null : new ims.core.patient.vo.PatientRefVo(new Integer(bean.getPatient().getId()), bean.getPatient().getVersion());
		this.referringservice = bean.getReferringService() == null ? null : bean.getReferringService().buildVo(map);
		this.authorisinginfo = bean.getAuthorisingInfo() == null ? null : bean.getAuthorisingInfo().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.ClinicalReferralsVoBean bean = null;
		if(map != null)
			bean = (ims.clinical.vo.beans.ClinicalReferralsVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.clinical.vo.beans.ClinicalReferralsVoBean();
			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("REFERRALTYPE"))
			return getReferralType();
		if(fieldName.equals("CURRENTREFERRALSTATUS"))
			return getCurrentReferralStatus();
		if(fieldName.equals("HISTORYOFREFERRALSTATUS"))
			return getHistoryOfReferralStatus();
		if(fieldName.equals("REFERRINGHCP"))
			return getReferringHCP();
		if(fieldName.equals("REFERTOSERVICE"))
			return getReferToService();
		if(fieldName.equals("REFERTOHCP"))
			return getReferToHCP();
		if(fieldName.equals("URGENTREFERRAL"))
			return getUrgentReferral();
		if(fieldName.equals("NEWCONDITION"))
			return getNewCondition();
		if(fieldName.equals("REQUIRESAUTHORISATION"))
			return getRequiresAuthorisation();
		if(fieldName.equals("SERVICESPECIFICANSWERS"))
			return getServiceSpecificAnswers();
		if(fieldName.equals("REASONFORREFERRAL"))
			return getReasonForReferral();
		if(fieldName.equals("DATEDECISIONTOREFER"))
			return getDateDecisionToRefer();
		if(fieldName.equals("PATHWAYID"))
			return getPathwayID();
		if(fieldName.equals("RECORDINGINFO"))
			return getRecordingInfo();
		if(fieldName.equals("REFERRALDOCUMENT"))
			return getReferralDocument();
		if(fieldName.equals("CLINICALREFERRALNOTES"))
			return getClinicalReferralNotes();
		if(fieldName.equals("ACKNOWLEDGEREJECTION"))
			return getAcknowledgeRejection();
		if(fieldName.equals("PATIENT"))
			return getPatient();
		if(fieldName.equals("REFERRINGSERVICE"))
			return getReferringService();
		if(fieldName.equals("AUTHORISINGINFO"))
			return getAuthorisingInfo();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getReferralTypeIsNotNull()
	{
		return this.referraltype != null;
	}
	public ims.clinical.vo.lookups.ClinicalReferralType getReferralType()
	{
		return this.referraltype;
	}
	public void setReferralType(ims.clinical.vo.lookups.ClinicalReferralType value)
	{
		this.isValidated = false;
		this.referraltype = value;
	}
	public boolean getCurrentReferralStatusIsNotNull()
	{
		return this.currentreferralstatus != null;
	}
	public ims.clinical.vo.ClinicalReferralStatusVo getCurrentReferralStatus()
	{
		return this.currentreferralstatus;
	}
	public void setCurrentReferralStatus(ims.clinical.vo.ClinicalReferralStatusVo value)
	{
		this.isValidated = false;
		this.currentreferralstatus = value;
	}
	public boolean getHistoryOfReferralStatusIsNotNull()
	{
		return this.historyofreferralstatus != null;
	}
	public ims.clinical.vo.ClinicalReferralStatusVoCollection getHistoryOfReferralStatus()
	{
		return this.historyofreferralstatus;
	}
	public void setHistoryOfReferralStatus(ims.clinical.vo.ClinicalReferralStatusVoCollection value)
	{
		this.isValidated = false;
		this.historyofreferralstatus = value;
	}
	public boolean getReferringHCPIsNotNull()
	{
		return this.referringhcp != null;
	}
	public ims.core.vo.HcpLiteVo getReferringHCP()
	{
		return this.referringhcp;
	}
	public void setReferringHCP(ims.core.vo.HcpLiteVo value)
	{
		this.isValidated = false;
		this.referringhcp = value;
	}
	public boolean getReferToServiceIsNotNull()
	{
		return this.refertoservice != null;
	}
	public ims.clinical.vo.ServiceConfigIntReferralForReferralVo getReferToService()
	{
		return this.refertoservice;
	}
	public void setReferToService(ims.clinical.vo.ServiceConfigIntReferralForReferralVo value)
	{
		this.isValidated = false;
		this.refertoservice = value;
	}
	public boolean getReferToHCPIsNotNull()
	{
		return this.refertohcp != null;
	}
	public ims.core.vo.HcpLiteVo getReferToHCP()
	{
		return this.refertohcp;
	}
	public void setReferToHCP(ims.core.vo.HcpLiteVo value)
	{
		this.isValidated = false;
		this.refertohcp = value;
	}
	public boolean getUrgentReferralIsNotNull()
	{
		return this.urgentreferral != null;
	}
	public Boolean getUrgentReferral()
	{
		return this.urgentreferral;
	}
	public void setUrgentReferral(Boolean value)
	{
		this.isValidated = false;
		this.urgentreferral = value;
	}
	public boolean getNewConditionIsNotNull()
	{
		return this.newcondition != null;
	}
	public Boolean getNewCondition()
	{
		return this.newcondition;
	}
	public void setNewCondition(Boolean value)
	{
		this.isValidated = false;
		this.newcondition = value;
	}
	public boolean getRequiresAuthorisationIsNotNull()
	{
		return this.requiresauthorisation != null;
	}
	public Boolean getRequiresAuthorisation()
	{
		return this.requiresauthorisation;
	}
	public void setRequiresAuthorisation(Boolean value)
	{
		this.isValidated = false;
		this.requiresauthorisation = value;
	}
	public boolean getServiceSpecificAnswersIsNotNull()
	{
		return this.servicespecificanswers != null;
	}
	public ims.assessment.vo.PatientAssessmentQuestionVoCollection getServiceSpecificAnswers()
	{
		return this.servicespecificanswers;
	}
	public void setServiceSpecificAnswers(ims.assessment.vo.PatientAssessmentQuestionVoCollection value)
	{
		this.isValidated = false;
		this.servicespecificanswers = value;
	}
	public boolean getReasonForReferralIsNotNull()
	{
		return this.reasonforreferral != null;
	}
	public String getReasonForReferral()
	{
		return this.reasonforreferral;
	}
	public static int getReasonForReferralMaxLength()
	{
		return 1000;
	}
	public void setReasonForReferral(String value)
	{
		this.isValidated = false;
		this.reasonforreferral = value;
	}
	public boolean getDateDecisionToReferIsNotNull()
	{
		return this.datedecisiontorefer != null;
	}
	public ims.framework.utils.Date getDateDecisionToRefer()
	{
		return this.datedecisiontorefer;
	}
	public void setDateDecisionToRefer(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.datedecisiontorefer = value;
	}
	public boolean getPathwayIDIsNotNull()
	{
		return this.pathwayid != null;
	}
	public String getPathwayID()
	{
		return this.pathwayid;
	}
	public static int getPathwayIDMaxLength()
	{
		return 20;
	}
	public void setPathwayID(String value)
	{
		this.isValidated = false;
		this.pathwayid = value;
	}
	public boolean getRecordingInfoIsNotNull()
	{
		return this.recordinginfo != null;
	}
	public ims.core.vo.RecordingUserInformationVo getRecordingInfo()
	{
		return this.recordinginfo;
	}
	public void setRecordingInfo(ims.core.vo.RecordingUserInformationVo value)
	{
		this.isValidated = false;
		this.recordinginfo = value;
	}
	public boolean getReferralDocumentIsNotNull()
	{
		return this.referraldocument != null;
	}
	public ims.core.documents.vo.PatientDocumentRefVoCollection getReferralDocument()
	{
		return this.referraldocument;
	}
	public void setReferralDocument(ims.core.documents.vo.PatientDocumentRefVoCollection value)
	{
		this.isValidated = false;
		this.referraldocument = value;
	}
	public boolean getClinicalReferralNotesIsNotNull()
	{
		return this.clinicalreferralnotes != null;
	}
	public ims.clinical.vo.ClinicalReferralNotesVoCollection getClinicalReferralNotes()
	{
		return this.clinicalreferralnotes;
	}
	public void setClinicalReferralNotes(ims.clinical.vo.ClinicalReferralNotesVoCollection value)
	{
		this.isValidated = false;
		this.clinicalreferralnotes = value;
	}
	public boolean getAcknowledgeRejectionIsNotNull()
	{
		return this.acknowledgerejection != null;
	}
	public Boolean getAcknowledgeRejection()
	{
		return this.acknowledgerejection;
	}
	public void setAcknowledgeRejection(Boolean value)
	{
		this.isValidated = false;
		this.acknowledgerejection = value;
	}
	public boolean getPatientIsNotNull()
	{
		return this.patient != null;
	}
	public ims.core.patient.vo.PatientRefVo getPatient()
	{
		return this.patient;
	}
	public void setPatient(ims.core.patient.vo.PatientRefVo value)
	{
		this.isValidated = false;
		this.patient = value;
	}
	public boolean getReferringServiceIsNotNull()
	{
		return this.referringservice != null;
	}
	public ims.core.vo.ServiceLiteVo getReferringService()
	{
		return this.referringservice;
	}
	public void setReferringService(ims.core.vo.ServiceLiteVo value)
	{
		this.isValidated = false;
		this.referringservice = value;
	}
	public boolean getAuthorisingInfoIsNotNull()
	{
		return this.authorisinginfo != null;
	}
	public ims.core.vo.RecordingUserInformationVo getAuthorisingInfo()
	{
		return this.authorisinginfo;
	}
	public void setAuthorisingInfo(ims.core.vo.RecordingUserInformationVo value)
	{
		this.isValidated = false;
		this.authorisinginfo = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.currentreferralstatus != null)
		{
			if(!this.currentreferralstatus.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.historyofreferralstatus != null)
		{
			if(!this.historyofreferralstatus.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.servicespecificanswers != null)
		{
			if(!this.servicespecificanswers.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.recordinginfo != null)
		{
			if(!this.recordinginfo.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.clinicalreferralnotes != null)
		{
			if(!this.clinicalreferralnotes.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.authorisinginfo != null)
		{
			if(!this.authorisinginfo.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.referraltype == null)
			listOfErrors.add("Referral Type is mandatory");
		if(this.currentreferralstatus == null)
			listOfErrors.add("CurrentReferralStatus is mandatory");
		if(this.currentreferralstatus != null)
		{
			String[] listOfOtherErrors = this.currentreferralstatus.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.historyofreferralstatus != null)
		{
			String[] listOfOtherErrors = this.historyofreferralstatus.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.referringhcp == null)
			listOfErrors.add("Referring HCP is mandatory");
		if(this.refertoservice == null)
			listOfErrors.add("Refer To Service is mandatory");
		if(this.servicespecificanswers != null)
		{
			String[] listOfOtherErrors = this.servicespecificanswers.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.reasonforreferral != null)
			if(this.reasonforreferral.length() > 1000)
				listOfErrors.add("The length of the field [reasonforreferral] in the value object [ims.clinical.vo.ClinicalReferralsVo] is too big. It should be less or equal to 1000");
		if(this.datedecisiontorefer == null)
			listOfErrors.add("Date Decision To Refer is mandatory");
		if(this.pathwayid != null)
			if(this.pathwayid.length() > 20)
				listOfErrors.add("The length of the field [pathwayid] in the value object [ims.clinical.vo.ClinicalReferralsVo] is too big. It should be less or equal to 20");
		if(this.recordinginfo == null)
			listOfErrors.add("RecordingInfo is mandatory");
		if(this.recordinginfo != null)
		{
			String[] listOfOtherErrors = this.recordinginfo.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.clinicalreferralnotes != null)
		{
			String[] listOfOtherErrors = this.clinicalreferralnotes.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.patient == null)
			listOfErrors.add("Patient is mandatory");
		if(this.authorisinginfo != null)
		{
			String[] listOfOtherErrors = this.authorisinginfo.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;
	
		ClinicalReferralsVo clone = new ClinicalReferralsVo(this.id, this.version);
		
		if(this.referraltype == null)
			clone.referraltype = null;
		else
			clone.referraltype = (ims.clinical.vo.lookups.ClinicalReferralType)this.referraltype.clone();
		if(this.currentreferralstatus == null)
			clone.currentreferralstatus = null;
		else
			clone.currentreferralstatus = (ims.clinical.vo.ClinicalReferralStatusVo)this.currentreferralstatus.clone();
		if(this.historyofreferralstatus == null)
			clone.historyofreferralstatus = null;
		else
			clone.historyofreferralstatus = (ims.clinical.vo.ClinicalReferralStatusVoCollection)this.historyofreferralstatus.clone();
		if(this.referringhcp == null)
			clone.referringhcp = null;
		else
			clone.referringhcp = (ims.core.vo.HcpLiteVo)this.referringhcp.clone();
		if(this.refertoservice == null)
			clone.refertoservice = null;
		else
			clone.refertoservice = (ims.clinical.vo.ServiceConfigIntReferralForReferralVo)this.refertoservice.clone();
		if(this.refertohcp == null)
			clone.refertohcp = null;
		else
			clone.refertohcp = (ims.core.vo.HcpLiteVo)this.refertohcp.clone();
		clone.urgentreferral = this.urgentreferral;
		clone.newcondition = this.newcondition;
		clone.requiresauthorisation = this.requiresauthorisation;
		if(this.servicespecificanswers == null)
			clone.servicespecificanswers = null;
		else
			clone.servicespecificanswers = (ims.assessment.vo.PatientAssessmentQuestionVoCollection)this.servicespecificanswers.clone();
		clone.reasonforreferral = this.reasonforreferral;
		if(this.datedecisiontorefer == null)
			clone.datedecisiontorefer = null;
		else
			clone.datedecisiontorefer = (ims.framework.utils.Date)this.datedecisiontorefer.clone();
		clone.pathwayid = this.pathwayid;
		if(this.recordinginfo == null)
			clone.recordinginfo = null;
		else
			clone.recordinginfo = (ims.core.vo.RecordingUserInformationVo)this.recordinginfo.clone();
		clone.referraldocument = this.referraldocument;
		if(this.clinicalreferralnotes == null)
			clone.clinicalreferralnotes = null;
		else
			clone.clinicalreferralnotes = (ims.clinical.vo.ClinicalReferralNotesVoCollection)this.clinicalreferralnotes.clone();
		clone.acknowledgerejection = this.acknowledgerejection;
		clone.patient = this.patient;
		if(this.referringservice == null)
			clone.referringservice = null;
		else
			clone.referringservice = (ims.core.vo.ServiceLiteVo)this.referringservice.clone();
		if(this.authorisinginfo == null)
			clone.authorisinginfo = null;
		else
			clone.authorisinginfo = (ims.core.vo.RecordingUserInformationVo)this.authorisinginfo.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 (!(ClinicalReferralsVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A ClinicalReferralsVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((ClinicalReferralsVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((ClinicalReferralsVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.referraltype != null)
			count++;
		if(this.currentreferralstatus != null)
			count++;
		if(this.historyofreferralstatus != null)
			count++;
		if(this.referringhcp != null)
			count++;
		if(this.refertoservice != null)
			count++;
		if(this.refertohcp != null)
			count++;
		if(this.urgentreferral != null)
			count++;
		if(this.newcondition != null)
			count++;
		if(this.requiresauthorisation != null)
			count++;
		if(this.servicespecificanswers != null)
			count++;
		if(this.reasonforreferral != null)
			count++;
		if(this.datedecisiontorefer != null)
			count++;
		if(this.pathwayid != null)
			count++;
		if(this.recordinginfo != null)
			count++;
		if(this.referraldocument != null)
			count++;
		if(this.clinicalreferralnotes != null)
			count++;
		if(this.acknowledgerejection != null)
			count++;
		if(this.patient != null)
			count++;
		if(this.referringservice != null)
			count++;
		if(this.authorisinginfo != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 20;
	}
	protected ims.clinical.vo.lookups.ClinicalReferralType referraltype;
	protected ims.clinical.vo.ClinicalReferralStatusVo currentreferralstatus;
	protected ims.clinical.vo.ClinicalReferralStatusVoCollection historyofreferralstatus;
	protected ims.core.vo.HcpLiteVo referringhcp;
	protected ims.clinical.vo.ServiceConfigIntReferralForReferralVo refertoservice;
	protected ims.core.vo.HcpLiteVo refertohcp;
	protected Boolean urgentreferral;
	protected Boolean newcondition;
	protected Boolean requiresauthorisation;
	protected ims.assessment.vo.PatientAssessmentQuestionVoCollection servicespecificanswers;
	protected String reasonforreferral;
	protected ims.framework.utils.Date datedecisiontorefer;
	protected String pathwayid;
	protected ims.core.vo.RecordingUserInformationVo recordinginfo;
	protected ims.core.documents.vo.PatientDocumentRefVoCollection referraldocument;
	protected ims.clinical.vo.ClinicalReferralNotesVoCollection clinicalreferralnotes;
	protected Boolean acknowledgerejection;
	protected ims.core.patient.vo.PatientRefVo patient;
	protected ims.core.vo.ServiceLiteVo referringservice;
	protected ims.core.vo.RecordingUserInformationVo authorisinginfo;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
