Table of Contents |
---|
Status
Page Properties | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Purpose
This WS is design to update reimbursement and/or flags "is_active", "medication_request_allowed" for Medication within Medical_program.
Specification
WS logic
Authorize
- Verify the validity of access token
- In case error - generate 401 response
- Check user scope (scope = 'program_medication:write') in order to perform this action
- In case error - generate 403 response
Verify the validity of access token
- Check user scope (scope = 'program_medications:write') in order to perform this action
- In case error - generate 401 response
Validate request (JSON schema)
- Validate request using JSON schemas:
- Return 422 with list of validation errors in case validation fails (422 EView)
Validate PK Program Medications
1. Check participant Program_medication ($.id) exists in PRM.medications
...
Code Block | ||
---|---|---|
| ||
{:error, [{%{ description: "ID for Medication within the Medical program is not found", params: [], rule: :invalid }, "$.id"}]} |
Validate status
1. Validate `is_active` == TRUE
- if invalid - return 409 eror (message: "Medication within the program is inactive")
Validate medical_request_allowed status
To deactivate Participant (to update is_active == FALSE for medication within the program with id={id}) medical_request_allowed must be inactive (medical_request_allowed == FALSE)
...
- if invalid - return 409 eror (message: "To deactivate medication within the program firstly disable medical_request_allowed")
Update Program Medication
Update medication record by $.id set values:
Destination | Source | Description |
---|---|---|
reimbursement | $.reimbursement | |
is_active | $.is_active | |
medical_request_allowed | $.medical_request_allowed | |
inserted_at | :timestamp | Get current date-time |
inserted_by | user_id | Extract user from token |
updated_at | :timestamp | Get current date-time |
updated_by | user_id | Extract user from token |