View Javadoc
1   /*
2    * Copyright 2015 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.iti81;
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.StringAndListParam;
25  import ca.uhn.fhir.rest.param.TokenAndListParam;
26  import org.hl7.fhir.dstu3.model.AuditEvent;
27  import org.openehealth.ipf.commons.ihe.fhir.AbstractPlainProvider;
28  
29  import javax.servlet.http.HttpServletRequest;
30  import javax.servlet.http.HttpServletResponse;
31  import java.util.Set;
32  
33  /**
34   * According to the Restful ATNA specification, this resource provider must handle requests in the form
35   * GET [base]/AuditEvent?date=>start-time&date=<stoptime>&<query>{&_format=[mime-type]}
36   *
37   * @author Christian Ohr
38   * @since 3.1
39   */
40  public class Iti81ResourceProvider extends AbstractPlainProvider {
41  
42      @SuppressWarnings("unused")
43      @Search(type = AuditEvent.class)
44      public IBundleProvider auditSearch(
45              @RequiredParam(name = AuditEvent.SP_DATE) DateRangeParam interval,
46              @OptionalParam(name = AuditEvent.SP_ADDRESS) StringAndListParam address,
47              @OptionalParam(name = AuditEvent.SP_PATIENT + ".identifier") TokenAndListParam patientId,
48              @OptionalParam(name = AuditEvent.SP_ENTITY_ID) TokenAndListParam entityId,
49              @OptionalParam(name = AuditEvent.SP_ENTITY_TYPE) TokenAndListParam entityType,
50              @OptionalParam(name = AuditEvent.SP_ENTITY_ROLE) TokenAndListParam entityRole,
51              @OptionalParam(name = AuditEvent.SP_SOURCE) StringAndListParam source,
52              @OptionalParam(name = AuditEvent.SP_TYPE) TokenAndListParam type,
53              @OptionalParam(name = AuditEvent.SP_USER) StringAndListParam user,
54              @OptionalParam(name = AuditEvent.SP_SUBTYPE) TokenAndListParam subtype,
55              @OptionalParam(name = Iti81Constants.SP_OUTCOME) TokenAndListParam outcome,
56              @Sort SortSpec sortSpec,
57              @IncludeParam Set<Include> includeSpec,
58              HttpServletRequest httpServletRequest,
59              HttpServletResponse httpServletResponse) {
60  
61          Iti81SearchParameters searchParameters = Iti81SearchParameters.builder()
62                  .interval(interval)
63                  .address(address)
64                  .patientId(patientId)
65                  .entityId(entityId)
66                  .entityType(entityType)
67                  .entityRole(entityRole)
68                  .source(source)
69                  .type(type)
70                  .user(user)
71                  .subtype(subtype)
72                  .outcome(outcome)
73                  .sortSpec(sortSpec)
74                  .includeSpec(includeSpec)
75                  .fhirContext(getFhirContext())
76                  .build();
77  
78          // Run down the route
79          return requestBundleProvider(null, searchParameters, httpServletRequest, httpServletResponse);
80  
81      }
82  
83  }