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

	public RespiratoryTreatmentVo()
	{
	}
	public RespiratoryTreatmentVo(Integer id, int version)
	{
		super(id, version);
	}
	public RespiratoryTreatmentVo(ims.core.vo.beans.RespiratoryTreatmentVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.soapclinicalcontact = bean.getSOAPClinicalContact() == null ? null : bean.getSOAPClinicalContact().buildVo();
		this.authoringdatetime = bean.getAuthoringDateTime() == null ? null : bean.getAuthoringDateTime().buildDateTime();
		this.authoringcp = bean.getAuthoringCP() == null ? null : bean.getAuthoringCP().buildVo();
		this.posturaldrainage = bean.getPosturalDrainage() == null ? null : ims.spinalinjuries.vo.lookups.PosturalDrainage.buildLookup(bean.getPosturalDrainage());
		this.assistedcough = bean.getAssistedCough() == null ? null : ims.spinalinjuries.vo.lookups.AssistedCough.buildLookup(bean.getAssistedCough());
		this.ippb = bean.getIPPB();
		this.contraindicationchecked = bean.getContraindicationChecked() == null ? null : ims.core.vo.lookups.YesNoUnknown.buildLookup(bean.getContraindicationChecked());
		this.coughassist = bean.getCoughAssist();
		this.treatments = ims.core.vo.RespiratoryTreatmentDetailVoCollection.buildFromBeanCollection(bean.getTreatments());
		this.treatmentanalysis = bean.getTreatmentAnalysis();
		this.referoncallphysio = bean.getReferOnCallPhysio() == null ? null : ims.core.vo.lookups.YesNoUnknown.buildLookup(bean.getReferOnCallPhysio());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.RespiratoryTreatmentVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.soapclinicalcontact = bean.getSOAPClinicalContact() == null ? null : bean.getSOAPClinicalContact().buildVo(map);
		this.authoringdatetime = bean.getAuthoringDateTime() == null ? null : bean.getAuthoringDateTime().buildDateTime();
		this.authoringcp = bean.getAuthoringCP() == null ? null : bean.getAuthoringCP().buildVo(map);
		this.posturaldrainage = bean.getPosturalDrainage() == null ? null : ims.spinalinjuries.vo.lookups.PosturalDrainage.buildLookup(bean.getPosturalDrainage());
		this.assistedcough = bean.getAssistedCough() == null ? null : ims.spinalinjuries.vo.lookups.AssistedCough.buildLookup(bean.getAssistedCough());
		this.ippb = bean.getIPPB();
		this.contraindicationchecked = bean.getContraindicationChecked() == null ? null : ims.core.vo.lookups.YesNoUnknown.buildLookup(bean.getContraindicationChecked());
		this.coughassist = bean.getCoughAssist();
		this.treatments = ims.core.vo.RespiratoryTreatmentDetailVoCollection.buildFromBeanCollection(bean.getTreatments());
		this.treatmentanalysis = bean.getTreatmentAnalysis();
		this.referoncallphysio = bean.getReferOnCallPhysio() == null ? null : ims.core.vo.lookups.YesNoUnknown.buildLookup(bean.getReferOnCallPhysio());
	}
	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.RespiratoryTreatmentVoBean bean = null;
		if(map != null)
			bean = (ims.core.vo.beans.RespiratoryTreatmentVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.core.vo.beans.RespiratoryTreatmentVoBean();
			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("SOAPCLINICALCONTACT"))
			return getSOAPClinicalContact();
		if(fieldName.equals("AUTHORINGDATETIME"))
			return getAuthoringDateTime();
		if(fieldName.equals("AUTHORINGCP"))
			return getAuthoringCP();
		if(fieldName.equals("POSTURALDRAINAGE"))
			return getPosturalDrainage();
		if(fieldName.equals("ASSISTEDCOUGH"))
			return getAssistedCough();
		if(fieldName.equals("IPPB"))
			return getIPPB();
		if(fieldName.equals("CONTRAINDICATIONCHECKED"))
			return getContraindicationChecked();
		if(fieldName.equals("COUGHASSIST"))
			return getCoughAssist();
		if(fieldName.equals("TREATMENTS"))
			return getTreatments();
		if(fieldName.equals("TREATMENTANALYSIS"))
			return getTreatmentAnalysis();
		if(fieldName.equals("REFERONCALLPHYSIO"))
			return getReferOnCallPhysio();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getSOAPClinicalContactIsNotNull()
	{
		return this.soapclinicalcontact != null;
	}
	public ims.core.vo.ClinicalContactShortVo getSOAPClinicalContact()
	{
		return this.soapclinicalcontact;
	}
	public void setSOAPClinicalContact(ims.core.vo.ClinicalContactShortVo value)
	{
		this.isValidated = false;
		this.soapclinicalcontact = value;
	}
	public boolean getAuthoringDateTimeIsNotNull()
	{
		return this.authoringdatetime != null;
	}
	public ims.framework.utils.DateTime getAuthoringDateTime()
	{
		return this.authoringdatetime;
	}
	public void setAuthoringDateTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.authoringdatetime = value;
	}
	public boolean getAuthoringCPIsNotNull()
	{
		return this.authoringcp != null;
	}
	public ims.core.vo.Hcp getAuthoringCP()
	{
		return this.authoringcp;
	}
	public void setAuthoringCP(ims.core.vo.Hcp value)
	{
		this.isValidated = false;
		this.authoringcp = value;
	}
	public boolean getPosturalDrainageIsNotNull()
	{
		return this.posturaldrainage != null;
	}
	public ims.spinalinjuries.vo.lookups.PosturalDrainage getPosturalDrainage()
	{
		return this.posturaldrainage;
	}
	public void setPosturalDrainage(ims.spinalinjuries.vo.lookups.PosturalDrainage value)
	{
		this.isValidated = false;
		this.posturaldrainage = value;
	}
	public boolean getAssistedCoughIsNotNull()
	{
		return this.assistedcough != null;
	}
	public ims.spinalinjuries.vo.lookups.AssistedCough getAssistedCough()
	{
		return this.assistedcough;
	}
	public void setAssistedCough(ims.spinalinjuries.vo.lookups.AssistedCough value)
	{
		this.isValidated = false;
		this.assistedcough = value;
	}
	public boolean getIPPBIsNotNull()
	{
		return this.ippb != null;
	}
	public String getIPPB()
	{
		return this.ippb;
	}
	public static int getIPPBMaxLength()
	{
		return 255;
	}
	public void setIPPB(String value)
	{
		this.isValidated = false;
		this.ippb = value;
	}
	public boolean getContraindicationCheckedIsNotNull()
	{
		return this.contraindicationchecked != null;
	}
	public ims.core.vo.lookups.YesNoUnknown getContraindicationChecked()
	{
		return this.contraindicationchecked;
	}
	public void setContraindicationChecked(ims.core.vo.lookups.YesNoUnknown value)
	{
		this.isValidated = false;
		this.contraindicationchecked = value;
	}
	public boolean getCoughAssistIsNotNull()
	{
		return this.coughassist != null;
	}
	public String getCoughAssist()
	{
		return this.coughassist;
	}
	public static int getCoughAssistMaxLength()
	{
		return 255;
	}
	public void setCoughAssist(String value)
	{
		this.isValidated = false;
		this.coughassist = value;
	}
	public boolean getTreatmentsIsNotNull()
	{
		return this.treatments != null;
	}
	public ims.core.vo.RespiratoryTreatmentDetailVoCollection getTreatments()
	{
		return this.treatments;
	}
	public void setTreatments(ims.core.vo.RespiratoryTreatmentDetailVoCollection value)
	{
		this.isValidated = false;
		this.treatments = value;
	}
	public boolean getTreatmentAnalysisIsNotNull()
	{
		return this.treatmentanalysis != null;
	}
	public String getTreatmentAnalysis()
	{
		return this.treatmentanalysis;
	}
	public static int getTreatmentAnalysisMaxLength()
	{
		return 1000;
	}
	public void setTreatmentAnalysis(String value)
	{
		this.isValidated = false;
		this.treatmentanalysis = value;
	}
	public boolean getReferOnCallPhysioIsNotNull()
	{
		return this.referoncallphysio != null;
	}
	public ims.core.vo.lookups.YesNoUnknown getReferOnCallPhysio()
	{
		return this.referoncallphysio;
	}
	public void setReferOnCallPhysio(ims.core.vo.lookups.YesNoUnknown value)
	{
		this.isValidated = false;
		this.referoncallphysio = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.authoringcp != null)
		{
			if(!this.authoringcp.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.treatments != null)
		{
			if(!this.treatments.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.soapclinicalcontact == null)
			listOfErrors.add("SOAP Clinical Contact is a mandatory field");
		if(this.authoringdatetime == null)
			listOfErrors.add("Authoring Date/Time is a mandatory field");
		if(this.authoringcp == null)
			listOfErrors.add("Authoring HCP is a mandatory field");
		if(this.authoringcp != null)
		{
			String[] listOfOtherErrors = this.authoringcp.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.ippb != null)
			if(this.ippb.length() > 255)
				listOfErrors.add("The length of the field [ippb] in the value object [ims.core.vo.RespiratoryTreatmentVo] is too big. It should be less or equal to 255");
		if(this.coughassist != null)
			if(this.coughassist.length() > 255)
				listOfErrors.add("The length of the field [coughassist] in the value object [ims.core.vo.RespiratoryTreatmentVo] is too big. It should be less or equal to 255");
		if(this.treatments != null)
		{
			String[] listOfOtherErrors = this.treatments.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.treatmentanalysis != null)
			if(this.treatmentanalysis.length() > 1000)
				listOfErrors.add("The length of the field [treatmentanalysis] in the value object [ims.core.vo.RespiratoryTreatmentVo] is too big. It should be less or equal to 1000");
		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;
	
		RespiratoryTreatmentVo clone = new RespiratoryTreatmentVo(this.id, this.version);
		
		if(this.soapclinicalcontact == null)
			clone.soapclinicalcontact = null;
		else
			clone.soapclinicalcontact = (ims.core.vo.ClinicalContactShortVo)this.soapclinicalcontact.clone();
		if(this.authoringdatetime == null)
			clone.authoringdatetime = null;
		else
			clone.authoringdatetime = (ims.framework.utils.DateTime)this.authoringdatetime.clone();
		if(this.authoringcp == null)
			clone.authoringcp = null;
		else
			clone.authoringcp = (ims.core.vo.Hcp)this.authoringcp.clone();
		if(this.posturaldrainage == null)
			clone.posturaldrainage = null;
		else
			clone.posturaldrainage = (ims.spinalinjuries.vo.lookups.PosturalDrainage)this.posturaldrainage.clone();
		if(this.assistedcough == null)
			clone.assistedcough = null;
		else
			clone.assistedcough = (ims.spinalinjuries.vo.lookups.AssistedCough)this.assistedcough.clone();
		clone.ippb = this.ippb;
		if(this.contraindicationchecked == null)
			clone.contraindicationchecked = null;
		else
			clone.contraindicationchecked = (ims.core.vo.lookups.YesNoUnknown)this.contraindicationchecked.clone();
		clone.coughassist = this.coughassist;
		if(this.treatments == null)
			clone.treatments = null;
		else
			clone.treatments = (ims.core.vo.RespiratoryTreatmentDetailVoCollection)this.treatments.clone();
		clone.treatmentanalysis = this.treatmentanalysis;
		if(this.referoncallphysio == null)
			clone.referoncallphysio = null;
		else
			clone.referoncallphysio = (ims.core.vo.lookups.YesNoUnknown)this.referoncallphysio.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 (!(RespiratoryTreatmentVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A RespiratoryTreatmentVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((RespiratoryTreatmentVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((RespiratoryTreatmentVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.posturaldrainage != null)
			count++;
		if(this.assistedcough != null)
			count++;
		if(this.ippb != null)
			count++;
		if(this.contraindicationchecked != null)
			count++;
		if(this.coughassist != null)
			count++;
		if(this.treatments != null)
			count++;
		if(this.treatmentanalysis != null)
			count++;
		if(this.referoncallphysio != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 8;
	}
	protected ims.core.vo.ClinicalContactShortVo soapclinicalcontact;
	protected ims.framework.utils.DateTime authoringdatetime;
	protected ims.core.vo.Hcp authoringcp;
	protected ims.spinalinjuries.vo.lookups.PosturalDrainage posturaldrainage;
	protected ims.spinalinjuries.vo.lookups.AssistedCough assistedcough;
	protected String ippb;
	protected ims.core.vo.lookups.YesNoUnknown contraindicationchecked;
	protected String coughassist;
	protected ims.core.vo.RespiratoryTreatmentDetailVoCollection treatments;
	protected String treatmentanalysis;
	protected ims.core.vo.lookups.YesNoUnknown referoncallphysio;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
