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.fhir.iti68;
18  
19  import org.openehealth.ipf.commons.audit.AuditContext;
20  import org.openehealth.ipf.commons.audit.codes.EventActionCode;
21  import org.openehealth.ipf.commons.audit.codes.ParticipantObjectIdTypeCode;
22  import org.openehealth.ipf.commons.audit.codes.ParticipantObjectTypeCodeRole;
23  import org.openehealth.ipf.commons.audit.model.AuditMessage;
24  import org.openehealth.ipf.commons.ihe.core.atna.AuditStrategySupport;
25  import org.openehealth.ipf.commons.ihe.core.atna.event.PHIExportBuilder;
26  import org.openehealth.ipf.commons.ihe.fhir.audit.codes.FhirEventTypeCode;
27  
28  import java.util.Map;
29  
30  
31  /**
32   * @author Christian Ohr
33   */
34  public class Iti68ServerAuditStrategy extends AuditStrategySupport<Iti68AuditDataset> {
35  
36      public Iti68ServerAuditStrategy() {
37          super(true);
38      }
39  
40      @Override
41      public Iti68AuditDataset enrichAuditDatasetFromRequest(Iti68AuditDataset auditDataset, Object request, Map<String, Object> parameters) {
42          return auditDataset;
43      }
44  
45      @Override
46      public AuditMessage[] makeAuditMessage(AuditContext auditContext, Iti68AuditDataset auditDataset) {
47          PHIExportBuilder builder = new PHIExportBuilder<>(auditContext, auditDataset,
48                  EventActionCode.Create,
49                  FhirEventTypeCode.MobileDocumentRetrieval)
50                  .setPatient(auditDataset.getPatientId());
51          if (auditDataset.getDocumentUniqueId() != null) {
52              builder.addExportedEntity(
53                      auditDataset.getDocumentUniqueId(),
54                      ParticipantObjectIdTypeCode.ReportNumber,
55                      ParticipantObjectTypeCodeRole.Report,
56                      PHIExportBuilder.makeDocumentDetail(
57                              auditDataset.getRepositoryUniqueId(),
58                              auditDataset.getHomeCommunityId(),
59                              null, null));
60          }
61          return builder.getMessages();
62      }
63  
64      @Override
65      public Iti68AuditDataset createAuditDataset() {
66          return new Iti68AuditDataset(true);
67      }
68  }