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

	public CatsReferralRepatriationRequestVo()
	{
	}
	public CatsReferralRepatriationRequestVo(Integer id, int version)
	{
		super(id, version);
	}
	public CatsReferralRepatriationRequestVo(ims.core.vo.beans.CatsReferralRepatriationRequestVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.patient = bean.getPatient() == null ? null : new ims.core.patient.vo.PatientRefVo(new Integer(bean.getPatient().getId()), bean.getPatient().getVersion());
		this.referraldetails = bean.getReferralDetails() == null ? null : bean.getReferralDetails().buildVo();
		this.episodeofcare = bean.getEpisodeOfCare() == null ? null : new ims.core.admin.vo.EpisodeOfCareRefVo(new Integer(bean.getEpisodeOfCare().getId()), bean.getEpisodeOfCare().getVersion());
		this.carecontext = bean.getCareContext() == null ? null : new ims.core.admin.vo.CareContextRefVo(new Integer(bean.getCareContext().getId()), bean.getCareContext().getVersion());
		this.currentstatus = bean.getCurrentStatus() == null ? null : bean.getCurrentStatus().buildVo();
		this.statushistory = ims.RefMan.vo.CatsReferralStatusVoCollection.buildFromBeanCollection(bean.getStatusHistory());
		this.contract = bean.getContract() == null ? null : new ims.core.configuration.vo.ContractConfigRefVo(new Integer(bean.getContract().getId()), bean.getContract().getVersion());
		this.urgency = bean.getUrgency() == null ? null : ims.RefMan.vo.lookups.ReferralUrgency.buildLookup(bean.getUrgency());
		this.journey = bean.getJourney() == null ? null : new ims.pathways.vo.PatientPathwayJourneyRefVo(new Integer(bean.getJourney().getId()), bean.getJourney().getVersion());
		this.pathwayid = bean.getPathwayID();
		this.rttclockimpact = bean.getRTTClockImpact();
		this.currentrttstatus = bean.getCurrentRTTStatus() == null ? null : bean.getCurrentRTTStatus().buildVo();
		this.repatriationrequest = bean.getRepatriationRequest() == null ? null : bean.getRepatriationRequest().buildVo();
		this.patientcategory = bean.getPatientCategory() == null ? null : ims.core.vo.lookups.PatientStatus.buildLookup(bean.getPatientCategory());
		this.isemergencyreferral = bean.getIsEmergencyReferral();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.CatsReferralRepatriationRequestVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.patient = bean.getPatient() == null ? null : new ims.core.patient.vo.PatientRefVo(new Integer(bean.getPatient().getId()), bean.getPatient().getVersion());
		this.referraldetails = bean.getReferralDetails() == null ? null : bean.getReferralDetails().buildVo(map);
		this.episodeofcare = bean.getEpisodeOfCare() == null ? null : new ims.core.admin.vo.EpisodeOfCareRefVo(new Integer(bean.getEpisodeOfCare().getId()), bean.getEpisodeOfCare().getVersion());
		this.carecontext = bean.getCareContext() == null ? null : new ims.core.admin.vo.CareContextRefVo(new Integer(bean.getCareContext().getId()), bean.getCareContext().getVersion());
		this.currentstatus = bean.getCurrentStatus() == null ? null : bean.getCurrentStatus().buildVo(map);
		this.statushistory = ims.RefMan.vo.CatsReferralStatusVoCollection.buildFromBeanCollection(bean.getStatusHistory());
		this.contract = bean.getContract() == null ? null : new ims.core.configuration.vo.ContractConfigRefVo(new Integer(bean.getContract().getId()), bean.getContract().getVersion());
		this.urgency = bean.getUrgency() == null ? null : ims.RefMan.vo.lookups.ReferralUrgency.buildLookup(bean.getUrgency());
		this.journey = bean.getJourney() == null ? null : new ims.pathways.vo.PatientPathwayJourneyRefVo(new Integer(bean.getJourney().getId()), bean.getJourney().getVersion());
		this.pathwayid = bean.getPathwayID();
		this.rttclockimpact = bean.getRTTClockImpact();
		this.currentrttstatus = bean.getCurrentRTTStatus() == null ? null : bean.getCurrentRTTStatus().buildVo(map);
		this.repatriationrequest = bean.getRepatriationRequest() == null ? null : bean.getRepatriationRequest().buildVo(map);
		this.patientcategory = bean.getPatientCategory() == null ? null : ims.core.vo.lookups.PatientStatus.buildLookup(bean.getPatientCategory());
		this.isemergencyreferral = bean.getIsEmergencyReferral();
	}
	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.CatsReferralRepatriationRequestVoBean bean = null;
		if(map != null)
			bean = (ims.core.vo.beans.CatsReferralRepatriationRequestVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.core.vo.beans.CatsReferralRepatriationRequestVoBean();
			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("PATIENT"))
			return getPatient();
		if(fieldName.equals("REFERRALDETAILS"))
			return getReferralDetails();
		if(fieldName.equals("EPISODEOFCARE"))
			return getEpisodeOfCare();
		if(fieldName.equals("CARECONTEXT"))
			return getCareContext();
		if(fieldName.equals("CURRENTSTATUS"))
			return getCurrentStatus();
		if(fieldName.equals("STATUSHISTORY"))
			return getStatusHistory();
		if(fieldName.equals("CONTRACT"))
			return getContract();
		if(fieldName.equals("URGENCY"))
			return getUrgency();
		if(fieldName.equals("JOURNEY"))
			return getJourney();
		if(fieldName.equals("PATHWAYID"))
			return getPathwayID();
		if(fieldName.equals("RTTCLOCKIMPACT"))
			return getRTTClockImpact();
		if(fieldName.equals("CURRENTRTTSTATUS"))
			return getCurrentRTTStatus();
		if(fieldName.equals("REPATRIATIONREQUEST"))
			return getRepatriationRequest();
		if(fieldName.equals("PATIENTCATEGORY"))
			return getPatientCategory();
		if(fieldName.equals("ISEMERGENCYREFERRAL"))
			return getIsEmergencyReferral();
		return super.getFieldValueByFieldName(fieldName);
	}
	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 getReferralDetailsIsNotNull()
	{
		return this.referraldetails != null;
	}
	public ims.core.vo.CatsReferralDetailsRepatriationRequestVo getReferralDetails()
	{
		return this.referraldetails;
	}
	public void setReferralDetails(ims.core.vo.CatsReferralDetailsRepatriationRequestVo value)
	{
		this.isValidated = false;
		this.referraldetails = value;
	}
	public boolean getEpisodeOfCareIsNotNull()
	{
		return this.episodeofcare != null;
	}
	public ims.core.admin.vo.EpisodeOfCareRefVo getEpisodeOfCare()
	{
		return this.episodeofcare;
	}
	public void setEpisodeOfCare(ims.core.admin.vo.EpisodeOfCareRefVo value)
	{
		this.isValidated = false;
		this.episodeofcare = value;
	}
	public boolean getCareContextIsNotNull()
	{
		return this.carecontext != null;
	}
	public ims.core.admin.vo.CareContextRefVo getCareContext()
	{
		return this.carecontext;
	}
	public void setCareContext(ims.core.admin.vo.CareContextRefVo value)
	{
		this.isValidated = false;
		this.carecontext = value;
	}
	public boolean getCurrentStatusIsNotNull()
	{
		return this.currentstatus != null;
	}
	public ims.RefMan.vo.CatsReferralStatusVo getCurrentStatus()
	{
		return this.currentstatus;
	}
	public void setCurrentStatus(ims.RefMan.vo.CatsReferralStatusVo value)
	{
		this.isValidated = false;
		this.currentstatus = value;
	}
	public boolean getStatusHistoryIsNotNull()
	{
		return this.statushistory != null;
	}
	public ims.RefMan.vo.CatsReferralStatusVoCollection getStatusHistory()
	{
		return this.statushistory;
	}
	public void setStatusHistory(ims.RefMan.vo.CatsReferralStatusVoCollection value)
	{
		this.isValidated = false;
		this.statushistory = value;
	}
	public boolean getContractIsNotNull()
	{
		return this.contract != null;
	}
	public ims.core.configuration.vo.ContractConfigRefVo getContract()
	{
		return this.contract;
	}
	public void setContract(ims.core.configuration.vo.ContractConfigRefVo value)
	{
		this.isValidated = false;
		this.contract = value;
	}
	public boolean getUrgencyIsNotNull()
	{
		return this.urgency != null;
	}
	public ims.RefMan.vo.lookups.ReferralUrgency getUrgency()
	{
		return this.urgency;
	}
	public void setUrgency(ims.RefMan.vo.lookups.ReferralUrgency value)
	{
		this.isValidated = false;
		this.urgency = value;
	}
	public boolean getJourneyIsNotNull()
	{
		return this.journey != null;
	}
	public ims.pathways.vo.PatientPathwayJourneyRefVo getJourney()
	{
		return this.journey;
	}
	public void setJourney(ims.pathways.vo.PatientPathwayJourneyRefVo value)
	{
		this.isValidated = false;
		this.journey = 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 getRTTClockImpactIsNotNull()
	{
		return this.rttclockimpact != null;
	}
	public Boolean getRTTClockImpact()
	{
		return this.rttclockimpact;
	}
	public void setRTTClockImpact(Boolean value)
	{
		this.isValidated = false;
		this.rttclockimpact = value;
	}
	public boolean getCurrentRTTStatusIsNotNull()
	{
		return this.currentrttstatus != null;
	}
	public ims.pathways.vo.PathwayRTTStatusVo getCurrentRTTStatus()
	{
		return this.currentrttstatus;
	}
	public void setCurrentRTTStatus(ims.pathways.vo.PathwayRTTStatusVo value)
	{
		this.isValidated = false;
		this.currentrttstatus = value;
	}
	public boolean getRepatriationRequestIsNotNull()
	{
		return this.repatriationrequest != null;
	}
	public ims.core.vo.PendingEmergencyAdmissionRepatriationVo getRepatriationRequest()
	{
		return this.repatriationrequest;
	}
	public void setRepatriationRequest(ims.core.vo.PendingEmergencyAdmissionRepatriationVo value)
	{
		this.isValidated = false;
		this.repatriationrequest = value;
	}
	public boolean getPatientCategoryIsNotNull()
	{
		return this.patientcategory != null;
	}
	public ims.core.vo.lookups.PatientStatus getPatientCategory()
	{
		return this.patientcategory;
	}
	public void setPatientCategory(ims.core.vo.lookups.PatientStatus value)
	{
		this.isValidated = false;
		this.patientcategory = value;
	}
	public boolean getIsEmergencyReferralIsNotNull()
	{
		return this.isemergencyreferral != null;
	}
	public Boolean getIsEmergencyReferral()
	{
		return this.isemergencyreferral;
	}
	public void setIsEmergencyReferral(Boolean value)
	{
		this.isValidated = false;
		this.isemergencyreferral = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.referraldetails != null)
		{
			if(!this.referraldetails.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.currentstatus != null)
		{
			if(!this.currentstatus.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.statushistory != null)
		{
			if(!this.statushistory.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.repatriationrequest != null)
		{
			if(!this.repatriationrequest.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.patient == null)
			listOfErrors.add("Patient is mandatory");
		if(this.referraldetails != null)
		{
			String[] listOfOtherErrors = this.referraldetails.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.currentstatus != null)
		{
			String[] listOfOtherErrors = this.currentstatus.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.statushistory != null)
		{
			String[] listOfOtherErrors = this.statushistory.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.pathwayid != null)
			if(this.pathwayid.length() > 20)
				listOfErrors.add("The length of the field [pathwayid] in the value object [ims.core.vo.CatsReferralRepatriationRequestVo] is too big. It should be less or equal to 20");
		if(this.repatriationrequest != null)
		{
			String[] listOfOtherErrors = this.repatriationrequest.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;
	
		CatsReferralRepatriationRequestVo clone = new CatsReferralRepatriationRequestVo(this.id, this.version);
		
		clone.patient = this.patient;
		if(this.referraldetails == null)
			clone.referraldetails = null;
		else
			clone.referraldetails = (ims.core.vo.CatsReferralDetailsRepatriationRequestVo)this.referraldetails.clone();
		clone.episodeofcare = this.episodeofcare;
		clone.carecontext = this.carecontext;
		if(this.currentstatus == null)
			clone.currentstatus = null;
		else
			clone.currentstatus = (ims.RefMan.vo.CatsReferralStatusVo)this.currentstatus.clone();
		if(this.statushistory == null)
			clone.statushistory = null;
		else
			clone.statushistory = (ims.RefMan.vo.CatsReferralStatusVoCollection)this.statushistory.clone();
		clone.contract = this.contract;
		if(this.urgency == null)
			clone.urgency = null;
		else
			clone.urgency = (ims.RefMan.vo.lookups.ReferralUrgency)this.urgency.clone();
		clone.journey = this.journey;
		clone.pathwayid = this.pathwayid;
		clone.rttclockimpact = this.rttclockimpact;
		if(this.currentrttstatus == null)
			clone.currentrttstatus = null;
		else
			clone.currentrttstatus = (ims.pathways.vo.PathwayRTTStatusVo)this.currentrttstatus.clone();
		if(this.repatriationrequest == null)
			clone.repatriationrequest = null;
		else
			clone.repatriationrequest = (ims.core.vo.PendingEmergencyAdmissionRepatriationVo)this.repatriationrequest.clone();
		if(this.patientcategory == null)
			clone.patientcategory = null;
		else
			clone.patientcategory = (ims.core.vo.lookups.PatientStatus)this.patientcategory.clone();
		clone.isemergencyreferral = this.isemergencyreferral;
		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 (!(CatsReferralRepatriationRequestVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A CatsReferralRepatriationRequestVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((CatsReferralRepatriationRequestVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((CatsReferralRepatriationRequestVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.patient != null)
			count++;
		if(this.referraldetails != null)
			count++;
		if(this.episodeofcare != null)
			count++;
		if(this.carecontext != null)
			count++;
		if(this.currentstatus != null)
			count++;
		if(this.statushistory != null)
			count++;
		if(this.contract != null)
			count++;
		if(this.urgency != null)
			count++;
		if(this.journey != null)
			count++;
		if(this.pathwayid != null)
			count++;
		if(this.rttclockimpact != null)
			count++;
		if(this.currentrttstatus != null)
			count++;
		if(this.repatriationrequest != null)
			count++;
		if(this.patientcategory != null)
			count++;
		if(this.isemergencyreferral != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 15;
	}
	protected ims.core.patient.vo.PatientRefVo patient;
	protected ims.core.vo.CatsReferralDetailsRepatriationRequestVo referraldetails;
	protected ims.core.admin.vo.EpisodeOfCareRefVo episodeofcare;
	protected ims.core.admin.vo.CareContextRefVo carecontext;
	protected ims.RefMan.vo.CatsReferralStatusVo currentstatus;
	protected ims.RefMan.vo.CatsReferralStatusVoCollection statushistory;
	protected ims.core.configuration.vo.ContractConfigRefVo contract;
	protected ims.RefMan.vo.lookups.ReferralUrgency urgency;
	protected ims.pathways.vo.PatientPathwayJourneyRefVo journey;
	protected String pathwayid;
	protected Boolean rttclockimpact;
	protected ims.pathways.vo.PathwayRTTStatusVo currentrttstatus;
	protected ims.core.vo.PendingEmergencyAdmissionRepatriationVo repatriationrequest;
	protected ims.core.vo.lookups.PatientStatus patientcategory;
	protected Boolean isemergencyreferral;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
