Esempio n. 1
0
        public static IEnumerable <object[]> GetValidSearchParameters()
        {
            yield return(new object[] { new SearchParameterInfo("test", "test", ValueSets.SearchParamType.Date) });

            yield return(new object[] { new SearchParameterInfo("test", "test", ValueSets.SearchParamType.Token) });

            yield return(new object[] { new SearchParameterInfo("test", "test", ValueSets.SearchParamType.Number) });

            yield return(new object[] { new SearchParameterInfo("test", "test", ValueSets.SearchParamType.Quantity) });

            yield return(new object[] { new SearchParameterInfo("test", "test", ValueSets.SearchParamType.Reference) });

            yield return(new object[] { new SearchParameterInfo("test", "test", ValueSets.SearchParamType.String) });

            yield return(new object[] { new SearchParameterInfo("test", "test", ValueSets.SearchParamType.Uri) });

            var components = new List <SearchParameterComponentInfo>();
            var component  = new SearchParameterComponentInfo();

            component.ResolvedSearchParameter = new SearchParameterInfo("test", "test", ValueSets.SearchParamType.Token);
            components.Add(component);
            component = new SearchParameterComponentInfo();
            component.ResolvedSearchParameter = new SearchParameterInfo("test", "test", ValueSets.SearchParamType.Quantity);
            components.Add(component);
            var compositeParam = new SearchParameterInfo("test", "test", ValueSets.SearchParamType.Composite, components: components);

            yield return(new object[] { compositeParam });
        }
        private IEnumerable <SearchIndexEntry> ProcessCompositeSearchParameter(SearchParameterInfo searchParameter, ITypedElement resource, EvaluationContext context)
        {
            Debug.Assert(searchParameter?.Type == SearchParamType.Composite, "The search parameter must be composite.");

            SearchParameterInfo compositeSearchParameterInfo = searchParameter;

            IEnumerable <ITypedElement> rootObjects = resource.Select(searchParameter.Expression, context);

            foreach (var rootObject in rootObjects)
            {
                int  numberOfComponents = searchParameter.Component.Count;
                bool skip = false;

                var componentValues = new IReadOnlyList <ISearchValue> [numberOfComponents];

                // For each object extracted from the expression, we will need to evaluate each component.
                for (int i = 0; i < numberOfComponents; i++)
                {
                    SearchParameterComponentInfo component = searchParameter.Component[i];

                    // First find the type of the component.
                    SearchParameterInfo componentSearchParameterDefinition = searchParameter.Component[i].ResolvedSearchParameter;

                    IReadOnlyList <ISearchValue> extractedComponentValues = ExtractSearchValues(
                        componentSearchParameterDefinition.Url.ToString(),
                        componentSearchParameterDefinition.Type,
                        componentSearchParameterDefinition.TargetResourceTypes,
                        rootObject,
                        component.Expression,
                        context);

                    // Filter out any search value that's not valid as a composite component.
                    extractedComponentValues = extractedComponentValues
                                               .Where(sv => sv.IsValidAsCompositeComponent)
                                               .ToArray();

                    if (!extractedComponentValues.Any())
                    {
                        // One of the components didn't have any value and therefore it will not be indexed.
                        skip = true;
                        break;
                    }

                    componentValues[i] = extractedComponentValues;
                }

                if (skip)
                {
                    continue;
                }

                yield return(new SearchIndexEntry(compositeSearchParameterInfo, new CompositeSearchValue(componentValues)));
            }
        }
Esempio n. 3
0
        public ValueSets.SearchParamType GetSearchParameterType(SearchParameterInfo searchParameter, int?componentIndex)
        {
            if (componentIndex == null)
            {
                return(searchParameter.Type);
            }

            SearchParameterComponentInfo component = searchParameter.Component[componentIndex.Value];
            SearchParameterInfo          componentSearchParameter = GetSearchParameter(component.DefinitionUrl);

            return(componentSearchParameter.Type);
        }