public override object CloneDeep()
        {
            var Clone = new SearchQueryComposite(this as SearchParameter, this.ResourceContext, this.RawValue);

            base.CloneDeep(Clone);
            Clone.ValueList = new List <SearchQueryCompositeValue>();
            Clone.ValueList.AddRange(this.ValueList);
            return(Clone);
        }
示例#2
0
        private async Task LoadCompositeSubSearchParameters(Common.Enums.ResourceType ResourceContext, SearchParameter searchParameter, string ParameterValue, string RawValue, ISearchQueryBase SearchQueryBase)
        {
            if (SearchQueryBase is SearchQueryComposite SearchQueryComposite)
            {
                List <ISearchQueryBase> SearchParameterBaseList = new List <ISearchQueryBase>();

                //Note we OrderBy SequentialOrder as they must be processed in this specific order
                foreach (SearchParameterComponent Component in SearchQueryComposite.ComponentList) //Should this be ordered by sentinel?
                {
                    SearchParameter?CompositeSearchParamter = await ISearchParameterRepository.GetByCanonicalUrlAsync(SearchQueryComposite.FhirVersionId, ResourceContext, Component.Definition);

                    if (CompositeSearchParamter is object)
                    {
                        ISearchQueryBase CompositeSubSearchQueryBase = InitalizeSearchQueryEntity(CompositeSearchParamter, ResourceContext, false, RawValue);
                        SearchParameterBaseList.Add(CompositeSubSearchQueryBase);
                    }
                    else
                    {
                        //This should not ever happen, but have message in case it does. We should never have a Composite
                        //search parameter loaded like this as on load it is checked, but you never know!
                        string Message =
                            $"Unable to locate one of the SearchParameters referenced in a Composite SearchParametrer type. " +
                            $"The Composite SearchParametrer Url was: {SearchQueryComposite.Url} for the resource type '{ResourceContext.GetCode()}'. " +
                            $"This SearchParamter references another SearchParamter with the Canonical Url of {Component.Definition}. " +
                            $"This SearchParamter can not be located in the FHIR Server. This is most likely a server error that will require investigation to resolve";
                        SearchQueryComposite.InvalidMessage = Message;
                        SearchQueryComposite.IsValid        = false;
                        break;
                    }
                }
                SearchQueryComposite.ParseCompositeValue(SearchParameterBaseList, ParameterValue);
            }
            else
            {
                throw new InvalidCastException($"Unable to cast a {nameof(SearchQueryBase)} to {typeof(SearchQueryComposite).Name} when the {nameof(SearchQueryBase)}.{nameof(SearchQueryBase.SearchParamTypeId)} = {SearchQueryBase.SearchParamTypeId.GetCode()}");
            }
        }