Versions Compared

Key

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

...

Page Properties

Link

https://ehealthmisapi1.docs.apiary.io/#reference/public.-reimbursement/medication-request-requests/create-medication-request-request

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

Resource

/api/medication_request_requests

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

Scope

medication_request_request:write

Scope для доступу

Components

ePrescription

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

Microservices

API paragraph not found

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

Protocol type

REST

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

Request type

POST

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

Sync/Async

Sync

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

Logic

Технічний опис бізнес-процесу виписування рецепту в ЕСОЗ (загальний процес для усіх рецептурних ЛЗ, в т.ч. і тих, які підлягають реімбурсації)

...

  1. Verify the validity of access token

    • in case of error - return 401 (“Invalid access token”) in case of validation fails

  2. Verify that token is not expired

    • in case of error - return 401 (“Invalid access token”)

  3. Check user scopes in order to perform this action (scope = 'medication_request_request:write')

    • return 403 (“Your scope does not allow to access this resource. Missing allowances: medication_request_request:write”) in case of invalid scope(s)

  4. If BLOCK_UNVERIFIED_PARTY_USERS is true, then check party's data match following condition: verification_status != NOT_VERIFIED or (verification_status = NOT_VERIFIED and updated_at <= current_date - UNVERIFIED_PARTY_PERIOD_DAYS_ALLOWED):

    • in case not match - return 403 ("Access denied. Party is not verified")

Headers

Content-Type:application/json

...

  1. Validate $.container_dosage field by schemata

    1. $.container_dosage.code and $.container_dosage.value should be both filled

      1. in case of error return 422 error ("required property %{property} was not present")

    2. $.container_dosage.system should be “MEDICATION_UNIT”

      1. in case of error return 422 error ("value is not allowed in enum")

    3. if $.container_dosage is filled then $.container_dosage.unit should be checked with the MEDICATION_UNIT dictionary by $.container_dosage.code as a key.

      1. in case of error return 422 error ("value is not allowed in enum")

  2. Check if there is at list one record of Brand with requested primary container volume
    a. if not exist - return 404 error (message: "Not found any appropriate medication with such container parameters")

Validate priority

  1. Check by schemata if $.priority is filled with the value of MEDICATION_REQUEST_PRIORITY dictionary

    1. in case of error return 422 error ("value is not allowed in enum")

...

  1. Validate that created_at, started_at, ended_at in date format

    1. in case invalid return 422 with msg ("expected \"%{actual}\" to be a valid ISO 8601 date")

  2. Validate ended_at >= started_at

    1. if invalid - return 422 error  (message: "Ended date must be >= Started date!")

  3. Validate started_at >= created_at, but not greater than (created_at + MEDICATION_REQUEST_REQUEST_EXTENDED_LIMIT_STARTED_AT_DAYS)

    1. if invalid - return 422 error  (message: "The start date should be equal to or greater than the creation date, but the difference between them should be not exceed {{MEDICATION_REQUEST_REQUEST_EXTENDED_LIMIT_STARTED_AT_DAYS}} day(s).")

  4. Validate started_at >= current_date()

    1. if invalid - return 422 error  (message: "Started date must be >= current date!")

  5. Validate created_at >= current_date() - MEDICATION_REQUEST_REQUEST_DELAY_INPUT chart param

    1. if invalid - return 422 error  (message: "Create date must be >= Current date - MRR delay input!")

  6. Validate started_at regarding frequency of receiving drugs

    1. get $.medical_programs.medical_program_setting by medical_program_id from request

      1. validate skip_mnn_in_treatment_period variable

        1. in case skip_mnn_in_treatment_period == FALSE (or absent)

          1. validate request according to logic: PreQualify Medication request: 2. Check absence the same medications for the programs

        2. in case skip_mnn_in_treatment_period == TRUE

          1. skip validating frequency of receiving drugs

  7. Validate created_at regarding frequency of receiving drugs

    1. get $.medical_programs.medical_program_setting by medical_program_id from request

      1. validate skip_mnn_in_treatment_period variable

        1. in case skip_mnn_in_treatment_period == FALSE (or absent)

          1. validate request according to logic: PreQualify Medication request: 2. Check absence the same medications for the programs

        2. in case skip_mnn_in_treatment_period == TRUE

          1. skip validating frequency of receiving drugs

  8. Validate period length (ended_at - started_at):

    1. If medical program has been submitted:

      1. validate request according to logic: PreQualify Medication request: 7. Validate period

    2. else:

      1. Check that medication request period less than or equal to MEDICATION_REQUEST_MAX_PERIOD_DAY parameter from charts

        1. in case of error - return 409 “Period length exceeds default maximum value“ 

...

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

            3. current_qty as medication_qty from current MRR

          5. calculate remaining quantity by subtracting reserved_quantity, dispensed_qty, current_qty from activity quantity

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

          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

      2. 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 crossing 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")

...

  1. Validate medical_program_id is present in the request

    1. in case of error return 422 ("required property medical_program_id was not present")

  2. Validate medical_program_id - medical_program_id exists

    1. in case of error return 422 ("Medical program not found")

  3. Validate medical_programs.medication_request_allowed parameter

    1. check if medication_request_allowed == true

      1. in case of error return 422 with msg ("Forbidden to create medication request for this medical program!")

  4. Validate medical_programs.medical_program_setting parameters

    1. check if care_plan_required == true then the request should contain a based_on with care plan and activity that contains the same medical program

      1. in case of error return 422 with msg ("Care plan and activity with the same medical program should be present in request")

    2. If there is conditions_icd10_am_allowed parameter, then:

      1. Check if primary diagnosis from the encounter in context has code from eHealth/ICD10_AM/condition_codes dictionary

        1. Check diagnosis code in conditions_icd10_am_allowed

          1. in case of error - return 422 “Encounter in context has no primary diagnosis allowed for the medical program“

    3. If there is conditions_icpc2_allowed parameter, then:

      1. Check if primary diagnosis from the encounter in context has code from eHealth/ICPC2/condition_codes dictionary

        1. Check diagnosis code in conditions_icpc2_allowed

          1. in case of error - return 422 “Encounter in context has no primary diagnosis allowed for the medical program“.

    4. if skip_medication_request_employee_declaration_verify = false or null/absent

      1. then: get $.declarations by employee_id, person_id, status=ACTIVE

        1. if not found - return 422 error  "Only doctors with an active declaration with the patient can create medication request!"

      2. else skip declaration verification on employee level (if true).

    5. if skip_medication_request_legal_entity_declaration_verify = false or null/absent

      1. then: get $.declarations by employee's legal_entity_id, person_id, status=ACTIVE

        1. if not found - return 422 error "Only legal entity with an active declaration with the patient can create medication request!"

      2. else skip declaration verification on legal entity level (if true).

  5. If medical program has funding_source = LOCAL , then invoke validation described at PreQualify Medication request request | 11.-Check-provision-for-a-programs

...

  1. set:

    1. dispense_valid_from = created_at

    2. dispensed_valid_to = dispensed_valid_from + dispense_period

  2. Fill 'data' structure for Response & save in IL.medication_request_requests

    1. If encounter is present in the request context then based on it - fill the IL.medication_request_requests.context_episode_id

  3. Fill separately

    1. data_employee_id,
      data_intent,
      data_based_on_care_plan_id,
      data_based_on_activity_id,
      data_context_id,
      data_patient_id,
      data_legal_entity_id

Update based_on

  1. If the medication request request is based on activity with quantity - set remaining_quantity for the activity which was calculated at validation Create Medication Request: Validate based_on (p. 2.d.1 )

Generate content for response

...

Expand
titleResponse example
Code Block
{
  "meta": {
    "code": "422",
    "url": "https://example.com/resource",
    "type": "object",
    "request_id": "req-adasdoijasdojsda"
  },
  "error": {
    "type": "unverified",
    "message": "Only active employee with type DOCTOR can create medication request!"
  }
}

HTTP status codes

HTTP status code

Message

What caused the error

201

Response

 

403

Your scope does not allow to access this resource. Missing allowances: medication_request_request:write

409

  • Employee is not active

  • Invalid legal entity type

  • Patient is not verified

  • Period length exceeds default maximum value

  • {$.data.context.identifier.type.coding[*].code} not found

  • Entity in status "entered-in-error" can not be referenced

  • Entity without related episode can not be referenced

  • Incorrect additional instruction

  • Incorrect site

  • Incorrect route

  • Incorrect method

  • Incorrect dose and rate type

  • The total amount of the prescribed medication quantity exceeds quantity in care plan activity

422

  • required property %{property} was not present

  • value is not allowed in enum

  • Prior prescription is not found

  • Employee not found

  • Employee does not belong to legal entity from token

  • Employee type can't create medication request with medical program from request

  • Only doctors with an active declaration with the patient can create medication request with medical program from request!

  • Only legal entity with an active declaration with the patient can create medication request with medical program from request!

  • Employee's specialty doesn't allow create medication request with medical program from request

  • Division not found

  • Only employee of active divisions can create medication request!

  • Legal entity not found

  • Only active legal entity can provide medication request

  • Person not found

  • Only for active MPI record can be created medication request!

  • expected \"%{actual}\" to be a valid ISO 8601 date

  • Ended date must be >= Started date!

  • Started date must be >= Created date!

  • Started date must be >= current date!

  • Create date must be >= Current date - MRR delay input!

  • Medication not found

  • Only medication with type `INNM_DOSAGE` can be use for created medication request!

  • Only active innm_dosage can be use for created medication request!

  • required property context was not present

  • Sequence must be unique

  • Care plan not found

  • Activity not found

  • Invalid activity kind

  • Medical program from activity should be equal to medical program from request

  • Invalid care plan period

  • required property medical_program_id was not present

  • Medical program not found

  • Care plan and activity with the same medical program should be present in request

  • Encounter in context has no primary diagnosis allowed for the medical program

  • Only doctors with an active declaration with the patient can create medication request!

  • Only legal entity with an active declaration with the patient can create medication request!

  • Employee's specialty doesn't allow create medication request with medical program from request

  • Division not found

  • Only employee of active divisions can create medication request!

  • Only active legal entity can provide medication request

  • Only for active MPI record can be created medication request!

  • Started date must be >= current date!

  • Create date must be >= Current date - MRR delay input!

  • Medication not found

  • Care plan not found

  • Medical program from activity should be equal to medical program from request

  • required property medical_program_id was not present