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

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

	public PatientCurrentConcernVo()
	{
	}
	public PatientCurrentConcernVo(Integer id, int version)
	{
		super(id, version);
	}
	public PatientCurrentConcernVo(ims.core.vo.beans.PatientCurrentConcernVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.assocproblem = ims.generalmedical.vo.MedicalProbOnAdmisVoCollection.buildFromBeanCollection(bean.getAssocProblem());
		this.concerndescription = bean.getConcernDescription();
		this.datetimeidentified = bean.getDateTimeIdentified() == null ? null : bean.getDateTimeIdentified().buildDateTime();
		this.teamidentified = bean.getTeamIdentified() == null ? null : ims.core.vo.lookups.HcpDisType.buildLookup(bean.getTeamIdentified());
		this.memberidentified = bean.getMemberIdentified() == null ? null : bean.getMemberIdentified().buildVo();
		this.associatednote = bean.getAssociatedNote();
		this.allocatedtoteam = bean.getAllocatedToTeam() == null ? null : ims.core.vo.lookups.HcpDisType.buildLookup(bean.getAllocatedToTeam());
		this.alloctoteammember = bean.getAllocToTeamMember() == null ? null : bean.getAllocToTeamMember().buildVo();
		this.datetimeallocated = bean.getDateTimeAllocated() == null ? null : bean.getDateTimeAllocated().buildDateTime();
		this.concernstatus = bean.getConcernStatus() == null ? null : ims.core.vo.lookups.PatientConcernStatus.buildLookup(bean.getConcernStatus());
		this.recordinghcp = bean.getRecordingHCP() == null ? null : bean.getRecordingHCP().buildVo();
		this.updatinghcp = bean.getUpdatingHCP() == null ? null : bean.getUpdatingHCP().buildVo();
		this.sysinfo = bean.getSysInfo() == null ? null : bean.getSysInfo().buildSystemInformation();
		this.carecontext = bean.getCareContext() == null ? null : new ims.core.admin.vo.CareContextRefVo(new Integer(bean.getCareContext().getId()), bean.getCareContext().getVersion());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.PatientCurrentConcernVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.assocproblem = ims.generalmedical.vo.MedicalProbOnAdmisVoCollection.buildFromBeanCollection(bean.getAssocProblem());
		this.concerndescription = bean.getConcernDescription();
		this.datetimeidentified = bean.getDateTimeIdentified() == null ? null : bean.getDateTimeIdentified().buildDateTime();
		this.teamidentified = bean.getTeamIdentified() == null ? null : ims.core.vo.lookups.HcpDisType.buildLookup(bean.getTeamIdentified());
		this.memberidentified = bean.getMemberIdentified() == null ? null : bean.getMemberIdentified().buildVo(map);
		this.associatednote = bean.getAssociatedNote();
		this.allocatedtoteam = bean.getAllocatedToTeam() == null ? null : ims.core.vo.lookups.HcpDisType.buildLookup(bean.getAllocatedToTeam());
		this.alloctoteammember = bean.getAllocToTeamMember() == null ? null : bean.getAllocToTeamMember().buildVo(map);
		this.datetimeallocated = bean.getDateTimeAllocated() == null ? null : bean.getDateTimeAllocated().buildDateTime();
		this.concernstatus = bean.getConcernStatus() == null ? null : ims.core.vo.lookups.PatientConcernStatus.buildLookup(bean.getConcernStatus());
		this.recordinghcp = bean.getRecordingHCP() == null ? null : bean.getRecordingHCP().buildVo(map);
		this.updatinghcp = bean.getUpdatingHCP() == null ? null : bean.getUpdatingHCP().buildVo(map);
		this.sysinfo = bean.getSysInfo() == null ? null : bean.getSysInfo().buildSystemInformation();
		this.carecontext = bean.getCareContext() == null ? null : new ims.core.admin.vo.CareContextRefVo(new Integer(bean.getCareContext().getId()), bean.getCareContext().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.PatientCurrentConcernVoBean bean = null;
		if(map != null)
			bean = (ims.core.vo.beans.PatientCurrentConcernVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.core.vo.beans.PatientCurrentConcernVoBean();
			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("ASSOCPROBLEM"))
			return getAssocProblem();
		if(fieldName.equals("CONCERNDESCRIPTION"))
			return getConcernDescription();
		if(fieldName.equals("DATETIMEIDENTIFIED"))
			return getDateTimeIdentified();
		if(fieldName.equals("TEAMIDENTIFIED"))
			return getTeamIdentified();
		if(fieldName.equals("MEMBERIDENTIFIED"))
			return getMemberIdentified();
		if(fieldName.equals("ASSOCIATEDNOTE"))
			return getAssociatedNote();
		if(fieldName.equals("ALLOCATEDTOTEAM"))
			return getAllocatedToTeam();
		if(fieldName.equals("ALLOCTOTEAMMEMBER"))
			return getAllocToTeamMember();
		if(fieldName.equals("DATETIMEALLOCATED"))
			return getDateTimeAllocated();
		if(fieldName.equals("CONCERNSTATUS"))
			return getConcernStatus();
		if(fieldName.equals("RECORDINGHCP"))
			return getRecordingHCP();
		if(fieldName.equals("UPDATINGHCP"))
			return getUpdatingHCP();
		if(fieldName.equals("SYSINFO"))
			return getSysInfo();
		if(fieldName.equals("CARECONTEXT"))
			return getCareContext();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getAssocProblemIsNotNull()
	{
		return this.assocproblem != null;
	}
	public ims.generalmedical.vo.MedicalProbOnAdmisVoCollection getAssocProblem()
	{
		return this.assocproblem;
	}
	public void setAssocProblem(ims.generalmedical.vo.MedicalProbOnAdmisVoCollection value)
	{
		this.isValidated = false;
		this.assocproblem = value;
	}
	public boolean getConcernDescriptionIsNotNull()
	{
		return this.concerndescription != null;
	}
	public String getConcernDescription()
	{
		return this.concerndescription;
	}
	public static int getConcernDescriptionMaxLength()
	{
		return 100;
	}
	public void setConcernDescription(String value)
	{
		this.isValidated = false;
		this.concerndescription = value;
	}
	public boolean getDateTimeIdentifiedIsNotNull()
	{
		return this.datetimeidentified != null;
	}
	public ims.framework.utils.DateTime getDateTimeIdentified()
	{
		return this.datetimeidentified;
	}
	public void setDateTimeIdentified(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.datetimeidentified = value;
	}
	public boolean getTeamIdentifiedIsNotNull()
	{
		return this.teamidentified != null;
	}
	public ims.core.vo.lookups.HcpDisType getTeamIdentified()
	{
		return this.teamidentified;
	}
	public void setTeamIdentified(ims.core.vo.lookups.HcpDisType value)
	{
		this.isValidated = false;
		this.teamidentified = value;
	}
	public boolean getMemberIdentifiedIsNotNull()
	{
		return this.memberidentified != null;
	}
	public ims.core.vo.Hcp getMemberIdentified()
	{
		return this.memberidentified;
	}
	public void setMemberIdentified(ims.core.vo.Hcp value)
	{
		this.isValidated = false;
		this.memberidentified = value;
	}
	public boolean getAssociatedNoteIsNotNull()
	{
		return this.associatednote != null;
	}
	public String getAssociatedNote()
	{
		return this.associatednote;
	}
	public static int getAssociatedNoteMaxLength()
	{
		return 1000;
	}
	public void setAssociatedNote(String value)
	{
		this.isValidated = false;
		this.associatednote = value;
	}
	public boolean getAllocatedToTeamIsNotNull()
	{
		return this.allocatedtoteam != null;
	}
	public ims.core.vo.lookups.HcpDisType getAllocatedToTeam()
	{
		return this.allocatedtoteam;
	}
	public void setAllocatedToTeam(ims.core.vo.lookups.HcpDisType value)
	{
		this.isValidated = false;
		this.allocatedtoteam = value;
	}
	public boolean getAllocToTeamMemberIsNotNull()
	{
		return this.alloctoteammember != null;
	}
	public ims.core.vo.Hcp getAllocToTeamMember()
	{
		return this.alloctoteammember;
	}
	public void setAllocToTeamMember(ims.core.vo.Hcp value)
	{
		this.isValidated = false;
		this.alloctoteammember = value;
	}
	public boolean getDateTimeAllocatedIsNotNull()
	{
		return this.datetimeallocated != null;
	}
	public ims.framework.utils.DateTime getDateTimeAllocated()
	{
		return this.datetimeallocated;
	}
	public void setDateTimeAllocated(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.datetimeallocated = value;
	}
	public boolean getConcernStatusIsNotNull()
	{
		return this.concernstatus != null;
	}
	public ims.core.vo.lookups.PatientConcernStatus getConcernStatus()
	{
		return this.concernstatus;
	}
	public void setConcernStatus(ims.core.vo.lookups.PatientConcernStatus value)
	{
		this.isValidated = false;
		this.concernstatus = value;
	}
	public boolean getRecordingHCPIsNotNull()
	{
		return this.recordinghcp != null;
	}
	public ims.core.vo.Hcp getRecordingHCP()
	{
		return this.recordinghcp;
	}
	public void setRecordingHCP(ims.core.vo.Hcp value)
	{
		this.isValidated = false;
		this.recordinghcp = value;
	}
	public boolean getUpdatingHCPIsNotNull()
	{
		return this.updatinghcp != null;
	}
	public ims.core.vo.Hcp getUpdatingHCP()
	{
		return this.updatinghcp;
	}
	public void setUpdatingHCP(ims.core.vo.Hcp value)
	{
		this.isValidated = false;
		this.updatinghcp = value;
	}
	public boolean getSysInfoIsNotNull()
	{
		return this.sysinfo != null;
	}
	public ims.vo.SystemInformation getSysInfo()
	{
		return this.sysinfo;
	}
	public void setSysInfo(ims.vo.SystemInformation value)
	{
		this.isValidated = false;
		this.sysinfo = value;
	}
	public boolean getCareContextIsNotNull()
	{
		return this.carecontext != null;
	}
	public ims.core.admin.vo.CareContextRefVo getCareContext()
	{
		return this.carecontext;
	}
	public void setCareContext(ims.core.admin.vo.CareContextRefVo value)
	{
		this.isValidated = false;
		this.carecontext = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.assocproblem != null)
		{
			if(!this.assocproblem.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.memberidentified != null)
		{
			if(!this.memberidentified.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.alloctoteammember != null)
		{
			if(!this.alloctoteammember.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.recordinghcp != null)
		{
			if(!this.recordinghcp.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.updatinghcp != null)
		{
			if(!this.updatinghcp.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.assocproblem != null)
		{
			String[] listOfOtherErrors = this.assocproblem.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.concerndescription == null || this.concerndescription.length() == 0)
			listOfErrors.add("Concern/Action is a mandatory field");
		else if(this.concerndescription.length() > 100)
			listOfErrors.add("The length of the field [concerndescription] in the value object [ims.core.vo.PatientCurrentConcernVo] is too big. It should be less or equal to 100");
		if(this.memberidentified != null)
		{
			String[] listOfOtherErrors = this.memberidentified.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.associatednote != null)
			if(this.associatednote.length() > 1000)
				listOfErrors.add("The length of the field [associatednote] in the value object [ims.core.vo.PatientCurrentConcernVo] is too big. It should be less or equal to 1000");
		if(this.alloctoteammember != null)
		{
			String[] listOfOtherErrors = this.alloctoteammember.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.recordinghcp != null)
		{
			String[] listOfOtherErrors = this.recordinghcp.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.updatinghcp != null)
		{
			String[] listOfOtherErrors = this.updatinghcp.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.carecontext == null)
			listOfErrors.add("CareContext 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;
	
		PatientCurrentConcernVo clone = new PatientCurrentConcernVo(this.id, this.version);
		
		if(this.assocproblem == null)
			clone.assocproblem = null;
		else
			clone.assocproblem = (ims.generalmedical.vo.MedicalProbOnAdmisVoCollection)this.assocproblem.clone();
		clone.concerndescription = this.concerndescription;
		if(this.datetimeidentified == null)
			clone.datetimeidentified = null;
		else
			clone.datetimeidentified = (ims.framework.utils.DateTime)this.datetimeidentified.clone();
		if(this.teamidentified == null)
			clone.teamidentified = null;
		else
			clone.teamidentified = (ims.core.vo.lookups.HcpDisType)this.teamidentified.clone();
		if(this.memberidentified == null)
			clone.memberidentified = null;
		else
			clone.memberidentified = (ims.core.vo.Hcp)this.memberidentified.clone();
		clone.associatednote = this.associatednote;
		if(this.allocatedtoteam == null)
			clone.allocatedtoteam = null;
		else
			clone.allocatedtoteam = (ims.core.vo.lookups.HcpDisType)this.allocatedtoteam.clone();
		if(this.alloctoteammember == null)
			clone.alloctoteammember = null;
		else
			clone.alloctoteammember = (ims.core.vo.Hcp)this.alloctoteammember.clone();
		if(this.datetimeallocated == null)
			clone.datetimeallocated = null;
		else
			clone.datetimeallocated = (ims.framework.utils.DateTime)this.datetimeallocated.clone();
		if(this.concernstatus == null)
			clone.concernstatus = null;
		else
			clone.concernstatus = (ims.core.vo.lookups.PatientConcernStatus)this.concernstatus.clone();
		if(this.recordinghcp == null)
			clone.recordinghcp = null;
		else
			clone.recordinghcp = (ims.core.vo.Hcp)this.recordinghcp.clone();
		if(this.updatinghcp == null)
			clone.updatinghcp = null;
		else
			clone.updatinghcp = (ims.core.vo.Hcp)this.updatinghcp.clone();
		if(this.sysinfo == null)
			clone.sysinfo = null;
		else
			clone.sysinfo = (ims.vo.SystemInformation)this.sysinfo.clone();
		clone.carecontext = this.carecontext;
		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 (!(PatientCurrentConcernVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A PatientCurrentConcernVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		PatientCurrentConcernVo compareObj = (PatientCurrentConcernVo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getID_PatientConcern() == null && compareObj.getID_PatientConcern() != null)
				return -1;
			if(this.getID_PatientConcern() != null && compareObj.getID_PatientConcern() == null)
				return 1;
			if(this.getID_PatientConcern() != null && compareObj.getID_PatientConcern() != null)
				retVal = this.getID_PatientConcern().compareTo(compareObj.getID_PatientConcern());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.assocproblem != null)
			count++;
		if(this.concerndescription != null)
			count++;
		if(this.datetimeidentified != null)
			count++;
		if(this.teamidentified != null)
			count++;
		if(this.memberidentified != null)
			count++;
		if(this.associatednote != null)
			count++;
		if(this.allocatedtoteam != null)
			count++;
		if(this.alloctoteammember != null)
			count++;
		if(this.datetimeallocated != null)
			count++;
		if(this.concernstatus != null)
			count++;
		if(this.recordinghcp != null)
			count++;
		if(this.updatinghcp != null)
			count++;
		if(this.sysinfo != null)
			count++;
		if(this.carecontext != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 14;
	}
	protected ims.generalmedical.vo.MedicalProbOnAdmisVoCollection assocproblem;
	protected String concerndescription;
	protected ims.framework.utils.DateTime datetimeidentified;
	protected ims.core.vo.lookups.HcpDisType teamidentified;
	protected ims.core.vo.Hcp memberidentified;
	protected String associatednote;
	protected ims.core.vo.lookups.HcpDisType allocatedtoteam;
	protected ims.core.vo.Hcp alloctoteammember;
	protected ims.framework.utils.DateTime datetimeallocated;
	protected ims.core.vo.lookups.PatientConcernStatus concernstatus;
	protected ims.core.vo.Hcp recordinghcp;
	protected ims.core.vo.Hcp updatinghcp;
	protected ims.vo.SystemInformation sysinfo;
	protected ims.core.admin.vo.CareContextRefVo carecontext;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
