/FileExtraction/Java_unseen/IMS-MAXIMS_openMAXIMS/Source Library/openmaxims_workspace/Nursing/src/ims/nursing/domain/impl/CarePlanEvalutaionViewImpl.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 Rory Fitzpatrick using IMS Development Environment (version 1.22 build 41215.900)
// Copyright (C) 1995-2004 IMS MAXIMS plc. All rights reserved.

package ims.nursing.domain.impl;

import ims.core.admin.vo.CareContextRefVo;
import ims.domain.DomainFactory;
import ims.domain.impl.DomainImpl;
import ims.framework.exceptions.CodingRuntimeException;
import ims.framework.utils.Date;
import ims.nursing.vo.CarePlanEvaluationNoteListVoCollection;
import ims.nursing.vo.domain.CarePlanEvaluationNoteListVoAssembler;
import ims.nursing.vo.lookups.CarePlanStatus;

public class CarePlanEvalutaionViewImpl extends DomainImpl implements ims.nursing.domain.CarePlanEvalutaionView, ims.domain.impl.Transactional
{
	/**
	 * list all careplanevaluationnotes for the selecetd carecontext and only for active careplans
	 */
	private static final long serialVersionUID = 1L;

	public CarePlanEvaluationNoteListVoCollection listEvaluationNotesForActiveCarePlansByDateRange(CareContextRefVo voCareContext, Date dateFrom, Date dateTo, Boolean activeOnly)
	{
		if(voCareContext == null || voCareContext.getID_CareContext() == null || dateFrom == null || dateTo == null)
			throw new CodingRuntimeException("Mandatory parameters are null in method listEvaluationNotesForActiveCarePlans");
		
		String hql = "from CarePlanEvaluationNote note where note.carePlan.careContext.id = :idCareContext and note.carePlan.isRIE is null and note.carePlan.currentCarePlanStatus.status = :activeStatus and (note.recordedDateTime between :dateFrom and :dateTo) ";		
		if(activeOnly == true)
			hql += "and note.active = true";
		
		DomainFactory factory = getDomainFactory();
		return CarePlanEvaluationNoteListVoAssembler.createCarePlanEvaluationNoteListVoCollectionFromCarePlanEvaluationNote(factory.find(hql, new String[]{"idCareContext", "activeStatus", "dateFrom", "dateTo"}, new Object[]{voCareContext.getID_CareContext(), getDomLookup(CarePlanStatus.ACTIVE), dateFrom.getDate(), dateTo.copy().addDay(1).getDate()})).sort();
	}
}
