Purpose
This method intended to get all Device dispenses by legal entity from token.
Specification
Authorization
Verify the validity of access token
Return (401, 'Invalid access token') in case of validation fails
Verify that token is not expired
in case of error - return (401, 'Invalid access token')
Check user scopes in order to perform this action (scope = 'device_dispense:read')
Return (403, 'Your scope does not allow to access this resource. Missing allowances: device_dispense:read') in case of invalid scope(s)
Validations
Validate User
Extract client_id (performer_legal_entity) from token.
Return empty array in case employee has no access to medication dispense.
Service logic
Service returns specified Device dispenses related to the legal entity from token:
Get Device dispenses from device_dispenses (MongoDB)
Filter list above by submitted search parameters
Render a response according to specification.