ЕСОЗ - публічна документація
RC_CSI-2328_(GraphQl) Approve Confidant Person relationships request
Purpose
This WS is designed to approve previously created Confidant Person relationship request using Admin panel by authorized NHS employee
Key points
This graphQl method is used to approve Confidant Person relationship requests for creating new or deactivating existing confidant person relationships using Admin panel by authorized NHS employee.
Mutation has similarities to actions in Approve Confidant Person relationship request process, but there are some main differences:
Confidant_person_relationships (MPI) record is created in BE directly with verification_status = VERIFIED, verification_reason = MANUAL_CREATED_BY_NHS_ADMIN.
Scope is used: confidant_person_relationship_admin:write
Schema
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 = confidant_person_relationship_admin:write)
Return (403, 'Your scope does not allow to access this resource. Missing allowances: confidant_person_relationship_admin:write') in case of invalid scope(s)
Validation
Validate Person
Get
personId
from requestValidate person status is active (status = ‘active' & is_active = 'true’)
in case of error - return 404 ('Person is not found')
Validate request
Check that confidant person relationship request from request exists in https://edenlab.atlassian.net/wiki/spaces/EH/pages/3259924556/IL#confidant_person_relationship_requests table with person_id = personId from request
in case of error - return 404 ('Confidant person relationship request is not found')
Check that confidant person relationship request from request has status = NEW and channel = NHS
in case of error - return 409 ('Invalid transition')
Check absence of extra parameters from request
in case of error - return 422 ('schema does not allow additional properties')
Check uploaded documents
Get list of document types that must be uploaded to media content storage in documents_relationship
field of confidant person relationship request.
If list is empty - skip validation
If list is not empty - check that documents were uploaded, using Media Content Storage
in case of error - return 409 ('Document <<document_types_to_upload>> is not uploaded') with types of documents that must be uploaded to media content storage
Service logic
Create or deactivate confidant person relationship
Based on action field of confidant person relationship request:
Create confidant person relationship (action = INSERT)
Create confidant person relationship between person and confidant person:
Call https://edenlab.atlassian.net/wiki/spaces/EH/pages/3741876250, set values:
person_id = confidant_person_relationship_request.person_id
confidant_person_id = confidant_person_relationship_request.confidant_person_id
verification_status = “VERIFIED”
verification_reason = “MANUAL_CREATED_BY_NHS_ADMIN“
confidant_person_relationship_documents = confidant_person_relationship_request.confidant_person_relationship.documents_relationship
In case if persons age < person_full_legal_capacity_age years old:
calculate relationship_expiration_date - date when person becomes person_full_legal_capacity_age years old
check if $.active_to <= relationship_expiration_date
if true - set active_to = $.active_to
if false or $.active_to = null - set active_to = relationship_expiration_date
Check existence of authentication method with type = THIRD_PERSON, value = confidant_person_id from request, is_active = true and ended_at > now() or null
If not found - create authentication method for person, set values:
id = autogenerate uuid
person_id = confidant_person_relationship_request.person_id
type = THIRD_PERSON
value = confidant_person_relationship_request.confidant_person_id
inserted_at = now()
updated_at = now()
started_at = now()
ended_at: if person.age < person_full_legal_capacity_age
ended_at = birth_date + person_full_legal_capacity_age - 1d
else ended_at = start_date + third_person_term global parameter
inserted_by = user_id (from token)
updated_by = user_id (from token)
If found - do not create authentication method for person
Deactivate confidant person relationship (action = DEACTIVATE)
Deactivate existing confidant person relationship for person:
Deactivate relationship record in relationship https://edenlab.atlassian.net/wiki/spaces/EH/pages/3126394957/MPI#confidant_person_relationships table where id =
id
(confidant_person_relationship_id), set values:active_to = now()
updated_at = now()
updated_by = user_id (from token)
Save documents from documentsRelationship field to https://edenlab.atlassian.net/wiki/spaces/EH/pages/3126394957/MPI#confidant_person_relationship_documents table for deactivated confidant person relationship, set values:
id = autogenerate uuid
confidant_person_relationship_id =
id
(confidant_person_relationship_id) of deactivated relationshiptype =
documentsType
number =
documentsNumber
issued_at =
issuedAt
(ConfidantPersonRelationshipDocuments)issued_by =
issuedBy
(ConfidantPersonRelationshipDocuments)inserted_by = user_id (from token)
updated_by = user_id (from token)
inserted_at = now()
updated_at = now()
For deactivated relationship - deactivate person authentication methods in https://edenlab.atlassian.net/wiki/spaces/EH/pages/3126394957/MPI#person_authentication_methods table with type = THIRD_PERSON and value =
confidant_person_relationships.confidant_person_id
, set values:ended_at = now()
updated_at = now()
updated_by = user_id (from token)
Update confidant person relationship request
Update confidant person relationship request in https://edenlab.atlassian.net/wiki/spaces/EH/pages/3259924556/IL#confidant_person_relationship_requests table, set values:
status = COMPLETED
updated_at = now()
updated_by = user_id (from token)
confidant_person_relationship_id = confidant_person_relationship.id of created relationship (from action = INSERT)
ЕСОЗ - публічна документація