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

	public ChartRequestedVo()
	{
	}
	public ChartRequestedVo(Integer id, int version)
	{
		super(id, version);
	}
	public ChartRequestedVo(ims.emergency.vo.beans.ChartRequestedVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.emergencyattendence = bean.getEmergencyAttendence() == null ? null : new ims.core.admin.vo.EmergencyAttendanceRefVo(new Integer(bean.getEmergencyAttendence().getId()), bean.getEmergencyAttendence().getVersion());
		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.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.chartrequiredbytriage = bean.getChartRequiredbyTriage() == null ? null : ims.core.vo.lookups.YesNo.buildLookup(bean.getChartRequiredbyTriage());
		this.requestedbyreception = bean.getRequestedbyReception() == null ? null : ims.core.vo.lookups.YesNo.buildLookup(bean.getRequestedbyReception());
		this.datetimerequested = bean.getDateTimeRequested() == null ? null : bean.getDateTimeRequested().buildDateTime();
		this.chartreceived = bean.getChartReceived() == null ? null : ims.core.vo.lookups.YesNo.buildLookup(bean.getChartReceived());
		this.datetimereceived = bean.getDateTimeReceived() == null ? null : bean.getDateTimeReceived().buildDateTime();
		this.comment = bean.getComment();
		this.reasonnotrequested = bean.getReasonnotrequested() == null ? null : ims.admin.vo.lookups.ReasonChartNotRequested.buildLookup(bean.getReasonnotrequested());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.emergency.vo.beans.ChartRequestedVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.emergencyattendence = bean.getEmergencyAttendence() == null ? null : new ims.core.admin.vo.EmergencyAttendanceRefVo(new Integer(bean.getEmergencyAttendence().getId()), bean.getEmergencyAttendence().getVersion());
		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.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.chartrequiredbytriage = bean.getChartRequiredbyTriage() == null ? null : ims.core.vo.lookups.YesNo.buildLookup(bean.getChartRequiredbyTriage());
		this.requestedbyreception = bean.getRequestedbyReception() == null ? null : ims.core.vo.lookups.YesNo.buildLookup(bean.getRequestedbyReception());
		this.datetimerequested = bean.getDateTimeRequested() == null ? null : bean.getDateTimeRequested().buildDateTime();
		this.chartreceived = bean.getChartReceived() == null ? null : ims.core.vo.lookups.YesNo.buildLookup(bean.getChartReceived());
		this.datetimereceived = bean.getDateTimeReceived() == null ? null : bean.getDateTimeReceived().buildDateTime();
		this.comment = bean.getComment();
		this.reasonnotrequested = bean.getReasonnotrequested() == null ? null : ims.admin.vo.lookups.ReasonChartNotRequested.buildLookup(bean.getReasonnotrequested());
	}
	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.ChartRequestedVoBean bean = null;
		if(map != null)
			bean = (ims.emergency.vo.beans.ChartRequestedVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.emergency.vo.beans.ChartRequestedVoBean();
			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("EMERGENCYATTENDENCE"))
			return getEmergencyAttendence();
		if(fieldName.equals("PATIENT"))
			return getPatient();
		if(fieldName.equals("EPISODE"))
			return getEpisode();
		if(fieldName.equals("ATTENDANCE"))
			return getAttendance();
		if(fieldName.equals("CHARTREQUIREDBYTRIAGE"))
			return getChartRequiredbyTriage();
		if(fieldName.equals("REQUESTEDBYRECEPTION"))
			return getRequestedbyReception();
		if(fieldName.equals("DATETIMEREQUESTED"))
			return getDateTimeRequested();
		if(fieldName.equals("CHARTRECEIVED"))
			return getChartReceived();
		if(fieldName.equals("DATETIMERECEIVED"))
			return getDateTimeReceived();
		if(fieldName.equals("COMMENT"))
			return getComment();
		if(fieldName.equals("REASONNOTREQUESTED"))
			return getReasonnotrequested();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getEmergencyAttendenceIsNotNull()
	{
		return this.emergencyattendence != null;
	}
	public ims.core.admin.vo.EmergencyAttendanceRefVo getEmergencyAttendence()
	{
		return this.emergencyattendence;
	}
	public void setEmergencyAttendence(ims.core.admin.vo.EmergencyAttendanceRefVo value)
	{
		this.isValidated = false;
		this.emergencyattendence = 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.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 getChartRequiredbyTriageIsNotNull()
	{
		return this.chartrequiredbytriage != null;
	}
	public ims.core.vo.lookups.YesNo getChartRequiredbyTriage()
	{
		return this.chartrequiredbytriage;
	}
	public void setChartRequiredbyTriage(ims.core.vo.lookups.YesNo value)
	{
		this.isValidated = false;
		this.chartrequiredbytriage = value;
	}
	public boolean getRequestedbyReceptionIsNotNull()
	{
		return this.requestedbyreception != null;
	}
	public ims.core.vo.lookups.YesNo getRequestedbyReception()
	{
		return this.requestedbyreception;
	}
	public void setRequestedbyReception(ims.core.vo.lookups.YesNo value)
	{
		this.isValidated = false;
		this.requestedbyreception = value;
	}
	public boolean getDateTimeRequestedIsNotNull()
	{
		return this.datetimerequested != null;
	}
	public ims.framework.utils.DateTime getDateTimeRequested()
	{
		return this.datetimerequested;
	}
	public void setDateTimeRequested(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.datetimerequested = value;
	}
	public boolean getChartReceivedIsNotNull()
	{
		return this.chartreceived != null;
	}
	public ims.core.vo.lookups.YesNo getChartReceived()
	{
		return this.chartreceived;
	}
	public void setChartReceived(ims.core.vo.lookups.YesNo value)
	{
		this.isValidated = false;
		this.chartreceived = value;
	}
	public boolean getDateTimeReceivedIsNotNull()
	{
		return this.datetimereceived != null;
	}
	public ims.framework.utils.DateTime getDateTimeReceived()
	{
		return this.datetimereceived;
	}
	public void setDateTimeReceived(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.datetimereceived = 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 getReasonnotrequestedIsNotNull()
	{
		return this.reasonnotrequested != null;
	}
	public ims.admin.vo.lookups.ReasonChartNotRequested getReasonnotrequested()
	{
		return this.reasonnotrequested;
	}
	public void setReasonnotrequested(ims.admin.vo.lookups.ReasonChartNotRequested value)
	{
		this.isValidated = false;
		this.reasonnotrequested = 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.emergencyattendence == null)
			listOfErrors.add("EmergencyAttendence is mandatory");
		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.comment != null)
			if(this.comment.length() > 500)
				listOfErrors.add("The length of the field [comment] in the value object [ims.emergency.vo.ChartRequestedVo] 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;
	
		ChartRequestedVo clone = new ChartRequestedVo(this.id, this.version);
		
		clone.emergencyattendence = this.emergencyattendence;
		clone.patient = this.patient;
		clone.episode = this.episode;
		clone.attendance = this.attendance;
		if(this.chartrequiredbytriage == null)
			clone.chartrequiredbytriage = null;
		else
			clone.chartrequiredbytriage = (ims.core.vo.lookups.YesNo)this.chartrequiredbytriage.clone();
		if(this.requestedbyreception == null)
			clone.requestedbyreception = null;
		else
			clone.requestedbyreception = (ims.core.vo.lookups.YesNo)this.requestedbyreception.clone();
		if(this.datetimerequested == null)
			clone.datetimerequested = null;
		else
			clone.datetimerequested = (ims.framework.utils.DateTime)this.datetimerequested.clone();
		if(this.chartreceived == null)
			clone.chartreceived = null;
		else
			clone.chartreceived = (ims.core.vo.lookups.YesNo)this.chartreceived.clone();
		if(this.datetimereceived == null)
			clone.datetimereceived = null;
		else
			clone.datetimereceived = (ims.framework.utils.DateTime)this.datetimereceived.clone();
		clone.comment = this.comment;
		if(this.reasonnotrequested == null)
			clone.reasonnotrequested = null;
		else
			clone.reasonnotrequested = (ims.admin.vo.lookups.ReasonChartNotRequested)this.reasonnotrequested.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 (!(ChartRequestedVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A ChartRequestedVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((ChartRequestedVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((ChartRequestedVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.emergencyattendence != null)
			count++;
		if(this.patient != null)
			count++;
		if(this.episode != null)
			count++;
		if(this.attendance != null)
			count++;
		if(this.chartrequiredbytriage != null)
			count++;
		if(this.requestedbyreception != null)
			count++;
		if(this.datetimerequested != null)
			count++;
		if(this.chartreceived != null)
			count++;
		if(this.datetimereceived != null)
			count++;
		if(this.comment != null)
			count++;
		if(this.reasonnotrequested != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 11;
	}
	protected ims.core.admin.vo.EmergencyAttendanceRefVo emergencyattendence;
	protected ims.core.patient.vo.PatientRefVo patient;
	protected ims.core.admin.vo.EpisodeOfCareRefVo episode;
	protected ims.core.admin.vo.CareContextRefVo attendance;
	protected ims.core.vo.lookups.YesNo chartrequiredbytriage;
	protected ims.core.vo.lookups.YesNo requestedbyreception;
	protected ims.framework.utils.DateTime datetimerequested;
	protected ims.core.vo.lookups.YesNo chartreceived;
	protected ims.framework.utils.DateTime datetimereceived;
	protected String comment;
	protected ims.admin.vo.lookups.ReasonChartNotRequested reasonnotrequested;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
