1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.openehealth.ipf.commons.ihe.core.atna.event;
18
19 import org.openehealth.ipf.commons.audit.AuditContext;
20 import org.openehealth.ipf.commons.audit.codes.EventActionCode;
21 import org.openehealth.ipf.commons.audit.codes.EventOutcomeIndicator;
22 import org.openehealth.ipf.commons.audit.codes.ParticipantObjectTypeCode;
23 import org.openehealth.ipf.commons.audit.codes.ParticipantObjectTypeCodeRole;
24 import org.openehealth.ipf.commons.audit.event.DataExportBuilder;
25 import org.openehealth.ipf.commons.audit.model.TypeValuePairType;
26 import org.openehealth.ipf.commons.audit.types.EventType;
27 import org.openehealth.ipf.commons.audit.types.ParticipantObjectIdType;
28 import org.openehealth.ipf.commons.audit.types.PurposeOfUse;
29 import org.openehealth.ipf.commons.ihe.core.atna.AuditDataset;
30
31 import java.util.Collections;
32 import java.util.List;
33
34
35
36
37
38
39
40
41
42 public class PHIExportBuilder<T extends PHIExportBuilder<T>> extends IHEAuditMessageBuilder<T, DataExportBuilder> {
43
44 public PHIExportBuilder(AuditContext auditContext,
45 AuditDataset auditDataset,
46 EventType eventType,
47 PurposeOfUse... purposesOfUse) {
48 this(auditContext, auditDataset, EventActionCode.Read, eventType, purposesOfUse);
49 }
50
51 public PHIExportBuilder(AuditContext auditContext,
52 AuditDataset auditDataset,
53 EventActionCode eventActionCode,
54 EventType eventType,
55 PurposeOfUse... purposesOfUse) {
56 this(auditContext, auditDataset, auditDataset.getEventOutcomeIndicator(),
57 auditDataset.getEventOutcomeDescription(),
58 eventActionCode, eventType, purposesOfUse);
59 }
60
61 public PHIExportBuilder(AuditContext auditContext,
62 AuditDataset auditDataset,
63 EventOutcomeIndicator eventOutcomeIndicator,
64 String eventOutcomeDescription,
65 EventActionCode eventActionCode,
66 EventType eventType,
67 PurposeOfUse... purposesOfUse) {
68 super(auditContext, new DataExportBuilder(
69 eventOutcomeIndicator,
70 eventOutcomeDescription,
71 eventActionCode,
72 eventType,
73 purposesOfUse));
74
75
76 if (auditDataset.isServerSide()) {
77 setRemoteParticipant(auditDataset);
78 addHumanRequestor(auditDataset);
79 setLocalParticipant(auditDataset);
80 } else {
81 setLocalParticipant(auditDataset);
82 addHumanRequestor(auditDataset);
83 setRemoteParticipant(auditDataset);
84 }
85 }
86
87 public T setPatient(String patientId) {
88 if (patientId != null) {
89 delegate.addPatientParticipantObject(patientId, null,
90 Collections.emptyList(), null);
91 }
92 return self();
93 }
94
95 public T addExportedEntity(
96 String objectId,
97 ParticipantObjectIdType participantObjectIdType,
98 ParticipantObjectTypeCodeRole participantObjectTypeCodeRole,
99 List<TypeValuePairType> details) {
100 return addExportedEntity(
101 objectId,
102 participantObjectIdType,
103 ParticipantObjectTypeCode.System,
104 participantObjectTypeCodeRole,
105 details);
106 }
107
108 public T addExportedEntity(
109 String objectId,
110 ParticipantObjectIdType participantObjectIdType,
111 ParticipantObjectTypeCode participantObjectTypeCode,
112 ParticipantObjectTypeCodeRole participantObjectTypeCodeRole,
113 List<TypeValuePairType> details) {
114 delegate.addParticipantObjectIdentification(
115 participantObjectIdType,
116 null,
117 null,
118 details,
119 objectId,
120 participantObjectTypeCode,
121 participantObjectTypeCodeRole,
122 null,
123 null);
124 return self();
125 }
126
127 @Override
128 public void validate() {
129 super.validate();
130 }
131 }