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

/**
 * Linked to Oncology.PatTreatmentPlan business object (ID: 1105100037).
 */
public class PatTreatmentPlanVo extends ims.ccosched.vo.PatTreatmentPlanLiteVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public PatTreatmentPlanVo()
	{
	}
	public PatTreatmentPlanVo(Integer id, int version)
	{
		super(id, version);
	}
	public PatTreatmentPlanVo(ims.ccosched.vo.beans.PatTreatmentPlanVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.treatmentintent = bean.getTreatmentIntent() == null ? null : ims.ccosched.vo.lookups.TreatmentIntent.buildLookup(bean.getTreatmentIntent());
		this.dateseen = bean.getDateSeen() == null ? null : bean.getDateSeen().buildDate();
		this.decisiontotreat = bean.getDecisionToTreat() == null ? null : bean.getDecisionToTreat().buildDate();
		this.actions = ims.ccosched.vo.PatTreatPlanActionVoCollection.buildFromBeanCollection(bean.getActions());
		this.patient = bean.getPatient() == null ? null : new ims.core.patient.vo.PatientRefVo(new Integer(bean.getPatient().getId()), bean.getPatient().getVersion());
		this.pkey = bean.getPkey();
		this.rkey = bean.getRkey();
		this.episode = bean.getEpisode() == null ? null : new ims.core.admin.vo.EpisodeOfCareRefVo(new Integer(bean.getEpisode().getId()), bean.getEpisode().getVersion());
		this.treatmentplancomment = bean.getTreatmentplanComment();
		this.activestatus = bean.getActiveStatus();
		this.consultant = bean.getConsultant() == null ? null : bean.getConsultant().buildVo();
		this.sysinfo = bean.getSysInfo() == null ? null : bean.getSysInfo().buildSystemInformation();
		this.primarytumourhistology = bean.getPrimaryTumourHistology() == null ? null : bean.getPrimaryTumourHistology().buildVo();
		this.ecad_date = bean.getEcad_date() == null ? null : bean.getEcad_date().buildDate();
		this.primarytumourgroup = bean.getPrimaryTumourGroup() == null ? null : bean.getPrimaryTumourGroup().buildVo();
		this.primarytumoursite = bean.getPrimaryTumourSite() == null ? null : bean.getPrimaryTumourSite().buildVo();
		this.treatmentsites = ims.oncology.vo.lookups.TreatmentGroupSiteCollection.buildFromBeanCollection(bean.getTreatmentSites());
		this.creationuser = bean.getCreationUser() == null ? null : new ims.core.resource.people.vo.MemberOfStaffRefVo(new Integer(bean.getCreationUser().getId()), bean.getCreationUser().getVersion());
		this.patientstatus = bean.getPatientStatus() == null ? null : ims.ccosched.vo.lookups.Status.buildLookup(bean.getPatientStatus());
		this.authuser = bean.getAuthUser() == null ? null : new ims.core.clinical.vo.AuthoringInformationRefVo(new Integer(bean.getAuthUser().getId()), bean.getAuthUser().getVersion());
		this.modu = bean.getModu();
		this.surgeryrequired = bean.getSurgeryRequired() == null ? null : ims.oncology.vo.lookups.SurgeryRequired.buildLookup(bean.getSurgeryRequired());
		this.seenlocation = bean.getSeenLocation() == null ? null : ims.ccosched.vo.lookups.SeenAt.buildLookup(bean.getSeenLocation());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.ccosched.vo.beans.PatTreatmentPlanVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.treatmentintent = bean.getTreatmentIntent() == null ? null : ims.ccosched.vo.lookups.TreatmentIntent.buildLookup(bean.getTreatmentIntent());
		this.dateseen = bean.getDateSeen() == null ? null : bean.getDateSeen().buildDate();
		this.decisiontotreat = bean.getDecisionToTreat() == null ? null : bean.getDecisionToTreat().buildDate();
		this.actions = ims.ccosched.vo.PatTreatPlanActionVoCollection.buildFromBeanCollection(bean.getActions());
		this.patient = bean.getPatient() == null ? null : new ims.core.patient.vo.PatientRefVo(new Integer(bean.getPatient().getId()), bean.getPatient().getVersion());
		this.pkey = bean.getPkey();
		this.rkey = bean.getRkey();
		this.episode = bean.getEpisode() == null ? null : new ims.core.admin.vo.EpisodeOfCareRefVo(new Integer(bean.getEpisode().getId()), bean.getEpisode().getVersion());
		this.treatmentplancomment = bean.getTreatmentplanComment();
		this.activestatus = bean.getActiveStatus();
		this.consultant = bean.getConsultant() == null ? null : bean.getConsultant().buildVo(map);
		this.sysinfo = bean.getSysInfo() == null ? null : bean.getSysInfo().buildSystemInformation();
		this.primarytumourhistology = bean.getPrimaryTumourHistology() == null ? null : bean.getPrimaryTumourHistology().buildVo(map);
		this.ecad_date = bean.getEcad_date() == null ? null : bean.getEcad_date().buildDate();
		this.primarytumourgroup = bean.getPrimaryTumourGroup() == null ? null : bean.getPrimaryTumourGroup().buildVo(map);
		this.primarytumoursite = bean.getPrimaryTumourSite() == null ? null : bean.getPrimaryTumourSite().buildVo(map);
		this.treatmentsites = ims.oncology.vo.lookups.TreatmentGroupSiteCollection.buildFromBeanCollection(bean.getTreatmentSites());
		this.creationuser = bean.getCreationUser() == null ? null : new ims.core.resource.people.vo.MemberOfStaffRefVo(new Integer(bean.getCreationUser().getId()), bean.getCreationUser().getVersion());
		this.patientstatus = bean.getPatientStatus() == null ? null : ims.ccosched.vo.lookups.Status.buildLookup(bean.getPatientStatus());
		this.authuser = bean.getAuthUser() == null ? null : new ims.core.clinical.vo.AuthoringInformationRefVo(new Integer(bean.getAuthUser().getId()), bean.getAuthUser().getVersion());
		this.modu = bean.getModu();
		this.surgeryrequired = bean.getSurgeryRequired() == null ? null : ims.oncology.vo.lookups.SurgeryRequired.buildLookup(bean.getSurgeryRequired());
		this.seenlocation = bean.getSeenLocation() == null ? null : ims.ccosched.vo.lookups.SeenAt.buildLookup(bean.getSeenLocation());
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.ccosched.vo.beans.PatTreatmentPlanVoBean bean = null;
		if(map != null)
			bean = (ims.ccosched.vo.beans.PatTreatmentPlanVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.ccosched.vo.beans.PatTreatmentPlanVoBean();
			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("CREATIONUSER"))
			return getCreationUser();
		if(fieldName.equals("PATIENTSTATUS"))
			return getPatientStatus();
		if(fieldName.equals("AUTHUSER"))
			return getAuthUser();
		if(fieldName.equals("MODU"))
			return getModu();
		if(fieldName.equals("SURGERYREQUIRED"))
			return getSurgeryRequired();
		if(fieldName.equals("SEENLOCATION"))
			return getSeenLocation();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getCreationUserIsNotNull()
	{
		return this.creationuser != null;
	}
	public ims.core.resource.people.vo.MemberOfStaffRefVo getCreationUser()
	{
		return this.creationuser;
	}
	public void setCreationUser(ims.core.resource.people.vo.MemberOfStaffRefVo value)
	{
		this.isValidated = false;
		this.creationuser = value;
	}
	public boolean getPatientStatusIsNotNull()
	{
		return this.patientstatus != null;
	}
	public ims.ccosched.vo.lookups.Status getPatientStatus()
	{
		return this.patientstatus;
	}
	public void setPatientStatus(ims.ccosched.vo.lookups.Status value)
	{
		this.isValidated = false;
		this.patientstatus = value;
	}
	public boolean getAuthUserIsNotNull()
	{
		return this.authuser != null;
	}
	public ims.core.clinical.vo.AuthoringInformationRefVo getAuthUser()
	{
		return this.authuser;
	}
	public void setAuthUser(ims.core.clinical.vo.AuthoringInformationRefVo value)
	{
		this.isValidated = false;
		this.authuser = value;
	}
	public boolean getModuIsNotNull()
	{
		return this.modu != null;
	}
	public Integer getModu()
	{
		return this.modu;
	}
	public void setModu(Integer value)
	{
		this.isValidated = false;
		this.modu = value;
	}
	public boolean getSurgeryRequiredIsNotNull()
	{
		return this.surgeryrequired != null;
	}
	public ims.oncology.vo.lookups.SurgeryRequired getSurgeryRequired()
	{
		return this.surgeryrequired;
	}
	public void setSurgeryRequired(ims.oncology.vo.lookups.SurgeryRequired value)
	{
		this.isValidated = false;
		this.surgeryrequired = value;
	}
	public boolean getSeenLocationIsNotNull()
	{
		return this.seenlocation != null;
	}
	public ims.ccosched.vo.lookups.SeenAt getSeenLocation()
	{
		return this.seenlocation;
	}
	public void setSeenLocation(ims.ccosched.vo.lookups.SeenAt value)
	{
		this.isValidated = false;
		this.seenlocation = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.actions != null)
		{
			if(!this.actions.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.actions != null)
		{
			String[] listOfOtherErrors = this.actions.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.treatmentplancomment != null)
			if(this.treatmentplancomment.length() > 255)
				listOfErrors.add("The length of the field [treatmentplancomment] in the value object [ims.ccosched.vo.PatTreatmentPlanVo] is too big. It should be less or equal to 255");
		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;
	
		PatTreatmentPlanVo clone = new PatTreatmentPlanVo(this.id, this.version);
		
		if(this.treatmentintent == null)
			clone.treatmentintent = null;
		else
			clone.treatmentintent = (ims.ccosched.vo.lookups.TreatmentIntent)this.treatmentintent.clone();
		if(this.dateseen == null)
			clone.dateseen = null;
		else
			clone.dateseen = (ims.framework.utils.Date)this.dateseen.clone();
		if(this.decisiontotreat == null)
			clone.decisiontotreat = null;
		else
			clone.decisiontotreat = (ims.framework.utils.Date)this.decisiontotreat.clone();
		if(this.actions == null)
			clone.actions = null;
		else
			clone.actions = (ims.ccosched.vo.PatTreatPlanActionVoCollection)this.actions.clone();
		clone.patient = this.patient;
		clone.pkey = this.pkey;
		clone.rkey = this.rkey;
		clone.episode = this.episode;
		clone.treatmentplancomment = this.treatmentplancomment;
		clone.activestatus = this.activestatus;
		if(this.consultant == null)
			clone.consultant = null;
		else
			clone.consultant = (ims.core.vo.HcpLiteVo)this.consultant.clone();
		if(this.sysinfo == null)
			clone.sysinfo = null;
		else
			clone.sysinfo = (ims.vo.SystemInformation)this.sysinfo.clone();
		if(this.primarytumourhistology == null)
			clone.primarytumourhistology = null;
		else
			clone.primarytumourhistology = (ims.clinicaladmin.vo.TumourHistologyLiteVo)this.primarytumourhistology.clone();
		if(this.ecad_date == null)
			clone.ecad_date = null;
		else
			clone.ecad_date = (ims.framework.utils.Date)this.ecad_date.clone();
		if(this.primarytumourgroup == null)
			clone.primarytumourgroup = null;
		else
			clone.primarytumourgroup = (ims.clinicaladmin.vo.TumourGroupLiteVo)this.primarytumourgroup.clone();
		if(this.primarytumoursite == null)
			clone.primarytumoursite = null;
		else
			clone.primarytumoursite = (ims.clinicaladmin.vo.TumourSiteLiteVo)this.primarytumoursite.clone();
		if(this.treatmentsites == null)
			clone.treatmentsites = null;
		else
			clone.treatmentsites = (ims.oncology.vo.lookups.TreatmentGroupSiteCollection)this.treatmentsites.clone();
		clone.creationuser = this.creationuser;
		if(this.patientstatus == null)
			clone.patientstatus = null;
		else
			clone.patientstatus = (ims.ccosched.vo.lookups.Status)this.patientstatus.clone();
		clone.authuser = this.authuser;
		clone.modu = this.modu;
		if(this.surgeryrequired == null)
			clone.surgeryrequired = null;
		else
			clone.surgeryrequired = (ims.oncology.vo.lookups.SurgeryRequired)this.surgeryrequired.clone();
		if(this.seenlocation == null)
			clone.seenlocation = null;
		else
			clone.seenlocation = (ims.ccosched.vo.lookups.SeenAt)this.seenlocation.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 (!(PatTreatmentPlanVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A PatTreatmentPlanVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((PatTreatmentPlanVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((PatTreatmentPlanVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = super.countFieldsWithValue();
		if(this.creationuser != null)
			count++;
		if(this.patientstatus != null)
			count++;
		if(this.authuser != null)
			count++;
		if(this.modu != null)
			count++;
		if(this.surgeryrequired != null)
			count++;
		if(this.seenlocation != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return super.countValueObjectFields() + 6;
	}
	protected ims.core.resource.people.vo.MemberOfStaffRefVo creationuser;
	protected ims.ccosched.vo.lookups.Status patientstatus;
	protected ims.core.clinical.vo.AuthoringInformationRefVo authuser;
	protected Integer modu;
	protected ims.oncology.vo.lookups.SurgeryRequired surgeryrequired;
	protected ims.ccosched.vo.lookups.SeenAt seenlocation;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
