ЕСОЗ - публічна документація
RC_2_PSYHO_Deactivate medical program
Specification
Apiary | |
JSON Schema response | SPECS |
Purpose
This WS is design to update flags "is_active" for Medical Program.
WS logic
Authorize
- Verify the validity of access token
- In case error - generate 401 response
- Check user scope (scope = 'medical_program:deactivate') in order to perform this action
- In case error - generate 403 response
Validate FKs
Purpose validation: Check on active program medication. Only medical program without active program medication can be deactivated. In case on existing active program medication linked with medical program error must be shown.
- Check exist `program_medication` by $.medical_program_id=$.id & `is_active`= false
- if invalid - return 409 error (message: "This program has active participants. Only medical programs without participants can be deactivated.")
Validate PK Program Medications
Purpose validation: Check on existing record for Medical program
Check exist `Medical_program` by $.id.
if invalid - return 404 error (message: "Medical program with id={$.id} doesn't exist.")
Validate status
Purpose validation: Medical program should be active (is_active == TRUE)
- Validate `is_active` == TRUE
- if invalid - return 409 error (message: "Medical program is not active and can't be deactivated")
Deactivate Program Medications
Update medical program record by $.id set values:
Destination | Source |
---|---|
is_active | FALSE |
updated_at | :timestamp |
updated_by | user_id |
Deactivate Medical Program Provision
For MEDICATION medical program type (according to link).
Deactivate all related active medical program provision entities:
set is_active = false
set deactivate_reason = AUTO_MEDICAL_PROGRAM_DEACTIVATION
set updated_at, updated by
ЕСОЗ - публічна документація