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

/**
 * Linked to therapies.treatment.ElectrotherapyTensTreatment business object (ID: 1019100017).
 */
public class ElectrotherapyTensTreatmentVo extends ims.therapies.treatment.vo.ElectrotherapyTensTreatmentRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public ElectrotherapyTensTreatmentVo()
	{
	}
	public ElectrotherapyTensTreatmentVo(Integer id, int version)
	{
		super(id, version);
	}
	public ElectrotherapyTensTreatmentVo(ims.therapies.vo.beans.ElectrotherapyTensTreatmentVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.area = bean.getArea() == null ? null : ims.spinalinjuries.vo.lookups.TENSArea.buildLookup(bean.getArea());
		this.laterality = bean.getLaterality() == null ? null : ims.core.vo.lookups.LateralityLRB.buildLookup(bean.getLaterality());
		this.model = bean.getModel() == null ? null : ims.spinalinjuries.vo.lookups.TENSModel.buildLookup(bean.getModel());
		this.serialnr = bean.getSerialNr();
		this.protocolfollowed = bean.getProtocolFollowed() == null ? null : ims.core.vo.lookups.YesNoUnknown.buildLookup(bean.getProtocolFollowed());
		this.mode = bean.getMode() == null ? null : ims.spinalinjuries.vo.lookups.TENSMode.buildLookup(bean.getMode());
		this.pulserate = bean.getPulseRate();
		this.pulsewidth = bean.getPulseWidth();
		this.duration = bean.getDuration();
		this.dailyusage = bean.getDailyUsage() == null ? null : ims.spinalinjuries.vo.lookups.TENSDailyUsage.buildLookup(bean.getDailyUsage());
		this.electrodes = bean.getElectrodes() == null ? null : ims.spinalinjuries.vo.lookups.TENSElectrodes.buildLookup(bean.getElectrodes());
		this.size = bean.getSize() == null ? null : ims.spinalinjuries.vo.lookups.TENSSize.buildLookup(bean.getSize());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.therapies.vo.beans.ElectrotherapyTensTreatmentVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.area = bean.getArea() == null ? null : ims.spinalinjuries.vo.lookups.TENSArea.buildLookup(bean.getArea());
		this.laterality = bean.getLaterality() == null ? null : ims.core.vo.lookups.LateralityLRB.buildLookup(bean.getLaterality());
		this.model = bean.getModel() == null ? null : ims.spinalinjuries.vo.lookups.TENSModel.buildLookup(bean.getModel());
		this.serialnr = bean.getSerialNr();
		this.protocolfollowed = bean.getProtocolFollowed() == null ? null : ims.core.vo.lookups.YesNoUnknown.buildLookup(bean.getProtocolFollowed());
		this.mode = bean.getMode() == null ? null : ims.spinalinjuries.vo.lookups.TENSMode.buildLookup(bean.getMode());
		this.pulserate = bean.getPulseRate();
		this.pulsewidth = bean.getPulseWidth();
		this.duration = bean.getDuration();
		this.dailyusage = bean.getDailyUsage() == null ? null : ims.spinalinjuries.vo.lookups.TENSDailyUsage.buildLookup(bean.getDailyUsage());
		this.electrodes = bean.getElectrodes() == null ? null : ims.spinalinjuries.vo.lookups.TENSElectrodes.buildLookup(bean.getElectrodes());
		this.size = bean.getSize() == null ? null : ims.spinalinjuries.vo.lookups.TENSSize.buildLookup(bean.getSize());
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.therapies.vo.beans.ElectrotherapyTensTreatmentVoBean bean = null;
		if(map != null)
			bean = (ims.therapies.vo.beans.ElectrotherapyTensTreatmentVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.therapies.vo.beans.ElectrotherapyTensTreatmentVoBean();
			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("AREA"))
			return getArea();
		if(fieldName.equals("LATERALITY"))
			return getLaterality();
		if(fieldName.equals("MODEL"))
			return getModel();
		if(fieldName.equals("SERIALNR"))
			return getSerialNr();
		if(fieldName.equals("PROTOCOLFOLLOWED"))
			return getProtocolFollowed();
		if(fieldName.equals("MODE"))
			return getMode();
		if(fieldName.equals("PULSERATE"))
			return getPulseRate();
		if(fieldName.equals("PULSEWIDTH"))
			return getPulseWidth();
		if(fieldName.equals("DURATION"))
			return getDuration();
		if(fieldName.equals("DAILYUSAGE"))
			return getDailyUsage();
		if(fieldName.equals("ELECTRODES"))
			return getElectrodes();
		if(fieldName.equals("SIZE"))
			return getSize();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getAreaIsNotNull()
	{
		return this.area != null;
	}
	public ims.spinalinjuries.vo.lookups.TENSArea getArea()
	{
		return this.area;
	}
	public void setArea(ims.spinalinjuries.vo.lookups.TENSArea value)
	{
		this.isValidated = false;
		this.area = value;
	}
	public boolean getLateralityIsNotNull()
	{
		return this.laterality != null;
	}
	public ims.core.vo.lookups.LateralityLRB getLaterality()
	{
		return this.laterality;
	}
	public void setLaterality(ims.core.vo.lookups.LateralityLRB value)
	{
		this.isValidated = false;
		this.laterality = value;
	}
	public boolean getModelIsNotNull()
	{
		return this.model != null;
	}
	public ims.spinalinjuries.vo.lookups.TENSModel getModel()
	{
		return this.model;
	}
	public void setModel(ims.spinalinjuries.vo.lookups.TENSModel value)
	{
		this.isValidated = false;
		this.model = value;
	}
	public boolean getSerialNrIsNotNull()
	{
		return this.serialnr != null;
	}
	public String getSerialNr()
	{
		return this.serialnr;
	}
	public static int getSerialNrMaxLength()
	{
		return 50;
	}
	public void setSerialNr(String value)
	{
		this.isValidated = false;
		this.serialnr = value;
	}
	public boolean getProtocolFollowedIsNotNull()
	{
		return this.protocolfollowed != null;
	}
	public ims.core.vo.lookups.YesNoUnknown getProtocolFollowed()
	{
		return this.protocolfollowed;
	}
	public void setProtocolFollowed(ims.core.vo.lookups.YesNoUnknown value)
	{
		this.isValidated = false;
		this.protocolfollowed = value;
	}
	public boolean getModeIsNotNull()
	{
		return this.mode != null;
	}
	public ims.spinalinjuries.vo.lookups.TENSMode getMode()
	{
		return this.mode;
	}
	public void setMode(ims.spinalinjuries.vo.lookups.TENSMode value)
	{
		this.isValidated = false;
		this.mode = value;
	}
	public boolean getPulseRateIsNotNull()
	{
		return this.pulserate != null;
	}
	public Integer getPulseRate()
	{
		return this.pulserate;
	}
	public void setPulseRate(Integer value)
	{
		this.isValidated = false;
		this.pulserate = value;
	}
	public boolean getPulseWidthIsNotNull()
	{
		return this.pulsewidth != null;
	}
	public Integer getPulseWidth()
	{
		return this.pulsewidth;
	}
	public void setPulseWidth(Integer value)
	{
		this.isValidated = false;
		this.pulsewidth = value;
	}
	public boolean getDurationIsNotNull()
	{
		return this.duration != null;
	}
	public Integer getDuration()
	{
		return this.duration;
	}
	public void setDuration(Integer value)
	{
		this.isValidated = false;
		this.duration = value;
	}
	public boolean getDailyUsageIsNotNull()
	{
		return this.dailyusage != null;
	}
	public ims.spinalinjuries.vo.lookups.TENSDailyUsage getDailyUsage()
	{
		return this.dailyusage;
	}
	public void setDailyUsage(ims.spinalinjuries.vo.lookups.TENSDailyUsage value)
	{
		this.isValidated = false;
		this.dailyusage = value;
	}
	public boolean getElectrodesIsNotNull()
	{
		return this.electrodes != null;
	}
	public ims.spinalinjuries.vo.lookups.TENSElectrodes getElectrodes()
	{
		return this.electrodes;
	}
	public void setElectrodes(ims.spinalinjuries.vo.lookups.TENSElectrodes value)
	{
		this.isValidated = false;
		this.electrodes = value;
	}
	public boolean getSizeIsNotNull()
	{
		return this.size != null;
	}
	public ims.spinalinjuries.vo.lookups.TENSSize getSize()
	{
		return this.size;
	}
	public void setSize(ims.spinalinjuries.vo.lookups.TENSSize value)
	{
		this.isValidated = false;
		this.size = 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.area == null)
			listOfErrors.add("Area is mandatory");
		if(this.laterality == null)
			listOfErrors.add("Laterality is mandatory");
		if(this.serialnr != null)
			if(this.serialnr.length() > 50)
				listOfErrors.add("The length of the field [serialnr] in the value object [ims.therapies.vo.ElectrotherapyTensTreatmentVo] is too big. It should be less or equal to 50");
		if(this.electrodes == null)
			listOfErrors.add("Electrodes 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;
	
		ElectrotherapyTensTreatmentVo clone = new ElectrotherapyTensTreatmentVo(this.id, this.version);
		
		if(this.area == null)
			clone.area = null;
		else
			clone.area = (ims.spinalinjuries.vo.lookups.TENSArea)this.area.clone();
		if(this.laterality == null)
			clone.laterality = null;
		else
			clone.laterality = (ims.core.vo.lookups.LateralityLRB)this.laterality.clone();
		if(this.model == null)
			clone.model = null;
		else
			clone.model = (ims.spinalinjuries.vo.lookups.TENSModel)this.model.clone();
		clone.serialnr = this.serialnr;
		if(this.protocolfollowed == null)
			clone.protocolfollowed = null;
		else
			clone.protocolfollowed = (ims.core.vo.lookups.YesNoUnknown)this.protocolfollowed.clone();
		if(this.mode == null)
			clone.mode = null;
		else
			clone.mode = (ims.spinalinjuries.vo.lookups.TENSMode)this.mode.clone();
		clone.pulserate = this.pulserate;
		clone.pulsewidth = this.pulsewidth;
		clone.duration = this.duration;
		if(this.dailyusage == null)
			clone.dailyusage = null;
		else
			clone.dailyusage = (ims.spinalinjuries.vo.lookups.TENSDailyUsage)this.dailyusage.clone();
		if(this.electrodes == null)
			clone.electrodes = null;
		else
			clone.electrodes = (ims.spinalinjuries.vo.lookups.TENSElectrodes)this.electrodes.clone();
		if(this.size == null)
			clone.size = null;
		else
			clone.size = (ims.spinalinjuries.vo.lookups.TENSSize)this.size.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 (!(ElectrotherapyTensTreatmentVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A ElectrotherapyTensTreatmentVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		ElectrotherapyTensTreatmentVo compareObj = (ElectrotherapyTensTreatmentVo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getID_ElectrotherapyTensTreatment() == null && compareObj.getID_ElectrotherapyTensTreatment() != null)
				return -1;
			if(this.getID_ElectrotherapyTensTreatment() != null && compareObj.getID_ElectrotherapyTensTreatment() == null)
				return 1;
			if(this.getID_ElectrotherapyTensTreatment() != null && compareObj.getID_ElectrotherapyTensTreatment() != null)
				retVal = this.getID_ElectrotherapyTensTreatment().compareTo(compareObj.getID_ElectrotherapyTensTreatment());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.area != null)
			count++;
		if(this.laterality != null)
			count++;
		if(this.model != null)
			count++;
		if(this.serialnr != null)
			count++;
		if(this.protocolfollowed != null)
			count++;
		if(this.mode != null)
			count++;
		if(this.pulserate != null)
			count++;
		if(this.pulsewidth != null)
			count++;
		if(this.duration != null)
			count++;
		if(this.dailyusage != null)
			count++;
		if(this.electrodes != null)
			count++;
		if(this.size != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 12;
	}
	protected ims.spinalinjuries.vo.lookups.TENSArea area;
	protected ims.core.vo.lookups.LateralityLRB laterality;
	protected ims.spinalinjuries.vo.lookups.TENSModel model;
	protected String serialnr;
	protected ims.core.vo.lookups.YesNoUnknown protocolfollowed;
	protected ims.spinalinjuries.vo.lookups.TENSMode mode;
	protected Integer pulserate;
	protected Integer pulsewidth;
	protected Integer duration;
	protected ims.spinalinjuries.vo.lookups.TENSDailyUsage dailyusage;
	protected ims.spinalinjuries.vo.lookups.TENSElectrodes electrodes;
	protected ims.spinalinjuries.vo.lookups.TENSSize size;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
