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  package org.openehealth.ipf.platform.camel.ihe.mllp.iti31;
17  
18  import org.apache.camel.CamelContext;
19  import org.openehealth.ipf.commons.ihe.core.TransactionOptionUtils;
20  import org.openehealth.ipf.commons.ihe.hl7v2.HL7v2TransactionOption;
21  import org.openehealth.ipf.commons.ihe.hl7v2.audit.FeedAuditDataset;
22  import org.openehealth.ipf.commons.ihe.hl7v2.options.Iti31Options;
23  import org.openehealth.ipf.platform.camel.ihe.mllp.core.MllpTransactionComponent;
24  import org.openehealth.ipf.platform.camel.ihe.mllp.core.MllpTransactionEndpointConfiguration;
25  
26  import java.util.List;
27  import java.util.Map;
28  
29  import static org.openehealth.ipf.commons.ihe.hl7v2.PAM.Interactions.ITI_31;
30  
31  /**
32   * Camel component for ITI-31 (Patient Encounter Management).
33   * The endpoints take an additional parameter "options", that refer to the
34   * transaction options as specified in {@link Iti31Options} that need to be supported.
35   *
36   * @author Christian Ohr
37   */
38  public class Iti31Component extends MllpTransactionComponent<FeedAuditDataset> {
39  
40  
41      public Iti31Component() {
42          super(ITI_31);
43      }
44  
45      public Iti31Component(CamelContext camelContext) {
46          super(camelContext, ITI_31);
47      }
48  
49      @Override
50      protected MllpTransactionEndpointConfiguration createConfig(String uri, Map<String, Object> parameters) throws Exception {
51          MllpTransactionEndpointConfiguration config = super.createConfig(uri, parameters);
52          String options = getAndRemoveParameter(parameters, "options", String.class, Iti31Options.BASIC.name());
53          List<? extends HL7v2TransactionOption> iti31Options = TransactionOptionUtils.split(options, Iti31Options.class);
54          if (iti31Options.isEmpty()) {
55              throw new IllegalArgumentException("Options parameter for pam-iti30 is invalid");
56          }
57          getInteractionId().init(iti31Options);
58          return config;
59      }
60  
61  }