Purpose
Method to Get number of declarations per practitioner and his current limit
Specification
Service logic
Authorization
Verify that MIS API token exists in request
in case of error - return 401 (“Api key is not set")
Verify the validity of MIS API token
in case of error - return 401 (“Invalid api key”)
Verify that MIS API token is not expired
in case of error - return 401 (“Invalid api key”)
Check MIS scopes in order to perform this action (scope = 'declaration_bulk:read_pis')
return 403 (“Your scope does not allow to access this resource. Missing allowances: declaration_bulk:read_pis”) in case of invalid scope(s)
Service logic
Data preparation
This data must be calculated on daily basis (or other intervals depending on cron configuration)
Get all employees with a related party (party.id = employee.party_id)
Get all declared specialities (where speciality_officio = true) per party
Get current limit for each speciality from global parameters
PEDIATRICIAN: pediatrician_declaration_limit
THERAPIST: therapist_declaration_limit
FAMILY_DOCTOR: family_doctor_declaration_limit
Get lowest limit for each party (declarations_limit)
Find and count all active (status active or pending_verification) declarations for all this employees (per party) (declarations_count)
Representation
Get the latest snapshot to return calculated and aggregated report
Put to response the date the report is valid for