Subscribing to Topics
Client Systems may subscribe to Topics to receive notifications when events on that topic occur in future. When subscribing, Client Systems must specify a filter which will be applied to events to ensure that only notifications which are relevant to the client are sent. Clients may choose between two Subscription Types - rest-hook or event-pull - to determine whether they wish to receive push notifications or to use a polling mechanism. Client Systems wishing to use rest-hook must first set up an endpoint within their infrastructure, and register it with the Spine. Please see Working with Endpoints for further details.
Subscribe to a Topic using a Rest Hook
POST /Subscription
When creating or updating an Subscription of type rest-hook, the Spine will send a handshake notification to the endpoint using the POST method. The endpoint must return a success status otherwise the Subscription will not be created and an error response will be returned.
Parameters
Name | Type | Description |
|---|---|---|
| JSON Object (body) | Example
JSON
|
channelType:System:
http://hl7.org/fhir/subscription-channel-typeCode:
rest-hook
status: Onlyactiveis currently supportedcontent:Must be set toid-onlyEndpoint Extension: Must reference an existing endpoint
heartbeatPeriod: Optionally sends a heartbeat notification to the endpoint at this interval in seconds.nullor0: No Heartbeat will be sentMinimum:
60(1 minute)Maximum:
86400(24 hours)
maxCount: The maximum number of events to include in each notification sent to the endpointRequired for Rest Hook subscriptions
Minimum:
1Maximum:
50
Responses
Code | Description |
|---|---|
201 | Created See response header: |
422 | Unprocessable Entity |
Subscribe to a Topic using Event Pull
POST /Subscription
When creating or updating an Subscription of type event-pull, the Spine will not send notifications to an endpoint when events occur. Instead, it is the responsibility of the Client System to poll the Events endpoint to retrieve events.
Parameters
Name | Type | Description |
|---|---|---|
| JSON Object (body) | Example
JSON
|
channelType:System:
https://clevermed.com/fhir/r5/CodeSystem/subscription-channel-typeCode:
event-pull
status: Onlyactiveis currently supportedcontent:Must be set toid-only
Responses
Code | Description |
|---|---|
201 | Created See response header: |
422 | Unprocessable Entity |
Get Subscription
GET /Subscription/{subscription-id}
Parameters
Name | Type | Description |
|---|---|---|
| String (path) | The ID of the Subscription to get |
Responses
Code | Description |
|---|---|
200 | Example
JSON
|
404 | Not Found |
Get all Subscriptions
GET /Subscription
Responses
Code | Description |
|---|---|
200 | Example
JSON
|
Update Subscription
PUT /Subscription/{subscription-id}
Parameters
Name | Type | Description |
|---|---|---|
| String (path) | The ID of the Subscription to Update |
| JSON Object (body) | JSON model as for Create |
Responses
Code | Description |
|---|---|
204 | Success - No Content |
404 | Not Found |
Delete Subscription
DELETE /subscription/{subscription-id}
Parameters
Name | Type | Description |
|---|---|---|
| String (path) | The ID of the Subscription to Delete |
Responses
Code | Description |
|---|---|
204 | Success - No Content |
404 | Not Found |
Get Subscription Status
GET /Subscription/{subscription-id}/$status
Parameters
Name | Type | Description |
|---|---|---|
| String (path) | The ID of the Subscription to get the status for |
Responses
Code | Description |
|---|---|
200 | Example
JSON
|
404 | Not Found |