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.hl7v2.model.Message;
20  import org.apache.camel.builder.RouteBuilder;
21  import org.openehealth.ipf.commons.ihe.fhir.iti83.PixQueryResponseToPixmResponseTranslator;
22  import org.openehealth.ipf.commons.ihe.fhir.iti83.PixmRequestToPixQueryTranslator;
23  import org.openehealth.ipf.commons.ihe.fhir.translation.UriMapper;
24  import org.openehealth.ipf.platform.camel.ihe.fhir.test.FhirTestContainer;
25  
26  import static org.openehealth.ipf.platform.camel.ihe.fhir.core.FhirCamelTranslators.translateFhir;
27  import static org.openehealth.ipf.platform.camel.ihe.fhir.core.FhirCamelTranslators.translateToFhir;
28  import static org.openehealth.ipf.platform.camel.ihe.mllp.PixPdqCamelValidators.itiValidator;
29  
30  /**
31   *
32   */
33  public class Iti83TestRouteBuilder extends RouteBuilder {
34  
35      private final PixmRequestToPixQueryTranslator requestTranslator;
36      private final PixQueryResponseToPixmResponseTranslator responseTranslator;
37  
38      private ResponseCase responseCase = ResponseCase.OK;
39  
40      public Iti83TestRouteBuilder(UriMapper uriMapper) {
41          super();
42          this.requestTranslator = new PixmRequestToPixQueryTranslator(uriMapper);
43          requestTranslator.setPixSupplierResourceIdentifierUri("urn:oid:1.2.3.4.5.6");
44          this.responseTranslator = new PixQueryResponseToPixmResponseTranslator(uriMapper);
45      }
46  
47      public void setResponse(ResponseCase responseCase) {
48          this.responseCase = responseCase;
49      }
50  
51      @Override
52      public void configure() throws Exception {
53  
54          from("direct:input")
55                  .toF("pixm-iti83:localhost:%d", FhirTestContainer.DEMO_APP_PORT);
56  
57          from("pixm-iti83:translation?audit=true")
58                  // Translate into ITI-9
59                  .errorHandler(noErrorHandler())
60                  .process(translateFhir(requestTranslator))
61                  .process(itiValidator())
62                  // Create some static response
63                  .transform(new Iti9Responder(responseCase))
64                  // Translate back into FHIR
65                  .process(itiValidator())
66                  .process(translateToFhir(responseTranslator, Message.class));
67      }
68  
69  
70  }