
001/* 002 * #%L 003 * HAPI FHIR JPA Server 004 * %% 005 * Copyright (C) 2014 - 2025 Smile CDR, Inc. 006 * %% 007 * Licensed under the Apache License, Version 2.0 (the "License"); 008 * you may not use this file except in compliance with the License. 009 * You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 * #L% 019 */ 020package ca.uhn.fhir.jpa.dao; 021 022import ca.uhn.fhir.i18n.Msg; 023import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoEncounter; 024import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; 025import ca.uhn.fhir.jpa.searchparam.SearchParameterMap.EverythingModeEnum; 026import ca.uhn.fhir.rest.api.SortSpec; 027import ca.uhn.fhir.rest.api.server.IBundleProvider; 028import ca.uhn.fhir.rest.api.server.RequestDetails; 029import ca.uhn.fhir.rest.param.DateRangeParam; 030import ca.uhn.fhir.rest.param.StringParam; 031import org.hl7.fhir.instance.model.api.IBaseResource; 032import org.hl7.fhir.instance.model.api.IIdType; 033import org.hl7.fhir.instance.model.api.IPrimitiveType; 034 035import java.util.Collections; 036 037public class JpaResourceDaoEncounter<T extends IBaseResource> extends BaseHapiFhirResourceDao<T> 038 implements IFhirResourceDaoEncounter<T> { 039 040 @Override 041 public IBundleProvider encounterInstanceEverything( 042 RequestDetails theRequest, 043 IIdType theId, 044 IPrimitiveType<Integer> theCount, 045 IPrimitiveType<Integer> theOffset, 046 DateRangeParam theLastUpdated, 047 SortSpec theSort) { 048 049 SearchParameterMap paramMap = new SearchParameterMap(); 050 if (theCount != null) { 051 paramMap.setCount(theCount.getValue()); 052 } 053 if (theOffset != null) { 054 throw new IllegalArgumentException( 055 Msg.code(1128) + "Everything operation does not support offset searching"); 056 } 057 058 // paramMap.setRevIncludes(Collections.singleton(IResource.INCLUDE_ALL.asRecursive())); 059 paramMap.setIncludes(Collections.singleton(IBaseResource.INCLUDE_ALL.asRecursive())); 060 paramMap.setEverythingMode( 061 theId != null ? EverythingModeEnum.ENCOUNTER_INSTANCE : EverythingModeEnum.ENCOUNTER_TYPE); 062 paramMap.setSort(theSort); 063 paramMap.setLastUpdated(theLastUpdated); 064 if (theId != null) { 065 paramMap.add("_id", new StringParam(theId.getIdPart())); 066 } 067 068 if (!isPagingProviderDatabaseBacked(theRequest)) { 069 paramMap.setLoadSynchronous(true); 070 } 071 072 return search(paramMap, theRequest); 073 } 074 075 @Override 076 public IBundleProvider encounterTypeEverything( 077 RequestDetails theRequest, 078 IPrimitiveType<Integer> theCount, 079 IPrimitiveType<Integer> theOffset, 080 DateRangeParam theLastUpdated, 081 SortSpec theSort) { 082 return encounterInstanceEverything(theRequest, null, theCount, theOffset, theLastUpdated, theSort); 083 } 084}