ЕСОЗ - публічна документація
RC_[NEW] [Trembita API] Update Device Dispense
Overview
This API method is designed to update Device Dispense's information when it becomes completed.
Request
URL: min_sp/device_dispenses/actions/update
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 | payment_amount | float | Must be greater than 0 | O |
5 | when_handed_over | date |
| 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=
completed
, sell_price and payment_amount are greater than 0)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” “0060014”
$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” “0060015”
$Response.error.message = “Can not complete Device Dispense created by another legal entity”
Validate subject verification status
Search for Person's merged person
in case empty response returned or person is a master person check person verification status is not equal to
NOT_VERIFIED
in case of error update job with code 409:
$Response.error.type = “conflict“
$Response.error.code = “1030” “0060030”
$Response.error.message = “Person is not verified”
else, in case person is a merged person, validate master person verification status is not equal to
NOT_VERIFIED
in case of error update job with code 409:
$Response.error.type = “conflict“
$Response.error.code = “1030” “0060030”
$Response.error.message = “Person is not verified”
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” “0060016”
$Response.error.message = “Device Dispense in status <status> cannot be completed”
For more information look at https://e-health-ua.atlassian.net/wiki/spaces/REHABILIT/pages/18431246460/UPD+Device+dispense+status+model.
Validate request
Check that when_handed_over is greater or equal to device_request.authored_on and less or equal to current date
in case of error update job with code 422:
$Response.error.type = “validation_failed“
$Response.error.code = “1017” “0060017”
$Response.error.message = “Invalid dispense period”
Check that device_request.status is
active
in case of error update job with code 422:
$Response.error.type = “validation_failed“
$Response.error.code = “0060019”
$Response.error.message = “Device Request is not active”
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 = completed
when_handed_over = request.when_handed_over
payment_amount = request.payment_amount
sell_price = request.sell_price
If related Device Request has a reference on Activity as device_request.based_on, then
add reference on the Device Dispense resource to the outcome_reference attribute of the related Activity
if Activity.status is
scheduled
change it toin_progress
If there is quantity specified in the Device Request:
calculate remaining_quantity of the related Device Request:
Select all Device Dispenses with following parameters:
based_on is current Device Request
status =
completed
Sum quantity in the filtered Device Dispenses as dispensed_qty
Calculate remaining_quantity = device_request.quantity- dispensed_quantity
If remaining_quantity is equal to device_dispense.details.quantity, change status of the related Device Request($.based_on) to
completed
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 |
1013 | Request structure error |
0060014 | Device Dispense not found |
0060015 | Can not complete Device Dispense created by another legal entity |
0060016 | Device Dispense in status <status> cannot be completed |
0060017 | Invalid dispense period |
0060018 | Person is not verified |
0060019 | Device Request is not active |
ЕСОЗ - публічна документація