private void serialize(AuditMessage auditMessage, Writer writer, XMLOutputter outputter) throws IOException { Element element = new Element("AuditMessage"); element.addContent(eventIdentification(auditMessage.getEventIdentification())); auditMessage.getActiveParticipants().stream() .map(this::activeParticipant) .forEach(element::addContent); element.addContent(auditSourceIdentification(auditMessage.getAuditSourceIdentification())); auditMessage.getParticipantObjectIdentifications().stream() .map(this::participantObjectIdentification) .forEach(element::addContent); outputter.output(new Document(element), writer); }
@Override public void validate() { super.validate(); if (getMessage().getActiveParticipants().isEmpty() || getMessage().getActiveParticipants().size() > 2) { throw new AuditException("Must have one or two participants that started the Application"); } if (getMessage().findParticipantObjectIdentifications(poi -> ParticipantObjectIdTypeCode.URI.equals(poi.getParticipantObjectTypeCode())).size() != 1) { throw new AuditException("Must have exactly Audit Log Identity Participating Object "); } } }
@Override public void validate() { auditMessage.validate(); }
@Override public void validate() { super.validate(); if (getMessage().findActiveParticipants(ap -> ap.getRoleIDCodes().contains(ActiveParticipantRoleIdCode.Destination)).isEmpty()) { throw new AuditException("Must have one or more ActiveParticipant with RoleIDCode Destination"); } if (getMessage().findActiveParticipants(ap -> ap.getRoleIDCodes().contains(ActiveParticipantRoleIdCode.SourceMedia)).size() != 1) { throw new AuditException("Must have one ActiveParticipant with RoleIDCode SourceMedia"); } if (getMessage().findParticipantObjectIdentifications(poi -> poi.getParticipantObjectIDTypeCode() == ParticipantObjectIdTypeCode.PatientNumber).isEmpty()) { throw new AuditException("Must one or more ParticipantObjectIdentification with ParticipantObjectIDTypeCode PatientNumber"); } } }
boolean serverSide, boolean requiresPatient) { assertEquals(eventOutcomeIndicator, auditMessage.getEventIdentification().getEventOutcomeIndicator()); assertEquals(eventActionCode, auditMessage.getEventIdentification().getEventActionCode()); assertEquals(eventId, auditMessage.getEventIdentification().getEventID()); ActiveParticipantType human = auditMessage.getActiveParticipants().stream() .filter(apt -> apt.getUserName() != null) .findFirst().orElse(null); ActiveParticipantType source = auditMessage.getActiveParticipants().stream() .filter(apt -> ActiveParticipantRoleIdCode.Source == apt.getRoleIDCodes().get(0)) .findFirst().orElseThrow(() -> new AssertionError("Expected source participant")); ActiveParticipantType destination = auditMessage.getActiveParticipants().stream() .filter(apt -> ActiveParticipantRoleIdCode.Destination == apt.getRoleIDCodes().get(0)) .findFirst().orElseThrow(() -> new AssertionError("Expected destination active participant")); ParticipantObjectIdentificationType patient = auditMessage.getParticipantObjectIdentifications().stream() .filter(poi -> ParticipantObjectIdTypeCode.PatientNumber == poi.getParticipantObjectIDTypeCode()) .findFirst().orElseThrow(() -> new AssertionError("Expected patient participant object"));
event.getEventIdentification().getEventOutcomeIndicator()); assertEquals( EventActionCode.Create, event.getEventIdentification().getEventActionCode()); assertEquals(EventIdCode.Export, event.getEventIdentification().getEventID()); assertEquals(FhirEventTypeCode.MobileDocumentRetrieval, event.getEventIdentification().getEventTypeCode().get(0)); ActiveParticipantType source = event.getActiveParticipants().get(0); assertTrue(source.isUserIsRequestor()); assertEquals("127.0.0.1", source.getNetworkAccessPointID()); ActiveParticipantType destination = event.getActiveParticipants().get(1); assertFalse(destination.isUserIsRequestor()); assertEquals(AuditUtils.getLocalIPAddress(), destination.getNetworkAccessPointID()); AuditSourceIdentificationType sourceIdentificationType = event.getAuditSourceIdentification(); assertEquals("IPF", sourceIdentificationType.getAuditSourceID()); assertEquals("IPF", sourceIdentificationType.getAuditEnterpriseSiteID()); ParticipantObjectIdentificationType poit = event.findParticipantObjectIdentifications(p -> p.getParticipantObjectTypeCode() == ParticipantObjectTypeCode.System).get(0); assertEquals(Iti68TestRouteBuilder.DOCUMENT_UNIQUE_ID, poit.getParticipantObjectID());
public List<ActiveParticipantType> findActiveParticipants(Predicate<ActiveParticipantType> selector) { return getActiveParticipants().stream() .filter(selector) .collect(Collectors.toList()); }
public List<ParticipantObjectIdentificationType> findParticipantObjectIdentifications(Predicate<ParticipantObjectIdentificationType> selector) { return getParticipantObjectIdentifications().stream() .filter(selector) .collect(Collectors.toList()); }
private void testRequest(boolean serverSide, XdsIRetrieveAuditStrategy30 strategy) { XdsNonconstructiveDocumentSetRequestAuditDataset auditDataset = getXdsAuditDataset(strategy); AuditMessage auditMessage = makeAuditMessage(strategy, auditContext, auditDataset); assertNotNull(auditMessage); auditMessage.validate(); // System.out.println(printAuditMessage(auditMessage)); assertCommonXdsAuditAttributes(auditMessage, EventOutcomeIndicator.Success, serverSide ? EventIdCode.Export : EventIdCode.Import, serverSide ? EventActionCode.Read : EventActionCode.Create, serverSide, true); assertEquals(3, auditMessage.findParticipantObjectIdentifications( poit -> poit.getParticipantObjectTypeCodeRole() == ParticipantObjectTypeCodeRole.Report).size()); assertEquals(4, auditMessage.findParticipantObjectIdentifications( poit -> poit.getParticipantObjectTypeCode() == ParticipantObjectTypeCode.System) .get(0) .getParticipantObjectDetails().size()); }
private void testRequest(boolean serverSide, Iti59AuditStrategy strategy) { Iti59AuditDataset auditDataset = getHpdAuditDataset(strategy); AuditMessage[] auditMessages = makeAuditMessages(strategy, auditContext, auditDataset); assertEquals(3, auditMessages.length); for (AuditMessage auditMessage : auditMessages) { auditMessage.validate(); System.out.println(printAuditMessage(auditMessage)); assertEquals(1, auditMessage.getParticipantObjectIdentifications().size()); ParticipantObjectIdentificationType participant = auditMessage.getParticipantObjectIdentifications().get(0); assertEquals(ParticipantObjectTypeCodeRole.Provider, participant.getParticipantObjectTypeCodeRole()); assertEquals(HpdParticipantObjectIdTypeCode.RelativeDistinguishedName, participant.getParticipantObjectIDTypeCode()); } assertCommonHpdAuditAttributes(auditMessages[0], EventOutcomeIndicator.Success, serverSide ? EventIdCode.Import : EventIdCode.Export, EventActionCode.Update, serverSide); ParticipantObjectIdentificationType participant = auditMessages[2].getParticipantObjectIdentifications().get(0); assertEquals(1, participant.getParticipantObjectDetails().size()); assertEquals("old uid", participant.getParticipantObjectDetails().get(0).getType()); assertEquals("1.11.111.1111:klmno", new String(participant.getParticipantObjectDetails().get(0).getValue())); }
@Test public void testRetrieveDocument() { try { getProducerTemplate().requestBody("direct:input", null, byte[].class); fail(); } catch (CamelExecutionException e) { assertTrue(e.getCause() instanceof HttpOperationFailedException); // Check ATNA Audit AbstractMockedAuditMessageQueue sender = getAuditSender(); assertEquals(1, sender.getMessages().size()); AuditMessage event = sender.getMessages().get(0); assertEquals( EventOutcomeIndicator.MajorFailure, event.getEventIdentification().getEventOutcomeIndicator()); } }
@Override public void validate() { super.validate(); ParticipantObjectIdentificationType patient = getMessage().findParticipantObjectIdentifications(poi -> ParticipantObjectIdTypeCode.PatientNumber.equals(poi.getParticipantObjectIDTypeCode())).get(0); if (!PATIENT_ID_PATTERN.matcher(patient.getParticipantObjectID()).matches()) { throw new AuditException("Patient ID should be in CX format " + PATIENT_ID_PATTERN.pattern()); } } }
event.getEventIdentification().getEventOutcomeIndicator()); assertEquals( EventActionCode.Create, event.getEventIdentification().getEventActionCode()); assertEquals(EventIdCode.Import, event.getEventIdentification().getEventID()); assertEquals(FhirEventTypeCode.ProvideDocumentBundle, event.getEventIdentification().getEventTypeCode().get(0)); ActiveParticipantType source = event.getActiveParticipants().get(0); assertTrue(source.isUserIsRequestor()); assertEquals("127.0.0.1", source.getNetworkAccessPointID()); ActiveParticipantType destination = event.getActiveParticipants().get(1); assertFalse(destination.isUserIsRequestor()); assertEquals("http://localhost:" + DEMO_APP_PORT + "/", destination.getUserID()); ParticipantObjectIdentificationType patient = event.getParticipantObjectIdentifications().get(0); assertEquals(ParticipantObjectTypeCode.Person, patient.getParticipantObjectTypeCode()); assertEquals(ParticipantObjectTypeCodeRole.Patient, patient.getParticipantObjectTypeCodeRole()); ParticipantObjectIdentificationType poit = event.getParticipantObjectIdentifications().get(1); assertEquals(ParticipantObjectTypeCode.System, poit.getParticipantObjectTypeCode()); assertEquals(ParticipantObjectTypeCodeRole.Job, poit.getParticipantObjectTypeCodeRole());
public T addActiveParticipant(ActiveParticipantType activeParticipantType) { auditMessage.getActiveParticipants().add(activeParticipantType); return self(); }
public T addParticipantObjectIdentification(ParticipantObjectIdentificationType poit) { auditMessage.getParticipantObjectIdentifications().add(poit); return self(); }
private void testRequest(boolean serverSide, XdsIRetrieveAuditStrategy30 strategy) { XdsNonconstructiveDocumentSetRequestAuditDataset auditDataset = getXdsAuditDataset(strategy); AuditMessage auditMessage = makeAuditMessage(strategy, auditContext, auditDataset); assertNotNull(auditMessage); auditMessage.validate(); // System.out.println(printAuditMessage(auditMessage)); assertCommonXdsAuditAttributes(auditMessage, EventOutcomeIndicator.Success, serverSide ? EventIdCode.Export : EventIdCode.Import, serverSide ? EventActionCode.Read : EventActionCode.Create, serverSide, true); assertEquals(3, auditMessage.findParticipantObjectIdentifications( poit -> poit.getParticipantObjectTypeCodeRole() == ParticipantObjectTypeCodeRole.Report).size()); assertEquals(4, auditMessage.findParticipantObjectIdentifications( poit -> poit.getParticipantObjectTypeCode() == ParticipantObjectTypeCode.System) .get(0) .getParticipantObjectDetails().size()); }
@Override public void validate() { super.validate(); int sources = getMessage().findActiveParticipants(ap -> ap.getRoleIDCodes().contains(ActiveParticipantRoleIdCode.Source)).size(); if (sources < 1 || sources > 2) { throw new AuditException("Must have one or two ActiveParticipant with RoleIDCode Source"); } if (getMessage().findActiveParticipants(ap -> ap.getRoleIDCodes().contains(ActiveParticipantRoleIdCode.DestinationMedia)).size() != 1) { throw new AuditException("Must have one ActiveParticipant with RoleIDCode DestinationMedia"); } if (getMessage().findParticipantObjectIdentifications(poi -> poi.getParticipantObjectIDTypeCode() == ParticipantObjectIdTypeCode.PatientNumber).isEmpty()) { throw new AuditException("Must one or more ParticipantObjectIdentification with ParticipantObjectIDTypeCode PatientNumber"); } } }
protected AuditEvent translate(AuditMessage auditMessage) { EventIdentificationType eit = auditMessage.getEventIdentification(); AuditEvent auditEvent = new AuditEvent() .setType(codedValueTypeToCoding(eit.getEventID())) .setAction(getAuditEventAction(eit.getEventActionCode())) .setRecorded(Date.from(eit.getEventDateTime())) .setOutcome(getAuditEventOutcome(eit.getEventOutcomeIndicator())) .setOutcomeDesc(eit.getEventOutcomeDescription()); eit.getEventTypeCode().forEach(etc -> auditEvent.addSubtype(codedValueTypeToCoding(etc))); eit.getPurposesOfUse().forEach(pou -> auditEvent.addPurposeOfEvent(codedValueTypeToCodeableConcept(pou))); auditMessage.getActiveParticipants().forEach(ap -> auditEvent.addAgent(activeParticipantToAgent(ap))); auditEvent.setSource(auditSourceIdentificationToEventSource(auditMessage.getAuditSourceIdentification())); auditMessage.getParticipantObjectIdentifications().forEach(poit -> auditEvent.addEntity(participantObjectIdentificationToEntity(poit))); return auditEvent; }
event.getEventIdentification().getEventOutcomeIndicator()); assertEquals( EventActionCode.Create, event.getEventIdentification().getEventActionCode()); assertEquals(EventIdCode.Import, event.getEventIdentification().getEventID()); assertEquals(FhirEventTypeCode.ProvideDocumentBundle, event.getEventIdentification().getEventTypeCode().get(0)); ActiveParticipantType source = event.getActiveParticipants().get(0); assertTrue(source.isUserIsRequestor()); assertEquals("127.0.0.1", source.getNetworkAccessPointID()); ActiveParticipantType destination = event.getActiveParticipants().get(1); assertFalse(destination.isUserIsRequestor()); assertEquals("http://localhost:" + DEMO_APP_PORT + "/", destination.getUserID()); ParticipantObjectIdentificationType patient = event.getParticipantObjectIdentifications().get(0); assertEquals(ParticipantObjectTypeCode.Person, patient.getParticipantObjectTypeCode()); assertEquals(ParticipantObjectTypeCodeRole.Patient, patient.getParticipantObjectTypeCodeRole()); ParticipantObjectIdentificationType poit = event.getParticipantObjectIdentifications().get(1); assertEquals(ParticipantObjectTypeCode.System, poit.getParticipantObjectTypeCode()); assertEquals(ParticipantObjectTypeCodeRole.Job, poit.getParticipantObjectTypeCodeRole());
@Override public void validate() { super.validate(); int participants = getMessage().getActiveParticipants().size(); if (participants < 1 || participants > 2) { throw new AuditException("Must have one or two ActiveParticipants"); } if (getMessage().findParticipantObjectIdentifications(poi -> poi.getParticipantObjectIDTypeCode() == ParticipantObjectIdTypeCode.PatientNumber).size() != 1) { throw new AuditException("Must one ParticipantObjectIdentification with ParticipantObjectIDTypeCode PatientNumber"); } } }