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.context.FhirContext;
20  import ca.uhn.fhir.model.api.Include;
21  import ca.uhn.fhir.rest.api.SortSpec;
22  import ca.uhn.fhir.rest.param.*;
23  import lombok.*;
24  import org.openehealth.ipf.commons.ihe.fhir.FhirSearchParameters;
25  
26  import java.util.Collections;
27  import java.util.List;
28  import java.util.Set;
29  
30  /**
31   * @author Christian Ohr
32   * @since 3.5
33   */
34  @AllArgsConstructor
35  abstract class Pcc44CommonSearchParameters implements FhirSearchParameters {
36  
37      @Getter private ReferenceParam patientReference;
38      @Getter private TokenParam _id;
39  
40      @Getter private SortSpec sortSpec;
41      @Getter private Set<Include> includeSpec;
42      @Getter private Set<Include> revIncludeSpec;
43  
44      @Getter
45      private FhirContext fhirContext;
46  
47      @Override
48      public List<TokenParam> getPatientIdParam() {
49          if (_id != null)
50              return Collections.singletonList(_id);
51          return Collections.singletonList(patientReference.toTokenParam(fhirContext));
52      }
53  }