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

	public ReferralLetterDetailsForElectiveListDetailsVo()
	{
	}
	public ReferralLetterDetailsForElectiveListDetailsVo(Integer id, int version)
	{
		super(id, version);
	}
	public ReferralLetterDetailsForElectiveListDetailsVo(ims.RefMan.vo.beans.ReferralLetterDetailsForElectiveListDetailsVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.service = bean.getService() == null ? null : bean.getService().buildVo();
		this.end18ww = bean.getEnd18WW() == null ? null : bean.getEnd18WW().buildDate();
		this.interpreterrequired = bean.getInterpreterRequired() == null ? null : ims.core.vo.lookups.YesNo.buildLookup(bean.getInterpreterRequired());
		this.language = bean.getLanguage() == null ? null : ims.core.vo.lookups.Language.buildLookup(bean.getLanguage());
		this.transportrequired = bean.getTransportRequired() == null ? null : ims.core.vo.lookups.YesNo.buildLookup(bean.getTransportRequired());
		this.transport = bean.getTransport() == null ? null : ims.scheduling.vo.lookups.ApptTransportType.buildLookup(bean.getTransport());
		this.specialrequirements = bean.getSpecialRequirements();
		this.consultant = bean.getConsultant() == null ? null : bean.getConsultant().buildVo();
		this.referrertype = bean.getReferrerType() == null ? null : ims.core.vo.lookups.SourceOfReferral.buildLookup(bean.getReferrerType());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.RefMan.vo.beans.ReferralLetterDetailsForElectiveListDetailsVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.service = bean.getService() == null ? null : bean.getService().buildVo(map);
		this.end18ww = bean.getEnd18WW() == null ? null : bean.getEnd18WW().buildDate();
		this.interpreterrequired = bean.getInterpreterRequired() == null ? null : ims.core.vo.lookups.YesNo.buildLookup(bean.getInterpreterRequired());
		this.language = bean.getLanguage() == null ? null : ims.core.vo.lookups.Language.buildLookup(bean.getLanguage());
		this.transportrequired = bean.getTransportRequired() == null ? null : ims.core.vo.lookups.YesNo.buildLookup(bean.getTransportRequired());
		this.transport = bean.getTransport() == null ? null : ims.scheduling.vo.lookups.ApptTransportType.buildLookup(bean.getTransport());
		this.specialrequirements = bean.getSpecialRequirements();
		this.consultant = bean.getConsultant() == null ? null : bean.getConsultant().buildVo(map);
		this.referrertype = bean.getReferrerType() == null ? null : ims.core.vo.lookups.SourceOfReferral.buildLookup(bean.getReferrerType());
	}
	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.ReferralLetterDetailsForElectiveListDetailsVoBean bean = null;
		if(map != null)
			bean = (ims.RefMan.vo.beans.ReferralLetterDetailsForElectiveListDetailsVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.RefMan.vo.beans.ReferralLetterDetailsForElectiveListDetailsVoBean();
			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("SERVICE"))
			return getService();
		if(fieldName.equals("END18WW"))
			return getEnd18WW();
		if(fieldName.equals("INTERPRETERREQUIRED"))
			return getInterpreterRequired();
		if(fieldName.equals("LANGUAGE"))
			return getLanguage();
		if(fieldName.equals("TRANSPORTREQUIRED"))
			return getTransportRequired();
		if(fieldName.equals("TRANSPORT"))
			return getTransport();
		if(fieldName.equals("SPECIALREQUIREMENTS"))
			return getSpecialRequirements();
		if(fieldName.equals("CONSULTANT"))
			return getConsultant();
		if(fieldName.equals("REFERRERTYPE"))
			return getReferrerType();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getServiceIsNotNull()
	{
		return this.service != null;
	}
	public ims.core.vo.ServiceLiteVo getService()
	{
		return this.service;
	}
	public void setService(ims.core.vo.ServiceLiteVo value)
	{
		this.isValidated = false;
		this.service = value;
	}
	public boolean getEnd18WWIsNotNull()
	{
		return this.end18ww != null;
	}
	public ims.framework.utils.Date getEnd18WW()
	{
		return this.end18ww;
	}
	public void setEnd18WW(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.end18ww = value;
	}
	public boolean getInterpreterRequiredIsNotNull()
	{
		return this.interpreterrequired != null;
	}
	public ims.core.vo.lookups.YesNo getInterpreterRequired()
	{
		return this.interpreterrequired;
	}
	public void setInterpreterRequired(ims.core.vo.lookups.YesNo value)
	{
		this.isValidated = false;
		this.interpreterrequired = value;
	}
	public boolean getLanguageIsNotNull()
	{
		return this.language != null;
	}
	public ims.core.vo.lookups.Language getLanguage()
	{
		return this.language;
	}
	public void setLanguage(ims.core.vo.lookups.Language value)
	{
		this.isValidated = false;
		this.language = value;
	}
	public boolean getTransportRequiredIsNotNull()
	{
		return this.transportrequired != null;
	}
	public ims.core.vo.lookups.YesNo getTransportRequired()
	{
		return this.transportrequired;
	}
	public void setTransportRequired(ims.core.vo.lookups.YesNo value)
	{
		this.isValidated = false;
		this.transportrequired = value;
	}
	public boolean getTransportIsNotNull()
	{
		return this.transport != null;
	}
	public ims.scheduling.vo.lookups.ApptTransportType getTransport()
	{
		return this.transport;
	}
	public void setTransport(ims.scheduling.vo.lookups.ApptTransportType value)
	{
		this.isValidated = false;
		this.transport = value;
	}
	public boolean getSpecialRequirementsIsNotNull()
	{
		return this.specialrequirements != null;
	}
	public String getSpecialRequirements()
	{
		return this.specialrequirements;
	}
	public static int getSpecialRequirementsMaxLength()
	{
		return 255;
	}
	public void setSpecialRequirements(String value)
	{
		this.isValidated = false;
		this.specialrequirements = value;
	}
	public boolean getConsultantIsNotNull()
	{
		return this.consultant != null;
	}
	public ims.core.vo.HcpLiteVo getConsultant()
	{
		return this.consultant;
	}
	public void setConsultant(ims.core.vo.HcpLiteVo value)
	{
		this.isValidated = false;
		this.consultant = value;
	}
	public boolean getReferrerTypeIsNotNull()
	{
		return this.referrertype != null;
	}
	public ims.core.vo.lookups.SourceOfReferral getReferrerType()
	{
		return this.referrertype;
	}
	public void setReferrerType(ims.core.vo.lookups.SourceOfReferral value)
	{
		this.isValidated = false;
		this.referrertype = 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.service == null)
			listOfErrors.add("Service is mandatory");
		if(this.specialrequirements != null)
			if(this.specialrequirements.length() > 255)
				listOfErrors.add("The length of the field [specialrequirements] in the value object [ims.RefMan.vo.ReferralLetterDetailsForElectiveListDetailsVo] is too big. It should be less or equal to 255");
		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;
	
		ReferralLetterDetailsForElectiveListDetailsVo clone = new ReferralLetterDetailsForElectiveListDetailsVo(this.id, this.version);
		
		if(this.service == null)
			clone.service = null;
		else
			clone.service = (ims.core.vo.ServiceLiteVo)this.service.clone();
		if(this.end18ww == null)
			clone.end18ww = null;
		else
			clone.end18ww = (ims.framework.utils.Date)this.end18ww.clone();
		if(this.interpreterrequired == null)
			clone.interpreterrequired = null;
		else
			clone.interpreterrequired = (ims.core.vo.lookups.YesNo)this.interpreterrequired.clone();
		if(this.language == null)
			clone.language = null;
		else
			clone.language = (ims.core.vo.lookups.Language)this.language.clone();
		if(this.transportrequired == null)
			clone.transportrequired = null;
		else
			clone.transportrequired = (ims.core.vo.lookups.YesNo)this.transportrequired.clone();
		if(this.transport == null)
			clone.transport = null;
		else
			clone.transport = (ims.scheduling.vo.lookups.ApptTransportType)this.transport.clone();
		clone.specialrequirements = this.specialrequirements;
		if(this.consultant == null)
			clone.consultant = null;
		else
			clone.consultant = (ims.core.vo.HcpLiteVo)this.consultant.clone();
		if(this.referrertype == null)
			clone.referrertype = null;
		else
			clone.referrertype = (ims.core.vo.lookups.SourceOfReferral)this.referrertype.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 (!(ReferralLetterDetailsForElectiveListDetailsVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A ReferralLetterDetailsForElectiveListDetailsVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((ReferralLetterDetailsForElectiveListDetailsVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((ReferralLetterDetailsForElectiveListDetailsVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.service != null)
			count++;
		if(this.end18ww != null)
			count++;
		if(this.interpreterrequired != null)
			count++;
		if(this.language != null)
			count++;
		if(this.transportrequired != null)
			count++;
		if(this.transport != null)
			count++;
		if(this.specialrequirements != null)
			count++;
		if(this.consultant != null)
			count++;
		if(this.referrertype != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 9;
	}
	protected ims.core.vo.ServiceLiteVo service;
	protected ims.framework.utils.Date end18ww;
	protected ims.core.vo.lookups.YesNo interpreterrequired;
	protected ims.core.vo.lookups.Language language;
	protected ims.core.vo.lookups.YesNo transportrequired;
	protected ims.scheduling.vo.lookups.ApptTransportType transport;
	protected String specialrequirements;
	protected ims.core.vo.HcpLiteVo consultant;
	protected ims.core.vo.lookups.SourceOfReferral referrertype;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
