View Javadoc
1   /*
2    * Copyright 2009 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  package org.openehealth.ipf.commons.ihe.xds.core.requests.query;
17  
18  import lombok.EqualsAndHashCode;
19  import lombok.Getter;
20  import lombok.Setter;
21  import lombok.ToString;
22  import org.openehealth.ipf.commons.ihe.xds.core.metadata.*;
23  
24  import javax.xml.bind.annotation.*;
25  import java.util.List;
26  
27  /**
28   * Represents a stored query for FindSubmissionSets.
29   * @author Jens Riemschneider
30   */
31  @XmlAccessorType(XmlAccessType.FIELD)
32  @XmlType(name = "FindSubmissionSetsQuery", propOrder = {
33          "status", "sourceIds", "authorPerson", "submissionTime", "contentTypeCodes", "patientId"})
34  @XmlRootElement(name = "findSubmissionSetsQuery")
35  @EqualsAndHashCode(callSuper = true, doNotUseGetters = true)
36  @ToString(callSuper = true, doNotUseGetters = true)
37  public class FindSubmissionSetsQuery extends StoredQuery implements PatientIdBasedStoredQuery {
38      private static final long serialVersionUID = 1712346604151312305L;
39  
40      @Getter @Setter private List<AvailabilityStatus> status;
41      @XmlElement(name = "sourceId")
42      @Getter @Setter private List<String> sourceIds;
43      @XmlElement(name = "contentTypeCode")
44      @Getter @Setter private List<Code> contentTypeCodes;
45      @Getter @Setter private String authorPerson;
46      @Getter @Setter private Identifiable patientId;
47  
48      @Getter private final TimeRange submissionTime = new TimeRange();
49  
50      /**
51       * Constructs the query.
52       */
53      public FindSubmissionSetsQuery() {
54          super(QueryType.FIND_SUBMISSION_SETS);
55      }
56  
57      @Override
58      public void accept(Visitor visitor) {
59          visitor.visit(this);
60      }
61  
62      /**
63       * Allows to use a {@link Person} instead of a {@link String}
64       * for specifying the query parameter "$XDSSubmissionSetAuthorPerson".
65       *
66       * @param authorPerson a {@link Person} object.
67       */
68      public void setTypedAuthorPerson(Person authorPerson) {
69          this.authorPerson = Hl7v2Based.render(authorPerson);
70      }
71  
72      /**
73       * Tries to return the query parameter "$XDSSubmissionSetAuthorPerson"
74       * as a {@link Person} instead of a {@link String}.
75       * This may fail if SQL LIKE wildcards ("%", "_", etc.) are used.
76       *
77       * @return a {@link Person} object.
78       */
79      public Person getTypedAuthorPerson() {
80          return Hl7v2Based.parse(this.authorPerson, Person.class);
81      }
82  
83  }