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

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

Header

Type

Required

Uxp-Client

string

True

Uxp-Service

string

True

Uxp-Transaction-Id

string

True

Body

 Element

Type

Description

M/O

 Element

Type

Description

M/O

1

id

uuid

Unique Device Dispense identifier

M

2

subject

{Reference}

Reference to Patient

M

3

status

string

Always set in cancelled

M

4

status_reason

CodeableConcept

dictionary DEVICE_DISPENSE_PREPARATION_CANCELLATION_REASON

M

Validations

Validate headers

  1. Check that header Uxp-Client exists and is not empty

    1. in case of error - generate response with code 400:

      • $Response.error.type = “bad_request“

      • $Response.error.code = “1008”

      • $Response.error.message = “Missed Uxp-Client header”

  2. Check that header Uxp-Service exists and is not empty

    1. in case of error - generate response with code 400:

      • $Response.error.type = “bad_request“

      • $Response.error.code = “1009”

      • $Response.error.message = “Missed Uxp-Service header”

  3. Check that header Uxp-Transaction-Id exists and is not empty

    1. in 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”

  4. Check that header Uxp-Client contains 4 strings that are separated by / symbol

    1. in case of error - generate response with code 400:

      • $Response.error.type = “bad_request“

      • $Response.error.code = “1011”

      • $Response.error.message = “Invalid Uxp-Client format”

  5. Check that header Uxp-Service contains 4 or 5 strings that are separated by / symbol

    1. in 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

  1. Validate request according to JSON Schema (validate status= cancelled, validate status_reason is an active value from DEVICE_DISPENSE_PREPARATION_CANCELLATION_REASON dictionary)

    1. in case of errors generate response with code 422

      1. $Response.error.type = “validation_failed“

      2. $Response.error.code = “1013” “0000013”

      3. $Response.error.message = “Request structure error”

      4. $Response.error.invalid = {{json_schema_errors}}

Validate device dispense existence

  1. Check that Device Dispense with submitted id exists for submitted Patient

    1. in case of errors return code 422

      1. $Response.error.type = “validation_failed“

      2. $Response.error.code = “1014” “0070014”

      3. $Response.error.message = “Device Dispense not found”

Validate external performer

  1. Parse Uxp-Client header using pattern <client_instance>/<client_member_class>/<client_member_code>/<client_subsystem_code>

  2. Check that device_dispense.external_performer = {{client_member_code}}(from Uxp-Client header)

    1. in case of an error update job with code 409

      1. $Response.error.type = “conflict“

      2. $Response.error.code = “1015” “0070015”

      3. $Response.error.message = “Can not cancel Device Dispense created by another legal entity”

Validate transition

  1. Check that device_dispense.status = preparation

    1. in case of an error update job with code 422

      1. $Response.error.type = “validation_failed“

      2. $Response.error.code = “1016” “0070016”

      3. $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

  1. Parse Uxp-Client header using pattern <client_instance>/<client_member_class>/<client_member_code>/<client_subsystem_code>

  2. Parse Uxp-Service header using patter <service_instance>/<service_member_class>/<service_member_code>/<service_subsystem_code>/<service_service_code>[/<service_service_version>]

    1. <service_service_version> - optional parameter

  3. Save parsed headers (Uxp-Client, Uxp-Service, Uxp-transaction-Id), request body, response body, job_id to Trembita Integration Layer

  4. Update Device Dispense

    1. updated_at = {{current_date_time}}

    2. updated_by = {{trembita_user_id}}

    3. status = cancelled

    4. status_reason = {{request.status_reason}}

  5. Send StatusChangeEvent to Event Manager

  6. Update job

Response

Job

 Element

Type

Description

M/O

 Element

Type

Description

M/O

1

status

string

 

M

2

eta

eta

 

O

3

links

[link]

 

O

link

 Element

Type

Description

M/O

 Element

Type

Description

M/O

1

entity

string

 

M

2

href

string

 

M

Error codes

Code

Message

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

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