FHIR Chat · HttpClient based FhirClient · dotnet

Stream: dotnet

Topic: HttpClient based FhirClient


view this post on Zulip Brian Postlethwaite (Jul 06 2020 at 09:07):

We're working on the updated FhirClient that uses HttpClient underneath, which means that the OnBeforeEvent and OnAfterEvents need to be replaced.
How do others feel about code along the lines of this:

var handler = new AuthorizationMessageHandler();
handler.Authorization = new AuthenticationHeaderValue("Bearer", bearerToken);
var server = new HttpFhirClient(handler);

And this class could be something as simple as this:

public class AuthorizationMessageHandler : HttpClientHandler
{
    public System.Net.Http.Headers.AuthenticationHeaderValue Authorization { get; set; }
    protected async override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
    {
        if (Authorization != null)
            request.Headers.Authorization = Authorization;
        return await base.SendAsync(request, cancellationToken);
    }
}

view this post on Zulip Brian Postlethwaite (Jul 06 2020 at 09:10):

If you need to look at the raw response before the FHIR client processes it, you could do something similar to the above, but process the content returned from the base.SendAsync before returning from the handler

view this post on Zulip Sandhya (Jul 07 2020 at 16:01):

Curious did anyone implemented USCore compatibility validation in their application. Did you use Firely Nuget package?

view this post on Zulip Jeremy Chapman (Jul 08 2020 at 20:29):

would it be useful to provide a default handler so it doesn't need to be implemented in all solutions, but could be if neessary?

view this post on Zulip Brian Postlethwaite (Aug 31 2020 at 01:00):

This is the super simple version, but more likely you'll want to get the auth token from somewhere, and handle when it needs to be refreshed, and when you get 401s etc.

view this post on Zulip Brian Postlethwaite (Sep 17 2020 at 22:17):

I've done a quick fake fhir client that roughly emulates the FhirClient but using the HttpClient under the hood
https://www.nuget.org/packages/brianpos.Fhir.R4.httpclient
Reason I did it was in Azure function apps under high load the existing client will consume all sockets and start causing failures.
In other projects I just went back to raw doing it, but thought was time to at least do some effort.
May only be usefull till the v2 fhirclient comes out of alpha and into the sunlight :grinning:

view this post on Zulip Ewout Kramer (Sep 21 2020 at 18:36):

The 2.0 .NET API beta2 is nearly there - we're publishing it this week!

view this post on Zulip Brian Postlethwaite (Sep 22 2020 at 07:32):

Awesome!

view this post on Zulip Brian Postlethwaite (Sep 22 2020 at 07:32):

Mine was only to get over a prod hurdle.

view this post on Zulip Brian Postlethwaite (Sep 22 2020 at 07:33):

And for those who want 1.9.0 compatibility

view this post on Zulip Marco Visser (Sep 22 2020 at 14:10):

The 2.0 .NET API beta2 is now released. See https://github.com/FirelyTeam/fhir-net-api/releases for source code and for the NuGet Packages: https://www.nuget.org/packages?q=hl7.fhir


Last updated: Apr 12 2022 at 19:14 UTC