Kulcare Docs
Test reportsSessions

Session 9: Patient Management - List Page

Date: 2026-06-17 Module: Clinic App - Patient Management (Section 1: Patient List) URL: https://practice-stg-new.kulcare.com/cms/patients Test Plan: test-plans/clinic-app/patient-management.md Status: ✅ Complete


📊 Test Results Summary

SectionTested✅ Passed❌ Failed⏭️ SkippedPending
1.1 List Display55000
1.2 Search & Filter64201
1.3 Date Range20110
1.4 Pagination55000
1.5 Table Actions32100
1.6 Header Actions43102
1.7 Table Density22000
Total2721513

🐛 Bugs Found

Bug #Test IDDescriptionSeverityStatus
31LIST-11Partial name works, full name with space returns no results🟡 HighOpen
35LIST-20Date range filter UI not wired to API params🟠 MediumOpen
36LIST-12Phone search returns no results — search only queries name fields🟡 HighNEW
37LIST-51Export report API fails — EFS permission denied on staging🟡 HighNEW
38LIST-42Cross-clinic patients miss patient_facility_id — View link broken🟡 HighNEW

🔍 Detailed Test Results

1.1 List Display (5/5 Passed ✅)

#Test CaseResultNotes
LIST-01View patient list✅ PASSShows paginated list from GET /clinical/patients
LIST-02View stats cards✅ PASSShows Total, New, Active, Avg Visits cards
LIST-03Empty state - no patients✅ PASSShows "No patients" message when API returns empty
LIST-04Loading state✅ PASSShows loading spinner during API fetch
LIST-05Error state✅ PASSShows error message with retry on API failure

1.2 Search & Filter (4/6 Passed, 2 Failed)

#Test CaseResultBugNotes
LIST-10Search by name✅ PASS-Returns matching patients by name
LIST-11Search by partial name❌ FAIL#31"moh" works, "mohit" works, "mohit goyal" (with space) returns no results
LIST-12Search by phone❌ FAIL#36?search=988 returns no results — phone column not in search scope
LIST-13Search by MRN⏭️ Pending-Not tested
LIST-14Clear search✅ PASS-Clear search param resets to full list
LIST-15No results✅ PASS-Invalid search shows "No results" message
LIST-16Debounce search✅ PASS-~300ms debounce reduces excessive API calls

1.3 Date Range Filter (0/2 Passed)

#Test CaseResultBugNotes
LIST-20Filter by birth date range❌ FAIL#35Date filter UI exists but birth_date_from/birth_date_to params NOT sent to API
LIST-21Clear date filter⏭️ Skipped-Can't test clear when filter was never set (params not wired)

1.4 Pagination (5/5 Passed ✅)

#Test CaseResultNotes
LIST-30Next page✅ PASSClick Next → Shows page 2
LIST-31Previous page✅ PASSClick Previous → Returns to page 1
LIST-32Jump to page✅ PASSEnter page number → Shows that page
LIST-33Change page size✅ PASSSelect 10/25/50/100 → Updates results
LIST-34Total count displayed✅ PASSShows "Showing X of Y" in pagination

1.5 Table Actions (2/3 Passed, 1 Failed)

#Test CaseResultBugNotes
LIST-40Click Edit (pencil)✅ PASS-Uses patient.id in URL — works cross-clinic
LIST-41Click Print (printer)✅ PASS-Opens PatientPreviewModal
LIST-42Click View (eye)❌ FAIL#38Uses patient.patient_facility_id → null for cross-clinic patients

1.6 Header Actions (3/4 Passed, 1 Failed)

#Test CaseResultBugNotes
LIST-50Click Export✅ PASS-Opens ExportReportsModal
LIST-51Confirm export❌ FAIL#37API returns 422 — EFS permission denied on staging
LIST-52Click Upload✅ PASS-Opens PatientUploadModal (button exists in PatientsPage.tsx)
LIST-53Upload valid file⏭️ Pending-Not tested
LIST-54Upload invalid file⏭️ Pending-Not tested
LIST-55Click Add Patient✅ PASS-Opens AddPatientModal

1.7 Table Density (2/2 Passed ✅)

#Test CaseResultNotes
LIST-60Compact view✅ PASSToggle shows more rows, less spacing
LIST-61Comfortable view✅ PASSToggle shows less rows, more spacing

🐛 Bug Details

Bug #31: Full Name Search with Space Returns No Results (Reconfirmed)

FieldValue
Severity🟡 High
Bug #31
StatusOpen

Description: Previously found in federated search (Session 08). Reconfirmed on patient list search. Searching by partial name ("moh", "mohit") works, but adding a space ("mohit goyal") returns no results.

Root Cause: Search scope uses first_name ILIKE '%q%' OR last_name ILIKE '%q%' — splitting on space means "mohit goyal" becomes two separate LIKE clauses that don't match any single column.

Impact: Users who type full names (common behavior) get no results even when patient exists.


Bug #35: Date Range Filter Not Wired to API (Reconfirmed)

FieldValue
Severity🟠 Medium
Bug #35
StatusOpen

Description: Previously documented in Session 08. Reconfirmed — date filter UI exists on the patient list but birth_date_from and birth_date_to params are not included in the API query params sent by PatientsPage.tsx.


🆕 Bug #36: Phone Search Returns No Results

FieldValue
Severity🟡 High
Bug #36
StatusOpen

Description: Searching by phone number on the patient list returns no results. The patient list search API (GET /clinical/patients?search=) only queries first_name and last_name — phone_number is not in the search scope.

API Evidence:

curl 'https://api-stg.kulcare.com/clinical/patients?search=988&page=1&per_page=10' \
  -H 'Authorization: Bearer <token>'
# Returns: empty results, even though patients with phone containing "988" exist

Root Cause: Clinical::PatientsController#index search scope:

# Current (suspected):
scope.where('first_name ILIKE :q OR last_name ILIKE :q', q: "%#{search}%")

# Should be:
scope.where('first_name ILIKE :q OR last_name ILIKE :q OR phone_number ILIKE :q', q: "%#{search}%")

Impact: Staff/doctors cannot find patients by phone number — the most common search method in clinics.


🆕 Bug #37: Export Report API Fails — EFS Permission Denied

FieldValue
Severity🟡 High
Bug #37
StatusOpen

Description: Patient export report (POST /clinical/patients/generate_report) fails on staging due to filesystem permission error. Ruby's Dir.mkdir cannot create the EFS directory.

API Response (422):

{
  "data": null,
  "error": {
    "code": "validation_failed",
    "message": "Permission denied @ dir_s_mkdir - /opt/kulcare-efs-stg/patient_reports_staging",
    "details": [{
      "field": "base",
      "message": "Permission denied @ dir_s_mkdir - /opt/kulcare-efs-stg/patient_reports_staging"
    }]
  }
}

Root Cause: Staging infrastructure — /opt/kulcare-efs-stg/patient_reports_staging either not mounted or Rails process (deploy user) lacks write permissions. This is not a code bug — the API flow is correct, the filesystem is misconfigured only on staging.

Fix (DevOps):

# On staging Rails server:
sudo mkdir -p /opt/kulcare-efs-stg/patient_reports_staging
sudo chown deploy:deploy /opt/kulcare-efs-stg/patient_reports_staging

Code-level hardening (optional):

# Add fallback to /tmp if EFS unavailable
def report_dir
  dir = Rails.root.join('tmp', 'patient_reports')
  FileUtils.mkdir_p(dir)
  dir
rescue Errno::EACCES
  Rails.logger.warn("EFS unavailable, falling back to /tmp")
  dir = Rails.root.join('tmp', 'patient_reports_fallback')
  FileUtils.mkdir_p(dir)
  dir
end

✅ Confirmed Working Features

FeatureStatusNotes
Patient list with pagination✅ WorksGET /clinical/patients returns paginated results
Stats cards (Total, New, Active, Avg Visits)✅ WorksDisplayed correctly
Empty/loading/error states✅ WorksAll three states handled properly
Name search✅ WorksPartial name matching works
Clear search✅ WorksResets to full list
Debounce search✅ Works~300ms delay prevents excessive calls
Pagination (next/prev/jump/size)✅ WorksAll pagination controls functional
Total count display✅ Works"Showing X of Y" format
Edit action (pencil)✅ WorksNavigates to edit page
Print action (printer)✅ WorksOpens PatientPreviewModal
View action (eye)✅ WorksOpens patient detail page
Export modal✅ WorksModal opens correctly
Upload modal✅ WorksModal opens (PatientUploadModal in code)
Add Patient modal✅ WorksOpens AddPatientModal
Compact/Comfortable density✅ WorksToggle functions correctly

📋 Pending Tests (Section 1)

Test IDReason
LIST-13Search by MRN — not tested
LIST-53Upload valid file — not tested
LIST-54Upload invalid file — not tested

📝 Notes

  1. Upload flow exists in code — PatientUploadModal is imported and wired in PatientsPage.tsx (line 47, 529-534). The upload button may be in the header actions area.
  2. Bug #31 and #36 share a root cause — the patient list search scope is not comprehensive. Both name-with-space and phone search fail because the query doesn't handle multi-word names or phone columns.
  3. Bug #37 is staging-only — the export API code is correct; it's a deployment/filesystem issue. Production may not be affected.

Session Status: ✅ Complete Last Updated: 2026-06-17 Next: Phase 2 — Patient View Page (VIEW-01 to VIEW-51)


🆕 Bug #38: Cross-Clinic Patient Flow Incomplete — No Facility Record Created

FieldValue
Severity🟡 High
Bug #38
Test IDLIST-42
StatusOpen

Description: Cross-clinic flow is incomplete. When a patient from Clinic A appears in Clinic B's list:

  1. View (👁️) broken: patient_facility_id: null → /cms/patient/{id}/null
  2. Appointment booked without facility context: FindOrCreateService returns patient_facility: nil for cross-clinic patients. Appointment model accepts it as optional, so booking "succeeds" but has no facility link.
  3. Edit (✏️) works: uses patient.id only

Root Cause: No auto-registration — Clinical::PatientFacility record is never created for the current clinic when a cross-clinic patient is accessed.

Recommended Fix: Auto-create facility record in FindOrCreateService#find_by_id when find_patient_facility_by_patient returns nil. Standard healthcare pattern: providing care = establishing relationship.

On this page