001/* 002 * #%L 003 * HAPI FHIR JPA Server 004 * %% 005 * Copyright (C) 2014 - 2024 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.provider; 021 022import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoEncounter; 023import ca.uhn.fhir.jpa.model.util.JpaConstants; 024import ca.uhn.fhir.model.api.annotation.Description; 025import ca.uhn.fhir.model.valueset.BundleTypeEnum; 026import ca.uhn.fhir.rest.annotation.IdParam; 027import ca.uhn.fhir.rest.annotation.Operation; 028import ca.uhn.fhir.rest.annotation.OperationParam; 029import ca.uhn.fhir.rest.annotation.Sort; 030import ca.uhn.fhir.rest.api.Constants; 031import ca.uhn.fhir.rest.api.SortSpec; 032import ca.uhn.fhir.rest.api.server.IBundleProvider; 033import ca.uhn.fhir.rest.param.DateRangeParam; 034import org.hl7.fhir.instance.model.api.IBaseResource; 035import org.hl7.fhir.instance.model.api.IIdType; 036import org.hl7.fhir.instance.model.api.IPrimitiveType; 037 038public abstract class BaseJpaResourceProviderEncounter<T extends IBaseResource> extends BaseJpaResourceProvider<T> { 039 040 /** 041 * Encounter/123/$everything 042 */ 043 @Operation(name = JpaConstants.OPERATION_EVERYTHING, idempotent = true, bundleType = BundleTypeEnum.SEARCHSET) 044 public IBundleProvider EncounterInstanceEverything( 045 jakarta.servlet.http.HttpServletRequest theServletRequest, 046 @IdParam IIdType theId, 047 @Description( 048 formalDefinition = 049 "Results from this method are returned across multiple pages. This parameter controls the size of those pages.") 050 @OperationParam(name = Constants.PARAM_COUNT, typeName = "unsignedInt") 051 IPrimitiveType<Integer> theCount, 052 @Description( 053 formalDefinition = 054 "Results from this method are returned across multiple pages. This parameter controls the offset when fetching a page.") 055 @OperationParam(name = Constants.PARAM_OFFSET, typeName = "unsignedInt") 056 IPrimitiveType<Integer> theOffset, 057 @Description( 058 shortDefinition = 059 "Only return resources which were last updated as specified by the given range") 060 @OperationParam(name = Constants.PARAM_LASTUPDATED, min = 0, max = 1) 061 DateRangeParam theLastUpdated, 062 @Sort SortSpec theSortSpec) { 063 064 startRequest(theServletRequest); 065 try { 066 return ((IFhirResourceDaoEncounter<?>) getDao()) 067 .encounterInstanceEverything( 068 theServletRequest, theId, theCount, theOffset, theLastUpdated, theSortSpec); 069 } finally { 070 endRequest(theServletRequest); 071 } 072 } 073 074 /** 075 * /Encounter/$everything 076 */ 077 @Operation(name = JpaConstants.OPERATION_EVERYTHING, idempotent = true, bundleType = BundleTypeEnum.SEARCHSET) 078 public IBundleProvider EncounterTypeEverything( 079 jakarta.servlet.http.HttpServletRequest theServletRequest, 080 @Description( 081 formalDefinition = 082 "Results from this method are returned across multiple pages. This parameter controls the size of those pages.") 083 @OperationParam(name = Constants.PARAM_COUNT, typeName = "unsignedInt") 084 IPrimitiveType<Integer> theCount, 085 @Description( 086 formalDefinition = 087 "Results from this method are returned across multiple pages. This parameter controls the offset when fetching a page.") 088 @OperationParam(name = Constants.PARAM_OFFSET, typeName = "unsignedInt") 089 IPrimitiveType<Integer> theOffset, 090 @Description( 091 shortDefinition = 092 "Only return resources which were last updated as specified by the given range") 093 @OperationParam(name = Constants.PARAM_LASTUPDATED, min = 0, max = 1) 094 DateRangeParam theLastUpdated, 095 @Sort SortSpec theSortSpec) { 096 097 startRequest(theServletRequest); 098 try { 099 return ((IFhirResourceDaoEncounter<?>) getDao()) 100 .encounterTypeEverything(theServletRequest, theCount, theOffset, theLastUpdated, theSortSpec); 101 } finally { 102 endRequest(theServletRequest); 103 } 104 } 105}