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
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
|
|
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
|
|
|
|
|
|
class CreateLookups extends Migration {
|
|
|
|
|
public function up() {
|
|
|
|
|
$this->forge->addField([
|
|
|
|
|
'VID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
|
|
|
|
'SiteID' => ['type' => 'INT', 'null' => true],
|
|
|
|
|
'VSetID' => ['type' => 'INT', 'null' => true],
|
|
|
|
|
'VOrder' => ['type' => 'INT', 'null' => true],
|
|
|
|
|
'VValue' => ['type' => 'varchar', 'constraint' => 10],
|
|
|
|
|
'VDesc' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
|
|
|
|
|
'VCategory' => ['type' => 'int', 'null' => true],
|
|
|
|
|
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
|
|
|
|
'EndDate' => ['type' => 'DATETIME', 'null' => true]
|
|
|
|
|
]);
|
|
|
|
|
$this->forge->addKey('VID', true);
|
|
|
|
|
$this->forge->createTable('valueset');
|
|
|
|
|
|
|
|
|
|
$this->forge->addField([
|
|
|
|
|
'VSetID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
|
|
|
|
'SiteID' => ['type' => 'INT', 'null' => true],
|
|
|
|
|
'VSName' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => false],
|
|
|
|
|
'VSDesc' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => false],
|
|
|
|
|
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
|
|
|
|
'EndDate' => ['type' => 'DATETIME', 'null' => true]
|
|
|
|
|
]);
|
|
|
|
|
$this->forge->addKey('VSetID', true);
|
|
|
|
|
$this->forge->createTable('valuesetdef');
|
|
|
|
|
|
|
|
|
|
$this->forge->addField([
|
|
|
|
|
'CounterID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
|
|
|
|
'CounterValue' => ['type' => 'INT', 'null' => false],
|
|
|
|
|
'CounterStart' => ['type' => 'INT', 'null' => false],
|
|
|
|
|
'CounterEnd' => ['type' => 'INT', 'null' => false],
|
2026-03-10 16:40:37 +07:00
|
|
|
'CounterName' => [ 'type' => 'VARCHAR', 'constraint' => 50, 'null' => true, 'after' => 'CounterID' ],
|
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
|
|
|
'CounterDesc' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
|
|
|
|
|
'CounterReset' => ['type' => 'varchar', 'constraint' => 1, 'null' => true],
|
|
|
|
|
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
|
|
|
|
'EndDate' => ['type' => 'DATETIME', 'null' => true]
|
|
|
|
|
]);
|
|
|
|
|
$this->forge->addKey('CounterID', true);
|
|
|
|
|
$this->forge->createTable('counter');
|
|
|
|
|
|
|
|
|
|
$this->forge->addField([
|
|
|
|
|
'ConDefID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
|
|
|
|
'SiteID' => ['type' => 'INT', 'null' => true],
|
|
|
|
|
'ConCode' => ['type' => 'VARCHAR', 'constraint' => 3, 'null' => false],
|
|
|
|
|
'ConName' => ['type' => 'varchar', 'constraint' => 50, 'null' => true],
|
|
|
|
|
'ConDesc' => ['type' => 'varchar', 'constraint' => 50, 'null' => true],
|
|
|
|
|
'Additive' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
|
|
|
|
'ConClass' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
|
|
|
|
'Color' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
|
|
|
|
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
|
|
|
|
'EndDate' => ['type' => 'DATETIME', 'null' => true]
|
|
|
|
|
]);
|
|
|
|
|
$this->forge->addKey('ConDefID', true);
|
|
|
|
|
$this->forge->addUniqueKey('ConCode');
|
|
|
|
|
$this->forge->createTable('containerdef');
|
|
|
|
|
|
|
|
|
|
$this->forge->addField([
|
|
|
|
|
'OccupationID' => [ 'type' => 'INT', 'constraint' => 11, 'auto_increment' => true],
|
|
|
|
|
'OccCode' => [ 'type' => 'VARCHAR', 'constraint' => 5, 'null' => true ],
|
|
|
|
|
'OccText' => [ 'type' => 'VARCHAR', 'constraint' => 255, 'null' => true ],
|
|
|
|
|
'Description' => [ 'type' => 'TEXT', 'null' => true ],
|
|
|
|
|
'CreateDate' => ['type' => 'DATETIME', 'null' => true],
|
|
|
|
|
]);
|
|
|
|
|
$this->forge->addKey('OccupationID', true);
|
|
|
|
|
$this->forge->createTable('occupation');
|
|
|
|
|
|
|
|
|
|
$this->forge->addField([
|
|
|
|
|
'SpecialtyID' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
|
|
|
|
|
'SpecialtyText' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
|
|
|
|
|
'Parent' => ['type' => 'int', 'null' => true],
|
|
|
|
|
'Title' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => false],
|
|
|
|
|
'CreateDate' => ['type' => 'datetime', 'null' => true],
|
|
|
|
|
'EndDate' => ['type' => 'datetime', 'null' => true],
|
|
|
|
|
]);
|
|
|
|
|
$this->forge->addKey('SpecialtyID', true);
|
|
|
|
|
$this->forge->createTable('medicalspecialty');
|
2026-02-24 16:53:36 +07:00
|
|
|
|
|
|
|
|
$this->forge->addField([
|
|
|
|
|
'AreaGeoID' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
|
|
|
|
|
'AreaCode' => ['type' => 'varchar', 'constraint' => 20, 'null' => true],
|
|
|
|
|
'Class' => ['type' => 'int', 'null' => true],
|
|
|
|
|
'AreaName' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => false],
|
|
|
|
|
'Parent' => ['type' => 'int', 'null' => true],
|
|
|
|
|
]);
|
|
|
|
|
$this->forge->addKey('AreaGeoID', true);
|
|
|
|
|
$this->forge->createTable('areageo');
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function down() {
|
2026-02-24 16:53:36 +07:00
|
|
|
$this->forge->dropTable('areageo');
|
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
|
|
|
$this->forge->dropTable('medicalspecialty');
|
|
|
|
|
$this->forge->dropTable('occupation');
|
|
|
|
|
$this->forge->dropTable('containerdef');
|
|
|
|
|
$this->forge->dropTable('counter');
|
|
|
|
|
$this->forge->dropTable('valuesetdef');
|
|
|
|
|
$this->forge->dropTable('valueset');
|
|
|
|
|
}
|
|
|
|
|
}
|