ЕСОЗ - публічна документація
RC_PreQualify Medication request Request (modified - EN)
- 1 Specification
- 2 Purpose
- 3 Input parameters (filters)
- 4 Authorize
- 5 Validate request (JSON schema)
- 6 Check medication request type
- 7 Logics for qualify (analyze ability use medical programs)
- 8 Check compliance for programs
- 8.1 1. Check INNM complience for the programs
- 8.2 2. Check absence the same medications for the programs
- 8.3 3. Check that care plan is mandatory for programs
- 8.4 4. Check diagnosis comply with programs
- 8.5 5. Validate employee
- 8.6 6. Validate Care plan and Activity
- 8.7 7. Validate period
- 8.8 8. Validate context
- 8.9 9. Valdate person
- 8.10 10. Validate declaration for a program
- 9 Generate structure for response
Specification
Purpose
This WS is designed to Pre-qualify data of Medication request Request (post) - check whether it's possible to use Medication request within the particular Medical program.
There are two types of medication request:
plan - The request represents an intention to ensure something occurs without providing an authorization for others to act. Medication request with type plan can't be dispensed and only provide the instruction to administer the medicine. It also can't be qualified
order - The request represents a request/demand and authorization for action. Medication request with type order can be dispensed
Input parameters (filters)
created_at
started_at
ended_at
person_id
employee_id
division_id
medication_id
medication_qty
programs
Authorize
Verify the validity of access token
Check user scope (scope = 'medication_request_request:write') in order to perform this action
In case error - generate 401 response
Validate request (JSON schema)
Validate request using JSON schema.
in case of error return 422 error with msg ("required property %{property} was not present")
Check medication request type
Only medication request with type (intent) order can be qualified.
Check medication request intent
if medication request intent == plan - return 409, "Plan can't be qualified"
Logics for qualify (analyze ability use medical programs)
Each Medical program may have its unique conditions for the medication dispense. It can be based on analysis of personal info, medications list, terms, locations and combinations of them.
For now there are only conditions for the following programs "Dostupni liky", "Netsukrovyy diabet", "Insuliny z doplatoyu", "Insuliny bezoplatno" and we check them.
Also, it is possible to have the medication dispense without any Medical program.
However for any Medical program we need a separate block of branching logic.
Check compatibility only for programs which are available in payload (array).
If program status is invalid, the reason must be saved and returned in response.
Check compliance for programs
Some checks (below in the text) must be passed for the programs
if passed - save the response by this program - status = VALID
1. Check INNM complience 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 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
Check compatibility of innm with medication list for the program
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 \"<medical_programs.name>\""
SELECT *
FROM program_medications PM
INNER JOIN medical_programs MP
ON PM.medical_program_id=MP.id
INNER JOIN medications M
ON M.id = PM.medication_id
AND M.type = 'BRAND'
AND MP.medication_request_allowed = TRUE
INNER JOIN ingredients I
ON I.parent_id = M.id
AND I.is_primary = TRUE
AND I.medication_child_id = PM.medication_id
WHERE PM.medical_program_id = 'medical_program_id'
AND MP.is_active = TRUE
AND M.is_active = TRUE; |
2. Check absence the same medications for the programs
Applies to the following programs:
Dostupni liky
Validation purpose: It can be only 1 Medication request (ACTIVE, COMPLETED) per one innm for the one patient at defined period of time.
Example validation: without crossing time
EP | Preconditions # 1 | Result validate #1 | Preconditions #2 | Result validate #2 | Preconditions #3 | Result validate #2 |
---|---|---|---|---|---|---|
PreQualifyMedicationRequestRequest | No records in MedicationRequest | OK | Created record in MedicationRequest | Not valid | Medications request | Not valid |
QualifyMedicationRequestByID | No records in MedicationRequest | Not possible | Create record in MedicationRequest | OK | Medications request | Not valid |
For info - status charts: Medication_request
Get `check_innm_id`
SELECT I.innm_child_id FROM ingredients I WHERE I.parent_id = $.medication_id AND I.is_primary = TRUE
Get Medication requests with their completed Medication dispense by person_id & check_innm_id
SELECT * FROM medication_requests MR INNER JOIN medications MED ON MED.id = MR.medication_id INNER JOIN ingredients I ON I.parent_id = MED.id AND I.innm_child_id = `check_innm_id` AND I.is_primary = TRUE WHERE MR.person_id == $.person_id AND MR.status IN (ACTIVE, COMPLETED) AND NOT( $.started_at> MR.ended_at OR $.ended_at < MR.started_at)
Validate exist (IF EXIST () - that is any crossing calculating term (started_at + ended_at) for payload with terms selecting Medication requests (started_at + ended_at) with connected medication_dispense in status in (NEW,PROCESSED)).
if found
add to response: status = INVALID
add to response: rejection_reason = "It can be only 1 active/ completed medication request request or medication request per one innm for the same patient at the same period of time!"
Fetch Medication Request by $innm_dosge, $medical_program_id, $person_id and max(end_date). In case there is Medication Request with ended_at>=current_date then next one can be done in
if (ended_at - started_at) => mrr_standart_duration then
NEW created_at >= ended at - max_mrr_renew_days>=current_dayin case of error return 422 error ('It's to early to create new medication request for such innm_dosage and medical_program_id')
if (ended_at - started_at) < mrr_standart_duration then
NEW created_at >= ended_at - min_mrr_renew_days>=current_dayin case of error return 422 error ('It's to early to create new medication request for such innm_dosage and medical_program_id')
3. Check that care plan is mandatory for programs
Applies to the following programs:
Netsukrovyy diabet
Insuliny z doplatoyu
Insuliny bezoplatno
Validation purpose: It is need to check if the medication request with a program need a care plan (with `care_plan_required` == TRUE) for a this program.
Check if there is a based_on in the request
Check care_plan_required value
if care_plan_required true:
check based_on (reference on care_plan and it activity) in request
in case based_on not found:
add to response: status = INVALID
add to response: rejection_reason = "Care plan with activity on "<medical_programs.name>\" is required for for program \"<medical_programs.name>\""
4. Check diagnosis comply with programs
Applies to programs: any
Validation purpose: It is needed to check if medication request with a program needed a context (encounter) with a specified diagnosis.
If program has CONDITIONS_ICD10_AM_ALLOWED parameter in medical_program_settings:
Check if primary diagnosis from the encounter in context has code from eHealth/ICD10_AM/condition_codes dictionary
Check diagnosis code in CONDITIONS_ICD10_AM_ALLOWED
in case of error - return 200 with status = INVALID and rejection_reason = “Encounter in context has no primary diagnosis allowed for the medical program“
If program has CONDITIONS_ICPC2_ALLOWED parameter in medical_program_settings:
Check if primary diagnosis from the encounter in context has code from eHealth/ICPC2/condition_codes dictionary
Check diagnosis code in CONDITIONS_ICPC2_ALLOWED
in case of error - return 200 with status = INVALID and rejection_reason = “Encounter in context has no primary diagnosis allowed for the medical program“
5. Validate employee
Applies to programs: any
Validation purpose: It is needed to check if medication request with a program allowed to create for specified employee.
Validate employee_id as described on Create Medication request Request
6. Validate Care plan and Activity
Applies to programs: any
Validation purpose: It is needed to check if medication request with a program allowed to create for specified care plan and activity.
Validare based_on as described on Create Medication request Request
7. Validate period
Validation purpose: It is needed to check if medication request period does not exceed allowed maximum of days.
If medication request has program with MEDICATION_REQUEST_MAX_PERIOD_DAY in medical program setting:
Check that medication request period (ended_at - started_at) less than or equal to medical program setting MEDICATION_REQUEST_MAX_PERIOD_DAY parameter
in case of error - return 200 with status = INVALID and rejection_reason = “Period length exceeds allowed value for the medical program“
If medication request has program without MEDICATION_REQUEST_MAX_PERIOD_DAY in medical program setting:Check that medication request period (ended_at - started_at) less than or equal to MEDICATION_REQUEST_MAX_PERIOD_DAY parameter from chartsin case of error - return 200 with status = INVALID and rejection_reason = “Period length exceeds default maximum value“
8. Validate context
Validate "context" is an active (not entered-in-error) entity from corresponding dictionary, that belongs to the current patient
Validate there is an entity in collection $.data.context.identifier.type.coding[0].code with id == $.data.context.identifier.value that belongs to the current patient
in case of error - return 200 with status = INVALID and rejection_reason = “Encounter entity is not found for program“
encounter diagnosis is not empty in $.encounter.diagnosis
in case of error return 422 ("Encounter without diagnosis can not be referenced")
9. Valdate person
Applies to programs: any
Validation purpose: It is needed to check if person has allowed verification status to get medication.
Validate person's verification status as described on Create Medication request Request
10. Validate declaration for a program
Validation purpose: It is needed to check specified params for each medical program.
Declaration should always be validated for each program. Validate skip_medication_request_employee_declaration_verify and skip_medication_request_legal_entity_declaration_verify parameters at medical program settings as described at Create Medication request Request if there are some exclusions.
Generate structure for response
Collect array for all programs in payload with status for each (VALID or INVALID) and rejection_reason
ЕСОЗ - публічна документація