Purpose
This method is designed to reject previously created Medication Dispense
Specification
WS logic
Authorize user
- Verify the validity of access token
- Return 401 in case validation fails
- Check user scopes in order to perform this action (scope = 'medication_dispense:reject')
- Return 403 in case invalid scope(s)
Validate request
Get legal entity from token
- Extract legal_entity_id (client_id) from token
Validate context
- Only users of legal entity who has created Medication Dispense and NHS Admin can reject Medication Dispense
- medication_dispense.legal_entity_id = client_id (context) or client_id (context) (type) in TOKENS_TYPE_ADMIN
Validate status (transition)
- Dispense should be active in order to process it
- is_active = true
- status = 'NEW'
Change dispense status
Update dispense status to REJECTED
Parameter | Source | Description |
---|---|---|
payment_id | Request: $.payment_id or NULL | If payment_id exists in request - update record with payment_id |
status | Const: REJECTED | |
updated_at | Timestamp: now() | Get current date-time |
updated_by | Token: user_id | Extract user from token |