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.platform.camel.ihe.fhir.iti83;
18  
19  import ca.uhn.fhir.context.FhirVersionEnum;
20  import org.hl7.fhir.dstu3.model.*;
21  import org.openehealth.ipf.commons.ihe.fhir.Constants;
22  import org.openehealth.ipf.commons.ihe.fhir.IpfFhirServlet;
23  import org.openehealth.ipf.commons.ihe.fhir.iti83.Iti83Constants;
24  import org.openehealth.ipf.platform.camel.ihe.fhir.test.FhirTestContainer;
25  import org.slf4j.Logger;
26  import org.slf4j.LoggerFactory;
27  
28  /**
29   *
30   */
31  abstract class AbstractTestIti83 extends FhirTestContainer {
32  
33      private static final Logger LOG = LoggerFactory.getLogger(AbstractTestIti83.class);
34  
35      public static void startServer(String contextDescriptor) {
36          IpfFhirServlet servlet = new IpfFhirServlet(FhirVersionEnum.DSTU3);
37          startServer(servlet, contextDescriptor, false, DEMO_APP_PORT, "FhirServlet");
38          startClient(String.format("http://localhost:%d/", DEMO_APP_PORT));
39      }
40  
41      protected Parameters validQueryParameters() {
42          Parameters inParams = new Parameters();
43          inParams.addParameter()
44                  .setName(Constants.SOURCE_IDENTIFIER_NAME)
45                  .setValue(new StringType("urn:oid:1.2.3.4|0815"));
46          inParams.addParameter()
47                  .setName(Constants.TARGET_SYSTEM_NAME)
48                  .setValue(new UriType("urn:oid:1.2.3.4.6"));
49          return inParams;
50      }
51  
52      protected Parameters validReadParameters() {
53          Parameters inParams = new Parameters();
54          inParams.addParameter()
55                  .setName(Constants.SOURCE_IDENTIFIER_NAME)
56                  .setValue(new StringType("|0815"));
57          inParams.addParameter()
58                  .setName(Constants.TARGET_SYSTEM_NAME)
59                  .setValue(new UriType("urn:oid:1.2.3.4.6"));
60          return inParams;
61      }
62  
63      protected Parameters validTargetSystemParameters() {
64          Parameters inParams = new Parameters();
65          inParams.addParameter()
66                  .setName(Constants.TARGET_SYSTEM_NAME)
67                  .setValue(new UriType("urn:oid:1.2.3.4.6"));
68          return inParams;
69      }
70  
71      protected Parameters sendManuallyOnType(Parameters queryParameters) {
72          Parameters result = client.operation()
73                  .onType(Patient.class)
74                  .named(Iti83Constants.PIXM_OPERATION_NAME)
75                  .withParameters(queryParameters)
76                  .useHttpGet()
77                  .execute();
78          return result;
79      }
80  
81      protected Parameters sendManuallyOnInstance(String resourceId, Parameters queryParameters) {
82          Parameters result = client.operation()
83                  .onInstance(new IdType("Patient", resourceId))
84                  .named(Iti83Constants.PIXM_OPERATION_NAME)
85                  .withParameters(queryParameters)
86                  .useHttpGet()
87                  .execute();
88          return result;
89      }
90  
91  }