FHIR Chat · FHIR R4 Patient Creation in CDR · hapi

Stream: hapi

Topic: FHIR R4 Patient Creation in CDR


view this post on Zulip Atul Prakash Singh (Mar 08 2022 at 11:00):

@Lloyd McKenzie and colleagues,

I am facing some issue using FHIR Client v5.7.0 for Kotlin with creation of new Patients in CDR R4 org. I am defining additional headers for Content-Type and Accept as application/fhir+json;fhirVersion=4.0, but seems FHIR library is also sending these below headers along with that:

Content-Type: application/fhir+json; charset=UTF-8
Accept: application/fhir+json;q=1.0, application/json+fhir;q=0.9.

Can you suggest some method so that I can replace library headers with my custom ones marked in bold text. Thanks!

cc: @Farrukh Najmi

view this post on Zulip Farrukh Najmi (Mar 08 2022 at 16:09):

The solution that worked for @Atul Prakash Singh and I was as follows:

  1. Implement an interceptor class (we called it FHIRVersion4HeaderInterceptor) as an implementation of IClientInterceptor
  2. Override the interceptRequest method as follows:
    1. Add annotation: @Hook(Pointcut.CLIENT_REQUEST)
    2. Remove the Accept and Content-Type headers using request.removeHeaders() calls
    3. Add the replacement Accept and Content-Type headers using request.addHeader() calls
  3. Register the new FHIRVersion4HeaderInterceptor interceptor with the client using IGenericClient.registerInterceptor()

Last updated: Apr 12 2022 at 19:14 UTC