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

	public PDSBackOfficeItemVo()
	{
	}
	public PDSBackOfficeItemVo(Integer id, int version)
	{
		super(id, version);
	}
	public PDSBackOfficeItemVo(ims.core.vo.beans.PDSBackOfficeItemVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.type = bean.getType() == null ? null : ims.core.vo.lookups.PDSBackOfficeType.buildLookup(bean.getType());
		this.description = bean.getDescription();
		this.source = bean.getSource();
		this.priority = bean.getPriority() == null ? null : ims.core.vo.lookups.PDSBackOfficeWorkPriority.buildLookup(bean.getPriority());
		this.currentstatus = bean.getCurrentStatus() == null ? null : ims.core.vo.lookups.PDSBackOfficeWorkStatus.buildLookup(bean.getCurrentStatus());
		this.statushistory = ims.core.vo.PDSBackOfficeStatusVoCollection.buildFromBeanCollection(bean.getStatusHistory());
		this.nhsnumber = bean.getNHSNumber();
		this.nhsnumbersuperseded = bean.getNHSNumberSuperseded();
		this.outcome = bean.getOutcome() == null ? null : ims.core.vo.lookups.PDSBackOfficeOutcome.buildLookup(bean.getOutcome());
		this.updatetype = bean.getUpdateType() == null ? null : ims.core.vo.lookups.PDSUpdateType.buildLookup(bean.getUpdateType());
		this.registeryauthoritytype = bean.getRegisteryAuthorityType() == null ? null : ims.core.vo.lookups.PDSRegisteringAuthorityType.buildLookup(bean.getRegisteryAuthorityType());
		this.patient = bean.getPatient() == null ? null : new ims.core.patient.vo.PatientRefVo(new Integer(bean.getPatient().getId()), bean.getPatient().getVersion());
		this.notifications = ims.core.vo.NotificationVoCollection.buildFromBeanCollection(bean.getNotifications());
		this.systeminformation = bean.getSystemInformation() == null ? null : bean.getSystemInformation().buildSystemInformation();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.PDSBackOfficeItemVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.type = bean.getType() == null ? null : ims.core.vo.lookups.PDSBackOfficeType.buildLookup(bean.getType());
		this.description = bean.getDescription();
		this.source = bean.getSource();
		this.priority = bean.getPriority() == null ? null : ims.core.vo.lookups.PDSBackOfficeWorkPriority.buildLookup(bean.getPriority());
		this.currentstatus = bean.getCurrentStatus() == null ? null : ims.core.vo.lookups.PDSBackOfficeWorkStatus.buildLookup(bean.getCurrentStatus());
		this.statushistory = ims.core.vo.PDSBackOfficeStatusVoCollection.buildFromBeanCollection(bean.getStatusHistory());
		this.nhsnumber = bean.getNHSNumber();
		this.nhsnumbersuperseded = bean.getNHSNumberSuperseded();
		this.outcome = bean.getOutcome() == null ? null : ims.core.vo.lookups.PDSBackOfficeOutcome.buildLookup(bean.getOutcome());
		this.updatetype = bean.getUpdateType() == null ? null : ims.core.vo.lookups.PDSUpdateType.buildLookup(bean.getUpdateType());
		this.registeryauthoritytype = bean.getRegisteryAuthorityType() == null ? null : ims.core.vo.lookups.PDSRegisteringAuthorityType.buildLookup(bean.getRegisteryAuthorityType());
		this.patient = bean.getPatient() == null ? null : new ims.core.patient.vo.PatientRefVo(new Integer(bean.getPatient().getId()), bean.getPatient().getVersion());
		this.notifications = ims.core.vo.NotificationVoCollection.buildFromBeanCollection(bean.getNotifications());
		this.systeminformation = bean.getSystemInformation() == null ? null : bean.getSystemInformation().buildSystemInformation();
	}
	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.PDSBackOfficeItemVoBean bean = null;
		if(map != null)
			bean = (ims.core.vo.beans.PDSBackOfficeItemVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.core.vo.beans.PDSBackOfficeItemVoBean();
			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("TYPE"))
			return getType();
		if(fieldName.equals("DESCRIPTION"))
			return getDescription();
		if(fieldName.equals("SOURCE"))
			return getSource();
		if(fieldName.equals("PRIORITY"))
			return getPriority();
		if(fieldName.equals("CURRENTSTATUS"))
			return getCurrentStatus();
		if(fieldName.equals("STATUSHISTORY"))
			return getStatusHistory();
		if(fieldName.equals("NHSNUMBER"))
			return getNHSNumber();
		if(fieldName.equals("NHSNUMBERSUPERSEDED"))
			return getNHSNumberSuperseded();
		if(fieldName.equals("OUTCOME"))
			return getOutcome();
		if(fieldName.equals("UPDATETYPE"))
			return getUpdateType();
		if(fieldName.equals("REGISTERYAUTHORITYTYPE"))
			return getRegisteryAuthorityType();
		if(fieldName.equals("PATIENT"))
			return getPatient();
		if(fieldName.equals("NOTIFICATIONS"))
			return getNotifications();
		if(fieldName.equals("SYSTEMINFORMATION"))
			return getSystemInformation();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getTypeIsNotNull()
	{
		return this.type != null;
	}
	public ims.core.vo.lookups.PDSBackOfficeType getType()
	{
		return this.type;
	}
	public void setType(ims.core.vo.lookups.PDSBackOfficeType value)
	{
		this.isValidated = false;
		this.type = value;
	}
	public boolean getDescriptionIsNotNull()
	{
		return this.description != null;
	}
	public String getDescription()
	{
		return this.description;
	}
	public static int getDescriptionMaxLength()
	{
		return 2000;
	}
	public void setDescription(String value)
	{
		this.isValidated = false;
		this.description = value;
	}
	public boolean getSourceIsNotNull()
	{
		return this.source != null;
	}
	public String getSource()
	{
		return this.source;
	}
	public static int getSourceMaxLength()
	{
		return 100;
	}
	public void setSource(String value)
	{
		this.isValidated = false;
		this.source = value;
	}
	public boolean getPriorityIsNotNull()
	{
		return this.priority != null;
	}
	public ims.core.vo.lookups.PDSBackOfficeWorkPriority getPriority()
	{
		return this.priority;
	}
	public void setPriority(ims.core.vo.lookups.PDSBackOfficeWorkPriority value)
	{
		this.isValidated = false;
		this.priority = value;
	}
	public boolean getCurrentStatusIsNotNull()
	{
		return this.currentstatus != null;
	}
	public ims.core.vo.lookups.PDSBackOfficeWorkStatus getCurrentStatus()
	{
		return this.currentstatus;
	}
	public void setCurrentStatus(ims.core.vo.lookups.PDSBackOfficeWorkStatus value)
	{
		this.isValidated = false;
		this.currentstatus = value;
	}
	public boolean getStatusHistoryIsNotNull()
	{
		return this.statushistory != null;
	}
	public ims.core.vo.PDSBackOfficeStatusVoCollection getStatusHistory()
	{
		return this.statushistory;
	}
	public void setStatusHistory(ims.core.vo.PDSBackOfficeStatusVoCollection value)
	{
		this.isValidated = false;
		this.statushistory = value;
	}
	public boolean getNHSNumberIsNotNull()
	{
		return this.nhsnumber != null;
	}
	public String getNHSNumber()
	{
		return this.nhsnumber;
	}
	public static int getNHSNumberMaxLength()
	{
		return 20;
	}
	public void setNHSNumber(String value)
	{
		this.isValidated = false;
		this.nhsnumber = value;
	}
	public boolean getNHSNumberSupersededIsNotNull()
	{
		return this.nhsnumbersuperseded != null;
	}
	public String getNHSNumberSuperseded()
	{
		return this.nhsnumbersuperseded;
	}
	public static int getNHSNumberSupersededMaxLength()
	{
		return 20;
	}
	public void setNHSNumberSuperseded(String value)
	{
		this.isValidated = false;
		this.nhsnumbersuperseded = value;
	}
	public boolean getOutcomeIsNotNull()
	{
		return this.outcome != null;
	}
	public ims.core.vo.lookups.PDSBackOfficeOutcome getOutcome()
	{
		return this.outcome;
	}
	public void setOutcome(ims.core.vo.lookups.PDSBackOfficeOutcome value)
	{
		this.isValidated = false;
		this.outcome = value;
	}
	public boolean getUpdateTypeIsNotNull()
	{
		return this.updatetype != null;
	}
	public ims.core.vo.lookups.PDSUpdateType getUpdateType()
	{
		return this.updatetype;
	}
	public void setUpdateType(ims.core.vo.lookups.PDSUpdateType value)
	{
		this.isValidated = false;
		this.updatetype = value;
	}
	public boolean getRegisteryAuthorityTypeIsNotNull()
	{
		return this.registeryauthoritytype != null;
	}
	public ims.core.vo.lookups.PDSRegisteringAuthorityType getRegisteryAuthorityType()
	{
		return this.registeryauthoritytype;
	}
	public void setRegisteryAuthorityType(ims.core.vo.lookups.PDSRegisteringAuthorityType value)
	{
		this.isValidated = false;
		this.registeryauthoritytype = value;
	}
	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 getNotificationsIsNotNull()
	{
		return this.notifications != null;
	}
	public ims.core.vo.NotificationVoCollection getNotifications()
	{
		return this.notifications;
	}
	public void setNotifications(ims.core.vo.NotificationVoCollection value)
	{
		this.isValidated = false;
		this.notifications = value;
	}
	public boolean getSystemInformationIsNotNull()
	{
		return this.systeminformation != null;
	}
	public ims.vo.SystemInformation getSystemInformation()
	{
		return this.systeminformation;
	}
	public void setSystemInformation(ims.vo.SystemInformation value)
	{
		this.isValidated = false;
		this.systeminformation = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.statushistory != null)
		{
			if(!this.statushistory.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.notifications != null)
		{
			if(!this.notifications.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.description != null)
			if(this.description.length() > 2000)
				listOfErrors.add("The length of the field [description] in the value object [ims.core.vo.PDSBackOfficeItemVo] is too big. It should be less or equal to 2000");
		if(this.source != null)
			if(this.source.length() > 100)
				listOfErrors.add("The length of the field [source] in the value object [ims.core.vo.PDSBackOfficeItemVo] is too big. It should be less or equal to 100");
		if(this.statushistory != null)
		{
			String[] listOfOtherErrors = this.statushistory.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.nhsnumber != null)
			if(this.nhsnumber.length() > 20)
				listOfErrors.add("The length of the field [nhsnumber] in the value object [ims.core.vo.PDSBackOfficeItemVo] is too big. It should be less or equal to 20");
		if(this.nhsnumbersuperseded != null)
			if(this.nhsnumbersuperseded.length() > 20)
				listOfErrors.add("The length of the field [nhsnumbersuperseded] in the value object [ims.core.vo.PDSBackOfficeItemVo] is too big. It should be less or equal to 20");
		if(this.notifications != null)
		{
			String[] listOfOtherErrors = this.notifications.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;
	
		PDSBackOfficeItemVo clone = new PDSBackOfficeItemVo(this.id, this.version);
		
		if(this.type == null)
			clone.type = null;
		else
			clone.type = (ims.core.vo.lookups.PDSBackOfficeType)this.type.clone();
		clone.description = this.description;
		clone.source = this.source;
		if(this.priority == null)
			clone.priority = null;
		else
			clone.priority = (ims.core.vo.lookups.PDSBackOfficeWorkPriority)this.priority.clone();
		if(this.currentstatus == null)
			clone.currentstatus = null;
		else
			clone.currentstatus = (ims.core.vo.lookups.PDSBackOfficeWorkStatus)this.currentstatus.clone();
		if(this.statushistory == null)
			clone.statushistory = null;
		else
			clone.statushistory = (ims.core.vo.PDSBackOfficeStatusVoCollection)this.statushistory.clone();
		clone.nhsnumber = this.nhsnumber;
		clone.nhsnumbersuperseded = this.nhsnumbersuperseded;
		if(this.outcome == null)
			clone.outcome = null;
		else
			clone.outcome = (ims.core.vo.lookups.PDSBackOfficeOutcome)this.outcome.clone();
		if(this.updatetype == null)
			clone.updatetype = null;
		else
			clone.updatetype = (ims.core.vo.lookups.PDSUpdateType)this.updatetype.clone();
		if(this.registeryauthoritytype == null)
			clone.registeryauthoritytype = null;
		else
			clone.registeryauthoritytype = (ims.core.vo.lookups.PDSRegisteringAuthorityType)this.registeryauthoritytype.clone();
		clone.patient = this.patient;
		if(this.notifications == null)
			clone.notifications = null;
		else
			clone.notifications = (ims.core.vo.NotificationVoCollection)this.notifications.clone();
		if(this.systeminformation == null)
			clone.systeminformation = null;
		else
			clone.systeminformation = (ims.vo.SystemInformation)this.systeminformation.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 (!(PDSBackOfficeItemVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A PDSBackOfficeItemVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((PDSBackOfficeItemVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((PDSBackOfficeItemVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.type != null)
			count++;
		if(this.description != null)
			count++;
		if(this.source != null)
			count++;
		if(this.priority != null)
			count++;
		if(this.currentstatus != null)
			count++;
		if(this.statushistory != null)
			count++;
		if(this.nhsnumber != null)
			count++;
		if(this.nhsnumbersuperseded != null)
			count++;
		if(this.outcome != null)
			count++;
		if(this.updatetype != null)
			count++;
		if(this.registeryauthoritytype != null)
			count++;
		if(this.patient != null)
			count++;
		if(this.notifications != null)
			count++;
		if(this.systeminformation != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 14;
	}
	protected ims.core.vo.lookups.PDSBackOfficeType type;
	protected String description;
	protected String source;
	protected ims.core.vo.lookups.PDSBackOfficeWorkPriority priority;
	protected ims.core.vo.lookups.PDSBackOfficeWorkStatus currentstatus;
	protected ims.core.vo.PDSBackOfficeStatusVoCollection statushistory;
	protected String nhsnumber;
	protected String nhsnumbersuperseded;
	protected ims.core.vo.lookups.PDSBackOfficeOutcome outcome;
	protected ims.core.vo.lookups.PDSUpdateType updatetype;
	protected ims.core.vo.lookups.PDSRegisteringAuthorityType registeryauthoritytype;
	protected ims.core.patient.vo.PatientRefVo patient;
	protected ims.core.vo.NotificationVoCollection notifications;
	protected ims.vo.SystemInformation systeminformation;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
