public void TestWriteSimpleExtendedFilter()
        {
            QueryFilterExtensions.AddExtendedFilter(new SimpleQueryExtension());
            var query      = QueryExpressionBuilder.BuildQuery <Patient>(o => o.Identifiers.Any(i => i.Value.TestExpression() <= 2));
            var expression = CreateQueryString(query.ToArray());

            Assert.AreEqual("identifier.value=%3A%28test%29%3C%3D2", expression);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Static CTOR
 /// </summary>
 static BaseRecordMatchingService()
 {
     foreach (var t in typeof(BaseRecordMatchingService).Assembly.ExportedTypes.Where(t => typeof(IQueryFilterExtension).IsAssignableFrom(t) && !t.IsAbstract))
     {
         QueryFilterExtensions.AddExtendedFilter(Activator.CreateInstance(t) as IQueryFilterExtension);
     }
     ModelSerializationBinder.RegisterModelType(typeof(MatchConfiguration));
 }
Ejemplo n.º 3
0
        public void TestAgeFilter()
        {
            QueryFilterExtensions.AddExtendedFilter(new AgeQueryFilterExtension());
            var filterQuery = NameValueCollection.ParseQueryString("dateOfBirth=:(age)<P3Y");
            var expr        = QueryExpressionParser.BuildLinqExpression <Patient>(filterQuery);

            Assert.IsTrue(expr.ToString().Contains("Age"));
        }
        public void TestWriteSelfParameterRef()
        {
            QueryFilterExtensions.AddExtendedFilter(new SimpleQueryExtensionEx());
            DateTime other      = DateTime.Parse("1980-01-01");
            TimeSpan myTime     = new TimeSpan(1, 0, 0, 0);
            var      query      = QueryExpressionBuilder.BuildQuery <Patient>(o => o.DateOfBirth.Value.TestExpressionEx(o.CreationTime.DateTime) < myTime);
            var      expression = CreateQueryString(query.ToArray());

            Assert.AreEqual("dateOfBirth=%3A%28testEx%7C%22%24_.creationTime%22%29%3C1.00%3A00%3A00", expression);
        }
Ejemplo n.º 5
0
        public void TestExtendedQueryFilterWithParameterVariableCrossReference()
        {
            var expected = "o => ((o.DateOfBirth != null) AndAlso (o.DateOfBirth.Value.TestExpressionEx((Invoke(__xinstance => (((__xinstance.Relationships.Where(guard => ((guard.LoadProperty(\"RelationshipType\") ?? new Concept()).Mnemonic == \"Mother\")).FirstOrDefault() ?? new EntityRelationship()).TargetEntity As Patient) ?? new Patient()).DateOfBirth, o) ?? default(DateTime))) > 7305.00:00:00))";

            QueryFilterExtensions.AddExtendedFilter(new SimpleQueryExtensionEx());
            NameValueCollection httpQueryParameters = new NameValueCollection();

            httpQueryParameters.Add("dateOfBirth", ":(testEx|$_.relationship[Mother][email protected])>20y");
            var expr = QueryExpressionParser.BuildLinqExpression <Patient>(httpQueryParameters);

            Assert.AreEqual(expected, expr.ToString());
        }
Ejemplo n.º 6
0
        public void TestExtendedQueryFilterWithParameterParse()
        {
            var expected = "o => ((o.DateOfBirth != null) AndAlso (o.DateOfBirth.Value.TestExpressionEx(2018-01-01 12:00:00 AM) > 7305.00:00:00))";

            QueryFilterExtensions.AddExtendedFilter(new SimpleQueryExtensionEx());
            NameValueCollection httpQueryParameters = new NameValueCollection();

            httpQueryParameters.Add("dateOfBirth", ":(testEx|2018-01-01)>20y");
            var expr = QueryExpressionParser.BuildLinqExpression <Patient>(httpQueryParameters);

            Assert.AreEqual(expected, expr.ToString());
        }
Ejemplo n.º 7
0
        public void TestExtendedQueryFilterParseBool()
        {
            var expected = "o => o.Names.Any(name => name.Component.Where(guard => ((guard.ComponentType ?? new Concept()).Mnemonic == \"OfficialRecord\")).Any(component => (component.Value.BoolTest() == True)))";

            QueryFilterExtensions.AddExtendedFilter(new BoolQueryExtension());
            NameValueCollection httpQueryParameters = new NameValueCollection();

            httpQueryParameters.Add("name.component[OfficialRecord].value", ":(testBool)");
            var expr = QueryExpressionParser.BuildLinqExpression <Patient>(httpQueryParameters);

            Assert.AreEqual(expected, expr.ToString());
        }
Ejemplo n.º 8
0
        public void TestExtendedQueryFilterWithParameterVariableParse()
        {
            var expected = "o => ((o.DateOfBirth != null) AndAlso (o.DateOfBirth.Value.TestExpressionEx(Convert(Convert(value(SanteDB.Messaging.HDSI.Test.QueryParameterLinqBuilderTest+<>c).<TestExtendedQueryFilterWithParameterVariableParse>b__18_0()))) > 7305.00:00:00))";

            QueryFilterExtensions.AddExtendedFilter(new SimpleQueryExtensionEx());
            NameValueCollection httpQueryParameters = new NameValueCollection();

            httpQueryParameters.Add("dateOfBirth", ":(testEx|$dateOfBirth)>20y");
            var expr = QueryExpressionParser.BuildLinqExpression <Patient>(httpQueryParameters, new System.Collections.Generic.Dictionary <string, Func <Object> >()
            {
                { "dateOfBirth", () => DateTime.Parse("2018-01-01") }
            });

            Assert.AreEqual(expected, expr.ToString());
        }
Ejemplo n.º 9
0
        public void TestExtendedQueryFilterWithParameterVariableComplexPathParse()
        {
            var expected = "((o.DateOfBirth != null) AndAlso (o.DateOfBirth.Value.TestExpressionEx((Invoke(__xinstance => (((__xinstance.Relationships.Where(guard => ((guard.LoadProperty(\"RelationshipType\") ?? new Concept()).Mnemonic == \"Mother\")).FirstOrDefault() ?? new EntityRelationship()).TargetEntity As Patient) ?? new Patient()).DateOfBirth, Convert(value(SanteDB.Messaging.HDSI.Test.QueryParameterLinqBuilderTest+<>c).<TestExtendedQueryFilterWithParameterVariableComplexPathParse>b__20_0())) ?? default(DateTime))) > 730.12:00:00))";

            QueryFilterExtensions.AddExtendedFilter(new SimpleQueryExtensionEx());
            NameValueCollection httpQueryParameters = new NameValueCollection();

            httpQueryParameters.Add("dateOfBirth", ":(testEx|$input.relationship[Mother][email protected])>2y");
            var expr = QueryExpressionParser.BuildLinqExpression <Patient>(httpQueryParameters, new System.Collections.Generic.Dictionary <string, Func <Object> >()
            {
                { "input", () => new Patient()
                  {
                      DateOfBirth = DateTime.Parse("2018-01-01")
                  } }
            });

            Assert.AreEqual(expected, expr.ToString());
        }