[507] | 1 | /*
|
---|
| 2 | * To change this template, choose Tools | Templates
|
---|
| 3 | * and open the template in the editor.
|
---|
| 4 | */
|
---|
| 5 | package gov.hhs.fha.nhinc.transform.audit;
|
---|
| 6 |
|
---|
| 7 | import org.apache.commons.logging.Log;
|
---|
| 8 | import org.apache.commons.logging.LogFactory;
|
---|
| 9 |
|
---|
| 10 |
|
---|
| 11 | import javax.xml.bind.JAXBContext;
|
---|
| 12 | import java.io.ByteArrayOutputStream;
|
---|
| 13 | import javax.xml.bind.Marshaller;
|
---|
| 14 |
|
---|
| 15 | import com.services.nhinc.schema.auditmessage.AuditMessageType;
|
---|
| 16 | import com.services.nhinc.schema.auditmessage.AuditSourceIdentificationType;
|
---|
| 17 | import com.services.nhinc.schema.auditmessage.CodedValueType;
|
---|
| 18 | import com.services.nhinc.schema.auditmessage.ParticipantObjectIdentificationType;
|
---|
| 19 | import gov.hhs.fha.nhinc.common.auditlog.LogSubjectAddedRequestType;
|
---|
| 20 | import gov.hhs.fha.nhinc.common.auditlog.LogSubjectRevisedRequestType;
|
---|
| 21 | import gov.hhs.fha.nhinc.common.auditlog.LogSubjectRevokedRequestType;
|
---|
| 22 | import gov.hhs.fha.nhinc.common.auditlog.LogNhinSubjectDiscoveryAckRequestType;
|
---|
| 23 | import gov.hhs.fha.nhinc.common.auditlog.LogSubjectReidentificationRequestType;
|
---|
| 24 | import gov.hhs.fha.nhinc.common.auditlog.LogSubjectReidentificationResponseType;
|
---|
| 25 | import gov.hhs.fha.nhinc.common.nhinccommon.AssertionType;
|
---|
| 26 | import gov.hhs.fha.nhinc.transform.subdisc.HL7Extractors;
|
---|
| 27 | import org.hl7.v3.*;
|
---|
| 28 | import gov.hhs.fha.nhinc.common.nhinccommon.UserType;
|
---|
| 29 | import gov.hhs.fha.nhinc.common.auditlog.LogEventRequestType;
|
---|
| 30 |
|
---|
| 31 | /**
|
---|
| 32 | *
|
---|
| 33 | * @author MFLYNN02
|
---|
| 34 | */
|
---|
| 35 | public class SubjectDiscoveryTransforms {
|
---|
| 36 |
|
---|
| 37 | private static Log log = LogFactory.getLog(SubjectDiscoveryTransforms.class);
|
---|
| 38 |
|
---|
| 39 | public static LogEventRequestType transformPRPA2013012AuditMsg(LogSubjectAddedRequestType message) {
|
---|
| 40 | AuditMessageType auditMsg = new AuditMessageType();
|
---|
| 41 | LogEventRequestType response = new LogEventRequestType();
|
---|
| 42 | response.setDirection(message.getDirection());
|
---|
| 43 | response.setInterface(message.getInterface());
|
---|
| 44 |
|
---|
| 45 | log.info("******************************************************************");
|
---|
| 46 | log.info("Entering transformPRPA2013012AuditMsg() method.");
|
---|
| 47 | log.info("******************************************************************");
|
---|
| 48 |
|
---|
| 49 | // Extract UserInfo from Message.Assertion
|
---|
| 50 | UserType userInfo = new UserType();
|
---|
| 51 | if (message != null &&
|
---|
| 52 | message.getMessage() != null &&
|
---|
| 53 | message.getMessage().getAssertion() != null &&
|
---|
| 54 | message.getMessage().getAssertion().getUserInfo() != null) {
|
---|
| 55 | userInfo = message.getMessage().getAssertion().getUserInfo();
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | // Create EventIdentification
|
---|
| 59 | CodedValueType eventID = new CodedValueType();
|
---|
| 60 | eventID = AuditDataTransformHelper.createEventId(AuditDataTransformConstants.EVENT_ID_CODE_SYS_NAME_SDN, AuditDataTransformConstants.EVENT_ID_DISPLAY_NAME_SDNEW, AuditDataTransformConstants.EVENT_ID_CODE_SYS_NAME_SDN, AuditDataTransformConstants.EVENT_ID_DISPLAY_NAME_SDNEW);
|
---|
| 61 | auditMsg.setEventIdentification(AuditDataTransformHelper.createEventIdentification(AuditDataTransformConstants.EVENT_ACTION_CODE_CREATE, AuditDataTransformConstants.EVENT_OUTCOME_INDICATOR_SUCCESS, eventID));
|
---|
| 62 |
|
---|
| 63 | // Create Active Participant Section
|
---|
| 64 | if (userInfo != null) {
|
---|
| 65 | AuditMessageType.ActiveParticipant participant = AuditDataTransformHelper.createActiveParticipantFromUser(userInfo, true);
|
---|
| 66 | auditMsg.getActiveParticipant().add(participant);
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | /* Assign AuditSourceIdentification */
|
---|
| 70 | String communityId = "";
|
---|
| 71 | String communityName = "";
|
---|
| 72 | String patientId = "";
|
---|
| 73 |
|
---|
| 74 | if (message != null &&
|
---|
| 75 | message.getMessage() != null &&
|
---|
| 76 | message.getMessage().getPRPAIN201301UV() != null) {
|
---|
| 77 | PRPAMT201301UVPatient patient = HL7Extractors.ExtractHL7PatientFromMessage(message.getMessage().getPRPAIN201301UV());
|
---|
| 78 | communityId = patient.getId().get(0).getRoot();
|
---|
| 79 | patientId = message.getMessage().getPRPAIN201301UV().getControlActProcess().getSubject().get(0).getRegistrationEvent().getSubject1().getPatient().getId().get(0).getExtension();
|
---|
| 80 | patientId = AuditDataTransformHelper.createCompositePatientId(communityId, patientId);
|
---|
| 81 |
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | if (userInfo != null &&
|
---|
| 85 | userInfo.getOrg() != null) {
|
---|
| 86 | if (userInfo.getOrg().getHomeCommunityId() != null) {
|
---|
| 87 | communityId = userInfo.getOrg().getHomeCommunityId();
|
---|
| 88 | }
|
---|
| 89 | if (userInfo.getOrg().getName() != null) {
|
---|
| 90 | communityName = userInfo.getOrg().getName();
|
---|
| 91 | }
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | AuditSourceIdentificationType auditSource = AuditDataTransformHelper.createAuditSourceIdentification(communityId, communityName);
|
---|
| 95 | auditMsg.getAuditSourceIdentification().add(auditSource);
|
---|
| 96 |
|
---|
| 97 | /* Assign ParticipationObjectIdentification */
|
---|
| 98 | ParticipantObjectIdentificationType participantObject = AuditDataTransformHelper.createParticipantObjectIdentification(patientId);
|
---|
| 99 |
|
---|
| 100 | // Fill in the message field with the contents of the event message
|
---|
| 101 | try {
|
---|
| 102 | JAXBContext jc = JAXBContext.newInstance("org.hl7.v3");
|
---|
| 103 | Marshaller marshaller = jc.createMarshaller();
|
---|
| 104 | ByteArrayOutputStream baOutStrm = new ByteArrayOutputStream();
|
---|
| 105 | baOutStrm.reset();
|
---|
| 106 | marshaller.marshal(message.getMessage().getPRPAIN201301UV(), baOutStrm);
|
---|
| 107 |
|
---|
| 108 | participantObject.setParticipantObjectQuery(baOutStrm.toByteArray());
|
---|
| 109 | } catch (Exception e) {
|
---|
| 110 | e.printStackTrace();
|
---|
| 111 | log.error("EXCEPTION when marshalling 201301 : " + e);
|
---|
| 112 | throw new RuntimeException();
|
---|
| 113 | }
|
---|
| 114 | auditMsg.getParticipantObjectIdentification().add(participantObject);
|
---|
| 115 |
|
---|
| 116 | log.info("******************************************************************");
|
---|
| 117 | log.info("Exiting transformPRPA2013012AuditMsg() method.");
|
---|
| 118 | log.info("******************************************************************");
|
---|
| 119 |
|
---|
| 120 | response.setAuditMessage(auditMsg);
|
---|
| 121 | return response;
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 | public static LogEventRequestType transformPRPA2013022AuditMsg(LogSubjectRevisedRequestType message) {
|
---|
| 125 | AuditMessageType auditMsg = new AuditMessageType();
|
---|
| 126 | LogEventRequestType response = new LogEventRequestType();
|
---|
| 127 | response.setDirection(message.getDirection());
|
---|
| 128 | response.setInterface(message.getInterface());
|
---|
| 129 |
|
---|
| 130 | log.info("******************************************************************");
|
---|
| 131 | log.info("Entering transformPRPA2013022AuditMsg() method.");
|
---|
| 132 | log.info("******************************************************************");
|
---|
| 133 |
|
---|
| 134 | // Extract UserInfo from Message.Assertion
|
---|
| 135 | UserType userInfo = new UserType();
|
---|
| 136 | if (message != null &&
|
---|
| 137 | message.getMessage() != null &&
|
---|
| 138 | message.getMessage().getAssertion() != null &&
|
---|
| 139 | message.getMessage().getAssertion().getUserInfo() != null) {
|
---|
| 140 | userInfo = message.getMessage().getAssertion().getUserInfo();
|
---|
| 141 | }
|
---|
| 142 |
|
---|
| 143 |
|
---|
| 144 | // Create EventIdentification
|
---|
| 145 | CodedValueType eventID = new CodedValueType();
|
---|
| 146 | eventID = AuditDataTransformHelper.createEventId(AuditDataTransformConstants.EVENT_ID_CODE_SYS_NAME_SDR, AuditDataTransformConstants.EVENT_ID_DISPLAY_NAME_SDREV, AuditDataTransformConstants.EVENT_ID_CODE_SYS_NAME_SDR, AuditDataTransformConstants.EVENT_ID_DISPLAY_NAME_SDREV);
|
---|
| 147 | auditMsg.setEventIdentification(AuditDataTransformHelper.createEventIdentification(AuditDataTransformConstants.EVENT_ACTION_CODE_UPDATE, AuditDataTransformConstants.EVENT_OUTCOME_INDICATOR_SUCCESS, eventID));
|
---|
| 148 |
|
---|
| 149 | // Create Active Participant Section
|
---|
| 150 | if (message != null) {
|
---|
| 151 | AuditMessageType.ActiveParticipant participant = AuditDataTransformHelper.createActiveParticipantFromUser(userInfo, true);
|
---|
| 152 | auditMsg.getActiveParticipant().add(participant);
|
---|
| 153 | }
|
---|
| 154 |
|
---|
| 155 | /* Assign AuditSourceIdentification */
|
---|
| 156 | String communityId = "";
|
---|
| 157 | String communityName = "";
|
---|
| 158 | String patientId = "";
|
---|
| 159 |
|
---|
| 160 | if (message != null &&
|
---|
| 161 | message.getMessage() != null &&
|
---|
| 162 | message.getMessage().getPRPAIN201302UV() != null) {
|
---|
| 163 | PRPAMT201302UVPatient patient = HL7Extractors.ExtractHL7PatientFromMessage(message.getMessage().getPRPAIN201302UV());
|
---|
| 164 | communityId = patient.getId().get(0).getRoot();
|
---|
| 165 | patientId = message.getMessage().getPRPAIN201302UV().getControlActProcess().getSubject().get(0).getRegistrationEvent().getSubject1().getPatient().getId().get(0).getExtension();
|
---|
| 166 | patientId = AuditDataTransformHelper.createCompositePatientId(communityId, patientId);
|
---|
| 167 |
|
---|
| 168 | }
|
---|
| 169 |
|
---|
| 170 | if (userInfo != null &&
|
---|
| 171 | userInfo.getOrg() != null) {
|
---|
| 172 | if (userInfo.getOrg().getHomeCommunityId() != null) {
|
---|
| 173 | communityId = userInfo.getOrg().getHomeCommunityId();
|
---|
| 174 | }
|
---|
| 175 | if (userInfo.getOrg().getName() != null) {
|
---|
| 176 | communityName = userInfo.getOrg().getName();
|
---|
| 177 | }
|
---|
| 178 | }
|
---|
| 179 |
|
---|
| 180 | AuditSourceIdentificationType auditSource = AuditDataTransformHelper.createAuditSourceIdentification(communityId, communityName);
|
---|
| 181 | auditMsg.getAuditSourceIdentification().add(auditSource);
|
---|
| 182 |
|
---|
| 183 | /* Assign ParticipationObjectIdentification */
|
---|
| 184 | ParticipantObjectIdentificationType participantObject = AuditDataTransformHelper.createParticipantObjectIdentification(patientId);
|
---|
| 185 |
|
---|
| 186 | // Fill in the message field with the contents of the event message
|
---|
| 187 | try {
|
---|
| 188 | JAXBContext jc = JAXBContext.newInstance("org.hl7.v3");
|
---|
| 189 | Marshaller marshaller = jc.createMarshaller();
|
---|
| 190 | ByteArrayOutputStream baOutStrm = new ByteArrayOutputStream();
|
---|
| 191 | baOutStrm.reset();
|
---|
| 192 | marshaller.marshal(message.getMessage().getPRPAIN201302UV(), baOutStrm);
|
---|
| 193 |
|
---|
| 194 | participantObject.setParticipantObjectQuery(baOutStrm.toByteArray());
|
---|
| 195 | } catch (Exception e) {
|
---|
| 196 | e.printStackTrace();
|
---|
| 197 | throw new RuntimeException();
|
---|
| 198 | }
|
---|
| 199 | auditMsg.getParticipantObjectIdentification().add(participantObject);
|
---|
| 200 |
|
---|
| 201 | log.info("******************************************************************");
|
---|
| 202 | log.info("Exiting transformPRPA2013022AuditMsg() method.");
|
---|
| 203 | log.info("******************************************************************");
|
---|
| 204 |
|
---|
| 205 | response.setAuditMessage(auditMsg);
|
---|
| 206 | return response;
|
---|
| 207 | }
|
---|
| 208 |
|
---|
| 209 | public static LogEventRequestType transformPRPA2013032AuditMsg(LogSubjectRevokedRequestType message) {
|
---|
| 210 | AuditMessageType auditMsg = new AuditMessageType();
|
---|
| 211 | LogEventRequestType response = new LogEventRequestType();
|
---|
| 212 | response.setDirection(message.getDirection());
|
---|
| 213 | response.setInterface(message.getInterface());
|
---|
| 214 |
|
---|
| 215 | log.info("******************************************************************");
|
---|
| 216 | log.info("Entering transformPRPA2013032AuditMsg() method.");
|
---|
| 217 | log.info("******************************************************************");
|
---|
| 218 |
|
---|
| 219 | // Extract UserInfo from Message.Assertion
|
---|
| 220 | UserType userInfo = new UserType();
|
---|
| 221 | if (message != null &&
|
---|
| 222 | message.getMessage() != null &&
|
---|
| 223 | message.getMessage().getAssertion() != null &&
|
---|
| 224 | message.getMessage().getAssertion().getUserInfo() != null) {
|
---|
| 225 | userInfo = message.getMessage().getAssertion().getUserInfo();
|
---|
| 226 | }
|
---|
| 227 |
|
---|
| 228 | // Create EventIdentification
|
---|
| 229 | CodedValueType eventID = new CodedValueType();
|
---|
| 230 | eventID = AuditDataTransformHelper.createEventId(AuditDataTransformConstants.EVENT_ID_CODE_SYS_NAME_SDD, AuditDataTransformConstants.EVENT_ID_DISPLAY_NAME_SDDEL, AuditDataTransformConstants.EVENT_ID_CODE_SYS_NAME_SDD, AuditDataTransformConstants.EVENT_ID_DISPLAY_NAME_SDDEL);
|
---|
| 231 | auditMsg.setEventIdentification(AuditDataTransformHelper.createEventIdentification(AuditDataTransformConstants.EVENT_ACTION_CODE_DELETE, AuditDataTransformConstants.EVENT_OUTCOME_INDICATOR_SUCCESS, eventID));
|
---|
| 232 |
|
---|
| 233 |
|
---|
| 234 | // Create Active Participant Section
|
---|
| 235 | if (message != null) {
|
---|
| 236 | AuditMessageType.ActiveParticipant participant = AuditDataTransformHelper.createActiveParticipantFromUser(userInfo, true);
|
---|
| 237 | auditMsg.getActiveParticipant().add(participant);
|
---|
| 238 | }
|
---|
| 239 |
|
---|
| 240 | /* Assign AuditSourceIdentification */
|
---|
| 241 | String communityId = "";
|
---|
| 242 | String communityName = "";
|
---|
| 243 | String patientId = "";
|
---|
| 244 |
|
---|
| 245 | if (message != null &&
|
---|
| 246 | message.getMessage() != null &&
|
---|
| 247 | message.getMessage().getPRPAIN201303UV() != null) {
|
---|
| 248 | PRPAMT201305UVPatient patient = HL7Extractors.ExtractHL7PatientFromMessage(message.getMessage().getPRPAIN201303UV());
|
---|
| 249 | communityId = patient.getId().get(0).getRoot();
|
---|
| 250 | patientId = message.getMessage().getPRPAIN201303UV().getControlActProcess().getSubject().get(0).getRegistrationEvent().getSubject1().getPatient().getId().get(0).getExtension();
|
---|
| 251 | patientId = AuditDataTransformHelper.createCompositePatientId(communityId, patientId);
|
---|
| 252 |
|
---|
| 253 | }
|
---|
| 254 |
|
---|
| 255 | if (userInfo != null &&
|
---|
| 256 | userInfo.getOrg() != null) {
|
---|
| 257 | if (userInfo.getOrg().getHomeCommunityId() != null) {
|
---|
| 258 | communityId = userInfo.getOrg().getHomeCommunityId();
|
---|
| 259 | }
|
---|
| 260 | if (userInfo.getOrg().getName() != null) {
|
---|
| 261 | communityName = userInfo.getOrg().getName();
|
---|
| 262 | }
|
---|
| 263 | }
|
---|
| 264 |
|
---|
| 265 |
|
---|
| 266 | AuditSourceIdentificationType auditSource = AuditDataTransformHelper.createAuditSourceIdentification(communityId, communityName);
|
---|
| 267 | auditMsg.getAuditSourceIdentification().add(auditSource);
|
---|
| 268 |
|
---|
| 269 | /* Assign ParticipationObjectIdentification */
|
---|
| 270 | ParticipantObjectIdentificationType participantObject = AuditDataTransformHelper.createParticipantObjectIdentification(patientId);
|
---|
| 271 |
|
---|
| 272 | // Fill in the message field with the contents of the event message
|
---|
| 273 | try {
|
---|
| 274 | JAXBContext jc = JAXBContext.newInstance("org.hl7.v3");
|
---|
| 275 | Marshaller marshaller = jc.createMarshaller();
|
---|
| 276 | ByteArrayOutputStream baOutStrm = new ByteArrayOutputStream();
|
---|
| 277 | baOutStrm.reset();
|
---|
| 278 | marshaller.marshal(message.getMessage().getPRPAIN201303UV(), baOutStrm);
|
---|
| 279 |
|
---|
| 280 | participantObject.setParticipantObjectQuery(baOutStrm.toByteArray());
|
---|
| 281 | } catch (Exception e) {
|
---|
| 282 | e.printStackTrace();
|
---|
| 283 | throw new RuntimeException();
|
---|
| 284 | }
|
---|
| 285 | auditMsg.getParticipantObjectIdentification().add(participantObject);
|
---|
| 286 |
|
---|
| 287 | log.info("******************************************************************");
|
---|
| 288 | log.info("Exiting transformPRPA2013032AuditMsg() method.");
|
---|
| 289 | log.info("******************************************************************");
|
---|
| 290 |
|
---|
| 291 | response.setAuditMessage(auditMsg);
|
---|
| 292 | return response;
|
---|
| 293 | }
|
---|
| 294 |
|
---|
| 295 | public static LogEventRequestType transformAck2AuditMsg(LogNhinSubjectDiscoveryAckRequestType message) {
|
---|
| 296 |
|
---|
| 297 | log.info("******************************************************************");
|
---|
| 298 | log.info("Entering transformAck2AuditMsg() method.");
|
---|
| 299 | log.info("******************************************************************");
|
---|
| 300 |
|
---|
| 301 | AuditMessageType auditMsg = new AuditMessageType();
|
---|
| 302 | LogEventRequestType response = new LogEventRequestType();
|
---|
| 303 | response.setDirection(message.getDirection());
|
---|
| 304 | response.setInterface(message.getInterface());
|
---|
| 305 |
|
---|
| 306 | // Extract UserInfo from Message.Assertion
|
---|
| 307 | UserType userInfo = new UserType();
|
---|
| 308 | if (message != null &&
|
---|
| 309 | message.getMessage() != null &&
|
---|
| 310 | message.getMessage().getPIXConsumerMCCIIN000002UV01Request().getAssertion() != null &&
|
---|
| 311 | message.getMessage().getPIXConsumerMCCIIN000002UV01Request().getAssertion().getUserInfo() != null) {
|
---|
| 312 | userInfo = message.getMessage().getPIXConsumerMCCIIN000002UV01Request().getAssertion().getUserInfo();
|
---|
| 313 | }
|
---|
| 314 |
|
---|
| 315 | // Create EventIdentification
|
---|
| 316 | CodedValueType eventID = new CodedValueType();
|
---|
| 317 | eventID = AuditDataTransformHelper.createEventId(AuditDataTransformConstants.EVENT_ID_CODE_SYS_NAME_ACK, AuditDataTransformConstants.EVENT_ID_DISPLAY_NAME_ACK, AuditDataTransformConstants.EVENT_ID_CODE_SYS_NAME_ACK, AuditDataTransformConstants.EVENT_ID_DISPLAY_NAME_ACK);
|
---|
| 318 | auditMsg.setEventIdentification(AuditDataTransformHelper.createEventIdentification(AuditDataTransformConstants.EVENT_ACTION_CODE_EXECUTE, AuditDataTransformConstants.EVENT_OUTCOME_INDICATOR_SUCCESS, eventID));
|
---|
| 319 |
|
---|
| 320 | // Create Active Participant Section
|
---|
| 321 | if (userInfo != null) {
|
---|
| 322 | AuditMessageType.ActiveParticipant participant = AuditDataTransformHelper.createActiveParticipantFromUser(userInfo, true);
|
---|
| 323 | auditMsg.getActiveParticipant().add(participant);
|
---|
| 324 | }
|
---|
| 325 |
|
---|
| 326 | // AuditSourceIdentification
|
---|
| 327 | String enterpriseID = "";
|
---|
| 328 | String sourceID = "";
|
---|
| 329 |
|
---|
| 330 | if (message != null &&
|
---|
| 331 | message.getMessage().getPIXConsumerMCCIIN000002UV01Request().getMCCIIN000002UV01().getReceiver() != null &&
|
---|
| 332 | message.getMessage().getPIXConsumerMCCIIN000002UV01Request().getMCCIIN000002UV01().getReceiver().size() > 0) {
|
---|
| 333 | if (message.getMessage().getPIXConsumerMCCIIN000002UV01Request().getMCCIIN000002UV01().getReceiver().get(0).getDevice() != null &&
|
---|
| 334 | message.getMessage().getPIXConsumerMCCIIN000002UV01Request().getMCCIIN000002UV01().getReceiver().get(0).getDevice().getId() != null) {
|
---|
| 335 | sourceID = message.getMessage().getPIXConsumerMCCIIN000002UV01Request().getMCCIIN000002UV01().getReceiver().get(0).getDevice().getId().get(0).getRoot();
|
---|
| 336 | enterpriseID = message.getMessage().getPIXConsumerMCCIIN000002UV01Request().getMCCIIN000002UV01().getReceiver().get(0).getDevice().getId().get(0).getExtension();
|
---|
| 337 | log.info("Setting ACK enterpriseID : " + enterpriseID + " sourceID : " + sourceID);
|
---|
| 338 | AuditSourceIdentificationType auditSource = AuditDataTransformHelper.createAuditSourceIdentification(sourceID, enterpriseID);
|
---|
| 339 | auditMsg.getAuditSourceIdentification().add(auditSource);
|
---|
| 340 | }
|
---|
| 341 | }
|
---|
| 342 | // ParticipationObjectIdentification
|
---|
| 343 | String objectID = null;
|
---|
| 344 | if (message != null &&
|
---|
| 345 | message.getMessage() != null &&
|
---|
| 346 | message.getMessage().getPIXConsumerMCCIIN000002UV01Request() != null &&
|
---|
| 347 | message.getMessage().getPIXConsumerMCCIIN000002UV01Request().getAssertion() != null) {
|
---|
| 348 | AssertionType assertion = message.getMessage().getPIXConsumerMCCIIN000002UV01Request().getAssertion();
|
---|
| 349 | if (assertion.getUniquePatientId() != null &&
|
---|
| 350 | assertion.getUniquePatientId().size() > 0)
|
---|
| 351 | objectID = assertion.getUniquePatientId().get(0);
|
---|
| 352 | log.debug("setting objectID for ACK " + objectID);
|
---|
| 353 | }
|
---|
| 354 |
|
---|
| 355 | objectID = AuditDataTransformHelper.createCompositePatientId(sourceID, objectID);
|
---|
| 356 | ParticipantObjectIdentificationType participantObject = AuditDataTransformHelper.createParticipantObjectIdentification(objectID);
|
---|
| 357 | log.info("Setting ACK participantObject id : " + participantObject.getParticipantObjectID());
|
---|
| 358 |
|
---|
| 359 | // Put the contents of the actual message into the Audit Log Message
|
---|
| 360 | try {
|
---|
| 361 | JAXBContext jc = JAXBContext.newInstance("org.hl7.v3");
|
---|
| 362 | Marshaller marshaller = jc.createMarshaller();
|
---|
| 363 | ByteArrayOutputStream baOutStrm = new ByteArrayOutputStream();
|
---|
| 364 | baOutStrm.reset();
|
---|
| 365 | marshaller.marshal(message.getMessage().getPIXConsumerMCCIIN000002UV01Request().getMCCIIN000002UV01(), baOutStrm);
|
---|
| 366 |
|
---|
| 367 | participantObject.setParticipantObjectQuery(baOutStrm.toByteArray());
|
---|
| 368 | } catch (Exception e) {
|
---|
| 369 | e.printStackTrace();
|
---|
| 370 | throw new RuntimeException();
|
---|
| 371 | }
|
---|
| 372 | auditMsg.getParticipantObjectIdentification().add(participantObject);
|
---|
| 373 |
|
---|
| 374 |
|
---|
| 375 | log.info("******************************************************************");
|
---|
| 376 | log.info("Exiting transformAck2AuditMsg() method.");
|
---|
| 377 | log.info("******************************************************************");
|
---|
| 378 |
|
---|
| 379 | response.setAuditMessage(auditMsg);
|
---|
| 380 | return response;
|
---|
| 381 | }
|
---|
| 382 |
|
---|
| 383 | public static LogEventRequestType transformPRPA2013092AuditMsg(LogSubjectReidentificationRequestType message) {
|
---|
| 384 | AuditMessageType auditMsg = new AuditMessageType();
|
---|
| 385 | LogEventRequestType response = new LogEventRequestType();
|
---|
| 386 | response.setDirection(message.getDirection());
|
---|
| 387 | response.setInterface(message.getInterface());
|
---|
| 388 |
|
---|
| 389 | log.info("******************************************************************");
|
---|
| 390 | log.info("Entering transformPRPA2013092AuditMsg() method.");
|
---|
| 391 | log.info("******************************************************************");
|
---|
| 392 |
|
---|
| 393 | // Extract UserInfo from Message.Assertion
|
---|
| 394 | UserType userInfo = new UserType();
|
---|
| 395 | if (message != null &&
|
---|
| 396 | message.getMessage() != null &&
|
---|
| 397 | message.getMessage().getAssertion() != null &&
|
---|
| 398 | message.getMessage().getAssertion().getUserInfo() != null) {
|
---|
| 399 | userInfo = message.getMessage().getAssertion().getUserInfo();
|
---|
| 400 | }
|
---|
| 401 |
|
---|
| 402 | // Create EventIdentification
|
---|
| 403 | CodedValueType eventID = new CodedValueType();
|
---|
| 404 | eventID = AuditDataTransformHelper.createEventId(AuditDataTransformConstants.EVENT_ID_CODE_SYS_NAME_SRI, AuditDataTransformConstants.EVENT_ID_DISPLAY_NAME_SDRID, AuditDataTransformConstants.EVENT_ID_CODE_SYS_NAME_SRI, AuditDataTransformConstants.EVENT_ID_DISPLAY_NAME_SDRID);
|
---|
| 405 | auditMsg.setEventIdentification(AuditDataTransformHelper.createEventIdentification(AuditDataTransformConstants.EVENT_ACTION_CODE_EXECUTE, AuditDataTransformConstants.EVENT_OUTCOME_INDICATOR_SUCCESS, eventID));
|
---|
| 406 |
|
---|
| 407 | // Create Active Participant Section
|
---|
| 408 | if (userInfo != null) {
|
---|
| 409 | AuditMessageType.ActiveParticipant participant = AuditDataTransformHelper.createActiveParticipantFromUser(userInfo, true);
|
---|
| 410 | auditMsg.getActiveParticipant().add(participant);
|
---|
| 411 | }
|
---|
| 412 |
|
---|
| 413 | /* Assign AuditSourceIdentification */
|
---|
| 414 | String communityId = "";
|
---|
| 415 | String communityName = "";
|
---|
| 416 | String patientId = "";
|
---|
| 417 |
|
---|
| 418 | if (message != null &&
|
---|
| 419 | message.getMessage() != null &&
|
---|
| 420 | message.getMessage().getPRPAIN201309UV() != null) {
|
---|
| 421 | log.debug("201309 is not null");
|
---|
| 422 | if (message.getMessage().getPRPAIN201309UV().getControlActProcess() != null &&
|
---|
| 423 | message.getMessage().getPRPAIN201309UV().getControlActProcess().getQueryByParameter() != null) {
|
---|
| 424 | log.debug("querybyparameter is not null");
|
---|
| 425 | PRPAMT201307UVQueryByParameter parameter = message.getMessage().getPRPAIN201309UV().getControlActProcess().getQueryByParameter().getValue();
|
---|
| 426 | if (parameter.getParameterList() != null &&
|
---|
| 427 | parameter.getParameterList().getPatientIdentifier() != null &&
|
---|
| 428 | parameter.getParameterList().getPatientIdentifier().size() > 0) {
|
---|
| 429 | log.debug("parameterList has " + parameter.getParameterList().getPatientIdentifier().size() + " element(s)");
|
---|
| 430 | org.hl7.v3.PRPAMT201307UVPatientIdentifier patient = parameter.getParameterList().getPatientIdentifier().get(0);
|
---|
| 431 | if (patient.getValue() != null &&
|
---|
| 432 | patient.getValue().size() > 0) {
|
---|
| 433 | communityId = patient.getValue().get(0).getRoot();
|
---|
| 434 | patientId = patient.getValue().get(0).getExtension();
|
---|
| 435 | }
|
---|
| 436 | }
|
---|
| 437 | }
|
---|
| 438 | patientId = AuditDataTransformHelper.createCompositePatientId(communityId, patientId);
|
---|
| 439 |
|
---|
| 440 | }
|
---|
| 441 |
|
---|
| 442 | if (userInfo != null &&
|
---|
| 443 | userInfo.getOrg() != null) {
|
---|
| 444 | if (userInfo.getOrg().getHomeCommunityId() != null) {
|
---|
| 445 | communityId = userInfo.getOrg().getHomeCommunityId();
|
---|
| 446 | }
|
---|
| 447 | if (userInfo.getOrg().getName() != null) {
|
---|
| 448 | communityName = userInfo.getOrg().getName();
|
---|
| 449 | }
|
---|
| 450 | }
|
---|
| 451 |
|
---|
| 452 | AuditSourceIdentificationType auditSource = AuditDataTransformHelper.createAuditSourceIdentification(communityId, communityName);
|
---|
| 453 | auditMsg.getAuditSourceIdentification().add(auditSource);
|
---|
| 454 |
|
---|
| 455 | /* Assign ParticipationObjectIdentification */
|
---|
| 456 | ParticipantObjectIdentificationType participantObject = AuditDataTransformHelper.createParticipantObjectIdentification(patientId);
|
---|
| 457 |
|
---|
| 458 | // Fill in the message field with the contents of the event message
|
---|
| 459 | try {
|
---|
| 460 | JAXBContext jc = JAXBContext.newInstance("org.hl7.v3");
|
---|
| 461 | Marshaller marshaller = jc.createMarshaller();
|
---|
| 462 | ByteArrayOutputStream baOutStrm = new ByteArrayOutputStream();
|
---|
| 463 | baOutStrm.reset();
|
---|
| 464 | marshaller.marshal(message.getMessage().getPRPAIN201309UV(), baOutStrm);
|
---|
| 465 |
|
---|
| 466 | participantObject.setParticipantObjectQuery(baOutStrm.toByteArray());
|
---|
| 467 | } catch (Exception e) {
|
---|
| 468 | e.printStackTrace();
|
---|
| 469 | log.error("EXCEPTION when marshalling 201309 : " + e);
|
---|
| 470 | throw new RuntimeException();
|
---|
| 471 | }
|
---|
| 472 | auditMsg.getParticipantObjectIdentification().add(participantObject);
|
---|
| 473 |
|
---|
| 474 | log.info("******************************************************************");
|
---|
| 475 | log.info("Exiting transformPRPA2013092AuditMsg() method.");
|
---|
| 476 | log.info("******************************************************************");
|
---|
| 477 |
|
---|
| 478 | response.setAuditMessage(auditMsg);
|
---|
| 479 | return response;
|
---|
| 480 | }
|
---|
| 481 |
|
---|
| 482 | public static LogEventRequestType transformPRPA2013102AuditMsg(LogSubjectReidentificationResponseType message) {
|
---|
| 483 | AuditMessageType auditMsg = new AuditMessageType();
|
---|
| 484 | LogEventRequestType response = new LogEventRequestType();
|
---|
| 485 | response.setDirection(message.getDirection());
|
---|
| 486 | response.setInterface(message.getInterface());
|
---|
| 487 |
|
---|
| 488 | log.info("******************************************************************");
|
---|
| 489 | log.info("Entering transformPRPA2013102AuditMsg() method.");
|
---|
| 490 | log.info("******************************************************************");
|
---|
| 491 |
|
---|
| 492 | // Extract UserInfo from Message.Assertion
|
---|
| 493 | UserType userInfo = new UserType();
|
---|
| 494 | if (message != null &&
|
---|
| 495 | message.getMessage() != null &&
|
---|
| 496 | message.getAssertion() != null &&
|
---|
| 497 | message.getAssertion().getUserInfo() != null) {
|
---|
| 498 | userInfo = message.getAssertion().getUserInfo();
|
---|
| 499 | }
|
---|
| 500 |
|
---|
| 501 | // Create EventIdentification
|
---|
| 502 | CodedValueType eventID = new CodedValueType();
|
---|
| 503 | eventID = AuditDataTransformHelper.createEventId(AuditDataTransformConstants.EVENT_ID_CODE_SYS_NAME_SRI, AuditDataTransformConstants.EVENT_ID_DISPLAY_NAME_SDRID, AuditDataTransformConstants.EVENT_ID_CODE_SYS_NAME_SRI, AuditDataTransformConstants.EVENT_ID_DISPLAY_NAME_SDRID);
|
---|
| 504 | auditMsg.setEventIdentification(AuditDataTransformHelper.createEventIdentification(AuditDataTransformConstants.EVENT_ACTION_CODE_EXECUTE, AuditDataTransformConstants.EVENT_OUTCOME_INDICATOR_SUCCESS, eventID));
|
---|
| 505 |
|
---|
| 506 | // Create Active Participant Section
|
---|
| 507 | if (userInfo != null) {
|
---|
| 508 | AuditMessageType.ActiveParticipant participant = AuditDataTransformHelper.createActiveParticipantFromUser(userInfo, true);
|
---|
| 509 | auditMsg.getActiveParticipant().add(participant);
|
---|
| 510 | }
|
---|
| 511 |
|
---|
| 512 | /* Assign AuditSourceIdentification */
|
---|
| 513 | String communityId = "";
|
---|
| 514 | String communityName = "";
|
---|
| 515 | String patientId = "";
|
---|
| 516 |
|
---|
| 517 | if (message != null &&
|
---|
| 518 | message.getMessage() != null &&
|
---|
| 519 | message.getMessage().getPRPAIN201310UV() != null) {
|
---|
| 520 | PRPAMT201304UVPatient patient = HL7Extractors.ExtractHL7PatientFromMessage(message.getMessage().getPRPAIN201310UV());
|
---|
| 521 | communityId = patient.getId().get(0).getRoot();
|
---|
| 522 | patientId = patient.getId().get(0).getExtension();
|
---|
| 523 | patientId = AuditDataTransformHelper.createCompositePatientId(communityId, patientId);
|
---|
| 524 |
|
---|
| 525 | }
|
---|
| 526 |
|
---|
| 527 | if (userInfo != null &&
|
---|
| 528 | userInfo.getOrg() != null) {
|
---|
| 529 | if (userInfo.getOrg().getHomeCommunityId() != null) {
|
---|
| 530 | communityId = userInfo.getOrg().getHomeCommunityId();
|
---|
| 531 | }
|
---|
| 532 | if (userInfo.getOrg().getName() != null) {
|
---|
| 533 | communityName = userInfo.getOrg().getName();
|
---|
| 534 | }
|
---|
| 535 | }
|
---|
| 536 |
|
---|
| 537 | AuditSourceIdentificationType auditSource = AuditDataTransformHelper.createAuditSourceIdentification(communityId, communityName);
|
---|
| 538 | auditMsg.getAuditSourceIdentification().add(auditSource);
|
---|
| 539 |
|
---|
| 540 | /* Assign ParticipationObjectIdentification */
|
---|
| 541 | ParticipantObjectIdentificationType participantObject = AuditDataTransformHelper.createParticipantObjectIdentification(patientId);
|
---|
| 542 |
|
---|
| 543 | // Fill in the message field with the contents of the event message
|
---|
| 544 | try {
|
---|
| 545 | JAXBContext jc = JAXBContext.newInstance("org.hl7.v3");
|
---|
| 546 | Marshaller marshaller = jc.createMarshaller();
|
---|
| 547 | ByteArrayOutputStream baOutStrm = new ByteArrayOutputStream();
|
---|
| 548 | baOutStrm.reset();
|
---|
| 549 | marshaller.marshal(message.getMessage().getPRPAIN201310UV(), baOutStrm);
|
---|
| 550 |
|
---|
| 551 | participantObject.setParticipantObjectQuery(baOutStrm.toByteArray());
|
---|
| 552 | } catch (Exception e) {
|
---|
| 553 | e.printStackTrace();
|
---|
| 554 | log.error("EXCEPTION when marshalling 201309 : " + e);
|
---|
| 555 | throw new RuntimeException();
|
---|
| 556 | }
|
---|
| 557 | auditMsg.getParticipantObjectIdentification().add(participantObject);
|
---|
| 558 |
|
---|
| 559 | log.info("******************************************************************");
|
---|
| 560 | log.info("Exiting transformPRPA2013102AuditMsg() method.");
|
---|
| 561 | log.info("******************************************************************");
|
---|
| 562 |
|
---|
| 563 | response.setAuditMessage(auditMsg);
|
---|
| 564 | return response;
|
---|
| 565 | }
|
---|
| 566 |
|
---|
| 567 | }
|
---|