View Javadoc
1   /*
2    * Copyright 2018 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.pcc44;
18  
19  import org.apache.camel.CamelContext;
20  import org.openehealth.ipf.commons.ihe.core.TransactionOptionUtils;
21  import org.openehealth.ipf.commons.ihe.fhir.FhirTransactionOptions;
22  import org.openehealth.ipf.commons.ihe.fhir.audit.FhirQueryAuditDataset;
23  import org.openehealth.ipf.commons.ihe.fhir.pcc44.Pcc44Options;
24  import org.openehealth.ipf.platform.camel.ihe.fhir.core.FhirComponent;
25  import org.openehealth.ipf.platform.camel.ihe.fhir.core.FhirEndpointConfiguration;
26  
27  import java.util.List;
28  import java.util.Map;
29  
30  import static org.openehealth.ipf.commons.ihe.fhir.qedm.QEDM.Interactions.PCC_44;
31  
32  
33  /**
34   * Component for QEDM (PCC-44)
35   *
36   * @author Christian Ohr
37   * @since 3.5
38   */
39  public class Pcc44Component extends FhirComponent<FhirQueryAuditDataset> {
40  
41  
42      public Pcc44Component() {
43          super(PCC_44);
44      }
45  
46      public Pcc44Component(CamelContext context) {
47          super(context, PCC_44);
48      }
49  
50      @Override
51      protected Pcc44Endpoint doCreateEndpoint(String uri, FhirEndpointConfiguration<FhirQueryAuditDataset> config) {
52          return new Pcc44Endpoint(uri, this, config);
53      }
54  
55      @Override
56      protected FhirEndpointConfiguration<FhirQueryAuditDataset> createConfig(String remaining, Map<String, Object> parameters) throws Exception {
57          String options = getAndRemoveParameter(parameters, "options", String.class, Pcc44Options.ALL.name());
58          List<? extends FhirTransactionOptions> iti44Options = TransactionOptionUtils.split(options, Pcc44Options.class);
59          if (iti44Options.isEmpty()) {
60              throw new IllegalArgumentException("Options parameter for qedm-pcc44 is invalid");
61          }
62          getInteractionId().init(iti44Options);
63          return super.createConfig(remaining, parameters);
64      }
65  
66  }