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

	public SurgicalOperationNotesVo()
	{
	}
	public SurgicalOperationNotesVo(Integer id, int version)
	{
		super(id, version);
	}
	public SurgicalOperationNotesVo(ims.clinical.vo.beans.SurgicalOperationNotesVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.authoringinfo = bean.getAuthoringInfo() == null ? null : bean.getAuthoringInfo().buildVo();
		this.carecontext = bean.getCareContext() == null ? null : new ims.core.admin.vo.CareContextRefVo(new Integer(bean.getCareContext().getId()), bean.getCareContext().getVersion());
		this.signoffhcp = bean.getSignOffHCP() == null ? null : bean.getSignOffHCP().buildVo();
		this.signoffdatetime = bean.getSignOffDateTime() == null ? null : bean.getSignOffDateTime().buildDateTime();
		this.proceduresperformed = ims.core.vo.PatientProcedureVoCollection.buildFromBeanCollection(bean.getProceduresPerformed());
		this.patientdiagnoses = ims.core.vo.PatientDiagnosisVoCollection.buildFromBeanCollection(bean.getPatientDiagnoses());
		this.mainprocedure = bean.getMainProcedure() == null ? null : bean.getMainProcedure().buildVo();
		this.surgicalopnotedocument = bean.getSurgicalOpNoteDocument() == null ? null : bean.getSurgicalOpNoteDocument().buildVo();
		this.diagram = bean.getDiagram() == null ? null : bean.getDiagram().buildVo();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.clinical.vo.beans.SurgicalOperationNotesVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.authoringinfo = bean.getAuthoringInfo() == null ? null : bean.getAuthoringInfo().buildVo(map);
		this.carecontext = bean.getCareContext() == null ? null : new ims.core.admin.vo.CareContextRefVo(new Integer(bean.getCareContext().getId()), bean.getCareContext().getVersion());
		this.signoffhcp = bean.getSignOffHCP() == null ? null : bean.getSignOffHCP().buildVo(map);
		this.signoffdatetime = bean.getSignOffDateTime() == null ? null : bean.getSignOffDateTime().buildDateTime();
		this.proceduresperformed = ims.core.vo.PatientProcedureVoCollection.buildFromBeanCollection(bean.getProceduresPerformed());
		this.patientdiagnoses = ims.core.vo.PatientDiagnosisVoCollection.buildFromBeanCollection(bean.getPatientDiagnoses());
		this.mainprocedure = bean.getMainProcedure() == null ? null : bean.getMainProcedure().buildVo(map);
		this.surgicalopnotedocument = bean.getSurgicalOpNoteDocument() == null ? null : bean.getSurgicalOpNoteDocument().buildVo(map);
		this.diagram = bean.getDiagram() == null ? null : bean.getDiagram().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.SurgicalOperationNotesVoBean bean = null;
		if(map != null)
			bean = (ims.clinical.vo.beans.SurgicalOperationNotesVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.clinical.vo.beans.SurgicalOperationNotesVoBean();
			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("AUTHORINGINFO"))
			return getAuthoringInfo();
		if(fieldName.equals("CARECONTEXT"))
			return getCareContext();
		if(fieldName.equals("SIGNOFFHCP"))
			return getSignOffHCP();
		if(fieldName.equals("SIGNOFFDATETIME"))
			return getSignOffDateTime();
		if(fieldName.equals("PROCEDURESPERFORMED"))
			return getProceduresPerformed();
		if(fieldName.equals("PATIENTDIAGNOSES"))
			return getPatientDiagnoses();
		if(fieldName.equals("MAINPROCEDURE"))
			return getMainProcedure();
		if(fieldName.equals("SURGICALOPNOTEDOCUMENT"))
			return getSurgicalOpNoteDocument();
		if(fieldName.equals("DIAGRAM"))
			return getDiagram();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getAuthoringInfoIsNotNull()
	{
		return this.authoringinfo != null;
	}
	public ims.core.vo.AuthoringInformationVo getAuthoringInfo()
	{
		return this.authoringinfo;
	}
	public void setAuthoringInfo(ims.core.vo.AuthoringInformationVo value)
	{
		this.isValidated = false;
		this.authoringinfo = 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 getSignOffHCPIsNotNull()
	{
		return this.signoffhcp != null;
	}
	public ims.core.vo.HcpLiteVo getSignOffHCP()
	{
		return this.signoffhcp;
	}
	public void setSignOffHCP(ims.core.vo.HcpLiteVo value)
	{
		this.isValidated = false;
		this.signoffhcp = value;
	}
	public boolean getSignOffDateTimeIsNotNull()
	{
		return this.signoffdatetime != null;
	}
	public ims.framework.utils.DateTime getSignOffDateTime()
	{
		return this.signoffdatetime;
	}
	public void setSignOffDateTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.signoffdatetime = value;
	}
	public boolean getProceduresPerformedIsNotNull()
	{
		return this.proceduresperformed != null;
	}
	public ims.core.vo.PatientProcedureVoCollection getProceduresPerformed()
	{
		return this.proceduresperformed;
	}
	public void setProceduresPerformed(ims.core.vo.PatientProcedureVoCollection value)
	{
		this.isValidated = false;
		this.proceduresperformed = value;
	}
	public boolean getPatientDiagnosesIsNotNull()
	{
		return this.patientdiagnoses != null;
	}
	public ims.core.vo.PatientDiagnosisVoCollection getPatientDiagnoses()
	{
		return this.patientdiagnoses;
	}
	public void setPatientDiagnoses(ims.core.vo.PatientDiagnosisVoCollection value)
	{
		this.isValidated = false;
		this.patientdiagnoses = value;
	}
	public boolean getMainProcedureIsNotNull()
	{
		return this.mainprocedure != null;
	}
	public ims.core.vo.PatientProcedureVo getMainProcedure()
	{
		return this.mainprocedure;
	}
	public void setMainProcedure(ims.core.vo.PatientProcedureVo value)
	{
		this.isValidated = false;
		this.mainprocedure = value;
	}
	public boolean getSurgicalOpNoteDocumentIsNotNull()
	{
		return this.surgicalopnotedocument != null;
	}
	public ims.core.vo.PatientDocumentVo getSurgicalOpNoteDocument()
	{
		return this.surgicalopnotedocument;
	}
	public void setSurgicalOpNoteDocument(ims.core.vo.PatientDocumentVo value)
	{
		this.isValidated = false;
		this.surgicalopnotedocument = value;
	}
	public boolean getDiagramIsNotNull()
	{
		return this.diagram != null;
	}
	public ims.assessment.vo.PatientAssessmentLiteVo getDiagram()
	{
		return this.diagram;
	}
	public void setDiagram(ims.assessment.vo.PatientAssessmentLiteVo value)
	{
		this.isValidated = false;
		this.diagram = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.authoringinfo != null)
		{
			if(!this.authoringinfo.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.surgicalopnotedocument != null)
		{
			if(!this.surgicalopnotedocument.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.diagram != null)
		{
			if(!this.diagram.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.authoringinfo == null)
			listOfErrors.add("AuthoringInfo is mandatory");
		if(this.authoringinfo != null)
		{
			String[] listOfOtherErrors = this.authoringinfo.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.carecontext == null)
			listOfErrors.add("CareContext is mandatory");
		if(this.surgicalopnotedocument != null)
		{
			String[] listOfOtherErrors = this.surgicalopnotedocument.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.diagram != null)
		{
			String[] listOfOtherErrors = this.diagram.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;
	
		SurgicalOperationNotesVo clone = new SurgicalOperationNotesVo(this.id, this.version);
		
		if(this.authoringinfo == null)
			clone.authoringinfo = null;
		else
			clone.authoringinfo = (ims.core.vo.AuthoringInformationVo)this.authoringinfo.clone();
		clone.carecontext = this.carecontext;
		if(this.signoffhcp == null)
			clone.signoffhcp = null;
		else
			clone.signoffhcp = (ims.core.vo.HcpLiteVo)this.signoffhcp.clone();
		if(this.signoffdatetime == null)
			clone.signoffdatetime = null;
		else
			clone.signoffdatetime = (ims.framework.utils.DateTime)this.signoffdatetime.clone();
		if(this.proceduresperformed == null)
			clone.proceduresperformed = null;
		else
			clone.proceduresperformed = (ims.core.vo.PatientProcedureVoCollection)this.proceduresperformed.clone();
		if(this.patientdiagnoses == null)
			clone.patientdiagnoses = null;
		else
			clone.patientdiagnoses = (ims.core.vo.PatientDiagnosisVoCollection)this.patientdiagnoses.clone();
		if(this.mainprocedure == null)
			clone.mainprocedure = null;
		else
			clone.mainprocedure = (ims.core.vo.PatientProcedureVo)this.mainprocedure.clone();
		if(this.surgicalopnotedocument == null)
			clone.surgicalopnotedocument = null;
		else
			clone.surgicalopnotedocument = (ims.core.vo.PatientDocumentVo)this.surgicalopnotedocument.clone();
		if(this.diagram == null)
			clone.diagram = null;
		else
			clone.diagram = (ims.assessment.vo.PatientAssessmentLiteVo)this.diagram.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 (!(SurgicalOperationNotesVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A SurgicalOperationNotesVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((SurgicalOperationNotesVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((SurgicalOperationNotesVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.authoringinfo != null)
			count++;
		if(this.carecontext != null)
			count++;
		if(this.signoffhcp != null)
			count++;
		if(this.signoffdatetime != null)
			count++;
		if(this.proceduresperformed != null)
			count++;
		if(this.patientdiagnoses != null)
			count++;
		if(this.mainprocedure != null)
			count++;
		if(this.surgicalopnotedocument != null)
			count++;
		if(this.diagram != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 9;
	}
	protected ims.core.vo.AuthoringInformationVo authoringinfo;
	protected ims.core.admin.vo.CareContextRefVo carecontext;
	protected ims.core.vo.HcpLiteVo signoffhcp;
	protected ims.framework.utils.DateTime signoffdatetime;
	protected ims.core.vo.PatientProcedureVoCollection proceduresperformed;
	protected ims.core.vo.PatientDiagnosisVoCollection patientdiagnoses;
	protected ims.core.vo.PatientProcedureVo mainprocedure;
	protected ims.core.vo.PatientDocumentVo surgicalopnotedocument;
	protected ims.assessment.vo.PatientAssessmentLiteVo diagram;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
