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

/**
 * Linked to Oncology.CancerMDTMeeting business object (ID: 1074100017).
 */
public class CancerMDTMeetingVo extends ims.oncology.vo.CancerMDTMeetingRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public CancerMDTMeetingVo()
	{
	}
	public CancerMDTMeetingVo(Integer id, int version)
	{
		super(id, version);
	}
	public CancerMDTMeetingVo(ims.oncology.vo.beans.CancerMDTMeetingVoBean 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.clinicalcontact = bean.getClinicalContact() == null ? null : new ims.core.admin.vo.ClinicalContactRefVo(new Integer(bean.getClinicalContact().getId()), bean.getClinicalContact().getVersion());
		this.date = bean.getDate() == null ? null : bean.getDate().buildDate();
		this.comorbidityassessment = bean.getCoMorbidityAssessment() == null ? null : ims.oncology.vo.lookups.CoMorbidityAssessment.buildLookup(bean.getCoMorbidityAssessment());
		this.notes = bean.getNotes();
		this.patientperformancestatus = bean.getPatientPerformanceStatus() == null ? null : ims.oncology.vo.lookups.PatientPerformanceStatus.buildLookup(bean.getPatientPerformanceStatus());
		this.mdtlocation = bean.getMDTLocation() == null ? null : bean.getMDTLocation().buildVo();
		this.associatedcareplan = bean.getAssociatedCarePlan() == null ? null : bean.getAssociatedCarePlan().buildVo();
		this.otherspresent = bean.getOthersPresent();
		this.invitedhcp = ims.oncology.vo.InvitedHCPVoCollection.buildFromBeanCollection(bean.getInvitedHCP());
		this.episodeofcare = bean.getEpisodeOfCare() == null ? null : new ims.core.admin.vo.EpisodeOfCareRefVo(new Integer(bean.getEpisodeOfCare().getId()), bean.getEpisodeOfCare().getVersion());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.oncology.vo.beans.CancerMDTMeetingVoBean 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.clinicalcontact = bean.getClinicalContact() == null ? null : new ims.core.admin.vo.ClinicalContactRefVo(new Integer(bean.getClinicalContact().getId()), bean.getClinicalContact().getVersion());
		this.date = bean.getDate() == null ? null : bean.getDate().buildDate();
		this.comorbidityassessment = bean.getCoMorbidityAssessment() == null ? null : ims.oncology.vo.lookups.CoMorbidityAssessment.buildLookup(bean.getCoMorbidityAssessment());
		this.notes = bean.getNotes();
		this.patientperformancestatus = bean.getPatientPerformanceStatus() == null ? null : ims.oncology.vo.lookups.PatientPerformanceStatus.buildLookup(bean.getPatientPerformanceStatus());
		this.mdtlocation = bean.getMDTLocation() == null ? null : bean.getMDTLocation().buildVo(map);
		this.associatedcareplan = bean.getAssociatedCarePlan() == null ? null : bean.getAssociatedCarePlan().buildVo(map);
		this.otherspresent = bean.getOthersPresent();
		this.invitedhcp = ims.oncology.vo.InvitedHCPVoCollection.buildFromBeanCollection(bean.getInvitedHCP());
		this.episodeofcare = bean.getEpisodeOfCare() == null ? null : new ims.core.admin.vo.EpisodeOfCareRefVo(new Integer(bean.getEpisodeOfCare().getId()), bean.getEpisodeOfCare().getVersion());
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.oncology.vo.beans.CancerMDTMeetingVoBean bean = null;
		if(map != null)
			bean = (ims.oncology.vo.beans.CancerMDTMeetingVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.oncology.vo.beans.CancerMDTMeetingVoBean();
			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("CLINICALCONTACT"))
			return getClinicalContact();
		if(fieldName.equals("DATE"))
			return getDate();
		if(fieldName.equals("COMORBIDITYASSESSMENT"))
			return getCoMorbidityAssessment();
		if(fieldName.equals("NOTES"))
			return getNotes();
		if(fieldName.equals("PATIENTPERFORMANCESTATUS"))
			return getPatientPerformanceStatus();
		if(fieldName.equals("MDTLOCATION"))
			return getMDTLocation();
		if(fieldName.equals("ASSOCIATEDCAREPLAN"))
			return getAssociatedCarePlan();
		if(fieldName.equals("OTHERSPRESENT"))
			return getOthersPresent();
		if(fieldName.equals("INVITEDHCP"))
			return getInvitedHCP();
		if(fieldName.equals("EPISODEOFCARE"))
			return getEpisodeOfCare();
		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 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 getDateIsNotNull()
	{
		return this.date != null;
	}
	public ims.framework.utils.Date getDate()
	{
		return this.date;
	}
	public void setDate(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.date = value;
	}
	public boolean getCoMorbidityAssessmentIsNotNull()
	{
		return this.comorbidityassessment != null;
	}
	public ims.oncology.vo.lookups.CoMorbidityAssessment getCoMorbidityAssessment()
	{
		return this.comorbidityassessment;
	}
	public void setCoMorbidityAssessment(ims.oncology.vo.lookups.CoMorbidityAssessment value)
	{
		this.isValidated = false;
		this.comorbidityassessment = value;
	}
	public boolean getNotesIsNotNull()
	{
		return this.notes != null;
	}
	public String getNotes()
	{
		return this.notes;
	}
	public static int getNotesMaxLength()
	{
		return 1000;
	}
	public void setNotes(String value)
	{
		this.isValidated = false;
		this.notes = value;
	}
	public boolean getPatientPerformanceStatusIsNotNull()
	{
		return this.patientperformancestatus != null;
	}
	public ims.oncology.vo.lookups.PatientPerformanceStatus getPatientPerformanceStatus()
	{
		return this.patientperformancestatus;
	}
	public void setPatientPerformanceStatus(ims.oncology.vo.lookups.PatientPerformanceStatus value)
	{
		this.isValidated = false;
		this.patientperformancestatus = value;
	}
	public boolean getMDTLocationIsNotNull()
	{
		return this.mdtlocation != null;
	}
	public ims.core.vo.LocationLiteVo getMDTLocation()
	{
		return this.mdtlocation;
	}
	public void setMDTLocation(ims.core.vo.LocationLiteVo value)
	{
		this.isValidated = false;
		this.mdtlocation = value;
	}
	public boolean getAssociatedCarePlanIsNotNull()
	{
		return this.associatedcareplan != null;
	}
	public ims.oncology.vo.CancerCarePlanShortVo getAssociatedCarePlan()
	{
		return this.associatedcareplan;
	}
	public void setAssociatedCarePlan(ims.oncology.vo.CancerCarePlanShortVo value)
	{
		this.isValidated = false;
		this.associatedcareplan = value;
	}
	public boolean getOthersPresentIsNotNull()
	{
		return this.otherspresent != null;
	}
	public String[] getOthersPresent()
	{
		return this.otherspresent;
	}
	public static int getOthersPresentMaxLength()
	{
		return 255;
	}
	public void setOthersPresent(String[] value)
	{
		this.isValidated = false;
		this.otherspresent = value;
	}
	public boolean getInvitedHCPIsNotNull()
	{
		return this.invitedhcp != null;
	}
	public ims.oncology.vo.InvitedHCPVoCollection getInvitedHCP()
	{
		return this.invitedhcp;
	}
	public void setInvitedHCP(ims.oncology.vo.InvitedHCPVoCollection value)
	{
		this.isValidated = false;
		this.invitedhcp = value;
	}
	public boolean getEpisodeOfCareIsNotNull()
	{
		return this.episodeofcare != null;
	}
	public ims.core.admin.vo.EpisodeOfCareRefVo getEpisodeOfCare()
	{
		return this.episodeofcare;
	}
	public void setEpisodeOfCare(ims.core.admin.vo.EpisodeOfCareRefVo value)
	{
		this.isValidated = false;
		this.episodeofcare = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.mdtlocation != null)
		{
			if(!this.mdtlocation.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.invitedhcp != null)
		{
			if(!this.invitedhcp.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.date == null)
			listOfErrors.add("MDT Date is mandatory");
		if(this.notes != null)
			if(this.notes.length() > 1000)
				listOfErrors.add("The length of the field [notes] in the value object [ims.oncology.vo.CancerMDTMeetingVo] is too big. It should be less or equal to 1000");
		if(this.mdtlocation != null)
		{
			String[] listOfOtherErrors = this.mdtlocation.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.invitedhcp != null)
		{
			String[] listOfOtherErrors = this.invitedhcp.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.episodeofcare == null)
			listOfErrors.add("EpisodeOfCare 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;
	
		CancerMDTMeetingVo clone = new CancerMDTMeetingVo(this.id, this.version);
		
		clone.carecontext = this.carecontext;
		clone.clinicalcontact = this.clinicalcontact;
		if(this.date == null)
			clone.date = null;
		else
			clone.date = (ims.framework.utils.Date)this.date.clone();
		if(this.comorbidityassessment == null)
			clone.comorbidityassessment = null;
		else
			clone.comorbidityassessment = (ims.oncology.vo.lookups.CoMorbidityAssessment)this.comorbidityassessment.clone();
		clone.notes = this.notes;
		if(this.patientperformancestatus == null)
			clone.patientperformancestatus = null;
		else
			clone.patientperformancestatus = (ims.oncology.vo.lookups.PatientPerformanceStatus)this.patientperformancestatus.clone();
		if(this.mdtlocation == null)
			clone.mdtlocation = null;
		else
			clone.mdtlocation = (ims.core.vo.LocationLiteVo)this.mdtlocation.clone();
		if(this.associatedcareplan == null)
			clone.associatedcareplan = null;
		else
			clone.associatedcareplan = (ims.oncology.vo.CancerCarePlanShortVo)this.associatedcareplan.clone();
		clone.otherspresent = this.otherspresent;
		if(this.invitedhcp == null)
			clone.invitedhcp = null;
		else
			clone.invitedhcp = (ims.oncology.vo.InvitedHCPVoCollection)this.invitedhcp.clone();
		clone.episodeofcare = this.episodeofcare;
		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 (!(CancerMDTMeetingVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A CancerMDTMeetingVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((CancerMDTMeetingVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((CancerMDTMeetingVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.carecontext != null)
			count++;
		if(this.clinicalcontact != null)
			count++;
		if(this.date != null)
			count++;
		if(this.comorbidityassessment != null)
			count++;
		if(this.notes != null)
			count++;
		if(this.patientperformancestatus != null)
			count++;
		if(this.mdtlocation != null)
			count++;
		if(this.associatedcareplan != null)
			count++;
		if(this.otherspresent != null)
			count++;
		if(this.invitedhcp != null)
			count++;
		if(this.episodeofcare != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 11;
	}
	protected ims.core.admin.vo.CareContextRefVo carecontext;
	protected ims.core.admin.vo.ClinicalContactRefVo clinicalcontact;
	protected ims.framework.utils.Date date;
	protected ims.oncology.vo.lookups.CoMorbidityAssessment comorbidityassessment;
	protected String notes;
	protected ims.oncology.vo.lookups.PatientPerformanceStatus patientperformancestatus;
	protected ims.core.vo.LocationLiteVo mdtlocation;
	protected ims.oncology.vo.CancerCarePlanShortVo associatedcareplan;
	protected String[] otherspresent;
	protected ims.oncology.vo.InvitedHCPVoCollection invitedhcp;
	protected ims.core.admin.vo.EpisodeOfCareRefVo episodeofcare;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
