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 public class DicomInstancesAccessedBuilder extends BaseAuditMessageBuilder<DicomInstancesAccessedBuilder> {
43
44 public DicomInstancesAccessedBuilder(EventOutcomeIndicator outcome,
45 String eventOutcomeDescription,
46 EventActionCode eventActionCode,
47 EventType eventType,
48 PurposeOfUse... purposesOfUse) {
49 super();
50 setEventIdentification(outcome,
51 eventOutcomeDescription,
52 eventActionCode,
53 EventIdCode.DICOMInstancesAccessed,
54 eventType,
55 purposesOfUse
56 );
57 }
58
59
60
61
62
63
64 public DicomInstancesAccessedBuilder setPatientParticipantObject(String patientId, String patientName) {
65 if (patientId != null) {
66 addPatientParticipantObject(patientId, patientName, Collections.emptyList(), null);
67 }
68 return self();
69 }
70
71 @Override
72 public void validate() {
73 super.validate();
74 int participants = getMessage().getActiveParticipants().size();
75 if (participants < 1 || participants > 2) {
76 throw new AuditException("Must have one or two ActiveParticipants");
77 }
78 if (getMessage().findParticipantObjectIdentifications(poi -> poi.getParticipantObjectIDTypeCode() == ParticipantObjectIdTypeCode.StudyInstanceUID).isEmpty()) {
79 throw new AuditException("Must have one or more ParticipantObjectIdentification with ParticipantObjectIDTypeCode StudyInstanceUID");
80 }
81 if (getMessage().findParticipantObjectIdentifications(poi -> poi.getParticipantObjectIDTypeCode() == ParticipantObjectIdTypeCode.PatientNumber).size() != 1) {
82 throw new AuditException("Must one ParticipantObjectIdentification with ParticipantObjectIDTypeCode PatientNumber");
83 }
84 }
85 }