public async Task GivenADatabaseWithAnEarlierSupportedSchema_WhenSearchingWithSort_SearchIsSuccessful()
        {
            string databaseName            = $"FHIRCOMPATIBILITYTEST_SORT_{DateTimeOffset.UtcNow.ToUnixTimeSeconds()}";
            int    schemaVersion           = SchemaVersionConstants.AddMinMaxForDateAndStringSearchParamVersion - 1;
            var    fhirStorageTestsFixture = new FhirStorageTestsFixture(new SqlServerFhirStorageTestsFixture(
                                                                             schemaVersion,
                                                                             databaseName));

            try
            {
                await fhirStorageTestsFixture.InitializeAsync();

                Mediator mediator = fhirStorageTestsFixture.Mediator;

                var saveResult = await mediator.UpsertResourceAsync(Samples.GetDefaultPatient());

                var deserialized = saveResult.RawResourceElement.ToResourceElement(Deserializers.ResourceDeserializer);

                List <Tuple <string, string> > queries = new List <Tuple <string, string> >();
                queries.Add(new Tuple <string, string>("_sort", "birthdate"));

                Core.Models.ResourceElement searchResult = await mediator.SearchResourceAsync("Patient", queries);

                var bundle = searchResult.ResourceInstance as Bundle;

                Assert.NotNull(searchResult);
                Assert.Single(bundle.Entry);
            }
            catch (Exception e)
            {
                throw new InvalidOperationException($"Sort query failed for schema version {schemaVersion}", e);
            }
            finally
            {
                await fhirStorageTestsFixture?.DisposeAsync();
            }
        }
Example #2
0
        private async System.Threading.Tasks.Task ValidateIfBundleEntryIsUniqueAsync(Core.Models.ResourceElement requestBundle)
        {
            var resourceIdList = new HashSet <string>(StringComparer.Ordinal);
            var bundle         = requestBundle.ToPoco <Hl7.Fhir.Model.Bundle>();

            var mockSearchEntry = new SearchResultEntry(
                new ResourceWrapper(
                    "123",
                    "1",
                    "Patient",
                    new RawResource("data", Core.Models.FhirResourceFormat.Json),
                    null,
                    DateTimeOffset.MinValue,
                    false,
                    null,
                    null,
                    null));

            var mockSearchResult = new SearchResult(new[] { mockSearchEntry }, new Tuple <string, string> [0], Array.Empty <(string parameterName, string reason)>(), null);

            _searchService.SearchAsync("Patient", Arg.Any <IReadOnlyList <Tuple <string, string> > >(), CancellationToken.None).Returns(mockSearchResult);

            await _transactionBundleValidator.ValidateBundle(bundle, CancellationToken.None);
        }
Example #3
0
 private static void ValidateIfBundleEntryIsUnique(Core.Models.ResourceElement requestBundle)
 {
     TransactionValidator.ValidateTransactionBundle(requestBundle.ToPoco <Hl7.Fhir.Model.Bundle>());
 }