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.DataImportBuilder;
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 PHIImportBuilder<T extends PHIImportBuilder<T>> extends IHEAuditMessageBuilder<T, DataImportBuilder> {
43
44
45 public PHIImportBuilder(AuditContext auditContext,
46 AuditDataset auditDataset,
47 EventType eventType,
48 PurposeOfUse... purposesOfUse) {
49 this(auditContext, auditDataset, EventActionCode.Create, eventType, purposesOfUse);
50 }
51
52 public PHIImportBuilder(AuditContext auditContext,
53 AuditDataset auditDataset,
54 EventActionCode eventActionCode,
55 EventType eventType,
56 PurposeOfUse... purposesOfUse) {
57 this(auditContext, auditDataset, auditDataset.getEventOutcomeIndicator(),
58 auditDataset.getEventOutcomeDescription(), eventActionCode, eventType, purposesOfUse);
59 }
60
61 public PHIImportBuilder(AuditContext auditContext,
62 AuditDataset auditDataset,
63 EventOutcomeIndicator eventOutcomeIndicator,
64 String eventOutcomeDescription,
65 EventActionCode eventActionCode,
66 EventType eventType,
67 PurposeOfUse... purposesOfUse) {
68 super(auditContext, new DataImportBuilder(
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 addImportedEntity(
96 String objectId,
97 ParticipantObjectIdType participantObjectIdType,
98 ParticipantObjectTypeCodeRole participantObjectTypeCodeRole,
99 List<TypeValuePairType> details) {
100 return addImportedEntity(objectId, participantObjectIdType, ParticipantObjectTypeCode.System,
101 participantObjectTypeCodeRole, details);
102 }
103
104 public T addImportedEntity(
105 String objectId,
106 ParticipantObjectIdType participantObjectIdType,
107 ParticipantObjectTypeCode participantObjectTypeCode,
108 ParticipantObjectTypeCodeRole participantObjectTypeCodeRole,
109 List<TypeValuePairType> details) {
110 if (objectId != null) {
111 delegate.addParticipantObjectIdentification(
112 participantObjectIdType,
113 null,
114 null,
115 details,
116 objectId,
117 participantObjectTypeCode,
118 participantObjectTypeCodeRole,
119 null,
120 null);
121 }
122 return self();
123 }
124
125 @Override
126 public void validate() {
127 super.validate();
128 }
129 }