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

/**
 * Linked to therapies.MobilityTransfers.WheelchairDetails business object (ID: 1019100045).
 */
public class WheelchairDetailsVo extends ims.therapies.mobilitytransfers.vo.WheelchairDetailsRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public WheelchairDetailsVo()
	{
	}
	public WheelchairDetailsVo(Integer id, int version)
	{
		super(id, version);
	}
	public WheelchairDetailsVo(ims.therapies.vo.beans.WheelchairDetailsVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.authoringdatetime = bean.getAuthoringDateTime() == null ? null : bean.getAuthoringDateTime().buildDateTime();
		this.wheelchairtype = bean.getWheelchairType() == null ? null : ims.spinalinjuries.vo.lookups.WheelchairType.buildLookup(bean.getWheelchairType());
		this.wheelchairmodel = bean.getWheelchairModel() == null ? null : ims.spinalinjuries.vo.lookups.WheelchairType.buildLookup(bean.getWheelchairModel());
		this.wheelchairframe = bean.getWheelchairFrame() == null ? null : ims.spinalinjuries.vo.lookups.WheelchairFrame.buildLookup(bean.getWheelchairFrame());
		this.wheelchairfootplates = bean.getWheelchairFootplates() == null ? null : ims.spinalinjuries.vo.lookups.WheelchairFootplates.buildLookup(bean.getWheelchairFootplates());
		this.seatwidth = bean.getSeatWidth();
		this.seatdepth = bean.getSeatDepth();
		this.seatoverallwidth = bean.getSeatOverallWidth();
		this.trialstartdate = bean.getTrialStartDate() == null ? null : bean.getTrialStartDate().buildDate();
		this.trialenddate = bean.getTrialEndDate() == null ? null : bean.getTrialEndDate().buildDate();
		this.wheelchairaccessories = bean.getWheelchairAccessories();
		this.wheelchaircomments = bean.getWheelchairComments();
		this.carecontext = bean.getCareContext() == null ? null : new ims.core.admin.vo.CareContextRefVo(new Integer(bean.getCareContext().getId()), bean.getCareContext().getVersion());
		this.clinicalcontact = bean.getClinicalContact() == null ? null : new ims.core.admin.vo.ClinicalContactRefVo(new Integer(bean.getClinicalContact().getId()), bean.getClinicalContact().getVersion());
		this.authoringhcp = bean.getAuthoringHCP() == null ? null : bean.getAuthoringHCP().buildVo();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.therapies.vo.beans.WheelchairDetailsVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.authoringdatetime = bean.getAuthoringDateTime() == null ? null : bean.getAuthoringDateTime().buildDateTime();
		this.wheelchairtype = bean.getWheelchairType() == null ? null : ims.spinalinjuries.vo.lookups.WheelchairType.buildLookup(bean.getWheelchairType());
		this.wheelchairmodel = bean.getWheelchairModel() == null ? null : ims.spinalinjuries.vo.lookups.WheelchairType.buildLookup(bean.getWheelchairModel());
		this.wheelchairframe = bean.getWheelchairFrame() == null ? null : ims.spinalinjuries.vo.lookups.WheelchairFrame.buildLookup(bean.getWheelchairFrame());
		this.wheelchairfootplates = bean.getWheelchairFootplates() == null ? null : ims.spinalinjuries.vo.lookups.WheelchairFootplates.buildLookup(bean.getWheelchairFootplates());
		this.seatwidth = bean.getSeatWidth();
		this.seatdepth = bean.getSeatDepth();
		this.seatoverallwidth = bean.getSeatOverallWidth();
		this.trialstartdate = bean.getTrialStartDate() == null ? null : bean.getTrialStartDate().buildDate();
		this.trialenddate = bean.getTrialEndDate() == null ? null : bean.getTrialEndDate().buildDate();
		this.wheelchairaccessories = bean.getWheelchairAccessories();
		this.wheelchaircomments = bean.getWheelchairComments();
		this.carecontext = bean.getCareContext() == null ? null : new ims.core.admin.vo.CareContextRefVo(new Integer(bean.getCareContext().getId()), bean.getCareContext().getVersion());
		this.clinicalcontact = bean.getClinicalContact() == null ? null : new ims.core.admin.vo.ClinicalContactRefVo(new Integer(bean.getClinicalContact().getId()), bean.getClinicalContact().getVersion());
		this.authoringhcp = bean.getAuthoringHCP() == null ? null : bean.getAuthoringHCP().buildVo(map);
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.therapies.vo.beans.WheelchairDetailsVoBean bean = null;
		if(map != null)
			bean = (ims.therapies.vo.beans.WheelchairDetailsVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.therapies.vo.beans.WheelchairDetailsVoBean();
			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("AUTHORINGDATETIME"))
			return getAuthoringDateTime();
		if(fieldName.equals("WHEELCHAIRTYPE"))
			return getWheelchairType();
		if(fieldName.equals("WHEELCHAIRMODEL"))
			return getWheelchairModel();
		if(fieldName.equals("WHEELCHAIRFRAME"))
			return getWheelchairFrame();
		if(fieldName.equals("WHEELCHAIRFOOTPLATES"))
			return getWheelchairFootplates();
		if(fieldName.equals("SEATWIDTH"))
			return getSeatWidth();
		if(fieldName.equals("SEATDEPTH"))
			return getSeatDepth();
		if(fieldName.equals("SEATOVERALLWIDTH"))
			return getSeatOverallWidth();
		if(fieldName.equals("TRIALSTARTDATE"))
			return getTrialStartDate();
		if(fieldName.equals("TRIALENDDATE"))
			return getTrialEndDate();
		if(fieldName.equals("WHEELCHAIRACCESSORIES"))
			return getWheelchairAccessories();
		if(fieldName.equals("WHEELCHAIRCOMMENTS"))
			return getWheelchairComments();
		if(fieldName.equals("CARECONTEXT"))
			return getCareContext();
		if(fieldName.equals("CLINICALCONTACT"))
			return getClinicalContact();
		if(fieldName.equals("AUTHORINGHCP"))
			return getAuthoringHCP();
		return super.getFieldValueByFieldName(fieldName);
	}
	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 getWheelchairTypeIsNotNull()
	{
		return this.wheelchairtype != null;
	}
	public ims.spinalinjuries.vo.lookups.WheelchairType getWheelchairType()
	{
		return this.wheelchairtype;
	}
	public void setWheelchairType(ims.spinalinjuries.vo.lookups.WheelchairType value)
	{
		this.isValidated = false;
		this.wheelchairtype = value;
	}
	public boolean getWheelchairModelIsNotNull()
	{
		return this.wheelchairmodel != null;
	}
	public ims.spinalinjuries.vo.lookups.WheelchairType getWheelchairModel()
	{
		return this.wheelchairmodel;
	}
	public void setWheelchairModel(ims.spinalinjuries.vo.lookups.WheelchairType value)
	{
		this.isValidated = false;
		this.wheelchairmodel = value;
	}
	public boolean getWheelchairFrameIsNotNull()
	{
		return this.wheelchairframe != null;
	}
	public ims.spinalinjuries.vo.lookups.WheelchairFrame getWheelchairFrame()
	{
		return this.wheelchairframe;
	}
	public void setWheelchairFrame(ims.spinalinjuries.vo.lookups.WheelchairFrame value)
	{
		this.isValidated = false;
		this.wheelchairframe = value;
	}
	public boolean getWheelchairFootplatesIsNotNull()
	{
		return this.wheelchairfootplates != null;
	}
	public ims.spinalinjuries.vo.lookups.WheelchairFootplates getWheelchairFootplates()
	{
		return this.wheelchairfootplates;
	}
	public void setWheelchairFootplates(ims.spinalinjuries.vo.lookups.WheelchairFootplates value)
	{
		this.isValidated = false;
		this.wheelchairfootplates = value;
	}
	public boolean getSeatWidthIsNotNull()
	{
		return this.seatwidth != null;
	}
	public Integer getSeatWidth()
	{
		return this.seatwidth;
	}
	public void setSeatWidth(Integer value)
	{
		this.isValidated = false;
		this.seatwidth = value;
	}
	public boolean getSeatDepthIsNotNull()
	{
		return this.seatdepth != null;
	}
	public Integer getSeatDepth()
	{
		return this.seatdepth;
	}
	public void setSeatDepth(Integer value)
	{
		this.isValidated = false;
		this.seatdepth = value;
	}
	public boolean getSeatOverallWidthIsNotNull()
	{
		return this.seatoverallwidth != null;
	}
	public Integer getSeatOverallWidth()
	{
		return this.seatoverallwidth;
	}
	public void setSeatOverallWidth(Integer value)
	{
		this.isValidated = false;
		this.seatoverallwidth = value;
	}
	public boolean getTrialStartDateIsNotNull()
	{
		return this.trialstartdate != null;
	}
	public ims.framework.utils.Date getTrialStartDate()
	{
		return this.trialstartdate;
	}
	public void setTrialStartDate(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.trialstartdate = value;
	}
	public boolean getTrialEndDateIsNotNull()
	{
		return this.trialenddate != null;
	}
	public ims.framework.utils.Date getTrialEndDate()
	{
		return this.trialenddate;
	}
	public void setTrialEndDate(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.trialenddate = value;
	}
	public boolean getWheelchairAccessoriesIsNotNull()
	{
		return this.wheelchairaccessories != null;
	}
	public String getWheelchairAccessories()
	{
		return this.wheelchairaccessories;
	}
	public static int getWheelchairAccessoriesMaxLength()
	{
		return 255;
	}
	public void setWheelchairAccessories(String value)
	{
		this.isValidated = false;
		this.wheelchairaccessories = value;
	}
	public boolean getWheelchairCommentsIsNotNull()
	{
		return this.wheelchaircomments != null;
	}
	public String getWheelchairComments()
	{
		return this.wheelchaircomments;
	}
	public static int getWheelchairCommentsMaxLength()
	{
		return 255;
	}
	public void setWheelchairComments(String value)
	{
		this.isValidated = false;
		this.wheelchaircomments = 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 getClinicalContactIsNotNull()
	{
		return this.clinicalcontact != null;
	}
	public ims.core.admin.vo.ClinicalContactRefVo getClinicalContact()
	{
		return this.clinicalcontact;
	}
	public void setClinicalContact(ims.core.admin.vo.ClinicalContactRefVo value)
	{
		this.isValidated = false;
		this.clinicalcontact = value;
	}
	public boolean getAuthoringHCPIsNotNull()
	{
		return this.authoringhcp != null;
	}
	public ims.core.vo.Hcp getAuthoringHCP()
	{
		return this.authoringhcp;
	}
	public void setAuthoringHCP(ims.core.vo.Hcp value)
	{
		this.isValidated = false;
		this.authoringhcp = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.authoringhcp != null)
		{
			if(!this.authoringhcp.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.authoringdatetime == null)
			listOfErrors.add("Please enter Date/Time.");
		if(this.wheelchairtype == null)
			listOfErrors.add("Please enter Wheelchair Type.");
		if(this.wheelchairmodel == null)
			listOfErrors.add("Please enter Wheelchair Model.");
		if(this.wheelchairaccessories != null)
			if(this.wheelchairaccessories.length() > 255)
				listOfErrors.add("The length of the field [wheelchairaccessories] in the value object [ims.therapies.vo.WheelchairDetailsVo] is too big. It should be less or equal to 255");
		if(this.wheelchaircomments != null)
			if(this.wheelchaircomments.length() > 255)
				listOfErrors.add("The length of the field [wheelchaircomments] in the value object [ims.therapies.vo.WheelchairDetailsVo] is too big. It should be less or equal to 255");
		if(this.carecontext == null)
			listOfErrors.add("CareContext is mandatory");
		if(this.authoringhcp == null)
			listOfErrors.add("AuthoringHCP is mandatory");
		if(this.authoringhcp != null)
		{
			String[] listOfOtherErrors = this.authoringhcp.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;
	
		WheelchairDetailsVo clone = new WheelchairDetailsVo(this.id, this.version);
		
		if(this.authoringdatetime == null)
			clone.authoringdatetime = null;
		else
			clone.authoringdatetime = (ims.framework.utils.DateTime)this.authoringdatetime.clone();
		if(this.wheelchairtype == null)
			clone.wheelchairtype = null;
		else
			clone.wheelchairtype = (ims.spinalinjuries.vo.lookups.WheelchairType)this.wheelchairtype.clone();
		if(this.wheelchairmodel == null)
			clone.wheelchairmodel = null;
		else
			clone.wheelchairmodel = (ims.spinalinjuries.vo.lookups.WheelchairType)this.wheelchairmodel.clone();
		if(this.wheelchairframe == null)
			clone.wheelchairframe = null;
		else
			clone.wheelchairframe = (ims.spinalinjuries.vo.lookups.WheelchairFrame)this.wheelchairframe.clone();
		if(this.wheelchairfootplates == null)
			clone.wheelchairfootplates = null;
		else
			clone.wheelchairfootplates = (ims.spinalinjuries.vo.lookups.WheelchairFootplates)this.wheelchairfootplates.clone();
		clone.seatwidth = this.seatwidth;
		clone.seatdepth = this.seatdepth;
		clone.seatoverallwidth = this.seatoverallwidth;
		if(this.trialstartdate == null)
			clone.trialstartdate = null;
		else
			clone.trialstartdate = (ims.framework.utils.Date)this.trialstartdate.clone();
		if(this.trialenddate == null)
			clone.trialenddate = null;
		else
			clone.trialenddate = (ims.framework.utils.Date)this.trialenddate.clone();
		clone.wheelchairaccessories = this.wheelchairaccessories;
		clone.wheelchaircomments = this.wheelchaircomments;
		clone.carecontext = this.carecontext;
		clone.clinicalcontact = this.clinicalcontact;
		if(this.authoringhcp == null)
			clone.authoringhcp = null;
		else
			clone.authoringhcp = (ims.core.vo.Hcp)this.authoringhcp.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 (!(WheelchairDetailsVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A WheelchairDetailsVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		WheelchairDetailsVo compareObj = (WheelchairDetailsVo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getID_WheelchairDetails() == null && compareObj.getID_WheelchairDetails() != null)
				return -1;
			if(this.getID_WheelchairDetails() != null && compareObj.getID_WheelchairDetails() == null)
				return 1;
			if(this.getID_WheelchairDetails() != null && compareObj.getID_WheelchairDetails() != null)
				retVal = this.getID_WheelchairDetails().compareTo(compareObj.getID_WheelchairDetails());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.authoringdatetime != null)
			count++;
		if(this.wheelchairtype != null)
			count++;
		if(this.wheelchairmodel != null)
			count++;
		if(this.wheelchairframe != null)
			count++;
		if(this.wheelchairfootplates != null)
			count++;
		if(this.seatwidth != null)
			count++;
		if(this.seatdepth != null)
			count++;
		if(this.seatoverallwidth != null)
			count++;
		if(this.trialstartdate != null)
			count++;
		if(this.trialenddate != null)
			count++;
		if(this.wheelchairaccessories != null)
			count++;
		if(this.wheelchaircomments != null)
			count++;
		if(this.carecontext != null)
			count++;
		if(this.clinicalcontact != null)
			count++;
		if(this.authoringhcp != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 15;
	}
	protected ims.framework.utils.DateTime authoringdatetime;
	protected ims.spinalinjuries.vo.lookups.WheelchairType wheelchairtype;
	protected ims.spinalinjuries.vo.lookups.WheelchairType wheelchairmodel;
	protected ims.spinalinjuries.vo.lookups.WheelchairFrame wheelchairframe;
	protected ims.spinalinjuries.vo.lookups.WheelchairFootplates wheelchairfootplates;
	protected Integer seatwidth;
	protected Integer seatdepth;
	protected Integer seatoverallwidth;
	protected ims.framework.utils.Date trialstartdate;
	protected ims.framework.utils.Date trialenddate;
	protected String wheelchairaccessories;
	protected String wheelchaircomments;
	protected ims.core.admin.vo.CareContextRefVo carecontext;
	protected ims.core.admin.vo.ClinicalContactRefVo clinicalcontact;
	protected ims.core.vo.Hcp authoringhcp;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
