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