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

/**
 * Linked to OCRR.OrderingResults.OcsOrderSession business object (ID: 1070100000).
 */
public class IfOcsOrderShortVo extends ims.ocrr.orderingresults.vo.OcsOrderSessionRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public IfOcsOrderShortVo()
	{
	}
	public IfOcsOrderShortVo(Integer id, int version)
	{
		super(id, version);
	}
	public IfOcsOrderShortVo(ims.ocs_if.vo.beans.IfOcsOrderShortVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.patient = bean.getPatient() == null ? null : new ims.core.patient.vo.PatientRefVo(new Integer(bean.getPatient().getId()), bean.getPatient().getVersion());
		this.orderedby = bean.getOrderedBy() == null ? null : bean.getOrderedBy().buildVo();
		this.responsibleclinician = bean.getResponsibleClinician() == null ? null : bean.getResponsibleClinician().buildVo();
		this.responsiblegp = bean.getResponsibleGp() == null ? null : bean.getResponsibleGp().buildVo();
		this.patientlocation = bean.getPatientLocation() == null ? null : new ims.core.resource.place.vo.LocationRefVo(new Integer(bean.getPatientLocation().getId()), bean.getPatientLocation().getVersion());
		this.patientclinic = bean.getPatientClinic() == null ? null : new ims.core.resource.place.vo.ClinicRefVo(new Integer(bean.getPatientClinic().getId()), bean.getPatientClinic().getVersion());
		this.additclinnotes = bean.getAdditClinNotes();
		this.sendnumber = bean.getSendNumber();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.ocs_if.vo.beans.IfOcsOrderShortVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.patient = bean.getPatient() == null ? null : new ims.core.patient.vo.PatientRefVo(new Integer(bean.getPatient().getId()), bean.getPatient().getVersion());
		this.orderedby = bean.getOrderedBy() == null ? null : bean.getOrderedBy().buildVo(map);
		this.responsibleclinician = bean.getResponsibleClinician() == null ? null : bean.getResponsibleClinician().buildVo(map);
		this.responsiblegp = bean.getResponsibleGp() == null ? null : bean.getResponsibleGp().buildVo(map);
		this.patientlocation = bean.getPatientLocation() == null ? null : new ims.core.resource.place.vo.LocationRefVo(new Integer(bean.getPatientLocation().getId()), bean.getPatientLocation().getVersion());
		this.patientclinic = bean.getPatientClinic() == null ? null : new ims.core.resource.place.vo.ClinicRefVo(new Integer(bean.getPatientClinic().getId()), bean.getPatientClinic().getVersion());
		this.additclinnotes = bean.getAdditClinNotes();
		this.sendnumber = bean.getSendNumber();
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.ocs_if.vo.beans.IfOcsOrderShortVoBean bean = null;
		if(map != null)
			bean = (ims.ocs_if.vo.beans.IfOcsOrderShortVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.ocs_if.vo.beans.IfOcsOrderShortVoBean();
			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("ORDEREDBY"))
			return getOrderedBy();
		if(fieldName.equals("RESPONSIBLECLINICIAN"))
			return getResponsibleClinician();
		if(fieldName.equals("RESPONSIBLEGP"))
			return getResponsibleGp();
		if(fieldName.equals("PATIENTLOCATION"))
			return getPatientLocation();
		if(fieldName.equals("PATIENTCLINIC"))
			return getPatientClinic();
		if(fieldName.equals("ADDITCLINNOTES"))
			return getAdditClinNotes();
		if(fieldName.equals("SENDNUMBER"))
			return getSendNumber();
		return super.getFieldValueByFieldName(fieldName);
	}
	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 getOrderedByIsNotNull()
	{
		return this.orderedby != null;
	}
	public ims.core.vo.MemberOfStaffLiteVo getOrderedBy()
	{
		return this.orderedby;
	}
	public void setOrderedBy(ims.core.vo.MemberOfStaffLiteVo value)
	{
		this.isValidated = false;
		this.orderedby = value;
	}
	public boolean getResponsibleClinicianIsNotNull()
	{
		return this.responsibleclinician != null;
	}
	public ims.core.vo.HcpLiteVo getResponsibleClinician()
	{
		return this.responsibleclinician;
	}
	public void setResponsibleClinician(ims.core.vo.HcpLiteVo value)
	{
		this.isValidated = false;
		this.responsibleclinician = value;
	}
	public boolean getResponsibleGpIsNotNull()
	{
		return this.responsiblegp != null;
	}
	public ims.core.vo.GpLiteVo getResponsibleGp()
	{
		return this.responsiblegp;
	}
	public void setResponsibleGp(ims.core.vo.GpLiteVo value)
	{
		this.isValidated = false;
		this.responsiblegp = value;
	}
	public boolean getPatientLocationIsNotNull()
	{
		return this.patientlocation != null;
	}
	public ims.core.resource.place.vo.LocationRefVo getPatientLocation()
	{
		return this.patientlocation;
	}
	public void setPatientLocation(ims.core.resource.place.vo.LocationRefVo value)
	{
		this.isValidated = false;
		this.patientlocation = value;
	}
	public boolean getPatientClinicIsNotNull()
	{
		return this.patientclinic != null;
	}
	public ims.core.resource.place.vo.ClinicRefVo getPatientClinic()
	{
		return this.patientclinic;
	}
	public void setPatientClinic(ims.core.resource.place.vo.ClinicRefVo value)
	{
		this.isValidated = false;
		this.patientclinic = value;
	}
	public boolean getAdditClinNotesIsNotNull()
	{
		return this.additclinnotes != null;
	}
	public String getAdditClinNotes()
	{
		return this.additclinnotes;
	}
	public static int getAdditClinNotesMaxLength()
	{
		return 4000;
	}
	public void setAdditClinNotes(String value)
	{
		this.isValidated = false;
		this.additclinnotes = value;
	}
	public boolean getSendNumberIsNotNull()
	{
		return this.sendnumber != null;
	}
	public Boolean getSendNumber()
	{
		return this.sendnumber;
	}
	public void setSendNumber(Boolean value)
	{
		this.isValidated = false;
		this.sendnumber = 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.patient == null)
			listOfErrors.add("Patient 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;
	
		IfOcsOrderShortVo clone = new IfOcsOrderShortVo(this.id, this.version);
		
		clone.patient = this.patient;
		if(this.orderedby == null)
			clone.orderedby = null;
		else
			clone.orderedby = (ims.core.vo.MemberOfStaffLiteVo)this.orderedby.clone();
		if(this.responsibleclinician == null)
			clone.responsibleclinician = null;
		else
			clone.responsibleclinician = (ims.core.vo.HcpLiteVo)this.responsibleclinician.clone();
		if(this.responsiblegp == null)
			clone.responsiblegp = null;
		else
			clone.responsiblegp = (ims.core.vo.GpLiteVo)this.responsiblegp.clone();
		clone.patientlocation = this.patientlocation;
		clone.patientclinic = this.patientclinic;
		clone.additclinnotes = this.additclinnotes;
		clone.sendnumber = this.sendnumber;
		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 (!(IfOcsOrderShortVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A IfOcsOrderShortVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((IfOcsOrderShortVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((IfOcsOrderShortVo)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.orderedby != null)
			count++;
		if(this.responsibleclinician != null)
			count++;
		if(this.responsiblegp != null)
			count++;
		if(this.patientlocation != null)
			count++;
		if(this.patientclinic != null)
			count++;
		if(this.additclinnotes != null)
			count++;
		if(this.sendnumber != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 8;
	}
	protected ims.core.patient.vo.PatientRefVo patient;
	protected ims.core.vo.MemberOfStaffLiteVo orderedby;
	protected ims.core.vo.HcpLiteVo responsibleclinician;
	protected ims.core.vo.GpLiteVo responsiblegp;
	protected ims.core.resource.place.vo.LocationRefVo patientlocation;
	protected ims.core.resource.place.vo.ClinicRefVo patientclinic;
	protected String additclinnotes;
	protected Boolean sendnumber;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
