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

Public. Approve Contract Request by MSP

 

Purpose

This WS is designed to change status of contract request to PENDING_NHS_SIGN by legal entity side. After the contract was approved by NHS side (status=APPROVED) MSP employee can change status of contract request and approve it from his side.

 

Specification

Link

https://ehealthmisapi1.docs.apiary.io/#reference/public.-contracts/contract-request/public.-approve-contract-request-by-msp

Resource

/api/contract_requests/{{contract_type}}/{{id}}/actions/approve_msp

Scope

contract_request:approve

Components

Contracts

Microservices

API paragraph not found

Protocol type

REST

Request type

PATCH

Sync/Async

Sync

Public/Private/Internal

Public

 

Logic

This WS is designed to approve contract request by MSP side after it was approved by NHS side. Contract request only in status APPROVED can be approved by MSP/PHARMACY and as a result status changes to 'PENDING_NHS_SIGN'. Only after that NHS employee can sign the contract request.

 

Input parameters

Input parameter

Values

Type

Description

Example

Input parameter

Values

Type

Description

Example

id

 

String

 

 

 

Authorize

Request to process the request using a token in the headers

 

Headers

Наприклад:

  • Content-Type:application/json

  • Authorization:Bearer c2778f3064753ea70de870a53795f5c9

 

Request data validation

Validate token

  • Verify the validity of access token

    • Return 401 in case validation fails

  • Check if token is not expired

    • in case error return 401 - "Token is expired"

Validate user

extract user_id from token

extract client_id from token

  • Check if user is active

    • in case error return 403 - (user is not active)

  • check contractor_legal_entity is active

    • in case error return 403 - (Client is not active)

  • Validate $client_id=contractor_legal_entity_id.

    • in case of error return 403 - Client is not allowed to modify contract_request

Validate scopes

  • Check user scopes in order to perform this action (scope = 'contract_requests:approve')

    • Return 403 in case invalid scope(s) "Your scope does not allow to access this resource. Missing allowances: contract_requests:approve"

Validate data

  1. Validate contract request id.

    1. Check contract_requests.id = $.id

      1. in case error return 404 ("Contract request with id=$id doesn't exist")

  2. Validate contract_request.status=APPROVED

    • in case error return 409 - "Incorrect status of contract request to modify it"

  3. Validate contractor_legal_entity_id

    1. Legal_entities.id = $.contractor_legal_entity_id and Legal_entities.status='ACTIVE' and  legal_entities.nhs_verified = true

      1. in case error return 422 ("Legal entity in contract request should be active")

  4. Validate contractor_owner_id

    1. Employee is_active=true and status='APPROVED' and employees.legal_entity_id=contractor_legal_entity_id

      1. in case error return 422, $contractor_owner_id (Contractor owner must be active within current legal entity in contract request)

  5. Validate contractor_divisions

    1. Check divisions belongs to legal_entity and divisions.status='active'

      1. in case of error return 422  error view $divisions ('Division must be active and within current legal_entity')

  6. For capitation only: Validate contractor_employee_divisions

    1. Employees from employee_divisions has employee_type='DOCTOR', status='APPROVED'

      1. in case of error return 422  error view $employee ('Employee must be an active DOCTOR')

    2. Check contractor_employee_divisions.division_id is present in contractor_divisions.id

      1. in case of error return 422 error $divisions ('The division is not belong to contractor_divisions')

  7. Validate start_date

    1. start_date > now()

      1. in case error return 422 $start_date ("Contract request start date should be in future")

         

  8. For reimbursement only: Validate medical_program_id is ACTIVE

 

Processing

Save response data to DB

set status='PENDING_NHS_SIGN'

Mapping

field

value

field

value

updated_by

 $.user_id

updated_at

 now()

status

 PENDING_NHS_SIGN

Add to event manager

After status was changed (status = APPROVED, DECLINED, PENDING_NHS_SIGN, TERMINATED or SIGNED) - add new status to event_manager

field

value

field

value

event_type

StatusChangeEvent

entity_type

Contract_request

entity_id

$.id

properties.status.new_value

$.status

event_time

$.update_at

changed_by

$.user_id

inserted_at

now()

updated_at

now()

 

Response structure

See on Apiary

Example:

{ "meta": { "code": 201, "url": "https://example.com/resource", "type": "object", "request_id": "req-adasdoijasdojsda" }, "data": { "id": "09106b70-18b0-4726-b0ed-6bda1369fd52", "contract_type": "CAPITATION", "contractor_legal_entity": { "id": "df9f70ee-4b12-4740-b0f5-bb5aea116863", "name": "Клініка Ноунейм", "edrpou": "32323454", "addresses": [ { "type": "RESIDENCE", "country": "UA", "area": "Житомирська", "region": "Бердичівський", "settlement": "Київ", "settlement_type": "CITY", "settlement_id": "b075f148", "street_type": "STREET", "street": "вул. Ніжинська", "building": "15", "apartment": "23", "zip": "02090" } ] }, "contractor_owner": { "id": "b075f148-7f93-4fc2-b2ec-2d81b19a9b7b", "party": { "first_name": "Петро", "last_name": "Іванов", "second_name": "Миколайович" } }, "contractor_base": "на підставі закону про Медичне обслуговування населення", "contractor_payment_details": { "bank_name": "Банк номер 1", "MFO": "351005", "payer_account": "32009102701026" }, "contractor_rmsp_amount": 50000, "contractor_divisions": [ { "id": "2922a240-63db-404e-b730-09222bfeb2dd", "name": "Бориспільське відділення Клініки Ноунейм", "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" } ], "email": "email@example.com", "working_hours": { "mon": [ [ "08.00", "12.00" ], [ "14.00", "18.00" ] ], "tue": [ [ "08.00", "12.00" ] ], "wed": [ [ "08.00", "12.00" ] ], "thu": [ [ "08.00", "12.00" ] ], "fri": [ [ "08.00", "12.00" ] ] }, "mountain_group": false } ], "contractor_employee_divisions": [ { "employee": { "id": "b075f148-7f93-4fc2-b2ec-2d81b19a9b7b", "party": { "first_name": "Петро", "last_name": "Іванов", "second_name": "Миколайович" }, "speciality": { "speciality": "THERAPIST", "speciality_officio": true, "level": "FIRST", "qualification_type": "AWARDING", "attestation_name": "Академія Богомольця", "attestation_date": "2017-02-28", "valid_to_date": "2020-02-28", "certificate_number": "AB/21331" } }, "staff_units": 0.5, "declaration_limit": 2000, "division_id": "2922a240-63db-404e-b730-09222bfeb2dd" } ], "external_contractor_flag": true, "external_contractors": [ { "legal_entity": { "id": "b075f148-7f93-4fc2-b2ec-2d81b19a9b7b", "name": "Клініка Ноунейм" }, "contract": { "number": "1234567", "issued_at": "2018-01-01", "expires_at": "2019-01-01" }, "divisions": [ { "id": "2922a240-63db-404e-b730-09222bfeb2dd", "name": "Бориспільське відділення Клініки Ноунейм", "medical_service": "Послуга ПМД" } ] } ], "id_form": "PMD_1", "nhs_signer": { "id": "b075f148-7f93-4fc2-b2ec-2d81b19a9b7b", "party": { "first_name": "Петро", "last_name": "Іванов", "second_name": "Миколайович" } }, "nhs_legal_entity": { "id": "df9f70ee-4b12-4740-b0f5-bb5aea116863", "name": "Клініка Ноунейм", "edrpou": "32323454", "addresses": [ { "type": "RESIDENCE", "country": "UA", "area": "Житомирська", "region": "Бердичівський", "settlement": "Київ", "settlement_type": "CITY", "settlement_id": "b075f148", "street_type": "STREET", "street": "вул. Ніжинська", "building": "15", "apartment": "23", "zip": "02090" } ] }, "nhs_signer_base": "на підставі наказу", "nhs_contract_price": 50000, "nhs_payment_method": "BACKWARD", "status": "NEW", "status_reason": "Не відповідає попереднім домовленостям", "issue_city": "Київ", "contract_number": "0000-9EAX-XT7X-3115", "contract_id": "df9f70ee-4b12-4740-b0f5-bb5aea116863", "parent_contract_id": "22e416c4-5747-41cd-9f73-c3a85cdee885", "start_date": "2017-04-20", "end_date": "2017-04-20", "printout_content": "Contract request content", "previous_request_id": "df9f70ee-4b12-4740-b0f5-bb5aea116863", "assignee_id": "22e416c4-5747-41cd-9f73-c3a85cdee885" } }

 

{ "meta": { "code": 201, "url": "https://example.com/resource", "type": "object", "request_id": "req-adasdoijasdojsda" }, "data": { "id": "09106b70-18b0-4726-b0ed-6bda1369fd52", "contract_type": "REIMBURSEMENT", "contractor_legal_entity": { "id": "df9f70ee-4b12-4740-b0f5-bb5aea116863", "name": "Клініка Ноунейм", "edrpou": "32323454", "addresses": [ { "type": "RESIDENCE", "country": "UA", "area": "Житомирська", "region": "Бердичівський", "settlement": "Київ", "settlement_type": "CITY", "settlement_id": "b075f148", "street_type": "STREET", "street": "вул. Ніжинська", "building": "15", "apartment": "23", "zip": "02090" } ] }, "contractor_owner": { "id": "b075f148-7f93-4fc2-b2ec-2d81b19a9b7b", "party": { "first_name": "Петро", "last_name": "Іванов", "second_name": "Миколайович" } }, "contractor_base": "на підставі закону про Медичне обслуговування населення", "contractor_payment_details": { "bank_name": "Банк номер 1", "MFO": "351005", "payer_account": "32009102701026" }, "id_form": "RMB-1", "nhs_signer": { "id": "b075f148-7f93-4fc2-b2ec-2d81b19a9b7b", "party": { "first_name": "Петро", "last_name": "Іванов", "second_name": "Миколайович" } }, "nhs_legal_entity": { "id": "df9f70ee-4b12-4740-b0f5-bb5aea116863", "name": "Клініка Ноунейм", "edrpou": "32323454", "addresses": [ { "type": "RESIDENCE", "country": "UA", "area": "Житомирська", "region": "Бердичівський", "settlement": "Київ", "settlement_type": "CITY", "settlement_id": "b075f148", "street_type": "STREET", "street": "вул. Ніжинська", "building": "15", "apartment": "23", "zip": "02090" } ] }, "nhs_signer_base": "на підставі наказу", "nhs_contract_price": 50000, "nhs_payment_method": "BACKWARD", "status": "NEW", "status_reason": "Не відповідає попереднім домовленостям", "issue_city": "Київ", "contract_number": "0000-9EAX-XT7X-3115", "contract_id": "df9f70ee-4b12-4740-b0f5-bb5aea116863", "parent_contract_id": "22e416c4-5747-41cd-9f73-c3a85cdee885", "start_date": "2017-04-20", "end_date": "2017-04-20", "printout_content": "Contract request content", "previous_request_id": "df9f70ee-4b12-4740-b0f5-bb5aea116863", "assignee_id": "22e416c4-5747-41cd-9f73-c3a85cdee885", "medical_programs": [ "3914a240-63db-404e-b730-09222bfeb2d0" ] } }

 

HTTP status codes

HTTP status code

Message

What caused the error

HTTP status code

Message

What caused the error

 200

 

 

 

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