...
- If "no_tax_id"= true, tax_id field should be empty, in case error return 422
- If "no_tax_id"=false and age>14, tax_id should be present, in case error return 422
Search MPI
Search patient in MPI using personal information
If found only one person - save mpi.person.id to il.declaration_request.mpi_id
...
Validate person_id
If person_id
is in request then
- validate person_id is UUID
- in case error return 422
- search person by person_id in MPI
- in case error return 422, "such person doesn't exist"
- validate person be deduplication model (if score > ONLINE_PERSON_UPDATE_SCORE, then add mpi_id to declaration request)
- else return error 409, "such person can't be updated. New person should be created instead"
If person_id
is not in request then
- search person in mpi
- in case deduplication model gave score < ONLINE_PERSON_UPDATE_SCORE, create new person
- else return error 409, "such person is in mpi with
person_id
. Update this person.
Validate phone number limit
...
- in case person is found, person_id will be saved to declaration_request, and person has the same authentication_methods.phone_number, we do not count phone numbers and do not compare the phone number with global_parameters.phone_number_auth_limit. So that we can update person, but still can not use phone over limit.
- In case person is not found
- Check if (SELECT count(*) from persons where authentication_methods::json->0->>'phone_number'='$.phone_number' and persons.status='active' and is_active=true)<global_parameters.phone_number_auth_limit
in case error return 422, msg "This phone number is present more then $.global_parameters.phone_number_auth_limit times in the system"
- Check if (SELECT count(*) from persons where authentication_methods::json->0->>'phone_number'='$.phone_number' and persons.status='active' and is_active=true)<global_parameters.phone_number_auth_limit
Validate declaration declaration limit
- 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
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 == 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"
...