Skip to content

Fix assign doctor API payload and add change consultation checkbox

Vandana reddy Balannagari requested to merge feat/change-consultation into develop

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-doctor was 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 using book_no
  • Added consultation dropdown (based on patient)
  • Added doctor dropdown for reassignment
  • Integrated /consultations/reassign-doctor API
  • Added validation (disable button if not selected)
  • Added success and error alerts

Technical Details

Flow Implemented:

  1. User enters/selects book_no

  2. Fetch consultations using:

    getPatientConsultations(book_no)
  3. Display consultations in dropdown

  4. Fetch and display doctors list

  5. User selects:

    • consultation
    • new doctor
  6. 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 (image)
Consultation dropdown image
Doctor selection image
Successful reassignment image,image

How to Set Up and Validate Locally

  1. Pull this branch

  2. Install dependencies:

    bun install
  3. Start frontend:

    bun dev
  4. Ensure backend is running:

    http://localhost:8000

Test Steps

  1. Open Assign Doctor page
  2. Enter/select patient using book_no
  3. Verify consultations are loaded
  4. Select a consultation
  5. Select a new doctor
  6. 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.example updated (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

Merge request reports

Loading