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

/**
 * Linked to clinical.PatientCaseConference business object (ID: 1072100018).
 */
public class PatientCaseConferenceVo extends ims.clinical.vo.PatientCaseConferenceRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public PatientCaseConferenceVo()
	{
	}
	public PatientCaseConferenceVo(Integer id, int version)
	{
		super(id, version);
	}
	public PatientCaseConferenceVo(ims.clinical.vo.beans.PatientCaseConferenceVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.clinicalcontact = bean.getClinicalContact() == null ? null : bean.getClinicalContact().buildVo();
		this.caseconfdate = bean.getCaseConfDate() == null ? null : bean.getCaseConfDate().buildDate();
		this.isdischargecaseconf = bean.getIsDischargeCaseConf();
		this.caseconfoutcome = bean.getCaseConfOutCome() == null ? null : ims.clinical.vo.lookups.CaseConferenceOutcome.buildLookup(bean.getCaseConfOutCome());
		this.cancellationreason = bean.getCancellationReason() == null ? null : ims.clinical.vo.lookups.CaseConferenceOutcome.buildLookup(bean.getCancellationReason());
		this.comments = bean.getComments();
		this.dischargedelayvalue = bean.getDischargeDelayValue();
		this.dischargedelayunit = bean.getDischargeDelayUnit() == null ? null : ims.core.vo.lookups.TimeDaystoYears.buildLookup(bean.getDischargeDelayUnit());
		this.predictednextcaseconf = bean.getPredictedNextCaseConf() == null ? null : bean.getPredictedNextCaseConf().buildPartialDate();
		this.predicateddischargedate = bean.getPredicatedDischargeDate() == null ? null : bean.getPredicatedDischargeDate().buildPartialDate();
		this.minutes = bean.getMinutes();
		this.mosstatus = ims.clinical.vo.CaseConfMOSStatusVoCollection.buildFromBeanCollection(bean.getMOSStatus());
		this.carecontext = bean.getCareContext() == null ? null : new ims.core.admin.vo.CareContextRefVo(new Integer(bean.getCareContext().getId()), bean.getCareContext().getVersion());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.clinical.vo.beans.PatientCaseConferenceVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.clinicalcontact = bean.getClinicalContact() == null ? null : bean.getClinicalContact().buildVo(map);
		this.caseconfdate = bean.getCaseConfDate() == null ? null : bean.getCaseConfDate().buildDate();
		this.isdischargecaseconf = bean.getIsDischargeCaseConf();
		this.caseconfoutcome = bean.getCaseConfOutCome() == null ? null : ims.clinical.vo.lookups.CaseConferenceOutcome.buildLookup(bean.getCaseConfOutCome());
		this.cancellationreason = bean.getCancellationReason() == null ? null : ims.clinical.vo.lookups.CaseConferenceOutcome.buildLookup(bean.getCancellationReason());
		this.comments = bean.getComments();
		this.dischargedelayvalue = bean.getDischargeDelayValue();
		this.dischargedelayunit = bean.getDischargeDelayUnit() == null ? null : ims.core.vo.lookups.TimeDaystoYears.buildLookup(bean.getDischargeDelayUnit());
		this.predictednextcaseconf = bean.getPredictedNextCaseConf() == null ? null : bean.getPredictedNextCaseConf().buildPartialDate();
		this.predicateddischargedate = bean.getPredicatedDischargeDate() == null ? null : bean.getPredicatedDischargeDate().buildPartialDate();
		this.minutes = bean.getMinutes();
		this.mosstatus = ims.clinical.vo.CaseConfMOSStatusVoCollection.buildFromBeanCollection(bean.getMOSStatus());
		this.carecontext = bean.getCareContext() == null ? null : new ims.core.admin.vo.CareContextRefVo(new Integer(bean.getCareContext().getId()), bean.getCareContext().getVersion());
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.clinical.vo.beans.PatientCaseConferenceVoBean bean = null;
		if(map != null)
			bean = (ims.clinical.vo.beans.PatientCaseConferenceVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.clinical.vo.beans.PatientCaseConferenceVoBean();
			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("CLINICALCONTACT"))
			return getClinicalContact();
		if(fieldName.equals("CASECONFDATE"))
			return getCaseConfDate();
		if(fieldName.equals("ISDISCHARGECASECONF"))
			return getIsDischargeCaseConf();
		if(fieldName.equals("CASECONFOUTCOME"))
			return getCaseConfOutCome();
		if(fieldName.equals("CANCELLATIONREASON"))
			return getCancellationReason();
		if(fieldName.equals("COMMENTS"))
			return getComments();
		if(fieldName.equals("DISCHARGEDELAYVALUE"))
			return getDischargeDelayValue();
		if(fieldName.equals("DISCHARGEDELAYUNIT"))
			return getDischargeDelayUnit();
		if(fieldName.equals("PREDICTEDNEXTCASECONF"))
			return getPredictedNextCaseConf();
		if(fieldName.equals("PREDICATEDDISCHARGEDATE"))
			return getPredicatedDischargeDate();
		if(fieldName.equals("MINUTES"))
			return getMinutes();
		if(fieldName.equals("MOSSTATUS"))
			return getMOSStatus();
		if(fieldName.equals("CARECONTEXT"))
			return getCareContext();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getClinicalContactIsNotNull()
	{
		return this.clinicalcontact != null;
	}
	public ims.core.vo.ClinicalContactShortVo getClinicalContact()
	{
		return this.clinicalcontact;
	}
	public void setClinicalContact(ims.core.vo.ClinicalContactShortVo value)
	{
		this.isValidated = false;
		this.clinicalcontact = value;
	}
	public boolean getCaseConfDateIsNotNull()
	{
		return this.caseconfdate != null;
	}
	public ims.framework.utils.Date getCaseConfDate()
	{
		return this.caseconfdate;
	}
	public void setCaseConfDate(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.caseconfdate = value;
	}
	public boolean getIsDischargeCaseConfIsNotNull()
	{
		return this.isdischargecaseconf != null;
	}
	public Boolean getIsDischargeCaseConf()
	{
		return this.isdischargecaseconf;
	}
	public void setIsDischargeCaseConf(Boolean value)
	{
		this.isValidated = false;
		this.isdischargecaseconf = value;
	}
	public boolean getCaseConfOutComeIsNotNull()
	{
		return this.caseconfoutcome != null;
	}
	public ims.clinical.vo.lookups.CaseConferenceOutcome getCaseConfOutCome()
	{
		return this.caseconfoutcome;
	}
	public void setCaseConfOutCome(ims.clinical.vo.lookups.CaseConferenceOutcome value)
	{
		this.isValidated = false;
		this.caseconfoutcome = value;
	}
	public boolean getCancellationReasonIsNotNull()
	{
		return this.cancellationreason != null;
	}
	public ims.clinical.vo.lookups.CaseConferenceOutcome getCancellationReason()
	{
		return this.cancellationreason;
	}
	public void setCancellationReason(ims.clinical.vo.lookups.CaseConferenceOutcome value)
	{
		this.isValidated = false;
		this.cancellationreason = value;
	}
	public boolean getCommentsIsNotNull()
	{
		return this.comments != null;
	}
	public String getComments()
	{
		return this.comments;
	}
	public static int getCommentsMaxLength()
	{
		return 2000;
	}
	public void setComments(String value)
	{
		this.isValidated = false;
		this.comments = value;
	}
	public boolean getDischargeDelayValueIsNotNull()
	{
		return this.dischargedelayvalue != null;
	}
	public Integer getDischargeDelayValue()
	{
		return this.dischargedelayvalue;
	}
	public void setDischargeDelayValue(Integer value)
	{
		this.isValidated = false;
		this.dischargedelayvalue = value;
	}
	public boolean getDischargeDelayUnitIsNotNull()
	{
		return this.dischargedelayunit != null;
	}
	public ims.core.vo.lookups.TimeDaystoYears getDischargeDelayUnit()
	{
		return this.dischargedelayunit;
	}
	public void setDischargeDelayUnit(ims.core.vo.lookups.TimeDaystoYears value)
	{
		this.isValidated = false;
		this.dischargedelayunit = value;
	}
	public boolean getPredictedNextCaseConfIsNotNull()
	{
		return this.predictednextcaseconf != null;
	}
	public ims.framework.utils.PartialDate getPredictedNextCaseConf()
	{
		return this.predictednextcaseconf;
	}
	public void setPredictedNextCaseConf(ims.framework.utils.PartialDate value)
	{
		this.isValidated = false;
		this.predictednextcaseconf = value;
	}
	public boolean getPredicatedDischargeDateIsNotNull()
	{
		return this.predicateddischargedate != null;
	}
	public ims.framework.utils.PartialDate getPredicatedDischargeDate()
	{
		return this.predicateddischargedate;
	}
	public void setPredicatedDischargeDate(ims.framework.utils.PartialDate value)
	{
		this.isValidated = false;
		this.predicateddischargedate = value;
	}
	public boolean getMinutesIsNotNull()
	{
		return this.minutes != null;
	}
	public String getMinutes()
	{
		return this.minutes;
	}
	public static int getMinutesMaxLength()
	{
		return 200;
	}
	public void setMinutes(String value)
	{
		this.isValidated = false;
		this.minutes = value;
	}
	public boolean getMOSStatusIsNotNull()
	{
		return this.mosstatus != null;
	}
	public ims.clinical.vo.CaseConfMOSStatusVoCollection getMOSStatus()
	{
		return this.mosstatus;
	}
	public void setMOSStatus(ims.clinical.vo.CaseConfMOSStatusVoCollection value)
	{
		this.isValidated = false;
		this.mosstatus = 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 isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.mosstatus != null)
		{
			if(!this.mosstatus.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.caseconfdate == null)
			listOfErrors.add("Please enter the Case Conference Date.");
		if(this.comments != null)
			if(this.comments.length() > 2000)
				listOfErrors.add("The length of the field [comments] in the value object [ims.clinical.vo.PatientCaseConferenceVo] is too big. It should be less or equal to 2000");
		if(this.minutes != null)
			if(this.minutes.length() > 200)
				listOfErrors.add("The length of the field [minutes] in the value object [ims.clinical.vo.PatientCaseConferenceVo] is too big. It should be less or equal to 200");
		if(this.mosstatus != null)
		{
			String[] listOfOtherErrors = this.mosstatus.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.carecontext == null)
			listOfErrors.add("CareContext is mandatory");
		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;
	
		PatientCaseConferenceVo clone = new PatientCaseConferenceVo(this.id, this.version);
		
		if(this.clinicalcontact == null)
			clone.clinicalcontact = null;
		else
			clone.clinicalcontact = (ims.core.vo.ClinicalContactShortVo)this.clinicalcontact.clone();
		if(this.caseconfdate == null)
			clone.caseconfdate = null;
		else
			clone.caseconfdate = (ims.framework.utils.Date)this.caseconfdate.clone();
		clone.isdischargecaseconf = this.isdischargecaseconf;
		if(this.caseconfoutcome == null)
			clone.caseconfoutcome = null;
		else
			clone.caseconfoutcome = (ims.clinical.vo.lookups.CaseConferenceOutcome)this.caseconfoutcome.clone();
		if(this.cancellationreason == null)
			clone.cancellationreason = null;
		else
			clone.cancellationreason = (ims.clinical.vo.lookups.CaseConferenceOutcome)this.cancellationreason.clone();
		clone.comments = this.comments;
		clone.dischargedelayvalue = this.dischargedelayvalue;
		if(this.dischargedelayunit == null)
			clone.dischargedelayunit = null;
		else
			clone.dischargedelayunit = (ims.core.vo.lookups.TimeDaystoYears)this.dischargedelayunit.clone();
		if(this.predictednextcaseconf == null)
			clone.predictednextcaseconf = null;
		else
			clone.predictednextcaseconf = (ims.framework.utils.PartialDate)this.predictednextcaseconf.clone();
		if(this.predicateddischargedate == null)
			clone.predicateddischargedate = null;
		else
			clone.predicateddischargedate = (ims.framework.utils.PartialDate)this.predicateddischargedate.clone();
		clone.minutes = this.minutes;
		if(this.mosstatus == null)
			clone.mosstatus = null;
		else
			clone.mosstatus = (ims.clinical.vo.CaseConfMOSStatusVoCollection)this.mosstatus.clone();
		clone.carecontext = this.carecontext;
		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 (!(PatientCaseConferenceVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A PatientCaseConferenceVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		PatientCaseConferenceVo compareObj = (PatientCaseConferenceVo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getID_PatientCaseConference() == null && compareObj.getID_PatientCaseConference() != null)
				return -1;
			if(this.getID_PatientCaseConference() != null && compareObj.getID_PatientCaseConference() == null)
				return 1;
			if(this.getID_PatientCaseConference() != null && compareObj.getID_PatientCaseConference() != null)
				retVal = this.getID_PatientCaseConference().compareTo(compareObj.getID_PatientCaseConference());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.clinicalcontact != null)
			count++;
		if(this.caseconfdate != null)
			count++;
		if(this.isdischargecaseconf != null)
			count++;
		if(this.caseconfoutcome != null)
			count++;
		if(this.cancellationreason != null)
			count++;
		if(this.comments != null)
			count++;
		if(this.dischargedelayvalue != null)
			count++;
		if(this.dischargedelayunit != null)
			count++;
		if(this.predictednextcaseconf != null)
			count++;
		if(this.predicateddischargedate != null)
			count++;
		if(this.minutes != null)
			count++;
		if(this.mosstatus != null)
			count++;
		if(this.carecontext != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 13;
	}
	protected ims.core.vo.ClinicalContactShortVo clinicalcontact;
	protected ims.framework.utils.Date caseconfdate;
	protected Boolean isdischargecaseconf;
	protected ims.clinical.vo.lookups.CaseConferenceOutcome caseconfoutcome;
	protected ims.clinical.vo.lookups.CaseConferenceOutcome cancellationreason;
	protected String comments;
	protected Integer dischargedelayvalue;
	protected ims.core.vo.lookups.TimeDaystoYears dischargedelayunit;
	protected ims.framework.utils.PartialDate predictednextcaseconf;
	protected ims.framework.utils.PartialDate predicateddischargedate;
	protected String minutes;
	protected ims.clinical.vo.CaseConfMOSStatusVoCollection mosstatus;
	protected ims.core.admin.vo.CareContextRefVo carecontext;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
