Skip to content

fix: update working of reassign and consultation

Vandana reddy Balannagari requested to merge fix/reassinging into fix/develop

Merge Request: Multi-Doctor Consultation & Reassignment Flow

Overview

This MR implements a robust Multi-Doctor workflow, allowing patients to see multiple specialists in a single camp visit. It resolves the issue where patients were "lost" or "locked" after a single consultation and enables coordinated referrals with seamless medication verification across all doctors.


What does this MR do and why?

Motivation

Previously, the system assumed a linear one-doctor-per-visit model, which failed in real-world camp scenarios where patients need multiple consultations (e.g., Dentist → Pediatrician).

Approach

  • Decoupled prescription validation from cycle counts in the backend.
  • Introduced a state-aware multi-doctor flow in the frontend.
  • Enabled handling of multiple active consultations per visit.

Trade-offs

  • Multiple active consultations required adding DISTINCT logic in queue dashboards to avoid duplicate patient entries.

Changes Made

Frontend (Vite + TypeScript)

  • AssignDoctorPage.tsx

    • Redesigned into a 3-card layout:

      1. Initial Assignment
      2. Referral
      3. Doctor Swap
  • UpdatePrescriptionPage.tsx

    • Prevents auto-navigation if other doctor records are pending.
  • VerifyMedicinesPage.tsx

    • Added completedConsultationIds tracking
    • Enables sequential verification of multiple doctors.

Tests

  • Updated AssignDoctorPage.test.tsx

    • Supports new state-based UI logic and card visibility.

Technical Details

Root Cause (Bug Fix)

Reassigning a doctor (Card 3) previously left the old specialization in the queue, making patients invisible to the new doctor. Fixed by synchronizing specialization during reassignment API call.

Architecture Change

  • Shifted from one-shot navigation → state-aware progression

  • Frontend now:

    • Fetches all consultations in a visit
    • Requires all to be completed/verified before queue transition

Type of Change

  • New feature (non-breaking functionality)
  • 🎨 UI/UX improvement
  • 🧪 Test update

Related Issues / References

closes #325 (closed)


Screenshots / Recordings

change-reassign image

Before After
Original Single Card UI New 3-Card Reassign UI

How to Set Up and Validate Locally

Setup

  1. Pull latest backend and frontend changes
  2. Run Alembic migrations
  3. Start backend and frontend servers

Validation Steps

  1. Assign patient to Doctor A (Spec X)

  2. In AssignDoctorPage, use Card 2 to refer to Spec Y

  3. Complete both consultations

  4. Open Verify Medicines

  5. Validate flow:

    • Verify Doctor A → success toast → card turns green
    • Verify Doctor B → auto-navigation to queue

Run Tests

npm test tests/unit/components/AssignDoctorPage.test.tsx

Testing Done

  • Manual testing for referral and doctor swap flows

  • Unit tests updated and passing

  • Database validation:


Code Quality Checklist

Code Standards

  • Code follows project structure and naming conventions
  • No console.log() statements
  • No any types used
  • ESLint and Prettier checks pass

React Best Practices

  • VerifyMedicinesPage uses state tracking (completedConsultationIds)
  • Conditional rendering implemented for 3-card UI
  • Proper dependency handling in useEffect

Known Limitations / Technical Debt

  • DISTINCT ON is PostgreSQL-specific (may require changes for other DBs)
  • UI may need scroll optimization for 3+ consultations

closes #325 (closed)

Merge request reports

Loading