...
Validate preperson_id UUID
In case of error - return 422
Check an entry with preperson_id doesn't exist in mpi.persons , but exists in medical_data.patients as patient_id. 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 medical_datampi.patientspersons
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)
...
Extract user_id and legal_entity_id from token and find corresponding employee_id
Check employee status is APPROVED
In case of error - return 422 error (Only active employee can create preperson merge request)
If employee has division - validate it has status ACTIVE
In case of error - return 422 error (Only employee of active divisions can create preperson merge request)
Save object to DB
il.personmerge_requests table
Parameter | Source | Description | ||
---|---|---|---|---|
id | uuid | Autogenerated | type | string |
Set PREPERSON_MERGE_REQUEST for this type of requests. Required | data | jsonb | Data from the request in json format. Required | |
person_mpi_id | Request: person_id | Person identifier in MPI (mpi.persons.id). Required | ||
preperson_mpi_id | Request: preperson_id | Preperson identifier that corresponds to MPI (returned on create preperson). Required | ||
status | varchar(50) | 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 | ||
channel | string | By default is MIS | ||
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 |
...