public virtual async Task NotifyGateway(string cmSuffix, DataNotificationRequest dataNotificationRequest) { var notificationRequest = new GatewayDataNotificationRequest(Guid.NewGuid(), DateTime.Now.ToUniversalTime(), new DataFlowNotificationRequest( dataNotificationRequest.TransactionId, dataNotificationRequest.ConsentId, dataNotificationRequest.DoneAt, dataNotificationRequest.Notifier, dataNotificationRequest.StatusNotification)); await gatewayClient.SendDataToGateway(PATH_HEALTH_INFORMATION_NOTIFY_GATEWAY, notificationRequest, cmSuffix); }
private async Task PostTo(string consentId, string dataPushUrl, IEnumerable <GrantedContext> careContexts, DataResponse dataResponse, string cmSuffix, string correlationId) { var grantedContexts = careContexts as GrantedContext[] ?? careContexts.ToArray(); var hiStatus = HiStatus.DELIVERED; var sessionStatus = SessionStatus.TRANSFERRED; var message = "Successfully delivered health information"; try { // TODO: Need to handle non 2xx response also await httpClient.SendAsync(CreateHttpRequest(dataPushUrl, dataResponse, correlationId)).ConfigureAwait(false); } catch (Exception exception) { hiStatus = HiStatus.ERRORED; sessionStatus = SessionStatus.FAILED; message = "Failed to deliver health information"; Log.Error(exception, exception.StackTrace); } try { var statusResponses = grantedContexts .Select(grantedContext => new StatusResponse(grantedContext.CareContextReference, hiStatus, message)) .ToList(); var dataNotificationRequest = new DataNotificationRequest(dataResponse.TransactionId, DateTime.Now.ToUniversalTime(), new Notifier(Type.HIP, gatewayConfiguration.ClientId), new StatusNotification(sessionStatus, gatewayConfiguration.ClientId, statusResponses), consentId, Guid.NewGuid()); await GetDataNotificationRequest(dataNotificationRequest, cmSuffix, correlationId).ConfigureAwait(false); } catch (Exception ex) { Log.Error(ex, ex.Message); } }
private async Task GetDataNotificationRequest(DataNotificationRequest dataNotificationRequest, string cmSuffix, string correlationId) { await dataFlowNotificationClient.NotifyGateway(cmSuffix, dataNotificationRequest, correlationId); }