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.ReferenceParam;
24  import ca.uhn.fhir.rest.param.TokenParam;
25  import org.hl7.fhir.dstu3.model.AllergyIntolerance;
26  import org.hl7.fhir.dstu3.model.ResourceType;
27  import org.hl7.fhir.instance.model.api.IAnyResource;
28  
29  import javax.servlet.http.HttpServletRequest;
30  import javax.servlet.http.HttpServletResponse;
31  import java.util.Set;
32  
33  /**
34   * AllergyIntolerance Resource Provider for QEDm (PCC-44)
35   *
36   * @author Christian Ohr
37   * @since 3.5
38   */
39  public class AllergyIntoleranceResourceProvider extends AbstractPcc44ResourceProvider<AllergyIntolerance> {
40  
41      public AllergyIntoleranceResourceProvider() {
42          super(AllergyIntolerance.class);
43      }
44  
45      @SuppressWarnings("unused")
46      @Search
47      public IBundleProvider search(
48              @RequiredParam(name = AllergyIntolerance.SP_PATIENT) ReferenceParam patient,
49              // Extension
50              @OptionalParam(name = IAnyResource.SP_RES_ID) TokenParam resourceId,
51              @Sort SortSpec sortSpec,
52              @IncludeParam Set<Include> includeSpec,
53              @IncludeParam(reverse = true) Set<Include> revIncludeSpec,
54              HttpServletRequest httpServletRequest,
55              HttpServletResponse httpServletResponse) {
56  
57          AllergyIntoleranceSearchParameters parameters = AllergyIntoleranceSearchParameters.builder()
58                  .patientReference(patient)
59                  ._id(resourceId)
60                  .sortSpec(sortSpec)
61                  .includeSpec(includeSpec)
62                  .revIncludeSpec(revIncludeSpec)
63                  .fhirContext(getFhirContext())
64                  .build();
65  
66          // Run down the route
67          return requestBundleProvider(null, parameters, ResourceType.AllergyIntolerance.name(), httpServletRequest, httpServletResponse);
68      }
69  
70  }