426 Commits

Author SHA1 Message Date
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
98008d3172 docs: regenerate bundled OpenAPI spec 2026-02-23 13:16:06 +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
10d87d21b4 refactor(api-docs): Split Master Data into Contacts and Locations modules
- Split monolithic master-data.yaml into separate contact.yaml and locations.yaml files
- Replace 'Master Data' tag with dedicated 'Contacts' and 'Locations' tags for better API organization
- Add complete CRUD operations for Contacts (GET, POST, PATCH, DELETE, GET by ID)
- Add complete CRUD operations for Locations (GET, POST, PATCH, DELETE, GET by ID)
- Enhance Contact schema with comprehensive fields: NameFirst, NameLast, Title, Initial,
  Birthdate, EmailAddress1/2, Phone, MobilePhone1/2, Specialty, SubSpecialty
- Enhance Location schema with additional fields: Description, LocType, improved Parent
  field documentation for hierarchical locations
- Update bundled API documentation to reflect new endpoint structure
- Remove deprecated Occupation, MedicalSpecialty, and Counter schemas from bundled docs
2026-02-18 08:45:54 +07:00
ac0ffb679a Add comprehensive test types and reference types documentation
- Document TEST, PARAM, CALC, and GROUP test type categories
- Include usage examples and frontend display guidance
- Provide quick reference card for developers
- Covers standard lab tests, components, calculations, and panels
2026-02-18 07:13:54 +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
a9384fbe96 fix(api-docs): update OpenAPI spec to match actual implementation
- Fix Patient schema fields (NameFirst, NameLast, EmailAddress1)
- Update Occupation schema (OccCode, OccText)
- Update MedicalSpecialty schema (SpecialtyText)
- Update Counter schema (CounterDesc, CounterValue)
- Fix Location schema (LocCode, LocFull)
- Update PatVisitADT doctor fields to integer (ContactID refs)
- Add proper request/response schemas for all endpoints
- Fix OrderStatus and Priority enums
- Add missing query parameters
2026-02-10 15:37:12 +07:00
89e7bfae38 refactor: clean up agent configs and consolidate API documentation 2026-02-10 13:28:32 +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
e5ac1957fe ● 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:31:00 +07:00
b367d059e2 update gitignore to add serena 2026-01-26 13:00:03 +07:00
15ab7017a9 openapi yml creation 2026-01-26 12:58:09 +07:00
f56200eb53 update areageo endpoint to value and label 2026-01-26 10:27:28 +07:00
823694e4a1 add valueset getter to valueset : , valuesetKey : 2026-01-20 13:20:37 +07:00
e96ffa1ca9 refactor(test): remove legacy v2 master tests and cleanup HealthTest
- Deleted obsolete v2 master test files and support classes:
  - tests/_support/v2/MasterTestCase.php
  - tests/unit/v2/master/TestDef/TestDefSiteModelTest.php
  - tests/unit/v2/master/TestDef/TestDefTechModelTest.php
  - tests/unit/v2/master/TestDef/TestMapModelTest.php
  - tests/feature/v2/master/TestDef/TestDefSiteTest.php
- Cleaned up formatting and logic in tests/unit/HealthTest.php.
2026-01-19 08:29:56 +07:00
351d3b6279 docs: extract ERD documentation and add database schema files
- Remove deprecated valueset migration docs and old project planning files
- Add ERD_EXTRACT.md with complete database table definitions
- Add clqms_database.dbml for database modeling
- Add clqms_database.dbdiagram for visual database design
- Add updated prj_3c.md project documentation
2026-01-15 12:37:37 +07:00
42a5260f9a feat(valueset): restructure valueset UI and add result-specific CRUD
- Restructure valueset pages from single master page to separate views:
  - Library Valuesets (read-only lookup browser)
  - Result Valuesets (CRUD for valueset table)
  - Valueset Definitions (CRUD for valuesetdef table)
- Add new ResultValueSetController for result-specific valueset operations
- Move views from master/valuesets to result/valueset and result/valuesetdef
- Convert valueset sidebar to collapsible nested menu
- Add search filtering to ValueSetController index
- Remove deprecated welcome_message.php and old nested CRUD view
- Update routes to organize under /result namespace
Summary of changes: This commit reorganizes the valueset management UI by splitting the monolithic master/valuesets page into three distinct sections, adds a new controller for result-related valueset operations, and restructures the sidebar navigation for better usability.
2026-01-14 16:45:58 +07:00
e36e390f71 refactor: consolidate ValueSet API and simplify seeders
- Consolidate ValueSet routes from multiple nested groups to flat structure
- Delete deprecated ValueSet\ namespaced controllers (ValueSetController, ValueSetDefController)
- Remove ValueSetSeeder and ValueSetCountrySeeder from DBSeeder
- Simplify seeders (LocationSeeder, OrganizationSeeder, PatientSeeder, TestSeeder)
  to use literal string values instead of ValueSet lookups
- Add new ValueSetController and ValueSetDefController in root namespace
- Update test files for new controller structure
The key changes are:
1. Routes: Consolidated from nested ValueSet\ namespace routes to flat ValueSetController routes with /items sub-endpoints
2. Controllers: Deleted old app/Controllers/ValueSet/ directory, created new root-level controllers
3. Seeders: Removed ValueSet dependencies, using literal values like 'ROOM', '1', 'TEST' instead of [12]['ROOM'] etc.
4. Tests: Updated tests to match new controller structure
2026-01-13 16:48:43 +07:00
4aa9cefc3d refactor: consolidate migrations and reorganize valueset data structure
Major refactoring to clean up database migrations and reorganize static lookup data:
- Consolidated 13 old migrations (2025) into 10 new numbered migrations (2026-01-01)
- Deleted redundant migrations: Location, Users, Contact, ValueSet, Counter, RefRange,
  CRMOrganizations, Organization, AreaGeo, DeviceLogin, EdgeRes
- New consolidated migrations:
  - 2026-01-01-000001_CreateLookups: valueset, counter, containerdef, occupation, specialty
  - 2026-01-01-000002_CreateOrganization: account, site, location, discipline, department
  - 2026-01-01-000003_CreatePatientCore: patient, patidentifier, pataddress, patcontact
  - 2026-01-01-000004_CreateSecurity: contact, contactdetail, userdevices, loginattempts
  - 2026-01-01-000005_CreatePatientVisits: patvisit, patinsurance
  - 2026-01-01-000006_CreateOrders: porder, orderitem
  - 2026-01-01-000007_CreateSpecimens: specimen, specmenactivity, containerdef
  - 2026-01-01-000008_CreateTestDefinitions: testdefinition, testactivity, refnum, reftxt
  - 2026-01-01-000009_CreateResults: patresult, patresultdetail, patresultcomment
  - 2026-01-01-000010_CreateLabInfrastructure: edgeres, edgestatus, edgeack, workstation
- Moved 44 JSON files from valuesets/ subdirectory to app/Libraries/Data/ root
- Added new country.json lookup
- Added _meta.json for valueset metadata
- Deleted old valuesets/_meta.json
- Renamed gender.json to sex.json for consistency with patient.Sex column
- Removed duplicate country.json from valuesets/
- AGENTS.md: Updated Lookups library documentation with new methods
- README.md: Complete rewrite of lookup/valueset documentation
- Renamed MVP_TODO.md to TODO.md
- Added VUE_SPA_IMPLEMENTATION_PLAN.md
- Removed deprecated prj_clinical laboratory quality management system_3a.docx
- ValueSet.php: Enhanced with caching and new lookup methods
- Lookups.php: Removed (functionality merged into ValueSet)
Impact: Prepares codebase for 2026 with cleaner migration history and improved
lookup data organization for the name-based valueset system.
2026-01-13 07:22:25 +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
mikael-zakaria
d4029dce38 Update perbaikan ContactSeeder dan AreaGeoSeeder 2026-01-08 10:49:19 +07:00