Пример #1
0
        private void ButtonPredicate_Click(object sender, RoutedEventArgs e)
        {
            var inputNav = GetResourceNavigator();

            if (inputNav == null)
            {
                return;
            }

            // Don't need to cache this, it is cached in the fhir-client
            Hl7.FhirPath.CompiledExpression xps = null;
            try
            {
                xps = _compiler.Compile(textboxExpression.Text);
            }
            catch (Exception ex)
            {
                SetResults("Expression compilation error:\r\n" + ex.Message);
                return;
            }

            if (xps != null)
            {
                try
                {
                    bool result;
                    if (inputNav is stu3.Hl7.Fhir.ElementModel.PocoNavigator)
                    {
                        result = xps.Predicate(inputNav, new fp3.FhirEvaluationContext(inputNav));
                    }
                    else
                    {
                        result = xps.Predicate(inputNav, new fp2.FhirEvaluationContext(inputNav));
                    }
                    SetResults(result.ToString());
                }
                catch (Exception ex)
                {
                    SetResults("Expression evaluation error:\r\n" + ex.Message);
                    return;
                }
            }

            AppendParseTree();
        }
Пример #2
0
        private static CompiledExpression Compile(string expression)
        {
            var compiler = new FhirPathCompiler();

            return(compiler.Compile(expression));
        }