Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

...

  • 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')

  • If persons age is greater then no_self_registration_age global parameter, but less then person_full_legal_capacity_age global parameter, check that person does not have document with type from PERSON_LEGAL_CAPACITY_DOCUMENT_TYPES config parameter or person has document with type from PERSON_LEGAL_CAPACITY_DOCUMENT_TYPES config parameter and legal_capacity_verification_status <> VERIFIED or VERIFICATION_NOT_NEEDED

    • in case of error - return 422 ('Confidant can not be submitted for person who has document that proves legal capacity')

Validate request

Validate JSON Schema

...

Validate person confidants limit

...

  • Check if $.confidant_person_relationship.confidant_person_id is not equal to person_id from URL

    • in case of error - return 422 ('Persons can not be submited as confidants for themselves')

  • Check if $.confidant_person_relationship.confidant_person_id exists in persons table (MPI DB) with status = active and is_active = true

    • in case of error - return 422 ('Confidant person is not found')

  • Check if confidant person does not already exist as confidant for person using following process /wiki/spaces/CSI/pages/17667883028 with person_id = person from URL and confidant_person_id = $.confidant_person_id from request - expected :error, :not_found response

    • in case of error - return 422 ('Relationship between confidant person and person already exists')

  • Check if confidant person itself shouldn’t be authorized by confidant - so it doesn’t correspond to following rules:

    • confidant persons age < no_self_registration_age global parameter;

    • confidant persons age between no_self_registration_age and person_full_legal_capacity_age global parameters and person does not have document with type from PERSON_LEGAL_CAPACITY_DOCUMENT_TYPES config parameter or person has document with type from PERSON_LEGAL_CAPACITY_DOCUMENT_TYPES config parameter and legal_capacity_verification_status <> VERIFIED or VERIFICATION_NOT_NEEDED;

    • confidant persons age > person_full_legal_capacity_age global parameter and exists at least one active and approved confidant person relationship for person (using following process /wiki/spaces/CSI/pages/17667883028 with person_id = $.confidant_person_id from request - expected :ok, :approved response)

    • confidant person has at least one confidant person in persons.confidant_person array

      • in case of error - return 422 ('Person with incorrect age or with active confidant person relationship can not be submitted as confidant')

  • Check if confidant person cumulative verification status is not in NOT_ALLOWED_CONFIDANT_PERSON_VERIFICATION_STATUSES config parameter

    • in case of error - return 422 ('Person with cumulative verification status <person.verification_status> can not be submitted as confidant')

  • Check if confidant person has active authentication method with type = OTP where ended_at is equal to or greater than today`s date

    • in case of error - return 422 ('Confidant person must have active authentication method with type 'OTP' where ended_at is equal to or greater than current date.')

...

  • Validate documents issued_at date

    • Check that issued_at <= now()

      • in case of error - return 422 ('Document issued date should be in the past')

    • Check that issued_at => person.birth_date

      • in case of error - return 422 ('Document issued date should greater than person.birth_date')

  • Validate document active_to date

    • Check that active_to > now()

      • in case error - return 422 ('Document active_to date should be in future')

  • Validate document type according to DOCUMENT_RELATIONSHIP_TYPEdictionary

    • In case of error - return 422 ('value is not allowed in enum')

  • Check that there are no duplicated document type values in request

    • in 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 < 255

    • in case of error - return 422 ('expected value to have a maximum length of 255 but was <<document_number_length>>')

  • If document type contains BIRTH_CERTIFICATE or BIRTH_CERTIFICATE_FOREIGN values, check that persons age < person_full_legal_capacity_age global parameter

    • in case of error - return 422 ('Invalid relationship document type for person in such age')

Service logic

Search active confidant person relationship requests

To prevent overlimit and duplication of requests, search for active requests in https://e-health-ua.atlassian.net/wiki/spaces/CSIEH/pages/17613422609724271171/IL#confidant_person_relationship_requests table with person_id = person_id from URL and status = NEW.

...

Create new relationship request

Create new record to https://e-health-ua.atlassian.net/wiki/spaces/CSIEH/pages/17613422609724271171/IL#confidant_person_relationship_requests table, set values:

  • id = autogenerate uuid

  • person_id = person_id from URL

  • confidant_person_id = $.confidant_person_id

  • confidant_person_relationship = methods request

  • status = NEW

  • action = INSERT

  • channel = MIS

  • authentication_method_current

    • type = OTP

    • phone_number = phone_number from confidant persons active auth method with type = OTP

  • inserted_by = user_id (from token)

  • inserted_at = now()

  • updated_by = user_id (from token)

  • updated_at = now()

  • documents_relationship = generated links for documents upload (if needed)

...