ЕСОЗ - публічна документація
Will be DEPRECATED_Get Medication request by ID
- 1 Purpose
- 2 Specification
- 3 Logic
- 4 Preconditions
- 5 Global and configurable parameters
- 6 Input parameters
- 7 Filters
- 8 Request structure
- 9 Authorize
- 10 Headers
- 11 Validate request
- 12 Request data validation
- 12.1 Search Medication Request
- 12.2 Validate FK
- 13 Processing
- 14 Response structure
- 15 Post-processing processes
- 16 HTTP status codes
- 17 Backward compatibility
Purpose
This WS is designed to return Medication request detail.
Search Medication Request possible in 2 options: by `medication_request.id` OR `medication_request.request_number`.
According to requirements:
A user of MSP, PRIMARY_CARE, OUTPATIENT (DOCTOR, SPECIALIST, etc) can see all Medication request from the user's legal entity.
A user of MSP, PRIMARY_CARE (DOCTOR, etc) can see all the Medication requests of the patients whom he has an active declaration with by yourself a doctor (employee_id).
Users of PHARMACY can see all Medication requests (without limitations).
Users of MSP, PRIMARY_CARE, OUTPATIENT (DOCTOR, SPECIALIST, etc) can see all Medication requests based on the approval of the care plan that is contained in the Medication request.
Specification
Link | Посилання на Apiary або Swagger | |
Resource | /api/medication_requests/{{id}} | Посилання на ресурс, наприклад: /api/persons/create |
Scope | medication_request:details | Scope для доступу |
Components | ePrescription | Зазначається перелік бізнес компонентів, які використовують цей метод, наприклад: ePrescription |
Microservices | API paragraph not found | Перелік мікросервісів, які використовує метод API, наприклад: Auth, ABAC |
Protocol type | REST | Тип протоколу, який використовується запитом, наприклад: SOAP | REST |
Request type | GET | Тип запиту API, наприклад: GET, POST, PATCH… |
Sync/Async | Sync | Метод є синхронним чи асинхронним? |
Public/Private/Internal | Public |
|
Logic
Verify the validity of access token
Return 401 in case validation fails
Check user scopes in order to perform this action (scope = 'medication_request:details')
Return 403 in case invalid scope(s)
Get `client_type` from `mithril.clients`
Get `my_party_id` from `$.context.user_id`
Get list from `prm.employees` for this `party_id` & `$.context.legal_entity_id`
Search Medication requests by filters:
SELECT * FROM medication_request MR INNER JOIN employees E ON E.party_id = my_party_id AND (E.id = $.employee_id OR $.employee_id IS NULL) AND (E.legal_entity_id == $.context.legal_entity_id OR $.context.legal_entity_id IS NULL) LEFT JOIN declarations D ON D.Employee_id = E.id AND E.status = ACTIVE AND D.status = ACTIVE AND MR.person_id = D.person_id WHERE (MR.id = $.id OR MR.request_number = $.id) AND MR.employee_id == E.id AND MR.is_active = TRUE
Logic WS for medication requests based on care plan
Get party_id from $.context.user_id
Get list from $.prm.employees for this party_id
Get care_plan_id from $.medication_requests.based_on_care_plan_id
Check $.approvals for user's employees (granted_to) on care_plan_id (granted_resources) and $.medication_requests.person_id (granted_by)
Search Medication requests by filters: based_on_care_plan_id, person_id.
SELECT * FROM medication_request MR WHERE (MR.id = $.id OR MR.request_number = $.id) AND MR.based_on_care_plan_id = $.id AND MR.person_id = $.id AND MR.is_active = TRUE
Logic WS for `client_type` = PHARMACY
Search Medication request by $.id:
SELECT * FROM medication_request MR WHERE (MR.id = $.id OR MR.request_number = $.id) AND MR.is_active = TRUE
Preconditions
No
Global and configurable parameters
No
Input parameters
Input parameter | Values | Type | Description | Example |
---|---|---|---|---|
id |
| String | Medication Request identifier OR request_number. Required. | 48416485-cc98-46c4-8bba-e321de9e1ecd |
Filters
No
Request structure
API paragraph not found
Authorize
API paragraph not found
Headers
Content-Type:application/json
Authorization:Bearer c2778f3064753ea70de870a53795f5c9
Validate request
API paragraph not found
Request data validation
Search Medication Request
Search record by `$.id` in column `medication_request.id`
If not found - Search record by `$.id` in column `medication_request.request_number`
If not found - Return 404 in case "Not found"
Validate FK
Read data from `ops.medication_requests` by `id`
Validate legal_entity_id - legal_entity_id exists
Return 422 in case validation fails (422 EView)
Validate employee_id - employee_id exists
Return 422 in case validation fails (422 EView)
Validate division_id - division_id exists
Return 422 in case validation fails (422 EView)
Validate medical_program_id - medical_program_id exists
Return 422 in case validation fails (422 EView)
Validate all medication_id - medication_id exists
Return 422 in case validation fails (422 EView)
Validate person_id - mpi_id exists
Return 422 in case validation fails (422 EView)
Processing
API paragraph not found
Response structure
Return object with response structure from WS Sign Medication request Request.
Calculate medication remaining quantity:
Select all Medication Dispenses in status PROCESSED related to the Medication Request
Sum medication_qty in the filtered Medication Dispenses as dispensed_qty
Calculate medication_remaining_qty = medication_qty - dispensed_qty
Return medication_remaining_qty in the response
Example:
Post-processing processes
No
HTTP status codes
HTTP status code | Message | What caused the error |
---|---|---|
200 | Response |
|
401 | Invalid access token |
|
403 | Invalid scope |
|
422 | Validation fails |
|
Backward compatibility
API paragraph not found
ЕСОЗ - публічна документація