Stream: hapi
Topic: How to Invoke Operation using HAPI Java Library
Jake Zhou (Jan 11 2022 at 16:02):
Hello,
We're trying to use the Java HAPI FHIR Library for one of our projects and we're having some questions on how to create a request to an endpoint with an operation.
The library we're using is hapi-fhir-base-4.2.0, and the IGenericClient.java class we're using is at package ca.uhn.fhir.rest.client.api
The docs for using operations on this library is at: https://hapifhir.io/hapi-fhir/docs/client/generic_client.html#extended-operations, but there are no examples of using this against a type instead of an instance
Here is the code we have that's generating a 400 code
Screen-Shot-2022-01-06-at-10.43.41-AM.png
Screen-Shot-2022-01-11-at-11.02.26-AM.png
Jake Zhou (Jan 11 2022 at 16:03):
We're using this code for the Patient Request for Correction track with @Virginia Lorenzi and @David Hay
Jake Zhou (Jan 11 2022 at 16:31):
Here is the latest code we have trying to send the request to the testing server:
var inParams = new Parameters();
inParams.addParameter()
.setName("CorrectionRequest")
.setResource(bundle);
var remoteClient = FhirR4Config.getFhirContext().newRestfulGenericClient(endpoint.getAddress());
var result = remoteClient
.operation()
.onType(Communication.class)
.named("$correctionrequest")
.withParameters(inParams)
.execute();
Jake Zhou (Jan 11 2022 at 20:24):
We were able to resolve the issue. I've attached the final code below. We discovered some detail about processing the Parameter on the server side
var inParams = new Parameters();
inParams.addParameter()
.setName("CorrectionRequest")
.setResource(bundle);
var remoteClient = FhirR4Config.getFhirContext().newRestfulGenericClient(endpoint.getAddress());
var result = remoteClient
.operation()
.onType(Communication.class)
.named("$correctionrequest")
.withParameters(inParams)
.execute();
Last updated: Apr 12 2022 at 19:14 UTC