use of org.hl7.fhir.r4.model.MessageHeader.ResponseType in project MobileAccessGateway by i4mi.
the class Iti93AuditStrategy method getEventOutcomeCodeFromResource.
/**
* Look at the response codes in the bundle entries and derive the ATNA event outcome
* @param resource FHIR resource
* @return RFC3881EventOutcomeCode
*/
@Override
protected EventOutcomeIndicator getEventOutcomeCodeFromResource(IBaseResource resource) {
if (!(resource instanceof Bundle))
return super.getEventOutcomeCodeFromResource(resource);
var bundle = (Bundle) resource;
var messageHeader = bundle.getEntry().stream().map(Bundle.BundleEntryComponent::getResource).filter(MessageHeader.class::isInstance).map(MessageHeader.class::cast).findFirst().orElseThrow(() -> new RuntimeException("ITI-93 bundle must contain MessageHeader"));
ResponseType result = messageHeader.getResponse().getCode();
if (result == null)
return EventOutcomeIndicator.MajorFailure;
if (result.equals(ResponseType.OK))
return EventOutcomeIndicator.Success;
if (result.equals(ResponseType.TRANSIENTERROR))
return EventOutcomeIndicator.MinorFailure;
return EventOutcomeIndicator.MajorFailure;
}
Aggregations