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

	public PDSBatchTraceItemsVo()
	{
	}
	public PDSBatchTraceItemsVo(Integer id, int version)
	{
		super(id, version);
	}
	public PDSBatchTraceItemsVo(ims.core.vo.beans.PDSBatchTraceItemsVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.nhsnumber = bean.getNHSNumber();
		this.surname = bean.getSurname();
		this.forename = bean.getForename();
		this.dateofbirth = bean.getDateOfBirth() == null ? null : bean.getDateOfBirth().buildDate();
		this.gender = bean.getGender() == null ? null : ims.core.vo.lookups.Sex.buildLookup(bean.getGender());
		this.dateofdeathfrom = bean.getDateOfDeathFrom() == null ? null : bean.getDateOfDeathFrom().buildDate();
		this.dateofdeathto = bean.getDateOfDeathTo() == null ? null : bean.getDateOfDeathTo().buildDate();
		this.postcode = bean.getPostCode();
		this.pafkey = bean.getPafKey();
		this.addresslines = bean.getAddressLines() == null ? null : new ims.core.patient.vo.PDSAddrRefVo(new Integer(bean.getAddressLines().getId()), bean.getAddressLines().getVersion());
		this.gppracticecode = bean.getGpPracticeCode();
		this.status = bean.getStatus() == null ? null : ims.core.vo.lookups.PDSSearchStatus.buildLookup(bean.getStatus());
		this.errorreason = bean.getErrorReason();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.PDSBatchTraceItemsVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.nhsnumber = bean.getNHSNumber();
		this.surname = bean.getSurname();
		this.forename = bean.getForename();
		this.dateofbirth = bean.getDateOfBirth() == null ? null : bean.getDateOfBirth().buildDate();
		this.gender = bean.getGender() == null ? null : ims.core.vo.lookups.Sex.buildLookup(bean.getGender());
		this.dateofdeathfrom = bean.getDateOfDeathFrom() == null ? null : bean.getDateOfDeathFrom().buildDate();
		this.dateofdeathto = bean.getDateOfDeathTo() == null ? null : bean.getDateOfDeathTo().buildDate();
		this.postcode = bean.getPostCode();
		this.pafkey = bean.getPafKey();
		this.addresslines = bean.getAddressLines() == null ? null : new ims.core.patient.vo.PDSAddrRefVo(new Integer(bean.getAddressLines().getId()), bean.getAddressLines().getVersion());
		this.gppracticecode = bean.getGpPracticeCode();
		this.status = bean.getStatus() == null ? null : ims.core.vo.lookups.PDSSearchStatus.buildLookup(bean.getStatus());
		this.errorreason = bean.getErrorReason();
	}
	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.PDSBatchTraceItemsVoBean bean = null;
		if(map != null)
			bean = (ims.core.vo.beans.PDSBatchTraceItemsVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.core.vo.beans.PDSBatchTraceItemsVoBean();
			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("NHSNUMBER"))
			return getNHSNumber();
		if(fieldName.equals("SURNAME"))
			return getSurname();
		if(fieldName.equals("FORENAME"))
			return getForename();
		if(fieldName.equals("DATEOFBIRTH"))
			return getDateOfBirth();
		if(fieldName.equals("GENDER"))
			return getGender();
		if(fieldName.equals("DATEOFDEATHFROM"))
			return getDateOfDeathFrom();
		if(fieldName.equals("DATEOFDEATHTO"))
			return getDateOfDeathTo();
		if(fieldName.equals("POSTCODE"))
			return getPostCode();
		if(fieldName.equals("PAFKEY"))
			return getPafKey();
		if(fieldName.equals("ADDRESSLINES"))
			return getAddressLines();
		if(fieldName.equals("GPPRACTICECODE"))
			return getGpPracticeCode();
		if(fieldName.equals("STATUS"))
			return getStatus();
		if(fieldName.equals("ERRORREASON"))
			return getErrorReason();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getNHSNumberIsNotNull()
	{
		return this.nhsnumber != null;
	}
	public String getNHSNumber()
	{
		return this.nhsnumber;
	}
	public static int getNHSNumberMaxLength()
	{
		return 10;
	}
	public void setNHSNumber(String value)
	{
		this.isValidated = false;
		this.nhsnumber = value;
	}
	public boolean getSurnameIsNotNull()
	{
		return this.surname != null;
	}
	public String getSurname()
	{
		return this.surname;
	}
	public static int getSurnameMaxLength()
	{
		return 40;
	}
	public void setSurname(String value)
	{
		this.isValidated = false;
		this.surname = value;
	}
	public boolean getForenameIsNotNull()
	{
		return this.forename != null;
	}
	public String getForename()
	{
		return this.forename;
	}
	public static int getForenameMaxLength()
	{
		return 40;
	}
	public void setForename(String value)
	{
		this.isValidated = false;
		this.forename = value;
	}
	public boolean getDateOfBirthIsNotNull()
	{
		return this.dateofbirth != null;
	}
	public ims.framework.utils.Date getDateOfBirth()
	{
		return this.dateofbirth;
	}
	public void setDateOfBirth(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.dateofbirth = value;
	}
	public boolean getGenderIsNotNull()
	{
		return this.gender != null;
	}
	public ims.core.vo.lookups.Sex getGender()
	{
		return this.gender;
	}
	public void setGender(ims.core.vo.lookups.Sex value)
	{
		this.isValidated = false;
		this.gender = value;
	}
	public boolean getDateOfDeathFromIsNotNull()
	{
		return this.dateofdeathfrom != null;
	}
	public ims.framework.utils.Date getDateOfDeathFrom()
	{
		return this.dateofdeathfrom;
	}
	public void setDateOfDeathFrom(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.dateofdeathfrom = value;
	}
	public boolean getDateOfDeathToIsNotNull()
	{
		return this.dateofdeathto != null;
	}
	public ims.framework.utils.Date getDateOfDeathTo()
	{
		return this.dateofdeathto;
	}
	public void setDateOfDeathTo(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.dateofdeathto = value;
	}
	public boolean getPostCodeIsNotNull()
	{
		return this.postcode != null;
	}
	public String getPostCode()
	{
		return this.postcode;
	}
	public static int getPostCodeMaxLength()
	{
		return 10;
	}
	public void setPostCode(String value)
	{
		this.isValidated = false;
		this.postcode = value;
	}
	public boolean getPafKeyIsNotNull()
	{
		return this.pafkey != null;
	}
	public String getPafKey()
	{
		return this.pafkey;
	}
	public static int getPafKeyMaxLength()
	{
		return 8;
	}
	public void setPafKey(String value)
	{
		this.isValidated = false;
		this.pafkey = value;
	}
	public boolean getAddressLinesIsNotNull()
	{
		return this.addresslines != null;
	}
	public ims.core.patient.vo.PDSAddrRefVo getAddressLines()
	{
		return this.addresslines;
	}
	public void setAddressLines(ims.core.patient.vo.PDSAddrRefVo value)
	{
		this.isValidated = false;
		this.addresslines = value;
	}
	public boolean getGpPracticeCodeIsNotNull()
	{
		return this.gppracticecode != null;
	}
	public String getGpPracticeCode()
	{
		return this.gppracticecode;
	}
	public static int getGpPracticeCodeMaxLength()
	{
		return 30;
	}
	public void setGpPracticeCode(String value)
	{
		this.isValidated = false;
		this.gppracticecode = value;
	}
	public boolean getStatusIsNotNull()
	{
		return this.status != null;
	}
	public ims.core.vo.lookups.PDSSearchStatus getStatus()
	{
		return this.status;
	}
	public void setStatus(ims.core.vo.lookups.PDSSearchStatus value)
	{
		this.isValidated = false;
		this.status = value;
	}
	public boolean getErrorReasonIsNotNull()
	{
		return this.errorreason != null;
	}
	public String getErrorReason()
	{
		return this.errorreason;
	}
	public static int getErrorReasonMaxLength()
	{
		return 100;
	}
	public void setErrorReason(String value)
	{
		this.isValidated = false;
		this.errorreason = 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.nhsnumber != null)
			if(this.nhsnumber.length() > 10)
				listOfErrors.add("The length of the field [nhsnumber] in the value object [ims.core.vo.PDSBatchTraceItemsVo] is too big. It should be less or equal to 10");
		if(this.surname != null)
			if(this.surname.length() > 40)
				listOfErrors.add("The length of the field [surname] in the value object [ims.core.vo.PDSBatchTraceItemsVo] is too big. It should be less or equal to 40");
		if(this.forename != null)
			if(this.forename.length() > 40)
				listOfErrors.add("The length of the field [forename] in the value object [ims.core.vo.PDSBatchTraceItemsVo] is too big. It should be less or equal to 40");
		if(this.postcode != null)
			if(this.postcode.length() > 10)
				listOfErrors.add("The length of the field [postcode] in the value object [ims.core.vo.PDSBatchTraceItemsVo] is too big. It should be less or equal to 10");
		if(this.pafkey != null)
			if(this.pafkey.length() > 8)
				listOfErrors.add("The length of the field [pafkey] in the value object [ims.core.vo.PDSBatchTraceItemsVo] is too big. It should be less or equal to 8");
		if(this.gppracticecode != null)
			if(this.gppracticecode.length() > 30)
				listOfErrors.add("The length of the field [gppracticecode] in the value object [ims.core.vo.PDSBatchTraceItemsVo] is too big. It should be less or equal to 30");
		if(this.errorreason != null)
			if(this.errorreason.length() > 100)
				listOfErrors.add("The length of the field [errorreason] in the value object [ims.core.vo.PDSBatchTraceItemsVo] is too big. It should be less or equal to 100");
		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;
	
		PDSBatchTraceItemsVo clone = new PDSBatchTraceItemsVo(this.id, this.version);
		
		clone.nhsnumber = this.nhsnumber;
		clone.surname = this.surname;
		clone.forename = this.forename;
		if(this.dateofbirth == null)
			clone.dateofbirth = null;
		else
			clone.dateofbirth = (ims.framework.utils.Date)this.dateofbirth.clone();
		if(this.gender == null)
			clone.gender = null;
		else
			clone.gender = (ims.core.vo.lookups.Sex)this.gender.clone();
		if(this.dateofdeathfrom == null)
			clone.dateofdeathfrom = null;
		else
			clone.dateofdeathfrom = (ims.framework.utils.Date)this.dateofdeathfrom.clone();
		if(this.dateofdeathto == null)
			clone.dateofdeathto = null;
		else
			clone.dateofdeathto = (ims.framework.utils.Date)this.dateofdeathto.clone();
		clone.postcode = this.postcode;
		clone.pafkey = this.pafkey;
		clone.addresslines = this.addresslines;
		clone.gppracticecode = this.gppracticecode;
		if(this.status == null)
			clone.status = null;
		else
			clone.status = (ims.core.vo.lookups.PDSSearchStatus)this.status.clone();
		clone.errorreason = this.errorreason;
		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 (!(PDSBatchTraceItemsVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A PDSBatchTraceItemsVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((PDSBatchTraceItemsVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((PDSBatchTraceItemsVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.nhsnumber != null)
			count++;
		if(this.surname != null)
			count++;
		if(this.forename != null)
			count++;
		if(this.dateofbirth != null)
			count++;
		if(this.gender != null)
			count++;
		if(this.dateofdeathfrom != null)
			count++;
		if(this.dateofdeathto != null)
			count++;
		if(this.postcode != null)
			count++;
		if(this.pafkey != null)
			count++;
		if(this.addresslines != null)
			count++;
		if(this.gppracticecode != null)
			count++;
		if(this.status != null)
			count++;
		if(this.errorreason != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 13;
	}
	protected String nhsnumber;
	protected String surname;
	protected String forename;
	protected ims.framework.utils.Date dateofbirth;
	protected ims.core.vo.lookups.Sex gender;
	protected ims.framework.utils.Date dateofdeathfrom;
	protected ims.framework.utils.Date dateofdeathto;
	protected String postcode;
	protected String pafkey;
	protected ims.core.patient.vo.PDSAddrRefVo addresslines;
	protected String gppracticecode;
	protected ims.core.vo.lookups.PDSSearchStatus status;
	protected String errorreason;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
