//#############################################################################
//#                                                                           #
//#  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.core.vo;

/**
 * Linked to core.clinical.ActivityContextPricingDetails business object (ID: 1007100004).
 */
public class ActivityContextPricingDetailsVo extends ims.core.clinical.vo.ActivityContextPricingDetailsRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public ActivityContextPricingDetailsVo()
	{
	}
	public ActivityContextPricingDetailsVo(Integer id, int version)
	{
		super(id, version);
	}
	public ActivityContextPricingDetailsVo(ims.core.vo.beans.ActivityContextPricingDetailsVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.context = bean.getContext() == null ? null : ims.core.vo.lookups.ProcedureContext.buildLookup(bean.getContext());
		this.price = bean.getPrice();
		this.currency = bean.getCurrency() == null ? null : ims.core.vo.lookups.Currency.buildLookup(bean.getCurrency());
		this.normlengthstay = bean.getNormLengthStay();
		this.effectivefrom = bean.getEffectiveFrom() == null ? null : bean.getEffectiveFrom().buildDate();
		this.effectiveto = bean.getEffectiveTo() == null ? null : bean.getEffectiveTo().buildDate();
		this.isactive = bean.getIsActive();
		this.pricecategory = bean.getPriceCategory() == null ? null : ims.ntpf.vo.lookups.PatientType.buildLookup(bean.getPriceCategory());
		this.taxonomymap = ims.core.vo.TaxonomyMapCollection.buildFromBeanCollection(bean.getTaxonomyMap());
		this.ispreactive = bean.getIsPreActive();
		this.effectivetoset = bean.getEffectiveToSet() == null ? null : bean.getEffectiveToSet().buildDate();
		this.creatingbatch = bean.getCreatingBatch() == null ? null : bean.getCreatingBatch().buildVo();
		this.effectivefromset = bean.getEffectiveFromSet() == null ? null : bean.getEffectiveFromSet().buildDate();
		this.activepricing = bean.getActivePricing() == null ? null : new ims.core.clinical.vo.ActivityContextPricingDetailsRefVo(new Integer(bean.getActivePricing().getId()), bean.getActivePricing().getVersion());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.ActivityContextPricingDetailsVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.context = bean.getContext() == null ? null : ims.core.vo.lookups.ProcedureContext.buildLookup(bean.getContext());
		this.price = bean.getPrice();
		this.currency = bean.getCurrency() == null ? null : ims.core.vo.lookups.Currency.buildLookup(bean.getCurrency());
		this.normlengthstay = bean.getNormLengthStay();
		this.effectivefrom = bean.getEffectiveFrom() == null ? null : bean.getEffectiveFrom().buildDate();
		this.effectiveto = bean.getEffectiveTo() == null ? null : bean.getEffectiveTo().buildDate();
		this.isactive = bean.getIsActive();
		this.pricecategory = bean.getPriceCategory() == null ? null : ims.ntpf.vo.lookups.PatientType.buildLookup(bean.getPriceCategory());
		this.taxonomymap = ims.core.vo.TaxonomyMapCollection.buildFromBeanCollection(bean.getTaxonomyMap());
		this.ispreactive = bean.getIsPreActive();
		this.effectivetoset = bean.getEffectiveToSet() == null ? null : bean.getEffectiveToSet().buildDate();
		this.creatingbatch = bean.getCreatingBatch() == null ? null : bean.getCreatingBatch().buildVo(map);
		this.effectivefromset = bean.getEffectiveFromSet() == null ? null : bean.getEffectiveFromSet().buildDate();
		this.activepricing = bean.getActivePricing() == null ? null : new ims.core.clinical.vo.ActivityContextPricingDetailsRefVo(new Integer(bean.getActivePricing().getId()), bean.getActivePricing().getVersion());
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.core.vo.beans.ActivityContextPricingDetailsVoBean bean = null;
		if(map != null)
			bean = (ims.core.vo.beans.ActivityContextPricingDetailsVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.core.vo.beans.ActivityContextPricingDetailsVoBean();
			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("CONTEXT"))
			return getContext();
		if(fieldName.equals("PRICE"))
			return getPrice();
		if(fieldName.equals("CURRENCY"))
			return getCurrency();
		if(fieldName.equals("NORMLENGTHSTAY"))
			return getNormLengthStay();
		if(fieldName.equals("EFFECTIVEFROM"))
			return getEffectiveFrom();
		if(fieldName.equals("EFFECTIVETO"))
			return getEffectiveTo();
		if(fieldName.equals("ISACTIVE"))
			return getIsActive();
		if(fieldName.equals("PRICECATEGORY"))
			return getPriceCategory();
		if(fieldName.equals("TAXONOMYMAP"))
			return getTaxonomyMap();
		if(fieldName.equals("ISPREACTIVE"))
			return getIsPreActive();
		if(fieldName.equals("EFFECTIVETOSET"))
			return getEffectiveToSet();
		if(fieldName.equals("CREATINGBATCH"))
			return getCreatingBatch();
		if(fieldName.equals("EFFECTIVEFROMSET"))
			return getEffectiveFromSet();
		if(fieldName.equals("ACTIVEPRICING"))
			return getActivePricing();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getContextIsNotNull()
	{
		return this.context != null;
	}
	public ims.core.vo.lookups.ProcedureContext getContext()
	{
		return this.context;
	}
	public void setContext(ims.core.vo.lookups.ProcedureContext value)
	{
		this.isValidated = false;
		this.context = value;
	}
	public boolean getPriceIsNotNull()
	{
		return this.price != null;
	}
	public Float getPrice()
	{
		return this.price;
	}
	public void setPrice(Float value)
	{
		this.isValidated = false;
		this.price = value;
	}
	public boolean getCurrencyIsNotNull()
	{
		return this.currency != null;
	}
	public ims.core.vo.lookups.Currency getCurrency()
	{
		return this.currency;
	}
	public void setCurrency(ims.core.vo.lookups.Currency value)
	{
		this.isValidated = false;
		this.currency = value;
	}
	public boolean getNormLengthStayIsNotNull()
	{
		return this.normlengthstay != null;
	}
	public Integer getNormLengthStay()
	{
		return this.normlengthstay;
	}
	public void setNormLengthStay(Integer value)
	{
		this.isValidated = false;
		this.normlengthstay = value;
	}
	public boolean getEffectiveFromIsNotNull()
	{
		return this.effectivefrom != null;
	}
	public ims.framework.utils.Date getEffectiveFrom()
	{
		return this.effectivefrom;
	}
	public void setEffectiveFrom(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.effectivefrom = value;
	}
	public boolean getEffectiveToIsNotNull()
	{
		return this.effectiveto != null;
	}
	public ims.framework.utils.Date getEffectiveTo()
	{
		return this.effectiveto;
	}
	public void setEffectiveTo(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.effectiveto = value;
	}
	public boolean getIsActiveIsNotNull()
	{
		return this.isactive != null;
	}
	public Boolean getIsActive()
	{
		return this.isactive;
	}
	public void setIsActive(Boolean value)
	{
		this.isValidated = false;
		this.isactive = value;
	}
	public boolean getPriceCategoryIsNotNull()
	{
		return this.pricecategory != null;
	}
	public ims.ntpf.vo.lookups.PatientType getPriceCategory()
	{
		return this.pricecategory;
	}
	public void setPriceCategory(ims.ntpf.vo.lookups.PatientType value)
	{
		this.isValidated = false;
		this.pricecategory = value;
	}
	public boolean getTaxonomyMapIsNotNull()
	{
		return this.taxonomymap != null;
	}
	public ims.core.vo.TaxonomyMapCollection getTaxonomyMap()
	{
		return this.taxonomymap;
	}
	public void setTaxonomyMap(ims.core.vo.TaxonomyMapCollection value)
	{
		this.isValidated = false;
		this.taxonomymap = value;
	}
	public boolean getIsPreActiveIsNotNull()
	{
		return this.ispreactive != null;
	}
	public Boolean getIsPreActive()
	{
		return this.ispreactive;
	}
	public void setIsPreActive(Boolean value)
	{
		this.isValidated = false;
		this.ispreactive = value;
	}
	public boolean getEffectiveToSetIsNotNull()
	{
		return this.effectivetoset != null;
	}
	public ims.framework.utils.Date getEffectiveToSet()
	{
		return this.effectivetoset;
	}
	public void setEffectiveToSet(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.effectivetoset = value;
	}
	public boolean getCreatingBatchIsNotNull()
	{
		return this.creatingbatch != null;
	}
	public ims.core.vo.BatchPricingShortVo getCreatingBatch()
	{
		return this.creatingbatch;
	}
	public void setCreatingBatch(ims.core.vo.BatchPricingShortVo value)
	{
		this.isValidated = false;
		this.creatingbatch = value;
	}
	public boolean getEffectiveFromSetIsNotNull()
	{
		return this.effectivefromset != null;
	}
	public ims.framework.utils.Date getEffectiveFromSet()
	{
		return this.effectivefromset;
	}
	public void setEffectiveFromSet(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.effectivefromset = value;
	}
	public boolean getActivePricingIsNotNull()
	{
		return this.activepricing != null;
	}
	public ims.core.clinical.vo.ActivityContextPricingDetailsRefVo getActivePricing()
	{
		return this.activepricing;
	}
	public void setActivePricing(ims.core.clinical.vo.ActivityContextPricingDetailsRefVo value)
	{
		this.isValidated = false;
		this.activepricing = value;
	}
	public String toString()
	{
		StringBuffer sb = new StringBuffer();
		sb.append("Context: ");
		if(this.context != null)
			sb.append(this.context);
		sb.append(", Price: ");
		if(this.price != null)
			sb.append(this.price);
		sb.append(", Length of Stay: ");
		if(this.normlengthstay != null)
			sb.append(this.normlengthstay);
		return sb.toString();
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.taxonomymap != null)
		{
			if(!this.taxonomymap.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.context == null)
			listOfErrors.add("Please enter a Context value.");
		if(this.price == null)
			listOfErrors.add("Please enter a Price value.");
		if(this.currency == null)
			listOfErrors.add("Please enter a Currency value.");
		if(this.effectivefrom == null)
			listOfErrors.add("Plesae enter an Effective from value.");
		if(this.pricecategory == null)
			listOfErrors.add("Please enter a Price Category value.");
		if(this.taxonomymap != null)
		{
			String[] listOfOtherErrors = this.taxonomymap.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.ispreactive == null)
			listOfErrors.add("isPreActive 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;
	
		ActivityContextPricingDetailsVo clone = new ActivityContextPricingDetailsVo(this.id, this.version);
		
		if(this.context == null)
			clone.context = null;
		else
			clone.context = (ims.core.vo.lookups.ProcedureContext)this.context.clone();
		clone.price = this.price;
		if(this.currency == null)
			clone.currency = null;
		else
			clone.currency = (ims.core.vo.lookups.Currency)this.currency.clone();
		clone.normlengthstay = this.normlengthstay;
		if(this.effectivefrom == null)
			clone.effectivefrom = null;
		else
			clone.effectivefrom = (ims.framework.utils.Date)this.effectivefrom.clone();
		if(this.effectiveto == null)
			clone.effectiveto = null;
		else
			clone.effectiveto = (ims.framework.utils.Date)this.effectiveto.clone();
		clone.isactive = this.isactive;
		if(this.pricecategory == null)
			clone.pricecategory = null;
		else
			clone.pricecategory = (ims.ntpf.vo.lookups.PatientType)this.pricecategory.clone();
		if(this.taxonomymap == null)
			clone.taxonomymap = null;
		else
			clone.taxonomymap = (ims.core.vo.TaxonomyMapCollection)this.taxonomymap.clone();
		clone.ispreactive = this.ispreactive;
		if(this.effectivetoset == null)
			clone.effectivetoset = null;
		else
			clone.effectivetoset = (ims.framework.utils.Date)this.effectivetoset.clone();
		if(this.creatingbatch == null)
			clone.creatingbatch = null;
		else
			clone.creatingbatch = (ims.core.vo.BatchPricingShortVo)this.creatingbatch.clone();
		if(this.effectivefromset == null)
			clone.effectivefromset = null;
		else
			clone.effectivefromset = (ims.framework.utils.Date)this.effectivefromset.clone();
		clone.activepricing = this.activepricing;
		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 (!(ActivityContextPricingDetailsVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A ActivityContextPricingDetailsVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		ActivityContextPricingDetailsVo compareObj = (ActivityContextPricingDetailsVo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getID_ActivityContextPricingDetails() == null && compareObj.getID_ActivityContextPricingDetails() != null)
				return -1;
			if(this.getID_ActivityContextPricingDetails() != null && compareObj.getID_ActivityContextPricingDetails() == null)
				return 1;
			if(this.getID_ActivityContextPricingDetails() != null && compareObj.getID_ActivityContextPricingDetails() != null)
				retVal = this.getID_ActivityContextPricingDetails().compareTo(compareObj.getID_ActivityContextPricingDetails());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.context != null)
			count++;
		if(this.price != null)
			count++;
		if(this.currency != null)
			count++;
		if(this.normlengthstay != null)
			count++;
		if(this.effectivefrom != null)
			count++;
		if(this.effectiveto != null)
			count++;
		if(this.isactive != null)
			count++;
		if(this.pricecategory != null)
			count++;
		if(this.taxonomymap != null)
			count++;
		if(this.ispreactive != null)
			count++;
		if(this.effectivetoset != null)
			count++;
		if(this.creatingbatch != null)
			count++;
		if(this.effectivefromset != null)
			count++;
		if(this.activepricing != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 14;
	}
	protected ims.core.vo.lookups.ProcedureContext context;
	protected Float price;
	protected ims.core.vo.lookups.Currency currency;
	protected Integer normlengthstay;
	protected ims.framework.utils.Date effectivefrom;
	protected ims.framework.utils.Date effectiveto;
	protected Boolean isactive;
	protected ims.ntpf.vo.lookups.PatientType pricecategory;
	protected ims.core.vo.TaxonomyMapCollection taxonomymap;
	protected Boolean ispreactive;
	protected ims.framework.utils.Date effectivetoset;
	protected ims.core.vo.BatchPricingShortVo creatingbatch;
	protected ims.framework.utils.Date effectivefromset;
	protected ims.core.clinical.vo.ActivityContextPricingDetailsRefVo activepricing;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
