Skip to content

Draft: Resolve "bug/Unable to register next patient after assigning doctor in camp registration"

Overview

This MR fixes an issue in the patient registration module where the system incorrectly detected an existing patient when registering a new book number.

Previously, when a patient was registered and assigned to a camp, the system redirected back to the registration page but still showed the previous patient data when entering a new book number.

This fix ensures that the correct patient lookup is performed based on the entered book number and that the registration form state is reset properly.


What does this MR do and why?

The issue occurred because the patient lookup logic and frontend state were not properly resetting after a successful registration.

As a result:

  • The system incorrectly showed "Existing Patient Found" for new book numbers.
  • Previous patient data remained in the form.

This MR fixes the issue by ensuring:

  • Correct patient lookup based on the entered book number
  • Proper resetting of registration form state after successful registration
  • Accurate display of patient information

Changes Made

  • Fixed patient lookup logic during registration
  • Ensured correct book number is used for patient search
  • Reset patient registration form state after successful registration
  • Prevented previously loaded patient data from appearing for new book numbers
  • Updated related components handling patient registration workflow

Technical Details

Root Cause

The frontend state containing patient information was not cleared after a patient was registered and assigned to a camp. Because of this, the UI incorrectly displayed previously fetched patient data when registering a new book number.

Fix Implemented

  • Reset patient state after successful registration
  • Ensure patient lookup is triggered only with the correct book number
  • Prevent stale state from being reused during new registrations

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • New feature
  • 💥 Breaking change
  • 📝 Documentation update
  • 🎨 UI/UX improvement
  • ️ Refactor
  • Performance improvement
  • 🧪 Test update
  • 🔧 Configuration change
  • 🚨 Security fix

Screenshots or Screen Recordings

Before After
New book numbers incorrectly showed existing patient data Screencast_from_2026-04-09_14-15-19Correct patient lookup based on entered book number

How to Set Up and Validate Locally

  1. Checkout this branch
  2. Install dependencies
bun install
  1. Run the development server
bun dev
  1. Navigate to patient registration page
/volunteer/patient-registration
  1. Steps to validate
  • Register a patient with a specific book number
  • Assign the patient to a camp
  • After redirect, attempt to register a new patient with a different book number

Expected Result:

  • The system should not show existing patient data
  • The form should load fresh state for the new patient

Testing Done

  • Manual testing completed
  • Unit tests added

Test Cases Covered

Scenario Expected Result Status
Register patient with Book No 10 Patient registered successfully
Register new patient with Book No 12 No previous patient data shown
Redirect after camp assignment Registration form resets correctly

Known Limitations / Technical Debt

Currently only manual testing has been performed. Automated tests may be added in future updates.


Additional Notes

This fix improves the reliability of the patient registration workflow and prevents incorrect patient detection during new registrations.


Closes #303 (closed)

Merge request reports

Loading