Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Info

REST API method / Метод REST API (настанова) (remove the link block before publishing the document)

...

Page Properties
idpage_properties_method_REST API

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-0145

Microservices (namespace)

IL

Component

ePrescription

Component ID

COM-005-008

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

https://ehealthmisapi1.docs.apiary.io/#reference/public.-reimbursement/medication-request/qualify-medication-request-by-id

Resource

{{host}}/api/medication_requests/{{id}}/actions/qualify

Scope

medication_request:details

Protocol type

REST

Request type

POST

Sync/Async

Sync

Public/Private

Public

...

MR should be found by number

Configuration parameters

Description of the configuration parameters that are used when processing a request in the system

Dictionaries

  • MEDICATION_FORM

  • COUNTRY

  • MEDICATION_UNIT

Input parameters

Description of input parameters

Input parameter

Mandatory

Type

Description

Example

1

id

 M

String

Medication request identifier

2848a935-5fd7-48ba-b235-a9b5d475c647

Request structure

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

Description of the REST API request structure, example

Expand
titleExample
Code Block
{
  "division_id": "2848a935-5fd7-48ba-b235-a9b5d475c647",
  "programs": [
    {
      "id": "59781de0-2e64-4359-b716-bcc05a32c10f"
    }
  ]
}

Headers

...

Key

...

Value

...

Mandatory

...

Description

...

Example

...

Content-Type

...

application/json

...

M

...

Тип контенту

...

Content-Type:application/json

...

Authorization

...

Bearer 2778f3064753ea70de870a53795f5c9

...

M

...

Перевірка користувача

...

Authorization:Bearer 2778f3064753ea70de870a53795f5c9

...

Request data validation

Authorize

...

  1. Verify Care plan:

    1. It should be in active status

      1. in case of error - return 409 (message: "Invalid care plan status").

    2. Care plan's period end (if exist) should be greater than current date or equal

      1. in case of error - return 409 (message: “Care plan expired“).

  2. Verify care plan Activity:

    1. It has scheduled, in_progress status

      1. in case of error - return 409 (message: "Invalid activity status").

    2. Validate quantity is not exceeded

      1. Select all MD (medication dispenses) in status PROCESSED related to the Medication requests which based_on one activity 

        1. Sum medication_qty in the filtered Medication dispenses as dispensed_qty

        2. medication_qty from current MR as current_qty

        3. Calculate remaining_qty = activity.quantity - (dispensed_qty+current_qty)

      2. Check remaining_qty is greater then zero

        1. error return 409 "The total amount of the dispensed medication quantity exceeds quantity in care plan activity"

Validate division

  1. Validate division is active

    1. in case of error - return 409 ("Division is not active")

  2. Validate division belongs to user's legal entity

    1. in case of error - return 409 ("Division does not belong to user's legal entity")

  3. If chart parameter DISPENSE_DIVISION_DLS_VERIFY is on, then validate division is DLS verified (dls_verified=true)

    1. in case of error - return 409 "Division is not verified in DLS"

  4. Check division participates in submitted programs. Validate Provision for each Medical Program:

    1. If the medical program has no setting skip_contract_provision_verify or it is equal to false/null:

      1. if medical program in the request has funding_source one of NHS, LOCAL

        1. In case of error - return status=INVALID for a program, rejection_reason="Program was configured incorrectly. Either incorrect source of funding or option skip_contract_provision_verify"

      2. provision exist and active for the division:

        1. in case of error - return status=INVALID for a program, rejection_reason= "Division does not provide the medical program"

      3. if medical program in the request has funding_source = NHS:

        1. provision relates to the actual reimbursement contract: contract.start_date <= current_date <= contract.end_date, is_active = true, status = VERIFIED, contracts.type==reimbursement, contracts.contractor_legal_entity_id=token.client_id, contracts.medical_program_id==$.medical_program_id

          1. in case of error - return status=INVALID for a program, rejection_reason="Medical program provision is not related to any actual contract for the current date"

        2. contract is_suspended = false

          1. in case of error - return status=INVALID for a program, rejection_reason="Contract with number <contract_number> is suspended"

      4. if medical program in the request has funding_source = LOCAL, then check medical_program_provision.msp_legal_entity_id = medication_request.legal_entity_id

        1. in case of error - return status=INVALID for a program, rejection_reson = "Medical program can not be provided for the legal entity specified in the medication request"

    2. else if skip_contract_provision_verify = true, then skip provision verification for the medical program

  5. Get license_types_allowed parameter from settings of medical program from request $.medical_program_id:

    1. if it is exists and not empty, get list of all license types from parameter.
      Check that division has active healthcare services with following parameters:

      1. legal_entity_id = client_id from access token

      2. division_id = division_id from request

      3. status = 'ACTIVE'

      4. licensed_healthcare_service.status = 'ACTIVE'

      5. healthcare_service.license_id is not null and licenses.type = value from license_types_allowed parameter

        1. in case of error - return status=INVALID for a program, rejection_reason = 'Division does not have active licenses to provide the medical program'

Logic for qualify (analyze compliance with programs)

...

Validation purpose:  There is a list of medications (which links to innm_dosage) which can be used for the program. It must be check whether there is at least one available medication for the innm_dosage for the particular program.

Check that there is at least one medication (brand or innm_dosage) associated with medical program that can be dispensed to the patient

  1. Get info from Medication request  by id in payload, set temp variable object `_MR`

  2. Validate the compatibility of innm with the medication program list 

    1. Search for active innm_dosages that associated with medical program

      1. medications.is_active = true

      2. medications.type = INNM_DOSAGE

      3. program_medications.is_active = true

    2. Search for active brands that have innm_dosage as primary ingredient and are associated with medical program

      1. medications.is_active = true

      2. medications.type = BRAND

      3. ingredients.is_primary = true

      4. program_medications.is_active = true

    3. if nothing found:

      1. add to response: status = INVALID

      2. add to response: rejection_reason = "Innm not on the list of approved innms for program '#{program.name}"

...

Access to the method is defined by the scope medication_request:details. Permission for this scope is determined by the System administrator by configuring scopes in the context of clients and roles.

Processing

A list of processes related to receiving, changing or transmitting data according to the logic defined in the REST API

Response structure examples

...

  • Collect response array for all programs in payload with status for each (VALID or INVALID) and rejection_reason

  • For all VALID programs - Get linked medications (type = BRAND) with reimbursement info 

  • Show only active program medications based on start_date and end (start_date must be earlier or equal to current date or empty, end_date must be greater or equal to current date or empty)

    • Filter participants simultaneously by container_dosage and max_request_dosage

Code Block
SELECT *
FROM program_medications pm
    INNER JOIN ingredients i ON (i.parent_id = pm.medication_id
                                 AND i.medication_child_id = :medication_request_medication_id
                                 AND i.is_primary = TRUE)
    INNER JOIN medications m ON (m.id = pm.medication_id)
WHERE pm.medical_program_id = $.id
      AND pm.is_active = TRUE
      AND m.is_active = TRUE
      AND (pm.start_date <= now() OR pm.start_date IS NULL)
      AND (pm.end_date >= now() OR pm.end_date IS NULL)
 
-- added 2022-05-20:
      AND (
      ((M.container ->> 'numerator_unit' = $mr.container_dosage.code) AND
      (M.container ->> 'numerator_value' <>  $mr.container_dosage.value)) OR
           ( ($mr.dosage_container.code is NULL) AND ($mr.container_dosage.value is NULL) )
        )
      AND (M.max_request_dosage >= $.medication_qty or M.max_request_dosage is null)

...

Also see on Apiary.

Example:

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

Description of the REST API response structure, example

Expand
titleExample
Code Block
{
  "meta": {
    "code": 200,
    "url": "https://example.com/resource",
    "type": "object",
    "request_id": "req-adasdoijasdojsda"
  },
  "data": [
    {
      "program_id": "59781de0-2e64-4359-b716-bcc05a32c10f",
      "program_name": "Програма \"Доступні ліки\"",
      "status": "INVALID",
      "rejection_reason": "Innm not on the list of approved innms for program 'DOSTUPNI LIKI' !",
      "participants": [
        {
          "id": "0f2fbf93-3041-4c0d-a3cf-ff558c861df8",
          "medication_id": "59781de0-2e64-4359-b716-bcc05a32c10f",
          "medication_name": "Амлодипін-КВ",
          "form": "PILL",
          "manufacturer": {
            "name": "ПАТ \"Київський вітамінний завод\"",
            "country": "UA"
          },
          "reimbursement_amount": 15,
          "wholesale_price": 25.14,
          "consumer_price": 34.03,
          "reimbursement_daily_dosage": 1.4438,
          "estimated_payment_amount": 5.15,
          "container_dosage": {
            "numerator_unit": "PILL",
            "numerator_value": 1,
            "denumerator_unit": "PILL",
            "denumerator_value": 1
          },
          "package_min_qty": 20,
          "package_qty": 20,
          "start_date": "2019-01-01",
          "end_date": "2019-06-30",
          "registry_number": "REG-1111"
        }
      ]
    }
  ]
}

...

Post-processing processes

No

Technical modules where the method is used

List of pages describing technical modules where the method is used

Page Properties Report
headingsID ТМ, Статус
cqllabel = "tr-mis"

...