Interceptors - Modifying All Service Responses
One Plugin for Multiple API Calls
The ADAPT_ENTITY Interception type lets you modify every API response that returns a specific entity type, using a single plugin subscription, instead of subscribing separately to each API that returns that entity.
For example, suppose all patient records include a date of birth, but you want every API response to show the patient's age instead. WithoutADAPT_ENTITY, you would need to subscribe individually to every API that returns a patient entity. WithADAPT_ENTITY, you subscribe once, and BioT applies your plugin across all of them.
Subscribing with ADAPT_ENTITY
To subscribe with ADAPT_ENTITY, see Custom Plugin Deployment.
Set interceptions.type to ADAPT_ENTITY, and set interceptions.entityTypeName to the name of the entity you want to intercept.
For example, passing patient as the entity name will cause BioT to invoke your plugin for every API call that returns a patient entity, including:
PATCH/organization/v1/users/patients/{id}GET/organization/v1/users/patientsDELETE/organization/v1/users/patients/{id}POST/organization/v1/users/patientsPOST/organization/v1/users/patients/{id}/enabled-state/{state}GET/organization/v1/users/patients/{id}GET/organization/v1/users/patients/self
For each of these calls, your plugin receives the entity from the API response and must return it, modified or unmodified, as the plugin's response.
Call sequence
ADAPT_ENTITYcallbacks run afterPRE_REQUESTcallbacks but beforePOST_REQUESTcallbacks. If you have both anADAPT_ENTITYinterceptor and aPOST_REQUESTinterceptor modifying the same entity, thePOST_REQUESTchanges will override theADAPT_ENTITYchanges.
