FirelyTeam / firely-net-sdk

The official Firely .NET SDK for HL7 FHIR
Other
829 stars 345 forks source link

FHIR path evaluation fails when expression contains %resource #664

Closed jackliums closed 6 years ago

jackliums commented 6 years ago

The FHIR path evaluation does not seem to work with %resource reference in the expression.

For example, the expression of the "coordinate" search parameter of the Sequence resource is defined as "Sequence.variant", which will be evaluated to the VariantComponent. The expression of the first component is defined as "%resource.referenceSeq.chromosome", so given the VariantComponent of the Sequence with that expression, I expect it to evaluate successfully by traversing back to the parent Sequence resource and retrieve the ReferenceSeqComponent.Chromosome property.

However, it fails with:

InvalidOperationException: Invocation of 'builtin.children' failed: Invocation of 'builtin.children' failed: Value cannot be null. Parameter name: source
Hl7.FhirPath.Expressions.InvokeeFactory+<>c__DisplayClass13_0.<Invoke>b__0(Closure ctx, IEnumerable<Invokee> _)
Hl7.Fhir.FhirPath.ElementNavFhirExtensions.Select(Base input, string expression, FhirEvaluationContext ctx)

This repros with the latest 0.96.0 release.

brianpos commented 6 years ago

Can you please include your call to the evaluator? Are you providing the expression and context?

jackliums commented 6 years ago

Once I created the FhirEvaluationContext using the root resource and passed that context to the Select method, it evaluated the expression correctly. Thanks!