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

RC_Qualify Medication request (CSI-2140)

 

Check INNM_dosage compliance for the programs

Applies to the following programs:

  1. Dostupni liky

  2. Netsukrovyy diabet

  3. Insuliny z doplatoyu

  4. Insuliny bezoplatno

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.

  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. if data is not 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}"

IF EXISTS (SELECT * FROM program_medications MP INNER JOIN medications M ON M.id = MP.medication_id AND M.type = BRANDS INNER JOIN ingredients I ON I.parend_id = M.id AND I.is_primary = TRUE AND I.medication_child_id = _MR.medication_id WHERE MP.medical_program_id == $.id AND MP.is_active == TRUE AND M.is_active == TRUE)

Filter program_medications according to remaining quantity and program_medications.package_qty_divisible

  1. calculate actual remaining quantity for dispense:

    1. for all "PROCESSED" medication_dispenses with medication_request_id = $.id:

      1. mr_quantity = medication_requests.medication_qty - sum(medication_dispenses.medication_qty)

  2. for each participant (program_medications) check package_qty_divisible param:

    1. if  package_qty_divisible = false:

      1. Check that mr_quantity is multiplier of package_qty

        1.  Mod(mr_quantity, medications.package_qty) = 0

      2. if  package_qty_divisible = true:

        1. Check that mr_quantity is multiplier of package_min_qty

          1. Mod(mr_quantity, medications.packagem_min_qty) = 0

         

  3. render in response only valid participants (Mod(_ , _) = 0). If there are not suitable participants:

    1. add to response: status = INVALID

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

Check absence a same medication for the programs

 

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