Skip to content

fix(queue): route patients to food queue after vitals

Damanagari Sathwika requested to merge fix/foods into develop

Merge Request

Overview

This MR introduces Food Queue integration into the existing backend queue workflow.

The goal is to ensure that after vitals are completed, patients automatically move into Food Queue before consultation. Food Queue is now handled as part of the existing queue architecture and supports Complete and Skip actions before consultation.


What does this MR do and why?

Previously, patients transitioned directly from Vitals to Consultation/Waiting.

Previous flow:

Registration → Vitals Waiting → Vitals → Consultation

This bypassed the newly introduced Food Queue workflow.

This MR updates backend queue transition logic so Food Queue becomes part of the patient progression flow.

Updated flow:

Registration → Vitals Waiting → Vitals → Food Queue → Consultation

Approach taken:

  • Integrate Food Queue into existing queue architecture
  • Reuse QueueStatusEnum and queue transition patterns
  • Modify auto-transition logic after vitals save
  • Add Food Queue transition handling for Complete and Skip actions
  • Preserve existing consultation, medicine and counselling workflows

Changes Made

Backend Queue Integration

Modified:

  • app/models/consultation_queue.py
  • app/services/patient_service.py
  • app/services/food_queue_service.py
  • app/api/v1/routes/food_queue_routes.py

Key Changes

  1. Added food into QueueStatusEnum
  2. Modified post-vitals auto transition logic
  3. Integrated Food Queue into existing queue lifecycle
  4. Added transition handling:
    • Food Complete → Consultation Waiting
    • Food Skip → Consultation Waiting
  5. Updated Food Queue routes and service flow

Technical Details

Root Cause

Patients were automatically transitioning:

Vitals → Waiting/Consultation

which bypassed Food Queue.

The auto-transition logic in patient service still updated queue status directly to waiting after vitals save.

Fix

Updated queue transition logic so:

After vitals save:

queue_status = food

instead of:

queue_status = waiting

Food Queue service now updates:

food → waiting

upon:

  • Complete
  • Skip

This preserves consultation readiness while enforcing Food Queue flow.


Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • 💥 Breaking change
  • 📝 Documentation update
  • ️ Refactor
  • Performance improvement
  • 🧪 Test update
  • 🔧 Configuration change
  • 🚨 Security fix
  • 🗑️ Deprecation

Related Issues / References

  • Closes Food Queue backend workflow issue
  • Related to frontend Food Queue integration

Screenshots or Screen Recordings

Add:

  • Swagger /docs showing Food Queue endpoints
  • Queue status transition screenshots
  • Curl verification screenshots

How to Validate Locally

Previous Behavior

Vitals → Consultation

New Behavior

Vitals → Food Queue → Consultation

Validation steps:

  1. Run backend
  2. Login and register patient
  3. Move patient to Vitals
  4. Save vitals
  5. Verify patient appears in Food Queue
  6. Complete or Skip Food Queue
  7. Verify patient moves to consultation/waiting

API validation:

Check patient queue:

curl http://localhost:8000/api/v1/queue/patient/{book_no}

Expected after vitals:

"queue_status":"food"

Expected after Complete/Skip:

"queue_status":"waiting"

Testing Done

  • Unit tests added/updated
  • API endpoint tests passing

Test Cases Covered

Scenario Expected Result Status
Save vitals Patient enters Food Queue
Food Complete Moves to waiting/consultation
Food Skip Moves to waiting/consultation
Existing consultation flow Remains functional

Test Commands Run

curl http://localhost:8000/api/v1/queue/patient/{book_no}

curl http://localhost:8000/api/v1/food-queue

curl -X PATCH http://localhost:8000/api/v1/food-queue/{id}/complete

curl -X PATCH http://localhost:8000/api/v1/food-queue/{id}/skip

Code Quality Checklist

Code Standards

  • Code follows project conventions
  • No unused code
  • Type hints maintained
  • Ruff checks pass

Python & FastAPI Best Practices

  • Single responsibility followed
  • Dependency injection maintained
  • Pydantic validation used
  • Error handling preserved

API Design

  • RESTful conventions followed
  • Proper status codes returned
  • Input validation implemented
  • OpenAPI docs updated

Database & Migrations

  • Queue state updated safely
  • Migration required (if applicable)

Security

  • No sensitive data logged
  • ORM usage preserved

Error Handling

  • Errors handled gracefully
  • Standard API responses preserved

Documentation

  • README updated
  • API documentation updated
  • CHANGELOG updated

Known Limitations / Technical Debt

  • Frontend synchronization depends on correct Food Queue API integration
  • Dashboard and queue counts rely on frontend refresh/state updates

Additional Notes

This MR focuses on backend queue transition behavior.

Food Queue is now treated as part of the queue lifecycle and no longer bypassed after vitals completion.


MR Acceptance Checklist

Quality & Correctness

  • Code works as intended
  • Existing functionality preserved
  • Queue transition edge cases handled

Maintainability

  • Code follows existing patterns
  • Queue architecture reused
  • Logic remains modular

Acceptance Review

  • Reviewed by teammate
  • Reviewed by product owner

Merge request reports

Loading