public void GivenExceptionType_WhenProcessException_ThenExceptionLoggedAndErrorMetricLogged_Test(Exception ex, string expectedErrorMetricName, string expectedErrorSource = null)
        {
            var logger = Substitute.For <ITelemetryLogger>();

            FhirServiceExceptionProcessor.ProcessException(ex, logger);

            logger.ReceivedWithAnyArgs(1).LogError(ex);
            logger.Received(1).LogMetric(
                Arg.Is <Metric>(m => ValidateFhirServiceErrorMetricProperties(m, expectedErrorMetricName, expectedErrorSource)),
                1);
        }
        public static async Task <bool> ValidateFhirClientAsync(
            this IFhirClient client,
            ITelemetryLogger logger)
        {
            EnsureArg.IsNotNull(client, nameof(client));
            EnsureArg.IsNotNull(logger, nameof(logger));

            try
            {
                await client.ReadAsync <Hl7.Fhir.Model.CapabilityStatement>("metadata?_summary=true").ConfigureAwait(false);

                return(true);
            }
            catch (Exception exception)
            {
                FhirServiceExceptionProcessor.ProcessException(exception, logger);
                return(false);
            }
        }
Пример #3
0
        public override async Task ProcessAsync(ILookupTemplate <IFhirTemplate> config, IMeasurementGroup data, Func <Exception, IMeasurementGroup, Task <bool> > errorConsumer = null)
        {
            try
            {
                // Get required ids
                var ids = await ResourceIdentityService.ResolveResourceIdentitiesAsync(data).ConfigureAwait(false);

                var grps = _fhirTemplateProcessor.CreateObservationGroups(config, data);

                foreach (var grp in grps)
                {
                    _ = await SaveObservationAsync(config, grp, ids).ConfigureAwait(false);
                }
            }
            catch (Exception ex)
            {
                FhirServiceExceptionProcessor.ProcessException(ex, _logger);
                throw;
            }
        }
        public void GivenExceptionType_WhenCustomizeException_ThenCustomExceptionTypeReturned_Test(Exception ex, Type customExType)
        {
            var(customEx, errName) = FhirServiceExceptionProcessor.CustomizeException(ex);

            Assert.IsType(customExType, customEx);
        }