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/patients
  • DELETE/organization/v1/users/patients/{id}
  • POST/organization/v1/users/patients
  • POST/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_ENTITY callbacks run after PRE_REQUEST callbacks but before POST_REQUEST callbacks. If you have both an ADAPT_ENTITY interceptor and a POST_REQUEST interceptor modifying the same entity, the POST_REQUEST changes will override the ADAPT_ENTITY changes.