/FileExtraction/Java_unseen/IMS-MAXIMS_openMAXIMS/Source Library/openmaxims_workspace/ValueObjects/src/ims/therapies/vo/WorkOnDischargeVo.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.workLeisureDriving.WorkOnDischarge business object (ID: 1019100079).
 */
public class WorkOnDischargeVo extends ims.therapies.workleisuredriving.vo.WorkOnDischargeRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public WorkOnDischargeVo()
	{
	}
	public WorkOnDischargeVo(Integer id, int version)
	{
		super(id, version);
	}
	public WorkOnDischargeVo(ims.therapies.vo.beans.WorkOnDischargeVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.carecontext = bean.getCareContext() == null ? null : new ims.core.admin.vo.CareContextRefVo(new Integer(bean.getCareContext().getId()), bean.getCareContext().getVersion());
		this.authoringdatetime = bean.getAuthoringDateTime() == null ? null : bean.getAuthoringDateTime().buildDateTime();
		this.authoringcp = bean.getAuthoringCP() == null ? null : bean.getAuthoringCP().buildVo();
		this.positionondischarge = bean.getPositionOnDischarge();
		this.returntoworkdate = bean.getReturnToWorkDate() == null ? null : bean.getReturnToWorkDate().buildDate();
		this.jobposition = bean.getJobPosition();
		this.hours = bean.getHours();
		this.reasonfornotreturning = bean.getReasonForNotReturning();
		this.careeradvice = bean.getCareerAdvice();
		this.occupationalpsychologist = bean.getOccupationalPsychologist();
		this.highereducation = bean.getHigherEducation();
		this.retraining = bean.getRetraining();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.therapies.vo.beans.WorkOnDischargeVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.carecontext = bean.getCareContext() == null ? null : new ims.core.admin.vo.CareContextRefVo(new Integer(bean.getCareContext().getId()), bean.getCareContext().getVersion());
		this.authoringdatetime = bean.getAuthoringDateTime() == null ? null : bean.getAuthoringDateTime().buildDateTime();
		this.authoringcp = bean.getAuthoringCP() == null ? null : bean.getAuthoringCP().buildVo(map);
		this.positionondischarge = bean.getPositionOnDischarge();
		this.returntoworkdate = bean.getReturnToWorkDate() == null ? null : bean.getReturnToWorkDate().buildDate();
		this.jobposition = bean.getJobPosition();
		this.hours = bean.getHours();
		this.reasonfornotreturning = bean.getReasonForNotReturning();
		this.careeradvice = bean.getCareerAdvice();
		this.occupationalpsychologist = bean.getOccupationalPsychologist();
		this.highereducation = bean.getHigherEducation();
		this.retraining = bean.getRetraining();
	}
	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.WorkOnDischargeVoBean bean = null;
		if(map != null)
			bean = (ims.therapies.vo.beans.WorkOnDischargeVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.therapies.vo.beans.WorkOnDischargeVoBean();
			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("CARECONTEXT"))
			return getCareContext();
		if(fieldName.equals("AUTHORINGDATETIME"))
			return getAuthoringDateTime();
		if(fieldName.equals("AUTHORINGCP"))
			return getAuthoringCP();
		if(fieldName.equals("POSITIONONDISCHARGE"))
			return getPositionOnDischarge();
		if(fieldName.equals("RETURNTOWORKDATE"))
			return getReturnToWorkDate();
		if(fieldName.equals("JOBPOSITION"))
			return getJobPosition();
		if(fieldName.equals("HOURS"))
			return getHours();
		if(fieldName.equals("REASONFORNOTRETURNING"))
			return getReasonForNotReturning();
		if(fieldName.equals("CAREERADVICE"))
			return getCareerAdvice();
		if(fieldName.equals("OCCUPATIONALPSYCHOLOGIST"))
			return getOccupationalPsychologist();
		if(fieldName.equals("HIGHEREDUCATION"))
			return getHigherEducation();
		if(fieldName.equals("RETRAINING"))
			return getRetraining();
		return super.getFieldValueByFieldName(fieldName);
	}
	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 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 getPositionOnDischargeIsNotNull()
	{
		return this.positionondischarge != null;
	}
	public String getPositionOnDischarge()
	{
		return this.positionondischarge;
	}
	public static int getPositionOnDischargeMaxLength()
	{
		return 1000;
	}
	public void setPositionOnDischarge(String value)
	{
		this.isValidated = false;
		this.positionondischarge = value;
	}
	public boolean getReturnToWorkDateIsNotNull()
	{
		return this.returntoworkdate != null;
	}
	public ims.framework.utils.Date getReturnToWorkDate()
	{
		return this.returntoworkdate;
	}
	public void setReturnToWorkDate(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.returntoworkdate = value;
	}
	public boolean getJobPositionIsNotNull()
	{
		return this.jobposition != null;
	}
	public String getJobPosition()
	{
		return this.jobposition;
	}
	public static int getJobPositionMaxLength()
	{
		return 100;
	}
	public void setJobPosition(String value)
	{
		this.isValidated = false;
		this.jobposition = value;
	}
	public boolean getHoursIsNotNull()
	{
		return this.hours != null;
	}
	public String getHours()
	{
		return this.hours;
	}
	public static int getHoursMaxLength()
	{
		return 100;
	}
	public void setHours(String value)
	{
		this.isValidated = false;
		this.hours = value;
	}
	public boolean getReasonForNotReturningIsNotNull()
	{
		return this.reasonfornotreturning != null;
	}
	public String getReasonForNotReturning()
	{
		return this.reasonfornotreturning;
	}
	public static int getReasonForNotReturningMaxLength()
	{
		return 1000;
	}
	public void setReasonForNotReturning(String value)
	{
		this.isValidated = false;
		this.reasonfornotreturning = value;
	}
	public boolean getCareerAdviceIsNotNull()
	{
		return this.careeradvice != null;
	}
	public String getCareerAdvice()
	{
		return this.careeradvice;
	}
	public static int getCareerAdviceMaxLength()
	{
		return 1000;
	}
	public void setCareerAdvice(String value)
	{
		this.isValidated = false;
		this.careeradvice = value;
	}
	public boolean getOccupationalPsychologistIsNotNull()
	{
		return this.occupationalpsychologist != null;
	}
	public String getOccupationalPsychologist()
	{
		return this.occupationalpsychologist;
	}
	public static int getOccupationalPsychologistMaxLength()
	{
		return 1000;
	}
	public void setOccupationalPsychologist(String value)
	{
		this.isValidated = false;
		this.occupationalpsychologist = value;
	}
	public boolean getHigherEducationIsNotNull()
	{
		return this.highereducation != null;
	}
	public String getHigherEducation()
	{
		return this.highereducation;
	}
	public static int getHigherEducationMaxLength()
	{
		return 1000;
	}
	public void setHigherEducation(String value)
	{
		this.isValidated = false;
		this.highereducation = value;
	}
	public boolean getRetrainingIsNotNull()
	{
		return this.retraining != null;
	}
	public String getRetraining()
	{
		return this.retraining;
	}
	public static int getRetrainingMaxLength()
	{
		return 1000;
	}
	public void setRetraining(String value)
	{
		this.isValidated = false;
		this.retraining = 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;
			}
		}
		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.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.positionondischarge != null)
			if(this.positionondischarge.length() > 1000)
				listOfErrors.add("The length of the field [positionondischarge] in the value object [ims.therapies.vo.WorkOnDischargeVo] is too big. It should be less or equal to 1000");
		if(this.jobposition != null)
			if(this.jobposition.length() > 100)
				listOfErrors.add("The length of the field [jobposition] in the value object [ims.therapies.vo.WorkOnDischargeVo] is too big. It should be less or equal to 100");
		if(this.hours != null)
			if(this.hours.length() > 100)
				listOfErrors.add("The length of the field [hours] in the value object [ims.therapies.vo.WorkOnDischargeVo] is too big. It should be less or equal to 100");
		if(this.reasonfornotreturning != null)
			if(this.reasonfornotreturning.length() > 1000)
				listOfErrors.add("The length of the field [reasonfornotreturning] in the value object [ims.therapies.vo.WorkOnDischargeVo] is too big. It should be less or equal to 1000");
		if(this.careeradvice != null)
			if(this.careeradvice.length() > 1000)
				listOfErrors.add("The length of the field [careeradvice] in the value object [ims.therapies.vo.WorkOnDischargeVo] is too big. It should be less or equal to 1000");
		if(this.occupationalpsychologist != null)
			if(this.occupationalpsychologist.length() > 1000)
				listOfErrors.add("The length of the field [occupationalpsychologist] in the value object [ims.therapies.vo.WorkOnDischargeVo] is too big. It should be less or equal to 1000");
		if(this.highereducation != null)
			if(this.highereducation.length() > 1000)
				listOfErrors.add("The length of the field [highereducation] in the value object [ims.therapies.vo.WorkOnDischargeVo] is too big. It should be less or equal to 1000");
		if(this.retraining != null)
			if(this.retraining.length() > 1000)
				listOfErrors.add("The length of the field [retraining] in the value object [ims.therapies.vo.WorkOnDischargeVo] 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;
	
		WorkOnDischargeVo clone = new WorkOnDischargeVo(this.id, this.version);
		
		clone.carecontext = this.carecontext;
		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();
		clone.positionondischarge = this.positionondischarge;
		if(this.returntoworkdate == null)
			clone.returntoworkdate = null;
		else
			clone.returntoworkdate = (ims.framework.utils.Date)this.returntoworkdate.clone();
		clone.jobposition = this.jobposition;
		clone.hours = this.hours;
		clone.reasonfornotreturning = this.reasonfornotreturning;
		clone.careeradvice = this.careeradvice;
		clone.occupationalpsychologist = this.occupationalpsychologist;
		clone.highereducation = this.highereducation;
		clone.retraining = this.retraining;
		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 (!(WorkOnDischargeVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A WorkOnDischargeVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((WorkOnDischargeVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((WorkOnDischargeVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.positionondischarge != null)
			count++;
		if(this.returntoworkdate != null)
			count++;
		if(this.jobposition != null)
			count++;
		if(this.hours != null)
			count++;
		if(this.reasonfornotreturning != null)
			count++;
		if(this.careeradvice != null)
			count++;
		if(this.occupationalpsychologist != null)
			count++;
		if(this.highereducation != null)
			count++;
		if(this.retraining != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 9;
	}
	protected ims.core.admin.vo.CareContextRefVo carecontext;
	protected ims.framework.utils.DateTime authoringdatetime;
	protected ims.core.vo.Hcp authoringcp;
	protected String positionondischarge;
	protected ims.framework.utils.Date returntoworkdate;
	protected String jobposition;
	protected String hours;
	protected String reasonfornotreturning;
	protected String careeradvice;
	protected String occupationalpsychologist;
	protected String highereducation;
	protected String retraining;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
