1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.commons.ihe.core.atna.custom;
17
18 import org.apache.commons.lang3.StringUtils;
19 import org.openhealthtools.ihe.atna.auditor.PIXAuditor;
20 import org.openhealthtools.ihe.atna.auditor.codes.ihe.IHETransactionParticipantObjectIDTypeCodes;
21 import org.openhealthtools.ihe.atna.auditor.codes.rfc3881.RFC3881EventCodes;
22 import org.openhealthtools.ihe.atna.auditor.codes.rfc3881.RFC3881ParticipantObjectCodes;
23 import org.openhealthtools.ihe.atna.auditor.context.AuditorModuleContext;
24 import org.openhealthtools.ihe.atna.auditor.events.ihe.PatientRecordEvent;
25 import org.openhealthtools.ihe.atna.auditor.models.rfc3881.TypeValuePairType;
26
27 import java.util.Arrays;
28
29 import static org.openehealth.ipf.commons.ihe.core.atna.custom.CustomAuditorUtils.configureEvent;
30
31
32
33
34
35
36
37
38
39
40 public class CustomPixAuditor extends PIXAuditor {
41
42 public static CustomPixAuditor getAuditor() {
43 AuditorModuleContext ctx = AuditorModuleContext.getContext();
44 return (CustomPixAuditor) ctx.getAuditor(CustomPixAuditor.class);
45 }
46
47 public void auditIti64(
48 boolean serverSide,
49 RFC3881EventCodes.RFC3881EventOutcomeCodes eventOutcome,
50 String pixManagerIpAddress,
51 String sendingFacility,
52 String sendingApp,
53 String documentRegistryUri,
54 String receivingFacility,
55 String receivingApp,
56 String hl7MessageControlId,
57 String localPatientId,
58 String subsumedLocalPatientId,
59 String newPatientId,
60 String previousPatientId,
61 String submissionSetUuid)
62 {
63 if (! isAuditorEnabled()) {
64 return;
65 }
66
67 CustomIHETransactionEventTypeCodes.NotifyXadPidLinkChange transactionCode =
68 new CustomIHETransactionEventTypeCodes.NotifyXadPidLinkChange();
69
70 PatientRecordEvent event = new PatientRecordEvent(
71 true,
72 eventOutcome,
73 RFC3881EventCodes.RFC3881EventActionCodes.UPDATE,
74 transactionCode,
75 null);
76
77 configureEvent(
78 this,
79 serverSide,
80 event,
81 sendingFacility + '|' + sendingApp,
82 null,
83 receivingFacility + '|' + receivingApp,
84 documentRegistryUri,
85 pixManagerIpAddress,
86 null);
87
88 TypeValuePairType messageIdVP = event.getTypeValuePair("MSH-10", hl7MessageControlId);
89 TypeValuePairType localPatientIdVP = event.getTypeValuePair("urn:ihe:iti:xpid:2017:patientIdentifierType", "localPatientId");
90 TypeValuePairType subsumedPatientIdVP = event.getTypeValuePair("urn:ihe:iti:xpid:2017:patientIdentifierType", "subsumedPatientId");
91 TypeValuePairType newPatientIdIdVP = event.getTypeValuePair("urn:ihe:iti:xpid:2017:patientIdentifierType", "newPatientId");
92 TypeValuePairType previousPatientIdIdVP = event.getTypeValuePair("urn:ihe:iti:xpid:2017:patientIdentifierType", "previousPatientId");
93
94 boolean subsumedLocalPatientIdPresent = StringUtils.isNoneBlank(subsumedLocalPatientId);
95 boolean newPatientIdEqualsToPrevious = StringUtils.equals(newPatientId, previousPatientId);
96
97 event.addParticipantObjectIdentification(
98 new RFC3881ParticipantObjectCodes.RFC3881ParticipantObjectIDTypeCodes.PatientNumber(),
99 null,
100 null,
101 Arrays.asList(messageIdVP, localPatientIdVP),
102 localPatientId,
103 RFC3881ParticipantObjectCodes.RFC3881ParticipantObjectTypeCodes.PERSON,
104 RFC3881ParticipantObjectCodes.RFC3881ParticipantObjectTypeRoleCodes.PATIENT,
105 subsumedLocalPatientIdPresent ? RFC3881ParticipantObjectCodes.RFC3881ParticipantObjectDataLifeCycleCodes.ORIGINATION : null,
106 null);
107
108 if (subsumedLocalPatientIdPresent) {
109 event.addParticipantObjectIdentification(
110 new RFC3881ParticipantObjectCodes.RFC3881ParticipantObjectIDTypeCodes.PatientNumber(),
111 null,
112 null,
113 Arrays.asList(messageIdVP, subsumedPatientIdVP),
114 subsumedLocalPatientId,
115 RFC3881ParticipantObjectCodes.RFC3881ParticipantObjectTypeCodes.PERSON,
116 RFC3881ParticipantObjectCodes.RFC3881ParticipantObjectTypeRoleCodes.PATIENT,
117 RFC3881ParticipantObjectCodes.RFC3881ParticipantObjectDataLifeCycleCodes.LOGICAL_DELETION,
118 null);
119 }
120
121 event.addParticipantObjectIdentification(
122 new RFC3881ParticipantObjectCodes.RFC3881ParticipantObjectIDTypeCodes.PatientNumber(),
123 null,
124 null,
125 Arrays.asList(messageIdVP, newPatientIdIdVP),
126 newPatientId,
127 RFC3881ParticipantObjectCodes.RFC3881ParticipantObjectTypeCodes.PERSON,
128 RFC3881ParticipantObjectCodes.RFC3881ParticipantObjectTypeRoleCodes.PATIENT,
129 newPatientIdEqualsToPrevious ? null : RFC3881ParticipantObjectCodes.RFC3881ParticipantObjectDataLifeCycleCodes.ORIGINATION,
130 null);
131
132 event.addParticipantObjectIdentification(
133 new RFC3881ParticipantObjectCodes.RFC3881ParticipantObjectIDTypeCodes.PatientNumber(),
134 null,
135 null,
136 Arrays.asList(messageIdVP, previousPatientIdIdVP),
137 previousPatientId,
138 RFC3881ParticipantObjectCodes.RFC3881ParticipantObjectTypeCodes.PERSON,
139 RFC3881ParticipantObjectCodes.RFC3881ParticipantObjectTypeRoleCodes.PATIENT,
140 newPatientIdEqualsToPrevious ? null : RFC3881ParticipantObjectCodes.RFC3881ParticipantObjectDataLifeCycleCodes.LOGICAL_DELETION,
141 null);
142
143 if (serverSide && StringUtils.isNotBlank(submissionSetUuid)) {
144 event.addParticipantObjectIdentification(
145 new IHETransactionParticipantObjectIDTypeCodes.SubmissionSet(),
146 null,
147 null,
148 null,
149 submissionSetUuid,
150 RFC3881ParticipantObjectCodes.RFC3881ParticipantObjectTypeCodes.SYSTEM,
151 RFC3881ParticipantObjectCodes.RFC3881ParticipantObjectTypeRoleCodes.JOB,
152 null,
153 null);
154 }
155
156 audit(event);
157 }
158
159 }