Esempio n. 1
0
        public async Task GivenAValidConfigurationWithETag_WhenExportingAnonymizedData_ResourceShouldBeAnonymized()
        {
            if (!_isUsingInProcTestServer)
            {
                return;
            }

            _metricHandler.ResetCount();

            (string fileName, string etag) = await UploadConfigurationAsync(RedactResourceIdAnonymizationConfiguration);

            string containerName   = Guid.NewGuid().ToString("N");
            Uri    contentLocation = await _testFhirClient.AnonymizedExportAsync(fileName, containerName, etag);

            HttpResponseMessage response = await WaitForCompleteAsync(contentLocation);

            IList <Uri> blobUris = await CheckExportStatus(response);

            IEnumerable <string> dataFromExport = await DownloadBlobAndParse(blobUris);

            FhirJsonParser parser = new FhirJsonParser();

            foreach (string content in dataFromExport)
            {
                Resource result = parser.Parse <Resource>(content);

                Assert.Contains(result.Meta.Security, c => "REDACTED".Equals(c.Code));
            }

            Assert.Single(_metricHandler.NotificationMapping[typeof(ExportTaskMetricsNotification)]);
        }
        public async Task GivenAValidConfigurationWithETag_WhenExportingAnonymizedData_ResourceShouldBeAnonymized()
        {
            (string fileName, string etag) = await UploadConfigurationAsync(RedactResourceIdAnonymizationConfiguration);

            Uri contentLocation = await _testFhirClient.AnonymizedExportAsync(fileName, etag);

            HttpResponseMessage response = await WaitForCompleteAsync(contentLocation);

            IList <Uri> blobUris = await CheckExportStatus(response);

            IEnumerable <string> dataFromExport = await DownloadBlobAndParse(blobUris);

            FhirJsonParser parser = new FhirJsonParser();

            foreach (string content in dataFromExport)
            {
                Resource result = parser.Parse <Resource>(content);

                Assert.Contains(result.Meta.Security, c => "REDACTED".Equals(c.Code));
            }
        }
        public async Task GivenAValidConfigurationWithETag_WhenExportingAnonymizedData_ResourceShouldBeAnonymized(string path)
        {
            _metricHandler?.ResetCount();
            var dateTime         = DateTimeOffset.UtcNow;
            var resourceToCreate = Samples.GetDefaultPatient().ToPoco <Patient>();

            resourceToCreate.Id = Guid.NewGuid().ToString();
            await _testFhirClient.UpdateAsync(resourceToCreate);

            (string fileName, string etag) = await UploadConfigurationAsync(RedactResourceIdAnonymizationConfiguration);

            string containerName   = Guid.NewGuid().ToString("N");
            Uri    contentLocation = await _testFhirClient.AnonymizedExportAsync(fileName, dateTime, containerName, etag, path);

            HttpResponseMessage response = await WaitForCompleteAsync(contentLocation);

            IList <Uri> blobUris = await CheckExportStatus(response);

            IEnumerable <string> dataFromExport = await DownloadBlobAndParse(blobUris);

            FhirJsonParser parser = new FhirJsonParser();

            foreach (string content in dataFromExport)
            {
                Resource result = parser.Parse <Resource>(content);

                Assert.Contains(result.Meta.Security, c => "REDACTED".Equals(c.Code));
            }

            // Only check metric for local tests
            if (_isUsingInProcTestServer)
            {
                Assert.Single(_metricHandler.NotificationMapping[typeof(ExportTaskMetricsNotification)]);
            }
        }