View Javadoc
1   package ca.uhn.fhir.jpa.dao.r4;
2   
3   /*
4    * #%L
5    * HAPI FHIR JPA Server
6    * %%
7    * Copyright (C) 2014 - 2018 University Health Network
8    * %%
9    * Licensed under the Apache License, Version 2.0 (the "License");
10   * you may not use this file except in compliance with the License.
11   * You may obtain a copy of the License at
12   * 
13   *      http://www.apache.org/licenses/LICENSE-2.0
14   * 
15   * Unless required by applicable law or agreed to in writing, software
16   * distributed under the License is distributed on an "AS IS" BASIS,
17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   * See the License for the specific language governing permissions and
19   * limitations under the License.
20   * #L%
21   */
22  
23  import java.util.Collections;
24  
25  import javax.servlet.http.HttpServletRequest;
26  
27  import org.hl7.fhir.r4.model.Encounter;
28  import org.hl7.fhir.instance.model.api.IIdType;
29  import org.hl7.fhir.instance.model.api.IPrimitiveType;
30  
31  import ca.uhn.fhir.jpa.dao.IFhirResourceDaoEncounter;
32  import ca.uhn.fhir.jpa.dao.SearchParameterMap;
33  import ca.uhn.fhir.jpa.dao.SearchParameterMap.EverythingModeEnum;
34  import ca.uhn.fhir.model.api.IResource;
35  import ca.uhn.fhir.rest.api.SortSpec;
36  import ca.uhn.fhir.rest.api.server.IBundleProvider;
37  import ca.uhn.fhir.rest.param.DateRangeParam;
38  import ca.uhn.fhir.rest.param.StringParam;
39  
40  public class FhirResourceDaoEncounterR4 extends FhirResourceDaoR4<Encounter>implements IFhirResourceDaoEncounter<Encounter> {
41  
42  	@Override
43  	public IBundleProvider encounterInstanceEverything(HttpServletRequest theServletRequest, IIdType theId, IPrimitiveType<Integer> theCount, DateRangeParam theLastUpdated, SortSpec theSort) {
44  		SearchParameterMap paramMap = new SearchParameterMap();
45  		if (theCount != null) {
46  			paramMap.setCount(theCount.getValue());
47  		}
48  
49  //		paramMap.setRevIncludes(Collections.singleton(IResource.INCLUDE_ALL.asRecursive()));
50  		paramMap.setIncludes(Collections.singleton(IResource.INCLUDE_ALL.asRecursive()));
51  		paramMap.setEverythingMode(theId != null ? EverythingModeEnum.ENCOUNTER_INSTANCE : EverythingModeEnum.ENCOUNTER_TYPE);
52  		paramMap.setSort(theSort);
53  		paramMap.setLastUpdated(theLastUpdated);
54  		if (theId != null) {
55  			paramMap.add("_id", new StringParam(theId.getIdPart()));
56  		}
57  		IBundleProvider retVal = search(paramMap);
58  		return retVal;
59  	}
60  
61  	@Override
62  	public IBundleProvider encounterTypeEverything(HttpServletRequest theServletRequest, IPrimitiveType<Integer> theCount, DateRangeParam theLastUpdated, SortSpec theSort) {
63  		return encounterInstanceEverything(theServletRequest, null, theCount, theLastUpdated, theSort);
64  	}
65  
66  }