public async Task GivenFhirServer_WhenPatientDataIsExported_ThenExportedDataIsSameAsDataInFhirServer() { // NOTE: Azure Storage Emulator is required to run these tests locally. // Trigger export request and check for export status Uri contentLocation = await _testFhirClient.ExportAsync("Patient/"); IList <Uri> blobUris = await ExportTestHelper.CheckExportStatus(_testFhirClient, contentLocation, timeToWaitInMinutes : 15); // Download exported data from storage account Dictionary <(string resourceType, string resourceId), Resource> dataFromExport = await ExportTestHelper.DownloadBlobAndParse(blobUris, _fhirJsonParser, _outputHelper); // Download resources from fhir server Uri address = new Uri(_testFhirClient.HttpClient.BaseAddress, "Patient/"); Dictionary <(string resourceType, string resourceId), Resource> dataFromFhirServer = await ExportTestHelper.GetResourcesFromFhirServer(_testFhirClient, address, _fhirJsonParser, _outputHelper); Dictionary <(string resourceType, string resourceId), Resource> compartmentData = new Dictionary <(string resourceType, string resourceId), Resource>(); foreach ((string resourceType, string resourceId)key in dataFromFhirServer.Keys) { address = new Uri(_testFhirClient.HttpClient.BaseAddress, "Patient/" + key.resourceId + "/*"); // copies all the new values into the compartment data dictionary (await ExportTestHelper.GetResourcesFromFhirServer(_testFhirClient, address, _fhirJsonParser, _outputHelper)) .ToList() .ForEach(x => compartmentData.TryAdd(x.Key, x.Value)); } compartmentData.ToList().ForEach(x => dataFromFhirServer.TryAdd(x.Key, x.Value)); dataFromFhirServer.Union(compartmentData); // Assert both data are equal Assert.True(ExportTestHelper.ValidateDataFromBothSources(dataFromFhirServer, dataFromExport, _outputHelper)); }
public async Task GivenFhirServer_WhenGroupDataIsExportedWithTypeParameter_ThenExportedDataIsSameAsDataInFhirServer() { // NOTE: Azure Storage Emulator is required to run these tests locally. // Add data for test var(dataInFhirServer, groupId) = await CreateGroupWithPatient(false); // Trigger export request and check for export status Uri contentLocation = await _testFhirClient.ExportAsync($"Group/{groupId}/", "_type=RelatedPerson,Encounter"); IList <Uri> blobUris = await ExportTestHelper.CheckExportStatus(_testFhirClient, contentLocation); // Download exported data from storage account Dictionary <(string resourceType, string resourceId), Resource> dataFromExport = await ExportTestHelper.DownloadBlobAndParse(blobUris, _fhirJsonParser, _outputHelper); // Assert both sets of data are equal Assert.True(ExportTestHelper.ValidateDataFromBothSources(dataInFhirServer, dataFromExport, _outputHelper)); }
public async Task GivenFhirServer_WhenAllDataIsExported_ThenExportedDataIsSameAsDataInFhirServer() { // NOTE: Azure Storage Emulator is required to run these tests locally. // Trigger export request and check for export status Uri contentLocation = await _testFhirClient.ExportAsync(); IList <Uri> blobUris = await ExportTestHelper.CheckExportStatus(_testFhirClient, contentLocation, timeToWaitInMinutes : 15); // Download exported data from storage account Dictionary <(string resourceType, string resourceId), Resource> dataFromExport = await ExportTestHelper.DownloadBlobAndParse(blobUris, _fhirJsonParser, _outputHelper); // Download all resources from fhir server Dictionary <(string resourceType, string resourceId), Resource> dataFromFhirServer = await ExportTestHelper.GetResourcesFromFhirServer(_testFhirClient, _testFhirClient.HttpClient.BaseAddress, _fhirJsonParser, _outputHelper); // Assert both data are equal Assert.True(ExportTestHelper.ValidateDataFromBothSources(dataFromFhirServer, dataFromExport, _outputHelper)); }
public async Task GivenFhirServer_WhenAllDataIsExportedToASpecificContainer_ThenExportedDataIsInTheSpecifiedContianer() { // NOTE: Azure Storage Emulator is required to run these tests locally. string testContainer = "test-container"; // Trigger export request and check for export status Uri contentLocation = await _testFhirClient.ExportAsync(parameters : $"_container={testContainer}"); IList <Uri> blobUris = await ExportTestHelper.CheckExportStatus(_testFhirClient, contentLocation, timeToWaitInMinutes : 15); // Download exported data from storage account Dictionary <(string resourceType, string resourceId), Resource> dataFromExport = await ExportTestHelper.DownloadBlobAndParse(blobUris, _fhirJsonParser, _outputHelper); // Download all resources from fhir server Dictionary <(string resourceType, string resourceId), Resource> dataFromFhirServer = await ExportTestHelper.GetResourcesFromFhirServer(_testFhirClient, _testFhirClient.HttpClient.BaseAddress, _fhirJsonParser, _outputHelper); // Assert both data are equal Assert.True(ExportTestHelper.ValidateDataFromBothSources(dataFromFhirServer, dataFromExport, _outputHelper)); Assert.True(blobUris.All((url) => url.OriginalString.Contains(testContainer))); }