/FileExtraction/Java_unseen/IMS-MAXIMS_openMAXIMS/Source Library/openmaxims_workspace/ValueObjects/src/ims/core/vo/PendingEmergencyAdmissionsDataVo.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.pas.PendingEmergencyAdmission business object (ID: 1014100011).
 */
public class PendingEmergencyAdmissionsDataVo extends ims.core.admin.pas.vo.PendingEmergencyAdmissionRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public PendingEmergencyAdmissionsDataVo()
	{
	}
	public PendingEmergencyAdmissionsDataVo(Integer id, int version)
	{
		super(id, version);
	}
	public PendingEmergencyAdmissionsDataVo(ims.core.vo.beans.PendingEmergencyAdmissionsDataVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.allocatedward = bean.getAllocatedWard() == null ? null : bean.getAllocatedWard().buildVo();
		this.patientforename = bean.getPatientForename();
		this.patientsurname = bean.getPatientSurname();
		this.hcp = bean.getHcp() == null ? null : bean.getHcp().buildVo();
		this.alert = bean.getAlert() == null ? null : ims.core.vo.lookups.AlertType.buildLookup(bean.getAlert());
		this.hospital = bean.getHospital() == null ? null : bean.getHospital().buildVo();
		this.admissionstatus = bean.getAdmissionStatus() == null ? null : ims.core.vo.lookups.EmergencyAdmissionStatus.buildLookup(bean.getAdmissionStatus());
		this.idnumber = bean.getIDNumber();
		this.idtype = bean.getIDType() == null ? null : ims.core.vo.lookups.PatIdType.buildLookup(bean.getIDType());
		this.wastimeron = bean.getWasTimerOn();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.PendingEmergencyAdmissionsDataVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.allocatedward = bean.getAllocatedWard() == null ? null : bean.getAllocatedWard().buildVo(map);
		this.patientforename = bean.getPatientForename();
		this.patientsurname = bean.getPatientSurname();
		this.hcp = bean.getHcp() == null ? null : bean.getHcp().buildVo(map);
		this.alert = bean.getAlert() == null ? null : ims.core.vo.lookups.AlertType.buildLookup(bean.getAlert());
		this.hospital = bean.getHospital() == null ? null : bean.getHospital().buildVo(map);
		this.admissionstatus = bean.getAdmissionStatus() == null ? null : ims.core.vo.lookups.EmergencyAdmissionStatus.buildLookup(bean.getAdmissionStatus());
		this.idnumber = bean.getIDNumber();
		this.idtype = bean.getIDType() == null ? null : ims.core.vo.lookups.PatIdType.buildLookup(bean.getIDType());
		this.wastimeron = bean.getWasTimerOn();
	}
	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.PendingEmergencyAdmissionsDataVoBean bean = null;
		if(map != null)
			bean = (ims.core.vo.beans.PendingEmergencyAdmissionsDataVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.core.vo.beans.PendingEmergencyAdmissionsDataVoBean();
			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("ALLOCATEDWARD"))
			return getAllocatedWard();
		if(fieldName.equals("PATIENTFORENAME"))
			return getPatientForename();
		if(fieldName.equals("PATIENTSURNAME"))
			return getPatientSurname();
		if(fieldName.equals("HCP"))
			return getHcp();
		if(fieldName.equals("ALERT"))
			return getAlert();
		if(fieldName.equals("HOSPITAL"))
			return getHospital();
		if(fieldName.equals("ADMISSIONSTATUS"))
			return getAdmissionStatus();
		if(fieldName.equals("IDNUMBER"))
			return getIDNumber();
		if(fieldName.equals("IDTYPE"))
			return getIDType();
		if(fieldName.equals("WASTIMERON"))
			return getWasTimerOn();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getAllocatedWardIsNotNull()
	{
		return this.allocatedward != null;
	}
	public ims.core.vo.LocationLiteVo getAllocatedWard()
	{
		return this.allocatedward;
	}
	public void setAllocatedWard(ims.core.vo.LocationLiteVo value)
	{
		this.isValidated = false;
		this.allocatedward = value;
	}
	public boolean getPatientForenameIsNotNull()
	{
		return this.patientforename != null;
	}
	public String getPatientForename()
	{
		return this.patientforename;
	}
	public static int getPatientForenameMaxLength()
	{
		return 255;
	}
	public void setPatientForename(String value)
	{
		this.isValidated = false;
		this.patientforename = value;
	}
	public boolean getPatientSurnameIsNotNull()
	{
		return this.patientsurname != null;
	}
	public String getPatientSurname()
	{
		return this.patientsurname;
	}
	public static int getPatientSurnameMaxLength()
	{
		return 255;
	}
	public void setPatientSurname(String value)
	{
		this.isValidated = false;
		this.patientsurname = value;
	}
	public boolean getHcpIsNotNull()
	{
		return this.hcp != null;
	}
	public ims.core.vo.HcpLiteVo getHcp()
	{
		return this.hcp;
	}
	public void setHcp(ims.core.vo.HcpLiteVo value)
	{
		this.isValidated = false;
		this.hcp = value;
	}
	public boolean getAlertIsNotNull()
	{
		return this.alert != null;
	}
	public ims.core.vo.lookups.AlertType getAlert()
	{
		return this.alert;
	}
	public void setAlert(ims.core.vo.lookups.AlertType value)
	{
		this.isValidated = false;
		this.alert = value;
	}
	public boolean getHospitalIsNotNull()
	{
		return this.hospital != null;
	}
	public ims.core.vo.LocationLiteVo getHospital()
	{
		return this.hospital;
	}
	public void setHospital(ims.core.vo.LocationLiteVo value)
	{
		this.isValidated = false;
		this.hospital = value;
	}
	public boolean getAdmissionStatusIsNotNull()
	{
		return this.admissionstatus != null;
	}
	public ims.core.vo.lookups.EmergencyAdmissionStatus getAdmissionStatus()
	{
		return this.admissionstatus;
	}
	public void setAdmissionStatus(ims.core.vo.lookups.EmergencyAdmissionStatus value)
	{
		this.isValidated = false;
		this.admissionstatus = value;
	}
	public boolean getIDNumberIsNotNull()
	{
		return this.idnumber != null;
	}
	public String getIDNumber()
	{
		return this.idnumber;
	}
	public static int getIDNumberMaxLength()
	{
		return 255;
	}
	public void setIDNumber(String value)
	{
		this.isValidated = false;
		this.idnumber = value;
	}
	public boolean getIDTypeIsNotNull()
	{
		return this.idtype != null;
	}
	public ims.core.vo.lookups.PatIdType getIDType()
	{
		return this.idtype;
	}
	public void setIDType(ims.core.vo.lookups.PatIdType value)
	{
		this.isValidated = false;
		this.idtype = value;
	}
	public boolean getWasTimerOnIsNotNull()
	{
		return this.wastimeron != null;
	}
	public Boolean getWasTimerOn()
	{
		return this.wastimeron;
	}
	public void setWasTimerOn(Boolean value)
	{
		this.isValidated = false;
		this.wastimeron = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.allocatedward != null)
		{
			if(!this.allocatedward.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.hcp != null)
		{
			if(!this.hcp.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.hospital != null)
		{
			if(!this.hospital.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.allocatedward != null)
		{
			String[] listOfOtherErrors = this.allocatedward.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.hcp != null)
		{
			String[] listOfOtherErrors = this.hcp.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.hospital != null)
		{
			String[] listOfOtherErrors = this.hospital.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;
	
		PendingEmergencyAdmissionsDataVo clone = new PendingEmergencyAdmissionsDataVo(this.id, this.version);
		
		if(this.allocatedward == null)
			clone.allocatedward = null;
		else
			clone.allocatedward = (ims.core.vo.LocationLiteVo)this.allocatedward.clone();
		clone.patientforename = this.patientforename;
		clone.patientsurname = this.patientsurname;
		if(this.hcp == null)
			clone.hcp = null;
		else
			clone.hcp = (ims.core.vo.HcpLiteVo)this.hcp.clone();
		if(this.alert == null)
			clone.alert = null;
		else
			clone.alert = (ims.core.vo.lookups.AlertType)this.alert.clone();
		if(this.hospital == null)
			clone.hospital = null;
		else
			clone.hospital = (ims.core.vo.LocationLiteVo)this.hospital.clone();
		if(this.admissionstatus == null)
			clone.admissionstatus = null;
		else
			clone.admissionstatus = (ims.core.vo.lookups.EmergencyAdmissionStatus)this.admissionstatus.clone();
		clone.idnumber = this.idnumber;
		if(this.idtype == null)
			clone.idtype = null;
		else
			clone.idtype = (ims.core.vo.lookups.PatIdType)this.idtype.clone();
		clone.wastimeron = this.wastimeron;
		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 (!(PendingEmergencyAdmissionsDataVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A PendingEmergencyAdmissionsDataVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((PendingEmergencyAdmissionsDataVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((PendingEmergencyAdmissionsDataVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.allocatedward != null)
			count++;
		if(this.patientforename != null)
			count++;
		if(this.patientsurname != null)
			count++;
		if(this.hcp != null)
			count++;
		if(this.alert != null)
			count++;
		if(this.hospital != null)
			count++;
		if(this.admissionstatus != null)
			count++;
		if(this.idnumber != null)
			count++;
		if(this.idtype != null)
			count++;
		if(this.wastimeron != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 10;
	}
	protected ims.core.vo.LocationLiteVo allocatedward;
	protected String patientforename;
	protected String patientsurname;
	protected ims.core.vo.HcpLiteVo hcp;
	protected ims.core.vo.lookups.AlertType alert;
	protected ims.core.vo.LocationLiteVo hospital;
	protected ims.core.vo.lookups.EmergencyAdmissionStatus admissionstatus;
	protected String idnumber;
	protected ims.core.vo.lookups.PatIdType idtype;
	protected Boolean wastimeron;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
