feat: Display Only Patients with Incomplete KYP in Know Your Patient Page
Issue Summary
Currently, the Know Your Patient (KYP) page only allows searching patients using a book number. There is no automatic listing of patients who have not completed KYP.
Expected behavior: The system should automatically display patients registered for the current camp who have not completed their KYP. Patients who already completed KYP in previous camps should not be shown.
Problem Statement
- There is no visibility into which patients have pending KYP.
- Volunteers must manually search each patient, which is time-consuming.
- Patients who already completed KYP may be unnecessarily rechecked.
- This slows down camp workflow and reduces efficiency.
Affected users:
- Volunteers
- Camp coordinators
Impact:
- Increased processing time
- Poor user experience
- Inefficient patient handling
Reproduction:
- Open KYP page
- Observe that no patient list is shown automatically
- User must manually search each patient
Proposed Solution
- Fetch patients registered in the current camp.
- Filter patients whose KYP is incomplete.
- Display them automatically on page load.
- Exclude patients who already completed KYP in previous camps.
- Retain search functionality for manual lookup.
Changes required:
- Frontend: Display filtered patient list.
- Backend (if needed): Add filter for KYP completion status.
Test-Driven Development
Acceptance Criteria (Given-When-Then)
Scenario 1: Display pending KYP patients Given a volunteer opens the Know Your Patient page When the page loads Then the system should display patients registered for the camp And only those with incomplete KYP should be shown
Scenario 2: Hide completed KYP patients Given a patient has already completed KYP in a previous camp When the KYP page is opened Then the patient should not appear in the list
Scenario 3: Search functionality Given a volunteer enters a book number When they click search Then matching patient data should be shown only if KYP is incomplete
Test Cases
| Test ID | Test Description | Precondition | Test Steps | Expected Result | Priority |
|---|---|---|---|---|---|
| TC-001 | Load pending patients | Patients exist with incomplete KYP | Open page | Only incomplete KYP patients displayed | High |
| TC-002 | Hide completed patients | Patient completed KYP | Open page | Patient not shown | High |
| TC-003 | Search incomplete patient | Patient exists | Enter book number → Search | Patient displayed | High |
| TC-004 | Search completed patient | Patient completed KYP | Enter book number → Search | Patient not displayed | Medium |
Unit Test Requirements
Components/Functions to Test:
| Module/Component | Function/Hook | Tests |
|---|---|---|
| KYPPage | fetchPatients | TC-001, TC-002 |
| KYPPage | handleSearch | TC-003, TC-004 |
Test Assertions Required:
- Renders correctly with initial state
- Calls API with correct filters
- Displays only incomplete KYP patients
- Handles search input correctly
- Handles empty state
- Handles API errors
Implementation Details
Files to Change
| File Path | Action | Purpose |
|---|---|---|
| src/pages/KYPPage.tsx | Modify | Display filtered patient list |
| src/api/patient.ts | Modify | Add KYP filter in API |
| src/types/patient.ts | Modify | Add KYP status field |
| src/tests/KYPPage.test.tsx | Create | Unit tests |
Technical Considerations
- Backend should support filtering by KYP completion.
- Use existing API or extend query params.
- Ensure performance for large patient lists.
- Maintain current search functionality.
UI/UX Requirements
- Auto-load list on page open.
- Show patient details (name, book number).
- Display empty state if no pending patients.
- Keep search bar functional.
Testing Strategy
Manual Testing
Test Environment:
- Browser: Chrome
- Viewport: Desktop
- User Role: Volunteer
Manual Test Steps:
- Open KYP page
- Verify pending patients are listed
- Search for a patient
- Verify filtering works correctly
Automated Testing
Unit Tests:
- Component render tests
- API fetch tests
- Search functionality tests
- Error handling tests
Test Data Requirements
const mockTestData = { patients: [ { id: 1, name: "Patient A", kyp_completed: false }, { id: 2, name: "Patient B", kyp_completed: true } ] }
Definition of Done
- Acceptance criteria met
- Test cases passing
- Unit tests written
- Manual testing completed
- Code reviewed
- No console errors
- Type-safe code
- UI works correctly
Additional Context
Notes:
- This feature improves volunteer efficiency.
- Prevents redundant KYP processing.
- Helps prioritize pending patients.