/FileExtraction/Java_unseen/IMS-MAXIMS_openMAXIMS/Source Library/openmaxims_workspace/ValueObjects/src/ims/pci/vo/CommunityCareVo.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.pci.vo;

/**
 * Linked to core.patient.CommunityCareDetail business object (ID: 1001100006).
 */
public class CommunityCareVo extends ims.pci.vo.CommunityCareShortVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public CommunityCareVo()
	{
	}
	public CommunityCareVo(Integer id, int version)
	{
		super(id, version);
	}
	public CommunityCareVo(ims.pci.vo.beans.CommunityCareVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.cca = bean.getCca() == null ? null : bean.getCca().buildVo();
		this.gpregistrationdate = bean.getGPRegistrationDate() == null ? null : bean.getGPRegistrationDate().buildDate();
		this.lho = bean.getLho() == null ? null : bean.getLho().buildVo();
		this.sector = bean.getSector() == null ? null : bean.getSector().buildVo();
		this.registeredgp = bean.getRegisteredGp() == null ? null : bean.getRegisteredGp().buildVo();
		this.registeredgpsurgery = bean.getRegisteredGpSurgery() == null ? null : new ims.core.resource.place.vo.LocSiteRefVo(new Integer(bean.getRegisteredGpSurgery().getId()), bean.getRegisteredGpSurgery().getVersion());
		this.phndistrict = bean.getPhnDistrict() == null ? null : bean.getPhnDistrict().buildVo();
		this.ded = bean.getDED() == null ? null : bean.getDED().buildVo();
		this.userdefinedfield1 = bean.getUserDefinedField1() == null ? null : ims.pci.vo.lookups.UserDefinedType1.buildLookup(bean.getUserDefinedField1());
		this.userdefinedfield2 = bean.getUserDefinedField2() == null ? null : ims.pci.vo.lookups.UserDefinedType2.buildLookup(bean.getUserDefinedField2());
		this.userdefinedfield3 = bean.getUserDefinedField3() == null ? null : ims.pci.vo.lookups.UserDefinedType3.buildLookup(bean.getUserDefinedField3());
		this.userdefinedfield4 = bean.getUserDefinedField4() == null ? null : ims.pci.vo.lookups.UserDefinedType4.buildLookup(bean.getUserDefinedField4());
		this.userdefinedfield5 = bean.getUserDefinedField5() == null ? null : ims.pci.vo.lookups.UserDefinedType5.buildLookup(bean.getUserDefinedField5());
		this.addresshistory = ims.pci.vo.PciAddressHistoryVoCollection.buildFromBeanCollection(bean.getAddressHistory());
		this.isextracted = bean.getIsExtracted();
		this.currentschool = bean.getCurrentSchool() == null ? null : bean.getCurrentSchool().buildVo();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.pci.vo.beans.CommunityCareVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.cca = bean.getCca() == null ? null : bean.getCca().buildVo(map);
		this.gpregistrationdate = bean.getGPRegistrationDate() == null ? null : bean.getGPRegistrationDate().buildDate();
		this.lho = bean.getLho() == null ? null : bean.getLho().buildVo(map);
		this.sector = bean.getSector() == null ? null : bean.getSector().buildVo(map);
		this.registeredgp = bean.getRegisteredGp() == null ? null : bean.getRegisteredGp().buildVo(map);
		this.registeredgpsurgery = bean.getRegisteredGpSurgery() == null ? null : new ims.core.resource.place.vo.LocSiteRefVo(new Integer(bean.getRegisteredGpSurgery().getId()), bean.getRegisteredGpSurgery().getVersion());
		this.phndistrict = bean.getPhnDistrict() == null ? null : bean.getPhnDistrict().buildVo(map);
		this.ded = bean.getDED() == null ? null : bean.getDED().buildVo(map);
		this.userdefinedfield1 = bean.getUserDefinedField1() == null ? null : ims.pci.vo.lookups.UserDefinedType1.buildLookup(bean.getUserDefinedField1());
		this.userdefinedfield2 = bean.getUserDefinedField2() == null ? null : ims.pci.vo.lookups.UserDefinedType2.buildLookup(bean.getUserDefinedField2());
		this.userdefinedfield3 = bean.getUserDefinedField3() == null ? null : ims.pci.vo.lookups.UserDefinedType3.buildLookup(bean.getUserDefinedField3());
		this.userdefinedfield4 = bean.getUserDefinedField4() == null ? null : ims.pci.vo.lookups.UserDefinedType4.buildLookup(bean.getUserDefinedField4());
		this.userdefinedfield5 = bean.getUserDefinedField5() == null ? null : ims.pci.vo.lookups.UserDefinedType5.buildLookup(bean.getUserDefinedField5());
		this.addresshistory = ims.pci.vo.PciAddressHistoryVoCollection.buildFromBeanCollection(bean.getAddressHistory());
		this.isextracted = bean.getIsExtracted();
		this.currentschool = bean.getCurrentSchool() == null ? null : bean.getCurrentSchool().buildVo(map);
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.pci.vo.beans.CommunityCareVoBean bean = null;
		if(map != null)
			bean = (ims.pci.vo.beans.CommunityCareVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.pci.vo.beans.CommunityCareVoBean();
			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("LHO"))
			return getLho();
		if(fieldName.equals("SECTOR"))
			return getSector();
		if(fieldName.equals("REGISTEREDGP"))
			return getRegisteredGp();
		if(fieldName.equals("REGISTEREDGPSURGERY"))
			return getRegisteredGpSurgery();
		if(fieldName.equals("PHNDISTRICT"))
			return getPhnDistrict();
		if(fieldName.equals("DED"))
			return getDED();
		if(fieldName.equals("USERDEFINEDFIELD1"))
			return getUserDefinedField1();
		if(fieldName.equals("USERDEFINEDFIELD2"))
			return getUserDefinedField2();
		if(fieldName.equals("USERDEFINEDFIELD3"))
			return getUserDefinedField3();
		if(fieldName.equals("USERDEFINEDFIELD4"))
			return getUserDefinedField4();
		if(fieldName.equals("USERDEFINEDFIELD5"))
			return getUserDefinedField5();
		if(fieldName.equals("ADDRESSHISTORY"))
			return getAddressHistory();
		if(fieldName.equals("ISEXTRACTED"))
			return getIsExtracted();
		if(fieldName.equals("CURRENTSCHOOL"))
			return getCurrentSchool();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getLhoIsNotNull()
	{
		return this.lho != null;
	}
	public ims.core.vo.OrgLiteVo getLho()
	{
		return this.lho;
	}
	public void setLho(ims.core.vo.OrgLiteVo value)
	{
		this.isValidated = false;
		this.lho = value;
	}
	public boolean getSectorIsNotNull()
	{
		return this.sector != null;
	}
	public ims.core.vo.LocationLiteVo getSector()
	{
		return this.sector;
	}
	public void setSector(ims.core.vo.LocationLiteVo value)
	{
		this.isValidated = false;
		this.sector = value;
	}
	public boolean getRegisteredGpIsNotNull()
	{
		return this.registeredgp != null;
	}
	public ims.core.vo.GpLiteWithNameVo getRegisteredGp()
	{
		return this.registeredgp;
	}
	public void setRegisteredGp(ims.core.vo.GpLiteWithNameVo value)
	{
		this.isValidated = false;
		this.registeredgp = value;
	}
	public boolean getRegisteredGpSurgeryIsNotNull()
	{
		return this.registeredgpsurgery != null;
	}
	public ims.core.resource.place.vo.LocSiteRefVo getRegisteredGpSurgery()
	{
		return this.registeredgpsurgery;
	}
	public void setRegisteredGpSurgery(ims.core.resource.place.vo.LocSiteRefVo value)
	{
		this.isValidated = false;
		this.registeredgpsurgery = value;
	}
	public boolean getPhnDistrictIsNotNull()
	{
		return this.phndistrict != null;
	}
	public ims.core.vo.LocationLiteVo getPhnDistrict()
	{
		return this.phndistrict;
	}
	public void setPhnDistrict(ims.core.vo.LocationLiteVo value)
	{
		this.isValidated = false;
		this.phndistrict = value;
	}
	public boolean getDEDIsNotNull()
	{
		return this.ded != null;
	}
	public ims.core.vo.DEDLiteVo getDED()
	{
		return this.ded;
	}
	public void setDED(ims.core.vo.DEDLiteVo value)
	{
		this.isValidated = false;
		this.ded = value;
	}
	public boolean getUserDefinedField1IsNotNull()
	{
		return this.userdefinedfield1 != null;
	}
	public ims.pci.vo.lookups.UserDefinedType1 getUserDefinedField1()
	{
		return this.userdefinedfield1;
	}
	public void setUserDefinedField1(ims.pci.vo.lookups.UserDefinedType1 value)
	{
		this.isValidated = false;
		this.userdefinedfield1 = value;
	}
	public boolean getUserDefinedField2IsNotNull()
	{
		return this.userdefinedfield2 != null;
	}
	public ims.pci.vo.lookups.UserDefinedType2 getUserDefinedField2()
	{
		return this.userdefinedfield2;
	}
	public void setUserDefinedField2(ims.pci.vo.lookups.UserDefinedType2 value)
	{
		this.isValidated = false;
		this.userdefinedfield2 = value;
	}
	public boolean getUserDefinedField3IsNotNull()
	{
		return this.userdefinedfield3 != null;
	}
	public ims.pci.vo.lookups.UserDefinedType3 getUserDefinedField3()
	{
		return this.userdefinedfield3;
	}
	public void setUserDefinedField3(ims.pci.vo.lookups.UserDefinedType3 value)
	{
		this.isValidated = false;
		this.userdefinedfield3 = value;
	}
	public boolean getUserDefinedField4IsNotNull()
	{
		return this.userdefinedfield4 != null;
	}
	public ims.pci.vo.lookups.UserDefinedType4 getUserDefinedField4()
	{
		return this.userdefinedfield4;
	}
	public void setUserDefinedField4(ims.pci.vo.lookups.UserDefinedType4 value)
	{
		this.isValidated = false;
		this.userdefinedfield4 = value;
	}
	public boolean getUserDefinedField5IsNotNull()
	{
		return this.userdefinedfield5 != null;
	}
	public ims.pci.vo.lookups.UserDefinedType5 getUserDefinedField5()
	{
		return this.userdefinedfield5;
	}
	public void setUserDefinedField5(ims.pci.vo.lookups.UserDefinedType5 value)
	{
		this.isValidated = false;
		this.userdefinedfield5 = value;
	}
	public boolean getAddressHistoryIsNotNull()
	{
		return this.addresshistory != null;
	}
	public ims.pci.vo.PciAddressHistoryVoCollection getAddressHistory()
	{
		return this.addresshistory;
	}
	public void setAddressHistory(ims.pci.vo.PciAddressHistoryVoCollection value)
	{
		this.isValidated = false;
		this.addresshistory = value;
	}
	public boolean getIsExtractedIsNotNull()
	{
		return this.isextracted != null;
	}
	public Boolean getIsExtracted()
	{
		return this.isextracted;
	}
	public void setIsExtracted(Boolean value)
	{
		this.isValidated = false;
		this.isextracted = value;
	}
	public boolean getCurrentSchoolIsNotNull()
	{
		return this.currentschool != null;
	}
	public ims.core.vo.SchoolShortVo getCurrentSchool()
	{
		return this.currentschool;
	}
	public void setCurrentSchool(ims.core.vo.SchoolShortVo value)
	{
		this.isValidated = false;
		this.currentschool = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.cca != null)
		{
			if(!this.cca.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.phndistrict != null)
		{
			if(!this.phndistrict.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.addresshistory != null)
		{
			if(!this.addresshistory.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.cca != null)
		{
			String[] listOfOtherErrors = this.cca.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.phndistrict != null)
		{
			String[] listOfOtherErrors = this.phndistrict.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.addresshistory != null)
		{
			String[] listOfOtherErrors = this.addresshistory.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;
	
		CommunityCareVo clone = new CommunityCareVo(this.id, this.version);
		
		if(this.cca == null)
			clone.cca = null;
		else
			clone.cca = (ims.core.vo.LocSiteLiteVo)this.cca.clone();
		if(this.gpregistrationdate == null)
			clone.gpregistrationdate = null;
		else
			clone.gpregistrationdate = (ims.framework.utils.Date)this.gpregistrationdate.clone();
		if(this.lho == null)
			clone.lho = null;
		else
			clone.lho = (ims.core.vo.OrgLiteVo)this.lho.clone();
		if(this.sector == null)
			clone.sector = null;
		else
			clone.sector = (ims.core.vo.LocationLiteVo)this.sector.clone();
		if(this.registeredgp == null)
			clone.registeredgp = null;
		else
			clone.registeredgp = (ims.core.vo.GpLiteWithNameVo)this.registeredgp.clone();
		clone.registeredgpsurgery = this.registeredgpsurgery;
		if(this.phndistrict == null)
			clone.phndistrict = null;
		else
			clone.phndistrict = (ims.core.vo.LocationLiteVo)this.phndistrict.clone();
		if(this.ded == null)
			clone.ded = null;
		else
			clone.ded = (ims.core.vo.DEDLiteVo)this.ded.clone();
		if(this.userdefinedfield1 == null)
			clone.userdefinedfield1 = null;
		else
			clone.userdefinedfield1 = (ims.pci.vo.lookups.UserDefinedType1)this.userdefinedfield1.clone();
		if(this.userdefinedfield2 == null)
			clone.userdefinedfield2 = null;
		else
			clone.userdefinedfield2 = (ims.pci.vo.lookups.UserDefinedType2)this.userdefinedfield2.clone();
		if(this.userdefinedfield3 == null)
			clone.userdefinedfield3 = null;
		else
			clone.userdefinedfield3 = (ims.pci.vo.lookups.UserDefinedType3)this.userdefinedfield3.clone();
		if(this.userdefinedfield4 == null)
			clone.userdefinedfield4 = null;
		else
			clone.userdefinedfield4 = (ims.pci.vo.lookups.UserDefinedType4)this.userdefinedfield4.clone();
		if(this.userdefinedfield5 == null)
			clone.userdefinedfield5 = null;
		else
			clone.userdefinedfield5 = (ims.pci.vo.lookups.UserDefinedType5)this.userdefinedfield5.clone();
		if(this.addresshistory == null)
			clone.addresshistory = null;
		else
			clone.addresshistory = (ims.pci.vo.PciAddressHistoryVoCollection)this.addresshistory.clone();
		clone.isextracted = this.isextracted;
		if(this.currentschool == null)
			clone.currentschool = null;
		else
			clone.currentschool = (ims.core.vo.SchoolShortVo)this.currentschool.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 (!(CommunityCareVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A CommunityCareVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((CommunityCareVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((CommunityCareVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = super.countFieldsWithValue();
		if(this.lho != null)
			count++;
		if(this.sector != null)
			count++;
		if(this.registeredgp != null)
			count++;
		if(this.registeredgpsurgery != null)
			count++;
		if(this.phndistrict != null)
			count++;
		if(this.ded != null)
			count++;
		if(this.userdefinedfield1 != null)
			count++;
		if(this.userdefinedfield2 != null)
			count++;
		if(this.userdefinedfield3 != null)
			count++;
		if(this.userdefinedfield4 != null)
			count++;
		if(this.userdefinedfield5 != null)
			count++;
		if(this.addresshistory != null)
			count++;
		if(this.isextracted != null)
			count++;
		if(this.currentschool != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return super.countValueObjectFields() + 14;
	}
	protected ims.core.vo.OrgLiteVo lho;
	protected ims.core.vo.LocationLiteVo sector;
	protected ims.core.vo.GpLiteWithNameVo registeredgp;
	protected ims.core.resource.place.vo.LocSiteRefVo registeredgpsurgery;
	protected ims.core.vo.LocationLiteVo phndistrict;
	protected ims.core.vo.DEDLiteVo ded;
	protected ims.pci.vo.lookups.UserDefinedType1 userdefinedfield1;
	protected ims.pci.vo.lookups.UserDefinedType2 userdefinedfield2;
	protected ims.pci.vo.lookups.UserDefinedType3 userdefinedfield3;
	protected ims.pci.vo.lookups.UserDefinedType4 userdefinedfield4;
	protected ims.pci.vo.lookups.UserDefinedType5 userdefinedfield5;
	protected ims.pci.vo.PciAddressHistoryVoCollection addresshistory;
	protected Boolean isextracted;
	protected ims.core.vo.SchoolShortVo currentschool;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
