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

/**
 * Linked to core.vitals.VitalSigns business object (ID: 1022100004).
 */
public class VitalSignsForNursingNotesVo extends ims.core.vitals.vo.VitalSignsRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public VitalSignsForNursingNotesVo()
	{
	}
	public VitalSignsForNursingNotesVo(Integer id, int version)
	{
		super(id, version);
	}
	public VitalSignsForNursingNotesVo(ims.core.vo.beans.VitalSignsForNursingNotesVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.vitalstakendatetime = bean.getVitalsTakenDateTime() == null ? null : bean.getVitalsTakenDateTime().buildDateTime();
		this.bloodpressure = bean.getBloodPressure() == null ? null : bean.getBloodPressure().buildVo();
		this.pulse = bean.getPulse() == null ? null : bean.getPulse().buildVo();
		this.respiratory = bean.getRespiratory() == null ? null : bean.getRespiratory().buildVo();
		this.temperature = bean.getTemperature() == null ? null : bean.getTemperature().buildVo();
		this.metrics = bean.getMetrics() == null ? null : bean.getMetrics().buildVo();
		this.carecontext = bean.getCareContext() == null ? null : new ims.core.admin.vo.CareContextRefVo(new Integer(bean.getCareContext().getId()), bean.getCareContext().getVersion());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.VitalSignsForNursingNotesVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.vitalstakendatetime = bean.getVitalsTakenDateTime() == null ? null : bean.getVitalsTakenDateTime().buildDateTime();
		this.bloodpressure = bean.getBloodPressure() == null ? null : bean.getBloodPressure().buildVo(map);
		this.pulse = bean.getPulse() == null ? null : bean.getPulse().buildVo(map);
		this.respiratory = bean.getRespiratory() == null ? null : bean.getRespiratory().buildVo(map);
		this.temperature = bean.getTemperature() == null ? null : bean.getTemperature().buildVo(map);
		this.metrics = bean.getMetrics() == null ? null : bean.getMetrics().buildVo(map);
		this.carecontext = bean.getCareContext() == null ? null : new ims.core.admin.vo.CareContextRefVo(new Integer(bean.getCareContext().getId()), bean.getCareContext().getVersion());
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.core.vo.beans.VitalSignsForNursingNotesVoBean bean = null;
		if(map != null)
			bean = (ims.core.vo.beans.VitalSignsForNursingNotesVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.core.vo.beans.VitalSignsForNursingNotesVoBean();
			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("VITALSTAKENDATETIME"))
			return getVitalsTakenDateTime();
		if(fieldName.equals("BLOODPRESSURE"))
			return getBloodPressure();
		if(fieldName.equals("PULSE"))
			return getPulse();
		if(fieldName.equals("RESPIRATORY"))
			return getRespiratory();
		if(fieldName.equals("TEMPERATURE"))
			return getTemperature();
		if(fieldName.equals("METRICS"))
			return getMetrics();
		if(fieldName.equals("CARECONTEXT"))
			return getCareContext();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getVitalsTakenDateTimeIsNotNull()
	{
		return this.vitalstakendatetime != null;
	}
	public ims.framework.utils.DateTime getVitalsTakenDateTime()
	{
		return this.vitalstakendatetime;
	}
	public void setVitalsTakenDateTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.vitalstakendatetime = value;
	}
	public boolean getBloodPressureIsNotNull()
	{
		return this.bloodpressure != null;
	}
	public ims.core.vo.BloodPressureForNursingNotesVo getBloodPressure()
	{
		return this.bloodpressure;
	}
	public void setBloodPressure(ims.core.vo.BloodPressureForNursingNotesVo value)
	{
		this.isValidated = false;
		this.bloodpressure = value;
	}
	public boolean getPulseIsNotNull()
	{
		return this.pulse != null;
	}
	public ims.core.vo.PulseForNursingNotesVo getPulse()
	{
		return this.pulse;
	}
	public void setPulse(ims.core.vo.PulseForNursingNotesVo value)
	{
		this.isValidated = false;
		this.pulse = value;
	}
	public boolean getRespiratoryIsNotNull()
	{
		return this.respiratory != null;
	}
	public ims.core.vo.RespiratoryForNursingNotesVo getRespiratory()
	{
		return this.respiratory;
	}
	public void setRespiratory(ims.core.vo.RespiratoryForNursingNotesVo value)
	{
		this.isValidated = false;
		this.respiratory = value;
	}
	public boolean getTemperatureIsNotNull()
	{
		return this.temperature != null;
	}
	public ims.core.vo.TemperatureForNursingNotesVo getTemperature()
	{
		return this.temperature;
	}
	public void setTemperature(ims.core.vo.TemperatureForNursingNotesVo value)
	{
		this.isValidated = false;
		this.temperature = value;
	}
	public boolean getMetricsIsNotNull()
	{
		return this.metrics != null;
	}
	public ims.core.vo.MetricsForNursingNotesVo getMetrics()
	{
		return this.metrics;
	}
	public void setMetrics(ims.core.vo.MetricsForNursingNotesVo value)
	{
		this.isValidated = false;
		this.metrics = 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 isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.bloodpressure != null)
		{
			if(!this.bloodpressure.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.pulse != null)
		{
			if(!this.pulse.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.respiratory != null)
		{
			if(!this.respiratory.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.temperature != null)
		{
			if(!this.temperature.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.metrics != null)
		{
			if(!this.metrics.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.vitalstakendatetime == null)
			listOfErrors.add("VitalsTakenDateTime is mandatory");
		if(this.bloodpressure != null)
		{
			String[] listOfOtherErrors = this.bloodpressure.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.pulse != null)
		{
			String[] listOfOtherErrors = this.pulse.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.respiratory != null)
		{
			String[] listOfOtherErrors = this.respiratory.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.temperature != null)
		{
			String[] listOfOtherErrors = this.temperature.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.metrics != null)
		{
			String[] listOfOtherErrors = this.metrics.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");
		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;
	
		VitalSignsForNursingNotesVo clone = new VitalSignsForNursingNotesVo(this.id, this.version);
		
		if(this.vitalstakendatetime == null)
			clone.vitalstakendatetime = null;
		else
			clone.vitalstakendatetime = (ims.framework.utils.DateTime)this.vitalstakendatetime.clone();
		if(this.bloodpressure == null)
			clone.bloodpressure = null;
		else
			clone.bloodpressure = (ims.core.vo.BloodPressureForNursingNotesVo)this.bloodpressure.clone();
		if(this.pulse == null)
			clone.pulse = null;
		else
			clone.pulse = (ims.core.vo.PulseForNursingNotesVo)this.pulse.clone();
		if(this.respiratory == null)
			clone.respiratory = null;
		else
			clone.respiratory = (ims.core.vo.RespiratoryForNursingNotesVo)this.respiratory.clone();
		if(this.temperature == null)
			clone.temperature = null;
		else
			clone.temperature = (ims.core.vo.TemperatureForNursingNotesVo)this.temperature.clone();
		if(this.metrics == null)
			clone.metrics = null;
		else
			clone.metrics = (ims.core.vo.MetricsForNursingNotesVo)this.metrics.clone();
		clone.carecontext = this.carecontext;
		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 (!(VitalSignsForNursingNotesVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A VitalSignsForNursingNotesVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((VitalSignsForNursingNotesVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((VitalSignsForNursingNotesVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.vitalstakendatetime != null)
			count++;
		if(this.bloodpressure != null)
			count++;
		if(this.pulse != null)
			count++;
		if(this.respiratory != null)
			count++;
		if(this.temperature != null)
			count++;
		if(this.metrics != null)
			count++;
		if(this.carecontext != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 7;
	}
	protected ims.framework.utils.DateTime vitalstakendatetime;
	protected ims.core.vo.BloodPressureForNursingNotesVo bloodpressure;
	protected ims.core.vo.PulseForNursingNotesVo pulse;
	protected ims.core.vo.RespiratoryForNursingNotesVo respiratory;
	protected ims.core.vo.TemperatureForNursingNotesVo temperature;
	protected ims.core.vo.MetricsForNursingNotesVo metrics;
	protected ims.core.admin.vo.CareContextRefVo carecontext;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
