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.
120 lines
6.3 KiB
PHP
120 lines
6.3 KiB
PHP
<?php
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
class CreateSpecimens extends Migration {
|
|
public function up() {
|
|
$this->forge->addField([
|
|
'InternalSID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
|
'SID' => ['type' => 'VARCHAR', 'constraint' => 30, 'null' => false],
|
|
'SiteID' => ['type' => 'INT', 'null' => true],
|
|
'OrderID' => ['type' => 'INT', 'null' => true],
|
|
'ConDefID' => ['type' => 'INT', 'null' => true],
|
|
'Parent' => ['type' => 'varchar', 'constraint' => 30, 'null' => true],
|
|
'Qty' => ['type' => 'INT', 'null' => true],
|
|
'Unit' => ['type' => 'varchar', 'constraint'=> 30, 'null' => true],
|
|
'GenerateBy' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
|
'SchDateTime' => ['type' => 'datetime', 'null' => true],
|
|
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
|
'EndDate' => ['type' => 'DATETIME', 'null' => true],
|
|
'ArchiveDate' => ['type' => 'DATETIME', 'null' => true]
|
|
]);
|
|
$this->forge->addKey('InternalSID', true);
|
|
$this->forge->addUniqueKey('SID');
|
|
$this->forge->createTable('specimen');
|
|
|
|
$this->forge->addField([
|
|
'SpcStaID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
|
'SID' => ['type' => 'VARCHAR', 'constraint' => 30, 'null' => false],
|
|
'OrderID' => ['type' => 'int', 'null' => false],
|
|
'SpcAct' => ['type' => 'varchar', 'constraint' => 15, 'null' => true],
|
|
'ActRes' => ['type' => 'INT', 'null' => true],
|
|
'SpcStatus' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
|
'Qty' => ['type' => 'INT', 'null' => true],
|
|
'Unit' => ['type' => 'INT', 'null' => true],
|
|
'SpcCon' => ['type' => 'INT', 'null' => true],
|
|
'Comment' => ['type' => 'varchar', 'constraint'=>150, 'null' => true],
|
|
'CurrSiteID' => ['type' => 'int', 'null' => true ],
|
|
'CurrLocID' => ['type' => 'int', 'null' => true ],
|
|
'Origin' => ['type' => 'varchar', 'constraint'=>50, 'null' => true ],
|
|
'GeoLocationSystem' => ['type' => 'varchar', 'constraint'=>10, 'null' => true ],
|
|
'GeoLocationData' => ['type' => 'varchar', 'constraint'=>10, 'null' => true ],
|
|
'DIDType' => ['type' => 'varchar', 'constraint'=>10, 'null' => true ],
|
|
'DID' => ['type' => 'varchar', 'constraint'=>10, 'null' => true ],
|
|
'UserID' => ['type' => 'int', 'null' => true ],
|
|
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
|
'EndDate' => ['type' => 'DATETIME', 'null' => true],
|
|
'ArchiveDate' => ['type' => 'DATETIME', 'null' => true]
|
|
]);
|
|
$this->forge->addKey('SpcStaID', true);
|
|
$this->forge->createTable('specimenstatus');
|
|
|
|
$this->forge->addField([
|
|
'SpcColID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
|
'SpcStaID' => ['type' => 'INT', 'unsigned' => true],
|
|
'SpcRole' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
|
'ColMethod' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
|
'BodySite' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
|
'CntSize' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
|
'FastingVolume' => ['type' => 'varchar', 'constraint'=> 2, 'null' => true],
|
|
'ColStart' => ['type' => 'datetime', 'null' => true],
|
|
'ColEnd' => ['type' => 'datetime', 'null' => true],
|
|
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
|
'EndDate' => ['type' => 'DATETIME', 'null' => true],
|
|
'ArchiveDate' => ['type' => 'DATETIME', 'null' => true]
|
|
]);
|
|
$this->forge->addKey('SpcColID', true);
|
|
$this->forge->createTable('specimencollection');
|
|
|
|
$this->forge->addField([
|
|
'SpcPrpID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
|
'SpcStaID' => ['type' => 'INT', 'unsigned' => true],
|
|
'Description' => ['type' => 'varchar', 'constraint' => 150, 'null' => true],
|
|
'Method' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
|
'Additive' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
|
'AddQty' => ['type' => 'float', 'null' => true],
|
|
'AddUnit' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
|
'PrepStart' => ['type' => 'datetime', 'null' => true],
|
|
'PrepEnd' => ['type' => 'datetime', 'null' => true],
|
|
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
|
'EndDate' => ['type' => 'DATETIME', 'null' => true],
|
|
'ArchiveDate' => ['type' => 'DATETIME', 'null' => true]
|
|
]);
|
|
$this->forge->addKey('SpcPrpID', true);
|
|
$this->forge->createTable('specimenprep');
|
|
|
|
$this->forge->addField([
|
|
'SpcLogID'=> ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
|
|
'TblName' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'RecID' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
|
'FldName' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'FldValuePrev'=> ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'UserID' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
|
'SiteID' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
|
'DIDType' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'DID' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'MachineID' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'SessionID' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'AppID' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'ProcessID' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'WebPageID' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'EventID' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'ActivityID' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'Reason' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'LogDate' => ['type' => 'Datetime', 'null' => true],
|
|
]);
|
|
$this->forge->addKey('SpcLogID', true);
|
|
$this->forge->createTable('specimenlog');
|
|
}
|
|
|
|
public function down() {
|
|
$this->forge->dropTable('specimenlog');
|
|
$this->forge->dropTable('specimenprep');
|
|
$this->forge->dropTable('specimencollection');
|
|
$this->forge->dropTable('specimenstatus');
|
|
$this->forge->dropTable('specimen');
|
|
}
|
|
}
|