Purpose
This page describes validation rules for person data (both regular person and person than have confidant person) as part of sign-up processes through person information system (PIS).
Regular person
Key points for regular person dataset:
Schema does not allow to submit “confidant_person” block
There is a need to check if persons age is greater then no_self_registration_age chart parameter
Person authentication methods must contain only records with
type = 'OTP'
This validation rules set is currently used by following WS:
Validations
Validate schema
Validate person data according to JSON Schema:
in case field value does not match the schema - return 422 with field-specific message
in case additional fields exist in request - return 422 ('schema does not allow additional properties')
in case required parameter does not exist in request - return 422 ('required property %{property} was not present')
in case required amount of parameters does not exist in request - return 422 ('expected a minimum of %{min} items but got %{actual}')
Validate person
Validate
tax_id
according to existing validations, described here: https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/589266986/Create+Update+person+request#Validate-%22tax_id%22Validate
no_tax_id
according to existing validations, described here: https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/589266986/Create+Update+person+request#Check-%22no_tax_id%22-flagCheck persons age is greater then no_self_registration_age chart parameter
in case of error - return 422 ('Incorrect person age for such an action')
Validate person documents
Check submitted person document types exist in PIS_PERSON_REGISTRATION_DOCUMENT_TYPES config parameter that contains values from DOCUMENT_TYPE dictionary
in case of error - return 422 ('Submitted document type is not allowed')
Check documents that prove persons legal capacity
In case if persons age is greater then no_self_registration_age global parameter, but less then person_full_legal_capacity_age global parameter:
Check if at least one of submitted person document types exist in PIS_PERSON_REGISTRATION_DOCUMENT_TYPES config parameter that contains values from DOCUMENT_TYPE_EXTENDED dictionary
in case of error - return 422 ('Document that proves personal data must be submitted')
Check if at least one of submitted person document types exist in PIS_PERSON_LEGAL_CAPACITY_DOCUMENT_TYPES config parameter that contains values from DOCUMENT_TYPE_EXTENDED dictionary
in case of error - return 422 ('Document that proves legal capacity must be submitted')
Else check that any of submitted person document types exist in PIS_PERSON_REGISTRATION_DOCUMENT_TYPES config parameter
in case of error - return 422 ('<Document type> can not be submitted for this person')
Validate person documents according to exiting validations, described here: https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/589266986/Create+Update+person+request#Validate-person-documents
Validate person addresses
Check that one address record with
type = 'RESIDENCE'
is submittedin case of error - return 422 ('one and only one residence address is required')
Validate person authentication methods
Check that submitted authentication_methods contains only records with
type = 'OTP'
in case of error - return 422 ('Only OTP authentication method can be created for person')
Validate phone number limit according to existing validation, described here: https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/589266986/Create+Update+person+request#Validate-phone-number-limit
Person with confidant
There are few differences between validation of reqular person and validation of person with confidant:
Schema allowes to submit “confidant_person” block
User can set only one confidant person and only one authentication method
There is no need to check if persons age is greater then no_self_registration_age chart parameter
To validate submitted document types another config parameter is used (PIS_PERSON_WITH_CONFIDANT_REGISTRATION_DOCUMENT_TYPES)
Person authentication methods must contain only records with
type = 'THIRD_PERSON'
Confidant person must be validated
This validation rules set is currently used by following WS:
Validations
Validate schema
Validate person data according to JSON Schema:
in case field value does not match the schema - return 422 with field-specific message
in case additional fields exist in request - return 422 ('schema does not allow additional properties')
in case required parameter does not exist in request - return 422 ('required property %{property} was not present')
in case required amount of parameters does not exist in request - return 422 ('expected a minimum of %{min} items but got %{actual}')
Validate person
Validate
tax_id
according to existing validations, described here: https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/589266986/Create+Update+person+request#Validate-%22tax_id%22Validate
no_tax_id
according to existing validations, described here: https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/589266986/Create+Update+person+request#Check-%22no_tax_id%22-flag
Validate person documents
Check submitted person document types exist in PIS_PERSON_WITH_CONFIDANT_REGISTRATION_DOCUMENT_TYPES config parameter that contains values from DOCUMENT_TYPE dictionary
in case of error - return 422 ('Submitted document type is not allowed')
Validate person documents according to exiting validations, described here: https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/589266986/Create+Update+person+request#Validate-person-documents
Validate person addresses
Validate person addresses according to existing validation, described here: https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/589266986/Create+Update+person+request#Validate-person-documents
Validate сonfidant person
Check if confidant_person.person_id is equal to person_id of user who initiates patient registration
in case of error - return 422 ('Person who initiates registration of patient must be submitted as confidant person')
Check if confidant_person.person_id exists in persons table (MPI DB)
in case of error - return 422 ('Confidant patient is not found')
Check if confidant person age >= no_self_registration_age chart parameter
in case of error - return 422 ('Incorrect person age for such an action')
Check if confidant person cumulative verification status is not in
NOT_ALLOWED_CONFIDANT_PERSON_VERIFICATION_STATUSES
config parameterin case of error - return 422 ('Person with cumulative verification status <verification_status> can not be submitted as confidant')
Check if confidant person has authentication method with
type = OTP
where ended_at is equal to or greater than today`s datein 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 person authentication methods
Check that submitted authentication_methods contains only one record and this record has
type = 'THIRD_PERSON'
in case of error - return 422 ('Only THIRD_PERSON authentication method can be created for person')
Check if THIRD_PERSON is the same person who initiates patient registration and submitted as confidant (authentication_methods.value =
x-person-id
from token)in case of error - return 422 ('person.authentication_methods.value must be equal to person.confidant_person.person_id')