Table of Contents |
---|
Purpose
This WS allows to link linking medical data of an unidentified person to a person in eHealth. Thus it helps a person who was unidentified during some period to store all its medical history.
Specification
Page Properties | ||
---|---|---|
| ||
...
|
Logic
Only authenticated and authorized SPECIALIST, ASSISTANT or RECEPTIONIST employees can merge prepersons with prepersons.
Prepersons can be merged in EMERGENCY or OUTPATIENT legal entities.
Employee can merge any active preperson to any active person.
To merge person with preperson only their MPI ids needed.
Change status should be logged in the Event manager.
...
Dictionaries
AUTHENTICATION_METHOD
DOCUMENT_TYPE
Request structure
Example:
Expand | ||
---|---|---|
| ||
|
Authorize
Verify the validity of access token
...
return 401 in case validation fails
Check user scopes in order to perform this action (scope = '
...
merge_request:write')
...
return 403 in case invalid scope(s)
If BLOCK_UNVERIFIED_PARTY_USERS is true, then check party's data match following condition: verification_status != NOT_VERIFIED or (verification_status = NOT_VERIFIED and updated_at <= current_date - UNVERIFIED_PARTY_PERIOD_DAYS_ALLOWED):
in case not match - return 403 ("Access denied. Party is not verified")
Headers
Content-Type:application/json
Authorization:Bearer {{access_token}}
Api-key:{{secret}}
Request data validation
Validate request
Validate request using schema (TBD)
Validate legal entity
Check that legal entity is active (status = ACTIVE, SUSPENDED)
Extract client_id from
...
token
...
Check legal entity status (status = ACTIVE
...
)
In case of error - return 409 (Legal entity must be ACTIVE
...
)
Validate person
Ensure master_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
...
404 ( Person not found)
Check person status is active
In case of error - return 409 (Person is not active)
Validate preperson
Ensure merge_person_id is preperson
Validate merge_person_id UUID
In case of error - return 422
...
Find preperson by id in mpi.prepersons
In case of error - return
...
404 (Preperson not found)
Check preperson status is active in mpi.
...
prepersons
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 of another requests to
...
CANCELLED
Check if preperson has at least one episode( status!= "entered_in_error")
if no episodes - return
...
409 (Preperson has no episodes)
Validate employee
...
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
...
Validate authorize_with
If submitted, validate authorize_with field for a person as described on create Person request process. But for success case set it to il.merge_requests.authentication_method_current field instead.
Generate verification code
Validate person authentication method in mpi.person_authentication_methods table:
If type is OTP or THIRD_PERSON - Generate verification code as on create patient request process.
If type is OFFLINE - Generate uploaded URLs as on create patient request process. Set il.merge_requests.documents
In case no auth methods found (null) - return error with code 409 (Person has no auth methods)
Processing
Save object to DB
il.merge_requeststable
Parameter | Source | Description |
---|---|---|
id | uuid | Autogenerated |
data | jsonb |
Contains data for signed_content in json format. |
At this step is null. Optional field | ||
master_person_id | Request: master_person_id | Person identifier in MPI (mpi.persons.id). Required |
merge_person_id | Request: merge_person_id | Preperson identifier that corresponds to MPI.prepersons.id (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 |
documents | jsonb | urls of the person`s documents if chosen authentication method is OFFLINE |
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 |
Generate verification code
Validate person authentication method in mpi.person_authentication_methods table:
...
Response structure
See on Apiary
Example:
Expand | ||
---|---|---|
| ||
|
HTTP status codes
Page Properties | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||
|