155 Commits

Author SHA1 Message Date
8aefeaca01 fix: preserve nullable test metadata and day-based age ranges
Avoid coercing missing SiteID, Decimal, and age boundaries to hardcoded defaults so payload intent is retained across test creation and reference range inserts. Align patient result age checks and OpenAPI examples with day-based age bounds, with feature coverage for create variants.
2026-04-01 13:28:44 +07:00
366572a0cb fix: preserve numeric ref range metadata 2026-03-26 14:48:49 +07:00
76c528564c fix: simplify test detail retrieval and clean tracked index artifacts
Use the base test row's RefType and ResultType to decide refnum/reftxt loading, and fetch discipline/department joins directly in getTestById to avoid redundant relation queries. Add feature coverage for show response behavior and include the related workspace cleanup changes so the branch state is consistent.
2026-03-25 14:06:00 +07:00
76ea22d841 refactor: standardize boolean field naming across API domains
Rename legacy boolean helpers to is* naming across test definitions, patient models, and infrastructure data to match rest of backend.

Update controllers, models, migrations, seeders, tests, and OpenAPI docs/bundled spec so contracts and runtime align.
2026-03-25 11:37:17 +07:00
7600989bed feat: expand audit logging service and docs 2026-03-25 10:41:22 +07:00
aaadd593dd feat: require id params for update endpoints 2026-03-16 15:58:56 +07:00
root
2bcdf09b55 chore: repo-wide normalization + rules test coverage
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.
2026-03-16 07:24:50 +07:00
c01786bb93 feat: add calc endpoint and rule engine compilation 2026-03-12 16:55:03 +07:00
88be3f3809 feat: add rules engine API and order-created hook
- 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
2026-03-12 06:34:56 +07:00
911846592f feat: add calculator API support for test formulas and update docs 2026-03-11 16:45:16 +07:00
ad8e1cc977 Update site controller, organization & test models, migrations, and API docs 2026-03-10 16:40:37 +07:00
011a2456c2 Cleanup: Remove obsolete docs, opencode configs, and openspec files; update test models and API docs 2026-03-09 16:49:03 +07:00
282c642da6 feat: add OpenSpec workflow, Serena integration, User API, and Specimen delete endpoint
- Add OpenSpec experimental workflow with commands (opsx-apply, opsx-archive, opsx-explore, opsx-propose)
- Add Serena memory system for project context
- Implement User API (UserController, UserModel, routes)
- Add Specimen delete endpoint
- Update Test definitions and Routes
- Sync API documentation (OpenAPI)
- Archive completed 2026-03-08-backend-specs change
2026-03-09 07:00:12 +07:00
85c7e96405 feat: implement comprehensive result management and lab reporting system
- 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
2026-03-04 16:48:12 +07:00
42006e1af9 feat: implement comprehensive order management with specimens and tests
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
2026-03-03 13:51:27 +07:00
e9c7beeb2b feat: update test management APIs and reference range models 2026-03-03 06:03:27 +07:00
24e0293824 feat: add HostApp and CodingSys management APIs with CRUD operations 2026-02-27 16:31:55 +07:00
5e0a7f21f5 feat: add TestMapDetail controller, model and migration for test site mapping
- 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
2026-02-26 16:48:10 +07:00
d3668fe2b3 feat: add equipment list management API with CRUD operations 2026-02-24 16:53:36 +07:00
707d548db0 feat: implement test mapping functionality with TestMapController and model
- 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
2026-02-23 16:49:39 +07:00
d173098652 feat: implement audit logging and test management enhancements
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
2026-02-20 13:47:47 +07:00
ece101b6d2 Add audit logging plan documentation and update test infrastructure
- 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)
2026-02-19 13:20:24 +07:00
fcaf9b74ea feat: Restructure OpenAPI documentation with modular components
- Add OpenApiDocs controller for serving bundled API docs

- Split monolithic api-docs.yaml into modular components/

- Add organized paths/ directory with endpoint definitions

- Create bundling scripts (JS, PHP, Python) for merging docs

- Add API_DOCS_README.md with documentation guidelines

- Update Routes.php for new API documentation endpoints

- Update swagger.php view and TestDefSiteModel
2026-02-16 14:20:52 +07:00
f30755c830 Update seeders and models, remove MinimalMasterDataSeeder, update API docs 2026-02-13 16:51:24 +07:00
305e605a60 Merge branch 'main' of github.com:mahdahar1/clqms01-be
Resolved conflicts and integrated remote changes:
- Keep PatVisitController fixes (validation, soft delete, proper HTTP status codes)
- Updated routes and controllers from remote
- Synced api-docs.yaml
2026-02-12 16:53:58 +07:00
d974e2f3c1 fix patvisit endpoint: add validation, soft delete, fix tests, remove sequence from update 2026-02-12 16:50:21 +07:00
4b8d31f3a1 Simplify FullName to only include first, middle, and last name 2026-02-11 09:22:15 +07:00
64646293dc Fix patient creation error: extract nested arrays before insert
- 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
2026-02-10 16:43:52 +07:00
40ecb4e6e8 feat(api): transition to headless architecture and enhance order management
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`.
2026-01-31 09:27:32 +07:00
fcdbc3f20a feat(patient): handle array format for Custodian and LinkTo fields
- 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
2026-01-29 11:21:34 +07:00
823694e4a1 add valueset getter to valueset : , valuesetKey : 2026-01-20 13:20:37 +07:00
bb7df6b70c feat(valueset): refactor from ID-based to name-based lookups
Complete overhaul of the valueset system to use human-readable names
instead of numeric IDs for improved maintainability and API consistency.
- PatientController: Renamed 'Gender' field to 'Sex' in validation rules
- ValuesetController: Changed API endpoints from ID-based (/:num) to name-based (/:any)
- TestsController: Refactored to use ValueSet library instead of direct valueset queries
- Added ValueSet library (app/Libraries/ValueSet.php) with static lookup methods:
  - getOptions() - returns dropdown format [{value, label}]
  - getLabel(, ) - returns label for a value
  - transformLabels(, ) - batch transform records
  - get() and getRaw() for Lookups compatibility
- Added ValueSetApiController for public valueset API endpoints
- Added ValueSet refresh endpoint (POST /api/valueset/refresh)
- Added DemoOrderController for testing order creation without auth
- 2026-01-12-000001: Convert valueset references from VID to VValue
- 2026-01-12-000002: Rename patient.Gender column to Sex
- OrderTestController: Now uses OrderTestModel with proper model pattern
- TestsController: Uses ValueSet library for all lookup operations
- ValueSetController: Simplified to use name-based lookups
- Updated all organization (account/site/workstation) dialogs and index views
- Updated specimen container dialogs and index views
- Updated tests_index.php with ValueSet integration
- Updated patient dialog form and index views
- Removed .factory/config.json and CLAUDE.md (replaced by AGENTS.md)
- Consolidated lookups in Lookups.php (removed inline valueset constants)
- Updated all test files to match new field names
- 32 modified files, 17 new files, 2 deleted files
- Net: +661 insertions, -1443 deletions (significant cleanup)
2026-01-12 16:53:41 +07:00
f11bde4d30 refactor(valueset): simplify API response by removing pagination
- Remove pagination from ValueSetController::index() and ValueSetModel::getValueSets()
     - Delete duplicate AGENTS.md documentation (consolidated into CLAUDE.md)
     - Update .gitignore to exclude .claude folder
     - Add CLAUDE.md with comprehensive agent instructions for Valueset queries
     - Document new Lookups static library in README.md
2026-01-09 16:58:43 +07:00
a47db49f81 feat: improve Location API error handling
- Add Phone/Email fields to LocationAddressModel allowedFields
- Fix saveLocation() to throw exceptions instead of returning error arrays
- Update controller to properly handle model responses
- Include actual database error message in transaction failures
2026-01-06 17:00:33 +07:00
cd65e91db1 refactor: Rename controllers to follow CodeIgniter 4 naming convention
- Rename all controllers from X.php to XController.php format
- Add new RefTxtModel for text-based reference ranges
- Rename group_dialog.php to grp_dialog.php and remove title_dialog.php
- Add comprehensive test suite for v2/master/TestDef module
- Update Routes.php to reflect controller renames
- Remove obsolete data files (clqms_v2.sql, lab.dbml)
2026-01-05 16:55:34 +07:00
97edfe50a8 feat: enhance Test Management module with improved UI and tests
- Refactor Tests.php controller with updated logic and error handling
- Update Test migration with schema improvements
- Enhance TestDefCalModel, TestDefGrpModel, TestDefTechModel with CRUD operations
- Improve TestMapModel with better test mapping relationships
- Redesign test dialog views (calc, group, param) with improved UX
- Update tests_index view with better data presentation
- Add CSS styles for test management UI components
- Add TestDefSiteTest feature test for site-based test definitions
- Add TestDefModelsTest unit test for model validation
- Remove obsolete Test Management.docx documentation
2026-01-02 08:33:22 +07:00
97451496c3 feat(tests): enhance Test Management module with v2 UI dialogs
- Add new dialog forms for test calc, group, param, and title management
- Refactor test_dialog.php to new location (master/tests/)
- Update TestDefCalModel, TestDefSiteModel, TestDefTechModel, TestMapModel
- Modify Tests controller and Routes for new dialog handlers
- Update migration schema for test definitions
- Add new styles for v2 test management interface
- Include Test Management documentation files
2025-12-30 16:54:33 +07:00
a94df3b5f7 **feat: migrate to v2 frontend with Alpine.js pattern**
- Introduce v2 views directory with Alpine.js-based UI components
- Add AuthV2 controller for v2 authentication flow
- Update PagesController for v2 routing
- Refactor ValueSet module with v2 dialogs and nested CRUD views
- Add organization management views (accounts, departments, disciplines, sites, workstations)
- Add specimen management views (containers, preparations)
- Add master views for tests and valuesets
- Migrate patient views to v2 pattern
- Update Routes and Exceptions config for v2 support
- Enhance CORS configuration
- Clean up legacy files (check_db.php, llms.txt, sanity.php, old views)
- Update agent workflow patterns for PHP Alpine.js
2025-12-30 14:30:35 +07:00
cb4181dbff refactor: restructure application architecture and consolidate controllers
- Consolidate page controllers into unified PagesController
- Remove deprecated V2 pages, layouts, and controllers (AuthPage, DashboardPage, V2Page)
- Add Edge resource with migration and model (EdgeResModel)
- Implement new main_layout.php for consistent page structure
- Reorganize patient views into dedicated module with dialog form
- Update routing configuration in Routes.php
- Enhance AuthFilter for improved authentication handling
- Clean up unused V2 assets (CSS, JS) and legacy images
- Update README.md with latest project information

This refactoring improves code organization, removes technical debt, and
establishes a cleaner foundation for future development.
2025-12-29 16:57:46 +07:00
118d490bbd refactor: update TestSeeder to use dynamic ValueSet lookups
- Implemented dynamic VID retrieval from ValueSetModel for all test definitions
- Aligned ResultType, RefType, and SpcType with the valueset table
- Updated sample data for Hematology, Chemistry, and Urinalysis tests
- Ensured consistency between ValueSetSeeder and TestSeeder data
2025-12-29 12:55:31 +07:00
9f83199ddf adding crud test, and some dummy data for all test 2025-12-17 10:06:05 +07:00
600f672831 add crud for test 2025-12-17 07:03:16 +07:00
6b83f332ea fix test seeder 2025-12-16 13:48:33 +07:00
d9f9768074 add parent to discipline 2025-12-08 11:21:48 +07:00
2b9a30a073 yes 2025-12-03 15:45:24 +07:00
b52726b694 fix location show 2025-12-02 14:48:30 +07:00
72002bd437 fix getcities by parent 2025-12-02 13:19:42 +07:00
8767b823ca fix getcities showing province 2025-12-02 13:14:23 +07:00
d4f5e8b16a fix areageo 2025-12-02 12:52:23 +07:00
d5fd300b6a new feature for suhu kuda 2025-12-02 09:29:42 +07:00