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

	public DeathDetailsVo()
	{
	}
	public DeathDetailsVo(Integer id, int version)
	{
		super(id, version);
	}
	public DeathDetailsVo(ims.core.vo.beans.DeathDetailsVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.deathplaceofdeath = bean.getDeathPlaceofDeath() == null ? null : ims.core.vo.lookups.PlaceofDeath.buildLookup(bean.getDeathPlaceofDeath());
		this.deathcauseestablished = bean.getDeathCauseEstablished() == null ? null : ims.core.vo.lookups.DeathCauseEstablished.buildLookup(bean.getDeathCauseEstablished());
		this.cancerrelateddeath = bean.getCancerRelatedDeath() == null ? null : ims.core.vo.lookups.DeathCauseCancer.buildLookup(bean.getCancerRelatedDeath());
		this.deathcodediscrepency = bean.getDeathCodeDiscrepency() == null ? null : ims.core.vo.lookups.DeathCodeDiscrepency.buildLookup(bean.getDeathCodeDiscrepency());
		this.deathconditions = ims.core.vo.DeathConditionsVoCollection.buildFromBeanCollection(bean.getDeathConditions());
		this.patient = bean.getPatient() == null ? null : bean.getPatient().buildVo();
		this.referredtocorroner = bean.getReferredToCorroner();
		this.postmortem = bean.getPostMortem() == null ? null : ims.core.vo.lookups.PostMortem.buildLookup(bean.getPostMortem());
		this.pdsdeathnotificationstatus = bean.getPDSDeathNotificationStatus() == null ? null : ims.admin.vo.lookups.PDSDeathNotificationStatus.buildLookup(bean.getPDSDeathNotificationStatus());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.DeathDetailsVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.deathplaceofdeath = bean.getDeathPlaceofDeath() == null ? null : ims.core.vo.lookups.PlaceofDeath.buildLookup(bean.getDeathPlaceofDeath());
		this.deathcauseestablished = bean.getDeathCauseEstablished() == null ? null : ims.core.vo.lookups.DeathCauseEstablished.buildLookup(bean.getDeathCauseEstablished());
		this.cancerrelateddeath = bean.getCancerRelatedDeath() == null ? null : ims.core.vo.lookups.DeathCauseCancer.buildLookup(bean.getCancerRelatedDeath());
		this.deathcodediscrepency = bean.getDeathCodeDiscrepency() == null ? null : ims.core.vo.lookups.DeathCodeDiscrepency.buildLookup(bean.getDeathCodeDiscrepency());
		this.deathconditions = ims.core.vo.DeathConditionsVoCollection.buildFromBeanCollection(bean.getDeathConditions());
		this.patient = bean.getPatient() == null ? null : bean.getPatient().buildVo(map);
		this.referredtocorroner = bean.getReferredToCorroner();
		this.postmortem = bean.getPostMortem() == null ? null : ims.core.vo.lookups.PostMortem.buildLookup(bean.getPostMortem());
		this.pdsdeathnotificationstatus = bean.getPDSDeathNotificationStatus() == null ? null : ims.admin.vo.lookups.PDSDeathNotificationStatus.buildLookup(bean.getPDSDeathNotificationStatus());
	}
	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.DeathDetailsVoBean bean = null;
		if(map != null)
			bean = (ims.core.vo.beans.DeathDetailsVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.core.vo.beans.DeathDetailsVoBean();
			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("DEATHPLACEOFDEATH"))
			return getDeathPlaceofDeath();
		if(fieldName.equals("DEATHCAUSEESTABLISHED"))
			return getDeathCauseEstablished();
		if(fieldName.equals("CANCERRELATEDDEATH"))
			return getCancerRelatedDeath();
		if(fieldName.equals("DEATHCODEDISCREPENCY"))
			return getDeathCodeDiscrepency();
		if(fieldName.equals("DEATHCONDITIONS"))
			return getDeathConditions();
		if(fieldName.equals("PATIENT"))
			return getPatient();
		if(fieldName.equals("REFERREDTOCORRONER"))
			return getReferredToCorroner();
		if(fieldName.equals("POSTMORTEM"))
			return getPostMortem();
		if(fieldName.equals("PDSDEATHNOTIFICATIONSTATUS"))
			return getPDSDeathNotificationStatus();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getDeathPlaceofDeathIsNotNull()
	{
		return this.deathplaceofdeath != null;
	}
	public ims.core.vo.lookups.PlaceofDeath getDeathPlaceofDeath()
	{
		return this.deathplaceofdeath;
	}
	public void setDeathPlaceofDeath(ims.core.vo.lookups.PlaceofDeath value)
	{
		this.isValidated = false;
		this.deathplaceofdeath = value;
	}
	public boolean getDeathCauseEstablishedIsNotNull()
	{
		return this.deathcauseestablished != null;
	}
	public ims.core.vo.lookups.DeathCauseEstablished getDeathCauseEstablished()
	{
		return this.deathcauseestablished;
	}
	public void setDeathCauseEstablished(ims.core.vo.lookups.DeathCauseEstablished value)
	{
		this.isValidated = false;
		this.deathcauseestablished = value;
	}
	public boolean getCancerRelatedDeathIsNotNull()
	{
		return this.cancerrelateddeath != null;
	}
	public ims.core.vo.lookups.DeathCauseCancer getCancerRelatedDeath()
	{
		return this.cancerrelateddeath;
	}
	public void setCancerRelatedDeath(ims.core.vo.lookups.DeathCauseCancer value)
	{
		this.isValidated = false;
		this.cancerrelateddeath = value;
	}
	public boolean getDeathCodeDiscrepencyIsNotNull()
	{
		return this.deathcodediscrepency != null;
	}
	public ims.core.vo.lookups.DeathCodeDiscrepency getDeathCodeDiscrepency()
	{
		return this.deathcodediscrepency;
	}
	public void setDeathCodeDiscrepency(ims.core.vo.lookups.DeathCodeDiscrepency value)
	{
		this.isValidated = false;
		this.deathcodediscrepency = value;
	}
	public boolean getDeathConditionsIsNotNull()
	{
		return this.deathconditions != null;
	}
	public ims.core.vo.DeathConditionsVoCollection getDeathConditions()
	{
		return this.deathconditions;
	}
	public void setDeathConditions(ims.core.vo.DeathConditionsVoCollection value)
	{
		this.isValidated = false;
		this.deathconditions = value;
	}
	public boolean getPatientIsNotNull()
	{
		return this.patient != null;
	}
	public ims.core.vo.PatientShort getPatient()
	{
		return this.patient;
	}
	public void setPatient(ims.core.vo.PatientShort value)
	{
		this.isValidated = false;
		this.patient = value;
	}
	public boolean getReferredToCorronerIsNotNull()
	{
		return this.referredtocorroner != null;
	}
	public Boolean getReferredToCorroner()
	{
		return this.referredtocorroner;
	}
	public void setReferredToCorroner(Boolean value)
	{
		this.isValidated = false;
		this.referredtocorroner = value;
	}
	public boolean getPostMortemIsNotNull()
	{
		return this.postmortem != null;
	}
	public ims.core.vo.lookups.PostMortem getPostMortem()
	{
		return this.postmortem;
	}
	public void setPostMortem(ims.core.vo.lookups.PostMortem value)
	{
		this.isValidated = false;
		this.postmortem = value;
	}
	public boolean getPDSDeathNotificationStatusIsNotNull()
	{
		return this.pdsdeathnotificationstatus != null;
	}
	public ims.admin.vo.lookups.PDSDeathNotificationStatus getPDSDeathNotificationStatus()
	{
		return this.pdsdeathnotificationstatus;
	}
	public void setPDSDeathNotificationStatus(ims.admin.vo.lookups.PDSDeathNotificationStatus value)
	{
		this.isValidated = false;
		this.pdsdeathnotificationstatus = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.deathconditions != null)
		{
			if(!this.deathconditions.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.deathconditions != null)
		{
			String[] listOfOtherErrors = this.deathconditions.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;
	
		DeathDetailsVo clone = new DeathDetailsVo(this.id, this.version);
		
		if(this.deathplaceofdeath == null)
			clone.deathplaceofdeath = null;
		else
			clone.deathplaceofdeath = (ims.core.vo.lookups.PlaceofDeath)this.deathplaceofdeath.clone();
		if(this.deathcauseestablished == null)
			clone.deathcauseestablished = null;
		else
			clone.deathcauseestablished = (ims.core.vo.lookups.DeathCauseEstablished)this.deathcauseestablished.clone();
		if(this.cancerrelateddeath == null)
			clone.cancerrelateddeath = null;
		else
			clone.cancerrelateddeath = (ims.core.vo.lookups.DeathCauseCancer)this.cancerrelateddeath.clone();
		if(this.deathcodediscrepency == null)
			clone.deathcodediscrepency = null;
		else
			clone.deathcodediscrepency = (ims.core.vo.lookups.DeathCodeDiscrepency)this.deathcodediscrepency.clone();
		if(this.deathconditions == null)
			clone.deathconditions = null;
		else
			clone.deathconditions = (ims.core.vo.DeathConditionsVoCollection)this.deathconditions.clone();
		if(this.patient == null)
			clone.patient = null;
		else
			clone.patient = (ims.core.vo.PatientShort)this.patient.clone();
		clone.referredtocorroner = this.referredtocorroner;
		if(this.postmortem == null)
			clone.postmortem = null;
		else
			clone.postmortem = (ims.core.vo.lookups.PostMortem)this.postmortem.clone();
		if(this.pdsdeathnotificationstatus == null)
			clone.pdsdeathnotificationstatus = null;
		else
			clone.pdsdeathnotificationstatus = (ims.admin.vo.lookups.PDSDeathNotificationStatus)this.pdsdeathnotificationstatus.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 (!(DeathDetailsVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A DeathDetailsVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((DeathDetailsVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((DeathDetailsVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.deathplaceofdeath != null)
			count++;
		if(this.deathcauseestablished != null)
			count++;
		if(this.cancerrelateddeath != null)
			count++;
		if(this.deathcodediscrepency != null)
			count++;
		if(this.deathconditions != null)
			count++;
		if(this.patient != null)
			count++;
		if(this.referredtocorroner != null)
			count++;
		if(this.postmortem != null)
			count++;
		if(this.pdsdeathnotificationstatus != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 9;
	}
	protected ims.core.vo.lookups.PlaceofDeath deathplaceofdeath;
	protected ims.core.vo.lookups.DeathCauseEstablished deathcauseestablished;
	protected ims.core.vo.lookups.DeathCauseCancer cancerrelateddeath;
	protected ims.core.vo.lookups.DeathCodeDiscrepency deathcodediscrepency;
	protected ims.core.vo.DeathConditionsVoCollection deathconditions;
	protected ims.core.vo.PatientShort patient;
	protected Boolean referredtocorroner;
	protected ims.core.vo.lookups.PostMortem postmortem;
	protected ims.admin.vo.lookups.PDSDeathNotificationStatus pdsdeathnotificationstatus;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
