diff --git a/app/Database/Migrations/2025-09-02-070826_Patient_Reg.php b/app/Database/Migrations/2025-09-02-070826_Patient_Reg.php index 2d71618..7f9c53b 100644 --- a/app/Database/Migrations/2025-09-02-070826_Patient_Reg.php +++ b/app/Database/Migrations/2025-09-02-070826_Patient_Reg.php @@ -12,7 +12,7 @@ class CreatePatientRegTables extends Migration { 'InternalPID'=> ['type' => 'INT', 'constraint' => 11, 'null' => true], 'Address' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true], 'UserID' => ['type' => 'INT', 'constraint' => 11, 'null' => true], - 'CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP', + 'CreateDate' => ['type' => 'DATETIME', 'null' => true], 'DelDate' => ['type' => 'DATETIME', 'null' => true], ]); $this->forge->addKey('PatAttID', true); @@ -24,7 +24,7 @@ class CreatePatientRegTables extends Migration { 'PatComID' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true], 'InternalPID'=> ['type' => 'INT', 'constraint' => 11, 'null' => true], 'Comment' => ['type' => 'TEXT', 'null' => true], - 'CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP', + 'CreateDate' => ['type' => 'DATETIME', 'null' => true], 'EndDate' => ['type' => 'DATETIME', 'null' => true], ]); $this->forge->addKey('PatComID', true); @@ -39,7 +39,7 @@ class CreatePatientRegTables extends Migration { 'Identifier' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true], 'EffectiveDate' => ['type' => 'DATETIME', 'null' => true], 'ExpirationDate'=> ['type' => 'DATETIME', 'null' => true], - 'CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP', + 'CreateDate' => ['type' => 'DATETIME', 'null' => true], 'DelDate' => ['type' => 'DATETIME', 'null' => true], ]); $this->forge->addKey('PatIdtID', true); @@ -80,9 +80,9 @@ class CreatePatientRegTables extends Migration { 'Citizenship' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true], 'DeathIndicator'=> ['type' => 'INT', 'constraint' => 11, 'null' => true], 'DeathDateTime' => ['type' => 'DATETIME', 'null' => true], - 'LinkTo' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true], - 'CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP', - 'DelDate' => ['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'); @@ -109,8 +109,8 @@ class CreatePatientRegTables extends Migration { '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->addField('LogDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP'); $this->forge->addKey('PatRegLogID', true); $this->forge->createTable('patreglog'); @@ -118,7 +118,7 @@ class CreatePatientRegTables extends Migration { $this->forge->addField([ 'PatRelID' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true], 'InternalPID'=> ['type' => 'INT', 'constraint' => 11, 'null' => true], - 'CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP', + 'CreateDate' => ['type' => 'DATETIME', 'null' => true], 'EndDate' => ['type' => 'DATETIME', 'null' => true], ]); $this->forge->addKey('PatRelID', true); diff --git a/app/Database/Migrations/2025-09-09-155526_Pat_Visit.php b/app/Database/Migrations/2025-09-09-155526_Pat_Visit.php index ca1320d..9602818 100644 --- a/app/Database/Migrations/2025-09-09-155526_Pat_Visit.php +++ b/app/Database/Migrations/2025-09-09-155526_Pat_Visit.php @@ -29,7 +29,7 @@ class CreatePVTables extends Migration { 'InternalPID' => ['type' => 'INT', 'constraint' => 11, 'null' => true], 'DiagCode' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true], 'Diagnosis' => ['type' => 'TEXT', 'null' => true], - 'CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP', + 'CreateDate' => ['type' => 'DATETIME', 'null' => true], 'EndDate' => ['type' => 'DATETIME', 'null' => true], 'ArchivedDate' => ['type' => 'DATETIME', 'null' => true], 'DelDate' => ['type' => 'DATETIME', 'null' => true], @@ -47,7 +47,7 @@ class CreatePVTables extends Migration { 'RefDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true], 'AdmDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true], 'CnsDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true], - 'CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP', + 'CreateDate' => ['type' => 'DATETIME', 'null' => true], 'EndDate' => ['type' => 'DATETIME', 'null' => true], 'ArchivedDate'=> ['type' => 'DATETIME', 'null' => true], 'DelDate' => ['type' => 'DATETIME', 'null' => true], @@ -75,7 +75,7 @@ class CreatePVTables extends Migration { 'EventID' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true], 'ActivityID' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true], 'Reason' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true], - 'LogDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP' + 'LogDate' => ['type' => 'DATETIME', 'null' => true], ]); $this->forge->addKey('PatVisLogID', true); $this->forge->createTable('patvisitlog'); diff --git a/app/Database/Migrations/2025-09-10-141522_Location.php b/app/Database/Migrations/2025-09-10-141522_Location.php index 23549b8..9722852 100644 --- a/app/Database/Migrations/2025-09-10-141522_Location.php +++ b/app/Database/Migrations/2025-09-10-141522_Location.php @@ -15,7 +15,7 @@ class CreateLocationTable extends Migration { 'LocFull' => ['type' => 'varchar', 'constraint' => 255, 'null' => true], 'Description' => ['type' => 'varchar', 'constraint' => 255, 'null' => true], 'LocType' => ['type' => 'varchar', 'constraint' => 11, 'null' => true], - 'CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP', + 'CreateDate' => ['type' => 'DATETIME', 'null' => true], 'EndDate' => ['type' => 'DATETIME', 'null' => true] ]); $this->forge->addKey('LocationID', true); @@ -30,7 +30,7 @@ class CreateLocationTable extends Migration { 'PostCode' => ['type' => 'varchar', 'constraint' => 255, 'null' => true], 'GeoLocationSystem' => ['type' => 'varchar', 'constraint' => 255, 'null' => true], 'GeoLocationData' => ['type' => 'varchar', 'constraint' => 255, 'null' => true], - 'CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP', + 'CreateDate' => ['type' => 'DATETIME', 'null' => true], 'EndDate' => ['type' => 'DATETIME', 'null' => true] ]); $this->forge->addKey('LocationID', true); diff --git a/app/Database/Migrations/2025-09-12-011643_Contact.php b/app/Database/Migrations/2025-09-12-011643_Contact.php index c8a7e49..517251c 100644 --- a/app/Database/Migrations/2025-09-12-011643_Contact.php +++ b/app/Database/Migrations/2025-09-12-011643_Contact.php @@ -22,7 +22,7 @@ class CreateContactTable extends Migration { 'Specialty' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ], 'SubSpecialty' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ], 'Password' => [ 'type' => 'VARCHAR', 'constraint' => 255, 'null' => true ], - 'CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP', + 'CreateDate' => ['type' => 'DATETIME', 'null' => true], 'EndDate' => [ 'type' => 'DATETIME', 'null' => true ], ]); $this->forge->addKey('ContactID', true); @@ -51,7 +51,7 @@ class CreateContactTable extends Migration { 'OccCode' => [ 'type' => 'VARCHAR', 'constraint' => 5, 'null' => true ], 'OccText' => [ 'type' => 'VARCHAR', 'constraint' => 255, 'null' => true ], 'Description' => [ 'type' => 'TEXT', 'null' => true ], - 'CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP', + 'CreateDate' => ['type' => 'DATETIME', 'null' => true], ]); $this->forge->addKey('OccupationID', true); $this->forge->createTable('occupation'); diff --git a/app/Database/Migrations/2025-09-12-100001_Order_Test.php b/app/Database/Migrations/2025-09-12-100001_Order_Test.php index 3e7658d..a94b01f 100644 --- a/app/Database/Migrations/2025-09-12-100001_Order_Test.php +++ b/app/Database/Migrations/2025-09-12-100001_Order_Test.php @@ -18,11 +18,11 @@ class CreateOrdersTable extends Migration { 'Priority' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true], 'TrnDate' => ['type' => 'Datetime', 'null' => true], 'EffDate' => ['type' => 'Datetime', 'null' => true], + 'CreateDate' => ['type' => 'Datetime', 'null' => true], 'EndDate' => ['type' => 'Datetime', 'null' => true], 'ArchiveDate' => ['type' => 'Datetime', 'null' => true], 'DelDate' => ['type' => 'Datetime', 'null' => true] ]); - $this->forge->addField('CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP'); $this->forge->addKey('InternalOID', true); $this->forge->addUniqueKey('OrderID'); $this->forge->createTable('ordertest'); @@ -32,11 +32,11 @@ class CreateOrdersTable extends Migration { 'OrderComID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true], 'Comment' => ['type' => 'text', 'null' => true], 'UserID' => ['type' => 'INT', 'null' => false], + 'CreateDate' => ['type' => 'Datetime', 'null' => true], 'EndDate' => ['type' => 'Datetime', 'null' => true], 'ArchiveDate' => ['type' => 'Datetime', 'null' => true], 'DelDate' => ['type' => 'Datetime', 'null' => true] ]); - $this->forge->addField('CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP'); $this->forge->addKey('OrderComID', true); $this->forge->createTable('ordercom'); @@ -45,11 +45,11 @@ class CreateOrdersTable extends Migration { 'OrderAttID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true], 'Address' => ['type' => 'varchar', 'constraint'=>255, 'null' => true], 'UserID' => ['type' => 'INT', 'null' => false], + 'CreateDate' => ['type' => 'Datetime', 'null' => true], 'EndDate' => ['type' => 'Datetime', 'null' => true], 'ArchiveDate' => ['type' => 'Datetime', 'null' => true], 'DelDate' => ['type' => 'Datetime', 'null' => true] ]); - $this->forge->addField('CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP'); $this->forge->addKey('OrderAttID', true); $this->forge->createTable('orderatt'); @@ -57,11 +57,11 @@ class CreateOrdersTable extends Migration { 'InternalOID' => ['type' => 'INT', 'null' => false], 'OrderStatID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true], 'OrderStatus' => ['type' => 'varchar', 'constraint'=>2, 'null' => false], + 'CreateDate' => ['type' => 'Datetime', 'null' => true], 'EndDate' => ['type' => 'Datetime', 'null' => true], 'ArchiveDate' => ['type' => 'Datetime', 'null' => true], 'DelDate' => ['type' => 'Datetime', 'null' => true] ]); - $this->forge->addField('CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP'); $this->forge->addKey('OrderStatID', true); $this->forge->createTable('orderstatus'); diff --git a/app/Database/Migrations/2025-09-15-130122_ValueSet.php b/app/Database/Migrations/2025-09-15-130122_ValueSet.php index 8c90c29..c1ca970 100644 --- a/app/Database/Migrations/2025-09-15-130122_ValueSet.php +++ b/app/Database/Migrations/2025-09-15-130122_ValueSet.php @@ -15,9 +15,9 @@ class CreateValueSetTable extends Migration { '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->addField('CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP'); $this->forge->addKey('VID', true); $this->forge->createTable('valueset'); @@ -26,9 +26,9 @@ class CreateValueSetTable extends Migration { '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->addField('CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP'); $this->forge->addKey('VSetID', true); $this->forge->createTable('valuesetdef'); } diff --git a/app/Database/Migrations/2025-09-22-155700_Counter.php b/app/Database/Migrations/2025-09-22-155700_Counter.php index 8651488..8431680 100644 --- a/app/Database/Migrations/2025-09-22-155700_Counter.php +++ b/app/Database/Migrations/2025-09-22-155700_Counter.php @@ -14,9 +14,9 @@ class CreateCounterTable extends Migration { 'CounterEnd' => ['type' => 'INT', 'null' => false], '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->addField('CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP'); $this->forge->addKey('CounterID', true); $this->forge->createTable('counter'); } diff --git a/app/Database/Migrations/2025-10-07-132705_Specimen.php b/app/Database/Migrations/2025-10-07-132705_Specimen.php index 669e2df..ee7125f 100644 --- a/app/Database/Migrations/2025-10-07-132705_Specimen.php +++ b/app/Database/Migrations/2025-10-07-132705_Specimen.php @@ -16,7 +16,7 @@ class CreateSpecimenTable extends Migration { 'Additive' => ['type' => 'varchar', 'constraint' => 50, 'null' => true], 'ConClass' => ['type' => 'int', 'null' => false], 'Color' => ['type' => 'int', 'null' => false], - 'CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP', + 'CreateDate' => ['type' => 'Datetime', 'null' => true], 'EndDate' => ['type' => 'DATETIME', 'null' => true] ]); $this->forge->addKey('ConDefID', true); @@ -34,7 +34,7 @@ class CreateSpecimenTable extends Migration { 'Unit' => ['type' => 'varchar', 'constraint'=> 30, 'null' => true], 'GenerateBy' => ['type' => 'int', 'null' => true], 'SchDateTime' => ['type' => 'datetime', 'null' => true], - 'CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP', + 'CreateDate' => ['type' => 'Datetime', 'null' => true], 'EndDate' => ['type' => 'DATETIME', 'null' => true], 'ArchiveDate' => ['type' => 'DATETIME', 'null' => true] ]); @@ -59,7 +59,7 @@ class CreateSpecimenTable extends Migration { 'GeoLocationData' => ['type' => 'varchar', 'constraint'=>10, 'null' => true ], 'DIDType' => ['type' => 'varchar', 'constraint'=>10, 'null' => true ], 'DID' => ['type' => 'varchar', 'constraint'=>10, 'null' => true ], - 'CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP', + 'CreateDate' => ['type' => 'Datetime', 'null' => true], 'EndDate' => ['type' => 'DATETIME', 'null' => true], 'ArchiveDate' => ['type' => 'DATETIME', 'null' => true] ]); @@ -76,7 +76,7 @@ class CreateSpecimenTable extends Migration { 'FastingVolume' => ['type' => 'varchar', 'constraint'=> 2, 'null' => true], 'ColStart' => ['type' => 'datetime', 'null' => true], 'ColEnd' => ['type' => 'datetime', 'null' => true], - 'CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP', + 'CreateDate' => ['type' => 'Datetime', 'null' => true], 'EndDate' => ['type' => 'DATETIME', 'null' => true], 'ArchiveDate' => ['type' => 'DATETIME', 'null' => true] ]); @@ -93,7 +93,7 @@ class CreateSpecimenTable extends Migration { 'AddUnit' => ['type' => 'varchar', 'constraint'=> 15, 'null' => true], 'PrepStart' => ['type' => 'datetime', 'null' => true], 'PrepEnd' => ['type' => 'datetime', 'null' => true], - 'CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP', + 'CreateDate' => ['type' => 'Datetime', 'null' => true], 'EndDate' => ['type' => 'DATETIME', 'null' => true], 'ArchiveDate' => ['type' => 'DATETIME', 'null' => true] ]); @@ -118,7 +118,7 @@ class CreateSpecimenTable extends Migration { 'EventID' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true], 'ActivityID' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true], 'Reason' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true], - 'LogDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP' + 'LogDate' => ['type' => 'Datetime', 'null' => true], ]); $this->forge->addKey('SpcLogID', true); $this->forge->createTable('specimenlog'); diff --git a/app/Models/PatientModel.php b/app/Models/PatientModel.php index 892fc98..f68b793 100644 --- a/app/Models/PatientModel.php +++ b/app/Models/PatientModel.php @@ -11,7 +11,10 @@ class PatientModel extends Model { protected $allowedFields = ['PatientID', 'AlternatePID', 'Prefix', 'NameFirst', 'NameMiddle', 'NameMaiden', 'NameLast', 'Suffix', 'NameAlias', 'Gender', 'Birthdate', 'PlaceOfBirth', 'Street_1', 'Street_2', 'Street_3', 'City', 'Province', 'ZIP', 'EmailAddress1', 'EmailAddress2', 'Phone', 'MobilePhone', 'Custodian', 'AccountNumber', 'Country', 'Race', 'MaritalStatus', 'Religion', 'Ethnic', 'Citizenship', 'DeathIndicator', 'DeathDateTime', 'LinkTo' ]; - + protected $useTimestamps = true; // Enable automatic timestamps + protected $createdField = 'CreateDate'; // Specify the 'created_at' field name + protected $dateFormat = 'datetime'; + public function getPatients($filters = []) { $qname = "LOWER(CONCAT_WS(' ', IFNULL(Prefix,''), IFNULL(NameFirst,''), IFNULL(NameMiddle,''), IFNULL(NameLast,''), IFNULL(NameMaiden,''), IFNULL(Suffix,'')))";