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 167d550..6ca3072 100644 --- a/app/Database/Migrations/2025-09-09-155526_Pat_Visit.php +++ b/app/Database/Migrations/2025-09-09-155526_Pat_Visit.php @@ -39,18 +39,19 @@ class CreatePVTables extends Migration { // patvisitadt $this->forge->addField([ - 'PVADTID' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true], - 'InternalPVID'=> ['type' => 'INT', 'constraint' => 11, 'null' => true], - 'ADTCode' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true], - 'LocationID' => ['type' => 'INT', 'constraint' => 11, 'null' => true], - 'AttDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true], - 'RefDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true], - 'AdmDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true], - 'CnsDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true], + 'PVADTID' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true], + 'InternalPVID'=> ['type' => 'INT', 'null' => true], + 'Sequence' => ['type' => 'INT', 'null' => true], + 'ADTCode' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true], + 'LocationID' => ['type' => 'INT', 'constraint' => 11, 'null' => true], + 'AttDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true], + 'RefDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true], + 'AdmDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true], + 'CnsDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true], 'CreateDate' => ['type' => 'DATETIME', 'null' => true], - 'EndDate' => ['type' => 'DATETIME', 'null' => true], + 'EndDate' => ['type' => 'DATETIME', 'null' => true], 'ArchivedDate'=> ['type' => 'DATETIME', 'null' => true], - 'DelDate' => ['type' => 'DATETIME', 'null' => true], + 'DelDate' => ['type' => 'DATETIME', 'null' => true], ]); $this->forge->addKey('PVADTID', true); $this->forge->createTable('patvisitadt'); diff --git a/app/Database/Seeds/DummySeeder.php b/app/Database/Seeds/DummySeeder.php index 73b3242..5ab8d3f 100644 --- a/app/Database/Seeds/DummySeeder.php +++ b/app/Database/Seeds/DummySeeder.php @@ -6,8 +6,11 @@ use CodeIgniter\Database\Seeder; class DummySeeder extends Seeder { + protected array $map = []; + public function run() { $now = date('Y-m-d H:i:s'); + // location $data = [ ['LocationID'=>1, 'LocCode'=>'QLOC', 'LocFull'=>'Dummy Location', 'LocType'=>'ROOM', 'Description'=>'Location made for dummy testing', 'CreateDate'=> "$now" ], @@ -52,17 +55,13 @@ class DummySeeder extends Seeder { // patient $data = [ - [ 'InternalPID'=>1, 'PatientID'=>'SMAJ1', 'NameFirst'=>'Dummy', 'NameLast' => 'Patient M', 'Gender'=>'6', 'BirthDate'=>'1991-09-09', 'Street_1'=>'Makati', 'EmailAddress1'=>'smaj1@5panda.id', - 'Province'=>'1', 'City'=>'37', 'Country'=>'325', 'Race'=>'175', 'Religion'=>'207', 'Ethnic'=>'218', 'DeathIndicator' => '16', 'CreateDate'=> "$now"], - [ 'InternalPID'=>2, 'PatientID'=>'SMAJ2', 'NameFirst'=>'Dummy', 'NameLast' => 'Patient F', 'Gender'=>'6', 'BirthDate'=>'1997-02-02', 'Street_1'=>'Manila', 'EmailAddress1'=>'smaj2@5panda.id', - 'Province'=>'2', 'City'=>'60', 'Country'=>'325', 'Race'=>'176', 'Religion'=>'206', 'Ethnic'=>'219', 'DeathIndicator' => '16', 'CreateDate'=> "$now"], - [ 'InternalPID'=>3, 'PatientID'=>'SMAJ3', 'NameFirst'=>'Dummy', 'NameLast' => 'Patient L', 'Gender'=>'6', 'BirthDate'=>'1997-02-02', 'Street_1'=>'Manila', 'EmailAddress1'=>'smaj3@5panda.id', - 'Province'=>'3', 'City'=>'103', 'Country'=>'325', 'Race'=>'176', 'Religion'=>'206', 'Ethnic'=>'219', 'DeathIndicator' => '16', 'CreateDate'=> "$now"] + [ 'InternalPID'=>1, 'PatientID'=>'SMAJ1', 'NameFirst'=>'Dummy', 'NameLast' => 'Patient M', 'BirthDate'=>'1991-09-09', 'Street_1'=>'Makati', 'EmailAddress1'=>'smaj1@5panda.id', 'CreateDate'=> "$now"], + [ 'InternalPID'=>2, 'PatientID'=>'SMAJ2', 'NameFirst'=>'Dummy', 'NameLast' => 'Patient F', 'BirthDate'=>'1997-02-02', 'Street_1'=>'Manila', 'EmailAddress1'=>'smaj2@5panda.id', 'CreateDate'=> "$now"], + [ 'InternalPID'=>3, 'PatientID'=>'SMAJ3', 'NameFirst'=>'Dummy', 'NameLast' => 'Patient L', 'BirthDate'=>'1997-02-02', 'Street_1'=>'Manila', 'EmailAddress1'=>'smaj3@5panda.id', 'CreateDate'=> "$now"] ]; $this->db->table('patient')->insertBatch($data); $data = [ [ 'InternalPID'=>1, 'IdentifierType'=>'KTP', 'Identifier'=>'9901', 'CreateDate'=> "$now" ], - // [ 'InternalPID'=>2, 'IdentifierType'=>'KTP', 'Identifier'=>'9902', 'CreateDate'=> "$now" ], [ 'InternalPID'=>3, 'IdentifierType'=>'KTP', 'Identifier'=>'9903', 'CreateDate'=> "$now" ] ]; $this->db->table('patidt')->insertBatch($data); @@ -76,13 +75,30 @@ class DummySeeder extends Seeder { ]; $this->db->table('patatt')->insertBatch($data); - + // patvisit + $data = [ + ['InternalPVID'=>1, "PVID"=>"XLAB0001", "InternalPID"=>1, "EpisodeID"=>1, "CreateDate"=>"$now"], + ['InternalPVID'=>2, "PVID"=>"XLAB0002", "InternalPID"=>1, "EpisodeID"=>1, "CreateDate"=>"$now"], + ]; + $this->db->table('patvisit')->insertBatch($data); + + $data = [ + ['InternalPVID'=>1, "Sequence"=>1, "ADTCode"=>"X01", "LocationID"=>1, "AttDoc"=>null, "CreateDate"=>"$now"], + ['InternalPVID'=>1, "Sequence"=>2, "ADTCode"=>"X02", "LocationID"=>null, "AttDoc"=>1, "CreateDate"=>"$now"], + ['InternalPVID'=>1, "Sequence"=>3, "ADTCode"=>"X01", "LocationID"=>2, "AttDoc"=>null, "CreateDate"=>"$now"], + ['InternalPVID'=>1, "Sequence"=>4, "ADTCode"=>"X02", "LocationID"=>null, "AttDoc"=>2, "CreateDate"=>"$now"], + ['InternalPVID'=>2, "Sequence"=>1, "ADTCode"=>"X01", "LocationID"=>1, "AttDoc"=>null, "CreateDate"=>"$now"], + ['InternalPVID'=>2, "Sequence"=>2, "ADTCode"=>"X02", "LocationID"=>null, "AttDoc"=>1, "CreateDate"=>"$now"], + ['InternalPVID'=>2, "Sequence"=>3, "ADTCode"=>"X01", "LocationID"=>2, "AttDoc"=>null, "CreateDate"=>"$now"], + ['InternalPVID'=>2, "Sequence"=>4, "ADTCode"=>"X02", "LocationID"=>null, "AttDoc"=>2, "CreateDate"=>"$now"], + ]; + $this->db->table('patvisitadt')->insertBatch($data); // Organization $data = [ - [ 'AccountID' => 1, 'Parent' => null, 'AccountName' => 'Dummy Account', 'Initial'=>'QAC', 'Street_1'=>'Dummy Address', 'City'=>'194', 'Province'=>'11', 'ZIP'=>'505', 'Country'=>'325', 'AreaCode'=>'', 'EmailAddress1'=>'dummy@summit.co.id', 'Phone'=>'092029', 'Fax'=>'092029', 'CreateDate' => "$now" ], - [ 'AccountID' => 2, 'Parent' => null, 'AccountName' => 'Dummy Account', 'Initial'=>'QAC', 'Street_1'=>'Dummy Address', 'City'=>'189', 'Province'=>'11', 'ZIP'=>'505', 'Country'=>'325', 'AreaCode'=>'', 'EmailAddress1'=>'dummy@summit.co.id', 'Phone'=>'092029', 'Fax'=>'092029', 'CreateDate' => "$now" ], - [ 'AccountID' => 3, 'Parent' => null, 'AccountName' => 'Dummy Account', 'Initial'=>'QAC', 'Street_1'=>'Dummy Address', 'City'=>'194', 'Province'=>'11', 'ZIP'=>'505', 'Country'=>'325', 'AreaCode'=>'', 'EmailAddress1'=>'dummy@summit.co.id', 'Phone'=>'092029', 'Fax'=>'092029', 'CreateDate' => "$now" ] + [ 'AccountID' => 1, 'Parent' => null, 'AccountName' => 'Dummy Account', 'Initial'=>'QAC', 'Street_1'=>'Dummy Address', 'EmailAddress1'=>'dummy@summit.co.id', 'Phone'=>'092029', 'Fax'=>'092029', 'CreateDate' => "$now" ], + [ 'AccountID' => 2, 'Parent' => null, 'AccountName' => 'Dummy Account', 'Initial'=>'QAC', 'Street_1'=>'Dummy Address', 'EmailAddress1'=>'dummy@summit.co.id', 'Phone'=>'092029', 'Fax'=>'092029', 'CreateDate' => "$now" ], + [ 'AccountID' => 3, 'Parent' => null, 'AccountName' => 'Dummy Account', 'Initial'=>'QAC', 'Street_1'=>'Dummy Address', 'EmailAddress1'=>'dummy@summit.co.id', 'Phone'=>'092029', 'Fax'=>'092029', 'CreateDate' => "$now" ] ]; $this->db->table('account')->insertBatch($data); diff --git a/app/Models/PatVisit/PatVisitADTModel.php b/app/Models/PatVisit/PatVisitADTModel.php index 33c9037..1683fea 100644 --- a/app/Models/PatVisit/PatVisitADTModel.php +++ b/app/Models/PatVisit/PatVisitADTModel.php @@ -6,7 +6,7 @@ use App\Models\BaseModel; class PatVisitADTModel extends BaseModel { protected $table = 'patvisitadt'; protected $primaryKey = 'PVADTID'; - protected $allowedFields = ['InternalPVID', 'ADTCode', 'LocationID', 'AttDoc', 'RefDoc', 'AdmDoc', 'CnsDoc', + protected $allowedFields = ['InternalPVID', 'Sequence', 'ADTCode', 'LocationID', 'AttDoc', 'RefDoc', 'AdmDoc', 'CnsDoc', 'CreateDate', 'EndDate', 'ArchivedDate', 'DelDate']; protected $visnum_prefix; diff --git a/app/Models/PatVisit/PatVisitModel.php b/app/Models/PatVisit/PatVisitModel.php index 1104e5d..dae06b0 100644 --- a/app/Models/PatVisit/PatVisitModel.php +++ b/app/Models/PatVisit/PatVisitModel.php @@ -108,7 +108,7 @@ class PatVisitModel extends BaseModel { $tmp = $modelPD->insert($input['PatDiag']); } } - if ($tmp === false) { + if (isset($tmp) && $tmp === false) { $error = $db->error(); throw new \Exception("Failed to update PatDiag record. ". $error['message']); }