feat(queue): allow all volunteers to verify medicines and expose picked_by details
Merge Request
Overview
This MR updates the consultation queue workflow to allow any volunteer to verify medicines (instead of only the volunteer who picked the patient) while still preserving and exposing information about who picked the patient.
What does this MR do and why?
Previously, the system restricted medicine verification to the volunteer who originally picked the patient. This caused operational issues because if the original picker was unavailable, other volunteers could not proceed with verification.
This MR:
- Removes the ownership restriction so any volunteer can verify medicines.
- Preserves information about which volunteer picked the patient.
- Exposes picker details (
picked_by) through API responses and WebSocket payloads for transparency in the UI.
This improves flexibility for volunteers while maintaining traceability of actions.
Changes Made
- Removed the restriction that blocked volunteers from verifying if they did not pick the patient.
- Introduced
get_queue_picked_by_info()helper function to resolve picker details. - Added
picked_byinformation to API responses. - Added
picked_byto WebSocket event payloads. - Optimized database queries with
joinedload.
Technical Details
Root cause of issue:
assigned_by != actor_user_id check prevented volunteers other than the picker from verifying medicines.
Fix:
Removed the ownership restriction while retaining pickup information.
New behavior:
- Any volunteer can verify medicines.
- The system still records who picked the patient.
- UI can display picker details.
Type of Change
-
✨ New feature (non-breaking change that adds functionality) -
🐛 Bug fix (non-breaking change that fixes an issue) -
⚡ Performance improvement
Related Issues / References
closes #96 (closed) Related to frontend issue: Display picked-by volunteer in queue UI.
Screenshots or Screen Recordings
N/A (Backend change — verified via API response).
How to Validate Locally
- Pick a patient as Volunteer A.
- Verify medicine as Volunteer B.
- Confirm verification succeeds (no ownership error).
- Confirm API returns:
"picked_by": {
"user_id": "...",
"user_name": "...",
"user_phone_no": "..."
}
- Confirm WebSocket updates include
picked_by.
Testing Done
-
Manual testing via API and UI -
Queue flow tested end-to-end
Test Cases Covered:
| Scenario | Expected Result | Status |
|---|---|---|
| Any volunteer verifies medicine | Success | |
| Picker info returned | picked_by present | |
| WebSocket updates include picked_by | Data available |
Test Commands Run:
python3 -m py_compile ehrs-fastapi/app/services/consultation_queue_service.py
python3 -m py_compile ehrs-fastapi/app/api/v1/routes/consultation_queue_routes.py
Code Quality Checklist
Code Standards
-
Code follows project conventions -
No debug statements -
No unused imports -
No duplicate code -
Type hints applied
Python & FastAPI Best Practices
-
Functions follow single-responsibility principle -
Dependency injection used -
SQLAlchemy queries optimized
API Design
-
REST conventions followed -
Proper status codes -
Validation applied
Database & Migrations
-
No schema changes required
Security
-
No sensitive data leaked -
ORM used (no SQL injection risk)
Error Handling
-
Proper error handling -
User-friendly messages
Documentation
-
API behavior documented in code comments
Known Limitations / Technical Debt
None currently identified.
Additional Notes
This change improves collaboration by allowing any volunteer to continue the workflow while preserving accountability.
MR Acceptance Checklist
Quality & Correctness
-
Code works as intended -
No regressions -
Edge cases covered
Maintainability
-
Code readable and organized -
Testable and extensible
Acceptance Review
-
Reviewed by at least 1 teammate -
Reviewed by product owner