View Javadoc
1   package ca.uhn.fhir.jpa.dao;
2   
3   /*
4    * #%L
5    * HAPI FHIR JPA Server
6    * %%
7    * Copyright (C) 2014 - 2019 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 ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
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.searchparam.SearchParameterMap.EverythingModeEnum;
32  import ca.uhn.fhir.model.api.IResource;
33  import ca.uhn.fhir.model.dstu2.resource.Encounter;
34  import ca.uhn.fhir.rest.api.SortSpec;
35  import ca.uhn.fhir.rest.api.server.IBundleProvider;
36  import ca.uhn.fhir.rest.param.DateRangeParam;
37  import ca.uhn.fhir.rest.param.StringParam;
38  
39  public class FhirResourceDaoEncounterDstu2 extends FhirResourceDaoDstu2<Encounter>implements IFhirResourceDaoEncounter<Encounter> {
40  
41  	@Override
42  	public IBundleProvider encounterInstanceEverything(HttpServletRequest theServletRequest, IIdType theId, IPrimitiveType<Integer> theCount, DateRangeParam theLastUpdated, SortSpec theSort) {
43  		SearchParameterMap paramMap = new SearchParameterMap();
44  		if (theCount != null) {
45  			paramMap.setCount(theCount.getValue());
46  		}
47  
48  //		paramMap.setRevIncludes(Collections.singleton(IResource.INCLUDE_ALL.asRecursive()));
49  		paramMap.setIncludes(Collections.singleton(IResource.INCLUDE_ALL.asRecursive()));
50  		paramMap.setEverythingMode(theId != null ? EverythingModeEnum.ENCOUNTER_INSTANCE : EverythingModeEnum.ENCOUNTER_TYPE);
51  		paramMap.setSort(theSort);
52  		paramMap.setLastUpdated(theLastUpdated);
53  		if (theId != null) {
54  			paramMap.add("_id", new StringParam(theId.getIdPart()));
55  		}
56  		IBundleProvider retVal = search(paramMap);
57  		return retVal;
58  	}
59  
60  	@Override
61  	public IBundleProvider encounterTypeEverything(HttpServletRequest theServletRequest, IPrimitiveType<Integer> theCount, DateRangeParam theLastUpdated, SortSpec theSort) {
62  		return encounterInstanceEverything(theServletRequest, null, theCount, theLastUpdated, theSort);
63  	}
64  
65  }