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

	public PatientContactPreferenceVo()
	{
	}
	public PatientContactPreferenceVo(Integer id, int version)
	{
		super(id, version);
	}
	public PatientContactPreferenceVo(ims.core.vo.beans.PatientContactPreferenceVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.contactname = bean.getContactName();
		this.preferredcontacttimes = bean.getPreferredContactTimes() == null ? null : ims.core.vo.lookups.PreferredContactTime.buildLookup(bean.getPreferredContactTimes());
		this.patientcallbackconsent = bean.getPatientCallBackConsent();
		this.pdspreferredcontacttimes = bean.getPdsPreferredContactTimes();
		this.pdspreferredwrittencomm = bean.getPdsPreferredWrittenComm() == null ? null : ims.core.vo.lookups.PreferredWrittenCommunication.buildLookup(bean.getPdsPreferredWrittenComm());
		this.pdsconsent = bean.getPdsConsent() == null ? null : ims.core.vo.lookups.PDSConsent.buildLookup(bean.getPdsConsent());
		this.pdsdatelastchanged = bean.getPdsDateLastChanged() == null ? null : bean.getPdsDateLastChanged().buildDate();
		this.preferredcontactmethod = bean.getPreferredContactMethod() == null ? null : ims.core.vo.lookups.ContactMethod.buildLookup(bean.getPreferredContactMethod());
		this.pdspreferredcontactmethod = bean.getPdsPreferredContactMethod() == null ? null : ims.core.vo.lookups.PDSContactMethod.buildLookup(bean.getPdsPreferredContactMethod());
		this.optoutofreminders = bean.getOptOutOfReminders();
		this.pdsconsenttype = bean.getPdsConsentType() == null ? null : ims.core.vo.lookups.PDSConsentType.buildLookup(bean.getPdsConsentType());
		this.pdsupdatemode = bean.getPdsUpdateMode() == null ? null : ims.core.vo.lookups.PDSUpdateMode.buildLookup(bean.getPdsUpdateMode());
		this.comment = bean.getComment();
		this.consenthistory = ims.core.vo.PDSConsentHistoryVoCollection.buildFromBeanCollection(bean.getConsentHistory());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.PatientContactPreferenceVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.contactname = bean.getContactName();
		this.preferredcontacttimes = bean.getPreferredContactTimes() == null ? null : ims.core.vo.lookups.PreferredContactTime.buildLookup(bean.getPreferredContactTimes());
		this.patientcallbackconsent = bean.getPatientCallBackConsent();
		this.pdspreferredcontacttimes = bean.getPdsPreferredContactTimes();
		this.pdspreferredwrittencomm = bean.getPdsPreferredWrittenComm() == null ? null : ims.core.vo.lookups.PreferredWrittenCommunication.buildLookup(bean.getPdsPreferredWrittenComm());
		this.pdsconsent = bean.getPdsConsent() == null ? null : ims.core.vo.lookups.PDSConsent.buildLookup(bean.getPdsConsent());
		this.pdsdatelastchanged = bean.getPdsDateLastChanged() == null ? null : bean.getPdsDateLastChanged().buildDate();
		this.preferredcontactmethod = bean.getPreferredContactMethod() == null ? null : ims.core.vo.lookups.ContactMethod.buildLookup(bean.getPreferredContactMethod());
		this.pdspreferredcontactmethod = bean.getPdsPreferredContactMethod() == null ? null : ims.core.vo.lookups.PDSContactMethod.buildLookup(bean.getPdsPreferredContactMethod());
		this.optoutofreminders = bean.getOptOutOfReminders();
		this.pdsconsenttype = bean.getPdsConsentType() == null ? null : ims.core.vo.lookups.PDSConsentType.buildLookup(bean.getPdsConsentType());
		this.pdsupdatemode = bean.getPdsUpdateMode() == null ? null : ims.core.vo.lookups.PDSUpdateMode.buildLookup(bean.getPdsUpdateMode());
		this.comment = bean.getComment();
		this.consenthistory = ims.core.vo.PDSConsentHistoryVoCollection.buildFromBeanCollection(bean.getConsentHistory());
	}
	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.PatientContactPreferenceVoBean bean = null;
		if(map != null)
			bean = (ims.core.vo.beans.PatientContactPreferenceVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.core.vo.beans.PatientContactPreferenceVoBean();
			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("CONTACTNAME"))
			return getContactName();
		if(fieldName.equals("PREFERREDCONTACTTIMES"))
			return getPreferredContactTimes();
		if(fieldName.equals("PATIENTCALLBACKCONSENT"))
			return getPatientCallBackConsent();
		if(fieldName.equals("PDSPREFERREDCONTACTTIMES"))
			return getPdsPreferredContactTimes();
		if(fieldName.equals("PDSPREFERREDWRITTENCOMM"))
			return getPdsPreferredWrittenComm();
		if(fieldName.equals("PDSCONSENT"))
			return getPdsConsent();
		if(fieldName.equals("PDSDATELASTCHANGED"))
			return getPdsDateLastChanged();
		if(fieldName.equals("PREFERREDCONTACTMETHOD"))
			return getPreferredContactMethod();
		if(fieldName.equals("PDSPREFERREDCONTACTMETHOD"))
			return getPdsPreferredContactMethod();
		if(fieldName.equals("OPTOUTOFREMINDERS"))
			return getOptOutOfReminders();
		if(fieldName.equals("PDSCONSENTTYPE"))
			return getPdsConsentType();
		if(fieldName.equals("PDSUPDATEMODE"))
			return getPdsUpdateMode();
		if(fieldName.equals("COMMENT"))
			return getComment();
		if(fieldName.equals("CONSENTHISTORY"))
			return getConsentHistory();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getContactNameIsNotNull()
	{
		return this.contactname != null;
	}
	public String getContactName()
	{
		return this.contactname;
	}
	public static int getContactNameMaxLength()
	{
		return 100;
	}
	public void setContactName(String value)
	{
		this.isValidated = false;
		this.contactname = value;
	}
	public boolean getPreferredContactTimesIsNotNull()
	{
		return this.preferredcontacttimes != null;
	}
	public ims.core.vo.lookups.PreferredContactTime getPreferredContactTimes()
	{
		return this.preferredcontacttimes;
	}
	public void setPreferredContactTimes(ims.core.vo.lookups.PreferredContactTime value)
	{
		this.isValidated = false;
		this.preferredcontacttimes = value;
	}
	public boolean getPatientCallBackConsentIsNotNull()
	{
		return this.patientcallbackconsent != null;
	}
	public Boolean getPatientCallBackConsent()
	{
		return this.patientcallbackconsent;
	}
	public void setPatientCallBackConsent(Boolean value)
	{
		this.isValidated = false;
		this.patientcallbackconsent = value;
	}
	public boolean getPdsPreferredContactTimesIsNotNull()
	{
		return this.pdspreferredcontacttimes != null;
	}
	public String getPdsPreferredContactTimes()
	{
		return this.pdspreferredcontacttimes;
	}
	public static int getPdsPreferredContactTimesMaxLength()
	{
		return 40;
	}
	public void setPdsPreferredContactTimes(String value)
	{
		this.isValidated = false;
		this.pdspreferredcontacttimes = value;
	}
	public boolean getPdsPreferredWrittenCommIsNotNull()
	{
		return this.pdspreferredwrittencomm != null;
	}
	public ims.core.vo.lookups.PreferredWrittenCommunication getPdsPreferredWrittenComm()
	{
		return this.pdspreferredwrittencomm;
	}
	public void setPdsPreferredWrittenComm(ims.core.vo.lookups.PreferredWrittenCommunication value)
	{
		this.isValidated = false;
		this.pdspreferredwrittencomm = value;
	}
	public boolean getPdsConsentIsNotNull()
	{
		return this.pdsconsent != null;
	}
	public ims.core.vo.lookups.PDSConsent getPdsConsent()
	{
		return this.pdsconsent;
	}
	public void setPdsConsent(ims.core.vo.lookups.PDSConsent value)
	{
		this.isValidated = false;
		this.pdsconsent = value;
	}
	public boolean getPdsDateLastChangedIsNotNull()
	{
		return this.pdsdatelastchanged != null;
	}
	public ims.framework.utils.Date getPdsDateLastChanged()
	{
		return this.pdsdatelastchanged;
	}
	public void setPdsDateLastChanged(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.pdsdatelastchanged = value;
	}
	public boolean getPreferredContactMethodIsNotNull()
	{
		return this.preferredcontactmethod != null;
	}
	public ims.core.vo.lookups.ContactMethod getPreferredContactMethod()
	{
		return this.preferredcontactmethod;
	}
	public void setPreferredContactMethod(ims.core.vo.lookups.ContactMethod value)
	{
		this.isValidated = false;
		this.preferredcontactmethod = value;
	}
	public boolean getPdsPreferredContactMethodIsNotNull()
	{
		return this.pdspreferredcontactmethod != null;
	}
	public ims.core.vo.lookups.PDSContactMethod getPdsPreferredContactMethod()
	{
		return this.pdspreferredcontactmethod;
	}
	public void setPdsPreferredContactMethod(ims.core.vo.lookups.PDSContactMethod value)
	{
		this.isValidated = false;
		this.pdspreferredcontactmethod = value;
	}
	public boolean getOptOutOfRemindersIsNotNull()
	{
		return this.optoutofreminders != null;
	}
	public Boolean getOptOutOfReminders()
	{
		return this.optoutofreminders;
	}
	public void setOptOutOfReminders(Boolean value)
	{
		this.isValidated = false;
		this.optoutofreminders = value;
	}
	public boolean getPdsConsentTypeIsNotNull()
	{
		return this.pdsconsenttype != null;
	}
	public ims.core.vo.lookups.PDSConsentType getPdsConsentType()
	{
		return this.pdsconsenttype;
	}
	public void setPdsConsentType(ims.core.vo.lookups.PDSConsentType value)
	{
		this.isValidated = false;
		this.pdsconsenttype = value;
	}
	public boolean getPdsUpdateModeIsNotNull()
	{
		return this.pdsupdatemode != null;
	}
	public ims.core.vo.lookups.PDSUpdateMode getPdsUpdateMode()
	{
		return this.pdsupdatemode;
	}
	public void setPdsUpdateMode(ims.core.vo.lookups.PDSUpdateMode value)
	{
		this.isValidated = false;
		this.pdsupdatemode = value;
	}
	public boolean getCommentIsNotNull()
	{
		return this.comment != null;
	}
	public String getComment()
	{
		return this.comment;
	}
	public static int getCommentMaxLength()
	{
		return 500;
	}
	public void setComment(String value)
	{
		this.isValidated = false;
		this.comment = value;
	}
	public boolean getConsentHistoryIsNotNull()
	{
		return this.consenthistory != null;
	}
	public ims.core.vo.PDSConsentHistoryVoCollection getConsentHistory()
	{
		return this.consenthistory;
	}
	public void setConsentHistory(ims.core.vo.PDSConsentHistoryVoCollection value)
	{
		this.isValidated = false;
		this.consenthistory = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.consenthistory != null)
		{
			if(!this.consenthistory.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.contactname != null)
			if(this.contactname.length() > 100)
				listOfErrors.add("The length of the field [contactname] in the value object [ims.core.vo.PatientContactPreferenceVo] is too big. It should be less or equal to 100");
		if(this.pdspreferredcontacttimes != null)
			if(this.pdspreferredcontacttimes.length() > 40)
				listOfErrors.add("The length of the field [pdspreferredcontacttimes] in the value object [ims.core.vo.PatientContactPreferenceVo] is too big. It should be less or equal to 40");
		if(this.comment != null)
			if(this.comment.length() > 500)
				listOfErrors.add("The length of the field [comment] in the value object [ims.core.vo.PatientContactPreferenceVo] is too big. It should be less or equal to 500");
		if(this.consenthistory != null)
		{
			String[] listOfOtherErrors = this.consenthistory.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;
	
		PatientContactPreferenceVo clone = new PatientContactPreferenceVo(this.id, this.version);
		
		clone.contactname = this.contactname;
		if(this.preferredcontacttimes == null)
			clone.preferredcontacttimes = null;
		else
			clone.preferredcontacttimes = (ims.core.vo.lookups.PreferredContactTime)this.preferredcontacttimes.clone();
		clone.patientcallbackconsent = this.patientcallbackconsent;
		clone.pdspreferredcontacttimes = this.pdspreferredcontacttimes;
		if(this.pdspreferredwrittencomm == null)
			clone.pdspreferredwrittencomm = null;
		else
			clone.pdspreferredwrittencomm = (ims.core.vo.lookups.PreferredWrittenCommunication)this.pdspreferredwrittencomm.clone();
		if(this.pdsconsent == null)
			clone.pdsconsent = null;
		else
			clone.pdsconsent = (ims.core.vo.lookups.PDSConsent)this.pdsconsent.clone();
		if(this.pdsdatelastchanged == null)
			clone.pdsdatelastchanged = null;
		else
			clone.pdsdatelastchanged = (ims.framework.utils.Date)this.pdsdatelastchanged.clone();
		if(this.preferredcontactmethod == null)
			clone.preferredcontactmethod = null;
		else
			clone.preferredcontactmethod = (ims.core.vo.lookups.ContactMethod)this.preferredcontactmethod.clone();
		if(this.pdspreferredcontactmethod == null)
			clone.pdspreferredcontactmethod = null;
		else
			clone.pdspreferredcontactmethod = (ims.core.vo.lookups.PDSContactMethod)this.pdspreferredcontactmethod.clone();
		clone.optoutofreminders = this.optoutofreminders;
		if(this.pdsconsenttype == null)
			clone.pdsconsenttype = null;
		else
			clone.pdsconsenttype = (ims.core.vo.lookups.PDSConsentType)this.pdsconsenttype.clone();
		if(this.pdsupdatemode == null)
			clone.pdsupdatemode = null;
		else
			clone.pdsupdatemode = (ims.core.vo.lookups.PDSUpdateMode)this.pdsupdatemode.clone();
		clone.comment = this.comment;
		if(this.consenthistory == null)
			clone.consenthistory = null;
		else
			clone.consenthistory = (ims.core.vo.PDSConsentHistoryVoCollection)this.consenthistory.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 (!(PatientContactPreferenceVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A PatientContactPreferenceVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((PatientContactPreferenceVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((PatientContactPreferenceVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.contactname != null)
			count++;
		if(this.preferredcontacttimes != null)
			count++;
		if(this.patientcallbackconsent != null)
			count++;
		if(this.pdspreferredcontacttimes != null)
			count++;
		if(this.pdspreferredwrittencomm != null)
			count++;
		if(this.pdsconsent != null)
			count++;
		if(this.pdsdatelastchanged != null)
			count++;
		if(this.preferredcontactmethod != null)
			count++;
		if(this.pdspreferredcontactmethod != null)
			count++;
		if(this.optoutofreminders != null)
			count++;
		if(this.pdsconsenttype != null)
			count++;
		if(this.pdsupdatemode != null)
			count++;
		if(this.comment != null)
			count++;
		if(this.consenthistory != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 14;
	}
	protected String contactname;
	protected ims.core.vo.lookups.PreferredContactTime preferredcontacttimes;
	protected Boolean patientcallbackconsent;
	protected String pdspreferredcontacttimes;
	protected ims.core.vo.lookups.PreferredWrittenCommunication pdspreferredwrittencomm;
	protected ims.core.vo.lookups.PDSConsent pdsconsent;
	protected ims.framework.utils.Date pdsdatelastchanged;
	protected ims.core.vo.lookups.ContactMethod preferredcontactmethod;
	protected ims.core.vo.lookups.PDSContactMethod pdspreferredcontactmethod;
	protected Boolean optoutofreminders;
	protected ims.core.vo.lookups.PDSConsentType pdsconsenttype;
	protected ims.core.vo.lookups.PDSUpdateMode pdsupdatemode;
	protected String comment;
	protected ims.core.vo.PDSConsentHistoryVoCollection consenthistory;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
