ЕСОЗ - публічна документація
RC_[NEW] [Trembita API] Cancel Device Dispense Preparation
Overview
This method is designed to cancel preparation of device dispense via Trembita.
Request
URL: min_sp/device_dispenses/actions/cancel
Method: PATCH
Headers
Header | Type | Required |
---|---|---|
Uxp-Client | string | True |
Uxp-Service | string | True |
Uxp-Transaction-Id | string | True |
Body
Element | Type | Description | M/O | |
---|---|---|---|---|
1 | id | uuid | Unique Device Dispense identifier | M |
2 | subject | Reference to Patient | M | |
3 | status | string | Always set in | M |
4 | status_reason | dictionary DEVICE_DISPENSE_PREPARATION_CANCELLATION_REASON | M |
Validations
Validate headers
Check that header
Uxp-Client
exists and is not emptyin case of error - generate response with code 400:
$Response.error.type = “bad_request“
$Response.error.code = “1008”
$Response.error.message = “Missed Uxp-Client header”
Check that header
Uxp-Service
exists and is not emptyin case of error - generate response with code 400:
$Response.error.type = “bad_request“
$Response.error.code = “1009”
$Response.error.message = “Missed Uxp-Service header”
Check that header
Uxp-Transaction-Id
exists and is not emptyin case of error - generate response with code 400:
$Response.error.type = “bad_request“
$Response.error.code = “1010”
$Response.error.message = “Missed Uxp-Transaction-Id header”
Check that header
Uxp-Client
contains 4 strings that are separated by/
symbolin case of error - generate response with code 400:
$Response.error.type = “bad_request“
$Response.error.code = “1011”
$Response.error.message = “Invalid Uxp-Client format”
Check that header
Uxp-Service
contains 4 or 5 strings that are separated by/
symbolin case of error - generate response with code 400:
$Response.error.type = “bad_request“
$Response.error.code = “1012”
$Response.error.message = “Invalid Uxp-Service format”
Validate JSON Schema
Validate request according to JSON Schema (validate status=
cancelled
, validate status_reason is an active value from DEVICE_DISPENSE_PREPARATION_CANCELLATION_REASON dictionary)in case of errors generate response with code 422
$Response.error.type = “validation_failed“
$Response.error.code = “1013” “0000013”
$Response.error.message = “Request structure error”
$Response.error.invalid = {{json_schema_errors}}
Validate device dispense existence
Check that Device Dispense with submitted id exists for submitted Patient
in case of errors return code 422
$Response.error.type = “validation_failed“
$Response.error.code = “1014” “0070014”
$Response.error.message = “Device Dispense not found”
Validate external performer
Parse
Uxp-Client
header using pattern<client_instance>/<client_member_class>/<client_member_code>/<client_subsystem_code>
Check that device_dispense.external_performer = {{client_member_code}}(from
Uxp-Client
header)in case of an error update job with code 409
$Response.error.type = “conflict“
$Response.error.code = “1015” “0070015”
$Response.error.message = “Can not cancel Device Dispense created by another legal entity”
Validate transition
Check that device_dispense.status =
preparation
in case of an error update job with code 422
$Response.error.type = “validation_failed“
$Response.error.code = “1016” “0070016”
$Response.error.message = “Device Dispense in status <status> cannot be cancelled”
For more information look at https://e-health-ua.atlassian.net/wiki/spaces/REHABILIT/pages/18431246460/UPD+Device+dispense+status+model.
Service logic
Parse
Uxp-Client
header using pattern<client_instance>/<client_member_class>/<client_member_code>/<client_subsystem_code>
Parse
Uxp-Service
header using patter<service_instance>/<service_member_class>/<service_member_code>/<service_subsystem_code>/<service_service_code>[/<service_service_version>]
<service_service_version> - optional parameter
Save parsed headers (
Uxp-Client
,Uxp-Service
,Uxp-transaction-Id
), request body, response body, job_id to Trembita Integration LayerUpdate Device Dispense
updated_at = {{current_date_time}}
updated_by = {{trembita_user_id}}
status = cancelled
status_reason = {{request.status_reason}}
Send
StatusChangeEvent
to Event ManagerUpdate job
Response
Job
Element | Type | Description | M/O | |
---|---|---|---|---|
1 | status | string |
| M |
2 | eta | eta |
| O |
3 | links | [link] |
| O |
link
Element | Type | Description | M/O | |
---|---|---|---|---|
1 | entity | string |
| M |
2 | href | string |
| M |
Error codes
Code | Message |
---|---|
1001 | No active person found |
1008 | Missed Uxp-Client header / Invalid Uxp-Client format |
1009 | Missed Uxp-Service header / Invalid Uxp-Service format |
1010 | Missed Uxp-Transaction-Id header |
1011 | Invalid Uxp-Client format |
1012 | Invalid Uxp-Service format |
0070014 | Device Dispense not found |
0070015 | Can not cancel Device Dispense created by another legal entity |
0070016 | Device Dispense in status <status> cannot be cancelled |
ЕСОЗ - публічна документація