...
- Count all declarations in status
active
where OPS.declarations.employee_id==$.declaration_request.employee_id
1.1 If there is an active declaration with the current person, exclude it from the selection in order to let doctor resign declaration with current patient - Count all declaration_requests in status
approved
approved
where IL.declaration_requests.data($.employee.id) ==$.declaration_request.employee_id - Get all specialities of current doctor
- Select speciality from PRM.employees where PRM.employees.party_id == (select PRM.employees.party_id where PRM.employees.id=$.declaration_request.employee_id)
- Select config parameter for declarations_limit where speciality == $.declaration_request.scope select 3
- Compare the result of selections 1+2 with the lowest config parameter from select 4. In case count (declarations+declaration_requests )> config_parameter, return 409 "The employee has reached the declaration limit"
...