Types
Subscription

Subscription Zambdas

Subscription Zambdas are invoked when a FHIR resource with matching search criteria is created, updated, or deleted.

Example use cases:

Creating a Subscription Zambda

To create a subscription Zambda, create a FHIR Subscription (opens in a new tab) resource with a channel type of rest-hook and an endpoint zapehr-lambda:{LAMBDA-ID}.

For example:

{
  "resourceType": "Subscription",
  "status": "active",
  "criteria": "Patient",
  "channel": {
    "type": "rest-hook",
    "endpoint": "zapehr-lambda:83b669f4-79f0-409e-8f11-baad2fcebfc9"
  }
}

Here are some more examples of subscription Zambdas:

  • criteria of Patient will run whenever a Patient is created or updated
  • criteria of Patient?organization=Organization/123 will run whenever a Patient with an Organization property of Organization/123 is created or updated

If you want to run a subscription when a resource is created or updated, you can add an extension http://zapehr.com/fhir/extension/SubscriptionTriggerEvent plus a value create or update.

{
  "resourceType": "Subscription",
  "status": "active",
  "criteria": "Patient",
  "channel": {
    "type": "rest-hook",
    "endpoint": "zapehr-lambda:83b669f4-79f0-409e-8f11-baad2fcebfc9 "
  },
  "extension": [
    {
      "url": "http://zapehr.com/fhir/extension/SubscriptionTriggerEvent",
      "valueString": "create"
    }
  ]
}

If the extension has value create the subscription runs when a resource is created; if it has value update it runs when a resource is updated. If the extension is not on the resource, it runs when a resource is created or updated.