1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.openehealth.ipf.commons.audit.event;
18
19 import org.openehealth.ipf.commons.audit.AuditException;
20 import org.openehealth.ipf.commons.audit.codes.*;
21 import org.openehealth.ipf.commons.audit.types.EventType;
22 import org.openehealth.ipf.commons.audit.types.PurposeOfUse;
23
24 import java.util.Collections;
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 public class DicomInstancesTransferredBuilder extends BaseAuditMessageBuilder<DicomInstancesTransferredBuilder> {
45
46 public DicomInstancesTransferredBuilder(EventOutcomeIndicator outcome,
47 String eventOutcomeDescription,
48 EventActionCode eventActionCode,
49 EventType eventType,
50 PurposeOfUse... purposesOfUse) {
51 super();
52 setEventIdentification(outcome,
53 eventOutcomeDescription,
54 eventActionCode,
55 EventIdCode.DICOMInstancesTransferred,
56 eventType,
57 purposesOfUse
58 );
59 }
60
61
62
63
64
65
66
67
68
69 public DicomInstancesTransferredBuilder setSendingProcessParticipant(String userId,
70 String altUserId,
71 String userName,
72 String networkId,
73 boolean userIsRequestor) {
74 return addSourceActiveParticipant(userId, altUserId, userName, networkId, userIsRequestor);
75 }
76
77
78
79
80
81
82
83
84
85 public DicomInstancesTransferredBuilder setReceivingProcessParticipant(String userId,
86 String altUserId,
87 String userName,
88 String networkId,
89 boolean userIsRequestor) {
90 return addDestinationActiveParticipant(userId, altUserId, userName, networkId, userIsRequestor);
91 }
92
93
94
95
96
97
98 public DicomInstancesTransferredBuilder setPatientParticipantObject(String patientId, String patientName) {
99 if (patientId != null) {
100 addPatientParticipantObject(patientId, patientName, Collections.emptyList(), null);
101 }
102 return self();
103 }
104
105 @Override
106 public void validate() {
107 super.validate();
108 if (getMessage().findActiveParticipants(ap -> ap.getRoleIDCodes().contains(ActiveParticipantRoleIdCode.Source)).size() != 1) {
109 throw new AuditException("Must have one ActiveParticipant with RoleIDCode Source");
110 }
111 if (getMessage().findActiveParticipants(ap -> ap.getRoleIDCodes().contains(ActiveParticipantRoleIdCode.Destination)).size() != 1) {
112 throw new AuditException("Must have one ActiveParticipant with RoleIDCode Destination");
113 }
114 if (getMessage().findParticipantObjectIdentifications(poi -> poi.getParticipantObjectIDTypeCode() == ParticipantObjectIdTypeCode.PatientNumber).size() != 1) {
115 throw new AuditException("Must one ParticipantObjectIdentification with ParticipantObjectIDTypeCode PatientNumber");
116 }
117 if (getMessage().findParticipantObjectIdentifications(poi -> poi.getParticipantObjectIDTypeCode() == ParticipantObjectIdTypeCode.StudyInstanceUID).isEmpty()) {
118 throw new AuditException("Must have one or more ParticipantObjectIdentification with ParticipantObjectIDTypeCode StudyInstanceUID");
119 }
120 }
121 }