ЕСОЗ - публічна документація
RC_CSI-2328_(GraphQl) Deactivate Confidant Person relationships request
Purpose
This WS is designed to deactivate Confidant Person relationship for an existing person using Admin panel by authorized NHS employee.
Key points
This graphQl method is used in Administration panel only
Only authenticated and authorized NHS employee with appropriate scope can create new confidant person relationships record.
Mutation has similarities to actions in Deactivate Confidant Person relationship request process, but has some differences.
Documents that prove relationship deactivation must be submitted as well.
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 person_id from URL
Validate person status is active (status = ‘active' & is_active = 'true’)
in case of error - return 404 ('Person is not found')
Validate request
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')
Validate confidant person relationship
Check that confidant person relationship from request (
id
) exists in https://edenlab.atlassian.net/wiki/spaces/EH/pages/3126394957/MPI#confidant_person_relationships with person_id = personId from request and is_active = true AND active_to > now() or nullin case of error - return 422 ('Confidant Person relationship does not belong to this person')
Validate documents relationship
Validate documents
issuedAt
dateCheck that issuedAt <= now()
in case of error - return 422 ('Document issued date should be in the past')
Check that issuedAt => person.birth_date
in case of error - return 422 ('Document issued date should greater than person.birth_date')
Validate document
type
according to DOCUMENT_RELATIONSHIP_TYPE dictionaryIn case of error - return 422 ('value is not allowed in enum')
Chech that there are no duplicated document
type
values in requestin case of error - return 422 ('Values are not unique by 'type'.')
Validate document
number
according to regexp (as part of JSON Schema validation)BIRTH_CERTIFICATE -
^((?![ЫЪЭЁыъэё@%&$^#`~:,.*|}{?!])[A-ZА-ЯҐЇІЄ0-9№\\/()-]){2,25}$
In case of error - return 422 error ('string does not match pattern') with the corresponding regexp
Check that document
number
length < 255in case of error - return 422 ('expected value to have a maximum length of 255 but was <<document_number_length>>')
Service logic
Search confidant person relationship requests
To prevent overlimit and duplication of requests, search for active requests in https://edenlab.atlassian.net/wiki/spaces/EH/pages/3259924556/IL#confidant_person_relationship_requests table with person_id = personId from request and status = NEW.
If found - cancel them, set values:
status = CANCELLED
updated_at = now()
updated_by = user_id (from token)
Generate upload URL
Depending on the payload system generates list of signed urls for document scan-copies upload.
Signed URLs to be expired after some period of time (according to SECRETS_TTL config parameter). If it has been expired - new confidant person relationship request should be created.
Each link is generated for one one-page document in jpeg format. Document should be no more than 10MB.
Generate URLs for each document from
$.confidant_person_relationship.documents_relationship
with following parameters:action:
PUT
bucket:
MEDIA_STORAGE_CONFIDANT_PERSON_RELATIONSHIP_REQUEST_BUCKET
resource_id:
confidant_person_relationship_request_id
resource_name:
confidant_person_relationship_request_#{type}.jpeg
Create new deactivation relationship request
Create new record to https://edenlab.atlassian.net/wiki/spaces/EH/pages/3259924556/IL#confidant_person_relationship_requests table, set values:
id = autogenerate uuid
person_id = personId from request
confidant_person_id = confidantPerson (id) from
$.confidant_person_relationship.id
that is being deactivatedconfidant_person_relationship =
$.confidant_person_relationship
status = NEW
action = DEACTIVATE
channel = NHS
authentication_method_current = null
inserted_by = user_id (from token)
inserted_at = now()
updated_by = user_id (from token)
updated_at = now()
confidant_person_relationship_id =
$.confidant_person_relationship.id
documents_relationship = generated links for documents upload
ЕСОЗ - публічна документація