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.
131 lines
7.3 KiB
PHP
131 lines
7.3 KiB
PHP
<?php
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
class CreatePatientCore extends Migration {
|
|
public function up() {
|
|
$this->forge->addField([
|
|
'InternalPID' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
|
|
'PatientID' => ['type' => 'VARCHAR', 'constraint' => 255],
|
|
'AlternatePID' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'Prefix' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'NameFirst' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'NameMiddle' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'NameMaiden' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'NameLast' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'Suffix' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'NameAlias' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'Sex' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
|
'PlaceOfBirth' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'Birthdate' => ['type' => 'DATE', 'null' => true],
|
|
'Street_1' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'Street_2' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'Street_3' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'City' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'Province' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'ZIP' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'EmailAddress1' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'EmailAddress2' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'Phone' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'MobilePhone' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'Custodian' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
|
'AccountNumber' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
|
'Country' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
|
'Race' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
|
'MaritalStatus' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
|
'Religion' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
|
'Ethnic' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
|
'Citizenship' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'DeathIndicator'=> ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
|
'TimeOfDeath' => ['type' => 'DATETIME', 'null' => true],
|
|
'LinkTo' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'CreateDate' => ['type' => 'DATETIME', 'null' => true],
|
|
'DelDate' => ['type' => 'DATETIME', 'null' => true]
|
|
]);
|
|
$this->forge->addKey('InternalPID', true);
|
|
$this->forge->addUniqueKey('PatientID');
|
|
$this->forge->addUniqueKey('AlternatePID');
|
|
$this->forge->addUniqueKey('EmailAddress1');
|
|
$this->forge->createTable('patient');
|
|
|
|
$this->forge->addField([
|
|
'PatAttID' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
|
|
'InternalPID'=> ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
|
'Address' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'UserID' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
|
'CreateDate' => ['type' => 'DATETIME', 'null' => true],
|
|
'DelDate' => ['type' => 'DATETIME', 'null' => true],
|
|
]);
|
|
$this->forge->addKey('PatAttID', true);
|
|
$this->forge->addUniqueKey('Address');
|
|
$this->forge->createTable('patatt');
|
|
|
|
$this->forge->addField([
|
|
'PatComID' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
|
|
'InternalPID'=> ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
|
'Comment' => ['type' => 'TEXT', 'null' => true],
|
|
'CreateDate' => ['type' => 'DATETIME', 'null' => true],
|
|
'EndDate' => ['type' => 'DATETIME', 'null' => true],
|
|
]);
|
|
$this->forge->addKey('PatComID', true);
|
|
$this->forge->addUniqueKey('InternalPID');
|
|
$this->forge->createTable('patcom');
|
|
|
|
$this->forge->addField([
|
|
'PatIdtID' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
|
|
'InternalPID' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
|
'IdentifierType'=> ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'Identifier' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
|
'EffectiveDate' => ['type' => 'DATETIME', 'null' => true],
|
|
'ExpirationDate'=> ['type' => 'DATETIME', 'null' => true],
|
|
'CreateDate' => ['type' => 'DATETIME', 'null' => true],
|
|
'DelDate' => ['type' => 'DATETIME', 'null' => true],
|
|
]);
|
|
$this->forge->addKey('PatIdtID', true);
|
|
$this->forge->createTable('patidt');
|
|
|
|
$this->forge->addField([
|
|
'PatRelID' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
|
|
'InternalPID'=> ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
|
'CreateDate' => ['type' => 'DATETIME', 'null' => true],
|
|
'EndDate' => ['type' => 'DATETIME', 'null' => true],
|
|
]);
|
|
$this->forge->addKey('PatRelID', true);
|
|
$this->forge->createTable('patrelation');
|
|
|
|
$this->forge->addField([
|
|
'PatRegLogID'=> ['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('PatRegLogID', true);
|
|
$this->forge->createTable('patreglog');
|
|
}
|
|
|
|
public function down() {
|
|
$this->forge->dropTable('patreglog');
|
|
$this->forge->dropTable('patrelation');
|
|
$this->forge->dropTable('patidt');
|
|
$this->forge->dropTable('patcom');
|
|
$this->forge->dropTable('patatt');
|
|
$this->forge->dropTable('patient');
|
|
}
|
|
}
|