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

/**
 * Linked to clinical.DiathermyDetailIntraOp business object (ID: 1072100138).
 */
public class DiathermyDetailIntraOpVo extends ims.clinical.vo.DiathermyDetailIntraOpRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public DiathermyDetailIntraOpVo()
	{
	}
	public DiathermyDetailIntraOpVo(Integer id, int version)
	{
		super(id, version);
	}
	public DiathermyDetailIntraOpVo(ims.clinical.vo.beans.DiathermyDetailIntraOpVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.theatreappointment = bean.getTheatreAppointment() == null ? null : new ims.scheduling.vo.Booking_AppointmentRefVo(new Integer(bean.getTheatreAppointment().getId()), bean.getTheatreAppointment().getVersion());
		this.diathermymode = bean.getDiathermyMode() == null ? null : ims.clinical.vo.lookups.DiathermyMode.buildLookup(bean.getDiathermyMode());
		this.coagsetting = bean.getCoagSetting();
		this.cutsetting = bean.getCutSetting();
		this.serialnumber = bean.getSerialNumber() == null ? null : ims.clinical.vo.lookups.DiathermySerialNumber.buildLookup(bean.getSerialNumber());
		this.padsite = bean.getPadSite() == null ? null : ims.core.vo.lookups.DiathermyPadSite.buildLookup(bean.getPadSite());
		this.appliedby = bean.getAppliedBy() == null ? null : bean.getAppliedBy().buildVo();
		this.removedby = bean.getRemovedBy() == null ? null : bean.getRemovedBy().buildVo();
		this.blendsetting = bean.getBlendSetting();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.clinical.vo.beans.DiathermyDetailIntraOpVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.theatreappointment = bean.getTheatreAppointment() == null ? null : new ims.scheduling.vo.Booking_AppointmentRefVo(new Integer(bean.getTheatreAppointment().getId()), bean.getTheatreAppointment().getVersion());
		this.diathermymode = bean.getDiathermyMode() == null ? null : ims.clinical.vo.lookups.DiathermyMode.buildLookup(bean.getDiathermyMode());
		this.coagsetting = bean.getCoagSetting();
		this.cutsetting = bean.getCutSetting();
		this.serialnumber = bean.getSerialNumber() == null ? null : ims.clinical.vo.lookups.DiathermySerialNumber.buildLookup(bean.getSerialNumber());
		this.padsite = bean.getPadSite() == null ? null : ims.core.vo.lookups.DiathermyPadSite.buildLookup(bean.getPadSite());
		this.appliedby = bean.getAppliedBy() == null ? null : bean.getAppliedBy().buildVo(map);
		this.removedby = bean.getRemovedBy() == null ? null : bean.getRemovedBy().buildVo(map);
		this.blendsetting = bean.getBlendSetting();
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.clinical.vo.beans.DiathermyDetailIntraOpVoBean bean = null;
		if(map != null)
			bean = (ims.clinical.vo.beans.DiathermyDetailIntraOpVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.clinical.vo.beans.DiathermyDetailIntraOpVoBean();
			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("THEATREAPPOINTMENT"))
			return getTheatreAppointment();
		if(fieldName.equals("DIATHERMYMODE"))
			return getDiathermyMode();
		if(fieldName.equals("COAGSETTING"))
			return getCoagSetting();
		if(fieldName.equals("CUTSETTING"))
			return getCutSetting();
		if(fieldName.equals("SERIALNUMBER"))
			return getSerialNumber();
		if(fieldName.equals("PADSITE"))
			return getPadSite();
		if(fieldName.equals("APPLIEDBY"))
			return getAppliedBy();
		if(fieldName.equals("REMOVEDBY"))
			return getRemovedBy();
		if(fieldName.equals("BLENDSETTING"))
			return getBlendSetting();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getTheatreAppointmentIsNotNull()
	{
		return this.theatreappointment != null;
	}
	public ims.scheduling.vo.Booking_AppointmentRefVo getTheatreAppointment()
	{
		return this.theatreappointment;
	}
	public void setTheatreAppointment(ims.scheduling.vo.Booking_AppointmentRefVo value)
	{
		this.isValidated = false;
		this.theatreappointment = value;
	}
	public boolean getDiathermyModeIsNotNull()
	{
		return this.diathermymode != null;
	}
	public ims.clinical.vo.lookups.DiathermyMode getDiathermyMode()
	{
		return this.diathermymode;
	}
	public void setDiathermyMode(ims.clinical.vo.lookups.DiathermyMode value)
	{
		this.isValidated = false;
		this.diathermymode = value;
	}
	public boolean getCoagSettingIsNotNull()
	{
		return this.coagsetting != null;
	}
	public String getCoagSetting()
	{
		return this.coagsetting;
	}
	public static int getCoagSettingMaxLength()
	{
		return 100;
	}
	public void setCoagSetting(String value)
	{
		this.isValidated = false;
		this.coagsetting = value;
	}
	public boolean getCutSettingIsNotNull()
	{
		return this.cutsetting != null;
	}
	public String getCutSetting()
	{
		return this.cutsetting;
	}
	public static int getCutSettingMaxLength()
	{
		return 100;
	}
	public void setCutSetting(String value)
	{
		this.isValidated = false;
		this.cutsetting = value;
	}
	public boolean getSerialNumberIsNotNull()
	{
		return this.serialnumber != null;
	}
	public ims.clinical.vo.lookups.DiathermySerialNumber getSerialNumber()
	{
		return this.serialnumber;
	}
	public void setSerialNumber(ims.clinical.vo.lookups.DiathermySerialNumber value)
	{
		this.isValidated = false;
		this.serialnumber = value;
	}
	public boolean getPadSiteIsNotNull()
	{
		return this.padsite != null;
	}
	public ims.core.vo.lookups.DiathermyPadSite getPadSite()
	{
		return this.padsite;
	}
	public void setPadSite(ims.core.vo.lookups.DiathermyPadSite value)
	{
		this.isValidated = false;
		this.padsite = value;
	}
	public boolean getAppliedByIsNotNull()
	{
		return this.appliedby != null;
	}
	public ims.core.vo.HcpLiteVo getAppliedBy()
	{
		return this.appliedby;
	}
	public void setAppliedBy(ims.core.vo.HcpLiteVo value)
	{
		this.isValidated = false;
		this.appliedby = value;
	}
	public boolean getRemovedByIsNotNull()
	{
		return this.removedby != null;
	}
	public ims.core.vo.HcpLiteVo getRemovedBy()
	{
		return this.removedby;
	}
	public void setRemovedBy(ims.core.vo.HcpLiteVo value)
	{
		this.isValidated = false;
		this.removedby = value;
	}
	public boolean getBlendSettingIsNotNull()
	{
		return this.blendsetting != null;
	}
	public String getBlendSetting()
	{
		return this.blendsetting;
	}
	public static int getBlendSettingMaxLength()
	{
		return 100;
	}
	public void setBlendSetting(String value)
	{
		this.isValidated = false;
		this.blendsetting = value;
	}
	/**
	* constructToolTipForDiathermy
	*/
	public String constructToolTipForDiathermy()
	{
		java.lang.StringBuffer bfr = new java.lang.StringBuffer();
		bfr.append("Applied By: ");
		bfr.append(this.getAppliedByIsNotNull() ? this.getAppliedBy().toString() : "");
		bfr.append("<br>");
		bfr.append("Removed By: ");
		bfr.append(this.getRemovedByIsNotNull() ? this.getRemovedBy().toString() : "");
		return bfr.toString();
	}
	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.theatreappointment == null)
			listOfErrors.add("TheatreAppointment is mandatory");
		if(this.diathermymode == null)
			listOfErrors.add("Diathermy Mode is mandatory");
		if(this.coagsetting == null || this.coagsetting.length() == 0)
			listOfErrors.add("Coag Setting is mandatory");
		else if(this.coagsetting.length() > 100)
			listOfErrors.add("The length of the field [coagsetting] in the value object [ims.clinical.vo.DiathermyDetailIntraOpVo] is too big. It should be less or equal to 100");
		if(this.cutsetting != null)
			if(this.cutsetting.length() > 100)
				listOfErrors.add("The length of the field [cutsetting] in the value object [ims.clinical.vo.DiathermyDetailIntraOpVo] is too big. It should be less or equal to 100");
		if(this.serialnumber == null)
			listOfErrors.add("Serial Number is mandatory");
		if(this.blendsetting != null)
			if(this.blendsetting.length() > 100)
				listOfErrors.add("The length of the field [blendsetting] in the value object [ims.clinical.vo.DiathermyDetailIntraOpVo] is too big. It should be less or equal to 100");
		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;
	
		DiathermyDetailIntraOpVo clone = new DiathermyDetailIntraOpVo(this.id, this.version);
		
		clone.theatreappointment = this.theatreappointment;
		if(this.diathermymode == null)
			clone.diathermymode = null;
		else
			clone.diathermymode = (ims.clinical.vo.lookups.DiathermyMode)this.diathermymode.clone();
		clone.coagsetting = this.coagsetting;
		clone.cutsetting = this.cutsetting;
		if(this.serialnumber == null)
			clone.serialnumber = null;
		else
			clone.serialnumber = (ims.clinical.vo.lookups.DiathermySerialNumber)this.serialnumber.clone();
		if(this.padsite == null)
			clone.padsite = null;
		else
			clone.padsite = (ims.core.vo.lookups.DiathermyPadSite)this.padsite.clone();
		if(this.appliedby == null)
			clone.appliedby = null;
		else
			clone.appliedby = (ims.core.vo.HcpLiteVo)this.appliedby.clone();
		if(this.removedby == null)
			clone.removedby = null;
		else
			clone.removedby = (ims.core.vo.HcpLiteVo)this.removedby.clone();
		clone.blendsetting = this.blendsetting;
		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 (!(DiathermyDetailIntraOpVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A DiathermyDetailIntraOpVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((DiathermyDetailIntraOpVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((DiathermyDetailIntraOpVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.theatreappointment != null)
			count++;
		if(this.diathermymode != null)
			count++;
		if(this.coagsetting != null)
			count++;
		if(this.cutsetting != null)
			count++;
		if(this.serialnumber != null)
			count++;
		if(this.padsite != null)
			count++;
		if(this.appliedby != null)
			count++;
		if(this.removedby != null)
			count++;
		if(this.blendsetting != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 9;
	}
	protected ims.scheduling.vo.Booking_AppointmentRefVo theatreappointment;
	protected ims.clinical.vo.lookups.DiathermyMode diathermymode;
	protected String coagsetting;
	protected String cutsetting;
	protected ims.clinical.vo.lookups.DiathermySerialNumber serialnumber;
	protected ims.core.vo.lookups.DiathermyPadSite padsite;
	protected ims.core.vo.HcpLiteVo appliedby;
	protected ims.core.vo.HcpLiteVo removedby;
	protected String blendsetting;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
