예제 #1
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();
                textboxResult.AppendText(String.Join("\r\n--------------------\r\n", parseErrors2, parseErrors3, parseErrors4));
            }

            if (inputNavR4 != null)
            {
                labelR4.Visibility = Visibility.Visible;
            }
            else
            {
                labelR4.Visibility = Visibility.Collapsed;
            }
            if (inputNavSTU3 != null)
            {
                labelSTU3.Visibility = Visibility.Visible;
            }
            else
            {
                labelSTU3.Visibility = Visibility.Collapsed;
            }

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

            if (inputNavR4 != null)
            {
                evalContext = new fp4.FhirEvaluationContext(inputNavR4);
                return(inputNavSTU3);
            }
            if (inputNavSTU3 != null)
            {
                evalContext = new fp3.FhirEvaluationContext(inputNavSTU3);
                return(inputNavSTU3);
            }
            evalContext = new fp2.FhirEvaluationContext(inputNavDSTU2);
            return(inputNavDSTU2);
        }
예제 #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);
        }