Beispiel #1
0
        public IList <IndexUri> Set(ITypedElement typedElement, Bug.Common.Enums.ResourceType resourceType, int searchParameterId, string searchParameterName)
        {
            this.TypedElement        = typedElement;
            this.ResourceType        = resourceType;
            this.SearchParameterId   = searchParameterId;
            this.SearchParameterName = searchParameterName;

            var ResourceIndexList = new List <IndexUri>();

            if (this.TypedElement is IFhirValueProvider FhirValueProvider && FhirValueProvider.FhirValue != null)
            {
                if (FhirValueProvider.FhirValue is FhirUri FhirUri)
                {
                    SetUri(FhirUri, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is FhirUrl FhirUrl)
                {
                    SetUrl(FhirUrl, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is Oid Oid)
                {
                    SetOid(Oid, ResourceIndexList);
                }
                else
                {
                    throw new FormatException($"Unknown FhirType: {this.TypedElement.InstanceType} for the SearchParameter entity with the database key of: {this.SearchParameterId.ToString()} for a resource type of: {this.ResourceType.GetCode()} and search parameter name of: {this.SearchParameterName}");
                }
                return(ResourceIndexList);
            }
Beispiel #2
0
 public SearchQueryDateTime(SearchParameter SearchParameter, Bug.Common.Enums.ResourceType ResourceContext, string RawValue, IFhirDateTimeFactory IFhirDateTimeFactory)
     : base(SearchParameter, ResourceContext, RawValue)
 {
     this.SearchParamTypeId    = Bug.Common.Enums.SearchParamType.Date;
     this.ValueList            = new List <SearchQueryDateTimeValue>();
     this.IFhirDateTimeFactory = IFhirDateTimeFactory;
 }
        private Expression <Func <IndexReference, bool> > EqualTo_ByKey(int PrimaryServiceBaseUrlId, string ResourceName, string ResourceId, string VersionId)
        {
            string?NullableVersionId = NullIfEmptyString(VersionId);

            Bug.Common.Enums.ResourceType ResourceType = GetResourceTypeFromString(ResourceName);
            return(x => x.ServiceBaseUrlId == PrimaryServiceBaseUrlId && x.ResourceTypeId == ResourceType && x.ResourceId == ResourceId && x.VersionId == NullableVersionId);
        }
        private Expression <Func <IndexReference, bool> > EqualTo_ByUrlString(string RemoteServiceBaseUrl, string ResourceName, string ResourceId, string VersionId)
        {
            string?NullableVersionId = NullIfEmptyString(VersionId);

            Bug.Common.Enums.ResourceType ResourceType = GetResourceTypeFromString(ResourceName);
            RemoteServiceBaseUrl = Common.StringTools.StringSupport.StripHttp(RemoteServiceBaseUrl);
            return(x => x.ServiceBaseUrl.Url == RemoteServiceBaseUrl && x.ResourceTypeId == ResourceType && x.ResourceId == ResourceId && x.VersionId == NullableVersionId);
        }
Beispiel #5
0
 public SearchQueryReference(SearchParameter SearchParameter, Bug.Common.Enums.ResourceType ResourceContext, IFhirUriFactory IFhirUriFactory, string RawValue, bool IsChained)
     : base(SearchParameter, ResourceContext, RawValue)
 {
     this.IFhirUriFactory   = IFhirUriFactory;
     this.SearchParamTypeId = Bug.Common.Enums.SearchParamType.Reference;
     this.IsChained         = IsChained;
     this.ValueList         = new List <SearchQueryReferenceValue>();
 }
Beispiel #6
0
        public async Task <IList <IndexReference> > SetAsync(ITypedElement typedElement, Bug.Common.Enums.ResourceType resourceType, int searchParameterId, string searchParameterName)
        {
            this.TypedElement        = typedElement;
            this.ResourceType        = resourceType;
            this.SearchParameterId   = searchParameterId;
            this.SearchParameterName = searchParameterName;

            List <IndexReference> ResourceIndexList = new List <IndexReference>();


            if (this.TypedElement is IFhirValueProvider FhirValueProvider && FhirValueProvider.FhirValue != null)
            {
                if (FhirValueProvider.FhirValue is FhirUri FhirUri)
                {
                    await SetFhirUri(FhirUri, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is ResourceReference ResourceReference)
                {
                    await SetResourcereference(ResourceReference, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is Canonical Canonical)
                {
                    await SetCanonical(Canonical, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is Resource Resource)
                {
                    SetResource(Resource, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is Attachment Attachment)
                {
                    await SetUri(Attachment, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is Identifier Identifier)
                {
                    await SetIdentifier(Identifier, ResourceIndexList);
                }
                else
                {
                    throw new FormatException($"Unknown FhirType: {this.TypedElement.InstanceType} for the SearchParameter entity with the database key of: {this.SearchParameterId.ToString()} for a resource type of: {this.ResourceType.GetCode()} and search parameter name of: {this.SearchParameterName}");
                }

                return(ResourceIndexList);
            }
        public IList <IndexDateTime> Set(ITypedElement typedElement, Bug.Common.Enums.ResourceType resourceType, int searchParameterId, string searchParameterName)
        {
            this.TypedElement        = typedElement;
            this.ResourceType        = resourceType;
            this.SearchParameterId   = searchParameterId;
            this.SearchParameterName = searchParameterName;

            var ResourceIndexList = new List <IndexDateTime>();

            if (this.TypedElement is IFhirValueProvider FhirValueProvider && FhirValueProvider.FhirValue != null)
            {
                if (FhirValueProvider.FhirValue is Date Date)
                {
                    SetDate(Date, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is Period Period)
                {
                    SetPeriod(Period, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is FhirDateTime FhirDateTime)
                {
                    SetDateTime(FhirDateTime, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is FhirString FhirString)
                {
                    SetString(FhirString, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is Instant Instant)
                {
                    SetInstant(Instant, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is Timing Timing)
                {
                    SetTiming(Timing, ResourceIndexList);
                }
                else
                {
                    throw new FormatException($"Unknown FhirType: {this.TypedElement.InstanceType} for the SearchParameter entity with the database key of: {this.SearchParameterId.ToString()} for a resource type of: {this.ResourceType.GetCode()} and search parameter name of: {this.SearchParameterName}");
                }

                return(ResourceIndexList);
            }
Beispiel #8
0
        public SearchQueryBase(SearchParameter SearchParameter, Bug.Common.Enums.ResourceType ResourceContext, string RawValue)
        {
            this.ResourceContext = ResourceContext;
            this.Id                     = SearchParameter.Id;
            this.Name                   = SearchParameter.Name;
            this.Description            = SearchParameter.Description;
            this.SearchParamTypeId      = SearchParameter.SearchParamTypeId;
            this.Url                    = SearchParameter.Url;
            this.FhirPath               = SearchParameter.FhirPath;
            this.ResourceTypeList       = SearchParameter.ResourceTypeList;
            this.TargetResourceTypeList = SearchParameter.TargetResourceTypeList;
            this.ComponentList          = SearchParameter.ComponentList;
            this.FhirVersionId          = SearchParameter.FhirVersionId;
            this.RawValue               = RawValue;

            this.TypeModifierResource   = null;
            this.InvalidMessage         = string.Empty;
            this.HasLogicalOrProperties = false;
            this.IsValid = true;
        }
Beispiel #9
0
        public IList <IndexString> Set(ITypedElement typedElement, Bug.Common.Enums.ResourceType resourceType, int searchParameterId, string searchParameterName)
        {
            this.TypedElement        = typedElement;
            this.ResourceType        = resourceType;
            this.SearchParameterId   = searchParameterId;
            this.SearchParameterName = searchParameterName;

            var ResourceIndexList = new List <IndexString>();

            if (this.TypedElement is IFhirValueProvider FhirValueProvider && FhirValueProvider.FhirValue != null)
            {
                if (FhirValueProvider.FhirValue is FhirString FhirString)
                {
                    SetFhirString(FhirString, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is Address address)
                {
                    SetAddress(address, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is HumanName HumanName)
                {
                    SetHumanName(HumanName, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is Markdown Markdown)
                {
                    SetMarkdown(Markdown, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is Annotation Annotation)
                {
                    SetAnnotation(Annotation, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is Base64Binary Base64Binary)
                {
                    //No good purpose to index base64 content as a search index
                }
                else
                {
                    throw new FormatException($"Unknown FhirType: {this.TypedElement.InstanceType} for the SearchParameter entity with the database key of: {this.SearchParameterId.ToString()} for a resource type of: {this.ResourceType.GetCode()} and search parameter name of: {this.SearchParameterName}");
                }
            }
Beispiel #10
0
        public IList <IndexQuantity> Set(ITypedElement typedElement, Bug.Common.Enums.ResourceType resourceType, int searchParameterId, string searchParameterName)
        {
            this.TypedElement        = typedElement;
            this.ResourceType        = resourceType;
            this.SearchParameterId   = searchParameterId;
            this.SearchParameterName = searchParameterName;

            var ResourceIndexList = new List <IndexQuantity>();

            if (this.TypedElement is IFhirValueProvider FhirValueProvider && FhirValueProvider.FhirValue != null)
            {
                if (FhirValueProvider.FhirValue is Integer Integer)
                {
                    SetInteger(Integer, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is PositiveInt PositiveInt)
                {
                    SetPositiveInt(PositiveInt, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is Duration Duration)
                {
                    SetDuration(Duration, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is FhirDecimal FhirDecimal)
                {
                    SetFhirDecimal(FhirDecimal, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is Hl7.Fhir.Model.Range Range)
                {
                    SetRange(Range, ResourceIndexList);
                }
                else
                {
                    throw new FormatException($"Unknown FhirType: {this.TypedElement.InstanceType} for the SearchParameter entity with the database key of: {this.SearchParameterId.ToString()} for a resource type of: {this.ResourceType.GetCode()} and search parameter name of: {this.SearchParameterName}");
                }

                return(ResourceIndexList);
            }
        public async Task <IList <ISearchQueryBase> > Create(Bug.Common.Enums.ResourceType ResourceContext, SearchParameter searchParameter, KeyValuePair <string, StringValues> Parameter, bool IsChainedReferance = false)
        {
            var    Result        = new List <ISearchQueryBase>();
            string ParameterName = Parameter.Key.Trim();

            foreach (var ParameterValue in Parameter.Value)
            {
                string RawValue;
                if (IsChainedReferance)
                {
                    RawValue = $"{ParameterName}{FhirSearchQuery.TermChainDelimiter}";
                }
                else
                {
                    RawValue = $"{ParameterName}={ParameterValue}";
                }

                ISearchQueryBase SearchQueryBase = InitalizeSearchQueryEntity(searchParameter, ResourceContext, IsChainedReferance, RawValue);
                Result.Add(SearchQueryBase);

                SearchQueryBase.ParseModifier(ParameterName, this.IResourceTypeSupport, this.IKnownResource);

                if (SearchQueryBase.Modifier == SearchModifierCode.Type && !IsChainedReferance)
                {
                    SearchQueryBase.ParseValue($"{SearchQueryBase.TypeModifierResource.GetCode()}/{ParameterValue}");
                }
                else if (SearchQueryBase.SearchParamTypeId == Common.Enums.SearchParamType.Composite)
                {
                    await LoadCompositeSubSearchParameters(ResourceContext, searchParameter, ParameterValue, RawValue, SearchQueryBase);
                }
                else
                {
                    SearchQueryBase.ParseValue(ParameterValue);
                }
            }
            return(Result);
        }
Beispiel #12
0
        public IList <IndexQuantity> Set(ITypedElement typedElement, Bug.Common.Enums.ResourceType resourceType, int searchParameterId, string searchParameterName)
        {
            this.TypedElement        = typedElement;
            this.ResourceType        = resourceType;
            this.SearchParameterId   = searchParameterId;
            this.SearchParameterName = searchParameterName;

            var ResourceIndexList = new List <IndexQuantity>();

            if (this.TypedElement is IFhirValueProvider FhirValueProvider && FhirValueProvider.FhirValue != null)
            {
                if (FhirValueProvider.FhirValue is Money Money)
                {
                    SetMoney(Money, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is SimpleQuantity SimpleQuantity)
                {
                    SetSimpleQuantity(SimpleQuantity, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is Quantity Quantity)
                {
                    SetQuantity(Quantity, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is Location.PositionComponent PositionComponent)
                {
                    SetPositionComponent(PositionComponent, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is Hl7.Fhir.Model.Range Range)
                {
                    SetRange(Range, ResourceIndexList);
                }
                else
                {
                    throw new FormatException($"Unknown FhirType: {this.TypedElement.InstanceType} for the SearchParameter entity with the database key of: {this.SearchParameterId.ToString()} for a resource type of: {this.ResourceType.GetCode()} and search parameter name of: {this.SearchParameterName}");
                }
                return(ResourceIndexList);
            }
Beispiel #13
0
        private async Task <IQueryable <ResourceStore> > ChainRecursion(AppDbContext AppDbContext, IQueryable <ResourceStore> OtherResourceStoreQuery, ISearchQueryBase ChainSearchQuery)
        {
            if (ChainSearchQuery.ChainedSearchParameter is object)
            {
                //Recursively move through each child chain search query until at the end and child is null
                //The last one is the root search at the end of the chain, performer:Organization.name from the example.
                Bug.Common.Enums.ResourceType ChainedResourceTypeContext = ChainSearchQuery.ChainedSearchParameter.ResourceContext;
                IQueryable <ResourceStore>    ResCurrentTypeContext      = AppDbContext.Set <ResourceStore>();

                IQueryable <IndexReference> IndexReferenceContext = AppDbContext.Set <IndexReference>();
                IQueryable <IndexString>    IndexStringContext    = AppDbContext.Set <IndexString>();

                ResCurrentTypeContext = await ChainRecursion(AppDbContext, ResCurrentTypeContext, ChainSearchQuery.ChainedSearchParameter);

                Bug.Common.Enums.ResourceType ReferenceResourceType = ChainSearchQuery.TypeModifierResource.Value;
                int ReferenceSearchParameterId = ChainSearchQuery.ChainedSearchParameter.Id;
                //need to get the Key of the Primary Base URL somehow as hard coded here
                //int ReferencePrimaryServiceRootUrlId = IServiceBaseUrlCache.GetPrimaryAsync.Id;
                int ReferencePrimaryServiceRootUrlId = 1;


                OtherResourceStoreQuery = OtherResourceStoreQuery.Where(x =>
                                                                        x.ReferenceIndexList.Any(y =>
                                                                                                 y.ServiceBaseUrlId == 1 &
                                                                                                 y.SearchParameterId == 1000 &
                                                                                                 y.ResourceTypeId == Common.Enums.ResourceType.Observation &
                                                                                                 y.CanonicalVersionId == null &
                                                                                                 y.VersionId == null &
                                                                                                 IndexReferenceContext.Where(g =>
                                                                                                                             g.ServiceBaseUrlId == 1 &
                                                                                                                             g.SearchParameterId == 2000 &
                                                                                                                             g.ResourceTypeId == Common.Enums.ResourceType.DiagnosticReport &
                                                                                                                             g.CanonicalVersionId == null &
                                                                                                                             g.VersionId == null &
                                                                                                                             IndexStringContext.Where(l =>
                                                                                                                                                      l.SearchParameterId == 3000 &
                                                                                                                                                      l.String == "Value").Select(s => s.ResourceStoreId).Contains(g.ResourceStoreId)).Select(q => q.ResourceStoreId).Contains(y.ResourceStoreId)));



                OtherResourceStoreQuery = OtherResourceStoreQuery
                                          .Where(x =>
                                                 x.ReferenceIndexList.Any(c =>
                                                                          ResCurrentTypeContext.Where(a =>
                                                                                                      a.IsCurrent == true &
                                                                                                      a.IsDeleted == false &
                                                                                                      a.ContainedId == null &
                                                                                                      a.ReferenceIndexList.Any(f =>
                                                                                                                               f.ResourceTypeId == ReferenceResourceType &
                                                                                                                               f.SearchParameterId == ReferenceSearchParameterId &
                                                                                                                               f.VersionId == null &
                                                                                                                               f.CanonicalVersionId == null &
                                                                                                                               f.ServiceBaseUrlId == ReferencePrimaryServiceRootUrlId)).Select(v => v.Id).Contains(c.Id)));
                return(OtherResourceStoreQuery);
            }
            else
            {
                switch (ChainSearchQuery.SearchParamTypeId)
                {
                case Common.Enums.SearchParamType.Number:
                    var Predicate2 = IResourceStorePredicateFactory.NumberIndex(ChainSearchQuery);
                    IQueryable <IndexQuantity>        IndexQuantity = AppDbContext.Set <IndexQuantity>();
                    ExpressionStarter <IndexQuantity> PredicateGus  = PredicateBuilder.New <IndexQuantity>(true);
                    foreach (var Pred in Predicate2)
                    {
                        PredicateGus = PredicateGus.Or(Pred);
                    }
                    IndexQuantity = IndexQuantity.Where(PredicateGus);

                    break;

                case Common.Enums.SearchParamType.Date:
                    break;

                case Common.Enums.SearchParamType.String:
                    break;

                case Common.Enums.SearchParamType.Token:
                    break;

                case Common.Enums.SearchParamType.Reference:
                    break;

                case Common.Enums.SearchParamType.Composite:
                    break;

                case Common.Enums.SearchParamType.Quantity:
                    break;

                case Common.Enums.SearchParamType.Uri:
                    break;

                case Common.Enums.SearchParamType.Special:
                    break;

                default:
                    break;
                }


                var Predicate = await GetResourceStoreIndexPredicate(ChainSearchQuery.FhirVersionId, ChainSearchQuery.ResourceContext, new List <ISearchQueryBase>() { ChainSearchQuery });

                IQueryable <ResourceStore> ResCurrentTypeContext = AppDbContext.Set <ResourceStore>();
                ResCurrentTypeContext = ResCurrentTypeContext.AsExpandable().Where(Predicate);

                OtherResourceStoreQuery = OtherResourceStoreQuery
                                          .Where(x => x.ReferenceIndexList.Any(c => ResCurrentTypeContext.Select(v => v.Id).Contains(c.Id)));

                return(OtherResourceStoreQuery);
            }
        }
Beispiel #14
0
 public SearchQueryQuantity(SearchParameter SearchParameter, Bug.Common.Enums.ResourceType ResourceContext, string RawValue)
     : base(SearchParameter, ResourceContext, RawValue)
 {
     this.SearchParamTypeId = Bug.Common.Enums.SearchParamType.Quantity;
     this.ValueList         = new List <SearchQueryQuantityValue>();
 }
Beispiel #15
0
        public async Task <IndexerOutcome> Process(Common.FhirTools.FhirResource fhirResource, Bug.Common.Enums.ResourceType resourceType)
        {
            var IndexerOutcome = new IndexerOutcome();

            List <SearchParameter> SearchParameterList = await ISearchParameterCache.GetForIndexingAsync(fhirResource.FhirVersion, resourceType);


            foreach (SearchParameter SearchParameter in SearchParameterList)
            {
                //Composite searchParameters do not require populating as they are a Composite of other SearchParameter Types
                //searchParameters with an empty or null FHIRPath can not be indexed, this is true for _query and _content which
                //in my view should not be searchParameter, just as _sort or _count are not.
                if (SearchParameter.SearchParamTypeId != Common.Enums.SearchParamType.Composite && !string.IsNullOrWhiteSpace(SearchParameter.FhirPath))
                {
                    IEnumerable <ITypedElement>?ResultList;
                    try
                    {
                        ResultList = ITypedElementSupport.Select(fhirResource, SearchParameter.FhirPath);
                    }
                    catch (Exception Exec)
                    {
                        throw new Bug.Common.Exceptions.FhirFatalException(System.Net.HttpStatusCode.InternalServerError, $"Error indexing the FhirPath select expression for the SearchParameter with the name of : {SearchParameter.Name} for a resource type of : {resourceType.GetCode()} with the SearchParameter database primary key of {SearchParameter.Id.ToString()}.  The FhirPath expression was : {SearchParameter.FhirPath}. See inner exception for more info.", Exec);
                    }

                    //This null check of ResultList is only here due to the exception issue above.
                    if (ResultList is object)
                    {
                        foreach (ITypedElement TypedElement in ResultList)
                        {
                            if (TypedElement != null)
                            {
                                switch (SearchParameter.SearchParamTypeId)
                                {
                                case Common.Enums.SearchParamType.Number:
                                    IndexerOutcome.QuantityIndexList.AddRange(INumberSetterSupport.Set(fhirResource.FhirVersion, TypedElement, resourceType, SearchParameter.Id, SearchParameter.Name));
                                    break;

                                case Common.Enums.SearchParamType.Date:
                                    IndexerOutcome.DateTimeIndexList.AddRange(IDateTimeSetterSupport.Set(fhirResource.FhirVersion, TypedElement, resourceType, SearchParameter.Id, SearchParameter.Name));

                                    break;

                                case Common.Enums.SearchParamType.String:
                                    IndexerOutcome.StringIndexList.AddRange(IStringSetterSupport.Set(fhirResource.FhirVersion, TypedElement, resourceType, SearchParameter.Id, SearchParameter.Name));
                                    break;

                                case Common.Enums.SearchParamType.Token:
                                    IndexerOutcome.TokenIndexList.AddRange(ITokenSetterSupport.Set(fhirResource.FhirVersion, TypedElement, resourceType, SearchParameter.Id, SearchParameter.Name));
                                    break;

                                case Common.Enums.SearchParamType.Reference:
                                    IndexerOutcome.ReferenceIndexList.AddRange(await IReferenceSetterSupport.SetAsync(fhirResource.FhirVersion, TypedElement, resourceType, SearchParameter.Id, SearchParameter.Name));
                                    break;

                                case Common.Enums.SearchParamType.Composite:
                                    //Composite searchParameters do not require populating as they are a Composite of other SearchParameter Types
                                    break;

                                case Common.Enums.SearchParamType.Quantity:
                                    IndexerOutcome.QuantityIndexList.AddRange(IQuantitySetterSupport.Set(fhirResource.FhirVersion, TypedElement, resourceType, SearchParameter.Id, SearchParameter.Name));
                                    break;

                                case Common.Enums.SearchParamType.Uri:
                                    IndexerOutcome.UriIndexList.AddRange(IUriSetterSupport.Set(fhirResource.FhirVersion, TypedElement, resourceType, SearchParameter.Id, SearchParameter.Name));
                                    break;

                                case Common.Enums.SearchParamType.Special:
                                    string SpecialMessage = $"Encountered a search parameter of type: {Common.Enums.SearchParamType.Special.GetCode()} which is not supported by the server. " +
                                                            $"The search parameter had the name of : {SearchParameter.Name} with a SearchParameter database primary key of {SearchParameter.Id.ToString()}. The " +
                                                            $"resource type being processed was of type : {resourceType.GetCode()}";
                                    this.ILogger.LogWarning(SpecialMessage);
                                    break;

                                default:
                                    throw new Bug.Common.Exceptions.FhirFatalException(System.Net.HttpStatusCode.InternalServerError, $"Internal Server Error: Encountered an unknown SearchParamType of type {SearchParameter.SearchParamTypeId.GetCode()}");
                                }
                            }
                        }
                    }
                }
            }
            return(IndexerOutcome);
        }
 private ISearchQueryBase InitalizeSearchQueryEntity(SearchParameter searchParameter, Bug.Common.Enums.ResourceType ResourceContext, bool IsChained, string RawValue)
 {
     return(searchParameter.SearchParamTypeId switch
     {
         Common.Enums.SearchParamType.Number => new SearchQueryNumber(searchParameter, ResourceContext, RawValue),
         Common.Enums.SearchParamType.Date => new SearchQueryDateTime(searchParameter, ResourceContext, RawValue, IFhirDateTimeFactory),
         Common.Enums.SearchParamType.String => new SearchQueryString(searchParameter, ResourceContext, RawValue),
         Common.Enums.SearchParamType.Token => new SearchQueryToken(searchParameter, ResourceContext, RawValue),
         Common.Enums.SearchParamType.Reference => new SearchQueryReference(searchParameter, ResourceContext, this.IFhirUriFactory, RawValue, IsChained),
         Common.Enums.SearchParamType.Composite => new SearchQueryComposite(searchParameter, ResourceContext, RawValue),
         Common.Enums.SearchParamType.Quantity => new SearchQueryQuantity(searchParameter, ResourceContext, RawValue),
         Common.Enums.SearchParamType.Uri => new SearchQueryUri(searchParameter, ResourceContext, RawValue),
         Common.Enums.SearchParamType.Special => new SearchQueryNumber(searchParameter, ResourceContext, RawValue),
         _ => throw new System.ComponentModel.InvalidEnumArgumentException(searchParameter.SearchParamTypeId.ToString(), (int)searchParameter.SearchParamTypeId, typeof(Bug.Common.Enums.SearchParamType)),
     });
Beispiel #17
0
        public IList <IndexToken> Set(ITypedElement typedElement, Bug.Common.Enums.ResourceType resourceType, int searchParameterId, string searchParameterName)
        {
            this.TypedElement        = typedElement;
            this.ResourceType        = resourceType;
            this.SearchParameterId   = searchParameterId;
            this.SearchParameterName = searchParameterName;

            var ResourceIndexList = new List <IndexToken>();


            if (this.TypedElement is IFhirValueProvider FhirValueProvider && FhirValueProvider.FhirValue != null)
            {
                if (FhirValueProvider.FhirValue is Code Code)
                {
                    SetCode(Code, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is CodeableConcept CodeableConcept)
                {
                    SetCodeableConcept(CodeableConcept, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is Coding Coding)
                {
                    SetCoding(Coding, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue.TypeName == "code")
                {
                    if (this.TypedElement.Value is string CodeValue)
                    {
                        SetCodeTypeT(CodeValue, ResourceIndexList);
                    }
                }
                else if (FhirValueProvider.FhirValue is ContactPoint ContactPoint)
                {
                    SetContactPoint(ContactPoint, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is FhirBoolean FhirBoolean)
                {
                    SetFhirBoolean(FhirBoolean, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is FhirDateTime FhirDateTime)
                {
                    SetFhirDateTime(FhirDateTime, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is FhirString FhirString)
                {
                    SetFhirString(FhirString, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is Id Id)
                {
                    SetId(Id, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is Identifier Identifier)
                {
                    SetIdentifier(Identifier, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is PositiveInt PositiveInt)
                {
                    SetPositiveInt(PositiveInt, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is Quantity Quantity)
                {
                    SetQuantity(Quantity, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is Hl7.Fhir.Model.Range Range)
                {
                    SetRange(Range, ResourceIndexList);
                }
                else if (FhirValueProvider.FhirValue is Location.PositionComponent PositionComponent)
                {
                    SePositionComponent(PositionComponent, ResourceIndexList);
                }
                else
                {
                    throw new FormatException($"Unknown FhirType: {this.TypedElement.InstanceType} for the SearchParameter entity with the database key of: {this.SearchParameterId.ToString()} for a resource type of: {this.ResourceType.GetCode()} and search parameter name of: {this.SearchParameterName}");
                }
                return(ResourceIndexList);
            }