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.commons.ihe.hpd.iti59;
18  
19  import org.apache.commons.lang3.StringUtils;
20  import org.openehealth.ipf.commons.audit.AuditContext;
21  import org.openehealth.ipf.commons.audit.codes.ParticipantObjectTypeCodeRole;
22  import org.openehealth.ipf.commons.audit.model.AuditMessage;
23  import org.openehealth.ipf.commons.audit.model.TypeValuePairType;
24  import org.openehealth.ipf.commons.ihe.core.atna.event.PHIExportBuilder;
25  import org.openehealth.ipf.commons.ihe.hpd.audit.codes.HpdEventTypeCode;
26  import org.openehealth.ipf.commons.ihe.hpd.audit.codes.HpdParticipantObjectIdTypeCode;
27  
28  import java.util.Collections;
29  import java.util.List;
30  
31  /**
32   * @author Christian Ohr
33   */
34  public class Iti59ClientAuditStrategy extends Iti59AuditStrategy {
35  
36      public Iti59ClientAuditStrategy() {
37          super(false);
38      }
39  
40      protected AuditMessage makeAuditMessage(AuditContext auditContext,
41                                              Iti59AuditDataset auditDataset,
42                                              Iti59AuditDataset.RequestItem requestItem) {
43          PHIExportBuilder builder = new PHIExportBuilder<>(
44                  auditContext,
45                  auditDataset,
46                  requestItem.getOutcomeCode(),
47                  null,
48                  requestItem.getActionCode(),
49                  HpdEventTypeCode.ProviderInformationFeed,
50                  auditDataset.getPurposesOfUse()
51          );
52  
53          List<TypeValuePairType> details = StringUtils.isBlank(requestItem.getNewUid())
54                  ? Collections.emptyList()
55                  : Collections.singletonList(new TypeValuePairType("new uid", requestItem.getNewUid()));
56  
57          builder.addExportedEntity(
58                  requestItem.getUid(),
59                  HpdParticipantObjectIdTypeCode.RelativeDistinguishedName,
60                  requestItem.getParticipantObjectTypeCode(),
61                  ParticipantObjectTypeCodeRole.Provider,
62                  details
63          );
64  
65          return builder.getMessage();
66      }
67  
68  }