//#############################################################################
//#                                                                           #
//#  Copyright (C) <2014>  <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/>.    #
//#                                                                           #
//#############################################################################
//#EOH
// This code was generated by Barbara Worwood using IMS Development Environment (version 1.80 build 5007.25751)
// Copyright (C) 1995-2014 IMS MAXIMS. All rights reserved.
// WARNING: DO NOT MODIFY the content of this file

package ims.core.vo;

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

	public VSBloodPressure()
	{
	}
	public VSBloodPressure(Integer id, int version)
	{
		super(id, version);
	}
	public VSBloodPressure(ims.core.vo.beans.VSBloodPressureBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.bpsittingsys = bean.getBPSittingSys();
		this.bpsittingdias = bean.getBPSittingDias();
		this.bpstandingsys = bean.getBPStandingSys();
		this.bpstandingdias = bean.getBPStandingDias();
		this.timeinterval = bean.getTimeInterval();
		this.bplyingsys = bean.getBPLyingSys();
		this.bplyingdias = bean.getBPLyingDias();
		this.comment = bean.getComment();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.VSBloodPressureBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.bpsittingsys = bean.getBPSittingSys();
		this.bpsittingdias = bean.getBPSittingDias();
		this.bpstandingsys = bean.getBPStandingSys();
		this.bpstandingdias = bean.getBPStandingDias();
		this.timeinterval = bean.getTimeInterval();
		this.bplyingsys = bean.getBPLyingSys();
		this.bplyingdias = bean.getBPLyingDias();
		this.comment = bean.getComment();
	}
	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.VSBloodPressureBean bean = null;
		if(map != null)
			bean = (ims.core.vo.beans.VSBloodPressureBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.core.vo.beans.VSBloodPressureBean();
			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("BPSITTINGSYS"))
			return getBPSittingSys();
		if(fieldName.equals("BPSITTINGDIAS"))
			return getBPSittingDias();
		if(fieldName.equals("BPSTANDINGSYS"))
			return getBPStandingSys();
		if(fieldName.equals("BPSTANDINGDIAS"))
			return getBPStandingDias();
		if(fieldName.equals("TIMEINTERVAL"))
			return getTimeInterval();
		if(fieldName.equals("BPLYINGSYS"))
			return getBPLyingSys();
		if(fieldName.equals("BPLYINGDIAS"))
			return getBPLyingDias();
		if(fieldName.equals("COMMENT"))
			return getComment();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getBPSittingSysIsNotNull()
	{
		return this.bpsittingsys != null;
	}
	public Float getBPSittingSys()
	{
		return this.bpsittingsys;
	}
	public void setBPSittingSys(Float value)
	{
		this.isValidated = false;
		this.bpsittingsys = value;
	}
	public boolean getBPSittingDiasIsNotNull()
	{
		return this.bpsittingdias != null;
	}
	public Float getBPSittingDias()
	{
		return this.bpsittingdias;
	}
	public void setBPSittingDias(Float value)
	{
		this.isValidated = false;
		this.bpsittingdias = value;
	}
	public boolean getBPStandingSysIsNotNull()
	{
		return this.bpstandingsys != null;
	}
	public Float getBPStandingSys()
	{
		return this.bpstandingsys;
	}
	public void setBPStandingSys(Float value)
	{
		this.isValidated = false;
		this.bpstandingsys = value;
	}
	public boolean getBPStandingDiasIsNotNull()
	{
		return this.bpstandingdias != null;
	}
	public Float getBPStandingDias()
	{
		return this.bpstandingdias;
	}
	public void setBPStandingDias(Float value)
	{
		this.isValidated = false;
		this.bpstandingdias = value;
	}
	public boolean getTimeIntervalIsNotNull()
	{
		return this.timeinterval != null;
	}
	public Integer getTimeInterval()
	{
		return this.timeinterval;
	}
	public void setTimeInterval(Integer value)
	{
		this.isValidated = false;
		this.timeinterval = value;
	}
	public boolean getBPLyingSysIsNotNull()
	{
		return this.bplyingsys != null;
	}
	public Float getBPLyingSys()
	{
		return this.bplyingsys;
	}
	public void setBPLyingSys(Float value)
	{
		this.isValidated = false;
		this.bplyingsys = value;
	}
	public boolean getBPLyingDiasIsNotNull()
	{
		return this.bplyingdias != null;
	}
	public Float getBPLyingDias()
	{
		return this.bplyingdias;
	}
	public void setBPLyingDias(Float value)
	{
		this.isValidated = false;
		this.bplyingdias = value;
	}
	public boolean getCommentIsNotNull()
	{
		return this.comment != null;
	}
	public String getComment()
	{
		return this.comment;
	}
	public static int getCommentMaxLength()
	{
		return 50;
	}
	public void setComment(String value)
	{
		this.isValidated = false;
		this.comment = 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.comment != null)
			if(this.comment.length() > 50)
				listOfErrors.add("The length of the field [comment] in the value object [ims.core.vo.VSBloodPressure] is too big. It should be less or equal to 50");
		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;
	
		VSBloodPressure clone = new VSBloodPressure(this.id, this.version);
		
		clone.bpsittingsys = this.bpsittingsys;
		clone.bpsittingdias = this.bpsittingdias;
		clone.bpstandingsys = this.bpstandingsys;
		clone.bpstandingdias = this.bpstandingdias;
		clone.timeinterval = this.timeinterval;
		clone.bplyingsys = this.bplyingsys;
		clone.bplyingdias = this.bplyingdias;
		clone.comment = this.comment;
		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 (!(VSBloodPressure.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A VSBloodPressure object cannot be compared an Object of type " + obj.getClass().getName());
		}
		VSBloodPressure compareObj = (VSBloodPressure)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getID_Bloodpressure() == null && compareObj.getID_Bloodpressure() != null)
				return -1;
			if(this.getID_Bloodpressure() != null && compareObj.getID_Bloodpressure() == null)
				return 1;
			if(this.getID_Bloodpressure() != null && compareObj.getID_Bloodpressure() != null)
				retVal = this.getID_Bloodpressure().compareTo(compareObj.getID_Bloodpressure());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.bpsittingsys != null)
			count++;
		if(this.bpsittingdias != null)
			count++;
		if(this.bpstandingsys != null)
			count++;
		if(this.bpstandingdias != null)
			count++;
		if(this.timeinterval != null)
			count++;
		if(this.bplyingsys != null)
			count++;
		if(this.bplyingdias != null)
			count++;
		if(this.comment != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 8;
	}
	protected Float bpsittingsys;
	protected Float bpsittingdias;
	protected Float bpstandingsys;
	protected Float bpstandingdias;
	protected Integer timeinterval;
	protected Float bplyingsys;
	protected Float bplyingdias;
	protected String comment;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
