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

/**
 * Linked to nursing.care plans.Care Plan Evaluation Note business object (ID: 1010100004).
 */
public class CarePlanEvaluationNote extends ims.nursing.careplans.vo.CarePlanEvaluationNoteRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public CarePlanEvaluationNote()
	{
	}
	public CarePlanEvaluationNote(Integer id, int version)
	{
		super(id, version);
	}
	public CarePlanEvaluationNote(ims.nursing.vo.beans.CarePlanEvaluationNoteBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.recordeddatetime = bean.getRecordedDateTime() == null ? null : bean.getRecordedDateTime().buildDateTime();
		this.recordedby = bean.getRecordedBy() == null ? null : bean.getRecordedBy().buildVo();
		this.nextevaluationdate = bean.getNextEvaluationDate() == null ? null : bean.getNextEvaluationDate().buildDate();
		this.nextevaluationtime = bean.getNextEvaluationTime() == null ? null : bean.getNextEvaluationTime().buildTime();
		this.note = bean.getNote();
		this.correctedby = bean.getCorrectedBy() == null ? null : bean.getCorrectedBy().buildVo();
		this.correctiondatetime = bean.getCorrectionDateTime() == null ? null : bean.getCorrectionDateTime().buildDateTime();
		this.correctionreason = bean.getCorrectionReason();
		this.active = bean.getActive();
		this.confirmedby = bean.getConfirmedBy() == null ? null : new ims.core.resource.people.vo.HcpRefVo(new Integer(bean.getConfirmedBy().getId()), bean.getConfirmedBy().getVersion());
		this.confirmeddatetime = bean.getConfirmedDateTime() == null ? null : bean.getConfirmedDateTime().buildDateTime();
		this.careplan = bean.getCarePlan() == null ? null : new ims.nursing.careplans.vo.CarePlanRefVo(new Integer(bean.getCarePlan().getId()), bean.getCarePlan().getVersion());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.nursing.vo.beans.CarePlanEvaluationNoteBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.recordeddatetime = bean.getRecordedDateTime() == null ? null : bean.getRecordedDateTime().buildDateTime();
		this.recordedby = bean.getRecordedBy() == null ? null : bean.getRecordedBy().buildVo(map);
		this.nextevaluationdate = bean.getNextEvaluationDate() == null ? null : bean.getNextEvaluationDate().buildDate();
		this.nextevaluationtime = bean.getNextEvaluationTime() == null ? null : bean.getNextEvaluationTime().buildTime();
		this.note = bean.getNote();
		this.correctedby = bean.getCorrectedBy() == null ? null : bean.getCorrectedBy().buildVo(map);
		this.correctiondatetime = bean.getCorrectionDateTime() == null ? null : bean.getCorrectionDateTime().buildDateTime();
		this.correctionreason = bean.getCorrectionReason();
		this.active = bean.getActive();
		this.confirmedby = bean.getConfirmedBy() == null ? null : new ims.core.resource.people.vo.HcpRefVo(new Integer(bean.getConfirmedBy().getId()), bean.getConfirmedBy().getVersion());
		this.confirmeddatetime = bean.getConfirmedDateTime() == null ? null : bean.getConfirmedDateTime().buildDateTime();
		this.careplan = bean.getCarePlan() == null ? null : new ims.nursing.careplans.vo.CarePlanRefVo(new Integer(bean.getCarePlan().getId()), bean.getCarePlan().getVersion());
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.nursing.vo.beans.CarePlanEvaluationNoteBean bean = null;
		if(map != null)
			bean = (ims.nursing.vo.beans.CarePlanEvaluationNoteBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.nursing.vo.beans.CarePlanEvaluationNoteBean();
			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("RECORDEDDATETIME"))
			return getRecordedDateTime();
		if(fieldName.equals("RECORDEDBY"))
			return getRecordedBy();
		if(fieldName.equals("NEXTEVALUATIONDATE"))
			return getNextEvaluationDate();
		if(fieldName.equals("NEXTEVALUATIONTIME"))
			return getNextEvaluationTime();
		if(fieldName.equals("NOTE"))
			return getNote();
		if(fieldName.equals("CORRECTEDBY"))
			return getCorrectedBy();
		if(fieldName.equals("CORRECTIONDATETIME"))
			return getCorrectionDateTime();
		if(fieldName.equals("CORRECTIONREASON"))
			return getCorrectionReason();
		if(fieldName.equals("ACTIVE"))
			return getActive();
		if(fieldName.equals("CONFIRMEDBY"))
			return getConfirmedBy();
		if(fieldName.equals("CONFIRMEDDATETIME"))
			return getConfirmedDateTime();
		if(fieldName.equals("CAREPLAN"))
			return getCarePlan();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getRecordedDateTimeIsNotNull()
	{
		return this.recordeddatetime != null;
	}
	public ims.framework.utils.DateTime getRecordedDateTime()
	{
		return this.recordeddatetime;
	}
	public void setRecordedDateTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.recordeddatetime = value;
	}
	public boolean getRecordedByIsNotNull()
	{
		return this.recordedby != null;
	}
	public ims.core.vo.HcpLiteVo getRecordedBy()
	{
		return this.recordedby;
	}
	public void setRecordedBy(ims.core.vo.HcpLiteVo value)
	{
		this.isValidated = false;
		this.recordedby = value;
	}
	public boolean getNextEvaluationDateIsNotNull()
	{
		return this.nextevaluationdate != null;
	}
	public ims.framework.utils.Date getNextEvaluationDate()
	{
		return this.nextevaluationdate;
	}
	public void setNextEvaluationDate(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.nextevaluationdate = value;
	}
	public boolean getNextEvaluationTimeIsNotNull()
	{
		return this.nextevaluationtime != null;
	}
	public ims.framework.utils.Time getNextEvaluationTime()
	{
		return this.nextevaluationtime;
	}
	public void setNextEvaluationTime(ims.framework.utils.Time value)
	{
		this.isValidated = false;
		this.nextevaluationtime = value;
	}
	public boolean getNoteIsNotNull()
	{
		return this.note != null;
	}
	public String getNote()
	{
		return this.note;
	}
	public static int getNoteMaxLength()
	{
		return 1000;
	}
	public void setNote(String value)
	{
		this.isValidated = false;
		this.note = value;
	}
	public boolean getCorrectedByIsNotNull()
	{
		return this.correctedby != null;
	}
	public ims.core.vo.HcpLiteVo getCorrectedBy()
	{
		return this.correctedby;
	}
	public void setCorrectedBy(ims.core.vo.HcpLiteVo value)
	{
		this.isValidated = false;
		this.correctedby = value;
	}
	public boolean getCorrectionDateTimeIsNotNull()
	{
		return this.correctiondatetime != null;
	}
	public ims.framework.utils.DateTime getCorrectionDateTime()
	{
		return this.correctiondatetime;
	}
	public void setCorrectionDateTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.correctiondatetime = value;
	}
	public boolean getCorrectionReasonIsNotNull()
	{
		return this.correctionreason != null;
	}
	public String getCorrectionReason()
	{
		return this.correctionreason;
	}
	public static int getCorrectionReasonMaxLength()
	{
		return 500;
	}
	public void setCorrectionReason(String value)
	{
		this.isValidated = false;
		this.correctionreason = value;
	}
	public boolean getActiveIsNotNull()
	{
		return this.active != null;
	}
	public Boolean getActive()
	{
		return this.active;
	}
	public void setActive(Boolean value)
	{
		this.isValidated = false;
		this.active = value;
	}
	public boolean getConfirmedByIsNotNull()
	{
		return this.confirmedby != null;
	}
	public ims.core.resource.people.vo.HcpRefVo getConfirmedBy()
	{
		return this.confirmedby;
	}
	public void setConfirmedBy(ims.core.resource.people.vo.HcpRefVo value)
	{
		this.isValidated = false;
		this.confirmedby = value;
	}
	public boolean getConfirmedDateTimeIsNotNull()
	{
		return this.confirmeddatetime != null;
	}
	public ims.framework.utils.DateTime getConfirmedDateTime()
	{
		return this.confirmeddatetime;
	}
	public void setConfirmedDateTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.confirmeddatetime = value;
	}
	public boolean getCarePlanIsNotNull()
	{
		return this.careplan != null;
	}
	public ims.nursing.careplans.vo.CarePlanRefVo getCarePlan()
	{
		return this.careplan;
	}
	public void setCarePlan(ims.nursing.careplans.vo.CarePlanRefVo value)
	{
		this.isValidated = false;
		this.careplan = 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.note != null)
			if(this.note.length() > 1000)
				listOfErrors.add("The length of the field [note] in the value object [ims.nursing.vo.CarePlanEvaluationNote] is too big. It should be less or equal to 1000");
		if(this.correctionreason != null)
			if(this.correctionreason.length() > 500)
				listOfErrors.add("The length of the field [correctionreason] in the value object [ims.nursing.vo.CarePlanEvaluationNote] is too big. It should be less or equal to 500");
		if(this.careplan == null)
			listOfErrors.add("carePlan 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;
	
		CarePlanEvaluationNote clone = new CarePlanEvaluationNote(this.id, this.version);
		
		if(this.recordeddatetime == null)
			clone.recordeddatetime = null;
		else
			clone.recordeddatetime = (ims.framework.utils.DateTime)this.recordeddatetime.clone();
		if(this.recordedby == null)
			clone.recordedby = null;
		else
			clone.recordedby = (ims.core.vo.HcpLiteVo)this.recordedby.clone();
		if(this.nextevaluationdate == null)
			clone.nextevaluationdate = null;
		else
			clone.nextevaluationdate = (ims.framework.utils.Date)this.nextevaluationdate.clone();
		if(this.nextevaluationtime == null)
			clone.nextevaluationtime = null;
		else
			clone.nextevaluationtime = (ims.framework.utils.Time)this.nextevaluationtime.clone();
		clone.note = this.note;
		if(this.correctedby == null)
			clone.correctedby = null;
		else
			clone.correctedby = (ims.core.vo.HcpLiteVo)this.correctedby.clone();
		if(this.correctiondatetime == null)
			clone.correctiondatetime = null;
		else
			clone.correctiondatetime = (ims.framework.utils.DateTime)this.correctiondatetime.clone();
		clone.correctionreason = this.correctionreason;
		clone.active = this.active;
		clone.confirmedby = this.confirmedby;
		if(this.confirmeddatetime == null)
			clone.confirmeddatetime = null;
		else
			clone.confirmeddatetime = (ims.framework.utils.DateTime)this.confirmeddatetime.clone();
		clone.careplan = this.careplan;
		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 (!(CarePlanEvaluationNote.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A CarePlanEvaluationNote object cannot be compared an Object of type " + obj.getClass().getName());
		}
		CarePlanEvaluationNote compareObj = (CarePlanEvaluationNote)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getRecordedDateTime() == null && compareObj.getRecordedDateTime() != null)
				return -1;
			if(this.getRecordedDateTime() != null && compareObj.getRecordedDateTime() == null)
				return 1;
			if(this.getRecordedDateTime() != null && compareObj.getRecordedDateTime() != null)
				retVal = this.getRecordedDateTime().compareTo(compareObj.getRecordedDateTime());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.recordeddatetime != null)
			count++;
		if(this.recordedby != null)
			count++;
		if(this.nextevaluationdate != null)
			count++;
		if(this.nextevaluationtime != null)
			count++;
		if(this.note != null)
			count++;
		if(this.correctedby != null)
			count++;
		if(this.correctiondatetime != null)
			count++;
		if(this.correctionreason != null)
			count++;
		if(this.active != null)
			count++;
		if(this.confirmedby != null)
			count++;
		if(this.confirmeddatetime != null)
			count++;
		if(this.careplan != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 12;
	}
	protected ims.framework.utils.DateTime recordeddatetime;
	protected ims.core.vo.HcpLiteVo recordedby;
	protected ims.framework.utils.Date nextevaluationdate;
	protected ims.framework.utils.Time nextevaluationtime;
	protected String note;
	protected ims.core.vo.HcpLiteVo correctedby;
	protected ims.framework.utils.DateTime correctiondatetime;
	protected String correctionreason;
	protected Boolean active;
	protected ims.core.resource.people.vo.HcpRefVo confirmedby;
	protected ims.framework.utils.DateTime confirmeddatetime;
	protected ims.nursing.careplans.vo.CarePlanRefVo careplan;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
