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

	public ReferralToSpecialtyTeamVo()
	{
	}
	public ReferralToSpecialtyTeamVo(Integer id, int version)
	{
		super(id, version);
	}
	public ReferralToSpecialtyTeamVo(ims.emergency.vo.beans.ReferralToSpecialtyTeamVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.patient = bean.getPatient() == null ? null : bean.getPatient().buildVo();
		this.episode = bean.getEpisode() == null ? null : new ims.core.admin.vo.EpisodeOfCareRefVo(new Integer(bean.getEpisode().getId()), bean.getEpisode().getVersion());
		this.attendance = bean.getAttendance() == null ? null : new ims.core.admin.vo.CareContextRefVo(new Integer(bean.getAttendance().getId()), bean.getAttendance().getVersion());
		this.trackingarea = bean.getTrackingArea() == null ? null : new ims.emergency.configuration.vo.TrackingAreaRefVo(new Integer(bean.getTrackingArea().getId()), bean.getTrackingArea().getVersion());
		this.teamconsultant = bean.getTeamConsultant() == null ? null : ims.emergency.vo.lookups.ReferralSpecialtyConsultantOrTeam.buildLookup(bean.getTeamConsultant());
		this.specialty = bean.getSpecialty() == null ? null : ims.core.vo.lookups.Specialty.buildLookup(bean.getSpecialty());
		this.referreddatetime = bean.getReferredDateTime() == null ? null : bean.getReferredDateTime().buildDateTime();
		this.seendatetime = bean.getSeenDateTime() == null ? null : bean.getSeenDateTime().buildDateTime();
		this.completiondatetime = bean.getCompletionDateTime() == null ? null : bean.getCompletionDateTime().buildDateTime();
		this.referredby = bean.getReferredBy() == null ? null : bean.getReferredBy().buildVo();
		this.comments = ims.emergency.vo.AttendanceClinicalNotesVoCollection.buildFromBeanCollection(bean.getComments());
		this.systeminformation = bean.getSystemInformation() == null ? null : bean.getSystemInformation().buildSystemInformation();
		this.notaccepted = bean.getNotAccepted();
		this.issafeguardingconcern = bean.getIsSafeguardingConcern();
		this.safeguardingcomments = bean.getSafeguardingComments();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.emergency.vo.beans.ReferralToSpecialtyTeamVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.patient = bean.getPatient() == null ? null : bean.getPatient().buildVo(map);
		this.episode = bean.getEpisode() == null ? null : new ims.core.admin.vo.EpisodeOfCareRefVo(new Integer(bean.getEpisode().getId()), bean.getEpisode().getVersion());
		this.attendance = bean.getAttendance() == null ? null : new ims.core.admin.vo.CareContextRefVo(new Integer(bean.getAttendance().getId()), bean.getAttendance().getVersion());
		this.trackingarea = bean.getTrackingArea() == null ? null : new ims.emergency.configuration.vo.TrackingAreaRefVo(new Integer(bean.getTrackingArea().getId()), bean.getTrackingArea().getVersion());
		this.teamconsultant = bean.getTeamConsultant() == null ? null : ims.emergency.vo.lookups.ReferralSpecialtyConsultantOrTeam.buildLookup(bean.getTeamConsultant());
		this.specialty = bean.getSpecialty() == null ? null : ims.core.vo.lookups.Specialty.buildLookup(bean.getSpecialty());
		this.referreddatetime = bean.getReferredDateTime() == null ? null : bean.getReferredDateTime().buildDateTime();
		this.seendatetime = bean.getSeenDateTime() == null ? null : bean.getSeenDateTime().buildDateTime();
		this.completiondatetime = bean.getCompletionDateTime() == null ? null : bean.getCompletionDateTime().buildDateTime();
		this.referredby = bean.getReferredBy() == null ? null : bean.getReferredBy().buildVo(map);
		this.comments = ims.emergency.vo.AttendanceClinicalNotesVoCollection.buildFromBeanCollection(bean.getComments());
		this.systeminformation = bean.getSystemInformation() == null ? null : bean.getSystemInformation().buildSystemInformation();
		this.notaccepted = bean.getNotAccepted();
		this.issafeguardingconcern = bean.getIsSafeguardingConcern();
		this.safeguardingcomments = bean.getSafeguardingComments();
	}
	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.ReferralToSpecialtyTeamVoBean bean = null;
		if(map != null)
			bean = (ims.emergency.vo.beans.ReferralToSpecialtyTeamVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.emergency.vo.beans.ReferralToSpecialtyTeamVoBean();
			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("PATIENT"))
			return getPatient();
		if(fieldName.equals("EPISODE"))
			return getEpisode();
		if(fieldName.equals("ATTENDANCE"))
			return getAttendance();
		if(fieldName.equals("TRACKINGAREA"))
			return getTrackingArea();
		if(fieldName.equals("TEAMCONSULTANT"))
			return getTeamConsultant();
		if(fieldName.equals("SPECIALTY"))
			return getSpecialty();
		if(fieldName.equals("REFERREDDATETIME"))
			return getReferredDateTime();
		if(fieldName.equals("SEENDATETIME"))
			return getSeenDateTime();
		if(fieldName.equals("COMPLETIONDATETIME"))
			return getCompletionDateTime();
		if(fieldName.equals("REFERREDBY"))
			return getReferredBy();
		if(fieldName.equals("COMMENTS"))
			return getComments();
		if(fieldName.equals("SYSTEMINFORMATION"))
			return getSystemInformation();
		if(fieldName.equals("NOTACCEPTED"))
			return getNotAccepted();
		if(fieldName.equals("ISSAFEGUARDINGCONCERN"))
			return getIsSafeguardingConcern();
		if(fieldName.equals("SAFEGUARDINGCOMMENTS"))
			return getSafeguardingComments();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getPatientIsNotNull()
	{
		return this.patient != null;
	}
	public ims.core.vo.PatientShortListVo getPatient()
	{
		return this.patient;
	}
	public void setPatient(ims.core.vo.PatientShortListVo value)
	{
		this.isValidated = false;
		this.patient = value;
	}
	public boolean getEpisodeIsNotNull()
	{
		return this.episode != null;
	}
	public ims.core.admin.vo.EpisodeOfCareRefVo getEpisode()
	{
		return this.episode;
	}
	public void setEpisode(ims.core.admin.vo.EpisodeOfCareRefVo value)
	{
		this.isValidated = false;
		this.episode = value;
	}
	public boolean getAttendanceIsNotNull()
	{
		return this.attendance != null;
	}
	public ims.core.admin.vo.CareContextRefVo getAttendance()
	{
		return this.attendance;
	}
	public void setAttendance(ims.core.admin.vo.CareContextRefVo value)
	{
		this.isValidated = false;
		this.attendance = value;
	}
	public boolean getTrackingAreaIsNotNull()
	{
		return this.trackingarea != null;
	}
	public ims.emergency.configuration.vo.TrackingAreaRefVo getTrackingArea()
	{
		return this.trackingarea;
	}
	public void setTrackingArea(ims.emergency.configuration.vo.TrackingAreaRefVo value)
	{
		this.isValidated = false;
		this.trackingarea = value;
	}
	public boolean getTeamConsultantIsNotNull()
	{
		return this.teamconsultant != null;
	}
	public ims.emergency.vo.lookups.ReferralSpecialtyConsultantOrTeam getTeamConsultant()
	{
		return this.teamconsultant;
	}
	public void setTeamConsultant(ims.emergency.vo.lookups.ReferralSpecialtyConsultantOrTeam value)
	{
		this.isValidated = false;
		this.teamconsultant = value;
	}
	public boolean getSpecialtyIsNotNull()
	{
		return this.specialty != null;
	}
	public ims.core.vo.lookups.Specialty getSpecialty()
	{
		return this.specialty;
	}
	public void setSpecialty(ims.core.vo.lookups.Specialty value)
	{
		this.isValidated = false;
		this.specialty = value;
	}
	public boolean getReferredDateTimeIsNotNull()
	{
		return this.referreddatetime != null;
	}
	public ims.framework.utils.DateTime getReferredDateTime()
	{
		return this.referreddatetime;
	}
	public void setReferredDateTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.referreddatetime = value;
	}
	public boolean getSeenDateTimeIsNotNull()
	{
		return this.seendatetime != null;
	}
	public ims.framework.utils.DateTime getSeenDateTime()
	{
		return this.seendatetime;
	}
	public void setSeenDateTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.seendatetime = value;
	}
	public boolean getCompletionDateTimeIsNotNull()
	{
		return this.completiondatetime != null;
	}
	public ims.framework.utils.DateTime getCompletionDateTime()
	{
		return this.completiondatetime;
	}
	public void setCompletionDateTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.completiondatetime = value;
	}
	public boolean getReferredByIsNotNull()
	{
		return this.referredby != null;
	}
	public ims.core.vo.HcpLiteVo getReferredBy()
	{
		return this.referredby;
	}
	public void setReferredBy(ims.core.vo.HcpLiteVo value)
	{
		this.isValidated = false;
		this.referredby = value;
	}
	public boolean getCommentsIsNotNull()
	{
		return this.comments != null;
	}
	public ims.emergency.vo.AttendanceClinicalNotesVoCollection getComments()
	{
		return this.comments;
	}
	public void setComments(ims.emergency.vo.AttendanceClinicalNotesVoCollection value)
	{
		this.isValidated = false;
		this.comments = value;
	}
	public boolean getSystemInformationIsNotNull()
	{
		return this.systeminformation != null;
	}
	public ims.vo.SystemInformation getSystemInformation()
	{
		return this.systeminformation;
	}
	public void setSystemInformation(ims.vo.SystemInformation value)
	{
		this.isValidated = false;
		this.systeminformation = value;
	}
	public boolean getNotAcceptedIsNotNull()
	{
		return this.notaccepted != null;
	}
	public Boolean getNotAccepted()
	{
		return this.notaccepted;
	}
	public void setNotAccepted(Boolean value)
	{
		this.isValidated = false;
		this.notaccepted = value;
	}
	public boolean getIsSafeguardingConcernIsNotNull()
	{
		return this.issafeguardingconcern != null;
	}
	public Boolean getIsSafeguardingConcern()
	{
		return this.issafeguardingconcern;
	}
	public void setIsSafeguardingConcern(Boolean value)
	{
		this.isValidated = false;
		this.issafeguardingconcern = value;
	}
	public boolean getSafeguardingCommentsIsNotNull()
	{
		return this.safeguardingcomments != null;
	}
	public String getSafeguardingComments()
	{
		return this.safeguardingcomments;
	}
	public static int getSafeguardingCommentsMaxLength()
	{
		return 500;
	}
	public void setSafeguardingComments(String value)
	{
		this.isValidated = false;
		this.safeguardingcomments = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.comments != null)
		{
			if(!this.comments.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.patient == null)
			listOfErrors.add("Patient is mandatory");
		if(this.episode == null)
			listOfErrors.add("Episode is mandatory");
		if(this.attendance == null)
			listOfErrors.add("Attendance is mandatory");
		if(this.trackingarea == null)
			listOfErrors.add("TrackingArea is mandatory");
		if(this.specialty == null)
			listOfErrors.add("Specialty is mandatory");
		if(this.referreddatetime == null)
			listOfErrors.add("Referred Date/Time is mandatory .");
		if(this.referredby == null)
			listOfErrors.add("Referred By is mandatory.");
		if(this.comments != null)
		{
			String[] listOfOtherErrors = this.comments.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.safeguardingcomments != null)
			if(this.safeguardingcomments.length() > 500)
				listOfErrors.add("The length of the field [safeguardingcomments] in the value object [ims.emergency.vo.ReferralToSpecialtyTeamVo] is too big. It should be less or equal to 500");
		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;
	
		ReferralToSpecialtyTeamVo clone = new ReferralToSpecialtyTeamVo(this.id, this.version);
		
		if(this.patient == null)
			clone.patient = null;
		else
			clone.patient = (ims.core.vo.PatientShortListVo)this.patient.clone();
		clone.episode = this.episode;
		clone.attendance = this.attendance;
		clone.trackingarea = this.trackingarea;
		if(this.teamconsultant == null)
			clone.teamconsultant = null;
		else
			clone.teamconsultant = (ims.emergency.vo.lookups.ReferralSpecialtyConsultantOrTeam)this.teamconsultant.clone();
		if(this.specialty == null)
			clone.specialty = null;
		else
			clone.specialty = (ims.core.vo.lookups.Specialty)this.specialty.clone();
		if(this.referreddatetime == null)
			clone.referreddatetime = null;
		else
			clone.referreddatetime = (ims.framework.utils.DateTime)this.referreddatetime.clone();
		if(this.seendatetime == null)
			clone.seendatetime = null;
		else
			clone.seendatetime = (ims.framework.utils.DateTime)this.seendatetime.clone();
		if(this.completiondatetime == null)
			clone.completiondatetime = null;
		else
			clone.completiondatetime = (ims.framework.utils.DateTime)this.completiondatetime.clone();
		if(this.referredby == null)
			clone.referredby = null;
		else
			clone.referredby = (ims.core.vo.HcpLiteVo)this.referredby.clone();
		if(this.comments == null)
			clone.comments = null;
		else
			clone.comments = (ims.emergency.vo.AttendanceClinicalNotesVoCollection)this.comments.clone();
		if(this.systeminformation == null)
			clone.systeminformation = null;
		else
			clone.systeminformation = (ims.vo.SystemInformation)this.systeminformation.clone();
		clone.notaccepted = this.notaccepted;
		clone.issafeguardingconcern = this.issafeguardingconcern;
		clone.safeguardingcomments = this.safeguardingcomments;
		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 (!(ReferralToSpecialtyTeamVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A ReferralToSpecialtyTeamVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((ReferralToSpecialtyTeamVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((ReferralToSpecialtyTeamVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.patient != null)
			count++;
		if(this.episode != null)
			count++;
		if(this.attendance != null)
			count++;
		if(this.trackingarea != null)
			count++;
		if(this.teamconsultant != null)
			count++;
		if(this.specialty != null)
			count++;
		if(this.referreddatetime != null)
			count++;
		if(this.seendatetime != null)
			count++;
		if(this.completiondatetime != null)
			count++;
		if(this.referredby != null)
			count++;
		if(this.comments != null)
			count++;
		if(this.systeminformation != null)
			count++;
		if(this.notaccepted != null)
			count++;
		if(this.issafeguardingconcern != null)
			count++;
		if(this.safeguardingcomments != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 15;
	}
	protected ims.core.vo.PatientShortListVo patient;
	protected ims.core.admin.vo.EpisodeOfCareRefVo episode;
	protected ims.core.admin.vo.CareContextRefVo attendance;
	protected ims.emergency.configuration.vo.TrackingAreaRefVo trackingarea;
	protected ims.emergency.vo.lookups.ReferralSpecialtyConsultantOrTeam teamconsultant;
	protected ims.core.vo.lookups.Specialty specialty;
	protected ims.framework.utils.DateTime referreddatetime;
	protected ims.framework.utils.DateTime seendatetime;
	protected ims.framework.utils.DateTime completiondatetime;
	protected ims.core.vo.HcpLiteVo referredby;
	protected ims.emergency.vo.AttendanceClinicalNotesVoCollection comments;
	protected ims.vo.SystemInformation systeminformation;
	protected Boolean notaccepted;
	protected Boolean issafeguardingconcern;
	protected String safeguardingcomments;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
