1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.openehealth.ipf.platform.camel.ihe.fhir.iti78;
18
19 import ca.uhn.hl7v2.model.Message;
20 import org.apache.camel.builder.RouteBuilder;
21 import org.openehealth.ipf.commons.ihe.fhir.iti78.PdqResponseToPdqmResponseTranslator;
22 import org.openehealth.ipf.commons.ihe.fhir.iti78.PdqmRequestToPdqQueryTranslator;
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 Iti78TestRouteBuilder extends RouteBuilder {
34
35 private final PdqmRequestToPdqQueryTranslator requestTranslator;
36 private final PdqResponseToPdqmResponseTranslator responseTranslator;
37
38 private ResponseCase responseCase = ResponseCase.OK;
39
40 public Iti78TestRouteBuilder(UriMapper uriMapper) {
41 super();
42 this.requestTranslator = new PdqmRequestToPdqQueryTranslator(uriMapper);
43 requestTranslator.setPdqSupplierResourceIdentifierUri("urn:oid:1.2.3.4.5.6");
44 this.responseTranslator = new PdqResponseToPdqmResponseTranslator(uriMapper);
45 responseTranslator.setPdqSupplierResourceIdentifierUri("urn:oid:1.2.3.4.5.6");
46 }
47
48 public void setResponse(ResponseCase responseCase) {
49 this.responseCase = responseCase;
50 }
51
52 @Override
53 public void configure() throws Exception {
54
55 from("direct:input")
56 .toF("pdqm-iti78:localhost:%d", FhirTestContainer.DEMO_APP_PORT);
57
58 from("pdqm-iti78:translation?audit=true")
59
60 .errorHandler(noErrorHandler())
61 .process(translateFhir(requestTranslator))
62 .process(itiValidator())
63
64 .transform(new Iti21Responder(responseCase))
65
66 .process(itiValidator())
67 .process(translateToFhir(responseTranslator, Message.class));
68 }
69
70
71 }