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

	public SurgicalAuditCancelOperationVo()
	{
	}
	public SurgicalAuditCancelOperationVo(Integer id, int version)
	{
		super(id, version);
	}
	public SurgicalAuditCancelOperationVo(ims.clinical.vo.beans.SurgicalAuditCancelOperationVoBean 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.carecontext = bean.getCareContext() == null ? null : new ims.core.admin.vo.CareContextRefVo(new Integer(bean.getCareContext().getId()), bean.getCareContext().getVersion());
		this.authoringinformation = bean.getAuthoringInformation() == null ? null : bean.getAuthoringInformation().buildVo();
		this.operationcancelled = bean.getOperationCancelled();
		this.reasonforcancellation = bean.getReasonForCancellation() == null ? null : ims.clinical.vo.lookups.OperationCancellationReason.buildLookup(bean.getReasonForCancellation());
		this.reasonforcancellationcomment = bean.getReasonForCancellationComment();
		this.operationcancelledby = bean.getOperationCancelledBy() == null ? null : bean.getOperationCancelledBy().buildVo();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.clinical.vo.beans.SurgicalAuditCancelOperationVoBean 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.carecontext = bean.getCareContext() == null ? null : new ims.core.admin.vo.CareContextRefVo(new Integer(bean.getCareContext().getId()), bean.getCareContext().getVersion());
		this.authoringinformation = bean.getAuthoringInformation() == null ? null : bean.getAuthoringInformation().buildVo(map);
		this.operationcancelled = bean.getOperationCancelled();
		this.reasonforcancellation = bean.getReasonForCancellation() == null ? null : ims.clinical.vo.lookups.OperationCancellationReason.buildLookup(bean.getReasonForCancellation());
		this.reasonforcancellationcomment = bean.getReasonForCancellationComment();
		this.operationcancelledby = bean.getOperationCancelledBy() == null ? null : bean.getOperationCancelledBy().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.SurgicalAuditCancelOperationVoBean bean = null;
		if(map != null)
			bean = (ims.clinical.vo.beans.SurgicalAuditCancelOperationVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.clinical.vo.beans.SurgicalAuditCancelOperationVoBean();
			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("CARECONTEXT"))
			return getCareContext();
		if(fieldName.equals("AUTHORINGINFORMATION"))
			return getAuthoringInformation();
		if(fieldName.equals("OPERATIONCANCELLED"))
			return getOperationCancelled();
		if(fieldName.equals("REASONFORCANCELLATION"))
			return getReasonForCancellation();
		if(fieldName.equals("REASONFORCANCELLATIONCOMMENT"))
			return getReasonForCancellationComment();
		if(fieldName.equals("OPERATIONCANCELLEDBY"))
			return getOperationCancelledBy();
		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 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 getAuthoringInformationIsNotNull()
	{
		return this.authoringinformation != null;
	}
	public ims.core.vo.AuthoringInformationVo getAuthoringInformation()
	{
		return this.authoringinformation;
	}
	public void setAuthoringInformation(ims.core.vo.AuthoringInformationVo value)
	{
		this.isValidated = false;
		this.authoringinformation = value;
	}
	public boolean getOperationCancelledIsNotNull()
	{
		return this.operationcancelled != null;
	}
	public Boolean getOperationCancelled()
	{
		return this.operationcancelled;
	}
	public void setOperationCancelled(Boolean value)
	{
		this.isValidated = false;
		this.operationcancelled = value;
	}
	public boolean getReasonForCancellationIsNotNull()
	{
		return this.reasonforcancellation != null;
	}
	public ims.clinical.vo.lookups.OperationCancellationReason getReasonForCancellation()
	{
		return this.reasonforcancellation;
	}
	public void setReasonForCancellation(ims.clinical.vo.lookups.OperationCancellationReason value)
	{
		this.isValidated = false;
		this.reasonforcancellation = value;
	}
	public boolean getReasonForCancellationCommentIsNotNull()
	{
		return this.reasonforcancellationcomment != null;
	}
	public String getReasonForCancellationComment()
	{
		return this.reasonforcancellationcomment;
	}
	public static int getReasonForCancellationCommentMaxLength()
	{
		return 100;
	}
	public void setReasonForCancellationComment(String value)
	{
		this.isValidated = false;
		this.reasonforcancellationcomment = value;
	}
	public boolean getOperationCancelledByIsNotNull()
	{
		return this.operationcancelledby != null;
	}
	public ims.core.vo.HcpLiteVo getOperationCancelledBy()
	{
		return this.operationcancelledby;
	}
	public void setOperationCancelledBy(ims.core.vo.HcpLiteVo value)
	{
		this.isValidated = false;
		this.operationcancelledby = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.authoringinformation != null)
		{
			if(!this.authoringinformation.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.carecontext == null)
			listOfErrors.add("CareContext is mandatory");
		if(this.authoringinformation == null)
			listOfErrors.add("AuthoringInformation is mandatory");
		if(this.authoringinformation != null)
		{
			String[] listOfOtherErrors = this.authoringinformation.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.operationcancelled == null)
			listOfErrors.add("OperationCancelled is mandatory");
		if(this.reasonforcancellation == null)
			listOfErrors.add("ReasonForCancellation is mandatory");
		if(this.reasonforcancellationcomment != null)
			if(this.reasonforcancellationcomment.length() > 100)
				listOfErrors.add("The length of the field [reasonforcancellationcomment] in the value object [ims.clinical.vo.SurgicalAuditCancelOperationVo] is too big. It should be less or equal to 100");
		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;
	
		SurgicalAuditCancelOperationVo clone = new SurgicalAuditCancelOperationVo(this.id, this.version);
		
		clone.patient = this.patient;
		clone.carecontext = this.carecontext;
		if(this.authoringinformation == null)
			clone.authoringinformation = null;
		else
			clone.authoringinformation = (ims.core.vo.AuthoringInformationVo)this.authoringinformation.clone();
		clone.operationcancelled = this.operationcancelled;
		if(this.reasonforcancellation == null)
			clone.reasonforcancellation = null;
		else
			clone.reasonforcancellation = (ims.clinical.vo.lookups.OperationCancellationReason)this.reasonforcancellation.clone();
		clone.reasonforcancellationcomment = this.reasonforcancellationcomment;
		if(this.operationcancelledby == null)
			clone.operationcancelledby = null;
		else
			clone.operationcancelledby = (ims.core.vo.HcpLiteVo)this.operationcancelledby.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 (!(SurgicalAuditCancelOperationVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A SurgicalAuditCancelOperationVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((SurgicalAuditCancelOperationVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((SurgicalAuditCancelOperationVo)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.carecontext != null)
			count++;
		if(this.authoringinformation != null)
			count++;
		if(this.operationcancelled != null)
			count++;
		if(this.reasonforcancellation != null)
			count++;
		if(this.reasonforcancellationcomment != null)
			count++;
		if(this.operationcancelledby != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 7;
	}
	protected ims.core.patient.vo.PatientRefVo patient;
	protected ims.core.admin.vo.CareContextRefVo carecontext;
	protected ims.core.vo.AuthoringInformationVo authoringinformation;
	protected Boolean operationcancelled;
	protected ims.clinical.vo.lookups.OperationCancellationReason reasonforcancellation;
	protected String reasonforcancellationcomment;
	protected ims.core.vo.HcpLiteVo operationcancelledby;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
