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.*;
24  import org.hl7.fhir.dstu3.model.Observation;
25  import org.hl7.fhir.dstu3.model.ResourceType;
26  import org.hl7.fhir.instance.model.api.IAnyResource;
27  
28  import javax.servlet.http.HttpServletRequest;
29  import javax.servlet.http.HttpServletResponse;
30  import java.util.Set;
31  
32  /**
33   * Observation Resource Provider for QEDm (PCC-44)
34   *
35   * @author Christian Ohr
36   * @since 3.5
37   */
38  public class ObservationResourceProvider extends AbstractPcc44ResourceProvider<Observation> {
39  
40      public ObservationResourceProvider() {
41          super(Observation.class);
42      }
43  
44      @SuppressWarnings("unused")
45      @Search
46      public IBundleProvider search(
47              @RequiredParam(name = Observation.SP_PATIENT) ReferenceParam patient,
48              @OptionalParam(name = Observation.SP_CATEGORY) TokenAndListParam category,
49              @OptionalParam(name = Observation.SP_CODE) TokenOrListParam code,
50              @OptionalParam(name = Observation.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          ObservationSearchParameters parameters = ObservationSearchParameters.builder()
61                  .patientReference(patient)
62                  .date(date)
63                  .code(code)
64                  .category(category)
65                  ._id(resourceId)
66                  .sortSpec(sortSpec)
67                  .includeSpec(includeSpec)
68                  .revIncludeSpec(revIncludeSpec)
69                  .fhirContext(getFhirContext())
70                  .build();
71  
72          // Run down the route
73          return requestBundleProvider(null, parameters, ResourceType.Observation.name(), httpServletRequest, httpServletResponse);
74      }
75  
76  
77  }