Table of Contents |
---|
...
For https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/583405719/Get+Medication+request+by+ID the new requirement and the validation were added :
...
User of MSP, PRIMARY_CARE (DOCTOR, etc) can see all Medication request for which he is the a doctor (employee_id)
User of MSP, PRIMARY_CARE (DOCTOR, etc) can see all the Medication requests of the patients whom he has an active declaration with by yourself a doctor (employee_id)User of PHARMACY or NHS_ADMIN (PHARMACIST, etc) can see all Medication request (without limitations)
User of MSP, PRIMARY_CARE, OUTPATIENT (DOCTOR, SPECIALIST, etc) can see all Medication request based on the approval of the care plan that is contained in the Medication request
Input parameters (filters)
...
Get `my_party_id` from `$.context.user_id`
Return 500 in case ("Not found party for this user!")
Get list from `prm.employees` for this `party_id` & `$.context.legal_entity_id`
Search Medication requests by filters:
Code Block SELECT * FROM medication_request MR INNER JOIN employees E ON E.party_id = my_party_id AND (E.id = $.employee_id OR $.employee_id IS NULL) AND (E.legal_entity_id == $.context.legal_entity_id OR $.context.legal_entity_id IS NULL) LEFT JOIN declarations D ON D.Employee_id = E.id AND E.status = ACTIVE AND D.status = ACTIVE AND MR.person_id = D.person_id WHERE (MR.id = $.id OR MR.request_number = $.id) AND MR.employee_id == E.id AND MR.is_active = TRUE
Logic WS for medication requests based on care plan
Get party_id from $.context.user_id
Get list from $.prm.employees for this party_id
Get care_plan_id from $.medication_requests.based_on_care_plan_id
Check $.approvals for user's employees (granted_to) on care_plan_id (granted_resources) and $.medication_requests.person_id (granted_by)
Search Medication requests by filters: based_on_care_plan_id, person_id.
Code Block SELECT * FROM medication_request MR WHERE (MR.id = $.id OR MR.request_number = $.id) AND MR.based_on_care_plan_id = $.id AND MR.person_id = $.id AND MR.is_active = TRUE
...