Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

%resource and %rootResource in default context #2841

Merged
merged 11 commits into from
Sep 4, 2024
Merged
4 changes: 2 additions & 2 deletions src/Hl7.Fhir.Base/FhirPath/Expressions/Closure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public static Closure Root(ITypedElement root, EvaluationContext ctx = null)
newContext.SetIndex(ElementNode.CreateList(0));
newContext.SetOriginalContext(input);

if (ctx.Resource != null) newContext.SetResource(new[] { ctx.Resource });
if (ctx.RootResource != null) newContext.SetRootResource(new[] { ctx.RootResource });
if (ctx?.Resource != null) newContext.SetResource(new[] { ctx.Resource });
if (ctx?.RootResource != null) newContext.SetRootResource(new[] { ctx.RootResource });

return newContext;
}
Expand Down
10 changes: 5 additions & 5 deletions src/Hl7.Fhir.Shims.STU3AndUp/FhirPath/FhirPathExtensions.cs
ewoutkramer marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,23 @@ public static class FhirPathExtensions

/// <inheritdoc cref="FhirPathCompilerCache.Select(ITypedElement, string, EvaluationContext?)"/>
public static IEnumerable<Base?> Select(this Base input, string expression, FhirEvaluationContext? ctx = null)
=> CACHE.Select(input.ToTypedElement(), expression, ctx ?? FhirEvaluationContext.CreateDefault()).ToFhirValues();
=> CACHE.Select(input.ToTypedElement(), expression, ctx ?? new FhirEvaluationContext(input.ToTypedElement())).ToFhirValues();
ewoutkramer marked this conversation as resolved.
Show resolved Hide resolved

/// <inheritdoc cref="FhirPathCompilerCache.Scalar(ITypedElement, string, EvaluationContext?)"/>
public static object? Scalar(this Base input, string expression, FhirEvaluationContext? ctx = null)
=> CACHE.Scalar(input.ToTypedElement(), expression, ctx ?? FhirEvaluationContext.CreateDefault());
=> CACHE.Scalar(input.ToTypedElement(), expression, ctx ?? new FhirEvaluationContext(input.ToTypedElement()));

/// <inheritdoc cref="FhirPathCompilerCache.Predicate(ITypedElement, string, EvaluationContext?)"/>
public static bool Predicate(this Base input, string expression, FhirEvaluationContext? ctx = null)
=> CACHE.Predicate(input.ToTypedElement(), expression, ctx ?? FhirEvaluationContext.CreateDefault());
=> CACHE.Predicate(input.ToTypedElement(), expression, ctx ?? new FhirEvaluationContext(input.ToTypedElement()));

/// <inheritdoc cref="FhirPathCompilerCache.IsTrue(ITypedElement, string, EvaluationContext?)"/>
public static bool IsTrue(this Base input, string expression, FhirEvaluationContext? ctx = null)
=> CACHE.IsTrue(input.ToTypedElement(), expression, ctx ?? FhirEvaluationContext.CreateDefault());
=> CACHE.IsTrue(input.ToTypedElement(), expression, ctx ?? new FhirEvaluationContext(input.ToTypedElement()));

/// <inheritdoc cref="FhirPathCompilerCache.IsBoolean(ITypedElement, string, bool, EvaluationContext?) "/>
public static bool IsBoolean(this Base input, string expression, bool value, FhirEvaluationContext? ctx = null)
=> CACHE.IsBoolean(input.ToTypedElement(), expression, value, ctx ?? FhirEvaluationContext.CreateDefault());
=> CACHE.IsBoolean(input.ToTypedElement(), expression, value, ctx ?? new FhirEvaluationContext(input.ToTypedElement()));
}
}

Expand Down