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

	public PatientCaseNoteTransferVo()
	{
	}
	public PatientCaseNoteTransferVo(Integer id, int version)
	{
		super(id, version);
	}
	public PatientCaseNoteTransferVo(ims.core.vo.beans.PatientCaseNoteTransferVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.patient = bean.getPatient() == null ? null : new ims.core.patient.vo.PatientRefVo(new Integer(bean.getPatient().getId()), bean.getPatient().getVersion());
		this.casenote = bean.getCaseNote() == null ? null : new ims.core.clinical.vo.PatientCaseNoteRefVo(new Integer(bean.getCaseNote().getId()), bean.getCaseNote().getVersion());
		this.transferredfromlocation = bean.getTransferredFromLocation() == null ? null : new ims.core.resource.place.vo.LocationRefVo(new Integer(bean.getTransferredFromLocation().getId()), bean.getTransferredFromLocation().getVersion());
		this.transferredtolocation = bean.getTransferredToLocation() == null ? null : new ims.core.resource.place.vo.LocationRefVo(new Integer(bean.getTransferredToLocation().getId()), bean.getTransferredToLocation().getVersion());
		this.transferredby = bean.getTransferredBy() == null ? null : new ims.core.resource.people.vo.MemberOfStaffRefVo(new Integer(bean.getTransferredBy().getId()), bean.getTransferredBy().getVersion());
		this.transferdate = bean.getTransferDate() == null ? null : bean.getTransferDate().buildDateTime();
		this.reasonfortransfer = bean.getReasonForTransfer() == null ? null : ims.core.vo.lookups.CaseNoteReasonForRequest.buildLookup(bean.getReasonForTransfer());
		this.tansfercomment = bean.getTansferComment() == null ? null : bean.getTansferComment().buildVo();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.PatientCaseNoteTransferVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.patient = bean.getPatient() == null ? null : new ims.core.patient.vo.PatientRefVo(new Integer(bean.getPatient().getId()), bean.getPatient().getVersion());
		this.casenote = bean.getCaseNote() == null ? null : new ims.core.clinical.vo.PatientCaseNoteRefVo(new Integer(bean.getCaseNote().getId()), bean.getCaseNote().getVersion());
		this.transferredfromlocation = bean.getTransferredFromLocation() == null ? null : new ims.core.resource.place.vo.LocationRefVo(new Integer(bean.getTransferredFromLocation().getId()), bean.getTransferredFromLocation().getVersion());
		this.transferredtolocation = bean.getTransferredToLocation() == null ? null : new ims.core.resource.place.vo.LocationRefVo(new Integer(bean.getTransferredToLocation().getId()), bean.getTransferredToLocation().getVersion());
		this.transferredby = bean.getTransferredBy() == null ? null : new ims.core.resource.people.vo.MemberOfStaffRefVo(new Integer(bean.getTransferredBy().getId()), bean.getTransferredBy().getVersion());
		this.transferdate = bean.getTransferDate() == null ? null : bean.getTransferDate().buildDateTime();
		this.reasonfortransfer = bean.getReasonForTransfer() == null ? null : ims.core.vo.lookups.CaseNoteReasonForRequest.buildLookup(bean.getReasonForTransfer());
		this.tansfercomment = bean.getTansferComment() == null ? null : bean.getTansferComment().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.PatientCaseNoteTransferVoBean bean = null;
		if(map != null)
			bean = (ims.core.vo.beans.PatientCaseNoteTransferVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.core.vo.beans.PatientCaseNoteTransferVoBean();
			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("PATIENT"))
			return getPatient();
		if(fieldName.equals("CASENOTE"))
			return getCaseNote();
		if(fieldName.equals("TRANSFERREDFROMLOCATION"))
			return getTransferredFromLocation();
		if(fieldName.equals("TRANSFERREDTOLOCATION"))
			return getTransferredToLocation();
		if(fieldName.equals("TRANSFERREDBY"))
			return getTransferredBy();
		if(fieldName.equals("TRANSFERDATE"))
			return getTransferDate();
		if(fieldName.equals("REASONFORTRANSFER"))
			return getReasonForTransfer();
		if(fieldName.equals("TANSFERCOMMENT"))
			return getTansferComment();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getPatientIsNotNull()
	{
		return this.patient != null;
	}
	public ims.core.patient.vo.PatientRefVo getPatient()
	{
		return this.patient;
	}
	public void setPatient(ims.core.patient.vo.PatientRefVo value)
	{
		this.isValidated = false;
		this.patient = value;
	}
	public boolean getCaseNoteIsNotNull()
	{
		return this.casenote != null;
	}
	public ims.core.clinical.vo.PatientCaseNoteRefVo getCaseNote()
	{
		return this.casenote;
	}
	public void setCaseNote(ims.core.clinical.vo.PatientCaseNoteRefVo value)
	{
		this.isValidated = false;
		this.casenote = value;
	}
	public boolean getTransferredFromLocationIsNotNull()
	{
		return this.transferredfromlocation != null;
	}
	public ims.core.resource.place.vo.LocationRefVo getTransferredFromLocation()
	{
		return this.transferredfromlocation;
	}
	public void setTransferredFromLocation(ims.core.resource.place.vo.LocationRefVo value)
	{
		this.isValidated = false;
		this.transferredfromlocation = value;
	}
	public boolean getTransferredToLocationIsNotNull()
	{
		return this.transferredtolocation != null;
	}
	public ims.core.resource.place.vo.LocationRefVo getTransferredToLocation()
	{
		return this.transferredtolocation;
	}
	public void setTransferredToLocation(ims.core.resource.place.vo.LocationRefVo value)
	{
		this.isValidated = false;
		this.transferredtolocation = value;
	}
	public boolean getTransferredByIsNotNull()
	{
		return this.transferredby != null;
	}
	public ims.core.resource.people.vo.MemberOfStaffRefVo getTransferredBy()
	{
		return this.transferredby;
	}
	public void setTransferredBy(ims.core.resource.people.vo.MemberOfStaffRefVo value)
	{
		this.isValidated = false;
		this.transferredby = value;
	}
	public boolean getTransferDateIsNotNull()
	{
		return this.transferdate != null;
	}
	public ims.framework.utils.DateTime getTransferDate()
	{
		return this.transferdate;
	}
	public void setTransferDate(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.transferdate = value;
	}
	public boolean getReasonForTransferIsNotNull()
	{
		return this.reasonfortransfer != null;
	}
	public ims.core.vo.lookups.CaseNoteReasonForRequest getReasonForTransfer()
	{
		return this.reasonfortransfer;
	}
	public void setReasonForTransfer(ims.core.vo.lookups.CaseNoteReasonForRequest value)
	{
		this.isValidated = false;
		this.reasonfortransfer = value;
	}
	public boolean getTansferCommentIsNotNull()
	{
		return this.tansfercomment != null;
	}
	public ims.core.vo.PatientCaseNoteCommentSaveVo getTansferComment()
	{
		return this.tansfercomment;
	}
	public void setTansferComment(ims.core.vo.PatientCaseNoteCommentSaveVo value)
	{
		this.isValidated = false;
		this.tansfercomment = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.tansfercomment != null)
		{
			if(!this.tansfercomment.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.patient == null)
			listOfErrors.add("Patient is mandatory");
		if(this.casenote == null)
			listOfErrors.add("CaseNote is mandatory");
		if(this.transferredfromlocation == null)
			listOfErrors.add("TransferredFromLocation is mandatory");
		if(this.transferredtolocation == null)
			listOfErrors.add("Transfer To Location is mandatory");
		if(this.transferredby == null)
			listOfErrors.add("Transferred By is mandatory");
		if(this.transferdate == null)
			listOfErrors.add("Transfer Date is mandatory");
		if(this.tansfercomment != null)
		{
			String[] listOfOtherErrors = this.tansfercomment.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;
	
		PatientCaseNoteTransferVo clone = new PatientCaseNoteTransferVo(this.id, this.version);
		
		clone.patient = this.patient;
		clone.casenote = this.casenote;
		clone.transferredfromlocation = this.transferredfromlocation;
		clone.transferredtolocation = this.transferredtolocation;
		clone.transferredby = this.transferredby;
		if(this.transferdate == null)
			clone.transferdate = null;
		else
			clone.transferdate = (ims.framework.utils.DateTime)this.transferdate.clone();
		if(this.reasonfortransfer == null)
			clone.reasonfortransfer = null;
		else
			clone.reasonfortransfer = (ims.core.vo.lookups.CaseNoteReasonForRequest)this.reasonfortransfer.clone();
		if(this.tansfercomment == null)
			clone.tansfercomment = null;
		else
			clone.tansfercomment = (ims.core.vo.PatientCaseNoteCommentSaveVo)this.tansfercomment.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 (!(PatientCaseNoteTransferVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A PatientCaseNoteTransferVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((PatientCaseNoteTransferVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((PatientCaseNoteTransferVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.patient != null)
			count++;
		if(this.casenote != null)
			count++;
		if(this.transferredfromlocation != null)
			count++;
		if(this.transferredtolocation != null)
			count++;
		if(this.transferredby != null)
			count++;
		if(this.transferdate != null)
			count++;
		if(this.reasonfortransfer != null)
			count++;
		if(this.tansfercomment != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 8;
	}
	protected ims.core.patient.vo.PatientRefVo patient;
	protected ims.core.clinical.vo.PatientCaseNoteRefVo casenote;
	protected ims.core.resource.place.vo.LocationRefVo transferredfromlocation;
	protected ims.core.resource.place.vo.LocationRefVo transferredtolocation;
	protected ims.core.resource.people.vo.MemberOfStaffRefVo transferredby;
	protected ims.framework.utils.DateTime transferdate;
	protected ims.core.vo.lookups.CaseNoteReasonForRequest reasonfortransfer;
	protected ims.core.vo.PatientCaseNoteCommentSaveVo tansfercomment;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
