Fix the complete councelling route by removing unnecessary data in request body
Summary
Simplify the counseling page to only show a search bar for book number and a "Done Counseling" button that directly calls the counseling endpoint.
Current Behavior (Before)
The counseling page has a complex multi-step flow:
- Book Number Search - Enter patient book number
- Patient Search Toggle - Alternative search by name/phone
- Patient Status Tracker - Shows patient's current status
- Consultation Selection - Lists all consultations grouped by camp
- Shows camp date and location
- Shows doctor name and chief complaint
- User must select a specific consultation
- Counseling Form - Detailed form with:
- Consultation summary
- "Counseling completed" checkbox
- Dietary Advice textarea
- Lifestyle Advice textarea
- Additional Notes textarea
- Save/Cancel buttons
Problem Statement
The current counseling workflow is overly complex for the actual use case. Volunteers only need to mark that counseling has been completed for a patient, but they must navigate through multiple screens and fill out optional form fields that aren't being used.
This creates unnecessary friction and slows down the counseling process.
Proposed Solution
Simplify the page to a two-step flow:
- Search - Enter book number to find patient
- Mark Complete - Click "Done Counseling" button to complete
New Flow
- User enters book number in search field
- System fetches and displays patient details
- User clicks "Done Counseling" button
- System calls PUT /api/v1/consultations/counselling/{book_no}
- Success message shown and form resets
What to Remove
- Patient search toggle
- Patient status tracker
- Consultation selection screen
- Counseling form fields (dietary advice, lifestyle advice, notes)
- "Counseling completed" checkbox
What to Keep
- Book number search input
- Patient details display
- API endpoint call to mark counseling complete
- Success/error messaging
Implementation Details
Files Modified src/pages/volunteer/CounselingPage.tsx - Simplified component tests/unit/components/CounselingPage.test.tsx - Updated tests
Changes Made Component Changes:
-
Removed useQuery for consultations
-
Removed selectedConsultation state
-
Removed showPatientSearch state
-
Removed counselingData form state
-
Simplified to just search → display → complete flow
-
Added Enter key support for search input
-
Form auto-resets after successful completion Test Changes:
-
Removed tests for consultation selection
-
Removed tests for counseling form fields
-
Added tests for "Done Counseling" button
-
Added tests for success/error states
-
Added tests for form reset behavior
API Endpoint
PUT /api/v1/consultations/counselling/{book_no}
No request body required - the endpoint simply marks counseling as done for the patient.
Benefits