{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://hl7.erp.uno/priv/schema/Subscription.schema.json",
  "$ref": "#/definitions/Subscription",
  "description": "see https://hl7.org/fhir/R5/json.html for information about the FHIR Json Schemas",
  "definitions": {
    "Subscription": {
      "allOf": [
        {
          "description": "The subscription resource is used to define a push based subscription from a server to another system. Once a subscription is registered with the server, the server checks every resource that is created or updated, and if the resource matches the given criteria, it sends a message on the defined \"channel\" so that another system is able to take an appropriate action.",
          "properties": {
            "resourceType": {
              "description": "This is a Subscription resource",
              "type": "string",
              "enum": [
                "Subscription"
              ]
            },
            "status": {
              "description": "The status of the subscription, which marks the server state for managing the subscription.",
              "enum": [
                "requested",
                "active",
                "error",
                "off"
              ],
              "type": "string"
            },
            "contact": {
              "description": "Contact details for a human to contact about the subscription. The primary use of this for system administrator troubleshooting.",
              "type": "array",
              "items": {
                "$ref": "ContactPoint.schema.json#/definitions/ContactPoint"
              }
            },
            "end": {
              "description": "The time for the server to turn the subscription off.",
              "type": "string"
            },
            "reason": {
              "description": "A description of why this subscription is defined.",
              "type": "string"
            },
            "criteria": {
              "description": "The rules that the server should use to determine when to generate notifications for this subscription.",
              "type": "string"
            },
            "error": {
              "description": "A record of the last error that occurred when the server processed a notification.",
              "type": "string"
            },
            "channel": {
              "description": "Details where to send notifications when resources are received that meet the criteria.",
              "$ref": "#/definitions/Subscription_Channel"
            },
            "tag": {
              "description": "A tag to add to any resource that matches the criteria, after the subscription is processed.",
              "type": "array",
              "items": {
                "$ref": "Coding.schema.json#/definitions/Coding"
              }
            }
          },
          "required": [
            "channel",
            "resourceType"
          ]
        }
      ]
    },
    "Subscription_Channel": {
      "allOf": [
        {
          "$ref": "BackboneElement.schema.json#/definitions/BackboneElement"
        },
        {
          "description": "The subscription resource is used to define a push based subscription from a server to another system. Once a subscription is registered with the server, the server checks every resource that is created or updated, and if the resource matches the given criteria, it sends a message on the defined \"channel\" so that another system is able to take an appropriate action.",
          "properties": {
            "type": {
              "description": "The type of channel to send notifications on.",
              "enum": [
                "rest-hook",
                "websocket",
                "email",
                "sms",
                "message"
              ],
              "type": "string"
            },
            "endpoint": {
              "description": "The uri that describes the actual end-point to send messages to.",
              "type": "string"
            },
            "payload": {
              "description": "The mime type to send the payload in - either application/fhir+xml, or application/fhir+json. If the payload is not present, then there is no payload in the notification, just a notification.",
              "type": "string"
            },
            "header": {
              "description": "Additional headers / information to send as part of the notification.",
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      ]
    }
  }
}