use of org.hl7.fhir.r4.model.AuditEvent in project summary-care-record-api by NHSDigital.
the class AlertRequestValidator method isValid.
@Override
public boolean isValid(String alert, ConstraintValidatorContext context) {
try {
AuditEvent auditEvent = fhirParser.parseResource(alert, AuditEvent.class);
checkId(auditEvent);
checkExtension(auditEvent);
checkType(auditEvent.getType());
checkSubtype(auditEvent.getSubtype());
checkRecorded(auditEvent.getRecorded());
checkSource(auditEvent.getSource());
checkEntity(auditEvent.getEntity());
checkPatient(auditEvent.getAgent());
checkOrganization(auditEvent.getAgent());
checkPerson(auditEvent.getAgent());
} catch (FhirValidationException exc) {
setErrorMessage(context, exc.getMessage());
return false;
}
return true;
}
use of org.hl7.fhir.r4.model.AuditEvent in project fhir-bridge by ehrbase.
the class ProvideResourceAuditHandler method process.
@Override
public void process(Exchange exchange) throws Exception {
RequestDetails requestDetails = getRequestDetails(exchange);
AuditEvent auditEvent = new AuditEvent(new Coding("http://terminology.hl7.org/CodeSystem/audit-event-type", "rest", "RESTful Operation"), new InstantType(new Date()), getSource());
getSubtype(requestDetails).ifPresent(auditEvent::addSubtype);
getAction(requestDetails).ifPresent(auditEvent::setAction);
Throwable ex = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Throwable.class);
if (ex == null) {
auditEvent.setOutcome(AuditEvent.AuditEventOutcome._0);
auditEvent.setOutcomeDesc("Operation completed successfully");
} else {
auditEvent.setOutcome(AuditEvent.AuditEventOutcome._8);
auditEvent.setOutcomeDesc("Operation failed: " + ex.getMessage());
}
auditEvent.addAgent(getAgent(exchange));
getEntity(exchange, requestDetails).ifPresent(auditEvent::addEntity);
MethodOutcome outcome = auditEventDao.create(auditEvent, requestDetails);
LOG.debug("Created AuditEvent: id={}", outcome.getId());
}
use of org.hl7.fhir.r4.model.AuditEvent in project fhir-bridge by ehrbase.
the class AuditEventReportIT method createResourceAndSearchAuditEvent.
@Test
void createResourceAndSearchAuditEvent() throws IOException {
Date now = new Date();
String resource = IOUtils.toString(new ClassPathResource("DiagnosticReport/create-diagnosticReport.json").getInputStream(), StandardCharsets.UTF_8);
MethodOutcome outcome = client.create().resource(resource.replaceAll(PATIENT_ID_TOKEN, PATIENT_ID)).execute();
assertNotNull(outcome.getId());
assertEquals(true, outcome.getCreated());
Bundle bundle = client.search().forResource(AuditEvent.class).where(AuditEvent.DATE.afterOrEquals().day(now)).and(AuditEvent.ENTITY.hasId(outcome.getResource().getIdElement())).returnBundle(Bundle.class).execute();
assertNotNull(bundle);
assertEquals(1, bundle.getTotal());
AuditEvent auditEvent = (AuditEvent) bundle.getEntryFirstRep().getResource();
assertEquals(AuditEvent.AuditEventOutcome._0, auditEvent.getOutcome());
assertEquals(outcome.getResource().getIdElement(), auditEvent.getEntity().get(0).getWhat().getReferenceElement());
}
use of org.hl7.fhir.r4.model.AuditEvent in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeAuditEventAuditEventAgentComponent.
protected void composeAuditEventAuditEventAgentComponent(Complex parent, String parentType, String name, AuditEvent.AuditEventAgentComponent element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeBackboneElement(t, "agent", name, element, index);
for (int i = 0; i < element.getRole().size(); i++) composeCodeableConcept(t, "AuditEvent", "role", element.getRole().get(i), i);
if (element.hasReference())
composeReference(t, "AuditEvent", "reference", element.getReference(), -1);
if (element.hasUserId())
composeIdentifier(t, "AuditEvent", "userId", element.getUserId(), -1);
if (element.hasAltIdElement())
composeString(t, "AuditEvent", "altId", element.getAltIdElement(), -1);
if (element.hasNameElement())
composeString(t, "AuditEvent", "name", element.getNameElement(), -1);
if (element.hasRequestorElement())
composeBoolean(t, "AuditEvent", "requestor", element.getRequestorElement(), -1);
if (element.hasLocation())
composeReference(t, "AuditEvent", "location", element.getLocation(), -1);
for (int i = 0; i < element.getPolicy().size(); i++) composeUri(t, "AuditEvent", "policy", element.getPolicy().get(i), i);
if (element.hasMedia())
composeCoding(t, "AuditEvent", "media", element.getMedia(), -1);
if (element.hasNetwork())
composeAuditEventAuditEventAgentNetworkComponent(t, "AuditEvent", "network", element.getNetwork(), -1);
for (int i = 0; i < element.getPurposeOfUse().size(); i++) composeCodeableConcept(t, "AuditEvent", "purposeOfUse", element.getPurposeOfUse().get(i), i);
}
use of org.hl7.fhir.r4.model.AuditEvent in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeAuditEvent.
protected void composeAuditEvent(Complex parent, String parentType, String name, AuditEvent element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeDomainResource(t, "AuditEvent", name, element, index);
if (element.hasType())
composeCoding(t, "AuditEvent", "type", element.getType(), -1);
for (int i = 0; i < element.getSubtype().size(); i++) composeCoding(t, "AuditEvent", "subtype", element.getSubtype().get(i), i);
if (element.hasActionElement())
composeEnum(t, "AuditEvent", "action", element.getActionElement(), -1);
if (element.hasPeriod())
composePeriod(t, "AuditEvent", "period", element.getPeriod(), -1);
if (element.hasRecordedElement())
composeInstant(t, "AuditEvent", "recorded", element.getRecordedElement(), -1);
if (element.hasOutcomeElement())
composeEnum(t, "AuditEvent", "outcome", element.getOutcomeElement(), -1);
if (element.hasOutcomeDescElement())
composeString(t, "AuditEvent", "outcomeDesc", element.getOutcomeDescElement(), -1);
for (int i = 0; i < element.getPurposeOfEvent().size(); i++) composeCodeableConcept(t, "AuditEvent", "purposeOfEvent", element.getPurposeOfEvent().get(i), i);
for (int i = 0; i < element.getAgent().size(); i++) composeAuditEventAuditEventAgentComponent(t, "AuditEvent", "agent", element.getAgent().get(i), i);
if (element.hasSource())
composeAuditEventAuditEventSourceComponent(t, "AuditEvent", "source", element.getSource(), -1);
for (int i = 0; i < element.getEntity().size(); i++) composeAuditEventAuditEventEntityComponent(t, "AuditEvent", "entity", element.getEntity().get(i), i);
}
Aggregations