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

	public SurgicalAuditActualProcedureVo()
	{
	}
	public SurgicalAuditActualProcedureVo(Integer id, int version)
	{
		super(id, version);
	}
	public SurgicalAuditActualProcedureVo(ims.clinical.vo.beans.SurgicalAuditActualProcedureVoBean 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.plannedactualprocedures = ims.clinical.vo.PatientProcedureForSurgicalAuditPreOpChecksVoCollection.buildFromBeanCollection(bean.getPlannedActualProcedures());
		this.surgicalpacks = ims.clinical.vo.SurgicalAuditSurgicalPackVoCollection.buildFromBeanCollection(bean.getSurgicalPacks());
		this.anaesthetistsstarttime = bean.getAnaesthetistsStartTime() == null ? null : bean.getAnaesthetistsStartTime().buildDateTime();
		this.surgerystarttime = bean.getSurgeryStartTime() == null ? null : bean.getSurgeryStartTime().buildDateTime();
		this.surgeryfinishtime = bean.getSurgeryFinishTime() == null ? null : bean.getSurgeryFinishTime().buildDateTime();
		this.anaesthetistsfinishtime = bean.getAnaesthetistsFinishTime() == null ? null : bean.getAnaesthetistsFinishTime().buildDateTime();
		this.sent = bean.getSent() == null ? null : bean.getSent().buildVo();
		this.timelefttheatre = bean.getTimeLeftTheatre() == null ? null : bean.getTimeLeftTheatre().buildDateTime();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.clinical.vo.beans.SurgicalAuditActualProcedureVoBean 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.plannedactualprocedures = ims.clinical.vo.PatientProcedureForSurgicalAuditPreOpChecksVoCollection.buildFromBeanCollection(bean.getPlannedActualProcedures());
		this.surgicalpacks = ims.clinical.vo.SurgicalAuditSurgicalPackVoCollection.buildFromBeanCollection(bean.getSurgicalPacks());
		this.anaesthetistsstarttime = bean.getAnaesthetistsStartTime() == null ? null : bean.getAnaesthetistsStartTime().buildDateTime();
		this.surgerystarttime = bean.getSurgeryStartTime() == null ? null : bean.getSurgeryStartTime().buildDateTime();
		this.surgeryfinishtime = bean.getSurgeryFinishTime() == null ? null : bean.getSurgeryFinishTime().buildDateTime();
		this.anaesthetistsfinishtime = bean.getAnaesthetistsFinishTime() == null ? null : bean.getAnaesthetistsFinishTime().buildDateTime();
		this.sent = bean.getSent() == null ? null : bean.getSent().buildVo(map);
		this.timelefttheatre = bean.getTimeLeftTheatre() == null ? null : bean.getTimeLeftTheatre().buildDateTime();
	}
	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.SurgicalAuditActualProcedureVoBean bean = null;
		if(map != null)
			bean = (ims.clinical.vo.beans.SurgicalAuditActualProcedureVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.clinical.vo.beans.SurgicalAuditActualProcedureVoBean();
			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("PLANNEDACTUALPROCEDURES"))
			return getPlannedActualProcedures();
		if(fieldName.equals("SURGICALPACKS"))
			return getSurgicalPacks();
		if(fieldName.equals("ANAESTHETISTSSTARTTIME"))
			return getAnaesthetistsStartTime();
		if(fieldName.equals("SURGERYSTARTTIME"))
			return getSurgeryStartTime();
		if(fieldName.equals("SURGERYFINISHTIME"))
			return getSurgeryFinishTime();
		if(fieldName.equals("ANAESTHETISTSFINISHTIME"))
			return getAnaesthetistsFinishTime();
		if(fieldName.equals("SENT"))
			return getSent();
		if(fieldName.equals("TIMELEFTTHEATRE"))
			return getTimeLeftTheatre();
		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 getPlannedActualProceduresIsNotNull()
	{
		return this.plannedactualprocedures != null;
	}
	public ims.clinical.vo.PatientProcedureForSurgicalAuditPreOpChecksVoCollection getPlannedActualProcedures()
	{
		return this.plannedactualprocedures;
	}
	public void setPlannedActualProcedures(ims.clinical.vo.PatientProcedureForSurgicalAuditPreOpChecksVoCollection value)
	{
		this.isValidated = false;
		this.plannedactualprocedures = value;
	}
	public boolean getSurgicalPacksIsNotNull()
	{
		return this.surgicalpacks != null;
	}
	public ims.clinical.vo.SurgicalAuditSurgicalPackVoCollection getSurgicalPacks()
	{
		return this.surgicalpacks;
	}
	public void setSurgicalPacks(ims.clinical.vo.SurgicalAuditSurgicalPackVoCollection value)
	{
		this.isValidated = false;
		this.surgicalpacks = value;
	}
	public boolean getAnaesthetistsStartTimeIsNotNull()
	{
		return this.anaesthetistsstarttime != null;
	}
	public ims.framework.utils.DateTime getAnaesthetistsStartTime()
	{
		return this.anaesthetistsstarttime;
	}
	public void setAnaesthetistsStartTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.anaesthetistsstarttime = value;
	}
	public boolean getSurgeryStartTimeIsNotNull()
	{
		return this.surgerystarttime != null;
	}
	public ims.framework.utils.DateTime getSurgeryStartTime()
	{
		return this.surgerystarttime;
	}
	public void setSurgeryStartTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.surgerystarttime = value;
	}
	public boolean getSurgeryFinishTimeIsNotNull()
	{
		return this.surgeryfinishtime != null;
	}
	public ims.framework.utils.DateTime getSurgeryFinishTime()
	{
		return this.surgeryfinishtime;
	}
	public void setSurgeryFinishTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.surgeryfinishtime = value;
	}
	public boolean getAnaesthetistsFinishTimeIsNotNull()
	{
		return this.anaesthetistsfinishtime != null;
	}
	public ims.framework.utils.DateTime getAnaesthetistsFinishTime()
	{
		return this.anaesthetistsfinishtime;
	}
	public void setAnaesthetistsFinishTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.anaesthetistsfinishtime = value;
	}
	public boolean getSentIsNotNull()
	{
		return this.sent != null;
	}
	public ims.core.vo.LocationLiteVo getSent()
	{
		return this.sent;
	}
	public void setSent(ims.core.vo.LocationLiteVo value)
	{
		this.isValidated = false;
		this.sent = value;
	}
	public boolean getTimeLeftTheatreIsNotNull()
	{
		return this.timelefttheatre != null;
	}
	public ims.framework.utils.DateTime getTimeLeftTheatre()
	{
		return this.timelefttheatre;
	}
	public void setTimeLeftTheatre(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.timelefttheatre = 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;
			}
		}
		if(this.plannedactualprocedures != null)
		{
			if(!this.plannedactualprocedures.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.surgicalpacks != null)
		{
			if(!this.surgicalpacks.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.plannedactualprocedures == null || this.plannedactualprocedures.size() == 0)
			listOfErrors.add("PlannedActualProcedures are mandatory");
		if(this.plannedactualprocedures != null)
		{
			String[] listOfOtherErrors = this.plannedactualprocedures.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.surgicalpacks == null || this.surgicalpacks.size() == 0)
			listOfErrors.add("SurgicalPacks are mandatory");
		if(this.surgicalpacks != null)
		{
			String[] listOfOtherErrors = this.surgicalpacks.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.anaesthetistsstarttime == null)
			listOfErrors.add("AnaesthetistsStartTime is mandatory");
		if(this.surgerystarttime == null)
			listOfErrors.add("SurgeryStartTime is mandatory");
		if(this.surgeryfinishtime == null)
			listOfErrors.add("SurgeryFinishTime is mandatory");
		if(this.anaesthetistsfinishtime == null)
			listOfErrors.add("AnaesthetistsFinishTime is mandatory");
		if(this.sent == null)
			listOfErrors.add("Sent is mandatory");
		if(this.timelefttheatre == null)
			listOfErrors.add("TimeLeftTheatre is mandatory");
		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;
	
		SurgicalAuditActualProcedureVo clone = new SurgicalAuditActualProcedureVo(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();
		if(this.plannedactualprocedures == null)
			clone.plannedactualprocedures = null;
		else
			clone.plannedactualprocedures = (ims.clinical.vo.PatientProcedureForSurgicalAuditPreOpChecksVoCollection)this.plannedactualprocedures.clone();
		if(this.surgicalpacks == null)
			clone.surgicalpacks = null;
		else
			clone.surgicalpacks = (ims.clinical.vo.SurgicalAuditSurgicalPackVoCollection)this.surgicalpacks.clone();
		if(this.anaesthetistsstarttime == null)
			clone.anaesthetistsstarttime = null;
		else
			clone.anaesthetistsstarttime = (ims.framework.utils.DateTime)this.anaesthetistsstarttime.clone();
		if(this.surgerystarttime == null)
			clone.surgerystarttime = null;
		else
			clone.surgerystarttime = (ims.framework.utils.DateTime)this.surgerystarttime.clone();
		if(this.surgeryfinishtime == null)
			clone.surgeryfinishtime = null;
		else
			clone.surgeryfinishtime = (ims.framework.utils.DateTime)this.surgeryfinishtime.clone();
		if(this.anaesthetistsfinishtime == null)
			clone.anaesthetistsfinishtime = null;
		else
			clone.anaesthetistsfinishtime = (ims.framework.utils.DateTime)this.anaesthetistsfinishtime.clone();
		if(this.sent == null)
			clone.sent = null;
		else
			clone.sent = (ims.core.vo.LocationLiteVo)this.sent.clone();
		if(this.timelefttheatre == null)
			clone.timelefttheatre = null;
		else
			clone.timelefttheatre = (ims.framework.utils.DateTime)this.timelefttheatre.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 (!(SurgicalAuditActualProcedureVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A SurgicalAuditActualProcedureVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((SurgicalAuditActualProcedureVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((SurgicalAuditActualProcedureVo)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.plannedactualprocedures != null)
			count++;
		if(this.surgicalpacks != null)
			count++;
		if(this.anaesthetistsstarttime != null)
			count++;
		if(this.surgerystarttime != null)
			count++;
		if(this.surgeryfinishtime != null)
			count++;
		if(this.anaesthetistsfinishtime != null)
			count++;
		if(this.sent != null)
			count++;
		if(this.timelefttheatre != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 11;
	}
	protected ims.core.patient.vo.PatientRefVo patient;
	protected ims.core.admin.vo.CareContextRefVo carecontext;
	protected ims.core.vo.AuthoringInformationVo authoringinformation;
	protected ims.clinical.vo.PatientProcedureForSurgicalAuditPreOpChecksVoCollection plannedactualprocedures;
	protected ims.clinical.vo.SurgicalAuditSurgicalPackVoCollection surgicalpacks;
	protected ims.framework.utils.DateTime anaesthetistsstarttime;
	protected ims.framework.utils.DateTime surgerystarttime;
	protected ims.framework.utils.DateTime surgeryfinishtime;
	protected ims.framework.utils.DateTime anaesthetistsfinishtime;
	protected ims.core.vo.LocationLiteVo sent;
	protected ims.framework.utils.DateTime timelefttheatre;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
