Esempio n. 1
0
        public MainPage()
        {
            this.InitializeComponent();

            TextControlFontSize    = 22;
            textboxInputXML.Text   = "<Patient xmlns=\"http://hl7.org/fhir\">\r\n  <name>\r\n    <given value=\"brian\"/>\r\n  </name>\r\n  <birthDate value=\"1980\"/>\r\n</Patient>";
            textboxExpression.Text = "birthDate < today()";
            DataContext            = this;

            // and remember the initial state
            AddHistoryEntry(textboxInputXML.Text, textboxExpression.Text);
            System.Threading.Tasks.Task.Run(() => {
                // in the background load up the 3 sets of ClassLibraries
                r4.Hl7.Fhir.Serialization.BaseFhirParser.Inspector.Import(typeof(r4.Hl7.Fhir.Serialization.BaseFhirParser).Assembly);
                // stu3.Hl7.Fhir.Serialization.BaseFhirParser.Inspector.Import(typeof(stu3.Hl7.Fhir.Serialization.BaseFhirParser).Assembly);
                dstu2.Hl7.Fhir.Serialization.BaseFhirParser.Inspector.Import(typeof(dstu2.Hl7.Fhir.Serialization.BaseFhirParser).Assembly);
                FhirPathProcessor.GetResourceNavigatorSTU3("<Patient xmlns=\"http://hl7.org/fhir\"/>", out var errs);
            });
        }
Esempio n. 2
0
        private ITypedElement GetResourceNavigator(out EvaluationContext evalContext)
        {
            string parseErrors2;
            var    inputNavDSTU2 = FhirPathProcessor.GetResourceNavigatorDSTU2(textboxInputXML.Text, out parseErrors2);
            string parseErrors3;
            var    inputNavSTU3 = FhirPathProcessor.GetResourceNavigatorSTU3(textboxInputXML.Text, out parseErrors3);
            string parseErrors4;
            var    inputNavR4 = FhirPathProcessor.GetResourceNavigatorR4(textboxInputXML.Text, out parseErrors4);

            if (!string.IsNullOrEmpty(parseErrors2) || !string.IsNullOrEmpty(parseErrors3) || !string.IsNullOrEmpty(parseErrors4))
            {
                ResetResults();
                AppendResults(String.Join("\r\n--------------------\r\n", parseErrors2, parseErrors3, parseErrors4), true);
            }
            if (inputNavR4 != null || inputNavSTU3 != null || inputNavDSTU2 != null)
            {
                ISourceNode node;
                if (textboxInputXML.Text.StartsWith("{"))
                {
                    node = Hl7.Fhir.Serialization.FhirJsonNode.Parse(textboxInputXML.Text);
                }
                else
                {
                    node = Hl7.Fhir.Serialization.FhirXmlNode.Parse(textboxInputXML.Text);
                }
                _locations.Clear();
                int           lastPos  = 0;
                IPositionInfo lastNode = null;
                AddLocations(node, ref lastNode, ref lastPos, textboxInputXML.Text.ToCharArray());
                string t = _locations.LastOrDefault(c => c.Key < textboxInputXML.SelectionStart).Value;
                System.Diagnostics.Trace.WriteLine($"Focused: {t}");
            }

            if (inputNavR4 != null)
            {
                btnR4.Visibility = Visibility.Visible;
            }
            else
            {
                btnR4.Visibility = Visibility.Collapsed;
            }

            if (inputNavSTU3 != null)
            {
                btnSTU3.Visibility = Visibility.Visible;
            }
            else
            {
                btnSTU3.Visibility = Visibility.Collapsed;
            }

            if (inputNavDSTU2 != null)
            {
                btnDSTU2.Visibility = Visibility.Visible;
            }
            else
            {
                btnDSTU2.Visibility = Visibility.Collapsed;
            }

            if (inputNavR4 != null)
            {
                evalContext = new fp4.FhirEvaluationContext(inputNavR4);
                return(inputNavR4);
            }
            if (inputNavSTU3 != null)
            {
                evalContext = new fp3.FhirEvaluationContext(inputNavSTU3);
                return(inputNavSTU3);
            }
            evalContext = new fp2.FhirEvaluationContext(inputNavDSTU2);
            return(inputNavDSTU2);
        }