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

[DRAFT] Get Medication requests [API-005-008-002-0154]

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

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

[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-008-002-0154

Microservices (namespace)

IL

Component

ePrescription

Component ID

COM-005-008

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

https://ehealthmisapi1.docs.apiary.io/#reference/public.-reimbursement/medication-request/get-medication-requests

Resource

{{host}}/api/medication_requests

Scope

medication_request:read

Protocol type

REST

Request type

GET

Sync/Async

Sync

Public/Private

Public

Purpose

This WS is designed to search (get list) for(of) Medication requests.

According to requirements:

  • User can see all Medication Requests of which he is an author

  • User of MSP, PRIMARY_CARE, OUTPATIENT (DOCTOR, SPECIALIST, etc) can see all Medication requests from the user's legal entity

  • DOCTOR can see all the Medication requests of the patients whom he has an active declaration with doctor (employee_id) 

  • User of NHS_ADMIN can see all Medication requests (without limitations)

  • User of MSP, PRIMARY_CARE, OUTPATIENT (DOCTOR, SPECIALIST, etc) can see all Medication request based on the approval of the care plan that is contained in the Medication request

Logic

Logic WS

  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 = 'medication_request:read')

    1. Return 403 in case invalid scope(s)

  3. Get `my_party_id`  from `$.context.user_id`

    1. Return 500 in case ("Not found party for this user!")  

  4. Get list of employees to `my_employees_list` for this `party_id`  & `$.context.legal_entity_id`

    SELECT E.id FROM parties P JOIN employees E ON P.id = E.party_id JOIN party_users PU ON parties.id = party_users.party_id WHERE PU.user_id=$.context.user_id AND E.legal_entity_id = $.context.legal_entity.id

     

  5. Search Medication requests by filters with use `my_employees_list` : 

    SELECT * FROM medication_request MR LEFT JOIN declarations D ON MR.person_id = D.person_id AND D.status = ACTIVE WHERE (MR.employee_id IN [my_employees_list] OR D.employee_id IN [my_employees_list] ) AND (MR.status = $.status OR $.status IS NULL) AND (MR.person_id = $.person_id OR $.person_id IS NULL) AND (MR.medication_id = $.medication_id OR $.medication_id IS NULL) AND (MR.number = $.request_number OR $.request_number IS NULL) AND (MR.created_at >= $.created_from OR $.created_from IS NULL) AND (MR.created_at <= $.created_to OR $.created_to IS NULL)

     

Logic WS for `client_type` = NHS_ADMIN

  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 = 'medication_request:read')

      1. Return 403 in case invalid scope(s)

    3. Search Medication requests by filters: 

      SELECT * FROM medication_request MR WHERE AND (MR.employee_id == $.employee_id OR $.employee_id IS NULL) AND (MR.status == $.status OR $.status IS NULL) AND (MR.person_id == $.person_id OR $.person_id IS NULL) AND (MR.medication_id = $.medication_id OR $.medication_id IS NULL) AND (MR.number = $.request_number OR $.request_number IS NULL) AND (MR.created_at >= $.created_from OR $.created_from IS NULL) AND (MR.created_at <= $.created_to OR $.created_to IS NULL) AND (MR.legal_entity_id == $.legal_entity_id OR $.legal_entity_id IS NULL)

 

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

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

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

  1. If according to filters requests are not found, WS returns empty data array:

    1. WS also returns pagination data - for technical info.

Response structure examples

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

Description of the REST API response structure, example

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

Invalid access token

 

 

4

 

401

Unauthorized

 

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

5

 

403

Your scope does not allow to access this resource. Missing allowances: medication_request_request:read

 

 

6

1000

404

Composition not found

COMPOSITION_NOT_FOUND_404

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

7

 

500

Not found party for this user!

 

 

8

Специфічні

9

 

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

 

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