Skip to content

Instantly share code, notes, and snippets.

@madaster97
Last active July 29, 2021 17:56
Show Gist options
  • Save madaster97/0bdfd92c0ed336700c3db48aa84bf24c to your computer and use it in GitHub Desktop.
Save madaster97/0bdfd92c0ed336700c3db48aa84bf24c to your computer and use it in GitHub Desktop.
Batch/Include tags for fhir subscriptions

Here's my take on handling batched notifications and included resources in id-only notifications.

  1. Whenever you batch multiple events in a notification you NEED to include a "focus" in the header, since you could for instance have the same resource show up multiple times in the header.
  2. Whenever you have _include resources in the bundle, you need to tag that entry saying that (in addition to maybe being the focus based on "focus") you are including it for a specific event. IE, rather than tagging what resoure this was included from, you tag the event ID (which has 1 focus resource we now know this was included for).

I have 4 examples attached showing different notification use cases: Simple -> Encounter1 Include -> Encounter2 includes Encounter1 Batch -> Encounter1, Encounter2, Encounter1 Batch and Include -> Encounter 2 includes Encounter1, Encounter1

I haven't explored how this will work with full resource payloads. That combined with include makes this pretty complex.

{
"resourceType": "Bundle",
"id": "notification-id-only",
"meta": {
"profile": [
"http://hl7.org/fhir/uv/subscriptions-backport/StructureDefinition/backport-subscription-notification"
]
},
"type": "history",
"timestamp": "2020-05-29T11:44:13.1882432-05:00",
"entry": [
{
"fullUrl": "urn:uuid:b21e4fae-ce73-45cb-8e37-1e203362b2ae",
"resource": {
"resourceType": "SubscriptionStatus",
"id": "b21e4fae-ce73-45cb-8e37-1e203362b2ae",
"status": "active",
"type": "event-notification",
"eventsSinceSubscriptionStart": "310",
"eventsInNotification": 3,
"subscription": {
"reference": "https://example.org/fhir/r4/Subscription/admission"
},
"topic": "http://example.org/fhir/r4/SubscriptionTopic/admission",
"focus": [
"https://example.org/fhir/r4/Encounter/Encounter1",
"https://example.org/fhir/r4/Encounter/Encounter2",
"https://example.org/fhir/r4/Encounter/Encounter1"
]
}
},
{
"fullUrl": "https://example.org/fhir/r4/Patient/Encounter1"
},
{
"fullUrl": "https://example.org/fhir/r4/Encounter/Encounter2"
}
]
}
{
"resourceType": "Bundle",
"id": "notification-id-only",
"meta": {
"profile": [
"http://hl7.org/fhir/uv/subscriptions-backport/StructureDefinition/backport-subscription-notification"
]
},
"type": "history",
"timestamp": "2020-05-29T11:44:13.1882432-05:00",
"entry": [
{
"fullUrl": "urn:uuid:b21e4fae-ce73-45cb-8e37-1e203362b2ae",
"resource": {
"resourceType": "SubscriptionStatus",
"id": "b21e4fae-ce73-45cb-8e37-1e203362b2ae",
"status": "active",
"type": "event-notification",
"eventsSinceSubscriptionStart": "310",
"eventsInNotification": 1,
"subscription": {
"reference": "https://example.org/fhir/r4/Subscription/admission"
},
"topic": "http://example.org/fhir/r4/SubscriptionTopic/admission",
"focus": [
"https://example.org/fhir/r4/Encounter/Encounter2",
"https://example.org/fhir/r4/Encounter/Encounter1"
]
}
},
{
"fullUrl": "https://example.org/fhir/r4/Encounter/Encounter2"
},
{
"extension": {
"url": "http://hl7.org/fhir/uv/subscriptions-backport/StructureDefinition/backport-include-event-key",
"valueString": "310"
},
"fullUrl": "https://example.org/fhir/r4/Patient/Encounter1"
}
]
}
{
"resourceType": "Bundle",
"id": "notification-id-only",
"meta": {
"profile": [
"http://hl7.org/fhir/uv/subscriptions-backport/StructureDefinition/backport-subscription-notification"
]
},
"type": "history",
"timestamp": "2020-05-29T11:44:13.1882432-05:00",
"entry": [
{
"fullUrl": "urn:uuid:b21e4fae-ce73-45cb-8e37-1e203362b2ae",
"resource": {
"resourceType": "SubscriptionStatus",
"id": "b21e4fae-ce73-45cb-8e37-1e203362b2ae",
"status": "active",
"type": "event-notification",
"eventsSinceSubscriptionStart": "310",
"eventsInNotification": 1,
"subscription": {
"reference": "https://example.org/fhir/r4/Subscription/admission"
},
"topic": "http://example.org/fhir/r4/SubscriptionTopic/admission"
}
},
{
"fullUrl": "https://example.org/fhir/r4/Encounter/Encounter2"
},
{
"extension": {
"url": "http://hl7.org/fhir/uv/subscriptions-backport/StructureDefinition/backport-include-event-key",
"valueString": "310"
},
"fullUrl": "https://example.org/fhir/r4/Patient/Encounter1"
}
]
}
{
"resourceType": "Bundle",
"id": "notification-id-only",
"meta": {
"profile": [
"http://hl7.org/fhir/uv/subscriptions-backport/StructureDefinition/backport-subscription-notification"
]
},
"type": "history",
"timestamp": "2020-05-29T11:44:13.1882432-05:00",
"entry": [
{
"fullUrl": "urn:uuid:b21e4fae-ce73-45cb-8e37-1e203362b2ae",
"resource": {
"resourceType": "SubscriptionStatus",
"id": "b21e4fae-ce73-45cb-8e37-1e203362b2ae",
"status": "active",
"type": "event-notification",
"eventsSinceSubscriptionStart": "310",
"eventsInNotification": 1,
"subscription": {
"reference": "https://example.org/fhir/r4/Subscription/admission"
},
"topic": "http://example.org/fhir/r4/SubscriptionTopic/admission"
}
},
{
"fullUrl": "https://example.org/fhir/r4/Encounter/Encounter1"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment