Interceptors - Modifying All Service Responses
One Plugin for Multiple API Calls
In some cases, you might want to modify all the responses from a certain type of service.
For example, if all patients show their date of birth, but you would like to show their age.
You could either subscribe to each API that returns a patient entity in its response, or you could use the ADAPT_ENTITY option instead.
Subscribing with ADAPT_ENTITY
To subscribe to with ADAPT_ENTITY, see the following article.
Use the interceptions.type to pass ADAPT_ENTITY parameter and in interceptions.entityTypeName pass the name of the entity you would like to intercept.
For example passing the patient entity name will result in BioT hooking your lambda to the following API calls:
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
As seen in POST_REQUEST, the code will receive the original API response body and is expected to return it, modified or not, as the lambda response.
Call sequenceNote that the
ADAPT_ENTITYcallbacks are made afterPRE_REQUESTbut beforePOST_REQUESTcallbacks. This means that changes made duringPOST_REQUESTwill override theADAPT_ENTITYchanges.
Updated about 2 months ago
