コード例 #1
0
        public async Task GivenASearchParameterDefinitionManager_WhenGettingSearchParameterHashForExistingResourceType_ThenHashIsReturned()
        {
            // Initialize a search parameter
            var searchParam = new SearchParameter()
            {
                Url  = "http://test/Patient-test",
                Type = Hl7.Fhir.Model.SearchParamType.String,
                Base = new List <ResourceType?>()
                {
                    ResourceType.Patient
                },
                Expression = "Patient.Name",
                Name       = "test",
                Code       = "test",
            };

            _searchParameterSupportResolver
            .IsSearchParameterSupported(Arg.Is <SearchParameterInfo>(p => p.Name == "test"))
            .Returns((true, false));

            await _searchParameterOperations.AddSearchParameterAsync(searchParam.ToTypedElement());

            var searchParamHash = _searchParameterDefinitionManager.GetSearchParameterHashForResourceType("Patient");

            Assert.NotNull(searchParamHash);
        }
コード例 #2
0
        public async Task <UpsertResourceResponse> Handle(CreateResourceRequest request, CancellationToken cancellationToken, RequestHandlerDelegate <UpsertResourceResponse> next)
        {
            if (request.Resource.InstanceType.Equals(KnownResourceTypes.SearchParameter, StringComparison.Ordinal))
            {
                // Before committing the SearchParameter resource to the data store, add it to the SearchParameterDefinitionManager
                // and parse the fhirPath, as well as validate the parameter type
                await _searchParameterOperations.AddSearchParameterAsync(request.Resource.Instance, cancellationToken);
            }

            // Allow the resource to be updated with the normal handler
            return(await next());
        }
コード例 #3
0
        internal async Task EnsureInitializedAsync(CancellationToken cancellationToken)
        {
            // now read in any previously POST'd SearchParameter resources
            using IScoped <ISearchService> search = _searchServiceFactory.Invoke();
            string continuationToken = null;

            do
            {
                var queryParams = new List <Tuple <string, string> >();
                if (continuationToken != null)
                {
                    queryParams.Add(new Tuple <string, string>(KnownQueryParameterNames.ContinuationToken, continuationToken));
                }

                var result = await search.Value.SearchAsync("SearchParameter", queryParams, cancellationToken);

                if (!string.IsNullOrEmpty(result?.ContinuationToken))
                {
                    continuationToken = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(result.ContinuationToken));
                }
                else
                {
                    continuationToken = null;
                }

                if (result != null && result.Results != null && result.Results.Any())
                {
                    var searchParams = result.Results.Select(r => r.Resource.RawResource.ToITypedElement(_modelInfoProvider)).ToList();

                    foreach (var searchParam in searchParams)
                    {
                        try
                        {
                            await _searchParameterOperations.AddSearchParameterAsync(searchParam);
                        }
                        catch (SearchParameterNotSupportedException ex)
                        {
                            _logger.LogWarning(ex, "Error loading search parameter {url} from data store.", searchParam.GetStringScalar("url"));
                        }
                        catch (InvalidDefinitionException ex)
                        {
                            _logger.LogWarning(ex, "Error loading search parameter {url} from data store.", searchParam.GetStringScalar("url"));
                        }
                        catch (Exception ex)
                        {
                            _logger.LogError(ex, "Error loading search parameter {url} from data store.", searchParam.GetStringScalar("url"));
                        }
                    }
                }
            }while (continuationToken != null);

            await _mediator.Publish(new SearchParametersInitializedNotification(), CancellationToken.None);
        }
        public async Task <UpsertResourceResponse> Handle(CreateResourceRequest request, CancellationToken cancellationToken, RequestHandlerDelegate <UpsertResourceResponse> next)
        {
            // Allow the resource to be updated with the normal handler
            var response = await next();

            if (request.Resource.InstanceType.Equals(KnownResourceTypes.SearchParameter, StringComparison.Ordinal))
            {
                // Once the SearchParameter resource is committed to the data store, we can update the in
                // memory SearchParameterDefinitionManager, and persist the status to the data store
                await _searchParameterOperations.AddSearchParameterAsync(request.Resource.Instance);
            }

            return(response);
        }