Fix assign doctor API payload and add change consultation checkbox
Overview
This MR updates the frontend to support the "Change Doctor" feature in the Assign Doctor page. It allows users to reassign an existing consultation to a different doctor using the consultation list fetched based on book_no.
What does this MR do and why?
This MR implements a new UI section to reassign doctors for existing consultations without affecting the current Assign Doctor functionality.
Previously:
- No UI to reassign doctor for an existing consultation
- Users could only assign doctor, not change it
- Backend API
/reassign-doctorwas not integrated in frontend
Now:
- "Change Doctor" section added in Assign Doctor page
- Consultations are fetched using
book_no - Users can select consultation and new doctor
- Reassign doctor API is integrated and working
Changes Made
-
✅ Added "Change Doctor" section in AssignDoctorPage -
✅ Fetched consultations usingbook_no -
✅ Added consultation dropdown (based on patient) -
✅ Added doctor dropdown for reassignment -
✅ Integrated/consultations/reassign-doctorAPI -
✅ Added validation (disable button if not selected) -
✅ Added success and error alerts
Technical Details
Flow Implemented:
-
User enters/selects
book_no -
Fetch consultations using:
getPatientConsultations(book_no) -
Display consultations in dropdown
-
Fetch and display doctors list
-
User selects:
- consultation
- new doctor
-
Call API:
PUT /api/v1/consultations/reassign-doctor
Payload:
{
consultation_id: selectedConsultationId,
doctor_id: selectedDoctorId
}
Type of Change
-
✨ New feature (Change Doctor functionality) -
🔌 API integration
Related Issues / References
- Backend MR: Reassign Doctor API implementation
- Related to doctor reassignment feature
- colses #227 (closed)
Screenshots or Screen Recordings
| Feature | Screenshot |
|---|---|
| Change Doctor UI | ( ) |
| Consultation dropdown | ![]() |
| Doctor selection | ![]() |
| Successful reassignment |
,
|
How to Set Up and Validate Locally
-
Pull this branch
-
Install dependencies:
bun install -
Start frontend:
bun dev -
Ensure backend is running:
http://localhost:8000
Test Steps
- Open Assign Doctor page
- Enter/select patient using
book_no - Verify consultations are loaded
- Select a consultation
- Select a new doctor
- Click "Change Doctor"
Expected Result
- Consultations load correctly based on
book_no - User can select consultation and doctor
- API call succeeds
- Doctor is reassigned successfully
- Success message displayed
Testing Done
-
Manual testing completed
Test Cases Covered:
| Scenario | Expected Result | Status |
|---|---|---|
| Fetch consultations | Based on book_no | |
| Select consultation | Dropdown works | |
| Select doctor | Dropdown works | |
| Reassign doctor | API success | |
| Error handling | Proper alerts |
Code Quality Checklist
Code Standards
-
Code follows project conventions -
No existing logic modified -
Clean and readable code
React Best Practices
-
State handled properly -
No unnecessary re-renders -
Existing components untouched
API & Data Fetching
-
Correct API integration -
Proper payload structure -
Conditional fetching based on book_no
Error Handling
-
Alerts shown for success/failure -
API errors handled gracefully
Documentation
-
README.md updated (not required) -
.env.exampleupdated (not required)
Known Limitations / Technical Debt
- Requires existing consultations for selected
book_no - Depends on backend API availability
Additional Notes
- Existing Assign Doctor functionality is NOT modified
- New feature is added safely as a separate section
- Tested with local backend and dummy data
Edited by Vandana reddy Balannagari




