Normalize formatting/line endings across configs, controllers, models, tests, and OpenAPI specs.
Update rule expression/rule engine implementation and remove obsolete RuleAction controller/model.
Add unit tests for rule expression syntax and multi-action behavior, and include docs updates.
- Add /api/rules CRUD, nested actions, and expr validation
- Add rules migration, models, and RuleEngine/Expression services
- Run ORDER_CREATED rules after order create (non-blocking) and refresh tests
- Update OpenAPI tags/schemas/paths and bundled docs
- Add full CRUD operations for results (index, show, update, delete)
- Implement result validation with reference range checking (L/H flags)
- Add cumulative patient results retrieval across all orders
- Create ReportController for HTML lab report generation
- Add lab report view with patient info, order details, and test results
- Implement soft delete for results with transaction safety
- Update API routes with /api/results/* endpoints for CRUD
- Add /api/reports/{orderID} endpoint for report viewing
- Update OpenAPI docs with results and reports schemas/paths
- Add documentation for manual result entry and MVP plan
Major updates to order system:
- Add specimen and test data to order responses (index, show, create, update, status update)
- Implement getOrderSpecimens() and getOrderTests() private methods in OrderTestController
- Support 'include=details' query parameter for expanded order data
- Update OrderTestModel with enhanced query capabilities and transaction handling
API documentation:
- Update OpenAPI specs for orders, patient-visits, and tests
- Add new schemas for order specimens and tests
- Regenerate bundled API documentation
Database:
- Add Requestable field to TestDefSite migration
- Create OrderSeeder and ClearOrderDataSeeder for test data
- Update DBSeeder to include order seeding
Patient visits:
- Add filtering by PatientID, PatientName, and date ranges
- Include LastLocation in visit queries
Testing:
- Add OrderCreateTest with comprehensive test coverage
Documentation:
- Update AGENTS.md with improved controller structure examples
- Move TestsController from App\Controllers to App\Controllers\Test namespace
- Update routes from 'api/tests' to 'api/test' group
- Clean up empty lines in Routes.php
- Improve code formatting and indentation in TestsController
- Add TestMapDetailController for managing test mapping details
- Create TestMapDetailModel with CRUD operations
- Add migration for TestSiteID column in testmap table
- Update TestMapController and TestMapModel
- Update routes, seeder and PatVisitModel
- Regenerate API documentation bundle
- Add TestMapController for managing test-to-analyzer mappings
- Create TestMapModel with database operations for test mappings
- Update TestsController to support test mapping operations
- Add testmap API routes to Routes.php
- Create migration updates for test definitions table
- Add OpenAPI specification for test mapping endpoints
- Include unit tests for TestDef models
- Update bundled API documentation
Major Features:
- Add comprehensive audit logging system with AuditService
- Create AuditLogs database migration for tracking changes
- Implement TestValidationService for test data validation
- Add FRONTEND_TEST_MANAGEMENT_PROMPT.md documentation
Controllers:
- Update TestsController with improved test management
Models:
- Enhance PatientModel with additional functionality
- Update TestDefSiteModel for better site management
Database:
- Add CreateAuditLogs migration (2026-02-20-000011)
- Update TestSeeder with new test data
Services:
- Add AuditService for comprehensive audit trail logging
Documentation:
- Update AGENTS.md with improved guidelines
- Update audit-logging-plan.md with implementation details
- Add FRONTEND_TEST_MANAGEMENT_PROMPT.md for frontend guidance
API Documentation:
- Update api-docs.bundled.yaml
- Update tests.yaml schema definitions
- Update tests.yaml paths
Testing:
- Enhance TestsControllerTest with new test cases
- Update TestDefModelsTest for model coverage
- Add audit-logging-plan.md with comprehensive logging implementation guide
- Update AGENTS.md with project guidelines
- Refactor test models: remove RefTHoldModel, RefVSetModel, TestDefTechModel
- Update TestDefSiteModel and related migrations
- Update seeder and test data files
- Update API documentation (OpenAPI specs)
- TestsController: Remove duplicate rangeTypeOptions assignment that was being
set inside the NUM condition block, causing it to be set unnecessarily
when it's also handled elsewhere
- ResponseTrait: Convert global helper function convert_empty_strings_to_null()
to private class method convertEmptyStringsToNull() for better encapsulation
and to avoid dependency on global functions
- Database schema: Update clqms_database.dbml with accurate table structure
derived from app/Models/ directory, reorganizing tables by functional
categories (Patient, Visit, Organization, Location, Test, Specimen,
Order, Contact management)
- Create App\Traits\ResponseTrait that wraps CodeIgniter\API\ResponseTrait
- Add json_helper with convert_empty_strings_to_null() and prepare_json_response() functions
- Replace all imports of CodeIgniter\API\ResponseTrait with App\Traits\ResponseTrait across all controllers
- Add 'json' helper to BaseController helpers array
- Ensure consistent API response formatting across the application
- Add PatVisitController with CRUD operations
- Add use case documentation (docx and md files)
- Update API documentation in api-docs.yaml
- Remove USER_STORIES.md (migrated to docs/)
- Update TODO.md with current tasks
- Update Routes.php for new endpoints
- Update DummySeeder with additional test data
- Extract PatIdt, PatCom, PatAtt arrays before patient insert to prevent MySQL error 1241
- Fix Custodian handling when InternalPID is null
- Apply same fix to updatePatient method
This commit marks a significant architectural shift, transitioning the CLQMS backend to a fully headless REST API. All view-related components have been removed to focus solely on providing a robust, stateless API for clinical laboratory workflows.
### Architectural Changes
- **Headless API Transition:**
- Removed all view files (`app/Views/v2`), associated page controllers (`PagesController`), and routes (`Routes.php`). The application no longer serves a front-end UI.
- The root endpoint (`/`) now returns a simple "Backend Running" status message.
- **Developer Tooling & Guidance:**
- Replaced `CLAUDE.md` with `GEMINI.md` to provide updated context and instructional guidelines for Gemini agents.
- Updated `.serena/project.yml` with project configuration.
### Feature Enhancements
- **Advanced Order Management (`OrderTestModel`):**
- **Test Expansion:** The `createOrder` process now automatically expands `GROUP` (panel) tests into their individual components and recursively includes all parameter dependencies for `CALC` (calculated) tests.
- **Order Comments:** Added support for attaching comments to an order via the `ordercom` table.
- **Status Tracking:** Order status updates are now correctly recorded in the `orderstatus` table.
- **Schema Alignment:** Switched from `OrderID` to `InternalOID` as the primary key for internal operations.
- **Reference Range Refactor (`TestsController`):**
- Simplified reference range logic by consolidating `refthold` and `refvset` into the main `refnum` and `reftxt` tables.
- Standardized `RefType` handling to support `NMRC`, `TEXT`, `THOLD`, and `VSET` codes from the `reference_type` ValueSet.
### Other Changes
- **Documentation:**
- `PRD.md`, `README.md`, and `TODO.md` were updated to reflect the headless architecture, refined scope, and current project priorities.
- **Database:**
- Removed obsolete `RefTHoldID` and `RefVSetID` columns from the `patres` table migration.
- **Testing:**
- Added new feature tests for `ContactController`, `OrganizationController`, and `TestsController`.
- PatientModel: Convert Custodian from array to integer InternalPID when received as object
- PatientModel: Convert LinkTo from array of objects to comma-separated InternalPID string
- API docs: Add LinkedPatient, Custodian, and PatAttEntry schema definitions
- API docs: Extend Patient schema with DeathIndicator, TimeOfDeath, PatCom,
PatAtt, Province, City, Country, Race, MaritalStatus, Religion, Ethnic fields
- Add AGENTS.md to .gitignore
- ValueSet::transformLabels() was outputting values incorrectly:
- Field contained label text (e.g., Race: 'Jawa')
- *Key contained original value (e.g., RaceKey: 'JAWA')
- Fixed to output correct format for all static JSON ValueSets:
- Field contains original value (e.g., Race: 'JAWA')
- *Label contains label text (e.g., RaceLabel: 'Jawa')
- Affected ValueSets: Race, Sex, Country, Religion, Ethnic,
DeathIndicator, MaritalStatus
- Patient show endpoint now returns: Race:'JAWA', RaceLabel:'Jawa',
Sex:'1', SexLabel:'Female' as expected