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

feature request: async support for FhirPath resolve() #3016

Open
darena-antonw opened this issue Jan 16, 2025 · 0 comments
Open

feature request: async support for FhirPath resolve() #3016

darena-antonw opened this issue Jan 16, 2025 · 0 comments

Comments

@darena-antonw
Copy link

Is your feature request related to a problem? Please describe.

I would like the fhir path evaluation to resolve elements from a database / http call.

This is currently possible with: FhirEvaluationContext.ElementResolver

However the caveat is that I would have to introduce blocking in to my application, as the delegate can not be async.

Describe the solution you'd like

  • new property AsyncElementResolver on FhirEvaluationContext of type Func<string,Task<ITypedElement>>
  • new method Compile(string fhirPath, bool async) that evaluates to CompiledAsyncExpression
  • new delegate type public delegate Task<IEnumerable<ITypedElement>> CompiledAsyncExpression(ITypedElement root, EvaluationContext ctx);

so in the end I can do the following:

var expression = compiler.Compile("entry.resource.ofType(MedicationRequest).medication.resolve().id", true);
var result = await expression(
    bundle,
    new FhirEvaluationContext
    {
        AsyncElementResolver = async (id) =>
        {
            // call to db or http
            return ...
        }
    }
);

Describe alternatives you've considered

it's possible with blocking via .GetAwaiter().GetResult()

Additional context

this was discovered during connectathon cds hooks testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant