Method is used for approve or reject employee request.
See service specification
Authorize
Verify the validity of access token
Check user scope employee_request:update in order to perform this action
In case error - return 401 error
Check action in request
if action = APPROVE, add user new role
if action - REJECT, update employee request status on REJECTED
Update employee request status to REJECTED
Invoke WS to update employee request status with parameter 'action'='reject'
See service specification
curl -X PATCH -H 'Content-Type: application/json' 'http://ehealth.nebo15.com/employee_requests/d290f1ee-6c54-4b01-90e6-d701748f0851/actions/reject' |
Get Employee Request Details
Invoke WS Get Employee Request by ID for further employee creation
See service specification
curl -X GET -H 'Content-Type: application/json' 'http://ehealth.nebo15.com/employee_requests/d290f1ee-6c54-4b01-90e6-d701748f0851' |
Create user in Auth
Create user in Auth
Create/Update employee
Search party_id by tax_id (tax_id or passport_number) and birth_date for deduplication Party
If found, update object party - Update party WS
If not found, - Create object party
Update Party. See specification
The following fields can't be changed:
tax_id (tax_id or passport_number)
birth_date
If doctor object in ER is null, don't update party.eductions/party.qualifications/party.specialities/party.science_degree. Otherwise update those objects.
if about_myself/working_experience is null or empty string - don't update correspondent fields in parties.
Create party WS. See specification
create related entity party-user in PRM
Chech employee_id in request
if employee_id is exist in request, Update employee.
if employee_id is not exist, Create employee.
Update employee. See specification
The following fields can't be changed:
employee_type
legal_entity_id
start_date
if employee_type = 'DOCTOR', update doctor object
if one of next fields were changed:
first_name
second_name
last_name
find contracts with contractor_owner_id=$owner_id and status='VERIFIED'. Set ops.contracts.is_suspended=true
Create new employee. See specification
If (employee_type = OWNER || employee_type = PHARMACY_OWNER) : deactivate all other records with the employee_type = OWNER
or employee_type = PHARMACY_OWNER for the legal_entity,
where new owner is creating:
update employees e set is_active = false inserted_by = $new_owner_id inserted_at = md5(clock_timestamp() where e.legal_entity_id = $employee_request.legal_entity_id and (e.employee_type = 'OWNER' or e.employee_type = 'PHARMACY_OWNER') |
In case new OWNER was added find contracts with contractor_owner_id=$old_owner_id and status='VERIFIED'.
Set ops.contracts.is_suspended=true
Create related entity party-user
Create related entity party-user
It can be only one pair user_id-party_id.
party_id cannot be updated for the user_id.
Check that there is no records in party_users for the stated in employee_request user_id
If not - return 422 error: "ЦЯ EMAIL-АДРЕСА ВЖЕ ЗАЙНЯТА ІНШИМ КОРИСТУВАЧЕМ"
Add role
Add user role by invoke service - название метода
Role is assigned according to employee_type
See service logic
See service spesification
curl -X POST -H 'Content-Type: application/json' -d '{ "role": "doctor", "client_id": "b075f148-7f93-4fc2-b2ec-2d81b19a9b7b" }' 'https://trump.herokuapp.com/admin/parties/b075f148-7f93-4fc2-b2ec-2d81b19a9b7b/add_role' |
Update employee request status to APPROVED
Invoke WS to update employee request status with parameter 'action'='approve'
See service specification
curl -X PATCH -H 'Content-Type: application/json' 'http://ehealth.nebo15.com/employee_requests/b075f148-7f93-4fc2-b2ec-2d81b19a9b7b/actions/approve' |
Send Email
Send email with successful registration using WS - Send Message (TBD)
Temporarily use Postmark
Submit party on verification
Create or update existing record in party_verifications table for a party according to logic in sections below. Also, set:
updated_at = now()
updated_by = user uuid
inserted_at = now() (for new records)
inserted_by = user uuid (for new records)
DRFO registry verification
Set to party verification record as ready for online verification with DRFO registry:
drfo_data_id = NULL
drfo_data_result = NULL
drfo_synced_at = NULL
drfo_verification_status = VERIFICATION_NEEDED
drfo_verification_reason = ONLINE_TRIGGERED
Then party will be verified online with DRFO registry via separate process: https://e-health-ua.atlassian.net/wiki/spaces/DRACS/pages/17250320467/DRFO+data+synchronization+for+Parties#Data-flow
DRACS death acts registry verification
Set to party verification record as ready for online verification with DRACS death acts registry:
dracs_death_verification_status = VERIFICATION_NEEDED
dracs_death_verification_reason = ONLINE_TRIGGERED
dracs_death_online_status = READY
Then party will be verified online with DRACS death acts registry via separate process: https://e-health-ua.atlassian.net/wiki/spaces/DRACS/pages/17249239231
DRACS name change acts registry verification
If party is created, set values in party_verifications table:
dracs_name_change_verification_status = VERIFICATION_NOT_NEEDED
dracs_name_change_verification_reason = INITIAL
If party is updated and persons dracs_name_change_verification_status = ‘VERIFICATION_NEEDED’:
Check existence of verification candidates for party_id with status = ‘NEW’ and entity_type in (‘dracs_marriage_act', ‘dracs_divorce_act’, ‘dracs_change_name_act’) in the party_verification_candidates table:
if found:
Compare updated party data with them using following processes for each entity_type:
for dracs_marriage_act - https://e-health-ua.atlassian.net/wiki/spaces/DRACS2/pages/17861116193/NEW+Offline+comparison+of+marriage+acts+with+Parties#Step-3.-Marriage-act-comparison-process
for dracs_divorce_act - https://e-health-ua.atlassian.net/wiki/spaces/DRACS2/pages/17861116243/NEW+Offline+comparison+of+divorce+acts+with+Parties#Step-3.-Divorce-act-comparison-process
for dracs_change_name_act - https://e-health-ua.atlassian.net/wiki/spaces/DRACS2/pages/17864654893/NEW+Offline+comparison+of+change+name+acts+with+Parties#Step-3.-Change-name-act-comparison-process
If a candidate does not already match the updated party’s data - deactivate them, set:
status = ‘DEACTIVATED’
status_reason = ‘PARTY_UPDATED’
updated_at = now()
If no more active candidates for name change left - update party DRACS change name verification status, set values:
dracs_name_change_verification_status = VERIFIED
dracs_name_change_verification_reason = AUTO_OFFLINE
dracs_name_change_verification_comment = null
Calculate cumulative verification status
Calculate parties cumulative verification status based on parties verification status in each stream: DRFO registry verification, DRACS death acts registry verification, DRACS name change acts registry verification according to logic described at https://e-health-ua.atlassian.net/wiki/spaces/DRACS2/pages/17861968774/UPD+Party+verification+status+model#Cumulative-verification-status
Set calculated status to parties.verification_status field
Create StatusChangeEvent for each active employee related to a party in event manager with new verification status if it was changed