View Javadoc
1   /*
2    * Copyright 2018 the original author or authors.
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *         http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  
17  package org.openehealth.ipf.commons.ihe.fhir.pcc44;
18  
19  import ca.uhn.fhir.model.api.Include;
20  import ca.uhn.fhir.rest.annotation.*;
21  import ca.uhn.fhir.rest.api.SortSpec;
22  import ca.uhn.fhir.rest.api.server.IBundleProvider;
23  import ca.uhn.fhir.rest.param.DateRangeParam;
24  import ca.uhn.fhir.rest.param.ReferenceParam;
25  import ca.uhn.fhir.rest.param.TokenParam;
26  import org.hl7.fhir.dstu3.model.Encounter;
27  import org.hl7.fhir.dstu3.model.ResourceType;
28  import org.hl7.fhir.instance.model.api.IAnyResource;
29  
30  import javax.servlet.http.HttpServletRequest;
31  import javax.servlet.http.HttpServletResponse;
32  import java.util.Set;
33  
34  /**
35   * Encounter Resource Provider for QEDm (PCC-44)
36   *
37   * @author Christian Ohr
38   * @since 3.5
39   */
40  public class EncounterResourceProvider extends AbstractPcc44ResourceProvider<Encounter> {
41  
42      public EncounterResourceProvider() {
43          super(Encounter.class);
44      }
45  
46      @SuppressWarnings("unused")
47      @Search
48      public IBundleProvider search(
49              @RequiredParam(name = Encounter.SP_PATIENT) ReferenceParam patient,
50              @OptionalParam(name = Encounter.SP_DATE) DateRangeParam date,
51              // Extension
52              @OptionalParam(name = IAnyResource.SP_RES_ID) TokenParam resourceId,
53              @Sort SortSpec sortSpec,
54              @IncludeParam Set<Include> includeSpec,
55              @IncludeParam(reverse = true) Set<Include> revIncludeSpec,
56              HttpServletRequest httpServletRequest,
57              HttpServletResponse httpServletResponse) {
58  
59  
60          EncounterSearchParameters parameters = EncounterSearchParameters.builder()
61                  .patientReference(patient)
62                  .date(date)
63                  ._id(resourceId)
64                  .sortSpec(sortSpec)
65                  .includeSpec(includeSpec)
66                  .revIncludeSpec(revIncludeSpec)
67                  .fhirContext(getFhirContext())
68                  .build();
69  
70          // Run down the route
71          return requestBundleProvider(null, parameters, ResourceType.Encounter.name(), httpServletRequest, httpServletResponse);
72      }
73  
74  }