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

	public CancerContactsVo()
	{
	}
	public CancerContactsVo(Integer id, int version)
	{
		super(id, version);
	}
	public CancerContactsVo(ims.oncology.vo.beans.CancerContactsVoBean 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.contacthcp = bean.getContactHCP() == null ? null : bean.getContactHCP().buildVo();
		this.hcpdiscipline = bean.getHCPDiscipline() == null ? null : ims.core.vo.lookups.HcpDisType.buildLookup(bean.getHCPDiscipline());
		this.contactdatetime = bean.getContactDateTime() == null ? null : bean.getContactDateTime().buildDateTime();
		this.unitsrequired = bean.getUnitsRequired();
		this.unitsgiven = bean.getUnitsGiven();
		this.comment = bean.getComment();
		if(bean.getContactTypes() != null)
		{
			this.contacttypes = new ims.oncology.vo.ContactTypesByDisciplineItemRefVoCollection();
			for(int contacttypes_i = 0; contacttypes_i < bean.getContactTypes().length; contacttypes_i++)
			{
				this.contacttypes.add(new ims.oncology.vo.ContactTypesByDisciplineItemRefVo(new Integer(bean.getContactTypes()[contacttypes_i].getId()), bean.getContactTypes()[contacttypes_i].getVersion()));
			}
		}
		this.episodeofcare = bean.getEpisodeOfCare() == null ? null : new ims.core.admin.vo.EpisodeOfCareRefVo(new Integer(bean.getEpisodeOfCare().getId()), bean.getEpisodeOfCare().getVersion());
		this.recordinginfo = bean.getRecordingInfo() == null ? null : bean.getRecordingInfo().buildVo();
		this.systeminformation = bean.getSystemInformation() == null ? null : bean.getSystemInformation().buildSystemInformation();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.oncology.vo.beans.CancerContactsVoBean 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.contacthcp = bean.getContactHCP() == null ? null : bean.getContactHCP().buildVo(map);
		this.hcpdiscipline = bean.getHCPDiscipline() == null ? null : ims.core.vo.lookups.HcpDisType.buildLookup(bean.getHCPDiscipline());
		this.contactdatetime = bean.getContactDateTime() == null ? null : bean.getContactDateTime().buildDateTime();
		this.unitsrequired = bean.getUnitsRequired();
		this.unitsgiven = bean.getUnitsGiven();
		this.comment = bean.getComment();
		if(bean.getContactTypes() != null)
		{
			this.contacttypes = new ims.oncology.vo.ContactTypesByDisciplineItemRefVoCollection();
			for(int contacttypes_i = 0; contacttypes_i < bean.getContactTypes().length; contacttypes_i++)
			{
				this.contacttypes.add(new ims.oncology.vo.ContactTypesByDisciplineItemRefVo(new Integer(bean.getContactTypes()[contacttypes_i].getId()), bean.getContactTypes()[contacttypes_i].getVersion()));
			}
		}
		this.episodeofcare = bean.getEpisodeOfCare() == null ? null : new ims.core.admin.vo.EpisodeOfCareRefVo(new Integer(bean.getEpisodeOfCare().getId()), bean.getEpisodeOfCare().getVersion());
		this.recordinginfo = bean.getRecordingInfo() == null ? null : bean.getRecordingInfo().buildVo(map);
		this.systeminformation = bean.getSystemInformation() == null ? null : bean.getSystemInformation().buildSystemInformation();
	}
	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.CancerContactsVoBean bean = null;
		if(map != null)
			bean = (ims.oncology.vo.beans.CancerContactsVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.oncology.vo.beans.CancerContactsVoBean();
			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("CONTACTHCP"))
			return getContactHCP();
		if(fieldName.equals("HCPDISCIPLINE"))
			return getHCPDiscipline();
		if(fieldName.equals("CONTACTDATETIME"))
			return getContactDateTime();
		if(fieldName.equals("UNITSREQUIRED"))
			return getUnitsRequired();
		if(fieldName.equals("UNITSGIVEN"))
			return getUnitsGiven();
		if(fieldName.equals("COMMENT"))
			return getComment();
		if(fieldName.equals("CONTACTTYPES"))
			return getContactTypes();
		if(fieldName.equals("EPISODEOFCARE"))
			return getEpisodeOfCare();
		if(fieldName.equals("RECORDINGINFO"))
			return getRecordingInfo();
		if(fieldName.equals("SYSTEMINFORMATION"))
			return getSystemInformation();
		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 getContactHCPIsNotNull()
	{
		return this.contacthcp != null;
	}
	public ims.core.vo.HcpLiteVo getContactHCP()
	{
		return this.contacthcp;
	}
	public void setContactHCP(ims.core.vo.HcpLiteVo value)
	{
		this.isValidated = false;
		this.contacthcp = value;
	}
	public boolean getHCPDisciplineIsNotNull()
	{
		return this.hcpdiscipline != null;
	}
	public ims.core.vo.lookups.HcpDisType getHCPDiscipline()
	{
		return this.hcpdiscipline;
	}
	public void setHCPDiscipline(ims.core.vo.lookups.HcpDisType value)
	{
		this.isValidated = false;
		this.hcpdiscipline = value;
	}
	public boolean getContactDateTimeIsNotNull()
	{
		return this.contactdatetime != null;
	}
	public ims.framework.utils.DateTime getContactDateTime()
	{
		return this.contactdatetime;
	}
	public void setContactDateTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.contactdatetime = value;
	}
	public boolean getUnitsRequiredIsNotNull()
	{
		return this.unitsrequired != null;
	}
	public Float getUnitsRequired()
	{
		return this.unitsrequired;
	}
	public void setUnitsRequired(Float value)
	{
		this.isValidated = false;
		this.unitsrequired = value;
	}
	public boolean getUnitsGivenIsNotNull()
	{
		return this.unitsgiven != null;
	}
	public Float getUnitsGiven()
	{
		return this.unitsgiven;
	}
	public void setUnitsGiven(Float value)
	{
		this.isValidated = false;
		this.unitsgiven = value;
	}
	public boolean getCommentIsNotNull()
	{
		return this.comment != null;
	}
	public String getComment()
	{
		return this.comment;
	}
	public static int getCommentMaxLength()
	{
		return 2000;
	}
	public void setComment(String value)
	{
		this.isValidated = false;
		this.comment = value;
	}
	public boolean getContactTypesIsNotNull()
	{
		return this.contacttypes != null;
	}
	public ims.oncology.vo.ContactTypesByDisciplineItemRefVoCollection getContactTypes()
	{
		return this.contacttypes;
	}
	public void setContactTypes(ims.oncology.vo.ContactTypesByDisciplineItemRefVoCollection value)
	{
		this.isValidated = false;
		this.contacttypes = 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 getRecordingInfoIsNotNull()
	{
		return this.recordinginfo != null;
	}
	public ims.core.vo.AuthoringInformationVo getRecordingInfo()
	{
		return this.recordinginfo;
	}
	public void setRecordingInfo(ims.core.vo.AuthoringInformationVo value)
	{
		this.isValidated = false;
		this.recordinginfo = value;
	}
	public boolean getSystemInformationIsNotNull()
	{
		return this.systeminformation != null;
	}
	public ims.vo.SystemInformation getSystemInformation()
	{
		return this.systeminformation;
	}
	public void setSystemInformation(ims.vo.SystemInformation value)
	{
		this.isValidated = false;
		this.systeminformation = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.recordinginfo != null)
		{
			if(!this.recordinginfo.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.contacthcp == null)
			listOfErrors.add("ContactHCP is mandatory");
		if(this.hcpdiscipline == null)
			listOfErrors.add("HCPDiscipline is mandatory");
		if(this.contactdatetime == null)
			listOfErrors.add("ContactDateTime is mandatory");
		if(this.comment != null)
			if(this.comment.length() > 2000)
				listOfErrors.add("The length of the field [comment] in the value object [ims.oncology.vo.CancerContactsVo] is too big. It should be less or equal to 2000");
		if(this.episodeofcare == null)
			listOfErrors.add("Episode Of Care is mandatory");
		if(this.recordinginfo != null)
		{
			String[] listOfOtherErrors = this.recordinginfo.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;
	
		CancerContactsVo clone = new CancerContactsVo(this.id, this.version);
		
		clone.carecontext = this.carecontext;
		if(this.contacthcp == null)
			clone.contacthcp = null;
		else
			clone.contacthcp = (ims.core.vo.HcpLiteVo)this.contacthcp.clone();
		if(this.hcpdiscipline == null)
			clone.hcpdiscipline = null;
		else
			clone.hcpdiscipline = (ims.core.vo.lookups.HcpDisType)this.hcpdiscipline.clone();
		if(this.contactdatetime == null)
			clone.contactdatetime = null;
		else
			clone.contactdatetime = (ims.framework.utils.DateTime)this.contactdatetime.clone();
		clone.unitsrequired = this.unitsrequired;
		clone.unitsgiven = this.unitsgiven;
		clone.comment = this.comment;
		clone.contacttypes = this.contacttypes;
		clone.episodeofcare = this.episodeofcare;
		if(this.recordinginfo == null)
			clone.recordinginfo = null;
		else
			clone.recordinginfo = (ims.core.vo.AuthoringInformationVo)this.recordinginfo.clone();
		if(this.systeminformation == null)
			clone.systeminformation = null;
		else
			clone.systeminformation = (ims.vo.SystemInformation)this.systeminformation.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 (!(CancerContactsVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A CancerContactsVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		CancerContactsVo compareObj = (CancerContactsVo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getContactDateTime() == null && compareObj.getContactDateTime() != null)
				return -1;
			if(this.getContactDateTime() != null && compareObj.getContactDateTime() == null)
				return 1;
			if(this.getContactDateTime() != null && compareObj.getContactDateTime() != null)
				retVal = this.getContactDateTime().compareTo(compareObj.getContactDateTime());
		}
		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.contacthcp != null)
			count++;
		if(this.hcpdiscipline != null)
			count++;
		if(this.contactdatetime != null)
			count++;
		if(this.unitsrequired != null)
			count++;
		if(this.unitsgiven != null)
			count++;
		if(this.comment != null)
			count++;
		if(this.contacttypes != null)
			count++;
		if(this.episodeofcare != null)
			count++;
		if(this.recordinginfo != null)
			count++;
		if(this.systeminformation != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 11;
	}
	protected ims.core.admin.vo.CareContextRefVo carecontext;
	protected ims.core.vo.HcpLiteVo contacthcp;
	protected ims.core.vo.lookups.HcpDisType hcpdiscipline;
	protected ims.framework.utils.DateTime contactdatetime;
	protected Float unitsrequired;
	protected Float unitsgiven;
	protected String comment;
	protected ims.oncology.vo.ContactTypesByDisciplineItemRefVoCollection contacttypes;
	protected ims.core.admin.vo.EpisodeOfCareRefVo episodeofcare;
	protected ims.core.vo.AuthoringInformationVo recordinginfo;
	protected ims.vo.SystemInformation systeminformation;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
