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 public class BeginTransferringDicomInstancesBuilder extends BaseAuditMessageBuilder<BeginTransferringDicomInstancesBuilder> {
39
40 public BeginTransferringDicomInstancesBuilder(
41 EventOutcomeIndicator outcome,
42 String eventOutcomeDescription,
43 EventType eventType,
44 PurposeOfUse... purposesOfUse) {
45 super();
46 setEventIdentification(outcome,
47 eventOutcomeDescription,
48 EventActionCode.Execute,
49 EventIdCode.BeginTransferringDICOMInstances,
50 eventType,
51 purposesOfUse
52 );
53 }
54
55
56
57
58
59
60
61
62
63
64 public BeginTransferringDicomInstancesBuilder setSendingProcessParticipant(String userId,
65 String altUserId,
66 String userName,
67 String networkId,
68 boolean userIsRequestor) {
69 return addSourceActiveParticipant(userId, altUserId, userName, networkId, userIsRequestor);
70 }
71
72
73
74
75
76
77
78
79
80 public BeginTransferringDicomInstancesBuilder setReceivingProcessParticipant(String userId,
81 String altUserId,
82 String userName,
83 String networkId,
84 boolean userIsRequestor) {
85 return addDestinationActiveParticipant(userId, altUserId, userName, networkId, userIsRequestor);
86 }
87
88
89
90
91
92
93 public BeginTransferringDicomInstancesBuilder setPatientParticipantObject(String patientId, String patientName) {
94 if (patientId != null) {
95 addPatientParticipantObject(patientId, patientName, Collections.emptyList(), null);
96 }
97 return self();
98 }
99
100
101
102
103
104
105 public BeginTransferringDicomInstancesBuilder addTransferredStudyParticipantObject(String studyId, String uids) {
106 return addStudyParticipantObject(
107 studyId,
108 Collections.singletonList(getTypeValuePair("ContainsSOPClass", uids)));
109 }
110
111 @Override
112 public void validate() {
113 super.validate();
114 if (getMessage().findActiveParticipants(ap -> ap.getRoleIDCodes().contains(ActiveParticipantRoleIdCode.Source)).size() != 1) {
115 throw new AuditException("Must have one ActiveParticipant with RoleIDCode Source");
116 }
117 if (getMessage().findActiveParticipants(ap -> ap.getRoleIDCodes().contains(ActiveParticipantRoleIdCode.Destination)).size() != 1) {
118 throw new AuditException("Must have one ActiveParticipant with RoleIDCode Destination");
119 }
120 if (getMessage().findParticipantObjectIdentifications(poi -> poi.getParticipantObjectIDTypeCode() == ParticipantObjectIdTypeCode.PatientNumber).size() != 1) {
121 throw new AuditException("Must have one ParticipantObjectIdentification with ParticipantObjectIDTypeCode PatientNumber");
122 }
123 if (getMessage().findParticipantObjectIdentifications(poi -> poi.getParticipantObjectIDTypeCode() == ParticipantObjectIdTypeCode.StudyInstanceUID).isEmpty()) {
124 throw new AuditException("Must have one or more ParticipantObjectIdentification with ParticipantObjectIDTypeCode StudyInstanceUID");
125 }
126 }
127 }