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

RC_PreQualify Medication request request (CSI-2140)

Validate compliance for programs

Some checks (below in the text) must be passed for the programs

  1. if passed - save the response by this program - status = VALID

  2. if not passed - save response by this program - status = INVALID

Check each medical program in the array is:

  1. is exists

    1. in case of error - return status = INVALID and reject reason = “Medical program not found”

  2. is_active = true

    1. in case of error - return status = INVALID and reject reason = “Medical program is not active”

1. Check INNM complience for the programs

There is a list of medications (BRANDs, which links to Innms)  which can be used for the program. It must be check whether there is at least one available medication (with `medication_request_allowed` == TRUE)  for the Innm for the particular program, that has setting request_allowed = true

  1. Check compatibility of innm with medication list for the program

    1. if data is not found:

      1. add to response: status = INVALID

      2. add to response: rejection_reason = "Not found any medications allowed for create medication request for this medical program!"

SELECT m0.id, m2.id, m2.package_qty, m2.package_min_qty, m3.id, m3.name FROM medications AS m0 INNER JOIN ingredients AS i1 ON i1.medication_child_id = {$.medication_id} INNER JOIN medications AS m2 ON i1.parent_id = m2.id INNER JOIN medical_programs AS m3 ON m3.id = {$.medical_program_id} INNER JOIN program_medications AS p4 ON (m3.id = p4.medical_program_id) AND (p4.medication_id = m2.id) WHERE (i1.is_primary = TRUE) AND (m0.id = {$.medication_id}) AND (m0.type = 'INNM_DOSAGE') AND (m0.is_active = TRUE) AND (m2.is_active = TRUE) AND (m3.medical_program_settings::jsonb -> 'request_allowed' = 'true') AND (p4.is_active = TRUE) AND (p4.medication_request_allowed = TRUE)
  1. Check if there is at list one record of Brand with requested primary container volume

a. if not exist - return 422 error (message: "Not found any appropriate medication with such container parameters")

  1. Check if there is at list one record medication_qty <= max_request_dosage or (max_request_dosage is null)
    a. if not exist - return 422 error (message: "Not found any appropriate medication complying with max_request_dosage limit")

  2. Check max allowed quantity for the treatment period:

  • Get non-null max_daily_dosage from all filtered above program medications

  • Define max value among max_daily_dosage as highest_max_daily_dosage

  • Get package_min_qty (or package_qty if PRM.program_medications.package_qty_divisible == false) from all related brands, connected to found program medications

  • Define min value among package_min_qty as lowest_package_min_qty (or lowest_package_qty if PRM.program_medications.package_qty_divisible == false)

a. Validate that remainder of the division: (highest_max_daily_dosage × (ended_at - started_at+1)) / one of package_min_qty (or package_qty if PRM.program_medications.package_qty_divisible == false) is equal to 0

i. if true - check medication_qty <= (highest_max_daily_dosage × (ended_at - started_at+1))

in case of error - return 422 “The amount of medications in medication request is greater than available maximum for the max_daily_dosage and treatment period limit” 

b. Validate: (medication_qty - (highest_max_daily_dosage × (ended_at - started_at+1))) < lowest_package_min_qty (or lowest_package_qty if PRM.program_medications.package_qty_divisible == false)

i. in case of error - return 422 “The amount of medications in medication request is not complying with max_daily_dosage and treatment period limit”

  1. Check compliance of medication quantity:

    1. if PRM.program_medications.package_qty_divisible == true:

      1. remainder of the division (medication_qty/package_min_qty) is equal to 0

        1. in case it is not equal to zero - return 422 “The amount of medications in medication request must be divisible to package_min_qty (or package_qty if program_medication.package_quantity_divisible = false)“

    2. else:

      1. remainder of the division (medication_qty/package_qty) is equal to 0

        1. in case it is not equal to zero - return 422 “The amount of medications in medication request must be divisible to package_min_qty (or package_qty if program_medication.package_quantity_divisible = false)“

 

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