/FileExtraction/Java_unseen/IMS-MAXIMS_openMAXIMS/Source Library/openmaxims_workspace/ValueObjects/src/ims/core/vo/PatientClericalTaskVo.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 OCRR.OrderingResults.PatientClericalTask business object (ID: 1070100027).
 */
public class PatientClericalTaskVo extends ims.ocrr.orderingresults.vo.PatientClericalTaskRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public PatientClericalTaskVo()
	{
	}
	public PatientClericalTaskVo(Integer id, int version)
	{
		super(id, version);
	}
	public PatientClericalTaskVo(ims.core.vo.beans.PatientClericalTaskVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.patient = bean.getPatient() == null ? null : bean.getPatient().buildVo();
		this.investigation = bean.getInvestigation() == null ? null : new ims.ocrr.orderingresults.vo.OrderInvestigationRefVo(new Integer(bean.getInvestigation().getId()), bean.getInvestigation().getVersion());
		this.requestor = bean.getRequestor() == null ? null : bean.getRequestor().buildVo();
		this.requesteddatetime = bean.getRequestedDateTime() == null ? null : bean.getRequestedDateTime().buildDateTime();
		this.allocatedto = bean.getAllocatedTo() == null ? null : bean.getAllocatedTo().buildVo();
		this.comment = bean.getComment();
		this.completedby = bean.getCompletedBy() == null ? null : bean.getCompletedBy().buildVo();
		this.completeddatetime = bean.getCompletedDateTime() == null ? null : bean.getCompletedDateTime().buildDateTime();
		this.status = bean.getStatus() == null ? null : ims.ocrr.vo.lookups.PatientClericalTaskStatus.buildLookup(bean.getStatus());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.PatientClericalTaskVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.patient = bean.getPatient() == null ? null : bean.getPatient().buildVo(map);
		this.investigation = bean.getInvestigation() == null ? null : new ims.ocrr.orderingresults.vo.OrderInvestigationRefVo(new Integer(bean.getInvestigation().getId()), bean.getInvestigation().getVersion());
		this.requestor = bean.getRequestor() == null ? null : bean.getRequestor().buildVo(map);
		this.requesteddatetime = bean.getRequestedDateTime() == null ? null : bean.getRequestedDateTime().buildDateTime();
		this.allocatedto = bean.getAllocatedTo() == null ? null : bean.getAllocatedTo().buildVo(map);
		this.comment = bean.getComment();
		this.completedby = bean.getCompletedBy() == null ? null : bean.getCompletedBy().buildVo(map);
		this.completeddatetime = bean.getCompletedDateTime() == null ? null : bean.getCompletedDateTime().buildDateTime();
		this.status = bean.getStatus() == null ? null : ims.ocrr.vo.lookups.PatientClericalTaskStatus.buildLookup(bean.getStatus());
	}
	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.PatientClericalTaskVoBean bean = null;
		if(map != null)
			bean = (ims.core.vo.beans.PatientClericalTaskVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.core.vo.beans.PatientClericalTaskVoBean();
			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("INVESTIGATION"))
			return getInvestigation();
		if(fieldName.equals("REQUESTOR"))
			return getRequestor();
		if(fieldName.equals("REQUESTEDDATETIME"))
			return getRequestedDateTime();
		if(fieldName.equals("ALLOCATEDTO"))
			return getAllocatedTo();
		if(fieldName.equals("COMMENT"))
			return getComment();
		if(fieldName.equals("COMPLETEDBY"))
			return getCompletedBy();
		if(fieldName.equals("COMPLETEDDATETIME"))
			return getCompletedDateTime();
		if(fieldName.equals("STATUS"))
			return getStatus();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getPatientIsNotNull()
	{
		return this.patient != null;
	}
	public ims.core.vo.PatientListVo getPatient()
	{
		return this.patient;
	}
	public void setPatient(ims.core.vo.PatientListVo value)
	{
		this.isValidated = false;
		this.patient = value;
	}
	public boolean getInvestigationIsNotNull()
	{
		return this.investigation != null;
	}
	public ims.ocrr.orderingresults.vo.OrderInvestigationRefVo getInvestigation()
	{
		return this.investigation;
	}
	public void setInvestigation(ims.ocrr.orderingresults.vo.OrderInvestigationRefVo value)
	{
		this.isValidated = false;
		this.investigation = value;
	}
	public boolean getRequestorIsNotNull()
	{
		return this.requestor != null;
	}
	public ims.core.vo.MemberOfStaffLiteVo getRequestor()
	{
		return this.requestor;
	}
	public void setRequestor(ims.core.vo.MemberOfStaffLiteVo value)
	{
		this.isValidated = false;
		this.requestor = value;
	}
	public boolean getRequestedDateTimeIsNotNull()
	{
		return this.requesteddatetime != null;
	}
	public ims.framework.utils.DateTime getRequestedDateTime()
	{
		return this.requesteddatetime;
	}
	public void setRequestedDateTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.requesteddatetime = value;
	}
	public boolean getAllocatedToIsNotNull()
	{
		return this.allocatedto != null;
	}
	public ims.core.vo.MemberOfStaffLiteVo getAllocatedTo()
	{
		return this.allocatedto;
	}
	public void setAllocatedTo(ims.core.vo.MemberOfStaffLiteVo value)
	{
		this.isValidated = false;
		this.allocatedto = value;
	}
	public boolean getCommentIsNotNull()
	{
		return this.comment != null;
	}
	public String getComment()
	{
		return this.comment;
	}
	public static int getCommentMaxLength()
	{
		return 2500;
	}
	public void setComment(String value)
	{
		this.isValidated = false;
		this.comment = value;
	}
	public boolean getCompletedByIsNotNull()
	{
		return this.completedby != null;
	}
	public ims.core.vo.MemberOfStaffLiteVo getCompletedBy()
	{
		return this.completedby;
	}
	public void setCompletedBy(ims.core.vo.MemberOfStaffLiteVo value)
	{
		this.isValidated = false;
		this.completedby = value;
	}
	public boolean getCompletedDateTimeIsNotNull()
	{
		return this.completeddatetime != null;
	}
	public ims.framework.utils.DateTime getCompletedDateTime()
	{
		return this.completeddatetime;
	}
	public void setCompletedDateTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.completeddatetime = value;
	}
	public boolean getStatusIsNotNull()
	{
		return this.status != null;
	}
	public ims.ocrr.vo.lookups.PatientClericalTaskStatus getStatus()
	{
		return this.status;
	}
	public void setStatus(ims.ocrr.vo.lookups.PatientClericalTaskStatus value)
	{
		this.isValidated = false;
		this.status = 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.patient == null)
			listOfErrors.add("Patient is mandatory");
		if(this.investigation == null)
			listOfErrors.add("Investigation is mandatory");
		if(this.requestor == null)
			listOfErrors.add("Requestor is mandatory");
		if(this.requesteddatetime == null)
			listOfErrors.add("RequestedDateTime is mandatory");
		if(this.allocatedto == null)
			listOfErrors.add("AllocatedTo is mandatory");
		if(this.comment == null || this.comment.length() == 0)
			listOfErrors.add("Comment is mandatory");
		else if(this.comment.length() > 2500)
			listOfErrors.add("The length of the field [comment] in the value object [ims.core.vo.PatientClericalTaskVo] is too big. It should be less or equal to 2500");
		if(this.status == null)
			listOfErrors.add("Status 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;
	
		PatientClericalTaskVo clone = new PatientClericalTaskVo(this.id, this.version);
		
		if(this.patient == null)
			clone.patient = null;
		else
			clone.patient = (ims.core.vo.PatientListVo)this.patient.clone();
		clone.investigation = this.investigation;
		if(this.requestor == null)
			clone.requestor = null;
		else
			clone.requestor = (ims.core.vo.MemberOfStaffLiteVo)this.requestor.clone();
		if(this.requesteddatetime == null)
			clone.requesteddatetime = null;
		else
			clone.requesteddatetime = (ims.framework.utils.DateTime)this.requesteddatetime.clone();
		if(this.allocatedto == null)
			clone.allocatedto = null;
		else
			clone.allocatedto = (ims.core.vo.MemberOfStaffLiteVo)this.allocatedto.clone();
		clone.comment = this.comment;
		if(this.completedby == null)
			clone.completedby = null;
		else
			clone.completedby = (ims.core.vo.MemberOfStaffLiteVo)this.completedby.clone();
		if(this.completeddatetime == null)
			clone.completeddatetime = null;
		else
			clone.completeddatetime = (ims.framework.utils.DateTime)this.completeddatetime.clone();
		if(this.status == null)
			clone.status = null;
		else
			clone.status = (ims.ocrr.vo.lookups.PatientClericalTaskStatus)this.status.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 (!(PatientClericalTaskVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A PatientClericalTaskVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((PatientClericalTaskVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((PatientClericalTaskVo)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.investigation != null)
			count++;
		if(this.requestor != null)
			count++;
		if(this.requesteddatetime != null)
			count++;
		if(this.allocatedto != null)
			count++;
		if(this.comment != null)
			count++;
		if(this.completedby != null)
			count++;
		if(this.completeddatetime != null)
			count++;
		if(this.status != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 9;
	}
	protected ims.core.vo.PatientListVo patient;
	protected ims.ocrr.orderingresults.vo.OrderInvestigationRefVo investigation;
	protected ims.core.vo.MemberOfStaffLiteVo requestor;
	protected ims.framework.utils.DateTime requesteddatetime;
	protected ims.core.vo.MemberOfStaffLiteVo allocatedto;
	protected String comment;
	protected ims.core.vo.MemberOfStaffLiteVo completedby;
	protected ims.framework.utils.DateTime completeddatetime;
	protected ims.ocrr.vo.lookups.PatientClericalTaskStatus status;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
