Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

...

Specification

Page Properties

Link

https://ehealthmisapi1uaehealthapi.docs.apiary.io/#reference/public.-reimbursement/medication-dispense/process-medication-dispense-by-pharmacy-user

Посилання на Apiary або Swagger

Resource

/api/pharmacy/medication_dispenses/{{id}}/actions/process

Посилання на ресурс, наприклад: /api/persons/create

Scope

medication_dispense:process

Scope для доступу

Components

ePrescription

Зазначається перелік бізнес компонентів, які використовують цей метод, наприклад: ePrescription

Microservices

API paragraph not found

Перелік мікросервісів, які використовує метод API, наприклад: Auth, ABAC

Protocol type

REST

Тип протоколу, який використовується запитом, наприклад: SOAP | REST

Request type

PATCH

Тип запиту API, наприклад: GET, POST, PATCH…

Sync/Async

Sync

Метод є синхронним чи асинхронним?

Public/Private/Internal

Public

...

  1. Verify Care plan:

    1. It should belong to the same person as set in MRR

      1. in case of error return 422 with msg ("Care plan not found")

    2. It should be in active status

  2. Verify submitted Activity:

    1. It belongs to the Care plan.

      1. in case of error return 422 with msg ("Activity not found")

    2. It has activity.detail.kind=medication_request; activity.detail.product_reference=medication_id.

      1. in case of error return 422 with msg ("Invalid activity kind")

    3. It has scheduled, in_progress status

      1. in case of error return 422 with msg ("Invalid activity status")

    4. If it has quantity then calculate remaining quantity:

      1. select all MRR in status NEW which based on current activity

      2. select all MR in statuses ACTIVE, COMPLETED based on current activity

      3. calculate reserved at the moment medication quantity as sum of medication_qty in the filtered MRR  and MR list, including medication_qty from current MRR

      4. calculate remaining quantity by subtracting reserved quantity from activity quantity

      5. Check remaining quantity is greater then or equal to zero

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

    5. check that medical_program_id equal to $.activity[].program

      1. in case of error return 422 with msg ("Medical program from activity should be equal to medical program from request")

  3. Validate started_at/ended_at of Medication request Request: 

    1. if care plan activity has detail.scheduled_timing.repeat.bounds_period - validate started_at/ended_at within bounds_period

    2. if care plan activity has detail.scheduled_period - validate started_at/ended_at within scheduled_period

    3. else - validate started_at/ended_at within care_plan.period

      1. in the case of started_at/ended_at is not within care_plan.period return 422 with msg  ("Invalid care plan period")

...

Expand
titleResponse example
Code Block
{
  "meta": {
    "code": 200,
    "url": "https://example.com/resource",
    "type": "object",
    "request_id": "6617aeec-15e2-4d6f-b9bd-53559c358f97#17810"
  },
  "data": {
    "id": "b075f148-7f93-4fc2-b2ec-2d81b19a9b7b",
    "medication_request": {
      "id": "b075f148-7f93-4fc2-b2ec-2d81b19a9b7b",
      "status": "ACTIVE",
      "request_number": "0000-243P-1X53-EH38",
      "created_at": "2017-08-17",
      "started_at": "2017-08-17",
      "ended_at": "2017-09-16",
      "dispense_valid_from": "2017-08-17",
      "dispense_valid_to": "2017-09-16",
      "person": {
        "short_name": "Петро І. І.",
        "age": 35
      },
      "medication_info": {
        "medication_id": "4a63b858-c138-4921-9341-ae9e384bcbd6",
        "medication_name": "Аміодарон 200мг таблетки",
        "form": "PILL",
        "dosage": {
          "numerator_unit": "MG",
          "numerator_value": 200,
          "denumerator_unit": "PILL",
          "denumerator_value": 1
        },
        "ingredients": [
          {
            "id": "1349a693-4db1-4a3f-9ac6-8c2f9e541982",
            "name": "Інсулін деглюдек",
            "name_original": "Insulin degludec",
            "sctid": "52574003",
            "dosage": {
              "numerator_unit": "MG",
              "numerator_value": 200,
              "denumerator_unit": "PILL",
              "denumerator_value": 1
            },
            "is_primary": true
          }
        ],
        "medication_qty": 10.34
      },
      "medical_program": {
        "id": "c7d52544-0bd4-4129-97b0-2d72633e0490",
        "name": "Доступні ліки",
        "medicalis_program_settingsactive": {true,
          "caremedication_plandispense_requiredallowed": true,
 
        "employeemedication_typesdispense_to_create_medication_requestallowed_text": [
   "Some text",
        "SPECIALIST",
medication_request_allowed": true,
           "DOCTOR"
"medication_request_allowed_text": "Some text",
         ],
 "type": "MEDICATION",
        "skip_mnn_in_treatment_periodfunding_source": true"NHS",
          "skipmr_employeeblank_validationtype": true"F-1",
          "specialityinserted_types_allowedat": ["2017-04-20T19:14:13Z",
            "ENDOCRINOLOGY",
 "inserted_by": "e1453f4c-1077-4e85-8c98-c13ffca0063e",
          "PEDIATRICupdated_NEUROLOGYat"
          ]: "2017-04-20T19:14:13Z",
          "conditions_icd10_am_allowed": [updated_by": "2922a240-63db-404e-b730-09222bfeb2dd"
      },
      "intent": "A00.0plan",
      "category": "community",
      "A00.1"
based_on": [
         ],{
          "conditions_icpc2_allowedidentifier": [{
            "A01",type": {
              "A02coding": [
          ],      {
     "providing_conditions_allowed": [            "system": "INPATIENTeHealth/resources",
            "OUTPATIENT"      "code": "care_plan"
        ],        }
  "medication_request_max_period_day": 90,           "skip_medication_request_employee_declaration_verify": true,]
           "skip_medication_request_legal_entity_declaration_verify": true },
          "multi_medication_dispense_allowed": true,  "value": "9183a36b-4d45-4244-9339-63d81cd08d9c"
          }
       "skip_medication_dispense_sign": true },
        {
 "medication_request_notification_disabled": true,         "identifier": {
            "skip_contract_provision_verifytype": true, {
              "medication_dispense_period_daycoding": 90,[
          "medical_program_change_on_dispense_allowed": true,     {
     "patient_categories_allowed": [            "system": "insulin_1eHealth/resources",
            "insulin_2"      "code": "activity"
   ],           "license_types_allowed": [ }
           "PHARMACY",   ]
         "PHARMACY_DRUGS"   },
        ]    "value": "9183a36b-4d45-4244-9339-63d81cd08d9c"
   },       }
 "medical_program_settings_text": "Some text",     }
   "is_active": true,  ],
      "medication_dispense_allowedcontext": true,{
        "medication_dispense_allowed_textidentifier": {
"Some text",         "medication_request_allowedtype": true, {
            "medication_request_allowed_textcoding": "Some[
text",         "type": "MEDICATION",    {
      "funding_source": "NHS",         "mr_blank_typesystem": "F-1eHealth/resources",
                "inserted_atcode": "2017-04-20T19:14:13Z",encounter"
          "inserted_by": "e1453f4c-1077-4e85-8c98-c13ffca0063e",   }
     "updated_at": "2017-04-20T19:14:13Z",      ]
  "updated_by": "2922a240-63db-404e-b730-09222bfeb2dd"       },
          "intentvalue": "plan",9183a36b-4d45-4244-9339-63d81cd08d9c"
        }
    "category": "community"  },
      "baseddosage_oninstruction": [
        {
          "identifiersequence": {
 1,
          "typetext": {"0.25mg PO every 6-12 hours as needed for menses from Jan 15-20, 2015.  Do "coding": [
    not exceed more than 4mg per day",
           {"additional_instruction": [
            {
     "system": "eHealth/resources",        "coding": [
         "code": "care_plan"      {
          }        "system": "eHealth/SNOMED/additional_dosage_instructions",
     ]             },
"code": "311504000"
           "value": "9183a36b-4d45-4244-9339-63d81cd08d9c"    }
      }        ]
},         {   }
       "identifier": {  ],
          "typepatient_instruction": {"0.25mg PO every 6-12 hours as needed for menses from Jan 15-20, 2015.  Do "coding": [
    not exceed more than 4mg per day",
          "timing": {
            "event": [
     "system": "eHealth/resources",         "2017-04-20T19:14:13Z"
            ],
     "code": "activity"      "repeat": {
         }     "bounds_duration": {
        ]        "value": 10,
   },             "valueunit": "9183a36b-4d45-4244-9339-63d81cd08d9c"days",
           }     "system": "eHealth/ucum/units",
  }       ],       "contextcode": {
  "d"
     "identifier": {         },
 "type": {             "codingcount": [2,
              {
 "count_max": 4,
              "systemduration": "eHealth/resources"4,

               "codeduration_max": "encounter"6,
              }
"duration_unit": "d",
           ]   "frequency": 1,
      },           "valuefrequency_max": "9183a36b-4d45-4244-9339-63d81cd08d9c"2,
        }      "period": }4,
         "dosage_instruction": [    "period_max": 6,
   {           "sequenceperiod_unit": 1,"d",
              "textday_of_week": "0.25mg[
PO every 6-12 hours as needed for menses from Jan 15-20, 2015.  Do not exceed more"mon"
than 4mg per day",           "additional_instruction": [],
             {
    "time_of_day": [
          "coding": [     "2017-04-20T19:14:13Z"
           {   ],
               "systemwhen": "eHealth/SNOMED/additional_dosage_instructions",
 [
                "codeWAKE":
"311504000"              ],
  }            "offset": 4
 ]           },
 }           ],
"code": {
         "patient_instruction": "0.25mg PO every 6-12 hours as needed for menses from Jan 15-20, 2015.  Do not exceed more than 4mg per day", "coding": [
                {
    "timing": {             "eventsystem": ["TIMING_ABBREVIATIONS",
              "2017-04-20T19:14:13Z"    "code": "patient"
       ],         }
   "repeat": {          ]
    "bounds_duration": {       }
         "value": 10},
           "as_needed_boolean": true,
          "unitsite": {
            "days",coding": [
              {
                "system": "eHealth/ucum/unitsSNOMED/anatomical_structure_administration_site_codes",
                "code": "d344001"
              },
            ]
     "count": 2,    },
          "count_maxroute": 4,
 {
            "durationcoding": [
4,              {
"duration_max": 6,               "duration_unitsystem": "deHealth/SNOMED/route_codes",
                "frequencycode": "46713006"
 1,             }
 "frequency_max": 2,           ]
     "period": 4,    },
          "period_maxmethod": 6,
 {
            "period_unitcoding": "d",[
              "day_of_week": [{
                "system": "mon"eHealth/SNOMED/administration_methods",
              ],  "code": "419747000"
           "time_of_day": [  }
            ]
 "2017-04-20T19:14:13Z"         },
     ],     "dose_and_rate": {
            "whentype": [{
                "WAKEcoding": [
             ],   {
           "offset": 4      "system": "eHealth/dose_and_rate",
     },             "code": { "'ordered'"
                }
  "coding": [           ]
     {       },
           "system": "TIMINGdose_ABBREVIATIONSrange",:  {
                "codelow": "patient"{
                }
"value": 0,
             ]     "unit": "mg",
       }         "system":  },"eHealth/ucum/units",
                "as_needed_boolean": true,code": "mg"
              },
              "sitehigh": {
                "codingvalue": 0,
  [               {"unit": "mg",
                "system": "eHealth/SNOMED/anatomical_structure_administration_site_codesucum/units",
                "code": "344001mg"
              }
            ]
        },
 },           "routerate_ratio": {
              "codingnumerator": [{
               { "value": 0,
                "systemunit": "eHealth/SNOMED/route_codesmg",
                "codesystem": "46713006eHealth/ucum/units",
              }  "code": "mg"
         ]     },
     },           "methoddenominator": {
                "codingvalue": 0,
  [               {"unit": "mg",
                "system": "eHealth/SNOMEDucum/administration_methodsunits",
                "code": "419747000mg"
              }
            ]}
          },
          "max_dose_andper_rateperiod": {
            "typenumerator": {
              "codingvalue": [0,
                {
 "unit": "mg",
                "system": "eHealth/dose_and_rate/ucum/units",
   
              "code": "'ordered'mg"
                }
              ]
            },
            "dose_range": {
              "lowdenominator": {
                "value": 0,
 
              "unit": "mg",
 
              "system": "eHealth/ucum/units",

               "code": "mg"
            }
      },    },
          "highmax_dose_per_administration": {
 
              "value": 0,
   
            "unit": "mg",

               "system": "eHealth/ucum/units",
   
            "code": "mg"
   
          },
            },
            "rate_ratio": {
              "numerator"max_dose_per_lifetime": {
  
             "value": 0,
   
            "unit": "mg",
 
              "system": "eHealth/ucum/units",
   
            "code": "mg"
          }
        },
      ],
       "denominatorreject_reason": {"Incompatible drugs",
        "reject_reason_code": "PATIENT_REJECT",
      "valueis_blocked": 0false,
      "block_reason": "Підозра на фрод",
      "unitblock_reason_code": "mgBLOCK_WRONG_QTY_DRUG",
      "block_legal_entity": {
        "systemid": "eHealth/ucum/unitsUUID",
        "type": "NHS"
      "code": "mg"},
      "priority": "routine",
       }"prior_prescription": {
        "identifier": {
  }        "type": {
 },           "max_dose_per_periodcoding": [
{             "numerator": {
                "valuesystem": 0"eHealth/resources",
                "unitcode": "mgmedication_request",
               "system": "eHealth/ucum/units",}
               "code": "mg"]
            },
 
          "denominatorvalue": {"9183a36b-4d45-4244-9339-63d81cd08d9c"
        }
     "value": 0,
       },
      "unitcontainer_dosage": "mg",
     {
        "system": "eHealth/ucum/unitsMEDICATION_UNIT",
     
        "code": "mgML",
        "value": 4
  }      }
    },
    "dispensed_at": "2017-08-17",
    "max_dose_per_administrationdispensed_by": { "Іванов Іван Іванович",
    "party": {
      "valueid": 0,
     "b075f148-7f93-4fc2-b2ec-2d81b19a9b7b",
      "unitfirst_name": "mgПетро",
   
        "systemlast_name": "eHealth/ucum/unitsІванов",
     
      "codesecond_name": "mgМиколайович"
   
      },
    
     "max_dose_per_lifetimelegal_entity": {
      "id": "b075f148-7f93-4fc2-b2ec-2d81b19a9b7b",
    "value": 0,
            "unitname": "mg",
            "system": "eHealth/ucum/units",
   Клініка Ноунейм",
        "code": "mg"
          }
        }
      ],
      "reject_reason": "Incompatible drugs",
      "reject_reason_code": "PATIENT_REJECT",
      "is_blocked": false,
      "block_reason": "Підозра на фрод",
      "block_reason_code": "BLOCK_WRONG_QTY_DRUG",
      "block_legal_entity": {
        "id": "UUID",
        "type": "NHS"
      },
      "priority": "routine",
      "prior_prescription": {
        "identifier": {
          "type": {
            "coding": [
              {
                "system": "eHealth/resources",
                "code": "medication_request"
              }
            ]
          },
          "value": "9183a36b-4d45-4244-9339-63d81cd08d9c"
        }
      },
      "container_dosage": {
        "system": "MEDICATION_UNIT",
        "code": "ML",
        "value": 4
      }
    },
    "dispensed_at": "2017-08-17",
    "dispensed_by": "Іванов Іван Іванович",
    "party": {
      "id": "b075f148-7f93-4fc2-b2ec-2d81b19a9b7b",
      "first_name": "Петро",
      "last_name": "Іванов",
      "second_name": "Миколайович"
    },
    "legal_entity": {
      "id": "b075f148-7f93-4fc2-b2ec-2d81b19a9b7b",
      "name": "Клініка Ноунейм",
      "short_name": "Ноунейм",
      "public_name": "Клініка Ноунейм",
      "type": "MSP",
      "edrpou": "5432345432",
      "status": "ACTIVE"
    },
    "division": {
      "id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
      "name": "Бориспільське відділення Клініки Ноунейм",
      "legal_entity_id": "d290f1ee",
      "type": "CLINIC",
      "status": "ACTIVE",
      "mountain_group": false,
      "dls_id": "2872985",
      "dls_verified": true
    },
    "medical_program": {
      "id": "c7d52544-0bd4-4129-97b0-2d72633e0490",
      "name": "Доступні ліки",
      "medical_program_settings": {
        "care_plan_required": true,
        "employee_types_to_create_medication_request": [
          "SPECIALIST",
          "DOCTOR"
        ],
        "skip_mnn_in_treatment_period": true,
        "skip_employee_validation": true,
        "speciality_types_allowed": [
          "ENDOCRINOLOGY",
          "PEDIATRIC_NEUROLOGY"
        ],
        "conditions_icd10_am_allowed": [
          "A00.0",
          "A00.1"
        ],
        "conditions_icpc2_allowed": [
          "A01",
          "A02"
        ],
        "providing_conditions_allowed": [
          "INPATIENT",
          "OUTPATIENT"
        ],
        "medication_request_max_period_day": 90,
        "skip_medication_request_employee_declaration_verify": true,
        "skip_medication_request_legal_entity_declaration_verify": true,
"short_name": "Ноунейм",
       "multi_medication_dispense_allowedpublic_name": "Клініка trueНоунейм",
        "skip_medication_dispense_sign"type": true"MSP",
        "medication_request_notification_disabled"edrpou": true"5432345432",
       "status": "skip_contract_provision_verify": true,ACTIVE"
    },
    "medication_dispense_period_daydivision": 90,
 {
      "medical_program_change_on_dispense_allowedid": true"d290f1ee-6c54-4b01-90e6-d701748f0851",
        "patient_categories_allowed"name": ["Бориспільське відділення Клініки Ноунейм",
      "legal_entity_id": "insulin_1d290f1ee",
         "type": "insulin_2CLINIC",
        ]"status": "ACTIVE",
        "licensemountain_types_allowedgroup": [false,
         "dls_id": "PHARMACY2872985",
      "dls_verified": true
  "PHARMACY_DRUGS"  },
    "medical_program": {
]       }"id": "c7d52544-0bd4-4129-97b0-2d72633e0490",
      "medical_program_settings_textname": "SomeДоступні textліки",
      "is_active": true,
      "medication_dispense_allowed": true,
      "medication_dispense_allowed_text": "Some text",
      "medication_request_allowed": true,
      "medication_request_allowed_text": "Some text",
      "type": "MEDICATION",
      "funding_source": "NHS",
      "mr_blank_type": "F-1",
      "inserted_at": "2017-04-20T19:14:13Z",
      "inserted_by": "e1453f4c-1077-4e85-8c98-c13ffca0063e",
      "updated_at": "2017-04-20T19:14:13Z",
      "updated_by": "2922a240-63db-404e-b730-09222bfeb2dd"
    },
    "details": [
      {
        "medication": {
          "name": "Амідарон",
          "type": "MEDICATION",
          "manufacturer": {
            "name": "ПАТ \"Київський вітамінний завод\"",
            "country": "UA"
          },
          "form": "PILL",
          "container": {
            "numerator_unit": "PILL",
            "numerator_value": 1,
            "denumerator_unit": "PILL",
            "denumerator_value": 1
          },
          "form_pharm": "DISPERSIBLE_TABLET",
          "drlz_sku_id": "0404466792737630283703997321"
        },
        "program_medication_id": "64c06ebc-0266-4645-85f0-7a6900d7dfbe",
        "medication_qty": 0,
        "sell_price": 18.65,
        "sell_amount": 186.5,
        "discount_amount": 150,
        "reimbursement_amount": 450,
        "medication_2d_codes": [
          {
            "medication_2d_code": "0104820005161713171812001022431115 211XV82HPV"
          }
        ]
      }
    ],
    "payment_id": "1239804",
    "payment_amount": 50,
    "status": "NEW",
    "inserted_at": "2017-04-20T19:14:13Z",
    "inserted_by": "e1453f4c-1077-4e85-8c98-c13ffca0063e",
    "updated_at": "2017-04-20T19:14:13Z",
    "updated_by": "2922a240-63db-404e-b730-09222bfeb2dd"
  } }

Processing

  1. Save signed content to media storage

  2. Update Medication dispense data in OPS DB:

    1. set status  =  ‘PROCESSED’

    2. updated_by = user_id

    3. updated_at = now()

  3. Update related Medication request data in OPS DB:

    1. set status  =  ‘COMPLETED’

    2. updated_by = user_id

    3. updated_at = now()

  4. Write changes to event manager (Medication dispense and Medication request)

  5. Change Care plan activity (If related medication request has reference on Care plan, then corresponding care plan activity should be changed after Medication dispense processed):

    1. Set activity status to in_progress if previous activity status was scheduled 

    2. Check the MD identifier in outcome_reference attribute of the activity:

      1. if not found:

        1. Add reference on the medication dispense resource to the outcome_reference attribute .

        2. If quantity in the activity was set - validate $.activity.details.remaining_quantity_type:

          1. if $.activity.details.remaining_quantity_type =for_request than:

            1. select all MRR in status NEW which based on current activity

            2. select all MR in statuses ACTIVE based on current activity

            3. select all MD (medication dispenses) in status PROCESSED related to the Medication requests which are in status COMPLETE, REJECTED, EXPIRED

            4. calculate:

              1. reserved_qty as sum of medication_qty in the filtered MRR  and MR list

              2. dispensed_qty as sum of medication_qty in the filtered MD list

            5. calculate and update remaining quantity by subtracting reserved_quantity and dispensed_qty from activity quantity

          2. if $.activity.details.remaining_quantity_type = for_use than:

            1. select all MD in status PROCESSED related to MR which based on care plan and current activity

            2. calculate dispensed quantity in the current activity as sum of medication_qty in the filtered MD list

            3. calculate remaining quantity by subtracting dispensed quantity from activity quantity

            4. update remaining_quantity value in the activity with calculated value

      2. If found, then skip updating activity (it means that activity has been already updated by event from current MD processing).

HTTP status codes

Page Properties

HTTP status code

Message

What caused the error

200

Response

 

400

Document must be signed by 1 signer but contains 0 signatures

401

Invalid access token

 

403

Your scope does not allow to access this resource. Missing allowances: medication_dispense:process

 

409

  • Can't update medication dispense status from {status} to PROCESSED.

  • Medication request is not active.

  • Medication request is blocked.

  • Care plan is not active.

  • Care plan activity should be scheduled or in_progress.

 

422

  • Does not match the signer drfo.

  • Does not match the signer last name

  • Signed content does not match to previously created dispense.

  • Expected the value to be >= 0.