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


public class CorrespondencePatientListsVo extends ims.vo.ValueObject implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public CorrespondencePatientListsVo()
	{
	}
	public CorrespondencePatientListsVo(ims.correspondence.vo.beans.CorrespondencePatientListsVoBean bean)
	{
		this.inpatientepisodevo = bean.getInpatientEpisodeVo() == null ? null : bean.getInpatientEpisodeVo().buildVo();
		this.paseventvo = bean.getPASEventVo() == null ? null : bean.getPASEventVo().buildVo();
		this.correspondencedetailsvo = bean.getCorrespondenceDetailsVo() == null ? null : bean.getCorrespondenceDetailsVo().buildVo();
		this.patient = bean.getPatient() == null ? null : bean.getPatient().buildVo();
		this.dischargeepisodevo = bean.getDischargeEpisodeVo() == null ? null : bean.getDischargeEpisodeVo().buildVo();
		this.outpatientattendancevo = bean.getOutpatientAttendanceVo() == null ? null : bean.getOutpatientAttendanceVo().buildVo();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.correspondence.vo.beans.CorrespondencePatientListsVoBean bean)
	{
		this.inpatientepisodevo = bean.getInpatientEpisodeVo() == null ? null : bean.getInpatientEpisodeVo().buildVo(map);
		this.paseventvo = bean.getPASEventVo() == null ? null : bean.getPASEventVo().buildVo(map);
		this.correspondencedetailsvo = bean.getCorrespondenceDetailsVo() == null ? null : bean.getCorrespondenceDetailsVo().buildVo(map);
		this.patient = bean.getPatient() == null ? null : bean.getPatient().buildVo(map);
		this.dischargeepisodevo = bean.getDischargeEpisodeVo() == null ? null : bean.getDischargeEpisodeVo().buildVo(map);
		this.outpatientattendancevo = bean.getOutpatientAttendanceVo() == null ? null : bean.getOutpatientAttendanceVo().buildVo(map);
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.correspondence.vo.beans.CorrespondencePatientListsVoBean bean = null;
		if(map != null)
			bean = (ims.correspondence.vo.beans.CorrespondencePatientListsVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.correspondence.vo.beans.CorrespondencePatientListsVoBean();
			map.addValueObjectBean(this, bean);
			bean.populate(map, this);
		}
		return bean;
	}
	public boolean getInpatientEpisodeVoIsNotNull()
	{
		return this.inpatientepisodevo != null;
	}
	public ims.core.vo.InpatientEpisodeVo getInpatientEpisodeVo()
	{
		return this.inpatientepisodevo;
	}
	public void setInpatientEpisodeVo(ims.core.vo.InpatientEpisodeVo value)
	{
		this.isValidated = false;
		this.inpatientepisodevo = value;
	}
	public boolean getPASEventVoIsNotNull()
	{
		return this.paseventvo != null;
	}
	public ims.core.vo.PasEventShortVo getPASEventVo()
	{
		return this.paseventvo;
	}
	public void setPASEventVo(ims.core.vo.PasEventShortVo value)
	{
		this.isValidated = false;
		this.paseventvo = value;
	}
	public boolean getCorrespondenceDetailsVoIsNotNull()
	{
		return this.correspondencedetailsvo != null;
	}
	public ims.correspondence.vo.CorrespondenceDetailsVo getCorrespondenceDetailsVo()
	{
		return this.correspondencedetailsvo;
	}
	public void setCorrespondenceDetailsVo(ims.correspondence.vo.CorrespondenceDetailsVo value)
	{
		this.isValidated = false;
		this.correspondencedetailsvo = value;
	}
	public boolean getPatientIsNotNull()
	{
		return this.patient != null;
	}
	public ims.core.vo.Patient getPatient()
	{
		return this.patient;
	}
	public void setPatient(ims.core.vo.Patient value)
	{
		this.isValidated = false;
		this.patient = value;
	}
	public boolean getDischargeEpisodeVoIsNotNull()
	{
		return this.dischargeepisodevo != null;
	}
	public ims.core.vo.DischargedEpisodeVo getDischargeEpisodeVo()
	{
		return this.dischargeepisodevo;
	}
	public void setDischargeEpisodeVo(ims.core.vo.DischargedEpisodeVo value)
	{
		this.isValidated = false;
		this.dischargeepisodevo = value;
	}
	public boolean getOutpatientAttendanceVoIsNotNull()
	{
		return this.outpatientattendancevo != null;
	}
	public ims.core.vo.OutPatientAttendanceVo getOutpatientAttendanceVo()
	{
		return this.outpatientattendancevo;
	}
	public void setOutpatientAttendanceVo(ims.core.vo.OutPatientAttendanceVo value)
	{
		this.isValidated = false;
		this.outpatientattendancevo = value;
	}
	public final String getIItemText()
	{
		return toString();
	}
	public final Integer getBoId() 
	{
		return null;
	}
	public final String getBoClassName()
	{
		return null;
	}
	public boolean equals(Object obj)
	{
		if(obj == null)
			return false;
		if(!(obj instanceof CorrespondencePatientListsVo))
			return false;
		CorrespondencePatientListsVo compareObj = (CorrespondencePatientListsVo)obj;
		if(this.getInpatientEpisodeVo() == null && compareObj.getInpatientEpisodeVo() != null)
			return false;
		if(this.getInpatientEpisodeVo() != null && compareObj.getInpatientEpisodeVo() == null)
			return false;
		if(this.getInpatientEpisodeVo() != null && compareObj.getInpatientEpisodeVo() != null)
			return this.getInpatientEpisodeVo().equals(compareObj.getInpatientEpisodeVo());
		return super.equals(obj);
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.inpatientepisodevo != null)
		{
			if(!this.inpatientepisodevo.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.paseventvo != null)
		{
			if(!this.paseventvo.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.correspondencedetailsvo != null)
		{
			if(!this.correspondencedetailsvo.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.patient != null)
		{
			if(!this.patient.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.dischargeepisodevo != null)
		{
			if(!this.dischargeepisodevo.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.outpatientattendancevo != null)
		{
			if(!this.outpatientattendancevo.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.inpatientepisodevo != null)
		{
			String[] listOfOtherErrors = this.inpatientepisodevo.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.paseventvo != null)
		{
			String[] listOfOtherErrors = this.paseventvo.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.correspondencedetailsvo != null)
		{
			String[] listOfOtherErrors = this.correspondencedetailsvo.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.patient != null)
		{
			String[] listOfOtherErrors = this.patient.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.dischargeepisodevo != null)
		{
			String[] listOfOtherErrors = this.dischargeepisodevo.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.outpatientattendancevo != null)
		{
			String[] listOfOtherErrors = this.outpatientattendancevo.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 Object clone()
	{
		if(this.isBusy)
			return this;
		this.isBusy = true;
	
		CorrespondencePatientListsVo clone = new CorrespondencePatientListsVo();
		
		if(this.inpatientepisodevo == null)
			clone.inpatientepisodevo = null;
		else
			clone.inpatientepisodevo = (ims.core.vo.InpatientEpisodeVo)this.inpatientepisodevo.clone();
		if(this.paseventvo == null)
			clone.paseventvo = null;
		else
			clone.paseventvo = (ims.core.vo.PasEventShortVo)this.paseventvo.clone();
		if(this.correspondencedetailsvo == null)
			clone.correspondencedetailsvo = null;
		else
			clone.correspondencedetailsvo = (ims.correspondence.vo.CorrespondenceDetailsVo)this.correspondencedetailsvo.clone();
		if(this.patient == null)
			clone.patient = null;
		else
			clone.patient = (ims.core.vo.Patient)this.patient.clone();
		if(this.dischargeepisodevo == null)
			clone.dischargeepisodevo = null;
		else
			clone.dischargeepisodevo = (ims.core.vo.DischargedEpisodeVo)this.dischargeepisodevo.clone();
		if(this.outpatientattendancevo == null)
			clone.outpatientattendancevo = null;
		else
			clone.outpatientattendancevo = (ims.core.vo.OutPatientAttendanceVo)this.outpatientattendancevo.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 (!(CorrespondencePatientListsVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A CorrespondencePatientListsVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		CorrespondencePatientListsVo compareObj = (CorrespondencePatientListsVo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getInpatientEpisodeVo() == null && compareObj.getInpatientEpisodeVo() != null)
				return -1;
			if(this.getInpatientEpisodeVo() != null && compareObj.getInpatientEpisodeVo() == null)
				return 1;
			if(this.getInpatientEpisodeVo() != null && compareObj.getInpatientEpisodeVo() != null)
				retVal = this.getInpatientEpisodeVo().compareTo(compareObj.getInpatientEpisodeVo());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.inpatientepisodevo != null)
			count++;
		if(this.paseventvo != null)
			count++;
		if(this.correspondencedetailsvo != null)
			count++;
		if(this.patient != null)
			count++;
		if(this.dischargeepisodevo != null)
			count++;
		if(this.outpatientattendancevo != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 6;
	}
	protected ims.core.vo.InpatientEpisodeVo inpatientepisodevo;
	protected ims.core.vo.PasEventShortVo paseventvo;
	protected ims.correspondence.vo.CorrespondenceDetailsVo correspondencedetailsvo;
	protected ims.core.vo.Patient patient;
	protected ims.core.vo.DischargedEpisodeVo dischargeepisodevo;
	protected ims.core.vo.OutPatientAttendanceVo outpatientattendancevo;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
