Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
REST API method / Метод REST API (настанова) (
Info
Note

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

Info

/wiki/spaces/EN/pages/17591304241 (remove the link block before publishing the document)

Table of Contents

Properties of a REST API method document

Page Properties
idpage_properties_method_REST API
Protocol type

Document type

Метод REST API

Document title

[DRAFT] Approve or Reject Employee Request [API-005-007-002-0115]

Guideline ID

GUI-0011

Author

@

Document version

1

Document status

DRAFT

Date of creation

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

Date of update

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

Method API ID

API-005-007-002-0115

Microservices (namespace)

MPIIL

Component

AuthEmployees

Component ID

COM-001005-001007

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

https://ehealthmisapi1.docs.apiary.io/#reference/public.-medicalportal-serviceand-provider-integration-layer/manage-client-configuration/get-client-detailsreports/employee-requests/approve-or-reject-employee-request

Resource

{{host}}//api.ehealth.gov.ua/api/patients/id/encounter_package

Scope

employee_requests/{{id}}/actions/{{action}}

Scope

employee_request:update

Protocol type

REST

Request type

POST

Sync/Async

Sync

Public/Private

Private

Purpose

Describe the purpose of the API method, add Key points (if necessary)

Logic

Description of the working algorithm of the API method and the interaction of services with each other add Service logic (if necessary)

Configuration parameters

Description of the configuration parameters that are used when processing a request in the system

Dictionaries

Provides a list of links to dictionaries that are available in Confluence

Input parameters

Description of input The method is used to approve or reject employee request

Logic

0e9d7fc0-15fc-433a-b980-0b3986ad8156.pngImage Added

Sample Request
Code Block
curl -X POST -H 'Content-Type: application/json' -H 'Authorization:Bearer YW5WcFkyVnFkV2xqWldwMWFXTmxDZzpjY1hwWTR0cWRZbGVjNHAxYUdsMXVJ' 'http://ehealth.nebo15.com/employee_requests/d290f1ee-6c54-4b01-90e6-d701748f0851/actions/approve'

Configuration parameters

N/A

Dictionaries

N/A

Input parameters

Input parameter

Mandatory

Type

Description

Example

1

composition_id

 M 

String ($uuid) (path)

Composition object ID

 89678f60-4cdc-4fe3-ae83-e8b3ebd35c59

2

Required

d290f1ee-6c54-4b01-90e6-d701748f0851

2

action

  • APPROVE

  • REJECT

String

Required

APPROVE

Request structure

See on API-specification (посилання на сторінку з API-специфікацією)

Description of the REST API request structure, example

Expand
titleExample
Code Block

Headers

...

Key

...

Value

...

Mandatory

...

Description

...

Example

...

Content-Type

...

application/json

...

M

...

Тип контенту

...

Content-Type:application/json

...

Authorization

...

Bearer c2778f3064753ea70de870a53795f5c9

...

M

...

Перевірка користувача

...

Authorization:Bearer c2778f3064753ea70de870a53795f5c9

...

Request data validation

Describe the process of checking the input data transmitted in the request for compliance with the given rules and restrictions set in the API

Processing

A list of processes related to receiving, changing or transmitting data according to the logic defined in the REST API

Response structure examples

Description of the REST API response structure, example

...

titleExample

...

Headers

Request data validation

Authorize

  1. Verify the validity of access token

  2. Check user scope employee_request:update in order to perform this action

    1. In case error - return 401 error

Check action in request

  1. if action = APPROVE, add user new role

  2. if action - REJECT, update employee request status on REJECTED 

Processing

Update employee request status to REJECTED

Invoke WS to update employee request status with parameter 'action'='reject' 

See service specification

Sample Request
Code Block
curl -X PATCH -H 'Content-Type: application/json' 'http://ehealth.nebo15.com/employee_requests/d290f1ee-6c54-4b01-90e6-d701748f0851/actions/reject'

Get Employee Request Details

Invoke WS Get Employee Request by ID for further employee creation

See service specification

Sample Request
Code Block
curl -X GET -H 'Content-Type: application/json' 'http://ehealth.nebo15.com/employee_requests/d290f1ee-6c54-4b01-90e6-d701748f0851'

Create user in Auth

Create user in Auth

Create/Update employee

...

  1. Search party_id by tax_id (tax_id or passport_number) and birth_date for deduplication Party

    1. If found, update object party - Update party WS

    2. If not found, - Create object party 

  2. Update Party.  See specification

    1. The following fields can't be changed:

      1. tax_id (tax_id or passport_number) 

      2. birth_date

    2. If doctor object in ER is null, don't update party.eductions/party.qualifications/party.specialities/party.science_degree. Otherwise update those objects.

    3. if about_myself/working_experience is null or empty string - don't update correspondent fields in parties.

  3. Create party WS. See specification

    1. create related entity party-user in PRM 

  4. Chech employee_id in request

    1. if employee_id is exist in request, Update employee.

    2. if  employee_id is not exist, Create employee.

  5. Update employee. See specification

    1. The following fields can't be changed:

      1. employee_type

      2. legal_entity_id

      3. start_date

    2. if employee_type = 'DOCTOR', 'SPECIALIST' or 'ASSISTANT' update doctor object

    3. if one of next fields were changed:

      1. first_name

      2. second_name

      3. last_name
        find contracts with contractor_owner_id=$owner_id and status='VERIFIED'. Set ops.contracts.is_suspended=true

  6. Create new employee. See specification

    1. If (employee_type = OWNER || employee_type = PHARMACY_OWNER) : deactivate all other records with the employee_type = OWNER
      or employee_type = PHARMACY_OWNER for the legal_entity,
      where new owner is creating:

Code Block
update employees e 
set is_active = false
inserted_by = $new_owner_id
inserted_at = md5(clock_timestamp()
where e.legal_entity_id = $employee_request.legal_entity_id
and (e.employee_type = 'OWNER' or e.employee_type = 'PHARMACY_OWNER')

In case new OWNER was added find contracts with contractor_owner_id=$old_owner_id and status='VERIFIED'.

Set ops.contracts.is_suspended=true

Create related entity party-user

Create related entity party-user

It can be only one pair user_id-party_id.

party_id cannot be updated for the user_id.

Check that there is no records in party_users for the stated in employee_request user_id

If not - return 422 error: "Email is already used by another person" 

Add role

Add user role by invoke service - название метода

Role is assigned according to employee_type

See service logic

See service specification

Sample Request
Code Block
curl -X POST -H 'Content-Type: application/json' -d '{
  "role": "doctor",
  "client_id": "b075f148-7f93-4fc2-b2ec-2d81b19a9b7b"
}' 'https://trump.herokuapp.com/admin/parties/b075f148-7f93-4fc2-b2ec-2d81b19a9b7b/add_role'

Update employee request status to APPROVED

Invoke WS to update employee request status with parameter 'action'='approve' 

See service specification

Sample Request
Code Block
curl -X PATCH -H 'Content-Type: application/json' 'http://ehealth.nebo15.com/employee_requests/b075f148-7f93-4fc2-b2ec-2d81b19a9b7b/actions/approve'

Send Email

Send email with successful registration using WS - Send Message (TBD)

Temporarily use Postmark

Response structure examples

See on API-specification

Expand
titleExample
Code Block
languagejson
{
  "meta": {
    "code": 200,
    "url": "https://example.com/resource",
    "type": "object",
    "request_id": "6617aeec-15e2-4d6f-b9bd-53559c358f97#17810"
  },
  "data": {}
}

HTTP status codes

Response code

HTTP Status code

Message

Internal name

Description

1

Базові

2

1000200

404 Response

Composition not found

COMPOSITION_NOT_FOUND_404

Не знайдено медичний висновок

3

401

Unauthorized

Помилка підтвердження

4

Специфічні

5

422

Only for active MPI record can be created medication request! 

3

 401

 

 Invalid scope

4

422

Email is already used by another person

 

5

Специфічні

6

Post-processing processes

Description of actions performed on data after processing

Technical modules where the method is used

List of pages describing technical N/A

Technical modules where the method is used

Page Properties Report
headingsID ТМ, Статус
cqllabel = "tr-mis"

...