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

	public WheelchairReferralVo()
	{
	}
	public WheelchairReferralVo(Integer id, int version)
	{
		super(id, version);
	}
	public WheelchairReferralVo(ims.therapies.vo.beans.WheelchairReferralVoBean 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.referraldate = bean.getReferralDate() == null ? null : bean.getReferralDate().buildDate();
		this.assessmentdate = bean.getAssessmentDate() == null ? null : bean.getAssessmentDate().buildDate();
		this.chairtype = bean.getChairType() == null ? null : ims.spinalinjuries.vo.lookups.WheelchairType.buildLookup(bean.getChairType());
		this.wheelchairauthority = bean.getWheelchairAuthority();
		this.wheelchairtherapist = bean.getWheelchairTherapist();
		this.outcomeofassessment = bean.getOutcomeOfAssessment();
		this.dischargedate = bean.getDischargeDate() == null ? null : bean.getDischargeDate().buildDate();
		this.dischargedetails = bean.getDischargeDetails();
		this.otherassessmentinfo = bean.getOtherAssessmentInfo();
		this.patientinformed = bean.getPatientInformed() == null ? null : ims.core.vo.lookups.YesNoUnknown.buildLookup(bean.getPatientInformed());
		this.clinicalcontact = bean.getClinicalContact() == null ? null : new ims.core.admin.vo.ClinicalContactRefVo(new Integer(bean.getClinicalContact().getId()), bean.getClinicalContact().getVersion());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.therapies.vo.beans.WheelchairReferralVoBean 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.referraldate = bean.getReferralDate() == null ? null : bean.getReferralDate().buildDate();
		this.assessmentdate = bean.getAssessmentDate() == null ? null : bean.getAssessmentDate().buildDate();
		this.chairtype = bean.getChairType() == null ? null : ims.spinalinjuries.vo.lookups.WheelchairType.buildLookup(bean.getChairType());
		this.wheelchairauthority = bean.getWheelchairAuthority();
		this.wheelchairtherapist = bean.getWheelchairTherapist();
		this.outcomeofassessment = bean.getOutcomeOfAssessment();
		this.dischargedate = bean.getDischargeDate() == null ? null : bean.getDischargeDate().buildDate();
		this.dischargedetails = bean.getDischargeDetails();
		this.otherassessmentinfo = bean.getOtherAssessmentInfo();
		this.patientinformed = bean.getPatientInformed() == null ? null : ims.core.vo.lookups.YesNoUnknown.buildLookup(bean.getPatientInformed());
		this.clinicalcontact = bean.getClinicalContact() == null ? null : new ims.core.admin.vo.ClinicalContactRefVo(new Integer(bean.getClinicalContact().getId()), bean.getClinicalContact().getVersion());
	}
	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.WheelchairReferralVoBean bean = null;
		if(map != null)
			bean = (ims.therapies.vo.beans.WheelchairReferralVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.therapies.vo.beans.WheelchairReferralVoBean();
			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("REFERRALDATE"))
			return getReferralDate();
		if(fieldName.equals("ASSESSMENTDATE"))
			return getAssessmentDate();
		if(fieldName.equals("CHAIRTYPE"))
			return getChairType();
		if(fieldName.equals("WHEELCHAIRAUTHORITY"))
			return getWheelchairAuthority();
		if(fieldName.equals("WHEELCHAIRTHERAPIST"))
			return getWheelchairTherapist();
		if(fieldName.equals("OUTCOMEOFASSESSMENT"))
			return getOutcomeOfAssessment();
		if(fieldName.equals("DISCHARGEDATE"))
			return getDischargeDate();
		if(fieldName.equals("DISCHARGEDETAILS"))
			return getDischargeDetails();
		if(fieldName.equals("OTHERASSESSMENTINFO"))
			return getOtherAssessmentInfo();
		if(fieldName.equals("PATIENTINFORMED"))
			return getPatientInformed();
		if(fieldName.equals("CLINICALCONTACT"))
			return getClinicalContact();
		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 getReferralDateIsNotNull()
	{
		return this.referraldate != null;
	}
	public ims.framework.utils.Date getReferralDate()
	{
		return this.referraldate;
	}
	public void setReferralDate(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.referraldate = value;
	}
	public boolean getAssessmentDateIsNotNull()
	{
		return this.assessmentdate != null;
	}
	public ims.framework.utils.Date getAssessmentDate()
	{
		return this.assessmentdate;
	}
	public void setAssessmentDate(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.assessmentdate = value;
	}
	public boolean getChairTypeIsNotNull()
	{
		return this.chairtype != null;
	}
	public ims.spinalinjuries.vo.lookups.WheelchairType getChairType()
	{
		return this.chairtype;
	}
	public void setChairType(ims.spinalinjuries.vo.lookups.WheelchairType value)
	{
		this.isValidated = false;
		this.chairtype = value;
	}
	public boolean getWheelchairAuthorityIsNotNull()
	{
		return this.wheelchairauthority != null;
	}
	public String getWheelchairAuthority()
	{
		return this.wheelchairauthority;
	}
	public static int getWheelchairAuthorityMaxLength()
	{
		return 255;
	}
	public void setWheelchairAuthority(String value)
	{
		this.isValidated = false;
		this.wheelchairauthority = value;
	}
	public boolean getWheelchairTherapistIsNotNull()
	{
		return this.wheelchairtherapist != null;
	}
	public String getWheelchairTherapist()
	{
		return this.wheelchairtherapist;
	}
	public static int getWheelchairTherapistMaxLength()
	{
		return 100;
	}
	public void setWheelchairTherapist(String value)
	{
		this.isValidated = false;
		this.wheelchairtherapist = value;
	}
	public boolean getOutcomeOfAssessmentIsNotNull()
	{
		return this.outcomeofassessment != null;
	}
	public String getOutcomeOfAssessment()
	{
		return this.outcomeofassessment;
	}
	public static int getOutcomeOfAssessmentMaxLength()
	{
		return 255;
	}
	public void setOutcomeOfAssessment(String value)
	{
		this.isValidated = false;
		this.outcomeofassessment = value;
	}
	public boolean getDischargeDateIsNotNull()
	{
		return this.dischargedate != null;
	}
	public ims.framework.utils.Date getDischargeDate()
	{
		return this.dischargedate;
	}
	public void setDischargeDate(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.dischargedate = value;
	}
	public boolean getDischargeDetailsIsNotNull()
	{
		return this.dischargedetails != null;
	}
	public String getDischargeDetails()
	{
		return this.dischargedetails;
	}
	public static int getDischargeDetailsMaxLength()
	{
		return 1000;
	}
	public void setDischargeDetails(String value)
	{
		this.isValidated = false;
		this.dischargedetails = value;
	}
	public boolean getOtherAssessmentInfoIsNotNull()
	{
		return this.otherassessmentinfo != null;
	}
	public String getOtherAssessmentInfo()
	{
		return this.otherassessmentinfo;
	}
	public static int getOtherAssessmentInfoMaxLength()
	{
		return 1000;
	}
	public void setOtherAssessmentInfo(String value)
	{
		this.isValidated = false;
		this.otherassessmentinfo = value;
	}
	public boolean getPatientInformedIsNotNull()
	{
		return this.patientinformed != null;
	}
	public ims.core.vo.lookups.YesNoUnknown getPatientInformed()
	{
		return this.patientinformed;
	}
	public void setPatientInformed(ims.core.vo.lookups.YesNoUnknown value)
	{
		this.isValidated = false;
		this.patientinformed = 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 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("Core 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.referraldate == null)
			listOfErrors.add("Referral Date is a mandatory field");
		if(this.chairtype == null)
			listOfErrors.add("Chair Type is a mandatory field");
		if(this.wheelchairauthority != null)
			if(this.wheelchairauthority.length() > 255)
				listOfErrors.add("The length of the field [wheelchairauthority] in the value object [ims.therapies.vo.WheelchairReferralVo] is too big. It should be less or equal to 255");
		if(this.wheelchairtherapist != null)
			if(this.wheelchairtherapist.length() > 100)
				listOfErrors.add("The length of the field [wheelchairtherapist] in the value object [ims.therapies.vo.WheelchairReferralVo] is too big. It should be less or equal to 100");
		if(this.outcomeofassessment != null)
			if(this.outcomeofassessment.length() > 255)
				listOfErrors.add("The length of the field [outcomeofassessment] in the value object [ims.therapies.vo.WheelchairReferralVo] is too big. It should be less or equal to 255");
		if(this.dischargedetails != null)
			if(this.dischargedetails.length() > 1000)
				listOfErrors.add("The length of the field [dischargedetails] in the value object [ims.therapies.vo.WheelchairReferralVo] is too big. It should be less or equal to 1000");
		if(this.otherassessmentinfo != null)
			if(this.otherassessmentinfo.length() > 1000)
				listOfErrors.add("The length of the field [otherassessmentinfo] in the value object [ims.therapies.vo.WheelchairReferralVo] is too big. It should be less or equal to 1000");
		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;
	
		WheelchairReferralVo clone = new WheelchairReferralVo(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();
		if(this.referraldate == null)
			clone.referraldate = null;
		else
			clone.referraldate = (ims.framework.utils.Date)this.referraldate.clone();
		if(this.assessmentdate == null)
			clone.assessmentdate = null;
		else
			clone.assessmentdate = (ims.framework.utils.Date)this.assessmentdate.clone();
		if(this.chairtype == null)
			clone.chairtype = null;
		else
			clone.chairtype = (ims.spinalinjuries.vo.lookups.WheelchairType)this.chairtype.clone();
		clone.wheelchairauthority = this.wheelchairauthority;
		clone.wheelchairtherapist = this.wheelchairtherapist;
		clone.outcomeofassessment = this.outcomeofassessment;
		if(this.dischargedate == null)
			clone.dischargedate = null;
		else
			clone.dischargedate = (ims.framework.utils.Date)this.dischargedate.clone();
		clone.dischargedetails = this.dischargedetails;
		clone.otherassessmentinfo = this.otherassessmentinfo;
		if(this.patientinformed == null)
			clone.patientinformed = null;
		else
			clone.patientinformed = (ims.core.vo.lookups.YesNoUnknown)this.patientinformed.clone();
		clone.clinicalcontact = this.clinicalcontact;
		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 (!(WheelchairReferralVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A WheelchairReferralVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		WheelchairReferralVo compareObj = (WheelchairReferralVo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getID_WheelchairReferral() == null && compareObj.getID_WheelchairReferral() != null)
				return -1;
			if(this.getID_WheelchairReferral() != null && compareObj.getID_WheelchairReferral() == null)
				return 1;
			if(this.getID_WheelchairReferral() != null && compareObj.getID_WheelchairReferral() != null)
				retVal = this.getID_WheelchairReferral().compareTo(compareObj.getID_WheelchairReferral());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.carecontext != null)
			count++;
		if(this.authoringdatetime != null)
			count++;
		if(this.authoringcp != null)
			count++;
		if(this.referraldate != null)
			count++;
		if(this.assessmentdate != null)
			count++;
		if(this.chairtype != null)
			count++;
		if(this.wheelchairauthority != null)
			count++;
		if(this.wheelchairtherapist != null)
			count++;
		if(this.outcomeofassessment != null)
			count++;
		if(this.dischargedate != null)
			count++;
		if(this.dischargedetails != null)
			count++;
		if(this.otherassessmentinfo != null)
			count++;
		if(this.patientinformed != null)
			count++;
		if(this.clinicalcontact != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 14;
	}
	protected ims.core.admin.vo.CareContextRefVo carecontext;
	protected ims.framework.utils.DateTime authoringdatetime;
	protected ims.core.vo.Hcp authoringcp;
	protected ims.framework.utils.Date referraldate;
	protected ims.framework.utils.Date assessmentdate;
	protected ims.spinalinjuries.vo.lookups.WheelchairType chairtype;
	protected String wheelchairauthority;
	protected String wheelchairtherapist;
	protected String outcomeofassessment;
	protected ims.framework.utils.Date dischargedate;
	protected String dischargedetails;
	protected String otherassessmentinfo;
	protected ims.core.vo.lookups.YesNoUnknown patientinformed;
	protected ims.core.admin.vo.ClinicalContactRefVo clinicalcontact;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
