gt: 		for(int x = 0; x < errorCount; x++)
context: //#############################################################################
  //#                                                                           #
  //#  Copyright (C) <2014>  <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/>.    #
  //#                                                                           #
  //#############################################################################
  //#EOH
  // This code was generated by Barbara Worwood using IMS Development Environment (version 1.80 build 5007.25751)
  // Copyright (C) 1995-2014 IMS MAXIMS. All rights reserved.
  // WARNING: DO NOT MODIFY the content of this file
  
  package ims.core.vo;
  
  /**
   * Linked to core.patient.Patient business object (ID: 1001100000).
   */
  public class PatientShortListVo extends ims.core.patient.vo.PatientRefVo implements ims.vo.ImsCloneable, Comparable
  {
  	private static final long serialVersionUID = 1L;
  
  	public PatientShortListVo()
  	{
  	}
  	public PatientShortListVo(Integer id, int version)
  	{
  		super(id, version);
  	}
  	public PatientShortListVo(ims.core.vo.beans.PatientShortListVoBean bean)
  	{
  		this.id = bean.getId();
  		this.version = bean.getVersion();
  		this.name = bean.getName() == null ? null : bean.getName().buildVo();
  		this.ward = bean.getWard() == null ? null : new ims.core.resource.place.vo.LocationRefVo(new Integer(bean.getWard().getId()), bean.getWard().getVersion());
  		this.identifiers = ims.core.vo.PatientIdCollection.buildFromBeanCollection(bean.getIdentifiers());
  		this.dod = bean.getDod() == null ? null : bean.getDod().buildDate();
  		this.associatedpatient = bean.getAssociatedPatient() == null ? null : new ims.core.patient.vo.PatientRefVo(new Integer(bean.getAssociatedPatient().getId()), bean.getAssociatedPatient().getVersion());
  		this.sex = bean.getSex() == null ? null : ims.core.vo.lookups.Sex.buildLookup(bean.getSex());
  		this.patientalerts = ims.core.vo.PatientAlertLiteVoCollection.buildFromBeanCollection(bean.getPatientAlerts());
  		this.dob = bean.getDob() == null ? null : bean.getDob().buildPartialDate();
  		this.age = bean.getAge();
  	}
  	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.PatientShortListVoBean bean)
  	{
  		this.id = bean.getId();
  		this.version = bean.getVersion();
  		this.name = bean.getName() == null ? null : bean.getName().buildVo(map);
  		this.ward = bean.getWard() == null ? null : new ims.core.resource.place.vo.LocationRefVo(new Integer(bean.getWard().getId()), bean.getWard().getVersion());
  		this.identifiers = ims.core.vo.PatientIdCollection.buildFromBeanCollection(bean.getIdentifiers());
  		this.dod = bean.getDod() == null ? null : bean.getDod().buildDate();
  		this.associatedpatient = bean.getAssociatedPatient() == null ? null : new ims.core.patient.vo.PatientRefVo(new Integer(bean.getAssociatedPatient().getId()), bean.getAssociatedPatient().getVersion());
  		this.sex = bean.getSex() == null ? null : ims.core.vo.lookups.Sex.buildLookup(bean.getSex());
  		this.patientalerts = ims.core.vo.PatientAlertLiteVoCollection.buildFromBeanCollection(bean.getPatientAlerts());
  		this.dob = bean.getDob() == null ? null : bean.getDob().buildPartialDate();
  		this.age = bean.getAge();
  	}
  	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.PatientShortListVoBean bean = null;
  		if(map != null)
  			bean = (ims.core.vo.beans.PatientShortListVoBean)map.getValueObjectBean(this);
  		if (bean == null)
  		{
  			bean = new ims.core.vo.beans.PatientShortListVoBean();
  			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("NAME"))
  			return getName();
  		if(fieldName.equals("WARD"))
  			return getWard();
  		if(fieldName.equals("IDENTIFIERS"))
  			return getIdentifiers();
  		if(fieldName.equals("DOD"))
  			return getDod();
  		if(fieldName.equals("ASSOCIATEDPATIENT"))
  			return getAssociatedPatient();
  		if(fieldName.equals("SEX"))
  			return getSex();
  		if(fieldName.equals("PATIENTALERTS"))
  			return getPatientAlerts();
  		if(fieldName.equals("DOB"))
  			return getDob();
  		if(fieldName.equals("AGE"))
  			return getAge();
  		return super.getFieldValueByFieldName(fieldName);
  	}
  	public boolean getNameIsNotNull()
  	{
  		return this.name != null;
  	}
  	public ims.core.vo.PersonName getName()
  	{
  		return this.name;
  	}
  	public void setName(ims.core.vo.PersonName value)
  	{
  		this.isValidated = false;
  		this.name = value;
  	}
  	public boolean getWardIsNotNull()
  	{
  		return this.ward != null;
  	}
  	public ims.core.resource.place.vo.LocationRefVo getWard()
  	{
  		return this.ward;
  	}
  	public void setWard(ims.core.resource.place.vo.LocationRefVo value)
  	{
  		this.isValidated = false;
  		this.ward = value;
  	}
  	public boolean getIdentifiersIsNotNull()
  	{
  		return this.identifiers != null;
  	}
  	public ims.core.vo.PatientIdCollection getIdentifiers()
  	{
  		return this.identifiers;
  	}
  	public void setIdentifiers(ims.core.vo.PatientIdCollection value)
  	{
  		this.isValidated = false;
  		this.identifiers = value;
  	}
  	public boolean getDodIsNotNull()
  	{
  		return this.dod != null;
  	}
  	public ims.framework.utils.Date getDod()
  	{
  		return this.dod;
  	}
  	public void setDod(ims.framework.utils.Date value)
  	{
  		this.isValidated = false;
  		this.dod = value;
  	}
  	public boolean getAssociatedPatientIsNotNull()
  	{
  		return this.associatedpatient != null;
  	}
  	public ims.core.patient.vo.PatientRefVo getAssociatedPatient()
  	{
  		return this.associatedpatient;
  	}
  	public void setAssociatedPatient(ims.core.patient.vo.PatientRefVo value)
  	{
  		this.isValidated = false;
  		this.associatedpatient = value;
  	}
  	public boolean getSexIsNotNull()
  	{
  		return this.sex != null;
  	}
  	public ims.core.vo.lookups.Sex getSex()
  	{
  		return this.sex;
  	}
  	public void setSex(ims.core.vo.lookups.Sex value)
  	{
  		this.isValidated = false;
  		this.sex = value;
  	}
  	public boolean getPatientAlertsIsNotNull()
  	{
  		return this.patientalerts != null;
  	}
  	public ims.core.vo.PatientAlertLiteVoCollection getPatientAlerts()
  	{
  		return this.patientalerts;
  	}
  	public void setPatientAlerts(ims.core.vo.PatientAlertLiteVoCollection value)
  	{
  		this.isValidated = false;
  		this.patientalerts = value;
  	}
  	public boolean getDobIsNotNull()
  	{
  		return this.dob != null;
  	}
  	public ims.framework.utils.PartialDate getDob()
  	{
  		return this.dob;
  	}
  	public void setDob(ims.framework.utils.PartialDate value)
  	{
  		this.isValidated = false;
  		this.dob = value;
  	}
  	public boolean getAgeIsNotNull()
  	{
  		return this.age != null;
  	}
  	public Integer getAge()
  	{
  		return this.age;
  	}
  	public void setAge(Integer value)
  	{
  		this.isValidated = false;
  		this.age = value;
  	}
  	/**
  	* getPatId: Gets the patient identifier for the type passed in
  	*/
  	public ims.core.vo.PatientId getPatId(ims.core.vo.lookups.PatIdType idType)
  	{
  		if (identifiers == null) return null;
  		for (int i = 0; i < identifiers.size(); i++)
  		{
  			ims.core.vo.PatientId id = identifiers.get(i);
  			if (id.getType().equals(idType))
  			{
  				return id;
  			}
  		}
  		return null;
  	}
  	
  	/**
  	* calculateAge: calculate's the patient's Age based on DOB and DOD
  	*/
  	public Integer calculateAge()
  	{
  		if (dob != null)
  		{		
  			int patAge = 0;
  			if (dod != null)
  			{
  				patAge = dod.yearDiff(dob);
  			}
  			else
  			{
  				patAge = new ims.framework.utils.Date().yearDiff(dob);
  			}
  			setAge(new Integer(patAge));
  		}
  		return getAge();
  	}
  	
  	
  	public boolean isValidated()
  	{
  		if(this.isBusy)
  			return true;
  		this.isBusy = true;
  	
  		if(!this.isValidated)
  		{
  			this.isBusy = false;
  			return false;
  		}
  		if(this.name != null)
  		{
  			if(!this.name.isValidated())
  			{
  				this.isBusy = false;
  				return false;
  			}
  		}
  		if(this.identifiers != null)
  		{
  			if(!this.identifiers.isValidated())
  			{
  				this.isBusy = false;
  				return false;
  			}
  		}
  		if(this.patientalerts != null)
  		{
  			if(!this.patientalerts.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.name != null)
  		{
  			String[] listOfOtherErrors = this.name.validate();
  			if(listOfOtherErrors != null)
  			{
  				for(int x = 0; x < listOfOtherErrors.length; x++)
  				{
  					listOfErrors.add(listOfOtherErrors[x]);
  				}
  			}
  		}
  		if(this.identifiers != null)
  		{
  			String[] listOfOtherErrors = this.identifiers.validate();
  			if(listOfOtherErrors != null)
  			{
  				for(int x = 0; x < listOfOtherErrors.length; x++)
  				{
  					listOfErrors.add(listOfOtherErrors[x]);
  				}
  			}
  		}
  		if(this.patientalerts != null)
  		{
  			String[] listOfOtherErrors = this.patientalerts.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];
  