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.audit.model;
17  
18  import lombok.EqualsAndHashCode;
19  import lombok.Getter;
20  import lombok.NonNull;
21  import lombok.Setter;
22  import org.openehealth.ipf.commons.audit.AuditException;
23  import org.openehealth.ipf.commons.audit.codes.ParticipantObjectDataLifeCycle;
24  import org.openehealth.ipf.commons.audit.codes.ParticipantObjectIdTypeCode;
25  import org.openehealth.ipf.commons.audit.codes.ParticipantObjectTypeCode;
26  import org.openehealth.ipf.commons.audit.codes.ParticipantObjectTypeCodeRole;
27  import org.openehealth.ipf.commons.audit.types.ParticipantObjectIdType;
28  
29  import java.io.Serializable;
30  import java.util.ArrayList;
31  import java.util.List;
32  
33  import static java.util.Objects.requireNonNull;
34  
35  /**
36   * @author Christian Ohr
37   * @since 3.5
38   */
39  @EqualsAndHashCode
40  public class ParticipantObjectIdentificationType implements Serializable, Validateable {
41  
42      /**
43       * Identifies a specific instance of the participant object.
44       */
45      @Getter
46      @Setter
47      @NonNull
48      private String participantObjectID;
49  
50      /**
51       * Describes the identifier that is contained in Participant Object ID.
52       */
53      @Getter
54      @Setter
55      @NonNull
56      private ParticipantObjectIdType participantObjectIDTypeCode;
57  
58      /**
59       * An instance-specific descriptor of the Participant Object ID audited, such as a person's name.
60       */
61      @Getter
62      @Setter
63      private String participantObjectName;
64  
65      /**
66       * The actual query for a query-type participant object.
67       */
68      @Getter
69      @Setter
70      private byte[] participantObjectQuery;
71  
72      /**
73       * Code for the participant object type being audited. This value is distinct from the user's role
74       * or any user relationship to the participant object.
75       */
76      @Getter
77      @Setter
78      private ParticipantObjectTypeCode participantObjectTypeCode;
79  
80      /**
81       * Code representing the functional application role of Participant Object being audited.
82       * The ParticipantObjectTypeCodeRole identifies the role that the object played in the event that is being reported.
83       * Most events involve multiple participating objects. ParticipantObjectTypeCodeRole identifies which object took which role in the event.
84       * It also covers agents, multi-purpose entities, and multi-role entities. For the purpose of the event one primary role is chosen.
85       */
86      @Getter
87      @Setter
88      private ParticipantObjectTypeCodeRole participantObjectTypeCodeRole;
89  
90      /**
91       * Identifier for the data life-cycle stage for the participant object.
92       * This can be used to provide an audit trail for data, over time, as it passes through the system.
93       */
94      @Getter
95      @Setter
96      private ParticipantObjectDataLifeCycle participantObjectDataLifeCycle;
97  
98      /**
99       * Denotes policy-defined sensitivity for the Participant Object ID such as VIP, HIV status,
100      * mental health status, or similar topics.
101      */
102     @Getter
103     @Setter
104     private String participantObjectSensitivity;
105 
106     private List<TypeValuePairType> participantObjectDetails;
107 
108     private List<DicomObjectDescriptionType> participantObjectDescriptions;
109 
110 
111     /**
112      * @param participantObjectID         Identifies a specific instance of the participant object.
113      * @param participantObjectIDTypeCode Describes the identifier that is contained in Participant Object ID.
114      */
115     public ParticipantObjectIdentificationType(String participantObjectID, ParticipantObjectIdType participantObjectIDTypeCode) {
116         this.participantObjectID = requireNonNull(participantObjectID, "participantObjectID must be not null");
117         this.participantObjectIDTypeCode = requireNonNull(participantObjectIDTypeCode, "participantObjectIDTypeCode must be not null");
118     }
119 
120     /**
121      * Implementation-defined data about specific details of the object accessed or used. This element is a Type-value pair.
122      * The "type" attribute is an implementation-defined text string. The "value" attribute is base 64 encoded data.
123      * The value is suitable for conveying binary data.
124      *
125      * @return Implementation-defined data about specific details of the object accessed or used
126      */
127     public List<TypeValuePairType> getParticipantObjectDetails() {
128         if (participantObjectDetails == null) {
129             participantObjectDetails = new ArrayList<>();
130         }
131         return this.participantObjectDetails;
132     }
133 
134     public List<DicomObjectDescriptionType> getParticipantObjectDescriptions() {
135         if (participantObjectDescriptions == null) {
136             participantObjectDescriptions = new ArrayList<>();
137         }
138         return this.participantObjectDescriptions;
139     }
140 
141     /**
142      * SOPClass is Required if ParticipantObjectIDTypeCode is (110180, DCM, "Study Instance UID") and any of the optional fields
143      * (AccessionNumber, ContainsMPPS, NumberOfInstances, ContainsSOPInstances,Encrypted,Anonymized) are present in this
144      * Participant Object. May be present if ParticipantObjectIDTypeCode is (110180, DCM, "Study Instance UID") even though none
145      * of the optional fields are present.
146      */
147     @Override
148     public void validate() {
149         if (participantObjectIDTypeCode == ParticipantObjectIdTypeCode.StudyInstanceUID &&
150                 participantObjectDescriptions.isEmpty())
151             throw new AuditException("DICOM Object Descriptions must be present for StudyInstanceUID participant object ID types");
152     }
153 }