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.platform.camel.ihe.fhir.pcc44;
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 org.hl7.fhir.dstu3.model.Bundle;
23  import org.hl7.fhir.dstu3.model.Observation;
24  import org.openehealth.ipf.commons.ihe.fhir.IpfFhirServlet;
25  import org.openehealth.ipf.platform.camel.ihe.fhir.test.FhirTestContainer;
26  import org.slf4j.Logger;
27  import org.slf4j.LoggerFactory;
28  
29  /**
30   *
31   */
32  abstract class AbstractTestPcc44 extends FhirTestContainer {
33  
34      private static final Logger LOG = LoggerFactory.getLogger(AbstractTestPcc44.class);
35  
36      public static void startServer(String contextDescriptor) {
37          IpfFhirServlet servlet = new IpfFhirServlet(FhirVersionEnum.DSTU3);
38          startServer(servlet, contextDescriptor, false, DEMO_APP_PORT, "FhirServlet");
39          startClient(String.format("http://localhost:%d/", DEMO_APP_PORT));
40      }
41  
42      protected ICriterion<?> observationPatientReferenceParameter() {
43          return new ReferenceClientParam("patient").hasId("http://fhirserver.org/Patient/1");
44      }
45  
46      protected Bundle sendManually(ICriterion<?> requestData) {
47          return client.search()
48                  .forResource(Observation.class)
49                  .where(requestData)
50                  .returnBundle(Bundle.class)
51                  .execute();
52      }
53  
54      protected Bundle nextPage(Bundle bundle) {
55          return client.loadPage()
56                  .next(bundle)
57                  .execute();
58      }
59  
60      protected Bundle previousPage(Bundle bundle) {
61          return client.loadPage()
62                  .previous(bundle)
63                  .execute();
64      }
65  
66  
67  }