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

/**
 * Linked to core.admin.Clinical Contact business object (ID: 1004100003).
 */
public class ClinicalContactVo extends ims.core.admin.vo.ClinicalContactRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public ClinicalContactVo()
	{
	}
	public ClinicalContactVo(Integer id, int version)
	{
		super(id, version);
	}
	public ClinicalContactVo(ims.core.vo.beans.ClinicalContactVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.specialty = bean.getSpecialty() == null ? null : ims.core.vo.lookups.Specialty.buildLookup(bean.getSpecialty());
		this.seenby = bean.getSeenBy() == null ? null : new ims.core.resource.people.vo.HcpRefVo(new Integer(bean.getSeenBy().getId()), bean.getSeenBy().getVersion());
		this.contacttype = bean.getContactType() == null ? null : ims.core.vo.lookups.ContactType.buildLookup(bean.getContactType());
		this.startdatetime = bean.getStartDateTime() == null ? null : bean.getStartDateTime().buildDateTime();
		this.enddatetime = bean.getEndDateTime() == null ? null : bean.getEndDateTime().buildDateTime();
		this.carecontext = bean.getCareContext() == null ? null : new ims.core.admin.vo.CareContextRefVo(new Integer(bean.getCareContext().getId()), bean.getCareContext().getVersion());
		this.isclinicalnotecreated = bean.getIsClinicalNoteCreated();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.ClinicalContactVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.specialty = bean.getSpecialty() == null ? null : ims.core.vo.lookups.Specialty.buildLookup(bean.getSpecialty());
		this.seenby = bean.getSeenBy() == null ? null : new ims.core.resource.people.vo.HcpRefVo(new Integer(bean.getSeenBy().getId()), bean.getSeenBy().getVersion());
		this.contacttype = bean.getContactType() == null ? null : ims.core.vo.lookups.ContactType.buildLookup(bean.getContactType());
		this.startdatetime = bean.getStartDateTime() == null ? null : bean.getStartDateTime().buildDateTime();
		this.enddatetime = bean.getEndDateTime() == null ? null : bean.getEndDateTime().buildDateTime();
		this.carecontext = bean.getCareContext() == null ? null : new ims.core.admin.vo.CareContextRefVo(new Integer(bean.getCareContext().getId()), bean.getCareContext().getVersion());
		this.isclinicalnotecreated = bean.getIsClinicalNoteCreated();
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.core.vo.beans.ClinicalContactVoBean bean = null;
		if(map != null)
			bean = (ims.core.vo.beans.ClinicalContactVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.core.vo.beans.ClinicalContactVoBean();
			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("SPECIALTY"))
			return getSpecialty();
		if(fieldName.equals("SEENBY"))
			return getSeenBy();
		if(fieldName.equals("CONTACTTYPE"))
			return getContactType();
		if(fieldName.equals("STARTDATETIME"))
			return getStartDateTime();
		if(fieldName.equals("ENDDATETIME"))
			return getEndDateTime();
		if(fieldName.equals("CARECONTEXT"))
			return getCareContext();
		if(fieldName.equals("ISCLINICALNOTECREATED"))
			return getIsClinicalNoteCreated();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getSpecialtyIsNotNull()
	{
		return this.specialty != null;
	}
	public ims.core.vo.lookups.Specialty getSpecialty()
	{
		return this.specialty;
	}
	public void setSpecialty(ims.core.vo.lookups.Specialty value)
	{
		this.isValidated = false;
		this.specialty = value;
	}
	public boolean getSeenByIsNotNull()
	{
		return this.seenby != null;
	}
	public ims.core.resource.people.vo.HcpRefVo getSeenBy()
	{
		return this.seenby;
	}
	public void setSeenBy(ims.core.resource.people.vo.HcpRefVo value)
	{
		this.isValidated = false;
		this.seenby = value;
	}
	public boolean getContactTypeIsNotNull()
	{
		return this.contacttype != null;
	}
	public ims.core.vo.lookups.ContactType getContactType()
	{
		return this.contacttype;
	}
	public void setContactType(ims.core.vo.lookups.ContactType value)
	{
		this.isValidated = false;
		this.contacttype = value;
	}
	public boolean getStartDateTimeIsNotNull()
	{
		return this.startdatetime != null;
	}
	public ims.framework.utils.DateTime getStartDateTime()
	{
		return this.startdatetime;
	}
	public void setStartDateTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.startdatetime = value;
	}
	public boolean getEndDateTimeIsNotNull()
	{
		return this.enddatetime != null;
	}
	public ims.framework.utils.DateTime getEndDateTime()
	{
		return this.enddatetime;
	}
	public void setEndDateTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.enddatetime = 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 getIsClinicalNoteCreatedIsNotNull()
	{
		return this.isclinicalnotecreated != null;
	}
	public Boolean getIsClinicalNoteCreated()
	{
		return this.isclinicalnotecreated;
	}
	public void setIsClinicalNoteCreated(Boolean value)
	{
		this.isValidated = false;
		this.isclinicalnotecreated = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.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.seenby == null)
			listOfErrors.add("SeenBy is mandatory");
		if(this.contacttype == null)
			listOfErrors.add("ContactType is mandatory");
		if(this.startdatetime == null)
			listOfErrors.add("StartDateTime is mandatory");
		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;
	
		ClinicalContactVo clone = new ClinicalContactVo(this.id, this.version);
		
		if(this.specialty == null)
			clone.specialty = null;
		else
			clone.specialty = (ims.core.vo.lookups.Specialty)this.specialty.clone();
		clone.seenby = this.seenby;
		if(this.contacttype == null)
			clone.contacttype = null;
		else
			clone.contacttype = (ims.core.vo.lookups.ContactType)this.contacttype.clone();
		if(this.startdatetime == null)
			clone.startdatetime = null;
		else
			clone.startdatetime = (ims.framework.utils.DateTime)this.startdatetime.clone();
		if(this.enddatetime == null)
			clone.enddatetime = null;
		else
			clone.enddatetime = (ims.framework.utils.DateTime)this.enddatetime.clone();
		clone.carecontext = this.carecontext;
		clone.isclinicalnotecreated = this.isclinicalnotecreated;
		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 (!(ClinicalContactVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A ClinicalContactVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		ClinicalContactVo compareObj = (ClinicalContactVo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getStartDateTime() == null && compareObj.getStartDateTime() != null)
				return -1;
			if(this.getStartDateTime() != null && compareObj.getStartDateTime() == null)
				return 1;
			if(this.getStartDateTime() != null && compareObj.getStartDateTime() != null)
				retVal = this.getStartDateTime().compareTo(compareObj.getStartDateTime());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.specialty != null)
			count++;
		if(this.seenby != null)
			count++;
		if(this.contacttype != null)
			count++;
		if(this.startdatetime != null)
			count++;
		if(this.enddatetime != null)
			count++;
		if(this.carecontext != null)
			count++;
		if(this.isclinicalnotecreated != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 7;
	}
	protected ims.core.vo.lookups.Specialty specialty;
	protected ims.core.resource.people.vo.HcpRefVo seenby;
	protected ims.core.vo.lookups.ContactType contacttype;
	protected ims.framework.utils.DateTime startdatetime;
	protected ims.framework.utils.DateTime enddatetime;
	protected ims.core.admin.vo.CareContextRefVo carecontext;
	protected Boolean isclinicalnotecreated;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
