/FileExtraction/Java_unseen/IMS-MAXIMS_openMAXIMS/Source Library/openmaxims_workspace/ValueObjects/src/ims/clinical/vo/HospitalAtNightPatientDetailVo.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.HospitalAtNightPatientDetail business object (ID: 1072100096).
 */
public class HospitalAtNightPatientDetailVo extends ims.clinical.vo.HospitalAtNightPatientDetailRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public HospitalAtNightPatientDetailVo()
	{
	}
	public HospitalAtNightPatientDetailVo(Integer id, int version)
	{
		super(id, version);
	}
	public HospitalAtNightPatientDetailVo(ims.clinical.vo.beans.HospitalAtNightPatientDetailVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.carecontext = bean.getCareContext() == null ? null : new ims.core.admin.vo.CareContextRefVo(new Integer(bean.getCareContext().getId()), bean.getCareContext().getVersion());
		this.patient = bean.getPatient() == null ? null : new ims.core.patient.vo.PatientRefVo(new Integer(bean.getPatient().getId()), bean.getPatient().getVersion());
		this.situation = bean.getSituation();
		this.background = bean.getBackground();
		this.assessment = bean.getAssessment();
		this.recommendation = bean.getRecommendation();
		this.mews = bean.getMEWS() == null ? null : ims.clinical.vo.lookups.MEWS.buildLookup(bean.getMEWS());
		this.typeofrequest = bean.getTypeOfRequest() == null ? null : ims.clinical.vo.lookups.HospitalAtNightRequestType.buildLookup(bean.getTypeOfRequest());
		this.clinicaltasks = ims.clinical.vo.lookups.HospitalAtNightClinicalTaskCollection.buildFromBeanCollection(bean.getClinicalTasks());
		this.requestingdatetime = bean.getRequestingDateTime() == null ? null : bean.getRequestingDateTime().buildDateTime();
		this.requestinghcp = bean.getRequestingHCP() == null ? null : bean.getRequestingHCP().buildVo();
		this.notes = ims.clinical.vo.HospitalAtNightNotesVoCollection.buildFromBeanCollection(bean.getNotes());
		this.wardwhenplacedonlist = bean.getWardWhenPlacedOnList() == null ? null : new ims.core.resource.place.vo.LocationRefVo(new Integer(bean.getWardWhenPlacedOnList().getId()), bean.getWardWhenPlacedOnList().getVersion());
		this.hospitalatnightlistanddates = bean.getHospitalAtNightListAndDates() == null ? null : new ims.clinical.vo.HospitalAtNightListandDatesRefVo(new Integer(bean.getHospitalAtNightListAndDates().getId()), bean.getHospitalAtNightListAndDates().getVersion());
		this.currentstatus = bean.getCurrentStatus() == null ? null : bean.getCurrentStatus().buildVo();
		this.statushistory = ims.clinical.vo.HospitalAtNightPatientDetailStatusVoCollection.buildFromBeanCollection(bean.getStatusHistory());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.clinical.vo.beans.HospitalAtNightPatientDetailVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.carecontext = bean.getCareContext() == null ? null : new ims.core.admin.vo.CareContextRefVo(new Integer(bean.getCareContext().getId()), bean.getCareContext().getVersion());
		this.patient = bean.getPatient() == null ? null : new ims.core.patient.vo.PatientRefVo(new Integer(bean.getPatient().getId()), bean.getPatient().getVersion());
		this.situation = bean.getSituation();
		this.background = bean.getBackground();
		this.assessment = bean.getAssessment();
		this.recommendation = bean.getRecommendation();
		this.mews = bean.getMEWS() == null ? null : ims.clinical.vo.lookups.MEWS.buildLookup(bean.getMEWS());
		this.typeofrequest = bean.getTypeOfRequest() == null ? null : ims.clinical.vo.lookups.HospitalAtNightRequestType.buildLookup(bean.getTypeOfRequest());
		this.clinicaltasks = ims.clinical.vo.lookups.HospitalAtNightClinicalTaskCollection.buildFromBeanCollection(bean.getClinicalTasks());
		this.requestingdatetime = bean.getRequestingDateTime() == null ? null : bean.getRequestingDateTime().buildDateTime();
		this.requestinghcp = bean.getRequestingHCP() == null ? null : bean.getRequestingHCP().buildVo(map);
		this.notes = ims.clinical.vo.HospitalAtNightNotesVoCollection.buildFromBeanCollection(bean.getNotes());
		this.wardwhenplacedonlist = bean.getWardWhenPlacedOnList() == null ? null : new ims.core.resource.place.vo.LocationRefVo(new Integer(bean.getWardWhenPlacedOnList().getId()), bean.getWardWhenPlacedOnList().getVersion());
		this.hospitalatnightlistanddates = bean.getHospitalAtNightListAndDates() == null ? null : new ims.clinical.vo.HospitalAtNightListandDatesRefVo(new Integer(bean.getHospitalAtNightListAndDates().getId()), bean.getHospitalAtNightListAndDates().getVersion());
		this.currentstatus = bean.getCurrentStatus() == null ? null : bean.getCurrentStatus().buildVo(map);
		this.statushistory = ims.clinical.vo.HospitalAtNightPatientDetailStatusVoCollection.buildFromBeanCollection(bean.getStatusHistory());
	}
	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.HospitalAtNightPatientDetailVoBean bean = null;
		if(map != null)
			bean = (ims.clinical.vo.beans.HospitalAtNightPatientDetailVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.clinical.vo.beans.HospitalAtNightPatientDetailVoBean();
			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("CARECONTEXT"))
			return getCareContext();
		if(fieldName.equals("PATIENT"))
			return getPatient();
		if(fieldName.equals("SITUATION"))
			return getSituation();
		if(fieldName.equals("BACKGROUND"))
			return getBackground();
		if(fieldName.equals("ASSESSMENT"))
			return getAssessment();
		if(fieldName.equals("RECOMMENDATION"))
			return getRecommendation();
		if(fieldName.equals("MEWS"))
			return getMEWS();
		if(fieldName.equals("TYPEOFREQUEST"))
			return getTypeOfRequest();
		if(fieldName.equals("CLINICALTASKS"))
			return getClinicalTasks();
		if(fieldName.equals("REQUESTINGDATETIME"))
			return getRequestingDateTime();
		if(fieldName.equals("REQUESTINGHCP"))
			return getRequestingHCP();
		if(fieldName.equals("NOTES"))
			return getNotes();
		if(fieldName.equals("WARDWHENPLACEDONLIST"))
			return getWardWhenPlacedOnList();
		if(fieldName.equals("HOSPITALATNIGHTLISTANDDATES"))
			return getHospitalAtNightListAndDates();
		if(fieldName.equals("CURRENTSTATUS"))
			return getCurrentStatus();
		if(fieldName.equals("STATUSHISTORY"))
			return getStatusHistory();
		return super.getFieldValueByFieldName(fieldName);
	}
	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 getPatientIsNotNull()
	{
		return this.patient != null;
	}
	public ims.core.patient.vo.PatientRefVo getPatient()
	{
		return this.patient;
	}
	public void setPatient(ims.core.patient.vo.PatientRefVo value)
	{
		this.isValidated = false;
		this.patient = value;
	}
	public boolean getSituationIsNotNull()
	{
		return this.situation != null;
	}
	public String getSituation()
	{
		return this.situation;
	}
	public static int getSituationMaxLength()
	{
		return 150;
	}
	public void setSituation(String value)
	{
		this.isValidated = false;
		this.situation = value;
	}
	public boolean getBackgroundIsNotNull()
	{
		return this.background != null;
	}
	public String getBackground()
	{
		return this.background;
	}
	public static int getBackgroundMaxLength()
	{
		return 250;
	}
	public void setBackground(String value)
	{
		this.isValidated = false;
		this.background = value;
	}
	public boolean getAssessmentIsNotNull()
	{
		return this.assessment != null;
	}
	public String getAssessment()
	{
		return this.assessment;
	}
	public static int getAssessmentMaxLength()
	{
		return 250;
	}
	public void setAssessment(String value)
	{
		this.isValidated = false;
		this.assessment = value;
	}
	public boolean getRecommendationIsNotNull()
	{
		return this.recommendation != null;
	}
	public String getRecommendation()
	{
		return this.recommendation;
	}
	public static int getRecommendationMaxLength()
	{
		return 250;
	}
	public void setRecommendation(String value)
	{
		this.isValidated = false;
		this.recommendation = value;
	}
	public boolean getMEWSIsNotNull()
	{
		return this.mews != null;
	}
	public ims.clinical.vo.lookups.MEWS getMEWS()
	{
		return this.mews;
	}
	public void setMEWS(ims.clinical.vo.lookups.MEWS value)
	{
		this.isValidated = false;
		this.mews = value;
	}
	public boolean getTypeOfRequestIsNotNull()
	{
		return this.typeofrequest != null;
	}
	public ims.clinical.vo.lookups.HospitalAtNightRequestType getTypeOfRequest()
	{
		return this.typeofrequest;
	}
	public void setTypeOfRequest(ims.clinical.vo.lookups.HospitalAtNightRequestType value)
	{
		this.isValidated = false;
		this.typeofrequest = value;
	}
	public boolean getClinicalTasksIsNotNull()
	{
		return this.clinicaltasks != null;
	}
	public ims.clinical.vo.lookups.HospitalAtNightClinicalTaskCollection getClinicalTasks()
	{
		return this.clinicaltasks;
	}
	public void setClinicalTasks(ims.clinical.vo.lookups.HospitalAtNightClinicalTaskCollection value)
	{
		this.isValidated = false;
		this.clinicaltasks = value;
	}
	public boolean getRequestingDateTimeIsNotNull()
	{
		return this.requestingdatetime != null;
	}
	public ims.framework.utils.DateTime getRequestingDateTime()
	{
		return this.requestingdatetime;
	}
	public void setRequestingDateTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.requestingdatetime = value;
	}
	public boolean getRequestingHCPIsNotNull()
	{
		return this.requestinghcp != null;
	}
	public ims.core.vo.HcpLiteVo getRequestingHCP()
	{
		return this.requestinghcp;
	}
	public void setRequestingHCP(ims.core.vo.HcpLiteVo value)
	{
		this.isValidated = false;
		this.requestinghcp = value;
	}
	public boolean getNotesIsNotNull()
	{
		return this.notes != null;
	}
	public ims.clinical.vo.HospitalAtNightNotesVoCollection getNotes()
	{
		return this.notes;
	}
	public void setNotes(ims.clinical.vo.HospitalAtNightNotesVoCollection value)
	{
		this.isValidated = false;
		this.notes = value;
	}
	public boolean getWardWhenPlacedOnListIsNotNull()
	{
		return this.wardwhenplacedonlist != null;
	}
	public ims.core.resource.place.vo.LocationRefVo getWardWhenPlacedOnList()
	{
		return this.wardwhenplacedonlist;
	}
	public void setWardWhenPlacedOnList(ims.core.resource.place.vo.LocationRefVo value)
	{
		this.isValidated = false;
		this.wardwhenplacedonlist = value;
	}
	public boolean getHospitalAtNightListAndDatesIsNotNull()
	{
		return this.hospitalatnightlistanddates != null;
	}
	public ims.clinical.vo.HospitalAtNightListandDatesRefVo getHospitalAtNightListAndDates()
	{
		return this.hospitalatnightlistanddates;
	}
	public void setHospitalAtNightListAndDates(ims.clinical.vo.HospitalAtNightListandDatesRefVo value)
	{
		this.isValidated = false;
		this.hospitalatnightlistanddates = value;
	}
	public boolean getCurrentStatusIsNotNull()
	{
		return this.currentstatus != null;
	}
	public ims.clinical.vo.HospitalAtNightPatientDetailStatusVo getCurrentStatus()
	{
		return this.currentstatus;
	}
	public void setCurrentStatus(ims.clinical.vo.HospitalAtNightPatientDetailStatusVo value)
	{
		this.isValidated = false;
		this.currentstatus = value;
	}
	public boolean getStatusHistoryIsNotNull()
	{
		return this.statushistory != null;
	}
	public ims.clinical.vo.HospitalAtNightPatientDetailStatusVoCollection getStatusHistory()
	{
		return this.statushistory;
	}
	public void setStatusHistory(ims.clinical.vo.HospitalAtNightPatientDetailStatusVoCollection value)
	{
		this.isValidated = false;
		this.statushistory = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.notes != null)
		{
			if(!this.notes.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.currentstatus != null)
		{
			if(!this.currentstatus.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.statushistory != null)
		{
			if(!this.statushistory.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.carecontext == null)
			listOfErrors.add("CareContext is mandatory");
		if(this.patient == null)
			listOfErrors.add("Patient is mandatory");
		if(this.situation == null || this.situation.length() == 0)
			listOfErrors.add("Situation is mandatory");
		else if(this.situation.length() > 150)
			listOfErrors.add("The length of the field [situation] in the value object [ims.clinical.vo.HospitalAtNightPatientDetailVo] is too big. It should be less or equal to 150");
		if(this.background != null)
			if(this.background.length() > 250)
				listOfErrors.add("The length of the field [background] in the value object [ims.clinical.vo.HospitalAtNightPatientDetailVo] is too big. It should be less or equal to 250");
		if(this.assessment != null)
			if(this.assessment.length() > 250)
				listOfErrors.add("The length of the field [assessment] in the value object [ims.clinical.vo.HospitalAtNightPatientDetailVo] is too big. It should be less or equal to 250");
		if(this.recommendation == null || this.recommendation.length() == 0)
			listOfErrors.add("Recommendation is mandatory");
		else if(this.recommendation.length() > 250)
			listOfErrors.add("The length of the field [recommendation] in the value object [ims.clinical.vo.HospitalAtNightPatientDetailVo] is too big. It should be less or equal to 250");
		if(this.mews == null)
			listOfErrors.add("MEWS is mandatory");
		if(this.typeofrequest == null)
			listOfErrors.add("TypeOfRequest is mandatory");
		if(this.requestingdatetime == null)
			listOfErrors.add("RequestingDateTime is mandatory");
		if(this.requestinghcp == null)
			listOfErrors.add("RequestingHCP is mandatory");
		if(this.notes != null)
		{
			String[] listOfOtherErrors = this.notes.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.wardwhenplacedonlist == null)
			listOfErrors.add("WardWhenPlacedOnList is mandatory");
		if(this.hospitalatnightlistanddates == null)
			listOfErrors.add("HospitalAtNightListAndDates is mandatory");
		if(this.currentstatus == null)
			listOfErrors.add("CurrentStatus is mandatory");
		if(this.currentstatus != null)
		{
			String[] listOfOtherErrors = this.currentstatus.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.statushistory == null || this.statushistory.size() == 0)
			listOfErrors.add("StatusHistory are mandatory");
		if(this.statushistory != null)
		{
			String[] listOfOtherErrors = this.statushistory.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		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;
	
		HospitalAtNightPatientDetailVo clone = new HospitalAtNightPatientDetailVo(this.id, this.version);
		
		clone.carecontext = this.carecontext;
		clone.patient = this.patient;
		clone.situation = this.situation;
		clone.background = this.background;
		clone.assessment = this.assessment;
		clone.recommendation = this.recommendation;
		if(this.mews == null)
			clone.mews = null;
		else
			clone.mews = (ims.clinical.vo.lookups.MEWS)this.mews.clone();
		if(this.typeofrequest == null)
			clone.typeofrequest = null;
		else
			clone.typeofrequest = (ims.clinical.vo.lookups.HospitalAtNightRequestType)this.typeofrequest.clone();
		if(this.clinicaltasks == null)
			clone.clinicaltasks = null;
		else
			clone.clinicaltasks = (ims.clinical.vo.lookups.HospitalAtNightClinicalTaskCollection)this.clinicaltasks.clone();
		if(this.requestingdatetime == null)
			clone.requestingdatetime = null;
		else
			clone.requestingdatetime = (ims.framework.utils.DateTime)this.requestingdatetime.clone();
		if(this.requestinghcp == null)
			clone.requestinghcp = null;
		else
			clone.requestinghcp = (ims.core.vo.HcpLiteVo)this.requestinghcp.clone();
		if(this.notes == null)
			clone.notes = null;
		else
			clone.notes = (ims.clinical.vo.HospitalAtNightNotesVoCollection)this.notes.clone();
		clone.wardwhenplacedonlist = this.wardwhenplacedonlist;
		clone.hospitalatnightlistanddates = this.hospitalatnightlistanddates;
		if(this.currentstatus == null)
			clone.currentstatus = null;
		else
			clone.currentstatus = (ims.clinical.vo.HospitalAtNightPatientDetailStatusVo)this.currentstatus.clone();
		if(this.statushistory == null)
			clone.statushistory = null;
		else
			clone.statushistory = (ims.clinical.vo.HospitalAtNightPatientDetailStatusVoCollection)this.statushistory.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 (!(HospitalAtNightPatientDetailVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A HospitalAtNightPatientDetailVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((HospitalAtNightPatientDetailVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((HospitalAtNightPatientDetailVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.carecontext != null)
			count++;
		if(this.patient != null)
			count++;
		if(this.situation != null)
			count++;
		if(this.background != null)
			count++;
		if(this.assessment != null)
			count++;
		if(this.recommendation != null)
			count++;
		if(this.mews != null)
			count++;
		if(this.typeofrequest != null)
			count++;
		if(this.clinicaltasks != null)
			count++;
		if(this.requestingdatetime != null)
			count++;
		if(this.requestinghcp != null)
			count++;
		if(this.notes != null)
			count++;
		if(this.wardwhenplacedonlist != null)
			count++;
		if(this.hospitalatnightlistanddates != null)
			count++;
		if(this.currentstatus != null)
			count++;
		if(this.statushistory != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 16;
	}
	protected ims.core.admin.vo.CareContextRefVo carecontext;
	protected ims.core.patient.vo.PatientRefVo patient;
	protected String situation;
	protected String background;
	protected String assessment;
	protected String recommendation;
	protected ims.clinical.vo.lookups.MEWS mews;
	protected ims.clinical.vo.lookups.HospitalAtNightRequestType typeofrequest;
	protected ims.clinical.vo.lookups.HospitalAtNightClinicalTaskCollection clinicaltasks;
	protected ims.framework.utils.DateTime requestingdatetime;
	protected ims.core.vo.HcpLiteVo requestinghcp;
	protected ims.clinical.vo.HospitalAtNightNotesVoCollection notes;
	protected ims.core.resource.place.vo.LocationRefVo wardwhenplacedonlist;
	protected ims.clinical.vo.HospitalAtNightListandDatesRefVo hospitalatnightlistanddates;
	protected ims.clinical.vo.HospitalAtNightPatientDetailStatusVo currentstatus;
	protected ims.clinical.vo.HospitalAtNightPatientDetailStatusVoCollection statushistory;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
