View Javadoc
1   /*
2    * Copyright 2016 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.commons.ihe.hl7v2;
17  
18  import ca.uhn.hl7v2.ErrorCode;
19  import ca.uhn.hl7v2.Version;
20  import lombok.Getter;
21  import org.openehealth.ipf.commons.ihe.core.IntegrationProfile;
22  import org.openehealth.ipf.commons.ihe.core.InteractionId;
23  import org.openehealth.ipf.commons.ihe.core.atna.AuditStrategy;
24  import org.openehealth.ipf.commons.ihe.hl7v2.audit.FeedAuditDataset;
25  import org.openehealth.ipf.commons.ihe.hl7v2.audit.iti30.Iti30AuditStrategy;
26  import org.openehealth.ipf.commons.ihe.hl7v2.audit.iti31.Iti31AuditStrategy;
27  import org.openehealth.ipf.commons.ihe.hl7v2.definitions.HapiContextFactory;
28  import org.openehealth.ipf.gazelle.validation.profile.pam.PamTransactions;
29  
30  import java.util.Arrays;
31  import java.util.List;
32  
33  /**
34   * @author Christian Ohr
35   * @since 3.2
36   */
37  public class PAM implements IntegrationProfile {
38  
39      public enum Interactions implements Hl7v2InteractionId<FeedAuditDataset> {
40          ITI_30 {
41              @Override
42              public void init(List<? extends HL7v2TransactionOption> options) {
43                  init("pam-iti30",
44                          "Patient Identity Management",
45                          false,
46                          new Iti30AuditStrategy(false),
47                          new Iti30AuditStrategy(true),
48                          PamTransactions.ITI30,
49                          options);
50              }
51          },
52          ITI_31 {
53              @Override
54              public void init(List<? extends HL7v2TransactionOption> options) {
55                  init("pam-iti31",
56                          "Patient Encounter Management",
57                          false,
58                          new Iti31AuditStrategy(false),
59                          new Iti31AuditStrategy(true),
60                          PamTransactions.ITI31,
61                          options);
62              }
63          };
64  
65          @Getter private Hl7v2TransactionConfiguration<FeedAuditDataset> hl7v2TransactionConfiguration;
66          @Getter private NakFactory<FeedAuditDataset> nakFactory;
67  
68          protected void init(
69                  String name,
70                  String description,
71                  boolean isQuery,
72                  AuditStrategy<FeedAuditDataset> clientAuditStrategy,
73                  AuditStrategy<FeedAuditDataset> serverAuditStrategy,
74                  PamTransactions pamTransactions,
75                  List<? extends HL7v2TransactionOption> options)
76          {
77              this.hl7v2TransactionConfiguration = new Hl7v2TransactionConfiguration<>(
78                      name,
79                      description,
80                      isQuery,
81                      clientAuditStrategy,
82                      serverAuditStrategy,
83                      new Version[]{Version.V25},
84                      "PIM adapter",
85                      "IPF",
86                      ErrorCode.APPLICATION_INTERNAL_ERROR,
87                      ErrorCode.APPLICATION_INTERNAL_ERROR,
88                      new String[]{"ADT"},
89                      new String[]{HL7v2TransactionOption.concatAllToString(options)},
90                      new String[]{"ACK"},
91                      new String[]{"*"},
92                      new boolean[]{true},
93                      new boolean[]{false},
94                      HapiContextFactory.createHapiContext(pamTransactions));
95  
96              this.nakFactory = new NakFactory<>(this.hl7v2TransactionConfiguration);
97          }
98      }
99  
100     @Override
101     public List<InteractionId> getInteractionIds() {
102         return Arrays.asList(Interactions.values());
103     }
104 }