View Javadoc
1   /*
2    * Copyright 2016 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.iti78;
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.Builder;
24  import lombok.Getter;
25  import lombok.Setter;
26  import org.openehealth.ipf.commons.ihe.fhir.FhirSearchParameters;
27  
28  import java.util.Collections;
29  import java.util.List;
30  import java.util.Set;
31  import java.util.stream.Collectors;
32  
33  /**
34   *
35   */
36  @Builder
37  public class Iti78SearchParameters implements FhirSearchParameters {
38  
39      @Getter @Setter private TokenAndListParam identifiers;
40      @Getter @Setter private TokenParam active;
41      @Getter @Setter private StringAndListParam family;
42      @Getter @Setter private StringAndListParam given;
43      @Getter @Setter private DateAndListParam birthDate;
44      @Getter @Setter private StringParam address;
45      @Getter @Setter private StringParam city;
46      @Getter @Setter private StringParam country;
47      @Getter @Setter private StringParam state;
48      @Getter @Setter private StringParam postalCode;
49      @Getter @Setter private TokenParam gender;
50      @Getter @Setter private TokenParam _id;
51      @Getter @Setter private StringParam telecom;
52  
53      @Getter @Setter private SortSpec sortSpec;
54      @Getter @Setter private Set<Include> includeSpec;
55  
56      @Getter
57      private FhirContext fhirContext;
58  
59      @Override
60      public List<TokenParam> getPatientIdParam() {
61          if (_id != null)
62              return Collections.singletonList(_id);
63          if (identifiers != null)
64              return identifiers.getValuesAsQueryTokens().stream()
65                  .flatMap(tol -> tol.getValuesAsQueryTokens().stream())
66                  .collect(Collectors.toList());
67          return Collections.emptyList();
68      }
69  }