/// <inheritdoc />
        public IReadOnlyCollection <SearchIndexEntry> Extract(ResourceElement resource)
        {
            EnsureArg.IsNotNull(resource, nameof(resource));

            var entries = new List <SearchIndexEntry>();

            var context = _modelInfoProvider.GetEvaluationContext(_referenceToElementResolver.Resolve);

            // This allow to resolve %resource FhirPath to provided value.
            context.Resource = resource.Instance;

            IEnumerable <SearchParameterInfo> searchParameters = _searchParameterDefinitionManager.GetSearchParameters(resource.InstanceType);

            foreach (SearchParameterInfo searchParameter in searchParameters)
            {
                if (searchParameter.Code == SearchParameterNames.ResourceType)
                {
                    // We don't index the resource type value. We just use the property on the root document.

                    continue;
                }

                if (searchParameter.Type == SearchParamType.Composite)
                {
                    entries.AddRange(ProcessCompositeSearchParameter(searchParameter, resource.Instance, context));
                }
                else
                {
                    entries.AddRange(ProcessNonCompositeSearchParameter(searchParameter, resource.Instance, context));
                }
            }

            return(entries.Distinct().ToList());
        }
Exemple #2
0
 public static EvaluationContext GetEvaluationContext(ITypedElement element)
 {
     EnsureProvider();
     return(_modelInfoProvider.GetEvaluationContext(element));
 }