Extended Operation with Resource Parameter

387 views
Skip to first unread message

andrewmic...@gmail.com

unread,
Mar 9, 2016, 1:01:41 PM3/9/16
to HAPI FHIR
Is there documentation of how to create an extended operation that uses a resource parameter?  Does anyone have a working example?  It looks like there are only extended operations with simple parameters here:

I've tried a bunch of different things on the server side and on the client, but I haven't gotten it to work yet.  Currently my Location resource provider has this method:

@Operation(name="$match")
public Bundle match(final @OperationParam(name="input") Location toFind) {


I've been using an identical annotation-driven client interface.  I've tried invoking it like this:

LocationClient client = ctx.newRestfulClient(LocationClient.class, url);
Location loc = new Location();
loc
.setName("Sample Clinic");
run
(client.match(loc));


ca.uhn.fhir.rest.server.exceptions.InvalidRequestException: HTTP 400 Bad Request: Invalid request: The FHIR endpoint on this server does not know how to handle POST operation[$match] with parameters [[]]

Am I don't something wrong on the server side or the client side (or both)?

andrewmic...@gmail.com

unread,
Mar 9, 2016, 2:03:05 PM3/9/16
to HAPI FHIR, andrewmic...@gmail.com
I changed the client to use the fluent API, and it worked:

final IGenericClient client = ctx.newRestfulGenericClient(url);
final Parameters parms = new Parameters();
final Parameter parm = parms.addParameter();
parm
.setName("input");
parm
.setResource(loc);
for (final Parameter p : client.operation().onType(Location.class).named("$match").withParameters(parms).execute().getParameter()) {

James Agnew

unread,
Mar 12, 2016, 3:11:55 PM3/12/16
to andrewmic...@gmail.com, HAPI FHIR
Hi there,

Glad you found a workaround. I just tried to reproduce and it looks like this was a bug with the annotation based client, where it was not able to handle operations that return a raw resource (e.g. Bundle) instead of a Parameters resource. I've just checked in a fix to correct that.

Cheers,
James

--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.
To post to this group, send email to hapi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hapi-fhir/549139cb-2a0e-4f4a-9f34-ee4c21639b8c%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages