Exemple #1
0
        private async Task LoadSearchParamsFromDataStore(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?.Results != null && result.Results.Any())
                {
                    var searchParams = result.Results.Select(r => r.Resource.RawResource.ToITypedElement(_modelInfoProvider)).ToList();

                    foreach (var searchParam in searchParams)
                    {
                        try
                        {
                            SearchParameterDefinitionBuilder.Build(
                                new List <ITypedElement>()
                            {
                                searchParam
                            },
                                UrlLookup,
                                TypeLookup,
                                _modelInfoProvider);
                        }
                        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);
        }
        public void AddNewSearchParameters(IReadOnlyCollection <ITypedElement> searchParameters)
        {
            SearchParameterDefinitionBuilder.Build(
                searchParameters,
                UrlLookup,
                TypeLookup,
                _modelInfoProvider);

            CalculateSearchParameterHash();
        }
        private async Task LoadSearchParamsFromDataStore(CancellationToken cancellationToken)
        {
            // now read in any previously POST'd SearchParameter resources
            using IScoped <ISearchService> search = _searchServiceFactory.Invoke();
            string continuationToken = null;

            do
            {
                var searchOptions = new SearchOptions();
                searchOptions.Sort = new List <(SearchParameterInfo, SortOrder)>();
                searchOptions.UnsupportedSearchParams = new List <Tuple <string, string> >();
                searchOptions.Expression   = Expression.SearchParameter(SearchParameterInfo.ResourceTypeSearchParameter, Expression.StringEquals(FieldName.TokenCode, null, KnownResourceTypes.SearchParameter, false));
                searchOptions.MaxItemCount = 10;
                if (continuationToken != null)
                {
                    searchOptions.ContinuationToken = continuationToken;
                }

                var result = await search.Value.SearchAsync(searchOptions, cancellationToken);

                continuationToken = result?.ContinuationToken;

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

                    foreach (var searchParam in searchParams)
                    {
                        try
                        {
                            SearchParameterDefinitionBuilder.Build(
                                new List <ITypedElement>()
                            {
                                searchParam
                            },
                                UrlLookup,
                                TypeLookup,
                                _modelInfoProvider);
                        }
                        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);
        }
        public Task StartAsync(CancellationToken cancellationToken)
        {
            var bundle = SearchParameterDefinitionBuilder.ReadEmbeddedSearchParameters("search-parameters.json", _modelInfoProvider);

            SearchParameterDefinitionBuilder.Build(
                bundle.Entries.Select(e => e.Resource).ToList(),
                UrlLookup,
                TypeLookup,
                _modelInfoProvider);

            return(Task.CompletedTask);
        }
        public void Start()
        {
            var builder = new SearchParameterDefinitionBuilder(
                _modelInfoProvider,
                "search-parameters.json");

            builder.Build();

            _typeLookup = builder.ResourceTypeDictionary;
            UrlLookup   = builder.UriDictionary;

            List <string> list = UrlLookup.Values.Where(p => p.Type == ValueSets.SearchParamType.Composite).Select(p => string.Join("|", p.Component.Select(c => UrlLookup[c.DefinitionUrl].Type))).Distinct().ToList();
        }
        public void Start()
        {
            Type type = GetType();

            var builder = new SearchParameterDefinitionBuilder(
                _fhirJsonParser,
                type.Assembly,
                $"{type.Namespace}.search-parameters.json");

            builder.Build();

            _typeLookup = builder.ResourceTypeDictionary;
            _urlLookup  = builder.UriDictionary;
        }
Exemple #7
0
        public void Start()
        {
            Type type = GetType();

            var builder = new SearchParameterDefinitionBuilder(
                _fhirJsonParser,
                type.Assembly,
                $"{type.Namespace}.search-parameters.json");

            builder.Build();

            _typeLookup = builder.ResourceTypeDictionary;
            _urlLookup  = builder.UriDictionary;

            List <string> list = _urlLookup.Values.Where(p => p.Type == SearchParamType.Composite).Select(p => string.Join("|", p.Component.Select(c => _urlLookup[c.GetComponentDefinitionUri()].Type))).Distinct().ToList();
        }
Exemple #8
0
        public void Start()
        {
            Type type = GetType();

            var builder = new SearchParameterDefinitionBuilder(
                _fhirJsonParser,
                _modelInfoProvider,
                type.Assembly,
                $"{type.Namespace}.search-parameters.json",
                $"{type.Namespace}.unsupported-search-parameters.json");

            builder.Build();

            _typeLookup = builder.ResourceTypeDictionary;
            UrlLookup   = builder.UriDictionary;

            List <string> list = UrlLookup.Values.Where(p => p.Type == ValueSets.SearchParamType.Composite).Select(p => string.Join("|", p.Component.Select(c => UrlLookup[c.DefinitionUrl].Type))).Distinct().ToList();
        }
        public void Start()
        {
            // This method is idempotent because dependent Start methods are not guaranteed to be executed in order.
            if (!_started)
            {
                var builder = new SearchParameterDefinitionBuilder(
                    _modelInfoProvider,
                    "search-parameters.json");

                builder.Build();

                _typeLookup = builder.ResourceTypeDictionary;
                UrlLookup   = builder.UriDictionary;

                List <string> list = UrlLookup.Values.Where(p => p.Type == ValueSets.SearchParamType.Composite).Select(p => string.Join("|", p.Component.Select(c => UrlLookup[c.DefinitionUrl].Type))).Distinct().ToList();

                _started = true;
            }
        }