예제 #1
0
        private IndexValue IndexResourceRecursively(Resource resource, IKey key, string rootPartName = "root")
        {
            var searchParametersForResource = _fhirModel.FindSearchParameters(resource.GetType());

            if (searchParametersForResource != null)
            {
                var result = new IndexValue(rootPartName);

                AddMetaParts(resource, key, result);

                foreach (var par in searchParametersForResource)
                {
                    var newIndexPart = new IndexValue(par.Code);
                    foreach (var path in par.GetPropertyPath())
                    {
                        _resourceVisitor.VisitByPath(resource,
                                                     obj =>
                        {
                            if (obj is Element)
                            {
                                newIndexPart.Values.AddRange(_elementIndexer.Map(obj as Element));
                            }
                        }
                                                     , path);
                    }
                    if (newIndexPart.Values.Any())
                    {
                        result.Values.Add(newIndexPart);
                    }
                }

                if (resource is DomainResource)
                {
                    AddContainedResources((DomainResource)resource, result);
                }

                return(result);
            }
            return(null);
        }
예제 #2
0
        public void ElementMapTest()
        {
            var input = new Annotation {
                Text = new Markdown("Text of the annotation")
            };

            _ = _sut.Map(input);

            //    Assert.Equal(2, lastLogEntry.EventId); //EventId 2 is related to Unsupported  features.
        }
        public void ElementMapTest()
        {
            var input = new Annotation();

            input.Text = "Text of the annotation";
            var result = sut.Map(input);

            Assert.AreEqual(2, lastLogEntry.EventId); //EventId 2 is related to Unsupported  features.
        }
        public void ElementMapTest()
        {
            var input = new Annotation();

            input.Text = "Text of the annotation";
            var result = sut.Map(input);
            //Assert.AreEqual(1, result.Count);
            //Assert.IsInstanceOfType(result.First(), typeof(StringValue));
            //Assert.AreEqual(input.ToString(), ((StringValue)result.First()).Value);
        }
예제 #5
0
파일: IndexService.cs 프로젝트: jjrdk/spark
        private IndexValue IndexResourceRecursively(Resource resource, IKey key, string rootPartName = "root")
        {
            var searchParameters = _fhirModel.FindSearchParameters(resource.GetType());

            if (searchParameters == null)
            {
                return(null);
            }

            var rootIndexValue = new IndexValue(rootPartName);

            AddMetaParts(resource, key, rootIndexValue);

            ElementNavFhirExtensions.PrepareFhirSymbolTableFunctions();

            foreach (var searchParameter in searchParameters)
            {
                if (string.IsNullOrWhiteSpace(searchParameter.Expression))
                {
                    continue;
                }

                // TODO: Do we need to index composite search parameters, some
                // of them are already indexed by ordinary search parameters so
                // need to make sure that we don't do overlapping indexing.
                if (searchParameter.Type == Hl7.Fhir.Model.SearchParamType.Composite)
                {
                    continue;
                }

                var indexValue = new IndexValue(searchParameter.Code);
                IEnumerable <Base> resolvedValues;
                // HACK: Ignoring search parameter expressions which the FhirPath engine does not yet have support for
                try
                {
                    resolvedValues = resource.SelectNew(searchParameter.Expression);
                }
                catch// (Exception e)
                {
                    // TODO: log error!
                    resolvedValues = new List <Base>();
                }

                foreach (var value in resolvedValues)
                {
                    if (value is not Element element)
                    {
                        continue;
                    }

                    indexValue.Values.AddRange(_elementIndexer.Map(element));
                }

                if (indexValue.Values.Any())
                {
                    rootIndexValue.Values.Add(indexValue);
                }
            }

            if (resource is DomainResource domainResource)
            {
                AddContainedResources(domainResource, rootIndexValue);
            }

            return(rootIndexValue);
        }