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.platform.camel.ihe.fhir.iti66;
18  
19  import ca.uhn.fhir.context.FhirVersionEnum;
20  import ca.uhn.fhir.rest.gclient.ICriterion;
21  import ca.uhn.fhir.rest.gclient.ReferenceClientParam;
22  import ca.uhn.fhir.rest.gclient.TokenClientParam;
23  import org.hl7.fhir.dstu3.model.Bundle;
24  import org.hl7.fhir.dstu3.model.DocumentManifest;
25  import org.openehealth.ipf.commons.ihe.fhir.IpfFhirServlet;
26  import org.openehealth.ipf.platform.camel.ihe.fhir.test.FhirTestContainer;
27  
28  /**
29   *
30   */
31  abstract class AbstractTestIti66 extends FhirTestContainer {
32  
33      public static void startServer(String contextDescriptor) {
34          IpfFhirServlet servlet = new IpfFhirServlet(FhirVersionEnum.DSTU3);
35          startServer(servlet, contextDescriptor, false, DEMO_APP_PORT, "FhirServlet");
36          startClient(String.format("http://localhost:%d/", DEMO_APP_PORT));
37      }
38  
39      protected ICriterion<?> manifestPatientIdentifierParameter() {
40          return new TokenClientParam("patient.identifier").exactly()
41                  .systemAndIdentifier("urn:oid:2.16.840.1.113883.3.37.4.1.1.2.1.1", "1");
42      }
43  
44      protected ICriterion<?> manifestPatientReferenceParameter() {
45          return new ReferenceClientParam("patient").hasId("http://fhirserver.org/Patient/1");
46      }
47  
48      protected Bundle sendManually(ICriterion<?> requestData) {
49          return client.search()
50                  .forResource(DocumentManifest.class)
51                  .where(requestData)
52                  .returnBundle(Bundle.class)
53                  .execute();
54      }
55  
56      protected Bundle nextPage(Bundle bundle) {
57          return client.loadPage()
58                  .next(bundle)
59                  .execute();
60      }
61  
62      protected Bundle previousPage(Bundle bundle) {
63          return client.loadPage()
64                  .previous(bundle)
65                  .execute();
66      }
67  
68  
69  }