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

	public PendingTransfersLiteVo()
	{
	}
	public PendingTransfersLiteVo(Integer id, int version)
	{
		super(id, version);
	}
	public PendingTransfersLiteVo(ims.core.vo.beans.PendingTransfersLiteVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.inpatientepisode = bean.getInpatientEpisode() == null ? null : bean.getInpatientEpisode().buildVo();
		this.transferrequestdatetime = bean.getTransferRequestDateTime() == null ? null : bean.getTransferRequestDateTime().buildDateTime();
		this.destinationward = bean.getDestinationWard() == null ? null : bean.getDestinationWard().buildVo();
		this.currentstatus = bean.getCurrentStatus() == null ? null : ims.core.vo.lookups.TransferStatus.buildLookup(bean.getCurrentStatus());
		this.wardtype = bean.getWardType() == null ? null : ims.core.vo.lookups.WardType.buildLookup(bean.getWardType());
		// Interface field type not supported.
		this.specialty = bean.getSpecialty() == null ? null : ims.core.vo.lookups.Specialty.buildLookup(bean.getSpecialty());
		this.passpecialty = bean.getPASSpecialty() == null ? null : ims.core.vo.lookups.PASSpecialty.buildLookup(bean.getPASSpecialty());
		this.transferreason = bean.getTransferReason() == null ? null : ims.core.vo.lookups.TransferReason.buildLookup(bean.getTransferReason());
		this.transfercomment = bean.getTransferComment();
		this.nolongerinbed = bean.getNoLongerInBed();
		this.cancellationreasondetails = bean.getCancellationReasonDetails() == null ? null : bean.getCancellationReasonDetails().buildVo();
		this.patientstatus = bean.getPatientStatus() == null ? null : ims.core.vo.lookups.PatientStatus.buildLookup(bean.getPatientStatus());
		this.bedavailabledatetime = bean.getBedAvailableDateTime() == null ? null : bean.getBedAvailableDateTime().buildDateTime();
		this.service = bean.getService() == null ? null : bean.getService().buildVo();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.PendingTransfersLiteVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.inpatientepisode = bean.getInpatientEpisode() == null ? null : bean.getInpatientEpisode().buildVo(map);
		this.transferrequestdatetime = bean.getTransferRequestDateTime() == null ? null : bean.getTransferRequestDateTime().buildDateTime();
		this.destinationward = bean.getDestinationWard() == null ? null : bean.getDestinationWard().buildVo(map);
		this.currentstatus = bean.getCurrentStatus() == null ? null : ims.core.vo.lookups.TransferStatus.buildLookup(bean.getCurrentStatus());
		this.wardtype = bean.getWardType() == null ? null : ims.core.vo.lookups.WardType.buildLookup(bean.getWardType());
		// Interface field type not supported.
		this.specialty = bean.getSpecialty() == null ? null : ims.core.vo.lookups.Specialty.buildLookup(bean.getSpecialty());
		this.passpecialty = bean.getPASSpecialty() == null ? null : ims.core.vo.lookups.PASSpecialty.buildLookup(bean.getPASSpecialty());
		this.transferreason = bean.getTransferReason() == null ? null : ims.core.vo.lookups.TransferReason.buildLookup(bean.getTransferReason());
		this.transfercomment = bean.getTransferComment();
		this.nolongerinbed = bean.getNoLongerInBed();
		this.cancellationreasondetails = bean.getCancellationReasonDetails() == null ? null : bean.getCancellationReasonDetails().buildVo(map);
		this.patientstatus = bean.getPatientStatus() == null ? null : ims.core.vo.lookups.PatientStatus.buildLookup(bean.getPatientStatus());
		this.bedavailabledatetime = bean.getBedAvailableDateTime() == null ? null : bean.getBedAvailableDateTime().buildDateTime();
		this.service = bean.getService() == null ? null : bean.getService().buildVo(map);
	}
	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.PendingTransfersLiteVoBean bean = null;
		if(map != null)
			bean = (ims.core.vo.beans.PendingTransfersLiteVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.core.vo.beans.PendingTransfersLiteVoBean();
			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("INPATIENTEPISODE"))
			return getInpatientEpisode();
		if(fieldName.equals("TRANSFERREQUESTDATETIME"))
			return getTransferRequestDateTime();
		if(fieldName.equals("DESTINATIONWARD"))
			return getDestinationWard();
		if(fieldName.equals("CURRENTSTATUS"))
			return getCurrentStatus();
		if(fieldName.equals("WARDTYPE"))
			return getWardType();
		if(fieldName.equals("CONSULTANT"))
			return getConsultant();
		if(fieldName.equals("SPECIALTY"))
			return getSpecialty();
		if(fieldName.equals("PASSPECIALTY"))
			return getPASSpecialty();
		if(fieldName.equals("TRANSFERREASON"))
			return getTransferReason();
		if(fieldName.equals("TRANSFERCOMMENT"))
			return getTransferComment();
		if(fieldName.equals("NOLONGERINBED"))
			return getNoLongerInBed();
		if(fieldName.equals("CANCELLATIONREASONDETAILS"))
			return getCancellationReasonDetails();
		if(fieldName.equals("PATIENTSTATUS"))
			return getPatientStatus();
		if(fieldName.equals("BEDAVAILABLEDATETIME"))
			return getBedAvailableDateTime();
		if(fieldName.equals("SERVICE"))
			return getService();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getInpatientEpisodeIsNotNull()
	{
		return this.inpatientepisode != null;
	}
	public ims.core.vo.InpatientEpisodeLiteVo getInpatientEpisode()
	{
		return this.inpatientepisode;
	}
	public void setInpatientEpisode(ims.core.vo.InpatientEpisodeLiteVo value)
	{
		this.isValidated = false;
		this.inpatientepisode = value;
	}
	public boolean getTransferRequestDateTimeIsNotNull()
	{
		return this.transferrequestdatetime != null;
	}
	public ims.framework.utils.DateTime getTransferRequestDateTime()
	{
		return this.transferrequestdatetime;
	}
	public void setTransferRequestDateTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.transferrequestdatetime = value;
	}
	public boolean getDestinationWardIsNotNull()
	{
		return this.destinationward != null;
	}
	public ims.core.vo.LocationLiteVo getDestinationWard()
	{
		return this.destinationward;
	}
	public void setDestinationWard(ims.core.vo.LocationLiteVo value)
	{
		this.isValidated = false;
		this.destinationward = value;
	}
	public boolean getCurrentStatusIsNotNull()
	{
		return this.currentstatus != null;
	}
	public ims.core.vo.lookups.TransferStatus getCurrentStatus()
	{
		return this.currentstatus;
	}
	public void setCurrentStatus(ims.core.vo.lookups.TransferStatus value)
	{
		this.isValidated = false;
		this.currentstatus = value;
	}
	public boolean getWardTypeIsNotNull()
	{
		return this.wardtype != null;
	}
	public ims.core.vo.lookups.WardType getWardType()
	{
		return this.wardtype;
	}
	public void setWardType(ims.core.vo.lookups.WardType value)
	{
		this.isValidated = false;
		this.wardtype = value;
	}
	public boolean getConsultantIsNotNull()
	{
		return this.consultant != null;
	}
	public ims.vo.interfaces.IMos getConsultant()
	{
		return this.consultant;
	}
	public void setConsultant(ims.vo.interfaces.IMos value)
	{
		this.isValidated = false;
		this.consultant = (ims.core.vo.MedicVo)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 getPASSpecialtyIsNotNull()
	{
		return this.passpecialty != null;
	}
	public ims.core.vo.lookups.PASSpecialty getPASSpecialty()
	{
		return this.passpecialty;
	}
	public void setPASSpecialty(ims.core.vo.lookups.PASSpecialty value)
	{
		this.isValidated = false;
		this.passpecialty = value;
	}
	public boolean getTransferReasonIsNotNull()
	{
		return this.transferreason != null;
	}
	public ims.core.vo.lookups.TransferReason getTransferReason()
	{
		return this.transferreason;
	}
	public void setTransferReason(ims.core.vo.lookups.TransferReason value)
	{
		this.isValidated = false;
		this.transferreason = value;
	}
	public boolean getTransferCommentIsNotNull()
	{
		return this.transfercomment != null;
	}
	public String getTransferComment()
	{
		return this.transfercomment;
	}
	public static int getTransferCommentMaxLength()
	{
		return 250;
	}
	public void setTransferComment(String value)
	{
		this.isValidated = false;
		this.transfercomment = value;
	}
	public boolean getNoLongerInBedIsNotNull()
	{
		return this.nolongerinbed != null;
	}
	public Boolean getNoLongerInBed()
	{
		return this.nolongerinbed;
	}
	public void setNoLongerInBed(Boolean value)
	{
		this.isValidated = false;
		this.nolongerinbed = value;
	}
	public boolean getCancellationReasonDetailsIsNotNull()
	{
		return this.cancellationreasondetails != null;
	}
	public ims.core.vo.TransferCancellationReasonDetailsVo getCancellationReasonDetails()
	{
		return this.cancellationreasondetails;
	}
	public void setCancellationReasonDetails(ims.core.vo.TransferCancellationReasonDetailsVo value)
	{
		this.isValidated = false;
		this.cancellationreasondetails = value;
	}
	public boolean getPatientStatusIsNotNull()
	{
		return this.patientstatus != null;
	}
	public ims.core.vo.lookups.PatientStatus getPatientStatus()
	{
		return this.patientstatus;
	}
	public void setPatientStatus(ims.core.vo.lookups.PatientStatus value)
	{
		this.isValidated = false;
		this.patientstatus = value;
	}
	public boolean getBedAvailableDateTimeIsNotNull()
	{
		return this.bedavailabledatetime != null;
	}
	public ims.framework.utils.DateTime getBedAvailableDateTime()
	{
		return this.bedavailabledatetime;
	}
	public void setBedAvailableDateTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.bedavailabledatetime = value;
	}
	public boolean getServiceIsNotNull()
	{
		return this.service != null;
	}
	public ims.core.vo.ServiceLiteVo getService()
	{
		return this.service;
	}
	public void setService(ims.core.vo.ServiceLiteVo value)
	{
		this.isValidated = false;
		this.service = value;
	}
	/**
	* getPatientString
	*/
		/**
		* getPatientString
		*/
		public String getPatientString()
		{
			if(this.getInpatientEpisodeIsNotNull())
				return this.getInpatientEpisode().getPatientString();
			
			return "";
		}
	/**
	* IGenericItemType interface methods
	*/
		public ims.core.vo.enums.SelectItemType getIGenericItemTypeSelectItemType()
		{
			return ims.core.vo.enums.SelectItemType.PENDINGTRANSFER;
		}
		public Integer getIGenericItemInfoID()
		{
			return this.id;
		}
		public String getIGenericItemInfoName()
		{
			return this.getPatientString();
		}
		public Boolean getIGenericItemInfoIsActive()
		{
			return Boolean.TRUE;
		}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.inpatientepisode != null)
		{
			if(!this.inpatientepisode.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.destinationward != null)
		{
			if(!this.destinationward.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.inpatientepisode != null)
		{
			String[] listOfOtherErrors = this.inpatientepisode.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.transferrequestdatetime == null)
			listOfErrors.add("Transfer Requested Date/Time is mandatory");
		if(this.destinationward == null)
			listOfErrors.add("Destination Ward is mandatory");
		if(this.destinationward != null)
		{
			String[] listOfOtherErrors = this.destinationward.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.currentstatus == null)
			listOfErrors.add("CurrentStatus is mandatory");
		if(this.wardtype == null)
			listOfErrors.add("Ward Type is mandatory");
		if(this.transfercomment != null)
			if(this.transfercomment.length() > 250)
				listOfErrors.add("The length of the field [transfercomment] in the value object [ims.core.vo.PendingTransfersLiteVo] is too big. It should be less or equal to 250");
		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;
	
		PendingTransfersLiteVo clone = new PendingTransfersLiteVo(this.id, this.version);
		
		if(this.inpatientepisode == null)
			clone.inpatientepisode = null;
		else
			clone.inpatientepisode = (ims.core.vo.InpatientEpisodeLiteVo)this.inpatientepisode.clone();
		if(this.transferrequestdatetime == null)
			clone.transferrequestdatetime = null;
		else
			clone.transferrequestdatetime = (ims.framework.utils.DateTime)this.transferrequestdatetime.clone();
		if(this.destinationward == null)
			clone.destinationward = null;
		else
			clone.destinationward = (ims.core.vo.LocationLiteVo)this.destinationward.clone();
		if(this.currentstatus == null)
			clone.currentstatus = null;
		else
			clone.currentstatus = (ims.core.vo.lookups.TransferStatus)this.currentstatus.clone();
		if(this.wardtype == null)
			clone.wardtype = null;
		else
			clone.wardtype = (ims.core.vo.lookups.WardType)this.wardtype.clone();
		clone.consultant = this.consultant;
		if(this.specialty == null)
			clone.specialty = null;
		else
			clone.specialty = (ims.core.vo.lookups.Specialty)this.specialty.clone();
		if(this.passpecialty == null)
			clone.passpecialty = null;
		else
			clone.passpecialty = (ims.core.vo.lookups.PASSpecialty)this.passpecialty.clone();
		if(this.transferreason == null)
			clone.transferreason = null;
		else
			clone.transferreason = (ims.core.vo.lookups.TransferReason)this.transferreason.clone();
		clone.transfercomment = this.transfercomment;
		clone.nolongerinbed = this.nolongerinbed;
		if(this.cancellationreasondetails == null)
			clone.cancellationreasondetails = null;
		else
			clone.cancellationreasondetails = (ims.core.vo.TransferCancellationReasonDetailsVo)this.cancellationreasondetails.clone();
		if(this.patientstatus == null)
			clone.patientstatus = null;
		else
			clone.patientstatus = (ims.core.vo.lookups.PatientStatus)this.patientstatus.clone();
		if(this.bedavailabledatetime == null)
			clone.bedavailabledatetime = null;
		else
			clone.bedavailabledatetime = (ims.framework.utils.DateTime)this.bedavailabledatetime.clone();
		if(this.service == null)
			clone.service = null;
		else
			clone.service = (ims.core.vo.ServiceLiteVo)this.service.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 (!(PendingTransfersLiteVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A PendingTransfersLiteVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((PendingTransfersLiteVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((PendingTransfersLiteVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.inpatientepisode != null)
			count++;
		if(this.transferrequestdatetime != null)
			count++;
		if(this.destinationward != null)
			count++;
		if(this.currentstatus != null)
			count++;
		if(this.wardtype != null)
			count++;
		if(this.consultant != null)
			count++;
		if(this.specialty != null)
			count++;
		if(this.passpecialty != null)
			count++;
		if(this.transferreason != null)
			count++;
		if(this.transfercomment != null)
			count++;
		if(this.nolongerinbed != null)
			count++;
		if(this.cancellationreasondetails != null)
			count++;
		if(this.patientstatus != null)
			count++;
		if(this.bedavailabledatetime != null)
			count++;
		if(this.service != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 15;
	}
	protected ims.core.vo.InpatientEpisodeLiteVo inpatientepisode;
	protected ims.framework.utils.DateTime transferrequestdatetime;
	protected ims.core.vo.LocationLiteVo destinationward;
	protected ims.core.vo.lookups.TransferStatus currentstatus;
	protected ims.core.vo.lookups.WardType wardtype;
	protected ims.core.vo.MedicVo consultant;
	protected ims.core.vo.lookups.Specialty specialty;
	protected ims.core.vo.lookups.PASSpecialty passpecialty;
	protected ims.core.vo.lookups.TransferReason transferreason;
	protected String transfercomment;
	protected Boolean nolongerinbed;
	protected ims.core.vo.TransferCancellationReasonDetailsVo cancellationreasondetails;
	protected ims.core.vo.lookups.PatientStatus patientstatus;
	protected ims.framework.utils.DateTime bedavailabledatetime;
	protected ims.core.vo.ServiceLiteVo service;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
