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.EventActionCode;
21 import org.openehealth.ipf.commons.audit.codes.EventIdCode;
22 import org.openehealth.ipf.commons.audit.codes.EventOutcomeIndicator;
23 import org.openehealth.ipf.commons.audit.codes.ParticipantObjectIdTypeCode;
24 import org.openehealth.ipf.commons.audit.types.EventType;
25 import org.openehealth.ipf.commons.audit.types.PurposeOfUse;
26
27 import java.util.Collections;
28
29
30
31
32
33
34
35
36
37
38
39
40
41 public class DicomStudyDeletedBuilder extends BaseAuditMessageBuilder<DicomStudyDeletedBuilder> {
42
43 public DicomStudyDeletedBuilder(EventOutcomeIndicator outcome,
44 String eventOutcomeDescription,
45 EventType eventType,
46 PurposeOfUse... purposesOfUse) {
47 super();
48 setEventIdentification(outcome,
49 eventOutcomeDescription,
50 EventActionCode.Delete,
51 EventIdCode.DICOMStudyDeleted,
52 eventType,
53 purposesOfUse
54 );
55 }
56
57
58
59
60
61
62 public DicomStudyDeletedBuilder setPatientParticipantObject(String patientId, String patientName) {
63 if (patientId != null) {
64 addPatientParticipantObject(patientId, patientName, Collections.emptyList(), null);
65 }
66 return self();
67 }
68
69 @Override
70 public void validate() {
71 super.validate();
72 int participants = getMessage().getActiveParticipants().size();
73 if (participants < 1 || participants > 2) {
74 throw new AuditException("Must have one or two ActiveParticipants");
75 }
76 if (getMessage().findParticipantObjectIdentifications(poi -> poi.getParticipantObjectIDTypeCode() == ParticipantObjectIdTypeCode.StudyInstanceUID).isEmpty()) {
77 throw new AuditException("Must have one or more ParticipantObjectIdentification with ParticipantObjectIDTypeCode StudyInstanceUID");
78 }
79 if (getMessage().findParticipantObjectIdentifications(poi -> poi.getParticipantObjectIDTypeCode() == ParticipantObjectIdTypeCode.PatientNumber).size() != 1) {
80 throw new AuditException("Must have one ParticipantObjectIdentification with ParticipantObjectIDTypeCode PatientNumber");
81 }
82 }
83 }