Skip to content

Feat/unregister doctor for camp

Mukthanand Reddy M requested to merge feat/unregister-doctor-for-camp into develop

Overview

This MR introduces three key improvements to doctor management in the EHRS platform: unregistering doctors from camps, filtering unavailable doctors from volunteer assignment options, and allowing admins/doctors to edit doctor profile information.

What does this MR do and why?

Doctor management had several gaps in the workflow:

  • There was no way to remove a doctor from a camp once registered, making roster corrections impossible.
  • Unavailable doctors were still showing up in the volunteer assignment dropdown, leading to potential bad assignments.
  • Doctor profile information couldn't be updated after creation, causing stale data issues.

This MR addresses all three with minimal scope and using existing patterns (existing API, alert system, modal patterns).

Changes Made

  • src/lib/api.ts — Added unregisterDoctorFromCamp API function
  • src/pages/ManageDoctorsPage.tsx — Unregister functionality with bulk selection UI and separate tracking for register vs unregister
  • src/pages/volunteer/AssignDoctorPage.tsx — Filter out doctors marked as unavailable from the assignment dropdown
  • src/pages/profile/ProfilePage.tsx — Edit doctor profile modal with all fields (name, age, sex, specialization, email, phone, license number)
  • src/components/ProfileLayout.tsx — Extended with an actions prop to support header buttons
  • tests/admin/ManageDoctorsPage.test.tsx — Updated test selectors
  • tests/unit/components/AssignDoctorPage.test.tsx — Fixed test mocking

Technical Details

  • Unregister flow: Bulk selection in ManageDoctorsPage tracks doctors to register and unregister separately. Calls unregisterDoctorFromCamp on confirm with error handling and success toasts.
  • Filter unavailable: Simple client-side filter on the doctors list before rendering the assignment dropdown — no API changes needed.
  • Edit profile: Modal integrated into ProfilePage, uses the existing updateDoctor API endpoint. ProfileLayout was extended with an actions prop rather than modifying its internals.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 📝 Documentation update
  • 🎨 UI/UX improvement
  • ️ Refactor (no functional changes)
  • Performance improvement
  • 🧪 Test update
  • 🔧 Configuration change
  • 🚨 Security fix

Related Issues / References

Screenshots or Screen Recordings

Before After
image

How to Set Up and Validate Locally

  1. Checkout this branch
  2. Install dependencies if changed:
    bun install
  3. Run the dev server:
    bun dev
  4. To test unregister: Go to ManageDoctorsPage → select a registered doctor → use the registration modal to unregister
  5. To test filter: Go to AssignDoctorPage → verify unavailable doctors don't appear in the dropdown
  6. To test edit profile: Open a doctor's profile as an admin or as the doctor themselves → click "Edit Profile" → update fields → save

Testing Done

  • Manual testing completed
  • Unit tests added/updated

Test Cases Covered:

Scenario Expected Result Status
Coordinator unregisters a doctor from a camp Doctor removed from roster, success toast shown
Volunteer opens assign doctor dropdown Only available doctors are listed
Admin edits any doctor profile Changes saved, success notification shown
Doctor edits own profile Edit button visible and functional
Doctor tries to edit another doctor's profile Edit button not shown

Code Quality Checklist

Code Standards

  • Code follows project conventions (naming, structure, formatting)
  • No console.log() or debugger statements left in code
  • No unused imports, variables, or functions
  • No duplicate code and use of existing components for reusability
  • i18n check passed with no hardcoded strings in codebase for i18n support
  • TypeScript types are properly defined (no any unless justified)
  • ESLint and Prettier checks pass
    bun run lint

React Best Practices

  • Components are properly split and single-responsibility
  • Hooks follow rules (no conditional hooks, proper dependencies)
  • State management is appropriate (local vs global state)
  • No unnecessary re-renders (memoization used where needed)
  • Event handlers are properly cleaned up

Component Patterns

  • shadcn/ui components used correctly
  • Tailwind classes follow utility-first approach
  • Responsive design considered (mobile-first if applicable)
  • Accessibility attributes included (aria-*, role, etc.)
  • Icons from lucide-react used consistently

API & Data Fetching

  • TanStack Query used for server state (if applicable)
  • Loading and error states handled
  • API types defined in src/types/api.ts
  • Axios interceptors handle auth tokens correctly
  • Use of Zod for data validations

Error Handling

  • Errors are caught and handled gracefully
  • User-friendly error messages displayed
  • Errors are being toasted properly
  • Network failures handled appropriately

Documentation

  • README.md updated (if setup steps changed)
  • .env.example updated (if new env vars added)
  • CHANGELOG.md updated (if applicable)

Known Limitations / Technical Debt

None introduced. Follow-up: consider moving the unavailable doctor filter to the API layer to avoid fetching unnecessary data on the frontend.

Additional Notes

  • Permission logic: Unregister is coordinator/admin only. Edit Profile is available to admins (any doctor) and to doctors (own profile only). The edit button does not appear on patient profiles.
  • All changes use existing API endpoints and UI patterns — no new dependencies introduced.
  • Build is clean with no TypeScript errors.

MR Acceptance Checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Mukthanand Reddy M

Merge request reports

Loading