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

/**
 * Linked to ICPs.Instantiation.PatientICPActionStatus business object (ID: 1100100006).
 */
public class PatientICPActionStatusVo extends ims.icps.instantiation.vo.PatientICPActionStatusRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public PatientICPActionStatusVo()
	{
	}
	public PatientICPActionStatusVo(Integer id, int version)
	{
		super(id, version);
	}
	public PatientICPActionStatusVo(ims.icp.vo.beans.PatientICPActionStatusVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.statusdate = bean.getStatusDate() == null ? null : bean.getStatusDate().buildDateTime();
		this.changedby = bean.getChangedBy() == null ? null : bean.getChangedBy().buildVo();
		this.status = bean.getStatus() == null ? null : ims.icp.vo.lookups.ICPActionStatus.buildLookup(bean.getStatus());
		this.variancecategory = bean.getVarianceCategory() == null ? null : ims.icp.vo.lookups.ICPVarianceType.buildLookup(bean.getVarianceCategory());
		this.variancetype = bean.getVarianceType() == null ? null : ims.icp.vo.lookups.ICPVarianceType.buildLookup(bean.getVarianceType());
		this.variancecomment = bean.getVarianceComment();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.icp.vo.beans.PatientICPActionStatusVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.statusdate = bean.getStatusDate() == null ? null : bean.getStatusDate().buildDateTime();
		this.changedby = bean.getChangedBy() == null ? null : bean.getChangedBy().buildVo(map);
		this.status = bean.getStatus() == null ? null : ims.icp.vo.lookups.ICPActionStatus.buildLookup(bean.getStatus());
		this.variancecategory = bean.getVarianceCategory() == null ? null : ims.icp.vo.lookups.ICPVarianceType.buildLookup(bean.getVarianceCategory());
		this.variancetype = bean.getVarianceType() == null ? null : ims.icp.vo.lookups.ICPVarianceType.buildLookup(bean.getVarianceType());
		this.variancecomment = bean.getVarianceComment();
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.icp.vo.beans.PatientICPActionStatusVoBean bean = null;
		if(map != null)
			bean = (ims.icp.vo.beans.PatientICPActionStatusVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.icp.vo.beans.PatientICPActionStatusVoBean();
			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("STATUSDATE"))
			return getStatusDate();
		if(fieldName.equals("CHANGEDBY"))
			return getChangedBy();
		if(fieldName.equals("STATUS"))
			return getStatus();
		if(fieldName.equals("VARIANCECATEGORY"))
			return getVarianceCategory();
		if(fieldName.equals("VARIANCETYPE"))
			return getVarianceType();
		if(fieldName.equals("VARIANCECOMMENT"))
			return getVarianceComment();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getStatusDateIsNotNull()
	{
		return this.statusdate != null;
	}
	public ims.framework.utils.DateTime getStatusDate()
	{
		return this.statusdate;
	}
	public void setStatusDate(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.statusdate = value;
	}
	public boolean getChangedByIsNotNull()
	{
		return this.changedby != null;
	}
	public ims.core.vo.MemberOfStaffLiteVo getChangedBy()
	{
		return this.changedby;
	}
	public void setChangedBy(ims.core.vo.MemberOfStaffLiteVo value)
	{
		this.isValidated = false;
		this.changedby = value;
	}
	public boolean getStatusIsNotNull()
	{
		return this.status != null;
	}
	public ims.icp.vo.lookups.ICPActionStatus getStatus()
	{
		return this.status;
	}
	public void setStatus(ims.icp.vo.lookups.ICPActionStatus value)
	{
		this.isValidated = false;
		this.status = value;
	}
	public boolean getVarianceCategoryIsNotNull()
	{
		return this.variancecategory != null;
	}
	public ims.icp.vo.lookups.ICPVarianceType getVarianceCategory()
	{
		return this.variancecategory;
	}
	public void setVarianceCategory(ims.icp.vo.lookups.ICPVarianceType value)
	{
		this.isValidated = false;
		this.variancecategory = value;
	}
	public boolean getVarianceTypeIsNotNull()
	{
		return this.variancetype != null;
	}
	public ims.icp.vo.lookups.ICPVarianceType getVarianceType()
	{
		return this.variancetype;
	}
	public void setVarianceType(ims.icp.vo.lookups.ICPVarianceType value)
	{
		this.isValidated = false;
		this.variancetype = value;
	}
	public boolean getVarianceCommentIsNotNull()
	{
		return this.variancecomment != null;
	}
	public String getVarianceComment()
	{
		return this.variancecomment;
	}
	public static int getVarianceCommentMaxLength()
	{
		return 500;
	}
	public void setVarianceComment(String value)
	{
		this.isValidated = false;
		this.variancecomment = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.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.statusdate == null)
			listOfErrors.add("StatusDate is mandatory");
		if(this.changedby == null)
			listOfErrors.add("ChangedBy is mandatory");
		if(this.status == null)
			listOfErrors.add("Status is mandatory");
		if(this.variancecomment != null)
			if(this.variancecomment.length() > 500)
				listOfErrors.add("The length of the field [variancecomment] in the value object [ims.icp.vo.PatientICPActionStatusVo] is too big. It should be less or equal to 500");
		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;
	
		PatientICPActionStatusVo clone = new PatientICPActionStatusVo(this.id, this.version);
		
		if(this.statusdate == null)
			clone.statusdate = null;
		else
			clone.statusdate = (ims.framework.utils.DateTime)this.statusdate.clone();
		if(this.changedby == null)
			clone.changedby = null;
		else
			clone.changedby = (ims.core.vo.MemberOfStaffLiteVo)this.changedby.clone();
		if(this.status == null)
			clone.status = null;
		else
			clone.status = (ims.icp.vo.lookups.ICPActionStatus)this.status.clone();
		if(this.variancecategory == null)
			clone.variancecategory = null;
		else
			clone.variancecategory = (ims.icp.vo.lookups.ICPVarianceType)this.variancecategory.clone();
		if(this.variancetype == null)
			clone.variancetype = null;
		else
			clone.variancetype = (ims.icp.vo.lookups.ICPVarianceType)this.variancetype.clone();
		clone.variancecomment = this.variancecomment;
		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 (!(PatientICPActionStatusVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A PatientICPActionStatusVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((PatientICPActionStatusVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((PatientICPActionStatusVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.statusdate != null)
			count++;
		if(this.changedby != null)
			count++;
		if(this.status != null)
			count++;
		if(this.variancecategory != null)
			count++;
		if(this.variancetype != null)
			count++;
		if(this.variancecomment != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 6;
	}
	protected ims.framework.utils.DateTime statusdate;
	protected ims.core.vo.MemberOfStaffLiteVo changedby;
	protected ims.icp.vo.lookups.ICPActionStatus status;
	protected ims.icp.vo.lookups.ICPVarianceType variancecategory;
	protected ims.icp.vo.lookups.ICPVarianceType variancetype;
	protected String variancecomment;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
