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

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 4 Next »

REST API method / Метод REST API (настанова) (remove the link block before publishing the document)

Properties of a REST API method document

Document type

Метод REST API

Document title

[Document status] REST API [Назва методу] [ID методу]

Guideline ID

GUI-0011

Author

@

Document version

1

Document status

DRAFT

Date of creation

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

Date of update

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

Method API ID

API-005-001-001-0017

Microservices (namespace)

IL

Component

Contract reports

Component ID

COM-005-001

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

https://ehealthmisapi1.docs.apiary.io/#reference/public.-reimbursement/reimbursement-report/get-reimbursement-report

Resource

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

Scope

reimbursement_report:read

Protocol type

REST

Request type

GET

Sync/Async

Sync

Public/Private

Public

Purpose

This method is designed to create reimbursement report which is based on Medication request and Medication dispense data. 

Logic

The access and ability to create and get the report have

  1. MSP (OWNER)

  2. PHARMACY (PHARMACY_OWNER)

To get the report the creator must input requested period (date_from_request, date_to_request, date_from_dispense, date_to based on date of dispense or request). In response will be received the json with data.

  • OWNER will receive info only about Medication Requests which were made by his legal_entity and corresponding Medication Dispenses.

  • PHARMACY_OWNER is allowed to view only info related to Medication Dispenses which were made by his PHARMACY and corresponding Medication Requests.

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 parameters

Input parameter

Mandatory

Type

Description

Example

1

composition_id

 M

String ($uuid) (path)

Composition object ID

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

2

Request structure

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

Description of the REST API request structure, example

 Example
 

Headers

Key

Value

Mandatory

Description

Example

1

Content-Type

application/json

M

Тип контенту

Content-Type:application/json

2

Authorization

Bearer c2778f3064753ea70de870a53795f5c9

M

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

Authorization:Bearer c2778f3064753ea70de870a53795f5c9

3

Request data validation

Get legal entity from token

  1. Extract legal_entity_id (client_id) from token

Get Party from token

  1. Extract party_user (user_id) from token.

Validate FK

  1. Validate 

legal_entity_id - legal_entity_id exists (for MSP and PHARMACY)

In case error - return 422 error:

{:error, [{%{
        description: "Legal entity not found",
        params: [],
        rule: :invalid
      }, "$.legal_entity_id"}]}
  1. Validate 

party_id - party_id exists

{:error, [{%{ 
        description: "Party not found",
        params: [],
        rule: :invalid
      }, "$.party_id"}]}

 

  1. Validate

legal_enity type - type [MSP, PHARMACY]

In case of error - show 403 error ('Legal_entity type is not allowed to get the report')

Validate statuses

  1. Legal entity should be active in order to create report

    • is_active = true

    • status = 'ACTIVE'

    • in case of error show 403 error ('Legal entity is not active')

  2. Party should refer to active employee in current legal_entity

    • employees.is_active = true

    • employees.status = 'APPROVED'

    • employees.legal_entity_id = client_id (context)

    • in case of error show 403 error ('Employee is not active')

Validate input dates

  1. There is 4 available dates for the filtering: by dispense or/and by request. At least one pair of those dates must be not empty.

          In case of error show 422 error with message must be shown (date_from_request:  "At least one of input dates must be not empty")

  1. Validate input date_from and date_to

    • if date_from_request is not null then: date_from_request<=date_to_request and date_to_request must be filled

      in case of error - return 422 error:

      {:error, [{%{
              description: "Input dates are not valid",
              params: [],
              rule: :invalid
            }, "$.date_from_request"}]}

       

  2. if date_from_dispense is not null then: date_from_dispense<=date_to_dispense and date_to_dispense must be filled

    in case of error - return 422 error:

    {:error, [{%{
            description: "Input dates are not valid",
            params: [],
            rule: :invalid
          }, "$.date_from_dispense"}]}

     

    Input dates filter the field: 

    • date_from_request/date_to_request comparing to field medication_requests.created_at

    • date_from_dispense/date_to_dispense comparing to field medication_dispenses.dispensed_at

If there is no data available for the requested period of time in response must be sent empty json, no error is shown. 

Processing

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

Response structure examples

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

Description of the REST API response structure, example

 Example
{
  "meta": {
    "code": 200,
    "url": "https://example.com/resource",
    "type": "object",
    "request_id": "6617aeec-15e2-4d6f-b9bd-53559c358f97#17810"
  },
  "data": [
    {
      "medication_request": {
        "created_at": "2017-08-17",
        "started_at": "2017-08-17",
        "ended_at": "2017-09-16",
        "dispense_valid_from": "2017-08-17",
        "dispense_valid_to": "2017-09-16",
        "rejected_at": "2017-04-20T19:14:13Z",
        "rejected_by": "2922a240-63db-404e-b730-09222bfeb2dd",
        "person_id": "b075f148-7f93-4fc2-b2ec-2d81b19a9b7b",
        "employee": {
          "id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
          "party_id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
          "last_name": "Іванов",
          "first_name": "Петро",
          "second_name": "Миколайович",
          "position": "P6",
          "employee_type": "DOCTOR"
        },
        "medical_program": {
          "id": "c7d52544-0bd4-4129-97b0-2d72633e0490",
          "name": "Доступні ліки",
          "mr_blank_type": "F-1"
        },
        "medication": {
          "name": "Амідарон",
          "type": "MEDICATION",
          "manufacturer": {
            "name": "ПАТ \"Київський вітамінний завод\"",
            "country": "UA"
          },
          "form": "PILL",
          "container": {
            "numerator_unit": "PILL",
            "numerator_value": 1,
            "denumerator_unit": "PILL",
            "denumerator_value": 1
          },
          "form_pharm": "DISPERSIBLE_TABLET",
          "drlz_sku_id": "0404466792737630283703997321"
        },
        "medication_qty": 10.34,
        "id": "f08ba3a3-157a-4adc-b65d-737f24f3a1f4",
        "dispensed_at": "2017-08-17",
        "dispensed_by": "Аннова Анна Анновна",
        "status": "NEW",
        "medications": [
          {
            "id": "b075f148-7f93-4fc2-b2ec-2d81b19a9b7b",
            "code_atc": [
              "М01АЕ01",
              "C01BD01"
            ],
            "name": "Амідарон",
            "type": "MEDICATION",
            "manufacturer": {
              "name": "ПАТ \"Київський вітамінний завод\"",
              "country": "UA"
            },
            "form": "PILL",
            "container": {
              "numerator_unit": "PILL",
              "numerator_value": 1,
              "denumerator_unit": "PILL",
              "denumerator_value": 1
            },
            "form_pharm": "DISPERSIBLE_TABLET",
            "drlz_sku_id": "0404466792737630283703997321",
            "package_qty": 30,
            "details": {
              "medication_qty": 10.34,
              "sell_price": 18.65,
              "sell_amount": 186.5,
              "discount_amount": 150,
              "reimbursement_amount": 450
            }
          }
        ],
        "legal_entity": {
          "id": "b075f148-7f93-4fc2-b2ec-2d81b19a9b7b",
          "name": "Аптека 42",
          "edrpou": "5432345431"
        },
        "division": {
          "id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
          "name": "Бориспільське відділення Аптеки 42",
          "mountain_group": false,
          "address": {
            "type": "RESIDENCE",
            "country": "UA",
            "area": "Житомирська",
            "region": "Бердичівський",
            "settlement": "Київ",
            "settlement_type": "CITY",
            "settlement_id": "b075f148",
            "street_type": "STREET",
            "street": "вул. Ніжинська",
            "building": "15",
            "apartment": "23",
            "zip": "02090"
          }
        },
        "party": {
          "id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
          "last_name": "Іванов",
          "first_name": "Петро",
          "second_name": "Миколайович"
        }
      }
    }
  ],
  "paging": {
    "page_number": 2,
    "page_size": 50,
    "total_entries": 1000,
    "total_pages": 23
  }
}

HTTP status codes

Response code

HTTP Status code

Message

Internal name

Description

1

Базові

2

1000

 200

 Response

 

 200

3

 401

 

 Access token validation failed

 401

4

403

  • Invalid scope

  • Legal_entity type is not allowed to get the report

  • Legal entity is not active

  • Employee is not active

 

403

5

422

 

Validation failed

422

6

Специфічні

7

422

Only for active MPI record can be created medication request!

Post-processing processes

Description of actions performed on data after processing

Technical modules where the method is used

List of pages describing technical modules where the method is used

  • No labels