Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Custom Operations : How-To-Code against ca.uhn.fhir.rest.client.api IGenericClient

18 views
Skip to first unread message

granada Coder

unread,
Apr 21, 2025, 1:38:53 PMApr 21
to HAPI FHIR
I've used the

ca.uhn.fhir.rest.client.api

IGenericClient

(and its concrete)

for many years.. for the "well known" FHIR operations like

    read
    vread
    search
    update
    create


https://hapifhir.io/hapi-fhir/apidocs/hapi-fhir-base/ca/uhn/fhir/rest/client/api/IGenericClient.html

https://hapifhir.io/hapi-fhir/docs/client/examples.html


Primary Question:

*Is there any examples of how to code against the hapi-fhir client libraries.. for custom methods/operations.*

...

for example, a well known custom operation like

URL: [base]/Patient/$match

https://hl7.org/fhir/R4/patient-operation-match.html

which is a 'form of a' search operation.



    example REQUEST
   
   
    POST /open/Patient/$match
    [some headers]
   
    {
      "resourceType": "Parameters",
      "id": "example",
      "parameter": [
        {
          "name": "resource",
          "resource": {
            "resourceType": "Patient",
            "identifier": [
              {
                "use": "usual",
                "type": {
                  "coding": [
                    {
                      "system": "http://hl7.org/fhir/v2/0203",
                      "code": "MR"
                    }
                  ]
                },
                "system": "urn:oid:1.2.36.146.595.217.0.1",
                "value": "12345"
              }
            ],



and

https://hl7.org/fhir/us/davinci-hrex/2020Sep/Parameters-member-match-in.json.html

POST {{fhirurl}}/Patient/$member-match

example REQUEST:

    {
      "resourceType" : "Parameters",
      "id" : "member-match-in",
      "parameter" : [
        {
          "name" : "MemberPatient",
          "resource" : {
            "resourceType" : "Patient",
            "id" : "1",
            "identifier" : [
              {


The thing here is that while the methods are defined against the "Patient" FHIR resource... the "input" is an array of "Parameters" objects.


But just for some variation:


https://www.hl7.org/fhir/activitydefinition-operation-apply.html


URL: [base]/**ActivityDefinition**/$apply

URL: [base]/**ActivityDefinition**/[id]/$apply


this is a GET that returns a

    <MedicationRequest xmlns="http://hl7.org/fhir">




Aka, the FHIR-Resource that is a part of the request ("ActivityDefinition") in the above... the return type is not a single or bundle of ActivityDefinition(s), but a MedicationRequest.


Despite all the specific examples... the crux of the question is .. how would one .. .code a custom operation .. against or extending IGenericClient (?)



James Agnew

unread,
Apr 21, 2025, 1:40:46 PMApr 21
to granada Coder, HAPI FHIR
Here's an example which includes a custom operation being called: https://hapifhir.io/hapi-fhir/docs/client/examples.html#create-composition-and-generate-document

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 view this discussion visit https://groups.google.com/d/msgid/hapi-fhir/b267d5fe-ed8f-40eb-a8b9-77bb9e63e9cbn%40googlegroups.com.

granada Coder

unread,
Apr 21, 2025, 2:19:45 PMApr 21
to HAPI FHIR
Eagle Eye James!

https://hapifhir.io/hapi-fhir/apidocs/hapi-fhir-base/ca/uhn/fhir/rest/client/api/IGenericClient.html#operation()

I see what was right in front of my face... "operation".  Thanks for the quick feedback and link to an example.

Long Live Code Monk.

Reply all
Reply to author
Forward
0 new messages