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