Authorization for Event-Driven Communication
An example scenario shows how to configure authorization for event-driven communication by defining permissions, policies, and authorization mappings for event listener applications.
Authorization is required to gain access to the resources within the SAP Health Data Services for FHIR service instance. For create, update, or delete operations on master and transactional resources, a corresponding external event is published from SAP Health Data Services for FHIR to the consumer event bus. An additional attribute is populated to the event body that the event listener application uses for authorization.
The following example scenario demonstrates how to model authorization for an event listener application that consumes Appointment update events and updates related resources.
Example Scenario
-
If you want to update the Slot and Schedule resource for the canceled appointment, then you must have the necessary permissions:
-
Create a RolePermission
A RolePermission resource type is a collection of permissions. -
Create a GroupPolicy
A GroupPolicy resource type is a collection of roles that define the governance policy for entities interacting with SAP Health Data Services for FHIR.ExampleThe GroupPolicy to define access to update the Slot and Schedule resource and read the Appointment, Slot, and Schedule resource:
Sample Code{ "resourceType": "GroupPolicy", "url": "https://sap.com/healthcare/pacc/GroupPolicy/Event-listener", "version": "1.0.0", "name": "Group-Policy-Event-Listener", "status": { "system": "http://hl7.org/fhir/resource-status", "code": "active", "display": "active-en" }, "description": "This policy defines access to create, update, and delete a Patient resource", "rolePermission": [ "https://sap.com/healthcare/fhir/RolePermission/RolePermission-events|1.0.0" ] }
-
-
To listen to the Appointment updated events, you must create an AuthorizationMap resource that is modeled as a mapping reference to an authorization usage and is mapped to the usageIdentity field and the GroupPolicy.
An AuthorizationMap resource type has the following elements:
-
usageContext - The mandatory element usageContext consists of the following:
-
system - The CodeSystem of an AuthorizationMap
-
code - The code is Event-Listener
-
display - The display is Event-Listener
-
-
usageIdentity - The mandatory element usageIdentity includes the master or transactional resource type with the operation, that is, sap.hdsf.<resourceType>.<operation>.v1.
NoteSupported operations for the usageIdentity field are created, updated, and deleted.
-
groupPolicy - The mandatory element groupPolicy indicates the canonical reference to the GroupPolicy.
ExampleAn AuthorizationMap to listen to the Appointment-updated event:
Sample Code{ "resourceType": "AuthorizationMap", "description": "Authorization Map for Event-Listener", "usageContext": { "system": "http://sap.com/healthcare/fhir/CodeSystem/AuthorizationMap-usage-context", "code": "Event-Listener", "display": "Event Listener" }, "usageIdentity": [ "sap.hdsf.Appointment.Updated.v1" ], "groupPolicy": [ "https://sap.com/healthcare/pacc/GroupPolicy/Event-listener|1.0.0" ] } -
-
For authorization, the additional attribute pid that is part of the event body is used by the event listener application. To gain access to the resources within the SAP Health Data Services for FHIR service instance, you must perform the following:
Generate OAuth Token Using Client Credentials Grant-
Send an HTTP POST request to the OAuth access token endpoint. The URL is landscape-specific:
POST <URL>/oauth/token?grant_type=client_credentials
-
<URL> is the authorization token URL obtained from the service key under .
-
The parameter grant_type=client_credentials notifies the endpoint that the client credentials flow is used.
BODY
x-www-form-urlencoded:
-
client_id - Enter the client ID obtained from the service key.
-
client_secret - Enter the client secret obtained from the service key
-
authorities - {"az_attr":{"pid":"<Enter pid value from the event body"}}
-
-
-
Using the generated access token, you can update the Slot and Schedule resource to cancel the appointment by performing the following:
-
Read the corresponding Appointment resource to know the referenced Slot resource:
GET [base]/Appointment/<Appointment ID>
-
Update the Slot resource indicating the status is free:
PUT [base]/Slot/<Slot ID>Sample Code{ "resourceType": "Slot", "id": "appointment-update-slot", "status": "free", "schedule": { "reference": "Schedule/appointment-update-schedule" }, "start": "2024-01-02T20:00:00Z", "end": "2024-02-02T20:40:00Z" } -
Update the Schedule resource indicating the slot is available:
PUT [base]/Schedule/<Schedule ID>Sample Code{ "resourceType": "Schedule", "id": "appointment-update-schedule", "actor": [ { "reference": "Practitioner/Peter", "display": "Outpatient Department" } ] }
-
Path Parameter
base: Service endpoint to interact with FHIR resources. For more information, see Service Endpoint.

