Beispiel #1
0
        public void TestVisitOnePathZeroMatch()
        {
            var sut = new ElementQuery("Patient.name");

            var testPatient = new Patient();
            var result      = new List <object>();

            sut.Visit(testPatient, fd => result.Add(fd));

            Assert.Equal(testPatient.Name.Count, result.Where(ob => ob != null).Count());
        }
Beispiel #2
0
        public void TestVisitOnePathOneMatch()
        {
            var sut = new ElementQuery("Patient.name");

            var testPatient = new Patient();
            var hn          = new HumanName().WithGiven("Sjors").AndFamily("Jansen");

            testPatient.Name = new List <HumanName> {
                hn
            };

            var result = new List <object>();

            sut.Visit(testPatient, fd => result.Add(fd));

            Assert.Equal(testPatient.Name.Count, result.Count(ob => ob != null));
            Assert.Contains(hn, result);
        }
Beispiel #3
0
        public static IEnumerable <Uri> GetReferences(this Resource resource, string include)
        {
            ElementQuery query = new ElementQuery(include);
            var          list  = new List <Uri>();

            query.Visit(resource, element =>
            {
                if (element is ResourceReference)
                {
                    Uri uri = (element as ResourceReference).Url;
                    if (uri != null)
                    {
                        list.Add(uri);
                    }
                }
            });
            return(list.Where(u => u != null));
        }
Beispiel #4
0
        public void TestVisitOnePathTwoMatches()
        {
            var sut = new ElementQuery("Patient.name");

            var testPatient = new Patient();
            var hn1         = new HumanName().WithGiven("A").AndFamily("B");
            var hn2         = new HumanName().WithGiven("Y").AndFamily("Z");

            testPatient.Name = new List <HumanName> {
                hn1, hn2
            };

            var result = new List <object>();

            sut.Visit(testPatient, fd => result.Add(fd));

            Assert.Equal(testPatient.Name.Count, result.Where(ob => ob != null).Count());
            Assert.Contains(hn1, result);
            Assert.Contains(hn2, result);
        }
        public static IEnumerable <string> GetReferences(this Resource resource, string path)
        {
            if (!isValidResourcePath(path, resource))
            {
                return(Enumerable.Empty <string>());
            }

            ElementQuery query = new ElementQuery(path);
            var          list  = new List <string>();

            query.Visit(resource, element =>
            {
                if (element is ResourceReference)
                {
                    string reference = (element as ResourceReference).Reference;
                    if (reference != null)
                    {
                        list.Add(reference);
                    }
                }
            });
            return(list);
        }
Beispiel #6
0
        public static IEnumerable<string> GetReferences(this Resource resource, string path)
        {
            if (!isValidResourcePath(path, resource)) return Enumerable.Empty<string>();

            ElementQuery query = new ElementQuery(path);
            var list = new List<string>();

            query.Visit(resource, element =>
                {
                    if (element is ResourceReference)
                    {
                        string reference = (element as ResourceReference).Reference;
                        if (reference != null)
                        {
                            list.Add(reference);
                        }
                    }
                });
            return list;
        }