375 Commits

Author SHA1 Message Date
6ece30302f feat: update calc endpoints and rule docs 2026-03-17 16:50:57 +07:00
4bb5496073 feat: add two-argument result_set syntax for targeting tests by code
- result_set('CODE', value) now supported alongside legacy result_set(value)
- RuleEngineService: add resolveTestSiteIdByCode() helper
- RuleExpressionService: add splitTopLevel() and unquoteStringArgument() helpers
- Update docs/test-rule-engine.md with new syntax examples
- Delete completed issue from issues.md
2026-03-16 16:39:54 +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
49d3a69308 refactor: move TestsController to Test namespace and update routes
- 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
2026-03-02 07:02:51 +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
3a30629e15 feat: add urine workstations and test specimen mappings to seeders 2026-02-24 06:11:18 +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
d5f1d9fc84 feat: update /api/valueset to return {value, label, count} format 2026-02-23 13:14:03 +07:00
5272efa7b9 reorganize database migrations with corrected numbering 2026-02-23 05:11:23 +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
b896c0aaf8 fix reftype 2026-02-19 15:28:04 +07:00
6be44e9421 add new reftype noref 2026-02-19 13:35:57 +07:00
2af95945a3 fix areageoseeder 2026-02-19 13:31:13 +07:00
5bfd71e7d7 fix areageoseeder to use env 2026-02-19 13:27:08 +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
30c0c538d6 refactor: Remove redundant ValueSet call and convert global function to private method
- 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)
2026-02-18 11:07:00 +07:00
425595f5c0 feat: Implement custom ResponseTrait with automatic empty string to null conversion
- 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
2026-02-18 10:15:47 +07:00
498afcc08c adding clqms01x to cors 2026-02-18 09:16:42 +07:00
46e52b124b feat: Migrate OpenAPI documentation to static HTML structure
- Remove OpenApiDocs.php controller and swagger.php view
- Delete legacy bundler scripts (bundle-api-docs.php, bundle-api-docs.py)
- Remove old documentation files (API_DOCS_README.md, docs.html)
- Update Routes.php to remove OpenAPI documentation routes
- Modify PagesController.php to reflect changes
- Add new public/swagger/index.html as standalone documentation
2026-02-16 15:58:30 +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
8c44cc84a2 Update files 2026-02-16 10:16:07 +07:00
c2eec916e9 chore: clean up PRD and fix API docs formatting 2026-02-16 07:03:40 +07:00
8806b007ab Add PatVisit controller and use case documentation
- 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
2026-02-15 21:05:25 +07:00
f30755c830 Update seeders and models, remove MinimalMasterDataSeeder, update API docs 2026-02-13 16:51:24 +07:00
5085b8270f Resolve merge conflicts in PatVisitController and add CORS headers to AuthFilter; update ValueSet API documentation 2026-02-13 06:35:05 +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
c38f9d2f91 feat(patvisits): add index method for paginated patient visits listing 2026-02-12 07:24:17 +07:00
c19847a812 refactor(routes): remove race/religion/ethnic/country routes, use /api/valueset instead 2026-02-11 18:22:36 +07:00
9769e1dfea fix(areageo): use province_id parameter instead of Parent in getCities 2026-02-11 18:19:04 +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
f47a43b061 refactor: reorganize ValueSet endpoints - Move user valueset items to /api/valueset/user/items - Move valueset definitions to /api/valueset/user/def - Keep lib valueset at /api/valueset/* 2026-02-10 10:05:44 +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
bf847b6835 fix: correct ValueSet transformLabels output format
- 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
2026-01-29 09:56:45 +07:00
6a20682d18 refactor(api): standardize ValueSet label transformation across controllers
Replace manual label lookup code with ValueSet::transformLabels() helper
for consistent API responses across all controllers.

Updated controllers:
- ContactController: Specialty, Occupation
- OrderTestController: Priority, OrderStatus
- PatientController: Sex
- ContainerDefController: ConCategory, CapColor, ConSize
- SpecimenCollectionController: CollectionMethod, Additive, SpecimenRole
- SpecimenController: SpecimenType, SpecimenStatus, BodySite
- SpecimenStatusController: Status, Activity
- DemoOrderController: Priority, OrderStatus
- TestMapController: HostType, ClientType
- TestsController: Reference range fields

Also updated api-docs.yaml field naming convention to PascalCase
2026-01-29 09:05:40 +07:00
212ab4e80a Merge branch 'main' of https://github.com/mahdahar/clqms-be
● refactor: update API responses to use {field}Label format

  - Transform coded fields to lowercase with Label suffix for display text                                                                                                                                              - Controllers: OrderTestController, DemoOrderController, SpecimenController,
    SpecimenStatusController, SpecimenCollectionController, ContainerDefController,
    ContactController, TestMapController
  - Example: Priority: "R" → priority: "R", priorityLabel: "Routine"
  - Update api-docs.yaml with new OpenAPI schema definitions
  - Add API docs reminder to CLAUDE.md
2026-01-28 17:34:11 +07:00