View Javadoc
1   /*
2    * Copyright 2014 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  package org.openehealth.ipf.platform.camel.ihe.mllp.core;
17  
18  import java.util.Map;
19  
20  import ca.uhn.hl7v2.DefaultHapiContext;
21  import ca.uhn.hl7v2.ErrorCode;
22  import ca.uhn.hl7v2.Version;
23  import org.apache.camel.component.mina2.Mina2Endpoint;
24  import org.openehealth.ipf.commons.ihe.hl7v2.Hl7v2InteractionId;
25  import org.openehealth.ipf.commons.ihe.hl7v2.Hl7v2TransactionConfiguration;
26  import org.openehealth.ipf.commons.ihe.hl7v2.NakFactory;
27  import org.openehealth.ipf.commons.ihe.hl7v2.audit.MllpAuditDataset;
28  import org.openehealth.ipf.modules.hl7.parser.DefaultEscaping;
29  
30  /**
31   * MLLP dispatching Camel component.
32   * @author Dmytro Rud
33   */
34  public class MllpDispatchComponent extends MllpComponent<MllpDispatchEndpointConfiguration, MllpAuditDataset> {
35  
36      public static final Hl7v2TransactionConfiguration<MllpAuditDataset> CONFIGURATION =
37              new Hl7v2TransactionConfiguration<>(
38                      "mllp-dispatch",
39                      "MLLP Dispatcher",
40                      false,
41                      null,                        // audit trail (if any) will be delegated
42                      null,                        // audit trail (if any) will be delegated
43                      new Version[] {Version.V25}, // not relevant for acceptance checking
44                      "MLLP Dispatcher",
45                      "IPF",
46                      ErrorCode.APPLICATION_INTERNAL_ERROR,
47                      ErrorCode.APPLICATION_INTERNAL_ERROR,
48                      new String[] {"\0"},        // acceptance checking will be delegated (4x)
49                      new String[] {"\0"},
50                      new String[] {"\0"},
51                      new String[] {"\0"},
52                      new boolean[] {false},      // audit trail (if any) will be delegated
53                      new boolean[] {false},      // interactive continuation (if any) will be delegated
54                      new DefaultHapiContext());
55  
56      private static final NakFactory<MllpAuditDataset> NAK_FACTORY = new NakFactory<>(CONFIGURATION);
57  
58      static {
59          CONFIGURATION.getHapiContext().getParserConfiguration().setEscaping(DefaultEscaping.INSTANCE);
60      }
61  
62      @Override
63      protected MllpDispatchEndpointConfiguration createConfig(String uri, Map<String, Object> parameters) throws Exception {
64          return new MllpDispatchEndpointConfiguration(this, uri, parameters);
65      }
66  
67      @Override
68      protected MllpEndpoint<?, ?, ?> createEndpoint(Mina2Endpoint wrappedEndpoint, MllpDispatchEndpointConfiguration config) {
69          return new MllpDispatchEndpoint(this, wrappedEndpoint, config);
70      }
71  
72      @Override
73      public Hl7v2InteractionId<MllpAuditDataset> getInteractionId() {
74          return null;
75      }
76  
77      @Override
78      public Hl7v2TransactionConfiguration<MllpAuditDataset> getHl7v2TransactionConfiguration() {
79          return CONFIGURATION;
80      }
81  
82      @Override
83      public NakFactory<MllpAuditDataset> getNakFactory() {
84          return NAK_FACTORY;
85      }
86  }