View Javadoc
1   /*
2    * Copyright 2017 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.core.atna.custom;
17  
18  import org.openhealthtools.ihe.atna.auditor.codes.dicom.DICOMEventIdCodes;
19  import org.openhealthtools.ihe.atna.auditor.codes.rfc3881.RFC3881EventCodes;
20  import org.openhealthtools.ihe.atna.auditor.codes.rfc3881.RFC3881ParticipantObjectCodes;
21  import org.openhealthtools.ihe.atna.auditor.events.ihe.GenericIHEAuditEventMessage;
22  import org.openhealthtools.ihe.atna.auditor.models.rfc3881.CodedValueType;
23  import org.openhealthtools.ihe.atna.auditor.models.rfc3881.TypeValuePairType;
24  import org.openhealthtools.ihe.atna.auditor.utils.EventUtils;
25  
26  import java.nio.charset.Charset;
27  import java.util.LinkedList;
28  import java.util.List;
29  
30  /**
31   * ATNA Audit event for ITI-86.
32   * @author Dmytro Rud
33   *
34   * @since 3.3
35   *
36   * @deprecated
37   */
38  public class RemoveDocumentsEvent extends GenericIHEAuditEventMessage {
39  
40      public RemoveDocumentsEvent(
41              boolean systemIsSource,
42              RFC3881EventCodes.RFC3881EventOutcomeCodes outcome,
43              List<CodedValueType> purposesOfUse)
44      {
45          super(systemIsSource,
46                outcome,
47                RFC3881EventCodes.RFC3881EventActionCodes.DELETE,
48                new DICOMEventIdCodes.PatientRecord(),
49                new CustomIHETransactionEventTypeCodes.RemoveDocuments(),
50                purposesOfUse);
51      }
52  
53  
54      protected void addTypeValuePair(List<TypeValuePairType> pairs, String type, String value) {
55          if (! EventUtils.isEmptyOrNull(value)) {
56              pairs.add(getTypeValuePair(type, value.getBytes(Charset.defaultCharset())));
57          }
58      }
59  
60  
61      public void addRemovedDocumentParticipantObject(String documentUniqueId, String repositoryUniqueId) {
62          List<TypeValuePairType> pairs = new LinkedList<>();
63          addTypeValuePair(pairs, "urn:ihe:iti:xds:2007:repositoryUniqueId", repositoryUniqueId);
64  
65          addParticipantObjectIdentification(
66                  new RFC3881ParticipantObjectCodes.RFC3881ParticipantObjectIDTypeCodes.ReportNumber(),
67                  null,
68                  null,
69                  pairs,
70                  documentUniqueId,
71                  RFC3881ParticipantObjectCodes.RFC3881ParticipantObjectTypeCodes.SYSTEM,
72                  RFC3881ParticipantObjectCodes.RFC3881ParticipantObjectTypeRoleCodes.REPORT,
73                  RFC3881ParticipantObjectCodes.RFC3881ParticipantObjectDataLifeCycleCodes.PERMANENT_ERASURE,
74                  null);
75      }
76  
77  }