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