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

/**
 * Linked to OCRR.OrderingResults.ResultComponent business object (ID: 1070100008).
 */
public class IfOcsResCompVo extends ims.ocrr.orderingresults.vo.ResultComponentRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public IfOcsResCompVo()
	{
	}
	public IfOcsResCompVo(Integer id, int version)
	{
		super(id, version);
	}
	public IfOcsResCompVo(ims.ocs_if.vo.beans.IfOcsResCompVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.analyte = bean.getAnalyte() == null ? null : bean.getAnalyte().buildVo();
		this.resvaltype = bean.getResValType() == null ? null : ims.ocrr.vo.lookups.ResultValueType.buildLookup(bean.getResValType());
		this.formattedtext = bean.getFormattedText();
		this.resultval = bean.getResultVal();
		this.unitofmeasure = bean.getUnitOfMeasure() == null ? null : ims.ocrr.vo.lookups.ResultUnitOfMeasure.buildLookup(bean.getUnitOfMeasure());
		this.refrange = bean.getRefRange();
		this.normalcystatus = bean.getNormalcyStatus() == null ? null : ims.ocrr.vo.lookups.NormalcyStatus.buildLookup(bean.getNormalcyStatus());
		this.isabnormal = bean.getIsAbnormal();
		this.obsdatetime = bean.getObsDateTime() == null ? null : bean.getObsDateTime().buildDateTime();
		this.obstimesupplied = bean.getObsTimeSupplied();
		this.resultstatus = bean.getResultStatus() == null ? null : ims.ocrr.vo.lookups.ResultStatus.buildLookup(bean.getResultStatus());
		this.resultcomponentcomments = ims.ocs_if.vo.IfOcsResCommentVoCollection.buildFromBeanCollection(bean.getResultComponentComments());
		this.edsubtype = bean.getEDSubType() == null ? null : ims.ocrr.vo.lookups.ResultEDSubtype.buildLookup(bean.getEDSubType());
		this.specimensource = bean.getSpecimenSource() == null ? null : ims.ocrr.vo.lookups.SpecimenType.buildLookup(bean.getSpecimenSource());
		this.resultspecimentype = bean.getResultSpecimenType() == null ? null : bean.getResultSpecimenType().buildLookupInstVo();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.ocs_if.vo.beans.IfOcsResCompVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.analyte = bean.getAnalyte() == null ? null : bean.getAnalyte().buildVo(map);
		this.resvaltype = bean.getResValType() == null ? null : ims.ocrr.vo.lookups.ResultValueType.buildLookup(bean.getResValType());
		this.formattedtext = bean.getFormattedText();
		this.resultval = bean.getResultVal();
		this.unitofmeasure = bean.getUnitOfMeasure() == null ? null : ims.ocrr.vo.lookups.ResultUnitOfMeasure.buildLookup(bean.getUnitOfMeasure());
		this.refrange = bean.getRefRange();
		this.normalcystatus = bean.getNormalcyStatus() == null ? null : ims.ocrr.vo.lookups.NormalcyStatus.buildLookup(bean.getNormalcyStatus());
		this.isabnormal = bean.getIsAbnormal();
		this.obsdatetime = bean.getObsDateTime() == null ? null : bean.getObsDateTime().buildDateTime();
		this.obstimesupplied = bean.getObsTimeSupplied();
		this.resultstatus = bean.getResultStatus() == null ? null : ims.ocrr.vo.lookups.ResultStatus.buildLookup(bean.getResultStatus());
		this.resultcomponentcomments = ims.ocs_if.vo.IfOcsResCommentVoCollection.buildFromBeanCollection(bean.getResultComponentComments());
		this.edsubtype = bean.getEDSubType() == null ? null : ims.ocrr.vo.lookups.ResultEDSubtype.buildLookup(bean.getEDSubType());
		this.specimensource = bean.getSpecimenSource() == null ? null : ims.ocrr.vo.lookups.SpecimenType.buildLookup(bean.getSpecimenSource());
		this.resultspecimentype = bean.getResultSpecimenType() == null ? null : bean.getResultSpecimenType().buildLookupInstVo();
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.ocs_if.vo.beans.IfOcsResCompVoBean bean = null;
		if(map != null)
			bean = (ims.ocs_if.vo.beans.IfOcsResCompVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.ocs_if.vo.beans.IfOcsResCompVoBean();
			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("ANALYTE"))
			return getAnalyte();
		if(fieldName.equals("RESVALTYPE"))
			return getResValType();
		if(fieldName.equals("FORMATTEDTEXT"))
			return getFormattedText();
		if(fieldName.equals("RESULTVAL"))
			return getResultVal();
		if(fieldName.equals("UNITOFMEASURE"))
			return getUnitOfMeasure();
		if(fieldName.equals("REFRANGE"))
			return getRefRange();
		if(fieldName.equals("NORMALCYSTATUS"))
			return getNormalcyStatus();
		if(fieldName.equals("ISABNORMAL"))
			return getIsAbnormal();
		if(fieldName.equals("OBSDATETIME"))
			return getObsDateTime();
		if(fieldName.equals("OBSTIMESUPPLIED"))
			return getObsTimeSupplied();
		if(fieldName.equals("RESULTSTATUS"))
			return getResultStatus();
		if(fieldName.equals("RESULTCOMPONENTCOMMENTS"))
			return getResultComponentComments();
		if(fieldName.equals("EDSUBTYPE"))
			return getEDSubType();
		if(fieldName.equals("SPECIMENSOURCE"))
			return getSpecimenSource();
		if(fieldName.equals("RESULTSPECIMENTYPE"))
			return getResultSpecimenType();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getAnalyteIsNotNull()
	{
		return this.analyte != null;
	}
	public ims.ocs_if.vo.IfAnalyteVo getAnalyte()
	{
		return this.analyte;
	}
	public void setAnalyte(ims.ocs_if.vo.IfAnalyteVo value)
	{
		this.isValidated = false;
		this.analyte = value;
	}
	public boolean getResValTypeIsNotNull()
	{
		return this.resvaltype != null;
	}
	public ims.ocrr.vo.lookups.ResultValueType getResValType()
	{
		return this.resvaltype;
	}
	public void setResValType(ims.ocrr.vo.lookups.ResultValueType value)
	{
		this.isValidated = false;
		this.resvaltype = value;
	}
	public boolean getFormattedTextIsNotNull()
	{
		return this.formattedtext != null;
	}
	public String getFormattedText()
	{
		return this.formattedtext;
	}
	public static int getFormattedTextMaxLength()
	{
		return 4000;
	}
	public void setFormattedText(String value)
	{
		this.isValidated = false;
		this.formattedtext = value;
	}
	public boolean getResultValIsNotNull()
	{
		return this.resultval != null;
	}
	public String getResultVal()
	{
		return this.resultval;
	}
	public static int getResultValMaxLength()
	{
		return 1000;
	}
	public void setResultVal(String value)
	{
		this.isValidated = false;
		this.resultval = value;
	}
	public boolean getUnitOfMeasureIsNotNull()
	{
		return this.unitofmeasure != null;
	}
	public ims.ocrr.vo.lookups.ResultUnitOfMeasure getUnitOfMeasure()
	{
		return this.unitofmeasure;
	}
	public void setUnitOfMeasure(ims.ocrr.vo.lookups.ResultUnitOfMeasure value)
	{
		this.isValidated = false;
		this.unitofmeasure = value;
	}
	public boolean getRefRangeIsNotNull()
	{
		return this.refrange != null;
	}
	public String getRefRange()
	{
		return this.refrange;
	}
	public static int getRefRangeMaxLength()
	{
		return 60;
	}
	public void setRefRange(String value)
	{
		this.isValidated = false;
		this.refrange = value;
	}
	public boolean getNormalcyStatusIsNotNull()
	{
		return this.normalcystatus != null;
	}
	public ims.ocrr.vo.lookups.NormalcyStatus getNormalcyStatus()
	{
		return this.normalcystatus;
	}
	public void setNormalcyStatus(ims.ocrr.vo.lookups.NormalcyStatus value)
	{
		this.isValidated = false;
		this.normalcystatus = value;
	}
	public boolean getIsAbnormalIsNotNull()
	{
		return this.isabnormal != null;
	}
	public Boolean getIsAbnormal()
	{
		return this.isabnormal;
	}
	public void setIsAbnormal(Boolean value)
	{
		this.isValidated = false;
		this.isabnormal = value;
	}
	public boolean getObsDateTimeIsNotNull()
	{
		return this.obsdatetime != null;
	}
	public ims.framework.utils.DateTime getObsDateTime()
	{
		return this.obsdatetime;
	}
	public void setObsDateTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.obsdatetime = value;
	}
	public boolean getObsTimeSuppliedIsNotNull()
	{
		return this.obstimesupplied != null;
	}
	public Boolean getObsTimeSupplied()
	{
		return this.obstimesupplied;
	}
	public void setObsTimeSupplied(Boolean value)
	{
		this.isValidated = false;
		this.obstimesupplied = value;
	}
	public boolean getResultStatusIsNotNull()
	{
		return this.resultstatus != null;
	}
	public ims.ocrr.vo.lookups.ResultStatus getResultStatus()
	{
		return this.resultstatus;
	}
	public void setResultStatus(ims.ocrr.vo.lookups.ResultStatus value)
	{
		this.isValidated = false;
		this.resultstatus = value;
	}
	public boolean getResultComponentCommentsIsNotNull()
	{
		return this.resultcomponentcomments != null;
	}
	public ims.ocs_if.vo.IfOcsResCommentVoCollection getResultComponentComments()
	{
		return this.resultcomponentcomments;
	}
	public void setResultComponentComments(ims.ocs_if.vo.IfOcsResCommentVoCollection value)
	{
		this.isValidated = false;
		this.resultcomponentcomments = value;
	}
	public boolean getEDSubTypeIsNotNull()
	{
		return this.edsubtype != null;
	}
	public ims.ocrr.vo.lookups.ResultEDSubtype getEDSubType()
	{
		return this.edsubtype;
	}
	public void setEDSubType(ims.ocrr.vo.lookups.ResultEDSubtype value)
	{
		this.isValidated = false;
		this.edsubtype = value;
	}
	public boolean getSpecimenSourceIsNotNull()
	{
		return this.specimensource != null;
	}
	public ims.ocrr.vo.lookups.SpecimenType getSpecimenSource()
	{
		return this.specimensource;
	}
	public void setSpecimenSource(ims.ocrr.vo.lookups.SpecimenType value)
	{
		this.isValidated = false;
		this.specimensource = value;
	}
	public boolean getResultSpecimenTypeIsNotNull()
	{
		return this.resultspecimentype != null;
	}
	public ims.vo.LookupInstVo getResultSpecimenType()
	{
		return this.resultspecimentype;
	}
	public void setResultSpecimenType(ims.vo.LookupInstVo value)
	{
		this.isValidated = false;
		this.resultspecimentype = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.analyte != null)
		{
			if(!this.analyte.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.resultcomponentcomments != null)
		{
			if(!this.resultcomponentcomments.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.analyte == null)
			listOfErrors.add("Analyte is mandatory");
		if(this.analyte != null)
		{
			String[] listOfOtherErrors = this.analyte.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.resvaltype == null)
			listOfErrors.add("ResValType is mandatory");
		if(this.resultval != null)
			if(this.resultval.length() > 1000)
				listOfErrors.add("The length of the field [resultval] in the value object [ims.ocs_if.vo.IfOcsResCompVo] is too big. It should be less or equal to 1000");
		if(this.refrange != null)
			if(this.refrange.length() > 60)
				listOfErrors.add("The length of the field [refrange] in the value object [ims.ocs_if.vo.IfOcsResCompVo] is too big. It should be less or equal to 60");
		if(this.isabnormal == null)
			listOfErrors.add("isAbnormal is mandatory");
		if(this.obsdatetime == null)
			listOfErrors.add("ObsDateTime is mandatory");
		if(this.obstimesupplied == null)
			listOfErrors.add("ObsTimeSupplied is mandatory");
		if(this.resultcomponentcomments != null)
		{
			String[] listOfOtherErrors = this.resultcomponentcomments.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;
	
		IfOcsResCompVo clone = new IfOcsResCompVo(this.id, this.version);
		
		if(this.analyte == null)
			clone.analyte = null;
		else
			clone.analyte = (ims.ocs_if.vo.IfAnalyteVo)this.analyte.clone();
		if(this.resvaltype == null)
			clone.resvaltype = null;
		else
			clone.resvaltype = (ims.ocrr.vo.lookups.ResultValueType)this.resvaltype.clone();
		clone.formattedtext = this.formattedtext;
		clone.resultval = this.resultval;
		if(this.unitofmeasure == null)
			clone.unitofmeasure = null;
		else
			clone.unitofmeasure = (ims.ocrr.vo.lookups.ResultUnitOfMeasure)this.unitofmeasure.clone();
		clone.refrange = this.refrange;
		if(this.normalcystatus == null)
			clone.normalcystatus = null;
		else
			clone.normalcystatus = (ims.ocrr.vo.lookups.NormalcyStatus)this.normalcystatus.clone();
		clone.isabnormal = this.isabnormal;
		if(this.obsdatetime == null)
			clone.obsdatetime = null;
		else
			clone.obsdatetime = (ims.framework.utils.DateTime)this.obsdatetime.clone();
		clone.obstimesupplied = this.obstimesupplied;
		if(this.resultstatus == null)
			clone.resultstatus = null;
		else
			clone.resultstatus = (ims.ocrr.vo.lookups.ResultStatus)this.resultstatus.clone();
		if(this.resultcomponentcomments == null)
			clone.resultcomponentcomments = null;
		else
			clone.resultcomponentcomments = (ims.ocs_if.vo.IfOcsResCommentVoCollection)this.resultcomponentcomments.clone();
		if(this.edsubtype == null)
			clone.edsubtype = null;
		else
			clone.edsubtype = (ims.ocrr.vo.lookups.ResultEDSubtype)this.edsubtype.clone();
		if(this.specimensource == null)
			clone.specimensource = null;
		else
			clone.specimensource = (ims.ocrr.vo.lookups.SpecimenType)this.specimensource.clone();
		clone.resultspecimentype = this.resultspecimentype;
		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 (!(IfOcsResCompVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A IfOcsResCompVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((IfOcsResCompVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((IfOcsResCompVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.analyte != null)
			count++;
		if(this.resvaltype != null)
			count++;
		if(this.formattedtext != null)
			count++;
		if(this.resultval != null)
			count++;
		if(this.unitofmeasure != null)
			count++;
		if(this.refrange != null)
			count++;
		if(this.normalcystatus != null)
			count++;
		if(this.isabnormal != null)
			count++;
		if(this.obsdatetime != null)
			count++;
		if(this.obstimesupplied != null)
			count++;
		if(this.resultstatus != null)
			count++;
		if(this.resultcomponentcomments != null)
			count++;
		if(this.edsubtype != null)
			count++;
		if(this.specimensource != null)
			count++;
		if(this.resultspecimentype != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 15;
	}
	protected ims.ocs_if.vo.IfAnalyteVo analyte;
	protected ims.ocrr.vo.lookups.ResultValueType resvaltype;
	protected String formattedtext;
	protected String resultval;
	protected ims.ocrr.vo.lookups.ResultUnitOfMeasure unitofmeasure;
	protected String refrange;
	protected ims.ocrr.vo.lookups.NormalcyStatus normalcystatus;
	protected Boolean isabnormal;
	protected ims.framework.utils.DateTime obsdatetime;
	protected Boolean obstimesupplied;
	protected ims.ocrr.vo.lookups.ResultStatus resultstatus;
	protected ims.ocs_if.vo.IfOcsResCommentVoCollection resultcomponentcomments;
	protected ims.ocrr.vo.lookups.ResultEDSubtype edsubtype;
	protected ims.ocrr.vo.lookups.SpecimenType specimensource;
	protected ims.vo.LookupInstVo resultspecimentype;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
