Table of Contents |
---|
...
This WS allows to update current verification status of specified person. Now updating of DRACS death and DRACS name change streams verification status are allowed.
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 = 'person_verification:write')
Return (403, 'Your scope does not allow to access this resource. Missing allowances: person_verification:write') in case of invalid scope(s)
...
Get Patient identifier from the URL
Check it exists in mpi DB, persons table
Return 404 ('not found') in case of error
Check if person verification record exists in
mpi.person_verifications
tableReturn 404 ('not found') in case of error
Check if person.dracs_death.verification_status is equal to “NOT_VERIFIED”in case of error - return 422 (“verification details for person in <person.dracs_death.verification_status> status can not be updated)
Validate schema
Validate request according to JSON Schema
Check presence of extra parameters
In case of error - return 422 ('schema does not allow additional properties')
Check presence of required parameters
In case of error - return 422 ('required property %{property} was not present')
Check only one of objects is submitted: dracs_death or dracs_name_change
In case of error - return 422 ('Only one of the parameters must be present')
Validate DRACS death fields
Validate DRACS death verification status
Check current status (dracs_death_verification_status) is equal to “NOT_VERIFIED”
in case not equal - return 422 (“verification details for person in <person_verifications.dracs_death_verification_status> status can not be updated)
Validate $.dracs_death.verification_status
Check if $.dracs_death.verification_status value is "VERIFICATION_NEEDED" (from PERSON_VERIFICATION_STATUSES dictionary)
In case of error - return 422 error ("value is not allowed in enum")
Validate DRACS death verification reason
Validate $.dracs_death.verification_reason
Check if $.dracs_death.verification_reason value is MANUAL_CONFIRMED or MANUAL_NOT_CONFIRMED from PERSON_VERIFICATION_STATUS_REASONS dictionary
in case of error - return 422 ("verification reason (<$.dracs_death.verification_reason>) is not allowed for person DRACS death status")
...
Validate $.dracs_death.death_date if exist
Check if $.dracs_death.death_date value is correct format ‘yyyy-mm-dd’
in case of error - return 422 ("Death date must not be in the future")
Check if $.dracs_death.death_date value in the past ($.dracs_death.death_date =< date.today())
in case of error - return 409 (“expected \"$.dracs_death.death_date\" to be less then or equal to current date“)
Check if $.dracs_death.death_date is absent if $.dracs_death.verification_reason = “MANUAL_NOT_CONFIRMED”
in case of error - return 422 (“Death date must not be present with MANUAL_NOT_CONFIRMED verification_reason“)
Validate DRACS name change fields
Validate DRACS name change verification status
Check current status (dracs_name_change_verification_status) is equal to “VERIFICATION_NEEDED”
in case not equal - return 422 (“verification details for person in <person_verifications.dracs_name_change_verification_status> status can not be updated)
Validate $.dracs_name_change.verification_status
Check if $.dracs_name_change.verification_status value is "VERIFIED" (from PERSON_VERIFICATION_STATUSES dictionary)
In case of error - return 422 error ("value is not allowed in enum")
Validate DRACS change name verification reason
Validate $.dracs_name_change.verification_reason
Check if $.dracs_name_change.verification_reason value is “MANUAL” from PERSON_VERIFICATION_STATUS_REASONS dictionary
in case of error - return 422 ("verification reason (<$.dracs_name_change.verification_reason>) is not allowed for person DRACS death status")
Service logic
For DRACS death verification stream:
Set person DRACS death verification status to
mpi.person_verifications
table:person.dracs_death_verification_status = $.dracs_death.verification_status
person.dracs_death_verification_reason = $.dracs_death.verification_reason
person.dracs_death_verification_comment = $.dracs_death.verification_comment
updated_at = now()
updated_by = user_id (from token)
If $.dracs_death.verification_status: VERIFIED and $.dracs_death.verification_reason: MANUAL_CONFIRMED in request - next steps are needed:
Deactivate person:
set persons.status = inactive, persons.updated_at = now(),
set persons.death_date = $.dracs_death.death_date (if death date in content)
terminate active declarations for person with reason = MANUAL_DEATH_REGISTRATION_BY_DOCTOR
deactivate active persons authentication methods
revert active verification candidates for person in person_verification_candidates table in MPI DB by person_id and entity_type = dracs_death_act:
set status = ‘CONFIRMED’
set updated_at = now()
Deactivate user
search user by person_id, if exists (Mithril.users DB)
set is_active = false
set updated_at = now()
call expire_user_tokens function
Deactivate relationships
Get relationships between two persons from MPI | confidant_person_relationships table where:
(person_id is equal to $.person_id OR confidant_person_id is equal to $.person_id)
is_active = true
Deactivate each found relationship from previous step, set values:
active_to = now()
updated_by = system_user()
updated_at = now()
Deactivate auth methods in MPI | person_authentication_methods table with type = THIRD_PERSON and value = confidant_person_id from each found relationship from previoud step, set values:
ended_at = now()
updated_by = system_user()
updated_at = now()
If $.dracs_death.verification_status: VERIFIED and $.dracs_death.verification_reason: MANUAL_NOT_CONFIRMED in request:
revert active verification candidates for person in person_verification_candidates table in MPI DB by person_id and entity_type = dracs_death_act:
set status = ‘NOT_CONFIRMED’
set updated_at = now()
For DRACS name change verification stream:
Set person DRACS name change verification status to
mpi.person_verifications
table:person_verifications.dracs_name_change_verification_status = $.dracs_name_change.verification_status
person_verifications.dracs_name_change_verification_reason = $.dracs_name_change.verification_reason
person_verifications.dracs_name_change_verification_comment = $.dracs_name_change.verification_comment
If $.dracs_name_change_verification_status = 'VERIFIED':
Deactivate active person verification candidates in
person_verification_candidates
table in MPI db with person_id = person_id from URL, status = NEW and entity_type in (dracs_marriage_act, dracs_divorce_act, dracs_change_name_act)status = ‘DEACTIVATED’
status_reason = ‘PERSON_UPDATED’
updated_at = now()
Calculate cumulative verification status based on persons verification status according to logic described at https://e-health-ua.atlassian.net/wiki/spaces/DRACSEH/pages/1725058253416755458061/Person+verification+status+model#Cumulativemodel_EN#Cumulative-verification-status :
Set calculated status to persons.verification_status field
Create StatusChangeEvent in event manager with new verification status if it was changed
Store
signed_content
in appropriatePerson Bucket
.Bucket name (
Person
)Person identifier
Folder for signed content of verification
File with signed content. Has name with timestamp (
epoch||"_verification"
) which corresponds toupdated_at
timestamp of updated Person verification record.
Render a response according to specification.