Esempio n. 1
0
        public static async Task <IActionResult> MeasurementCollectionToFhir(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req,
            [Blob("template/%Template:FhirMapping%", FileAccess.Read)] string templateDefinition,
            [MeasurementFhirImport] MeasurementFhirImportService measurementImportService,
            ILogger log)
        {
            try
            {
                await measurementImportService.ProcessStreamAsync(req.Body, templateDefinition, log).ConfigureAwait(false);

                return(new AcceptedResult());
            }
            catch (Exception ex)
            {
                log.RecordUnhandledExceptionMetrics(ex, nameof(MeasurementCollectionToFhir));
                throw;
            }
        }
Esempio n. 2
0
        public async void GivenEmptyStream_WhenParseStreamAsync_ThenCompleteSuccessfully_Test()
        {
            var log         = Substitute.For <ITelemetryLogger>();
            var options     = BuildMockOptions();
            var fhirService = Substitute.For <FhirImportService>();

            var fhirImport = new MeasurementFhirImportService(fhirService, options);

            var stream = Substitute.For <Stream>();

            stream.CanRead.Returns(true);

            using (stream)
            {
                await fhirImport.ProcessStreamAsync(stream, string.Empty, log);
            }

            options.TemplateFactory.Received(1).Create(string.Empty);
            await fhirService.DidNotReceiveWithAnyArgs().ProcessAsync(default, default);
        public async Task <IActionResult> MeasurementCollectionToFhir(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req,
            [Blob("template/%Template:FhirMapping%", FileAccess.Read)] string templateDefinition,
            [MeasurementFhirImport] MeasurementFhirImportService measurementImportService)
        {
            EnsureArg.IsNotNull(measurementImportService, nameof(measurementImportService));
            EnsureArg.IsNotNull(req, nameof(req));

            try
            {
                await measurementImportService.ProcessStreamAsync(req.Body, templateDefinition, _logger).ConfigureAwait(false);

                return(new AcceptedResult());
            }
            catch (Exception ex)
            {
                _logger.LogMetric(
                    IomtMetrics.UnhandledException(ex.GetType().Name, ConnectorOperation.FHIRConversion),
                    1);
                throw;
            }
        }