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

/**
 * Linked to RefMan.ReferralCodingItem business object (ID: 1096100038).
 */
public class ReferralCodingItemVo extends ims.RefMan.vo.ReferralCodingItemRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public ReferralCodingItemVo()
	{
	}
	public ReferralCodingItemVo(Integer id, int version)
	{
		super(id, version);
	}
	public ReferralCodingItemVo(ims.RefMan.vo.beans.ReferralCodingItemVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.patientprocedure = bean.getPatientProcedure() == null ? null : bean.getPatientProcedure().buildVo();
		this.patientdiagnosis = bean.getPatientDiagnosis() == null ? null : bean.getPatientDiagnosis().buildVo();
		this.opcs4 = bean.getOPCS4();
		this.icd10 = bean.getICD10();
		this.proclaterality = bean.getProcLaterality() == null ? null : ims.core.vo.lookups.LateralityLRB.buildLookup(bean.getProcLaterality());
		this.investigation = bean.getInvestigation() == null ? null : bean.getInvestigation().buildVo();
		this.hrg = bean.getHRG();
		this.daggerasterisk = bean.getDaggerAsterisk();
		this.codingtypeindicator = bean.getCodingTypeIndicator();
		this.firstinset = bean.getFirstInSet();
		this.primarysecondaryind = bean.getPrimarySecondaryInd();
		this.procconsandtheatrecode = bean.getProcConsandTheatreCode();
		this.proceduredatetime = bean.getProcedureDateTime();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.RefMan.vo.beans.ReferralCodingItemVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.patientprocedure = bean.getPatientProcedure() == null ? null : bean.getPatientProcedure().buildVo(map);
		this.patientdiagnosis = bean.getPatientDiagnosis() == null ? null : bean.getPatientDiagnosis().buildVo(map);
		this.opcs4 = bean.getOPCS4();
		this.icd10 = bean.getICD10();
		this.proclaterality = bean.getProcLaterality() == null ? null : ims.core.vo.lookups.LateralityLRB.buildLookup(bean.getProcLaterality());
		this.investigation = bean.getInvestigation() == null ? null : bean.getInvestigation().buildVo(map);
		this.hrg = bean.getHRG();
		this.daggerasterisk = bean.getDaggerAsterisk();
		this.codingtypeindicator = bean.getCodingTypeIndicator();
		this.firstinset = bean.getFirstInSet();
		this.primarysecondaryind = bean.getPrimarySecondaryInd();
		this.procconsandtheatrecode = bean.getProcConsandTheatreCode();
		this.proceduredatetime = bean.getProcedureDateTime();
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.RefMan.vo.beans.ReferralCodingItemVoBean bean = null;
		if(map != null)
			bean = (ims.RefMan.vo.beans.ReferralCodingItemVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.RefMan.vo.beans.ReferralCodingItemVoBean();
			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("PATIENTPROCEDURE"))
			return getPatientProcedure();
		if(fieldName.equals("PATIENTDIAGNOSIS"))
			return getPatientDiagnosis();
		if(fieldName.equals("OPCS4"))
			return getOPCS4();
		if(fieldName.equals("ICD10"))
			return getICD10();
		if(fieldName.equals("PROCLATERALITY"))
			return getProcLaterality();
		if(fieldName.equals("INVESTIGATION"))
			return getInvestigation();
		if(fieldName.equals("HRG"))
			return getHRG();
		if(fieldName.equals("DAGGERASTERISK"))
			return getDaggerAsterisk();
		if(fieldName.equals("CODINGTYPEINDICATOR"))
			return getCodingTypeIndicator();
		if(fieldName.equals("FIRSTINSET"))
			return getFirstInSet();
		if(fieldName.equals("PRIMARYSECONDARYIND"))
			return getPrimarySecondaryInd();
		if(fieldName.equals("PROCCONSANDTHEATRECODE"))
			return getProcConsandTheatreCode();
		if(fieldName.equals("PROCEDUREDATETIME"))
			return getProcedureDateTime();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getPatientProcedureIsNotNull()
	{
		return this.patientprocedure != null;
	}
	public ims.core.vo.PatientProcedureShortWithCareIntraOperativeVo getPatientProcedure()
	{
		return this.patientprocedure;
	}
	public void setPatientProcedure(ims.core.vo.PatientProcedureShortWithCareIntraOperativeVo value)
	{
		this.isValidated = false;
		this.patientprocedure = value;
	}
	public boolean getPatientDiagnosisIsNotNull()
	{
		return this.patientdiagnosis != null;
	}
	public ims.core.vo.PatientDiagnosisShortVo getPatientDiagnosis()
	{
		return this.patientdiagnosis;
	}
	public void setPatientDiagnosis(ims.core.vo.PatientDiagnosisShortVo value)
	{
		this.isValidated = false;
		this.patientdiagnosis = value;
	}
	public boolean getOPCS4IsNotNull()
	{
		return this.opcs4 != null;
	}
	public String getOPCS4()
	{
		return this.opcs4;
	}
	public static int getOPCS4MaxLength()
	{
		return 25;
	}
	public void setOPCS4(String value)
	{
		this.isValidated = false;
		this.opcs4 = value;
	}
	public boolean getICD10IsNotNull()
	{
		return this.icd10 != null;
	}
	public String getICD10()
	{
		return this.icd10;
	}
	public static int getICD10MaxLength()
	{
		return 25;
	}
	public void setICD10(String value)
	{
		this.isValidated = false;
		this.icd10 = value;
	}
	public boolean getProcLateralityIsNotNull()
	{
		return this.proclaterality != null;
	}
	public ims.core.vo.lookups.LateralityLRB getProcLaterality()
	{
		return this.proclaterality;
	}
	public void setProcLaterality(ims.core.vo.lookups.LateralityLRB value)
	{
		this.isValidated = false;
		this.proclaterality = value;
	}
	public boolean getInvestigationIsNotNull()
	{
		return this.investigation != null;
	}
	public ims.ocrr.vo.OrderInvestigationLiteVo getInvestigation()
	{
		return this.investigation;
	}
	public void setInvestigation(ims.ocrr.vo.OrderInvestigationLiteVo value)
	{
		this.isValidated = false;
		this.investigation = value;
	}
	public boolean getHRGIsNotNull()
	{
		return this.hrg != null;
	}
	public String getHRG()
	{
		return this.hrg;
	}
	public static int getHRGMaxLength()
	{
		return 5;
	}
	public void setHRG(String value)
	{
		this.isValidated = false;
		this.hrg = value;
	}
	public boolean getDaggerAsteriskIsNotNull()
	{
		return this.daggerasterisk != null;
	}
	public String getDaggerAsterisk()
	{
		return this.daggerasterisk;
	}
	public static int getDaggerAsteriskMaxLength()
	{
		return 1;
	}
	public void setDaggerAsterisk(String value)
	{
		this.isValidated = false;
		this.daggerasterisk = value;
	}
	public boolean getCodingTypeIndicatorIsNotNull()
	{
		return this.codingtypeindicator != null;
	}
	public String getCodingTypeIndicator()
	{
		return this.codingtypeindicator;
	}
	public static int getCodingTypeIndicatorMaxLength()
	{
		return 3;
	}
	public void setCodingTypeIndicator(String value)
	{
		this.isValidated = false;
		this.codingtypeindicator = value;
	}
	public boolean getFirstInSetIsNotNull()
	{
		return this.firstinset != null;
	}
	public String getFirstInSet()
	{
		return this.firstinset;
	}
	public static int getFirstInSetMaxLength()
	{
		return 1;
	}
	public void setFirstInSet(String value)
	{
		this.isValidated = false;
		this.firstinset = value;
	}
	public boolean getPrimarySecondaryIndIsNotNull()
	{
		return this.primarysecondaryind != null;
	}
	public String getPrimarySecondaryInd()
	{
		return this.primarysecondaryind;
	}
	public static int getPrimarySecondaryIndMaxLength()
	{
		return 1;
	}
	public void setPrimarySecondaryInd(String value)
	{
		this.isValidated = false;
		this.primarysecondaryind = value;
	}
	public boolean getProcConsandTheatreCodeIsNotNull()
	{
		return this.procconsandtheatrecode != null;
	}
	public String getProcConsandTheatreCode()
	{
		return this.procconsandtheatrecode;
	}
	public static int getProcConsandTheatreCodeMaxLength()
	{
		return 16;
	}
	public void setProcConsandTheatreCode(String value)
	{
		this.isValidated = false;
		this.procconsandtheatrecode = value;
	}
	public boolean getProcedureDateTimeIsNotNull()
	{
		return this.proceduredatetime != null;
	}
	public String getProcedureDateTime()
	{
		return this.proceduredatetime;
	}
	public static int getProcedureDateTimeMaxLength()
	{
		return 14;
	}
	public void setProcedureDateTime(String value)
	{
		this.isValidated = false;
		this.proceduredatetime = 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.opcs4 != null)
			if(this.opcs4.length() > 25)
				listOfErrors.add("The length of the field [opcs4] in the value object [ims.RefMan.vo.ReferralCodingItemVo] is too big. It should be less or equal to 25");
		if(this.icd10 != null)
			if(this.icd10.length() > 25)
				listOfErrors.add("The length of the field [icd10] in the value object [ims.RefMan.vo.ReferralCodingItemVo] is too big. It should be less or equal to 25");
		if(this.hrg != null)
			if(this.hrg.length() > 5)
				listOfErrors.add("The length of the field [hrg] in the value object [ims.RefMan.vo.ReferralCodingItemVo] is too big. It should be less or equal to 5");
		if(this.daggerasterisk != null)
			if(this.daggerasterisk.length() > 1)
				listOfErrors.add("The length of the field [daggerasterisk] in the value object [ims.RefMan.vo.ReferralCodingItemVo] is too big. It should be less or equal to 1");
		if(this.codingtypeindicator != null)
			if(this.codingtypeindicator.length() > 3)
				listOfErrors.add("The length of the field [codingtypeindicator] in the value object [ims.RefMan.vo.ReferralCodingItemVo] is too big. It should be less or equal to 3");
		if(this.firstinset != null)
			if(this.firstinset.length() > 1)
				listOfErrors.add("The length of the field [firstinset] in the value object [ims.RefMan.vo.ReferralCodingItemVo] is too big. It should be less or equal to 1");
		if(this.primarysecondaryind != null)
			if(this.primarysecondaryind.length() > 1)
				listOfErrors.add("The length of the field [primarysecondaryind] in the value object [ims.RefMan.vo.ReferralCodingItemVo] is too big. It should be less or equal to 1");
		if(this.procconsandtheatrecode != null)
			if(this.procconsandtheatrecode.length() > 16)
				listOfErrors.add("The length of the field [procconsandtheatrecode] in the value object [ims.RefMan.vo.ReferralCodingItemVo] is too big. It should be less or equal to 16");
		if(this.proceduredatetime != null)
			if(this.proceduredatetime.length() > 14)
				listOfErrors.add("The length of the field [proceduredatetime] in the value object [ims.RefMan.vo.ReferralCodingItemVo] is too big. It should be less or equal to 14");
		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;
	
		ReferralCodingItemVo clone = new ReferralCodingItemVo(this.id, this.version);
		
		if(this.patientprocedure == null)
			clone.patientprocedure = null;
		else
			clone.patientprocedure = (ims.core.vo.PatientProcedureShortWithCareIntraOperativeVo)this.patientprocedure.clone();
		if(this.patientdiagnosis == null)
			clone.patientdiagnosis = null;
		else
			clone.patientdiagnosis = (ims.core.vo.PatientDiagnosisShortVo)this.patientdiagnosis.clone();
		clone.opcs4 = this.opcs4;
		clone.icd10 = this.icd10;
		if(this.proclaterality == null)
			clone.proclaterality = null;
		else
			clone.proclaterality = (ims.core.vo.lookups.LateralityLRB)this.proclaterality.clone();
		if(this.investigation == null)
			clone.investigation = null;
		else
			clone.investigation = (ims.ocrr.vo.OrderInvestigationLiteVo)this.investigation.clone();
		clone.hrg = this.hrg;
		clone.daggerasterisk = this.daggerasterisk;
		clone.codingtypeindicator = this.codingtypeindicator;
		clone.firstinset = this.firstinset;
		clone.primarysecondaryind = this.primarysecondaryind;
		clone.procconsandtheatrecode = this.procconsandtheatrecode;
		clone.proceduredatetime = this.proceduredatetime;
		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 (!(ReferralCodingItemVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A ReferralCodingItemVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((ReferralCodingItemVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((ReferralCodingItemVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.patientprocedure != null)
			count++;
		if(this.patientdiagnosis != null)
			count++;
		if(this.opcs4 != null)
			count++;
		if(this.icd10 != null)
			count++;
		if(this.proclaterality != null)
			count++;
		if(this.investigation != null)
			count++;
		if(this.hrg != null)
			count++;
		if(this.daggerasterisk != null)
			count++;
		if(this.codingtypeindicator != null)
			count++;
		if(this.firstinset != null)
			count++;
		if(this.primarysecondaryind != null)
			count++;
		if(this.procconsandtheatrecode != null)
			count++;
		if(this.proceduredatetime != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 13;
	}
	protected ims.core.vo.PatientProcedureShortWithCareIntraOperativeVo patientprocedure;
	protected ims.core.vo.PatientDiagnosisShortVo patientdiagnosis;
	protected String opcs4;
	protected String icd10;
	protected ims.core.vo.lookups.LateralityLRB proclaterality;
	protected ims.ocrr.vo.OrderInvestigationLiteVo investigation;
	protected String hrg;
	protected String daggerasterisk;
	protected String codingtypeindicator;
	protected String firstinset;
	protected String primarysecondaryind;
	protected String procconsandtheatrecode;
	protected String proceduredatetime;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
