ЕСОЗ - публічна документація
RC_Qualify Medication request (CSI-2140)
…
Check INNM_dosage compliance for the programs
Applies to the following programs:
Dostupni liky
Netsukrovyy diabet
Insuliny z doplatoyu
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.
Get info from Medication request by id in payload, set temp variable object `_MR`
Validate the compatibility of innm with the medication program list
if data is not found:
add to response: status = INVALID
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
calculate actual remaining quantity for dispense:
for all "PROCESSED" medication_dispenses with medication_request_id = $.id:
mr_quantity = medication_requests.medication_qty - sum(medication_dispenses.medication_qty)
for each participant (program_medications) check package_qty_divisible param:
if package_qty_divisible = false:
Check that mr_quantity is multiplier of package_qty
Mod(mr_quantity, medications.package_qty) = 0
if package_qty_divisible = true:
Check that mr_quantity is multiplier of package_min_qty
Mod(mr_quantity, medications.packagem_min_qty) = 0
render in response only valid participants (Mod(_ , _) = 0). If there are not suitable participants:
add to response: status = INVALID
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
…
ЕСОЗ - публічна документація