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

/**
 * Linked to emergency.EDPartialAdmission business object (ID: 1086100043).
 */
public class EDPartialAdmissionForDischargeDetailOutcomeVo extends ims.emergency.vo.EDPartialAdmissionRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public EDPartialAdmissionForDischargeDetailOutcomeVo()
	{
	}
	public EDPartialAdmissionForDischargeDetailOutcomeVo(Integer id, int version)
	{
		super(id, version);
	}
	public EDPartialAdmissionForDischargeDetailOutcomeVo(ims.emergency.vo.beans.EDPartialAdmissionForDischargeDetailOutcomeVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.decisiontoadmitdatetime = bean.getDecisionToAdmitDateTime() == null ? null : bean.getDecisionToAdmitDateTime().buildDateTime();
		this.specialty = bean.getSpecialty() == null ? null : ims.core.vo.lookups.Specialty.buildLookup(bean.getSpecialty());
		this.allocatedstatus = bean.getAllocatedStatus() == null ? null : ims.emergency.vo.lookups.AllocationStatus.buildLookup(bean.getAllocatedStatus());
		this.allocatedbedtype = bean.getAllocatedBedType() == null ? null : ims.emergency.vo.lookups.AllocatedBedType.buildLookup(bean.getAllocatedBedType());
		this.authoringinfo = bean.getAuthoringInfo() == null ? null : bean.getAuthoringInfo().buildVo();
		this.allocateddatetime = bean.getAllocatedDateTime() == null ? null : bean.getAllocatedDateTime().buildDateTime();
		this.admittingconsultant = bean.getAdmittingConsultant() == null ? null : bean.getAdmittingConsultant().buildVo();
		this.accomodationrequestedtype = bean.getAccomodationRequestedType() == null ? null : ims.core.vo.lookups.AccomodationRequestedType.buildLookup(bean.getAccomodationRequestedType());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.emergency.vo.beans.EDPartialAdmissionForDischargeDetailOutcomeVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.decisiontoadmitdatetime = bean.getDecisionToAdmitDateTime() == null ? null : bean.getDecisionToAdmitDateTime().buildDateTime();
		this.specialty = bean.getSpecialty() == null ? null : ims.core.vo.lookups.Specialty.buildLookup(bean.getSpecialty());
		this.allocatedstatus = bean.getAllocatedStatus() == null ? null : ims.emergency.vo.lookups.AllocationStatus.buildLookup(bean.getAllocatedStatus());
		this.allocatedbedtype = bean.getAllocatedBedType() == null ? null : ims.emergency.vo.lookups.AllocatedBedType.buildLookup(bean.getAllocatedBedType());
		this.authoringinfo = bean.getAuthoringInfo() == null ? null : bean.getAuthoringInfo().buildVo(map);
		this.allocateddatetime = bean.getAllocatedDateTime() == null ? null : bean.getAllocatedDateTime().buildDateTime();
		this.admittingconsultant = bean.getAdmittingConsultant() == null ? null : bean.getAdmittingConsultant().buildVo(map);
		this.accomodationrequestedtype = bean.getAccomodationRequestedType() == null ? null : ims.core.vo.lookups.AccomodationRequestedType.buildLookup(bean.getAccomodationRequestedType());
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.emergency.vo.beans.EDPartialAdmissionForDischargeDetailOutcomeVoBean bean = null;
		if(map != null)
			bean = (ims.emergency.vo.beans.EDPartialAdmissionForDischargeDetailOutcomeVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.emergency.vo.beans.EDPartialAdmissionForDischargeDetailOutcomeVoBean();
			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("DECISIONTOADMITDATETIME"))
			return getDecisionToAdmitDateTime();
		if(fieldName.equals("SPECIALTY"))
			return getSpecialty();
		if(fieldName.equals("ALLOCATEDSTATUS"))
			return getAllocatedStatus();
		if(fieldName.equals("ALLOCATEDBEDTYPE"))
			return getAllocatedBedType();
		if(fieldName.equals("AUTHORINGINFO"))
			return getAuthoringInfo();
		if(fieldName.equals("ALLOCATEDDATETIME"))
			return getAllocatedDateTime();
		if(fieldName.equals("ADMITTINGCONSULTANT"))
			return getAdmittingConsultant();
		if(fieldName.equals("ACCOMODATIONREQUESTEDTYPE"))
			return getAccomodationRequestedType();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getDecisionToAdmitDateTimeIsNotNull()
	{
		return this.decisiontoadmitdatetime != null;
	}
	public ims.framework.utils.DateTime getDecisionToAdmitDateTime()
	{
		return this.decisiontoadmitdatetime;
	}
	public void setDecisionToAdmitDateTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.decisiontoadmitdatetime = 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 getAllocatedStatusIsNotNull()
	{
		return this.allocatedstatus != null;
	}
	public ims.emergency.vo.lookups.AllocationStatus getAllocatedStatus()
	{
		return this.allocatedstatus;
	}
	public void setAllocatedStatus(ims.emergency.vo.lookups.AllocationStatus value)
	{
		this.isValidated = false;
		this.allocatedstatus = value;
	}
	public boolean getAllocatedBedTypeIsNotNull()
	{
		return this.allocatedbedtype != null;
	}
	public ims.emergency.vo.lookups.AllocatedBedType getAllocatedBedType()
	{
		return this.allocatedbedtype;
	}
	public void setAllocatedBedType(ims.emergency.vo.lookups.AllocatedBedType value)
	{
		this.isValidated = false;
		this.allocatedbedtype = value;
	}
	public boolean getAuthoringInfoIsNotNull()
	{
		return this.authoringinfo != null;
	}
	public ims.core.vo.AuthoringInformationVo getAuthoringInfo()
	{
		return this.authoringinfo;
	}
	public void setAuthoringInfo(ims.core.vo.AuthoringInformationVo value)
	{
		this.isValidated = false;
		this.authoringinfo = value;
	}
	public boolean getAllocatedDateTimeIsNotNull()
	{
		return this.allocateddatetime != null;
	}
	public ims.framework.utils.DateTime getAllocatedDateTime()
	{
		return this.allocateddatetime;
	}
	public void setAllocatedDateTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.allocateddatetime = value;
	}
	public boolean getAdmittingConsultantIsNotNull()
	{
		return this.admittingconsultant != null;
	}
	public ims.core.vo.HcpMinVo getAdmittingConsultant()
	{
		return this.admittingconsultant;
	}
	public void setAdmittingConsultant(ims.core.vo.HcpMinVo value)
	{
		this.isValidated = false;
		this.admittingconsultant = value;
	}
	public boolean getAccomodationRequestedTypeIsNotNull()
	{
		return this.accomodationrequestedtype != null;
	}
	public ims.core.vo.lookups.AccomodationRequestedType getAccomodationRequestedType()
	{
		return this.accomodationrequestedtype;
	}
	public void setAccomodationRequestedType(ims.core.vo.lookups.AccomodationRequestedType value)
	{
		this.isValidated = false;
		this.accomodationrequestedtype = 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.decisiontoadmitdatetime == null)
			listOfErrors.add("DecisionToAdmitDateTime is mandatory");
		if(this.specialty == null)
			listOfErrors.add("Specialty is mandatory");
		if(this.admittingconsultant == null)
			listOfErrors.add("AdmittingConsultant 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;
	
		EDPartialAdmissionForDischargeDetailOutcomeVo clone = new EDPartialAdmissionForDischargeDetailOutcomeVo(this.id, this.version);
		
		if(this.decisiontoadmitdatetime == null)
			clone.decisiontoadmitdatetime = null;
		else
			clone.decisiontoadmitdatetime = (ims.framework.utils.DateTime)this.decisiontoadmitdatetime.clone();
		if(this.specialty == null)
			clone.specialty = null;
		else
			clone.specialty = (ims.core.vo.lookups.Specialty)this.specialty.clone();
		if(this.allocatedstatus == null)
			clone.allocatedstatus = null;
		else
			clone.allocatedstatus = (ims.emergency.vo.lookups.AllocationStatus)this.allocatedstatus.clone();
		if(this.allocatedbedtype == null)
			clone.allocatedbedtype = null;
		else
			clone.allocatedbedtype = (ims.emergency.vo.lookups.AllocatedBedType)this.allocatedbedtype.clone();
		if(this.authoringinfo == null)
			clone.authoringinfo = null;
		else
			clone.authoringinfo = (ims.core.vo.AuthoringInformationVo)this.authoringinfo.clone();
		if(this.allocateddatetime == null)
			clone.allocateddatetime = null;
		else
			clone.allocateddatetime = (ims.framework.utils.DateTime)this.allocateddatetime.clone();
		if(this.admittingconsultant == null)
			clone.admittingconsultant = null;
		else
			clone.admittingconsultant = (ims.core.vo.HcpMinVo)this.admittingconsultant.clone();
		if(this.accomodationrequestedtype == null)
			clone.accomodationrequestedtype = null;
		else
			clone.accomodationrequestedtype = (ims.core.vo.lookups.AccomodationRequestedType)this.accomodationrequestedtype.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 (!(EDPartialAdmissionForDischargeDetailOutcomeVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A EDPartialAdmissionForDischargeDetailOutcomeVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((EDPartialAdmissionForDischargeDetailOutcomeVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((EDPartialAdmissionForDischargeDetailOutcomeVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.decisiontoadmitdatetime != null)
			count++;
		if(this.specialty != null)
			count++;
		if(this.allocatedstatus != null)
			count++;
		if(this.allocatedbedtype != null)
			count++;
		if(this.authoringinfo != null)
			count++;
		if(this.allocateddatetime != null)
			count++;
		if(this.admittingconsultant != null)
			count++;
		if(this.accomodationrequestedtype != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 8;
	}
	protected ims.framework.utils.DateTime decisiontoadmitdatetime;
	protected ims.core.vo.lookups.Specialty specialty;
	protected ims.emergency.vo.lookups.AllocationStatus allocatedstatus;
	protected ims.emergency.vo.lookups.AllocatedBedType allocatedbedtype;
	protected ims.core.vo.AuthoringInformationVo authoringinfo;
	protected ims.framework.utils.DateTime allocateddatetime;
	protected ims.core.vo.HcpMinVo admittingconsultant;
	protected ims.core.vo.lookups.AccomodationRequestedType accomodationrequestedtype;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
