/FileExtraction/Java_unseen/IMS-MAXIMS_openMAXIMS/Source Library/openmaxims_workspace/ValueObjects/src/ims/core/vo/Urinalysis.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.Urinalysis business object (ID: 1022100012).
 */
public class Urinalysis extends ims.core.vitals.vo.UrinalysisRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public Urinalysis()
	{
	}
	public Urinalysis(Integer id, int version)
	{
		super(id, version);
	}
	public Urinalysis(ims.core.vo.beans.UrinalysisBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.noabnormalitydetected = bean.getNoAbnormalityDetected();
		this.leucocytes = bean.getLeucocytes() == null ? null : ims.core.vo.lookups.UrinalysisResults.buildLookup(bean.getLeucocytes());
		this.protein = bean.getProtein() == null ? null : ims.core.vo.lookups.UrinalysisResults.buildLookup(bean.getProtein());
		this.blood = bean.getBlood() == null ? null : ims.core.vo.lookups.UrinalysisResults.buildLookup(bean.getBlood());
		this.ketones = bean.getKetones() == null ? null : ims.core.vo.lookups.UrinalysisResults.buildLookup(bean.getKetones());
		this.ascorbicacid = bean.getAscorbicAcid() == null ? null : ims.core.vo.lookups.UrinalysisResults.buildLookup(bean.getAscorbicAcid());
		this.glucose = bean.getGlucose() == null ? null : ims.core.vo.lookups.UrinalysisResults.buildLookup(bean.getGlucose());
		this.bilirubin = bean.getBilirubin() == null ? null : ims.core.vo.lookups.UrinalysisResults.buildLookup(bean.getBilirubin());
		this.urobilinogen = bean.getUrobilinogen() == null ? null : ims.core.vo.lookups.UrinalysisResults.buildLookup(bean.getUrobilinogen());
		this.nitrate = bean.getNitrate();
		this.ph = bean.getPH() == null ? null : ims.core.vo.lookups.UrinalysisPH.buildLookup(bean.getPH());
		this.specificgravity = bean.getSpecificGravity();
		this.nosample = bean.getNoSample();
		this.isactive = bean.getIsActive();
		this.clinicalcontact = bean.getClinicalContact() == null ? null : bean.getClinicalContact().buildVo();
		this.sysinfo = bean.getSysInfo() == null ? null : bean.getSysInfo().buildSystemInformation();
		this.carecontext = bean.getCareContext() == null ? null : new ims.core.admin.vo.CareContextRefVo(new Integer(bean.getCareContext().getId()), bean.getCareContext().getVersion());
		this.authoringinformation = bean.getAuthoringInformation() == null ? null : bean.getAuthoringInformation().buildVo();
		this.recordinginformation = bean.getRecordingInformation() == null ? null : bean.getRecordingInformation().buildVo();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.UrinalysisBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.noabnormalitydetected = bean.getNoAbnormalityDetected();
		this.leucocytes = bean.getLeucocytes() == null ? null : ims.core.vo.lookups.UrinalysisResults.buildLookup(bean.getLeucocytes());
		this.protein = bean.getProtein() == null ? null : ims.core.vo.lookups.UrinalysisResults.buildLookup(bean.getProtein());
		this.blood = bean.getBlood() == null ? null : ims.core.vo.lookups.UrinalysisResults.buildLookup(bean.getBlood());
		this.ketones = bean.getKetones() == null ? null : ims.core.vo.lookups.UrinalysisResults.buildLookup(bean.getKetones());
		this.ascorbicacid = bean.getAscorbicAcid() == null ? null : ims.core.vo.lookups.UrinalysisResults.buildLookup(bean.getAscorbicAcid());
		this.glucose = bean.getGlucose() == null ? null : ims.core.vo.lookups.UrinalysisResults.buildLookup(bean.getGlucose());
		this.bilirubin = bean.getBilirubin() == null ? null : ims.core.vo.lookups.UrinalysisResults.buildLookup(bean.getBilirubin());
		this.urobilinogen = bean.getUrobilinogen() == null ? null : ims.core.vo.lookups.UrinalysisResults.buildLookup(bean.getUrobilinogen());
		this.nitrate = bean.getNitrate();
		this.ph = bean.getPH() == null ? null : ims.core.vo.lookups.UrinalysisPH.buildLookup(bean.getPH());
		this.specificgravity = bean.getSpecificGravity();
		this.nosample = bean.getNoSample();
		this.isactive = bean.getIsActive();
		this.clinicalcontact = bean.getClinicalContact() == null ? null : bean.getClinicalContact().buildVo(map);
		this.sysinfo = bean.getSysInfo() == null ? null : bean.getSysInfo().buildSystemInformation();
		this.carecontext = bean.getCareContext() == null ? null : new ims.core.admin.vo.CareContextRefVo(new Integer(bean.getCareContext().getId()), bean.getCareContext().getVersion());
		this.authoringinformation = bean.getAuthoringInformation() == null ? null : bean.getAuthoringInformation().buildVo(map);
		this.recordinginformation = bean.getRecordingInformation() == null ? null : bean.getRecordingInformation().buildVo(map);
	}
	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.UrinalysisBean bean = null;
		if(map != null)
			bean = (ims.core.vo.beans.UrinalysisBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.core.vo.beans.UrinalysisBean();
			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("NOABNORMALITYDETECTED"))
			return getNoAbnormalityDetected();
		if(fieldName.equals("LEUCOCYTES"))
			return getLeucocytes();
		if(fieldName.equals("PROTEIN"))
			return getProtein();
		if(fieldName.equals("BLOOD"))
			return getBlood();
		if(fieldName.equals("KETONES"))
			return getKetones();
		if(fieldName.equals("ASCORBICACID"))
			return getAscorbicAcid();
		if(fieldName.equals("GLUCOSE"))
			return getGlucose();
		if(fieldName.equals("BILIRUBIN"))
			return getBilirubin();
		if(fieldName.equals("UROBILINOGEN"))
			return getUrobilinogen();
		if(fieldName.equals("NITRATE"))
			return getNitrate();
		if(fieldName.equals("PH"))
			return getPH();
		if(fieldName.equals("SPECIFICGRAVITY"))
			return getSpecificGravity();
		if(fieldName.equals("NOSAMPLE"))
			return getNoSample();
		if(fieldName.equals("ISACTIVE"))
			return getIsActive();
		if(fieldName.equals("CLINICALCONTACT"))
			return getClinicalContact();
		if(fieldName.equals("SYSINFO"))
			return getSysInfo();
		if(fieldName.equals("CARECONTEXT"))
			return getCareContext();
		if(fieldName.equals("AUTHORINGINFORMATION"))
			return getAuthoringInformation();
		if(fieldName.equals("RECORDINGINFORMATION"))
			return getRecordingInformation();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getNoAbnormalityDetectedIsNotNull()
	{
		return this.noabnormalitydetected != null;
	}
	public Boolean getNoAbnormalityDetected()
	{
		return this.noabnormalitydetected;
	}
	public void setNoAbnormalityDetected(Boolean value)
	{
		this.isValidated = false;
		this.noabnormalitydetected = value;
	}
	public boolean getLeucocytesIsNotNull()
	{
		return this.leucocytes != null;
	}
	public ims.core.vo.lookups.UrinalysisResults getLeucocytes()
	{
		return this.leucocytes;
	}
	public void setLeucocytes(ims.core.vo.lookups.UrinalysisResults value)
	{
		this.isValidated = false;
		this.leucocytes = value;
	}
	public boolean getProteinIsNotNull()
	{
		return this.protein != null;
	}
	public ims.core.vo.lookups.UrinalysisResults getProtein()
	{
		return this.protein;
	}
	public void setProtein(ims.core.vo.lookups.UrinalysisResults value)
	{
		this.isValidated = false;
		this.protein = value;
	}
	public boolean getBloodIsNotNull()
	{
		return this.blood != null;
	}
	public ims.core.vo.lookups.UrinalysisResults getBlood()
	{
		return this.blood;
	}
	public void setBlood(ims.core.vo.lookups.UrinalysisResults value)
	{
		this.isValidated = false;
		this.blood = value;
	}
	public boolean getKetonesIsNotNull()
	{
		return this.ketones != null;
	}
	public ims.core.vo.lookups.UrinalysisResults getKetones()
	{
		return this.ketones;
	}
	public void setKetones(ims.core.vo.lookups.UrinalysisResults value)
	{
		this.isValidated = false;
		this.ketones = value;
	}
	public boolean getAscorbicAcidIsNotNull()
	{
		return this.ascorbicacid != null;
	}
	public ims.core.vo.lookups.UrinalysisResults getAscorbicAcid()
	{
		return this.ascorbicacid;
	}
	public void setAscorbicAcid(ims.core.vo.lookups.UrinalysisResults value)
	{
		this.isValidated = false;
		this.ascorbicacid = value;
	}
	public boolean getGlucoseIsNotNull()
	{
		return this.glucose != null;
	}
	public ims.core.vo.lookups.UrinalysisResults getGlucose()
	{
		return this.glucose;
	}
	public void setGlucose(ims.core.vo.lookups.UrinalysisResults value)
	{
		this.isValidated = false;
		this.glucose = value;
	}
	public boolean getBilirubinIsNotNull()
	{
		return this.bilirubin != null;
	}
	public ims.core.vo.lookups.UrinalysisResults getBilirubin()
	{
		return this.bilirubin;
	}
	public void setBilirubin(ims.core.vo.lookups.UrinalysisResults value)
	{
		this.isValidated = false;
		this.bilirubin = value;
	}
	public boolean getUrobilinogenIsNotNull()
	{
		return this.urobilinogen != null;
	}
	public ims.core.vo.lookups.UrinalysisResults getUrobilinogen()
	{
		return this.urobilinogen;
	}
	public void setUrobilinogen(ims.core.vo.lookups.UrinalysisResults value)
	{
		this.isValidated = false;
		this.urobilinogen = value;
	}
	public boolean getNitrateIsNotNull()
	{
		return this.nitrate != null;
	}
	public Boolean getNitrate()
	{
		return this.nitrate;
	}
	public void setNitrate(Boolean value)
	{
		this.isValidated = false;
		this.nitrate = value;
	}
	public boolean getPHIsNotNull()
	{
		return this.ph != null;
	}
	public ims.core.vo.lookups.UrinalysisPH getPH()
	{
		return this.ph;
	}
	public void setPH(ims.core.vo.lookups.UrinalysisPH value)
	{
		this.isValidated = false;
		this.ph = value;
	}
	public boolean getSpecificGravityIsNotNull()
	{
		return this.specificgravity != null;
	}
	public Float getSpecificGravity()
	{
		return this.specificgravity;
	}
	public void setSpecificGravity(Float value)
	{
		this.isValidated = false;
		this.specificgravity = value;
	}
	public boolean getNoSampleIsNotNull()
	{
		return this.nosample != null;
	}
	public Boolean getNoSample()
	{
		return this.nosample;
	}
	public void setNoSample(Boolean value)
	{
		this.isValidated = false;
		this.nosample = value;
	}
	public boolean getIsActiveIsNotNull()
	{
		return this.isactive != null;
	}
	public Boolean getIsActive()
	{
		return this.isactive;
	}
	public void setIsActive(Boolean value)
	{
		this.isValidated = false;
		this.isactive = value;
	}
	public boolean getClinicalContactIsNotNull()
	{
		return this.clinicalcontact != null;
	}
	public ims.core.vo.ClinicalContactShortVo getClinicalContact()
	{
		return this.clinicalcontact;
	}
	public void setClinicalContact(ims.core.vo.ClinicalContactShortVo value)
	{
		this.isValidated = false;
		this.clinicalcontact = value;
	}
	public boolean getSysInfoIsNotNull()
	{
		return this.sysinfo != null;
	}
	public ims.vo.SystemInformation getSysInfo()
	{
		return this.sysinfo;
	}
	public void setSysInfo(ims.vo.SystemInformation value)
	{
		this.isValidated = false;
		this.sysinfo = 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 getAuthoringInformationIsNotNull()
	{
		return this.authoringinformation != null;
	}
	public ims.core.vo.AuthoringInformationVo getAuthoringInformation()
	{
		return this.authoringinformation;
	}
	public void setAuthoringInformation(ims.core.vo.AuthoringInformationVo value)
	{
		this.isValidated = false;
		this.authoringinformation = value;
	}
	public boolean getRecordingInformationIsNotNull()
	{
		return this.recordinginformation != null;
	}
	public ims.core.vo.RecordingUserInformationVo getRecordingInformation()
	{
		return this.recordinginformation;
	}
	public void setRecordingInformation(ims.core.vo.RecordingUserInformationVo value)
	{
		this.isValidated = false;
		this.recordinginformation = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.authoringinformation != null)
		{
			if(!this.authoringinformation.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.recordinginformation != null)
		{
			if(!this.recordinginformation.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.carecontext == null)
			listOfErrors.add("CareContext is mandatory");
		if(this.authoringinformation != null)
		{
			String[] listOfOtherErrors = this.authoringinformation.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.recordinginformation != null)
		{
			String[] listOfOtherErrors = this.recordinginformation.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.countFieldsWithValue() < 1)
		{
			listOfErrors.add("A minimum of 1 data fields must be entered");
		}
		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;
	
		Urinalysis clone = new Urinalysis(this.id, this.version);
		
		clone.noabnormalitydetected = this.noabnormalitydetected;
		if(this.leucocytes == null)
			clone.leucocytes = null;
		else
			clone.leucocytes = (ims.core.vo.lookups.UrinalysisResults)this.leucocytes.clone();
		if(this.protein == null)
			clone.protein = null;
		else
			clone.protein = (ims.core.vo.lookups.UrinalysisResults)this.protein.clone();
		if(this.blood == null)
			clone.blood = null;
		else
			clone.blood = (ims.core.vo.lookups.UrinalysisResults)this.blood.clone();
		if(this.ketones == null)
			clone.ketones = null;
		else
			clone.ketones = (ims.core.vo.lookups.UrinalysisResults)this.ketones.clone();
		if(this.ascorbicacid == null)
			clone.ascorbicacid = null;
		else
			clone.ascorbicacid = (ims.core.vo.lookups.UrinalysisResults)this.ascorbicacid.clone();
		if(this.glucose == null)
			clone.glucose = null;
		else
			clone.glucose = (ims.core.vo.lookups.UrinalysisResults)this.glucose.clone();
		if(this.bilirubin == null)
			clone.bilirubin = null;
		else
			clone.bilirubin = (ims.core.vo.lookups.UrinalysisResults)this.bilirubin.clone();
		if(this.urobilinogen == null)
			clone.urobilinogen = null;
		else
			clone.urobilinogen = (ims.core.vo.lookups.UrinalysisResults)this.urobilinogen.clone();
		clone.nitrate = this.nitrate;
		if(this.ph == null)
			clone.ph = null;
		else
			clone.ph = (ims.core.vo.lookups.UrinalysisPH)this.ph.clone();
		clone.specificgravity = this.specificgravity;
		clone.nosample = this.nosample;
		clone.isactive = this.isactive;
		if(this.clinicalcontact == null)
			clone.clinicalcontact = null;
		else
			clone.clinicalcontact = (ims.core.vo.ClinicalContactShortVo)this.clinicalcontact.clone();
		if(this.sysinfo == null)
			clone.sysinfo = null;
		else
			clone.sysinfo = (ims.vo.SystemInformation)this.sysinfo.clone();
		clone.carecontext = this.carecontext;
		if(this.authoringinformation == null)
			clone.authoringinformation = null;
		else
			clone.authoringinformation = (ims.core.vo.AuthoringInformationVo)this.authoringinformation.clone();
		if(this.recordinginformation == null)
			clone.recordinginformation = null;
		else
			clone.recordinginformation = (ims.core.vo.RecordingUserInformationVo)this.recordinginformation.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 (!(Urinalysis.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A Urinalysis object cannot be compared an Object of type " + obj.getClass().getName());
		}
		Urinalysis compareObj = (Urinalysis)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getSysInfo() == null && compareObj.getSysInfo() != null)
				return -1;
			if(this.getSysInfo() != null && compareObj.getSysInfo() == null)
				return 1;
			if(this.getSysInfo() != null && compareObj.getSysInfo() != null)
				retVal = this.getSysInfo().compareTo(compareObj.getSysInfo());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.noabnormalitydetected != null)
			count++;
		if(this.leucocytes != null)
			count++;
		if(this.protein != null)
			count++;
		if(this.blood != null)
			count++;
		if(this.ketones != null)
			count++;
		if(this.ascorbicacid != null)
			count++;
		if(this.glucose != null)
			count++;
		if(this.bilirubin != null)
			count++;
		if(this.urobilinogen != null)
			count++;
		if(this.nitrate != null)
			count++;
		if(this.ph != null)
			count++;
		if(this.specificgravity != null)
			count++;
		if(this.nosample != null)
			count++;
		if(this.carecontext != null)
			count++;
		if(this.authoringinformation != null)
			count++;
		if(this.recordinginformation != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 16;
	}
	protected Boolean noabnormalitydetected;
	protected ims.core.vo.lookups.UrinalysisResults leucocytes;
	protected ims.core.vo.lookups.UrinalysisResults protein;
	protected ims.core.vo.lookups.UrinalysisResults blood;
	protected ims.core.vo.lookups.UrinalysisResults ketones;
	protected ims.core.vo.lookups.UrinalysisResults ascorbicacid;
	protected ims.core.vo.lookups.UrinalysisResults glucose;
	protected ims.core.vo.lookups.UrinalysisResults bilirubin;
	protected ims.core.vo.lookups.UrinalysisResults urobilinogen;
	protected Boolean nitrate;
	protected ims.core.vo.lookups.UrinalysisPH ph;
	protected Float specificgravity;
	protected Boolean nosample;
	protected Boolean isactive;
	protected ims.core.vo.ClinicalContactShortVo clinicalcontact;
	protected ims.vo.SystemInformation sysinfo;
	protected ims.core.admin.vo.CareContextRefVo carecontext;
	protected ims.core.vo.AuthoringInformationVo authoringinformation;
	protected ims.core.vo.RecordingUserInformationVo recordinginformation;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
