Search code examples
subscriptionhl7-fhirhapi-fhir

FHIR Subscription not working in hapi-fhir


I'm using this hapi-fhir v4.2.0 server with jpa and it's working just fine. I have added a few patients and I'm able to GET/POST requests to my hapi-fhir localhost environment.

I'm also able to create a subscription using this URL: http://localhost:8080/hapi-fhir-jpaserver/fhir/Subscription with this body:

{
  "resourceType": "Subscription",
  "criteria": "Patient",
  "reason": "Give me the patient",
  "end": "2021-01-01T00:00:00Z",
  "status": "requested",
  "channel": {
    "type": "rest-hook",
    "endpoint": "http://localhost:1337",
    "payload": "application/json"
  }
}

Whenever I made a POST or PUT to a Patient, the subscription should be triggered and send a POST request to http://localhost:1337 but nothing happens.

What I have tried:

  1. Changing requested to active
  2. Changing criteria from Patient to Patient?name=John
  3. Removing payload argument
  4. Reading the documentation
  5. Changing to application/fhir+json

And still not working :( what I'm missing here guys?

Edit: My backend is a simple nodejs running with morgan, so it will log every POST/GET/PUT attempt in the console.


Solution

  • I also experienced the same thing. But, I managed to solve it.

    We need to turn on the subscription rest webhook at hapi.properties file.

    ...
    ##################################################
    # Subscriptions
    ##################################################
    
    # Enable REST Hook Subscription Channel
    subscription.resthook.enabled=true
    ...
    

    If you are now using the latest version, v5.3.0, it is in application.yaml.

    ...
        subscription:
          resthook_enabled: true
    ...