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

/**
 * Linked to nursing.care plans.Care Plan Template Intervention business object (ID: 1010100002).
 */
public class CarePlanTemplateIntervention extends ims.nursing.careplans.vo.CarePlanTemplateInterventionRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public CarePlanTemplateIntervention()
	{
	}
	public CarePlanTemplateIntervention(Integer id, int version)
	{
		super(id, version);
	}
	public CarePlanTemplateIntervention(ims.nursing.vo.beans.CarePlanTemplateInterventionBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.intervention = bean.getIntervention();
		this.interventiontype = bean.getInterventionType() == null ? null : ims.nursing.vo.lookups.CarePlanInterventionManOpt.buildLookup(bean.getInterventionType());
		this.interventionnumber = bean.getInterventionNumber();
		this.active = bean.getActive();
		this.dateinactive = bean.getDateInactive() == null ? null : bean.getDateInactive().buildDate();
		this.frequency = bean.getFrequency() == null ? null : ims.nursing.vo.lookups.CPActionFrequency.buildLookup(bean.getFrequency());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.nursing.vo.beans.CarePlanTemplateInterventionBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.intervention = bean.getIntervention();
		this.interventiontype = bean.getInterventionType() == null ? null : ims.nursing.vo.lookups.CarePlanInterventionManOpt.buildLookup(bean.getInterventionType());
		this.interventionnumber = bean.getInterventionNumber();
		this.active = bean.getActive();
		this.dateinactive = bean.getDateInactive() == null ? null : bean.getDateInactive().buildDate();
		this.frequency = bean.getFrequency() == null ? null : ims.nursing.vo.lookups.CPActionFrequency.buildLookup(bean.getFrequency());
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.nursing.vo.beans.CarePlanTemplateInterventionBean bean = null;
		if(map != null)
			bean = (ims.nursing.vo.beans.CarePlanTemplateInterventionBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.nursing.vo.beans.CarePlanTemplateInterventionBean();
			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("INTERVENTION"))
			return getIntervention();
		if(fieldName.equals("INTERVENTIONTYPE"))
			return getInterventionType();
		if(fieldName.equals("INTERVENTIONNUMBER"))
			return getInterventionNumber();
		if(fieldName.equals("ACTIVE"))
			return getActive();
		if(fieldName.equals("DATEINACTIVE"))
			return getDateInactive();
		if(fieldName.equals("FREQUENCY"))
			return getFrequency();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getInterventionIsNotNull()
	{
		return this.intervention != null;
	}
	public String getIntervention()
	{
		return this.intervention;
	}
	public static int getInterventionMaxLength()
	{
		return 255;
	}
	public void setIntervention(String value)
	{
		this.isValidated = false;
		this.intervention = value;
	}
	public boolean getInterventionTypeIsNotNull()
	{
		return this.interventiontype != null;
	}
	public ims.nursing.vo.lookups.CarePlanInterventionManOpt getInterventionType()
	{
		return this.interventiontype;
	}
	public void setInterventionType(ims.nursing.vo.lookups.CarePlanInterventionManOpt value)
	{
		this.isValidated = false;
		this.interventiontype = value;
	}
	public boolean getInterventionNumberIsNotNull()
	{
		return this.interventionnumber != null;
	}
	public Integer getInterventionNumber()
	{
		return this.interventionnumber;
	}
	public void setInterventionNumber(Integer value)
	{
		this.isValidated = false;
		this.interventionnumber = value;
	}
	public boolean getActiveIsNotNull()
	{
		return this.active != null;
	}
	public Boolean getActive()
	{
		return this.active;
	}
	public void setActive(Boolean value)
	{
		this.isValidated = false;
		this.active = value;
	}
	public boolean getDateInactiveIsNotNull()
	{
		return this.dateinactive != null;
	}
	public ims.framework.utils.Date getDateInactive()
	{
		return this.dateinactive;
	}
	public void setDateInactive(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.dateinactive = value;
	}
	public boolean getFrequencyIsNotNull()
	{
		return this.frequency != null;
	}
	public ims.nursing.vo.lookups.CPActionFrequency getFrequency()
	{
		return this.frequency;
	}
	public void setFrequency(ims.nursing.vo.lookups.CPActionFrequency value)
	{
		this.isValidated = false;
		this.frequency = 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.intervention != null)
			if(this.intervention.length() > 255)
				listOfErrors.add("The length of the field [intervention] in the value object [ims.nursing.vo.CarePlanTemplateIntervention] 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;
	
		CarePlanTemplateIntervention clone = new CarePlanTemplateIntervention(this.id, this.version);
		
		clone.intervention = this.intervention;
		if(this.interventiontype == null)
			clone.interventiontype = null;
		else
			clone.interventiontype = (ims.nursing.vo.lookups.CarePlanInterventionManOpt)this.interventiontype.clone();
		clone.interventionnumber = this.interventionnumber;
		clone.active = this.active;
		if(this.dateinactive == null)
			clone.dateinactive = null;
		else
			clone.dateinactive = (ims.framework.utils.Date)this.dateinactive.clone();
		if(this.frequency == null)
			clone.frequency = null;
		else
			clone.frequency = (ims.nursing.vo.lookups.CPActionFrequency)this.frequency.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 (!(CarePlanTemplateIntervention.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A CarePlanTemplateIntervention object cannot be compared an Object of type " + obj.getClass().getName());
		}
		CarePlanTemplateIntervention compareObj = (CarePlanTemplateIntervention)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getInterventionNumber() == null && compareObj.getInterventionNumber() != null)
				return -1;
			if(this.getInterventionNumber() != null && compareObj.getInterventionNumber() == null)
				return 1;
			if(this.getInterventionNumber() != null && compareObj.getInterventionNumber() != null)
				retVal = this.getInterventionNumber().compareTo(compareObj.getInterventionNumber());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.intervention != null)
			count++;
		if(this.interventiontype != null)
			count++;
		if(this.interventionnumber != null)
			count++;
		if(this.active != null)
			count++;
		if(this.dateinactive != null)
			count++;
		if(this.frequency != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 6;
	}
	protected String intervention;
	protected ims.nursing.vo.lookups.CarePlanInterventionManOpt interventiontype;
	protected Integer interventionnumber;
	protected Boolean active;
	protected ims.framework.utils.Date dateinactive;
	protected ims.nursing.vo.lookups.CPActionFrequency frequency;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
