6

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.

ncesar
  • 1,592
  • 2
  • 15
  • 34

2 Answers2

7

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
...
Noel Victorino
  • 355
  • 3
  • 7
  • thanks man, I'm not working with FHIR anymore but this can be helpful to others :) – ncesar Mar 26 '21 at 19:48
  • @noelvictorino I am using docker run the fhir server in local using following command: `docker run -p 8080:8080 -e hapi.fhir.subscription.resthook_enabled=true hapiproject/hapi:latest` This should have set resthook_enabled=true but the subscription resource is still not triggering to the endpoint. Could you please let me know how you deployed the fhir server locally? – nirojshrestha019 Sep 02 '21 at 17:25
  • @nirojshrestha019 I managed to run it locally using `docker-compose.yml` – Noel Victorino Sep 04 '21 at 13:03
2

In response to @nirojshrestha019, I managed to run it locally via docker compose in version v.2.0.0-rc.1.

docker-compose.yml

version: "3.9"
services:
  hapi-fhir:
    image: hapiproject/hapi:v5.2.1
    ports:
      - target: 8080
        published: 8080
        x-aws-protocol: http
    env_file:
      - .env.dev
    environment:
      profiles.active: r4
      spring.datasource.driverClassName: org.postgresql.Driver
    deploy:
      x-aws-autoscaling:
        min: 1
        max: 10 # required
        cpu: 75
      resources:
        limits:
          cpus: '2'
          memory: 4Gb
## Uncomment these lines when working on development environment
#     depends_on:
#       - db
#   db:
#     image: postgres:13.2-alpine
#     env_file:
#       - .env.dev
#     volumes:
#       - db:/var/lib/postgresql/data
#     ports:
#       - 5432:5432
# volumes:
#   db:

.env.dev

POSTGRES_PASSWORD
POSTGRES_USER=
POSTGRES_DB=
POSTGRES_PORT=
POSTGRES_HOST=
SPRING_DATASOURCE_URL=jdbc:postgresql://${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}
SPRING_DATASOURCE_USERNAME=${POSTGRES_USER}
SPRING_DATASOURCE_PASSWORD=${POSTGRES_PASSWORD}
HAPI_FHIR_SERVER_ADDRESS=
HAPI_FHIR_TESTER_HOME_SERVER_ADDRESS=
HAPI_FHIR_SUBSCRIPTION_RESTHOOK_ENABLED=
HAPI_FHIR_CORS_ALLOWED_ORIGIN=
Noel Victorino
  • 355
  • 3
  • 7