...
Extract client_id from token (token.client_id == legal_entity_id)
Check legal entity status (status = ACTIVE, SUSPENDED)
In case of error - return 409 (Legal entity must be ACTIVE or SUSPENDED)
Validate person
Ensure the person existsmaster_person_id is person
Validate master_person_id UUID
In case of error - return 422
Find person by id in mpi.persons
In case of error - return 422 (Such person doesn't exist)
Check person status is active
In case of error - return 409 (Person is not active)
Validate preperson
Ensure the preperson existsmerge_person_id is preperson
Validate prepersonmerge_person_id UUID
In case of error - return 422
Check an entry with prepersonmerge_person_id exist in mpi.persons and has flag preperson=true. It means that preperson_id relates to preperson, but not to person.
In case of error - return 422 (Such preperson doesn't exist)
Check preperson status is active in mpi.persons
In case of error - return 409 (Preperson is not active)
Check if exists another preperson merge requests with status NEW or APPROVED for this preperson
if exists - update status to REJECTED
Check if preperson has at least one episode
if no episodes - return 422 (Preperson has no episodes)
...
Parameter | Source | Description |
---|---|---|
id | uuid | Autogenerated |
data | jsonb | Data from the request in json format. Required |
master_person_id | Request: master_person_id | Person identifier in MPI (mpi.persons.id). Required |
merge_person_id | Request: prepersonmerge_person_id | Preperson identifier that corresponds to MPI (returned on create preperson). Required |
status | string | Status of the request, required. Set NEW |
merged_pair_id | uuid | Reference to mpi.merged_pairs table when person becomes merged with preperson (on sign). By default is null. |
printout_form | text | Printout form of preperson merge request in html format. By default is null at this step |
legal_entity_id | Request: client_id | Legal entity where request was created. Client_id extracted from token. Required |
authentication_method_current | jsonb | Person current authentication method. |
is_active | bool | Technical flag. By default is true |
inserted_by | uuid | Extract user from token |
inserted_at | timestamp | Get current date-time |
updated_by | uuid | Extract user from token |
updated_at | timestamp | Get current date-time |
...