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

/**
 * Linked to core.admin.EmergencyAttendance business object (ID: 1004100025).
 */
public class EmergencyAttendanceForQuickRegistrationVo extends ims.core.admin.vo.EmergencyAttendanceRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public EmergencyAttendanceForQuickRegistrationVo()
	{
	}
	public EmergencyAttendanceForQuickRegistrationVo(Integer id, int version)
	{
		super(id, version);
	}
	public EmergencyAttendanceForQuickRegistrationVo(ims.emergency.vo.beans.EmergencyAttendanceForQuickRegistrationVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.arrivaldatetime = bean.getArrivalDateTime() == null ? null : bean.getArrivalDateTime().buildDateTime();
		this.registrationdatetime = bean.getRegistrationDateTime() == null ? null : bean.getRegistrationDateTime().buildDateTime();
		this.attendancetype = bean.getAttendanceType() == null ? null : ims.emergency.vo.lookups.AttendanceType.buildLookup(bean.getAttendanceType());
		this.registrationlocation = bean.getRegistrationLocation() == null ? null : bean.getRegistrationLocation().buildVo();
		this.carecontext = bean.getCareContext() == null ? null : new ims.core.admin.vo.CareContextRefVo(new Integer(bean.getCareContext().getId()), bean.getCareContext().getVersion());
		this.emergencyepisode = bean.getEmergencyEpisode() == null ? null : new ims.core.admin.vo.EmergencyEpisodeRefVo(new Integer(bean.getEmergencyEpisode().getId()), bean.getEmergencyEpisode().getVersion());
		this.isunknownpatient = bean.getIsUnknownPatient();
		this.patient = bean.getPatient() == null ? null : new ims.core.patient.vo.PatientRefVo(new Integer(bean.getPatient().getId()), bean.getPatient().getVersion());
		this.episode = bean.getEpisode() == null ? null : new ims.core.admin.vo.EmergencyEpisodeRefVo(new Integer(bean.getEpisode().getId()), bean.getEpisode().getVersion());
		this.isquickregistration = bean.getIsQuickRegistration();
		this.isexpectedarrival = bean.getIsExpectedArrival();
		this.ismajorincident = bean.getIsMajorIncident();
		this.expectedarrivaldatetime = bean.getExpectedArrivalDateTime() == null ? null : bean.getExpectedArrivalDateTime().buildDateTime();
		this.ageatattendance = bean.getAgeAtAttendance();
		this.registeringmos = bean.getRegisteringMOS() == null ? null : new ims.core.resource.people.vo.MemberOfStaffRefVo(new Integer(bean.getRegisteringMOS().getId()), bean.getRegisteringMOS().getVersion());
		this.comments = bean.getComments();
		this.customid = bean.getCustomID();
		this.endofregistrationdatetime = bean.getEndOfRegistrationDateTime() == null ? null : bean.getEndOfRegistrationDateTime().buildDateTime();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.emergency.vo.beans.EmergencyAttendanceForQuickRegistrationVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.arrivaldatetime = bean.getArrivalDateTime() == null ? null : bean.getArrivalDateTime().buildDateTime();
		this.registrationdatetime = bean.getRegistrationDateTime() == null ? null : bean.getRegistrationDateTime().buildDateTime();
		this.attendancetype = bean.getAttendanceType() == null ? null : ims.emergency.vo.lookups.AttendanceType.buildLookup(bean.getAttendanceType());
		this.registrationlocation = bean.getRegistrationLocation() == null ? null : bean.getRegistrationLocation().buildVo(map);
		this.carecontext = bean.getCareContext() == null ? null : new ims.core.admin.vo.CareContextRefVo(new Integer(bean.getCareContext().getId()), bean.getCareContext().getVersion());
		this.emergencyepisode = bean.getEmergencyEpisode() == null ? null : new ims.core.admin.vo.EmergencyEpisodeRefVo(new Integer(bean.getEmergencyEpisode().getId()), bean.getEmergencyEpisode().getVersion());
		this.isunknownpatient = bean.getIsUnknownPatient();
		this.patient = bean.getPatient() == null ? null : new ims.core.patient.vo.PatientRefVo(new Integer(bean.getPatient().getId()), bean.getPatient().getVersion());
		this.episode = bean.getEpisode() == null ? null : new ims.core.admin.vo.EmergencyEpisodeRefVo(new Integer(bean.getEpisode().getId()), bean.getEpisode().getVersion());
		this.isquickregistration = bean.getIsQuickRegistration();
		this.isexpectedarrival = bean.getIsExpectedArrival();
		this.ismajorincident = bean.getIsMajorIncident();
		this.expectedarrivaldatetime = bean.getExpectedArrivalDateTime() == null ? null : bean.getExpectedArrivalDateTime().buildDateTime();
		this.ageatattendance = bean.getAgeAtAttendance();
		this.registeringmos = bean.getRegisteringMOS() == null ? null : new ims.core.resource.people.vo.MemberOfStaffRefVo(new Integer(bean.getRegisteringMOS().getId()), bean.getRegisteringMOS().getVersion());
		this.comments = bean.getComments();
		this.customid = bean.getCustomID();
		this.endofregistrationdatetime = bean.getEndOfRegistrationDateTime() == null ? null : bean.getEndOfRegistrationDateTime().buildDateTime();
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.emergency.vo.beans.EmergencyAttendanceForQuickRegistrationVoBean bean = null;
		if(map != null)
			bean = (ims.emergency.vo.beans.EmergencyAttendanceForQuickRegistrationVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.emergency.vo.beans.EmergencyAttendanceForQuickRegistrationVoBean();
			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("ARRIVALDATETIME"))
			return getArrivalDateTime();
		if(fieldName.equals("REGISTRATIONDATETIME"))
			return getRegistrationDateTime();
		if(fieldName.equals("ATTENDANCETYPE"))
			return getAttendanceType();
		if(fieldName.equals("REGISTRATIONLOCATION"))
			return getRegistrationLocation();
		if(fieldName.equals("CARECONTEXT"))
			return getCareContext();
		if(fieldName.equals("EMERGENCYEPISODE"))
			return getEmergencyEpisode();
		if(fieldName.equals("ISUNKNOWNPATIENT"))
			return getIsUnknownPatient();
		if(fieldName.equals("PATIENT"))
			return getPatient();
		if(fieldName.equals("EPISODE"))
			return getEpisode();
		if(fieldName.equals("ISQUICKREGISTRATION"))
			return getIsQuickRegistration();
		if(fieldName.equals("ISEXPECTEDARRIVAL"))
			return getIsExpectedArrival();
		if(fieldName.equals("ISMAJORINCIDENT"))
			return getIsMajorIncident();
		if(fieldName.equals("EXPECTEDARRIVALDATETIME"))
			return getExpectedArrivalDateTime();
		if(fieldName.equals("AGEATATTENDANCE"))
			return getAgeAtAttendance();
		if(fieldName.equals("REGISTERINGMOS"))
			return getRegisteringMOS();
		if(fieldName.equals("COMMENTS"))
			return getComments();
		if(fieldName.equals("CUSTOMID"))
			return getCustomID();
		if(fieldName.equals("ENDOFREGISTRATIONDATETIME"))
			return getEndOfRegistrationDateTime();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getArrivalDateTimeIsNotNull()
	{
		return this.arrivaldatetime != null;
	}
	public ims.framework.utils.DateTime getArrivalDateTime()
	{
		return this.arrivaldatetime;
	}
	public void setArrivalDateTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.arrivaldatetime = value;
	}
	public boolean getRegistrationDateTimeIsNotNull()
	{
		return this.registrationdatetime != null;
	}
	public ims.framework.utils.DateTime getRegistrationDateTime()
	{
		return this.registrationdatetime;
	}
	public void setRegistrationDateTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.registrationdatetime = value;
	}
	public boolean getAttendanceTypeIsNotNull()
	{
		return this.attendancetype != null;
	}
	public ims.emergency.vo.lookups.AttendanceType getAttendanceType()
	{
		return this.attendancetype;
	}
	public void setAttendanceType(ims.emergency.vo.lookups.AttendanceType value)
	{
		this.isValidated = false;
		this.attendancetype = value;
	}
	public boolean getRegistrationLocationIsNotNull()
	{
		return this.registrationlocation != null;
	}
	public ims.core.vo.LocationLiteVo getRegistrationLocation()
	{
		return this.registrationlocation;
	}
	public void setRegistrationLocation(ims.core.vo.LocationLiteVo value)
	{
		this.isValidated = false;
		this.registrationlocation = value;
	}
	public boolean getCareContextIsNotNull()
	{
		return this.carecontext != null;
	}
	public ims.core.admin.vo.CareContextRefVo getCareContext()
	{
		return this.carecontext;
	}
	public void setCareContext(ims.core.admin.vo.CareContextRefVo value)
	{
		this.isValidated = false;
		this.carecontext = value;
	}
	public boolean getEmergencyEpisodeIsNotNull()
	{
		return this.emergencyepisode != null;
	}
	public ims.core.admin.vo.EmergencyEpisodeRefVo getEmergencyEpisode()
	{
		return this.emergencyepisode;
	}
	public void setEmergencyEpisode(ims.core.admin.vo.EmergencyEpisodeRefVo value)
	{
		this.isValidated = false;
		this.emergencyepisode = value;
	}
	public boolean getIsUnknownPatientIsNotNull()
	{
		return this.isunknownpatient != null;
	}
	public Boolean getIsUnknownPatient()
	{
		return this.isunknownpatient;
	}
	public void setIsUnknownPatient(Boolean value)
	{
		this.isValidated = false;
		this.isunknownpatient = 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 getEpisodeIsNotNull()
	{
		return this.episode != null;
	}
	public ims.core.admin.vo.EmergencyEpisodeRefVo getEpisode()
	{
		return this.episode;
	}
	public void setEpisode(ims.core.admin.vo.EmergencyEpisodeRefVo value)
	{
		this.isValidated = false;
		this.episode = value;
	}
	public boolean getIsQuickRegistrationIsNotNull()
	{
		return this.isquickregistration != null;
	}
	public Boolean getIsQuickRegistration()
	{
		return this.isquickregistration;
	}
	public void setIsQuickRegistration(Boolean value)
	{
		this.isValidated = false;
		this.isquickregistration = value;
	}
	public boolean getIsExpectedArrivalIsNotNull()
	{
		return this.isexpectedarrival != null;
	}
	public Boolean getIsExpectedArrival()
	{
		return this.isexpectedarrival;
	}
	public void setIsExpectedArrival(Boolean value)
	{
		this.isValidated = false;
		this.isexpectedarrival = value;
	}
	public boolean getIsMajorIncidentIsNotNull()
	{
		return this.ismajorincident != null;
	}
	public Boolean getIsMajorIncident()
	{
		return this.ismajorincident;
	}
	public void setIsMajorIncident(Boolean value)
	{
		this.isValidated = false;
		this.ismajorincident = value;
	}
	public boolean getExpectedArrivalDateTimeIsNotNull()
	{
		return this.expectedarrivaldatetime != null;
	}
	public ims.framework.utils.DateTime getExpectedArrivalDateTime()
	{
		return this.expectedarrivaldatetime;
	}
	public void setExpectedArrivalDateTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.expectedarrivaldatetime = value;
	}
	public boolean getAgeAtAttendanceIsNotNull()
	{
		return this.ageatattendance != null;
	}
	public Integer getAgeAtAttendance()
	{
		return this.ageatattendance;
	}
	public void setAgeAtAttendance(Integer value)
	{
		this.isValidated = false;
		this.ageatattendance = value;
	}
	public boolean getRegisteringMOSIsNotNull()
	{
		return this.registeringmos != null;
	}
	public ims.core.resource.people.vo.MemberOfStaffRefVo getRegisteringMOS()
	{
		return this.registeringmos;
	}
	public void setRegisteringMOS(ims.core.resource.people.vo.MemberOfStaffRefVo value)
	{
		this.isValidated = false;
		this.registeringmos = value;
	}
	public boolean getCommentsIsNotNull()
	{
		return this.comments != null;
	}
	public String getComments()
	{
		return this.comments;
	}
	public static int getCommentsMaxLength()
	{
		return 500;
	}
	public void setComments(String value)
	{
		this.isValidated = false;
		this.comments = value;
	}
	public boolean getCustomIDIsNotNull()
	{
		return this.customid != null;
	}
	public String getCustomID()
	{
		return this.customid;
	}
	public static int getCustomIDMaxLength()
	{
		return 20;
	}
	public void setCustomID(String value)
	{
		this.isValidated = false;
		this.customid = value;
	}
	public boolean getEndOfRegistrationDateTimeIsNotNull()
	{
		return this.endofregistrationdatetime != null;
	}
	public ims.framework.utils.DateTime getEndOfRegistrationDateTime()
	{
		return this.endofregistrationdatetime;
	}
	public void setEndOfRegistrationDateTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.endofregistrationdatetime = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.registrationlocation != null)
		{
			if(!this.registrationlocation.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.arrivaldatetime == null)
			listOfErrors.add("ArrivalDateTime is mandatory");
		if(this.registrationdatetime == null)
			listOfErrors.add("RegistrationDateTime is mandatory");
		if(this.registrationlocation != null)
		{
			String[] listOfOtherErrors = this.registrationlocation.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.carecontext == null)
			listOfErrors.add("CareContext is mandatory");
		if(this.emergencyepisode == null)
			listOfErrors.add("EmergencyEpisode is mandatory");
		if(this.patient == null)
			listOfErrors.add("Patient is mandatory");
		if(this.episode == null)
			listOfErrors.add("Episode is mandatory");
		if(this.registeringmos == null)
			listOfErrors.add("RegisteringMOS is mandatory");
		if(this.comments != null)
			if(this.comments.length() > 500)
				listOfErrors.add("The length of the field [comments] in the value object [ims.emergency.vo.EmergencyAttendanceForQuickRegistrationVo] is too big. It should be less or equal to 500");
		if(this.customid != null)
			if(this.customid.length() > 20)
				listOfErrors.add("The length of the field [customid] in the value object [ims.emergency.vo.EmergencyAttendanceForQuickRegistrationVo] is too big. It should be less or equal to 20");
		if(this.endofregistrationdatetime == null)
			listOfErrors.add("Registration End Time is mandatory");
		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;
	
		EmergencyAttendanceForQuickRegistrationVo clone = new EmergencyAttendanceForQuickRegistrationVo(this.id, this.version);
		
		if(this.arrivaldatetime == null)
			clone.arrivaldatetime = null;
		else
			clone.arrivaldatetime = (ims.framework.utils.DateTime)this.arrivaldatetime.clone();
		if(this.registrationdatetime == null)
			clone.registrationdatetime = null;
		else
			clone.registrationdatetime = (ims.framework.utils.DateTime)this.registrationdatetime.clone();
		if(this.attendancetype == null)
			clone.attendancetype = null;
		else
			clone.attendancetype = (ims.emergency.vo.lookups.AttendanceType)this.attendancetype.clone();
		if(this.registrationlocation == null)
			clone.registrationlocation = null;
		else
			clone.registrationlocation = (ims.core.vo.LocationLiteVo)this.registrationlocation.clone();
		clone.carecontext = this.carecontext;
		clone.emergencyepisode = this.emergencyepisode;
		clone.isunknownpatient = this.isunknownpatient;
		clone.patient = this.patient;
		clone.episode = this.episode;
		clone.isquickregistration = this.isquickregistration;
		clone.isexpectedarrival = this.isexpectedarrival;
		clone.ismajorincident = this.ismajorincident;
		if(this.expectedarrivaldatetime == null)
			clone.expectedarrivaldatetime = null;
		else
			clone.expectedarrivaldatetime = (ims.framework.utils.DateTime)this.expectedarrivaldatetime.clone();
		clone.ageatattendance = this.ageatattendance;
		clone.registeringmos = this.registeringmos;
		clone.comments = this.comments;
		clone.customid = this.customid;
		if(this.endofregistrationdatetime == null)
			clone.endofregistrationdatetime = null;
		else
			clone.endofregistrationdatetime = (ims.framework.utils.DateTime)this.endofregistrationdatetime.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 (!(EmergencyAttendanceForQuickRegistrationVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A EmergencyAttendanceForQuickRegistrationVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((EmergencyAttendanceForQuickRegistrationVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((EmergencyAttendanceForQuickRegistrationVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.arrivaldatetime != null)
			count++;
		if(this.registrationdatetime != null)
			count++;
		if(this.attendancetype != null)
			count++;
		if(this.registrationlocation != null)
			count++;
		if(this.carecontext != null)
			count++;
		if(this.emergencyepisode != null)
			count++;
		if(this.isunknownpatient != null)
			count++;
		if(this.patient != null)
			count++;
		if(this.episode != null)
			count++;
		if(this.isquickregistration != null)
			count++;
		if(this.isexpectedarrival != null)
			count++;
		if(this.ismajorincident != null)
			count++;
		if(this.expectedarrivaldatetime != null)
			count++;
		if(this.ageatattendance != null)
			count++;
		if(this.registeringmos != null)
			count++;
		if(this.comments != null)
			count++;
		if(this.customid != null)
			count++;
		if(this.endofregistrationdatetime != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 18;
	}
	protected ims.framework.utils.DateTime arrivaldatetime;
	protected ims.framework.utils.DateTime registrationdatetime;
	protected ims.emergency.vo.lookups.AttendanceType attendancetype;
	protected ims.core.vo.LocationLiteVo registrationlocation;
	protected ims.core.admin.vo.CareContextRefVo carecontext;
	protected ims.core.admin.vo.EmergencyEpisodeRefVo emergencyepisode;
	protected Boolean isunknownpatient;
	protected ims.core.patient.vo.PatientRefVo patient;
	protected ims.core.admin.vo.EmergencyEpisodeRefVo episode;
	protected Boolean isquickregistration;
	protected Boolean isexpectedarrival;
	protected Boolean ismajorincident;
	protected ims.framework.utils.DateTime expectedarrivaldatetime;
	protected Integer ageatattendance;
	protected ims.core.resource.people.vo.MemberOfStaffRefVo registeringmos;
	protected String comments;
	protected String customid;
	protected ims.framework.utils.DateTime endofregistrationdatetime;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
