ЕСОЗ - публічна документація

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 41 Next »

Purpose

This WS allows to link medical data of unidentified person to person in eHealth. Thus it helps person who was unidentified during some period to store all its medical history.

Specification

Apiary

Service logic

  1. Only authenticated and authorized SPECIALIST or RECEPTIONIST employees can merge prepersons with prepersons.

  2. Prepersons can be merged in EMERGENCY or OUTPATIENT legal entities.

  3. Employee can merge any active preperson to any active person.

  4. To merge person with preperson only their MPI ids needed.

  5. Change status should be logged in the Event manager.

Authentication

  1. Verify the validity of access token

    1. Return 401 in case validation fails

  2. Check user scopes in order to perform this action (scope = 'merge_request:write')

    1. Return 403 in case invalid scope(s)

Validate request

Validate request using schema (TBD)

Validate legal entity

Check that legal entity is active (status = ACTIVE, SUSPENDED)

  1. Extract client_id from token (token.client_id == legal_entity_id)

  2. Check legal entity status (status = ACTIVE, SUSPENDED)

    1. In case of error - return 409 (Legal entity must be ACTIVE or SUSPENDED)

Validate person

Ensure master_person_id is person

  1. Validate master_person_id UUID

    1. In case of error - return 422

  2. Find person by id in mpi.persons

    1. In case of error - return 422 (Such person doesn't exist)

  3. Check person status is active

    1. In case of error - return 409 (Person is not active)

Validate preperson

Ensure merge_person_id is preperson

  1. Validate merge_person_id UUID

    1. In case of error - return 422

  2. Find preperson by id in mpi.prepersons

    1. In case of error - return 422 (Such preperson doesn't exist)

  3. Check preperson status is active in mpi.prepersons

    1. In case of error - return 409 (Preperson is not active)

  4. Check if exists another preperson merge requests with status NEW or APPROVED for this preperson

    1. if exists - update status to REJECTED

  5. Check if preperson has at least one episode

    1. if no episodes - return 422 (Preperson has no episodes)

Validate employee

  1. Extract user_id and legal_entity_id from token and find corresponding employee_id

  2. Check employee status is APPROVED

    1. In case of error - return 422 error (Only active employee can create merge request)

  3. If employee has division - validate it has status ACTIVE

    1. In case of error - return 422 error (Only employee of active divisions can create merge request)

Save object to DB

il.merge_requests table

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: 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

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:

  • No labels