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

[DRAFT] Approve merge request [API-010-001-002-0354]

Сторінка знаходиться в процесі розробки. Інформація на ній може бути застарілою.

 

https://e-health-ua.atlassian.net/wiki/spaces/EN/pages/17591304241 (remove the link block before publishing the document)

Properties of a REST API method document

Document type

Метод REST API

Document title

[DRAFT] Approve merge request [API-010-001-002-0354]

Guideline ID

GUI-0011

Author

@

Document version

1

Document status

DRAFT

Date of creation

ХХ.ХХ.ХХХХ (дата фінальної версії документа – RC або PROD)

Date of update

ХХ.ХХ.ХХХХ (дата зміни версії)

Method API ID

API-010-001-002-0354

Microservices (namespace)

MPI

Component

Master Patient Index

Component ID

COM-010-001

Link на API-специфікацію

https://ehealthmisapi1.docs.apiary.io/#reference/public.-medical-service-provider-integration-layer/merge-request/approve-merge-request

Resource

{{host}}/api/merge_requests/{{id}}/actions/approve

Scope

merge_request:write

Protocol type

REST

Request type

PATCH

Sync/Async

Sync

Public/Private

Public

Purpose

This WS serves for receiving approval from a person on the action of merging with preperson.

Logic

  1. Only authenticated and authorized SPECIALIST, ASSISTANT or RECEPTIONIST employees can use this WS.

  2. Usage of this WS allowed in EMERGENCY or OUTPATIENT legal entities.

  3. Person should confirm merge with preperson by auth method chosen on create patient request or create declaration request processes.

  4. The request can be approved only by employee who made the request.

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

Configuration parameters

N/A

Dictionaries

  • GENDER

  • DOCUMENT_TYPE

  • ADDRESS_TYPE

  • COUNTRY

  • SETTLEMENT_TYPE

  • STREET_TYPE

  • PHONE_TYPE

  • CONFIDANT_PERSON_TYPE

  • PREFERRED_WAY_COMMUNICATION

  • DOCUMENT_RELATIONSHIP_TYPE

Input parameters

Input parameter

Mandatory

Type

Description

Example

Input parameter

Mandatory

Type

Description

Example

1

id

 

String

Identifier of the merge request. Required

7c3da506-804d-4550-8993-bf17f9ee0404

2

 

 

 

 

 

Request structure

See on API-specification

{ "verification_code": 6598 }

Headers

Headers

Request data validation

Authorize

  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)

  3. Check the employee has created this merge request. Thus select inserted_by from il.merge_requests of this merge request and compare it with user_id from the token.

    1. If not match - return 403 error (Only author of merge request is allowed to approve it)

  4. Check that client_id from the token maches with il.merge_requests.legal_entity_id

    1. If not match - return 422 error (User doesn’t belong to legal entity where the merge request was created)

Validate schema

Validate request using schema (TBD)

Validate merge request

  1. Validate merge request id exists in DB

    1. In case of error - return 404

  2. Check merge request status is NEW

    1. In case of error - return 422 (Incorrect status to approve merge request)

Validate legal entity

Validate legal entity as on create merge request process.

Validate person

Validate person as on create merge request process.

Validate preperson

Validate preperson as on create merge request process, but w/o searching pending merge requests and episodes.

Processing

Determine authorization method

Get authorization_method from il.merge_requests.authentication_method_current.

Next steps is similar to determine authorization method and check OTP/check Documents process on approve patient request.

Get preperson episodes

Get all the preperson episodes for the printout form (mongodb, episodes collection).

Generate printout form

  1. Check if person has confidant_person block:

    1. if has - select printout form with confidant person

    2. if not - select printout form w/o confidant person

  2. Invoke MAN to render print form.

Request mapping:

Parameter

Source

Parameter

Source

id

MERGE REQUEST

  1. Set

il.merge_requests.printout_form

Update object in DB

il.merge_requests table

Parameter

Source

Description

Parameter

Source

Description

status

Request: status

Status of the request, required. Set APPROVED

data

Request: data

Request data for sign, required. Save master_person and merge_person blocks with detailed information, printout form, merge request id, patient_signed (master person) and status field.

printout_form

text

Generated printout form (PREPERSON MERGE REQUEST)

updated_by

uuid

Extract user from token

updated_at

timestamp

Get current date-time

Response structure examples

See on API-specification

{ "meta": { "code": 200, "url": "https://example.com/resource", "type": "object", "request_id": "6617aeec-15e2-4d6f-b9bd-53559c358f97#17810" }, "data": { "id": "7c3da506-804d-4550-8993-bf17f9ee0404", "master_person_id": "7c3da506-804d-4550-8993-bf17f9ee0402", "merge_person_id": "7c3da506-804d-4550-8993-bf17f9ee0403", "status": "APPROVED", "inserted_at": "2017-04-20T19:14:13Z", "inserted_by": "e1453f4c-1077-4e85-8c98-c13ffca0063e", "updated_at": "2017-04-20T19:14:13Z", "updated_by": "2922a240-63db-404e-b730-09222bfeb2dd", "data_to_be_signed": { "id": "7c3da506-804d-4550-8993-bf17f9ee0404", "status": "APPROVED", "master_person": { "id": "13001c60-45a0-4b5a-b425-9505e1de18bd", "first_name": "Петро", "last_name": "Іванов", "second_name": "Миколайович", "birth_date": "2009-07-05", "birth_country": "Україна", "birth_settlement": "Вінниця", "gender": "MALE", "email": "email@example.com", "no_tax_id": false, "tax_id": "3999869394", "secret": "secret", "documents": [ { "type": "BIRTH_CERTIFICATE", "number": "АА120518", "issued_by": "Рокитнянським РВ ГУ МВС Київської області", "issued_at": "2017-02-28", "expiration_date": "2027-02-28" } ], "addresses": [ { "type": "RESIDENCE", "country": "UA", "area": "Житомирська", "region": "Бердичівський", "settlement": "Київ", "settlement_type": "CITY", "settlement_id": "b075f148", "street_type": "STREET", "street": "вул. Ніжинська", "building": "15", "apartment": "23", "zip": "02090" } ], "phones": [ { "type": "MOBILE", "number": "+380503410870" } ], "unzr": "20090705-00011", "emergency_contact": { "first_name": "Петро", "last_name": "Іванов", "second_name": "Миколайович", "phones": [ { "type": "MOBILE", "number": "+380503410870" } ] }, "confidant_person": [ { "relation_type": "PRIMARY", "first_name": "Петро", "last_name": "Іванов", "second_name": "Миколайович", "birth_date": "1972-10-26", "birth_country": "Україна", "birth_settlement": "Вінниця", "gender": "MALE", "tax_id": "2659719350", "secret": "secret", "unzr": "19900101-00099", "preferred_way_communication": "email", "documents_person": [ { "type": "PASSPORT", "number": "АА120518", "expiration_date": "2021-02-28", "issued_by": "Рокитнянським РВ ГУ МВС Київської області", "issued_at": "2017-02-28" } ], "documents_relationship": [ { "type": "BIRTH_CERTIFICATE", "number": "АА120518", "issued_by": "Рокитнянським РВ ГУ МВС Київської області", "issued_at": "2017-02-28" } ], "phones": [ { "type": "MOBILE", "number": "+380503410870" } ], "email": "emaill@example.com" } ], "preferred_way_communication": "email" }, "patient_signed": false, "merge_person": { "external_id": "#1234-FDS-aa", "first_name": "Петро", "last_name": "Іванов", "second_name": "Миколайович", "gender": "MALE", "birth_date": "1980-01-01", "emergency_contact": { "first_name": "Петро", "last_name": "Іванов", "second_name": "Миколайович", "phones": [ { "type": "MOBILE", "number": "+380503410870" } ] }, "id": "7c3da506-804d-4550-8993-bf17f9ee0402", "note": "Registered in SmartMed clinic at 01.01.2019 16:40. Male, 40 years old approximately, tatoo with sport motorcycle on the right forearm" }, "content": "HTML" } } }

HTTP status codes

Response code

HTTP Status code

Message

Internal name

Description

Response code

HTTP Status code

Message

Internal name

Description

1

Базові

2

 

200

 Response

 

 

3

 

401

 

Access token validation failed

 

4

 

403

Only author of merge request is allowed to approve it

 

Validation failed

 

5

 

403

Invalid scope

 

 

6

 

404

 

Validation failed

 

7

 

422

User doesn’t belong to legal entity where the merge request was created

 

Validation failed

 

8

 

422

Incorrect status to approve merge request

 

 

9

Специфічні

10

 

 

 

 

 

Post-processing processes

N/A

Technical modules where the method is used

 

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