Stream: hapi
Topic: FHIR R4 Patient Creation in CDR
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
Farrukh Najmi (Mar 08 2022 at 16:09):
The solution that worked for @Atul Prakash Singh and I was as follows:
- Implement an interceptor class (we called it FHIRVersion4HeaderInterceptor) as an implementation of IClientInterceptor
- Override the interceptRequest method as follows:
- Add annotation: @Hook(Pointcut.CLIENT_REQUEST)
- Remove the Accept and Content-Type headers using request.removeHeaders() calls
- Add the replacement Accept and Content-Type headers using request.addHeader() calls
- Register the new FHIRVersion4HeaderInterceptor interceptor with the client using IGenericClient.registerInterceptor()
Last updated: Apr 12 2022 at 19:14 UTC