Bug: Prevent Selecting Specialization When Repeat Medicine is Checked
Bug Summary
In the volunteer flow for assigning a doctor or specialization to a patient, there was a lack of validation/exclusivity between selecting standard medical specializations (e.g., General, Cardiology) and checking the "Repeat Medicine Only" option. This allowed a patient to be registered under conflicting flow states, causing routing issues in the consultation and prescription queues.
Current Behavior
Before the fix:
- Selecting "Repeat Medicine" did not disable or lock out normal specialization card options (General, Cardiology, etc.).
- Selecting a standard specialization did not disable the "Repeat Medicine" option.
- Volunteers could submit both selections, resulting in conflicting statuses and incorrect queue transitions.
Expected Behavior
- The selection of standard specializations and "Repeat Medicine" must be mutually exclusive.
- Toggling "Repeat Medicine" ON must disable all standard specialization option cards (reducing opacity, changing cursor to
not-allowed, and ignoring clicks). - Selecting a standard specialization must disable the "Repeat Medicine" card toggle.
- The state should be fully controlled/synchronized with the parent component (
AssignDoctorPage) to ensure clean submissions.
Impact
-
Severity:
⚠ ️ High - Major workflow feature is broken. Routing patients to incorrect queues or assigning them under conflicting specializations causes significant camp delays, although manual correction is possible. -
Affected Users:
volunteer,coordinator -
Affected Modules:
AssignDoctorPage,SpecializationSelector
Reproduction Steps
- Navigate to Volunteer -> Registration Dashboard / Quick Search.
- Select a patient and go to the Assign Doctor / Specialization page.
- Click on a standard specialization card (e.g., General).
- Observe that the Repeat Medicine checkbox/card remains enabled.
- Click the Repeat Medicine card. Notice that both selections can be active or submitted simultaneously.
Reproduction Rate: [x] Always [ ] Sometimes [ ] Rarely
Environment
Does the bug occur on:
-
Local development -
Staging environment -
Production environment
Test-Driven Bug Verification
Bug Reproduction Test Cases
| Test ID | Test Description | Steps to Reproduce | Expected Result | Actual Result (Before Fix) | Status (After Fix) |
|---|---|---|---|---|---|
| TC-BUG-001 | Disable specializations when repeat medicine is checked | 1. Toggle repeat medicine ON. 2. Try clicking standard specialization cards. |
Standard specialization cards are disabled and clicks are ignored. | Specialization cards remain active and clickable. |
|
| TC-BUG-002 | Disable repeat medicine when standard specialization is selected | 1. Select a standard specialization card. 2. Try clicking repeat medicine card. |
Repeat medicine card is disabled and clicks are ignored. | Repeat medicine card remains active and clickable. |
|
Regression Test Cases
Scenario 1: Bug is Fixed
Given a patient is on the Assign Doctor Page
And no specialization is currently selected
When the volunteer clicks on the "Repeat Medicine" card
Then the "Repeat Medicine" card should be selected
And all standard specialization cards should be visually disabled
And clicking a standard specialization card should not change the selection
Scenario 2: Selecting standard specialization blocks Repeat Medicine
Given a patient is on the Assign Doctor Page
And no specialization is currently selected
When the volunteer clicks on a standard specialization card (e.g. "General")
Then the "General" card should be selected
And the "Repeat Medicine" card should be visually disabled
And clicking the "Repeat Medicine" card should not toggle it ON
Unit Test Requirements (for fix)
-
Test case that reproduces the bug scenario -
Test for the edge case that was missed -
Test for correct state management -
Test that disabled options ignore clicks
Components/Functions to Add Tests For:
| File | Function/Component | Test to Add |
|---|---|---|
tests/unit/components/SpecializationSelector.test.tsx |
SpecializationSelector |
"disables specialization selection when repeat medicine is checked" |
tests/unit/components/SpecializationSelector.test.tsx |
SpecializationSelector |
"disables repeat medicine toggle when a specialization is selected" |
tests/unit/components/AssignDoctorPage.test.tsx |
AssignDoctorPage |
"correctly synchronizes selectedSpecialization and isRepeatMedicine with SpecializationSelector" |
Root Cause Analysis
What caused this bug?
-
Logic error in component -
Missing null/undefined check -
Incorrect API response handling -
Race condition -
State management issue -
Event handler not cleaned up -
Incorrect TypeScript type -
CSS/Styling issue -
Browser compatibility -
Other: _____
Technical Details:
The SpecializationSelector component was managing internal state for selectedSpecialization and repeatMedicineChecked without proper validation rules to enforce mutual exclusivity. The parent AssignDoctorPage was not properly controlling or synchronizing these two states. By providing a controlled prop selectedSpecialization to the SpecializationSelector and disabling respective click handlers when the alternate condition is met, we enforced mutual exclusivity.
Fix Verification Checklist
-
Bug reproduction steps now produce expected behavior -
All test cases in TC-BUG-* now pass -
No console errors related to this issue -
Fix works on all affected browsers -
Fix works on all affected viewport sizes -
No regressions in related functionality -
Unit tests added to prevent recurrence -
ESLint rules met ( react-hooks/set-state-in-effecthandled)
Browser Testing (if UI-related)
| Browser | Tested | Status |
|---|---|---|
| Chrome | [x] | |
| Firefox | [x] | |
| Safari | [x] | |
| Edge | [x] |
Responsive Testing (if UI-related)
| Viewport | Tested | Status |
|---|---|---|
| Mobile (<576px) | [x] | |
| Tablet (576px-991px) | [x] | |
| Desktop (≥992px) | [x] |
Additional Context
Related Commits
-
313ba608- fix: prevent repeat medicine & specialization conflict- Controls
SpecializationSelectorfromAssignDoctorPage - Disables standard cards when repeat medicine is checked
- Disables repeat medicine toggling when standard specializations are checked
- Adds unit tests verifying controlled synchronization and disabling logic
- Controls
Related Issues
- Duplicates: N/A
- Related to: Queue bypass flow for repeat medicine patients