/FileExtraction/Java_unseen/IMS-MAXIMS_openMAXIMS/Source Library/openmaxims_workspace/ValueObjects/src/ims/core/vo/MedicVo.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.resource.people.Hcp business object (ID: 1006100000).
 */
public class MedicVo extends ims.core.vo.Hcp implements ims.vo.ImsCloneable, Comparable, ims.vo.interfaces.ICspTypeSpecifier, ims.vo.interfaces.IHcp
{
	private static final long serialVersionUID = 1L;

	public MedicVo()
	{
	}
	public MedicVo(Integer id, int version)
	{
		super(id, version);
	}
	public MedicVo(ims.core.vo.beans.MedicVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.hcptype = bean.getHcpType() == null ? null : ims.core.vo.lookups.HcpDisType.buildLookup(bean.getHcpType());
		this.queryname = bean.getQueryName() == null ? null : bean.getQueryName().buildVo();
		this.isactive = bean.getIsActive();
		this.mos = bean.getMos() == null ? null : bean.getMos().buildVo();
		this.ishcparesponsiblehcp = bean.getIsHCPaResponsibleHCP();
		this.isalocalconsultant = bean.getIsALocalConsultant();
		this.isaresponsibleedclinician = bean.getIsAResponsibleEDClinician();
		this.ishcpaendoscopist = bean.getIsHCPaEndoscopist();
		this.medictype = bean.getMedicType() == null ? null : ims.core.vo.lookups.HcpDisType.buildLookup(bean.getMedicType());
		this.grade = bean.getGrade() == null ? null : ims.core.vo.lookups.MedicGrade.buildLookup(bean.getGrade());
		this.specialty = bean.getSpecialty() == null ? null : ims.core.vo.lookups.Specialty.buildLookup(bean.getSpecialty());
		this.secondspecialty = bean.getSecondSpecialty() == null ? null : ims.core.vo.lookups.Specialty.buildLookup(bean.getSecondSpecialty());
		this.thirdspecialty = bean.getThirdSpecialty() == null ? null : ims.core.vo.lookups.Specialty.buildLookup(bean.getThirdSpecialty());
		this.inpatienthandling = bean.getInpatientHandling();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.MedicVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.hcptype = bean.getHcpType() == null ? null : ims.core.vo.lookups.HcpDisType.buildLookup(bean.getHcpType());
		this.queryname = bean.getQueryName() == null ? null : bean.getQueryName().buildVo(map);
		this.isactive = bean.getIsActive();
		this.mos = bean.getMos() == null ? null : bean.getMos().buildVo(map);
		this.ishcparesponsiblehcp = bean.getIsHCPaResponsibleHCP();
		this.isalocalconsultant = bean.getIsALocalConsultant();
		this.isaresponsibleedclinician = bean.getIsAResponsibleEDClinician();
		this.ishcpaendoscopist = bean.getIsHCPaEndoscopist();
		this.medictype = bean.getMedicType() == null ? null : ims.core.vo.lookups.HcpDisType.buildLookup(bean.getMedicType());
		this.grade = bean.getGrade() == null ? null : ims.core.vo.lookups.MedicGrade.buildLookup(bean.getGrade());
		this.specialty = bean.getSpecialty() == null ? null : ims.core.vo.lookups.Specialty.buildLookup(bean.getSpecialty());
		this.secondspecialty = bean.getSecondSpecialty() == null ? null : ims.core.vo.lookups.Specialty.buildLookup(bean.getSecondSpecialty());
		this.thirdspecialty = bean.getThirdSpecialty() == null ? null : ims.core.vo.lookups.Specialty.buildLookup(bean.getThirdSpecialty());
		this.inpatienthandling = bean.getInpatientHandling();
	}
	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.MedicVoBean bean = null;
		if(map != null)
			bean = (ims.core.vo.beans.MedicVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.core.vo.beans.MedicVoBean();
			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("MEDICTYPE"))
			return getMedicType();
		if(fieldName.equals("GRADE"))
			return getGrade();
		if(fieldName.equals("SPECIALTY"))
			return getSpecialty();
		if(fieldName.equals("SECONDSPECIALTY"))
			return getSecondSpecialty();
		if(fieldName.equals("THIRDSPECIALTY"))
			return getThirdSpecialty();
		if(fieldName.equals("INPATIENTHANDLING"))
			return getInpatientHandling();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getMedicTypeIsNotNull()
	{
		return this.medictype != null;
	}
	public ims.core.vo.lookups.HcpDisType getMedicType()
	{
		return this.medictype;
	}
	public void setMedicType(ims.core.vo.lookups.HcpDisType value)
	{
		this.isValidated = false;
		this.medictype = value;
	}
	public boolean getGradeIsNotNull()
	{
		return this.grade != null;
	}
	public ims.core.vo.lookups.MedicGrade getGrade()
	{
		return this.grade;
	}
	public void setGrade(ims.core.vo.lookups.MedicGrade value)
	{
		this.isValidated = false;
		this.grade = value;
	}
	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 getSecondSpecialtyIsNotNull()
	{
		return this.secondspecialty != null;
	}
	public ims.core.vo.lookups.Specialty getSecondSpecialty()
	{
		return this.secondspecialty;
	}
	public void setSecondSpecialty(ims.core.vo.lookups.Specialty value)
	{
		this.isValidated = false;
		this.secondspecialty = value;
	}
	public boolean getThirdSpecialtyIsNotNull()
	{
		return this.thirdspecialty != null;
	}
	public ims.core.vo.lookups.Specialty getThirdSpecialty()
	{
		return this.thirdspecialty;
	}
	public void setThirdSpecialty(ims.core.vo.lookups.Specialty value)
	{
		this.isValidated = false;
		this.thirdspecialty = value;
	}
	public boolean getInpatientHandlingIsNotNull()
	{
		return this.inpatienthandling != null;
	}
	public Boolean getInpatientHandling()
	{
		return this.inpatienthandling;
	}
	public void setInpatientHandling(Boolean value)
	{
		this.isValidated = false;
		this.inpatienthandling = value;
	}
	/**
	* ICspTypeSpecifier Interface Methods
	*/
	public Integer getIGenericItemInfoID()
	{
		return getID_Hcp();
	}
	
	public ims.correspondence.vo.lookups.ProfileType getSpecifierType()
	{
		return ims.correspondence.vo.lookups.ProfileType.CONSULTANT;
	}
	
	public String getIGenericItemInfoName()
	{
		Object name = getName();
		return name == null ? "" : name.toString();
	}
	
	public Boolean getIGenericItemInfoIsActive()
	{
		return getIsActive();
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.queryname != null)
		{
			if(!this.queryname.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.mos != null)
		{
			if(!this.mos.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.queryname != null)
		{
			String[] listOfOtherErrors = this.queryname.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.mos != null)
		{
			String[] listOfOtherErrors = this.mos.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;
	
		MedicVo clone = new MedicVo(this.id, this.version);
		
		if(this.hcptype == null)
			clone.hcptype = null;
		else
			clone.hcptype = (ims.core.vo.lookups.HcpDisType)this.hcptype.clone();
		if(this.queryname == null)
			clone.queryname = null;
		else
			clone.queryname = (ims.core.vo.PersonName)this.queryname.clone();
		clone.isactive = this.isactive;
		if(this.mos == null)
			clone.mos = null;
		else
			clone.mos = (ims.core.vo.MemberOfStaffShortVo)this.mos.clone();
		clone.ishcparesponsiblehcp = this.ishcparesponsiblehcp;
		clone.isalocalconsultant = this.isalocalconsultant;
		clone.isaresponsibleedclinician = this.isaresponsibleedclinician;
		clone.ishcpaendoscopist = this.ishcpaendoscopist;
		if(this.medictype == null)
			clone.medictype = null;
		else
			clone.medictype = (ims.core.vo.lookups.HcpDisType)this.medictype.clone();
		if(this.grade == null)
			clone.grade = null;
		else
			clone.grade = (ims.core.vo.lookups.MedicGrade)this.grade.clone();
		if(this.specialty == null)
			clone.specialty = null;
		else
			clone.specialty = (ims.core.vo.lookups.Specialty)this.specialty.clone();
		if(this.secondspecialty == null)
			clone.secondspecialty = null;
		else
			clone.secondspecialty = (ims.core.vo.lookups.Specialty)this.secondspecialty.clone();
		if(this.thirdspecialty == null)
			clone.thirdspecialty = null;
		else
			clone.thirdspecialty = (ims.core.vo.lookups.Specialty)this.thirdspecialty.clone();
		clone.inpatienthandling = this.inpatienthandling;
		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 (!(MedicVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A MedicVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		MedicVo compareObj = (MedicVo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getMos() == null && compareObj.getMos() != null)
				return -1;
			if(this.getMos() != null && compareObj.getMos() == null)
				return 1;
			if(this.getMos() != null && compareObj.getMos() != null)
				retVal = this.getMos().compareTo(compareObj.getMos());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = super.countFieldsWithValue();
		if(this.medictype != null)
			count++;
		if(this.grade != null)
			count++;
		if(this.specialty != null)
			count++;
		if(this.secondspecialty != null)
			count++;
		if(this.thirdspecialty != null)
			count++;
		if(this.inpatienthandling != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return super.countValueObjectFields() + 6;
	}
	protected ims.core.vo.lookups.HcpDisType medictype;
	protected ims.core.vo.lookups.MedicGrade grade;
	protected ims.core.vo.lookups.Specialty specialty;
	protected ims.core.vo.lookups.Specialty secondspecialty;
	protected ims.core.vo.lookups.Specialty thirdspecialty;
	protected Boolean inpatienthandling;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
