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

	public PatientApptDiaryVo()
	{
	}
	public PatientApptDiaryVo(Integer id, int version)
	{
		super(id, version);
	}
	public PatientApptDiaryVo(ims.core.vo.beans.PatientApptDiaryVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.appointmentid = bean.getAppointmentId();
		this.pasevent = bean.getPasEvent() == null ? null : bean.getPasEvent().buildVo();
		this.apptdate = bean.getApptDate() == null ? null : bean.getApptDate().buildDate();
		this.starttime = bean.getStartTime() == null ? null : bean.getStartTime().buildTime();
		this.endtime = bean.getEndTime() == null ? null : bean.getEndTime().buildTime();
		this.clinicname = bean.getClinicName();
		this.clinic = bean.getClinic() == null ? null : new ims.core.resource.place.vo.ClinicRefVo(new Integer(bean.getClinic().getId()), bean.getClinic().getVersion());
		this.source = bean.getSource();
		this.appttype = bean.getApptType();
		this.patient = bean.getPatient() == null ? null : new ims.core.patient.vo.PatientRefVo(new Integer(bean.getPatient().getId()), bean.getPatient().getVersion());
		this.status = bean.getStatus();
		this.statusdate = bean.getStatusDate() == null ? null : bean.getStatusDate().buildDateTime();
		this.bookedby = bean.getBookedBy();
		this.bookeddate = bean.getBookedDate() == null ? null : bean.getBookedDate().buildDateTime();
		this.pkey = bean.getPkey();
		this.appointheaderid = bean.getAppointHeaderId();
		this.active = bean.getActive();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.PatientApptDiaryVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.appointmentid = bean.getAppointmentId();
		this.pasevent = bean.getPasEvent() == null ? null : bean.getPasEvent().buildVo(map);
		this.apptdate = bean.getApptDate() == null ? null : bean.getApptDate().buildDate();
		this.starttime = bean.getStartTime() == null ? null : bean.getStartTime().buildTime();
		this.endtime = bean.getEndTime() == null ? null : bean.getEndTime().buildTime();
		this.clinicname = bean.getClinicName();
		this.clinic = bean.getClinic() == null ? null : new ims.core.resource.place.vo.ClinicRefVo(new Integer(bean.getClinic().getId()), bean.getClinic().getVersion());
		this.source = bean.getSource();
		this.appttype = bean.getApptType();
		this.patient = bean.getPatient() == null ? null : new ims.core.patient.vo.PatientRefVo(new Integer(bean.getPatient().getId()), bean.getPatient().getVersion());
		this.status = bean.getStatus();
		this.statusdate = bean.getStatusDate() == null ? null : bean.getStatusDate().buildDateTime();
		this.bookedby = bean.getBookedBy();
		this.bookeddate = bean.getBookedDate() == null ? null : bean.getBookedDate().buildDateTime();
		this.pkey = bean.getPkey();
		this.appointheaderid = bean.getAppointHeaderId();
		this.active = bean.getActive();
	}
	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.PatientApptDiaryVoBean bean = null;
		if(map != null)
			bean = (ims.core.vo.beans.PatientApptDiaryVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.core.vo.beans.PatientApptDiaryVoBean();
			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("APPOINTMENTID"))
			return getAppointmentId();
		if(fieldName.equals("PASEVENT"))
			return getPasEvent();
		if(fieldName.equals("APPTDATE"))
			return getApptDate();
		if(fieldName.equals("STARTTIME"))
			return getStartTime();
		if(fieldName.equals("ENDTIME"))
			return getEndTime();
		if(fieldName.equals("CLINICNAME"))
			return getClinicName();
		if(fieldName.equals("CLINIC"))
			return getClinic();
		if(fieldName.equals("SOURCE"))
			return getSource();
		if(fieldName.equals("APPTTYPE"))
			return getApptType();
		if(fieldName.equals("PATIENT"))
			return getPatient();
		if(fieldName.equals("STATUS"))
			return getStatus();
		if(fieldName.equals("STATUSDATE"))
			return getStatusDate();
		if(fieldName.equals("BOOKEDBY"))
			return getBookedBy();
		if(fieldName.equals("BOOKEDDATE"))
			return getBookedDate();
		if(fieldName.equals("PKEY"))
			return getPkey();
		if(fieldName.equals("APPOINTHEADERID"))
			return getAppointHeaderId();
		if(fieldName.equals("ACTIVE"))
			return getActive();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getAppointmentIdIsNotNull()
	{
		return this.appointmentid != null;
	}
	public Integer getAppointmentId()
	{
		return this.appointmentid;
	}
	public void setAppointmentId(Integer value)
	{
		this.isValidated = false;
		this.appointmentid = value;
	}
	public boolean getPasEventIsNotNull()
	{
		return this.pasevent != null;
	}
	public ims.core.vo.PasEventADTVo getPasEvent()
	{
		return this.pasevent;
	}
	public void setPasEvent(ims.core.vo.PasEventADTVo value)
	{
		this.isValidated = false;
		this.pasevent = value;
	}
	public boolean getApptDateIsNotNull()
	{
		return this.apptdate != null;
	}
	public ims.framework.utils.Date getApptDate()
	{
		return this.apptdate;
	}
	public void setApptDate(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.apptdate = value;
	}
	public boolean getStartTimeIsNotNull()
	{
		return this.starttime != null;
	}
	public ims.framework.utils.Time getStartTime()
	{
		return this.starttime;
	}
	public void setStartTime(ims.framework.utils.Time value)
	{
		this.isValidated = false;
		this.starttime = value;
	}
	public boolean getEndTimeIsNotNull()
	{
		return this.endtime != null;
	}
	public ims.framework.utils.Time getEndTime()
	{
		return this.endtime;
	}
	public void setEndTime(ims.framework.utils.Time value)
	{
		this.isValidated = false;
		this.endtime = value;
	}
	public boolean getClinicNameIsNotNull()
	{
		return this.clinicname != null;
	}
	public String getClinicName()
	{
		return this.clinicname;
	}
	public static int getClinicNameMaxLength()
	{
		return 50;
	}
	public void setClinicName(String value)
	{
		this.isValidated = false;
		this.clinicname = value;
	}
	public boolean getClinicIsNotNull()
	{
		return this.clinic != null;
	}
	public ims.core.resource.place.vo.ClinicRefVo getClinic()
	{
		return this.clinic;
	}
	public void setClinic(ims.core.resource.place.vo.ClinicRefVo value)
	{
		this.isValidated = false;
		this.clinic = value;
	}
	public boolean getSourceIsNotNull()
	{
		return this.source != null;
	}
	public String getSource()
	{
		return this.source;
	}
	public static int getSourceMaxLength()
	{
		return 50;
	}
	public void setSource(String value)
	{
		this.isValidated = false;
		this.source = value;
	}
	public boolean getApptTypeIsNotNull()
	{
		return this.appttype != null;
	}
	public String getApptType()
	{
		return this.appttype;
	}
	public static int getApptTypeMaxLength()
	{
		return 50;
	}
	public void setApptType(String value)
	{
		this.isValidated = false;
		this.appttype = 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 getStatusIsNotNull()
	{
		return this.status != null;
	}
	public String getStatus()
	{
		return this.status;
	}
	public static int getStatusMaxLength()
	{
		return 30;
	}
	public void setStatus(String value)
	{
		this.isValidated = false;
		this.status = value;
	}
	public boolean getStatusDateIsNotNull()
	{
		return this.statusdate != null;
	}
	public ims.framework.utils.DateTime getStatusDate()
	{
		return this.statusdate;
	}
	public void setStatusDate(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.statusdate = value;
	}
	public boolean getBookedByIsNotNull()
	{
		return this.bookedby != null;
	}
	public String getBookedBy()
	{
		return this.bookedby;
	}
	public static int getBookedByMaxLength()
	{
		return 50;
	}
	public void setBookedBy(String value)
	{
		this.isValidated = false;
		this.bookedby = value;
	}
	public boolean getBookedDateIsNotNull()
	{
		return this.bookeddate != null;
	}
	public ims.framework.utils.DateTime getBookedDate()
	{
		return this.bookeddate;
	}
	public void setBookedDate(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.bookeddate = value;
	}
	public boolean getPkeyIsNotNull()
	{
		return this.pkey != null;
	}
	public Integer getPkey()
	{
		return this.pkey;
	}
	public void setPkey(Integer value)
	{
		this.isValidated = false;
		this.pkey = value;
	}
	public boolean getAppointHeaderIdIsNotNull()
	{
		return this.appointheaderid != null;
	}
	public Integer getAppointHeaderId()
	{
		return this.appointheaderid;
	}
	public void setAppointHeaderId(Integer value)
	{
		this.isValidated = false;
		this.appointheaderid = value;
	}
	public boolean getActiveIsNotNull()
	{
		return this.active != null;
	}
	public Boolean getActive()
	{
		return this.active;
	}
	public void setActive(Boolean value)
	{
		this.isValidated = false;
		this.active = 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.apptdate == null)
			listOfErrors.add("ApptDate is mandatory");
		if(this.clinicname != null)
			if(this.clinicname.length() > 50)
				listOfErrors.add("The length of the field [clinicname] in the value object [ims.core.vo.PatientApptDiaryVo] is too big. It should be less or equal to 50");
		if(this.source != null)
			if(this.source.length() > 50)
				listOfErrors.add("The length of the field [source] in the value object [ims.core.vo.PatientApptDiaryVo] is too big. It should be less or equal to 50");
		if(this.appttype != null)
			if(this.appttype.length() > 50)
				listOfErrors.add("The length of the field [appttype] in the value object [ims.core.vo.PatientApptDiaryVo] is too big. It should be less or equal to 50");
		if(this.patient == null)
			listOfErrors.add("Patient is mandatory");
		if(this.status != null)
			if(this.status.length() > 30)
				listOfErrors.add("The length of the field [status] in the value object [ims.core.vo.PatientApptDiaryVo] is too big. It should be less or equal to 30");
		if(this.bookedby != null)
			if(this.bookedby.length() > 50)
				listOfErrors.add("The length of the field [bookedby] in the value object [ims.core.vo.PatientApptDiaryVo] is too big. It should be less or equal to 50");
		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;
	
		PatientApptDiaryVo clone = new PatientApptDiaryVo(this.id, this.version);
		
		clone.appointmentid = this.appointmentid;
		if(this.pasevent == null)
			clone.pasevent = null;
		else
			clone.pasevent = (ims.core.vo.PasEventADTVo)this.pasevent.clone();
		if(this.apptdate == null)
			clone.apptdate = null;
		else
			clone.apptdate = (ims.framework.utils.Date)this.apptdate.clone();
		if(this.starttime == null)
			clone.starttime = null;
		else
			clone.starttime = (ims.framework.utils.Time)this.starttime.clone();
		if(this.endtime == null)
			clone.endtime = null;
		else
			clone.endtime = (ims.framework.utils.Time)this.endtime.clone();
		clone.clinicname = this.clinicname;
		clone.clinic = this.clinic;
		clone.source = this.source;
		clone.appttype = this.appttype;
		clone.patient = this.patient;
		clone.status = this.status;
		if(this.statusdate == null)
			clone.statusdate = null;
		else
			clone.statusdate = (ims.framework.utils.DateTime)this.statusdate.clone();
		clone.bookedby = this.bookedby;
		if(this.bookeddate == null)
			clone.bookeddate = null;
		else
			clone.bookeddate = (ims.framework.utils.DateTime)this.bookeddate.clone();
		clone.pkey = this.pkey;
		clone.appointheaderid = this.appointheaderid;
		clone.active = this.active;
		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 (!(PatientApptDiaryVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A PatientApptDiaryVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((PatientApptDiaryVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((PatientApptDiaryVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.appointmentid != null)
			count++;
		if(this.pasevent != null)
			count++;
		if(this.apptdate != null)
			count++;
		if(this.starttime != null)
			count++;
		if(this.endtime != null)
			count++;
		if(this.clinicname != null)
			count++;
		if(this.clinic != null)
			count++;
		if(this.source != null)
			count++;
		if(this.appttype != null)
			count++;
		if(this.patient != null)
			count++;
		if(this.status != null)
			count++;
		if(this.statusdate != null)
			count++;
		if(this.bookedby != null)
			count++;
		if(this.bookeddate != null)
			count++;
		if(this.pkey != null)
			count++;
		if(this.appointheaderid != null)
			count++;
		if(this.active != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 17;
	}
	protected Integer appointmentid;
	protected ims.core.vo.PasEventADTVo pasevent;
	protected ims.framework.utils.Date apptdate;
	protected ims.framework.utils.Time starttime;
	protected ims.framework.utils.Time endtime;
	protected String clinicname;
	protected ims.core.resource.place.vo.ClinicRefVo clinic;
	protected String source;
	protected String appttype;
	protected ims.core.patient.vo.PatientRefVo patient;
	protected String status;
	protected ims.framework.utils.DateTime statusdate;
	protected String bookedby;
	protected ims.framework.utils.DateTime bookeddate;
	protected Integer pkey;
	protected Integer appointheaderid;
	protected Boolean active;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
