18 Commits

Author SHA1 Message Date
c2c70505e5 Remove unused dialog include and add Phlebo role-specific UI logic
- Remove dialog_eng_result.php include from CS index view
- Add role-based status display for Phlebo (role 3) showing Ready/Pending badges
- Fix indentation inconsistencies in content_requests.php dropdown menus
- Add role restrictions: hide Generate Result and Create Eng Result buttons for CS (role 4) and Phlebo (role 3)
- Move status sorting logic from fetchList to computeSorted for proper Alpine.js reactivity
- Add statusOrder mapping (Pend -> Coll -> Recv -> Inc -> Fin) for consistent request sorting
- Simplify Actions dropdown for Phlebo role to show only status indicator
2026-03-04 13:49:46 +07:00
42d5abc25a Update printer configuration, label controller, and shared views 2026-02-26 12:42:49 +07:00
5f6cf47689 Add engineering result dialog and functionality across all roles 2026-02-25 16:38:07 +07:00
5d1b01c4e8 Fix empty table data - add missing compute chain calls 2026-02-16 10:54:56 +07:00
8d762261d4 Remove all Alpine.js calls to fix memory leaks
- Replace reactive watchers with explicit method calls
- Add setFilterKey() and setFilterTable() methods for manual updates
- Update sort(), nextPage(), prevPage() to trigger computations
- Update templates to use new setter methods
- Compute derived data explicitly after data loading
2026-02-16 10:52:49 +07:00
e947fc74d4 Refactor Alpine.js components: remove memory cleanup code from requests, fix keyboard event handling in validation 2026-02-16 10:23:23 +07:00
79e6ab63a0 fix: additional memory leak prevention in Alpine.js watchers and audit events
- Add toastTimeouts array to track and clear pending timeouts
- Consolidate duplicate watchers (sortCol, sortAsc, sorted, currentPage)
- Add destroy() method to clean up data structures and timeouts
- Cache audit events in _cachedAuditEvents instead of computed getter
- Clear item data when closing dialogs
2026-02-16 07:17:09 +07:00
3577ee870f Fix memory leak in Alpine.js computed properties
Replace getter-based computed properties with cached properties
and explicit watchers to prevent memory leak in:
- script_requests.php
- script_validation.php
2026-02-15 18:16:16 +07:00
f2e01adfc5 feat: auto-generate PDF after val2 validation from preview - Call /report/{accessnumber}/pdf endpoint when second validation succeeds 2026-02-12 13:50:01 +07:00
9e374103fa feat: auto-generate PDF after second validation - Trigger PDF generation via /report/{accessnumber}/pdf endpoint after VAL2 - Add preview dialog for admin/lab/superuser roles - Update role configs with previewEnabled flag 2026-02-12 13:02:31 +07:00
1534544bb9 refactor: Change collect/unreceive endpoints to use path parameters instead of JSON body
- Update collect() and unreceive() to accept samplenumber as path param
- Improve unreceive logic with better Firebird update handling
- Update routes and frontend to match new endpoint signature
2026-02-11 05:53:55 +07:00
46dc493af1 feat: Add PDF generation audit tracking and simplify result dialog
- Add PDF generation events (GEN_PDF, REGEN_PDF) to AUDIT_REQUESTS table
- Track PDF print/generate/regenerate with timestamp and language
- Fix language parameter handling in ReportController (engQuery vs engQuery typo)
- Simplify result dialog to show report in iframe instead of async PDF loading
- Add PDF tab to audit dialog showing generation history
2026-02-05 14:12:17 +07:00
8b4c71d1a3 feat: Replace PDF retry with direct link and generate dialog 2026-02-05 13:23:03 +07:00
cfb81201a2 feat: Implement configurable printer system and enhance UAT workflow
Add comprehensive printer configuration support:
- New Printers.php config with role-based printer defaults (lab, phlebo, reception)
- Update LabelController for configurable printer routing with error handling
- Add ResponseTrait for proper JSON responses (success/error status)
- Update routes to accept optional printer parameter for label printing
- Add default printer configuration per role in shared config

Enhance report generation workflow:
- Support REPORT_LANG from CM_REQUESTS table for language preference
- Prioritize URL parameter, then database value, then default
- Add language info to PDF generation response (Indonesian/English)
- Update all report methods (view, eng, preview, generate) with unified logic

Improve UI and user experience:
- Add dialog_results_generate to all role dashboards (superuser, admin, lab, phlebo, cs)
- Update skeleton loading states widths in content requests
- Add printer selection capability in sample collection flow

Add comprehensive UAT documentation:
- New UAT_GDC_CMOD_Checklist.md with 150+ test cases
- Cover all roles: superuser, admin, lab, phlebo, cs, and cross-role scenarios
- Include acceptance criteria (functional, security, performance, usability, data integrity)
- Test categories: authentication, user management, validation, sample management, audit trail, reporting
- Detailed sign-off structure for stakeholders

Add barcode printing documentation:
- docs/barcode_print_all.php - all labels printing implementation
- docs/barcode_print_coll.php - collection label implementation
- docs/barcode_print_disp.php - dispatch label implementation

Update TODO tracking:
- Mark Reprint Label and PDF Generation as completed
- Update pending tasks for testing and audit trails
2026-02-05 06:21:08 +07:00
0b4fdcfe5f feat: Extend audit trail with tube received tracking and enhance PDF workflow
Major Updates:

1. Extended Audit Trail System
   - Added tube received events tracking from SP_TUBES table (TUBESTATUS=4)
   - New audit tab "Receive" in dialog_audit.php to display tube reception history
   - ApiRequestsAuditController now fetches and returns tube received events with:
     * Sample type, tube status, collection date, and user information
   - Audit events sorted chronologically combining validation, sampling, and receiving events

2. Enhanced PDF Generation Workflow
   - Created new PdfHelper library with methods for PDF generation and posting to spooler
   - Reports can now be generated via GET /report/{accessnumber}/pdf endpoint
   - Updated PDF spooler API endpoint from port 3030 to 3000
   - Added retry PDF button with spinner animation for failed generations
   - Fixed PDF status check to use correct spooler endpoint

3. Validation UI Improvements
   - Added toast notification showing PDF queued after second validation (val2)
   - Retry PDF button appears when val1 and val2 are complete
   - Toast notifications success/error states with auto-dismiss after 2 seconds
   - Loading state with spinning icon during PDF retry operation

4. Report Template Fixes
   - Fixed typo in Val2 By display (added missing ":")
   - Consistent formatting with Val1 By : and Val2 By :

5. Documentation Updates
   - TODO.md updated with:
     * Auto generate PDF (in progress)
     * Print Eng Result (pending)
     * Add Receive to Audit (completed)

6. Cleanup
   - Removed legacy Node.js spooler implementation (node_spooler directory)
   - Deleted P0_log.txt (SQL setup scripts no longer needed in repo)
   - Cleaned up .gitignore to remove stale node_spooler entries

Files Changed:
- app/Controllers/ApiRequestsAuditController.php (tube received audit)
- app/Controllers/ReportController.php (port update: 3030 → 3000)
- app/Libraries/PdfHelper.php (new library)
- app/Views/report/template.php (typo fix)
- app/Views/shared/content_requests.php (retry PDF button)
- app/Views/shared/dialog_audit.php (receive tab)
- app/Views/shared/script_requests.php (retry handler, tube events)
- app/Views/shared/script_validation.php (enhanced toast)
- TODO.md (pending/completed tasks)
- .gitignore (cleanup)
- Deleted: node_spooler/* (legacy implementation)
- Deleted: P0_log.txt (no longer needed)
2026-02-04 11:09:42 +07:00
31acb6bf33 feat: Implement comprehensive report generation system with role-based access control
Add native CodeIgniter 4 report generation functionality replacing legacy spooler_db system.
Provides centralized report generation with audit logging and multi-language support.

New Features:
- Report generation with Indonesian and English language support
- Role-based access control (Lab, Admin, Superuser: generate; CS: print only)
- Preview mode for validation workflow
- Print audit logging to AUDIT_REQUESTS table
- Multi-page report support with proper pagination
- Dual unit system (Conventional and International units)

Controllers:
- ReportController: Main controller for report generation, preview, and print
  - generate(): Full report with audit logging
  - preview(): Preview mode without audit logging
  - print(): Print-only access for CS role
- Home::printReport(): Route handler redirecting based on user role

Libraries:
- ReportHelper: Comprehensive report data retrieval
  - Patient information (name, MR number, demographics, referral)
  - Test results with reference ranges and unit conversions
  - Collection and reception data with timestamps
  - Validation status and validator information
  - Special handling for pending samples and Chinese translations

Routes:
- /report/(:num) - Generate report (Lab, Admin, Superuser)
- /report/(:num)/preview - Preview without audit logging
- /report/(:num)/eng - English language report
- /report/print/(:num) - Print-only access (CS role)
- /print/(:num) - Redirect based on role (all roles)

Views:
- report/template.php: Professional lab report template with Gleneagles branding
  - Header and footer images
  - Patient information table
  - Test results with dual unit columns
  - Collection and reception timestamps
  - Authorization signature area
  - Preview watermark

Role Index Views:
- Removed dialog_preview.php inclusion from all role dashboards
- Consolidated print button directly linking to new report routes

Assets:
- Report-specific CSS files (normalize.min.css, style.css, pdf.css, style_qr.css)
- Gleneagles header and footer images
- Legacy spooler_db files preserved in public/spooler_db/ for reference

Tests:
- ReportTest.php: Unit tests for report generation functionality

Database:
- Uses existing tables: REQUESTS, TESTS, DICT_TESTS, SP_REQUESTS, PATIENTS
- Inserts print audit records into AUDIT_REQUESTS table

Security:
- Parameterized queries throughout (SQL injection prevention)
- Role-based access control enforced at route level
- Proper output escaping with esc() in views
2026-02-02 16:54:22 +07:00
01908bb002 feat: Implement status-based row coloring and enhance validation dialog
This commit implements a comprehensive status color system across the dashboard and validation interfaces, ensuring visual consistency between table rows and filter buttons.

Color System Changes:
- Updated statusRowBg mapping in script_requests.php with custom hex colors:
  * Pend: white (#ffffff) with black text
  * PartColl: pink (#ff99aa) with black text
  * Coll: red (#d63031) with white text
  * PartRecv: light blue (#a0c0d9) with black text
  * Recv: blue (#0984e3) with white text
  * Inc: yellow (#ffff00) with black text
  * Fin: green (#008000) with white text
- Added custom CSS button classes in layout.php matching row background colors
- Applied color backgrounds to table rows (Order through Tests columns)
- Removed hardcoded text-white classes, now using dynamic text colors from mapping

UI/UX Improvements:
- Table rows now have consistent color-coded backgrounds based on request status
- Filter button badges match their corresponding row background colors
- Yellow status uses black text for better readability
- Swapped Coll (yellow) and Inc (orange) colors as requested

Validation Dialog Enhancement:
- Updated dialog_val.php iframe to use dynamic URL generation
- Removed preview type selection (ID, EN, PDF options) - uses default only
- Added getPreviewUrl() method in script_validation.php
- Now uses same URL pattern as preview dialog: http://glenlis/spooler_db/main_dev.php?acc={accessnumber}

Documentation Updates:
- Added Serena MCP tool usage guidelines to AGENTS.md
- Renamed CHECKLIST.md to TODO.md
- Removed CLAUDE.md

Technical Details:
- Color mappings now include both background and text color classes
- Implemented using Tailwind arbitrary values for precise hex color matching
- Status buttons use btn-status-{status} and badge-status-{status} classes
- All 7 columns from Order through Tests have status-colored backgrounds
2026-02-02 14:27:12 +07:00
3cf4cc7f3f feat: Implement audit trail system for dual-level validation workflow
This commit adds comprehensive audit logging for specimen requests and sample collection activities across all roles.
Changes Summary:
New Features:
- Added AUDIT_EVENTS table schema for tracking validation and sample collection events
- Created ApiRequestsAuditController with /api/requests/(:any)/audit endpoint to retrieve audit history
- Added dialog_audit.php view component for displaying audit trails in UI
- Integrated audit logging into validation workflow (VAL1, VAL2, UNVAL events)
Database:
- Created AUDIT_EVENTS table with columns: ACCESSNUMBER, EVENT_TYPE, USERID, EVENT_AT, REASON
- Supports tracking validation events and sample collection actions
Controllers:
- RequestsController: Now inserts audit records for all validation operations
- ApiRequestsAuditController: New API controller returning validation and sample collection history
Routes:
- Added GET /api/requests/(:any)/audit endpoint for retrieving audit trail
- Removed DELETE /api/samples/collect/(:any) endpoint (uncollect functionality)
Views Refactoring:
- Consolidated dashboard layouts into shared components:
  - layout.php (from layout_dashboard.php)
  - script_requests.php (from script_dashboard.php)
  - script_validation.php (from script_validate.php)
  - content_requests.php (from dashboard_table.php)
  - content_validation.php (from dashboard_validate.php)
- Added content_validation_new.php for enhanced validation interface
2026-01-23 16:41:12 +07:00