diff --git a/app/Database/Migrations/2026-01-01-000004_CreateSecurity.php b/app/Database/Migrations/2026-01-01-000003_CreateUsers.php similarity index 100% rename from app/Database/Migrations/2026-01-01-000004_CreateSecurity.php rename to app/Database/Migrations/2026-01-01-000003_CreateUsers.php diff --git a/app/Database/Migrations/2026-01-01-000008_CreateTestDefinitions.php b/app/Database/Migrations/2026-01-01-000004_CreateTestDefinitions.php similarity index 100% rename from app/Database/Migrations/2026-01-01-000008_CreateTestDefinitions.php rename to app/Database/Migrations/2026-01-01-000004_CreateTestDefinitions.php diff --git a/app/Database/Migrations/2026-01-01-000010_CreateLabInfrastructure.php b/app/Database/Migrations/2026-01-01-000005_CreateLabInfrastructure.php similarity index 100% rename from app/Database/Migrations/2026-01-01-000010_CreateLabInfrastructure.php rename to app/Database/Migrations/2026-01-01-000005_CreateLabInfrastructure.php diff --git a/app/Database/Migrations/2026-01-01-000007_CreateSpecimens.php b/app/Database/Migrations/2026-01-01-000006_CreateSpecimens.php similarity index 100% rename from app/Database/Migrations/2026-01-01-000007_CreateSpecimens.php rename to app/Database/Migrations/2026-01-01-000006_CreateSpecimens.php diff --git a/app/Database/Migrations/2026-01-01-000003_CreatePatientCore.php b/app/Database/Migrations/2026-01-01-000011_CreatePatientCore.php similarity index 100% rename from app/Database/Migrations/2026-01-01-000003_CreatePatientCore.php rename to app/Database/Migrations/2026-01-01-000011_CreatePatientCore.php diff --git a/app/Database/Migrations/2026-01-01-000005_CreatePatientVisits.php b/app/Database/Migrations/2026-01-01-000012_CreatePatientVisits.php similarity index 100% rename from app/Database/Migrations/2026-01-01-000005_CreatePatientVisits.php rename to app/Database/Migrations/2026-01-01-000012_CreatePatientVisits.php diff --git a/app/Database/Migrations/2026-01-01-000006_CreateOrders.php b/app/Database/Migrations/2026-01-01-000021_CreateOrders.php similarity index 100% rename from app/Database/Migrations/2026-01-01-000006_CreateOrders.php rename to app/Database/Migrations/2026-01-01-000021_CreateOrders.php diff --git a/app/Database/Migrations/2026-01-01-000009_CreateResults.php b/app/Database/Migrations/2026-01-01-000022_CreateResults.php similarity index 100% rename from app/Database/Migrations/2026-01-01-000009_CreateResults.php rename to app/Database/Migrations/2026-01-01-000022_CreateResults.php diff --git a/app/Database/Migrations/2026-02-20-000011_CreateAuditLogs.php b/app/Database/Migrations/2026-02-20-000011_CreateAuditLogs.php deleted file mode 100644 index 388780f..0000000 --- a/app/Database/Migrations/2026-02-20-000011_CreateAuditLogs.php +++ /dev/null @@ -1,162 +0,0 @@ -forge->dropTable('patreglog', true); - $this->forge->dropTable('patvisitlog', true); - $this->forge->dropTable('specimenlog', true); - - // Create data_audit_log table - $this->forge->addField([ - 'id' => ['type' => 'BIGINT', 'constraint' => 20, 'unsigned' => true, 'auto_increment' => true], - 'operation' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => false], - 'entity_type' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => false], - 'entity_id' => ['type' => 'VARCHAR', 'constraint' => 36, 'null' => false], - 'table_name' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true], - 'field_name' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true], - 'previous_value' => ['type' => 'JSON', 'null' => true], - 'new_value' => ['type' => 'JSON', 'null' => true], - 'mechanism' => ['type' => 'ENUM', 'constraint' => ['MANUAL', 'AUTOMATIC'], 'null' => false, 'default' => 'MANUAL'], - 'application_id' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true], - 'web_page' => ['type' => 'VARCHAR', 'constraint' => 500, 'null' => true], - 'session_id' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true], - 'event_type' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true], - 'site_id' => ['type' => 'VARCHAR', 'constraint' => 36, 'null' => true], - 'workstation_id' => ['type' => 'VARCHAR', 'constraint' => 36, 'null' => true], - 'pc_name' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true], - 'ip_address' => ['type' => 'VARCHAR', 'constraint' => 45, 'null' => true], - 'user_id' => ['type' => 'VARCHAR', 'constraint' => 36, 'null' => false], - 'created_at' => ['type' => 'DATETIME', 'null' => false], - 'reason' => ['type' => 'TEXT', 'null' => true], - 'context' => ['type' => 'JSON', 'null' => true] - ]); - $this->forge->addKey('id', true); - $this->forge->addKey('idx_operation_created', ['operation', 'created_at']); - $this->forge->addKey('idx_entity', ['entity_type', 'entity_id', 'created_at']); - $this->forge->addKey('idx_user_created', ['user_id', 'created_at']); - $this->forge->addKey('idx_mechanism', ['mechanism', 'created_at']); - $this->forge->addKey('idx_table', ['table_name', 'created_at']); - $this->forge->addKey('idx_site', ['site_id', 'created_at']); - $this->forge->addKey('idx_created', 'created_at'); - $this->forge->addKey('idx_session', ['session_id', 'created_at']); - $this->forge->createTable('data_audit_log', true); - - // Create service_audit_log table - $this->forge->addField([ - 'id' => ['type' => 'BIGINT', 'constraint' => 20, 'unsigned' => true, 'auto_increment' => true], - 'operation' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => false], - 'entity_type' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => false], - 'entity_id' => ['type' => 'VARCHAR', 'constraint' => 36, 'null' => false], - 'service_class' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true], - 'resource_type' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true], - 'resource_details' => ['type' => 'JSON', 'null' => true], - 'previous_value' => ['type' => 'JSON', 'null' => true], - 'new_value' => ['type' => 'JSON', 'null' => true], - 'mechanism' => ['type' => 'ENUM', 'constraint' => ['MANUAL', 'AUTOMATIC'], 'null' => false, 'default' => 'AUTOMATIC'], - 'application_id' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true], - 'service_name' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true], - 'session_id' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true], - 'event_type' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true], - 'site_id' => ['type' => 'VARCHAR', 'constraint' => 36, 'null' => true], - 'workstation_id' => ['type' => 'VARCHAR', 'constraint' => 36, 'null' => true], - 'pc_name' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true], - 'ip_address' => ['type' => 'VARCHAR', 'constraint' => 45, 'null' => true], - 'port' => ['type' => 'INT', 'null' => true], - 'user_id' => ['type' => 'VARCHAR', 'constraint' => 36, 'null' => false], - 'created_at' => ['type' => 'DATETIME', 'null' => false], - 'reason' => ['type' => 'TEXT', 'null' => true], - 'context' => ['type' => 'JSON', 'null' => true] - ]); - $this->forge->addKey('id', true); - $this->forge->addKey('idx_operation_created', ['operation', 'created_at']); - $this->forge->addKey('idx_entity', ['entity_type', 'entity_id', 'created_at']); - $this->forge->addKey('idx_service_class', ['service_class', 'created_at']); - $this->forge->addKey('idx_user_created', ['user_id', 'created_at']); - $this->forge->addKey('idx_mechanism', ['mechanism', 'created_at']); - $this->forge->addKey('idx_site', ['site_id', 'created_at']); - $this->forge->addKey('idx_created', 'created_at'); - $this->forge->createTable('service_audit_log', true); - - // Create security_audit_log table - $this->forge->addField([ - 'id' => ['type' => 'BIGINT', 'constraint' => 20, 'unsigned' => true, 'auto_increment' => true], - 'operation' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => false], - 'entity_type' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => false], - 'entity_id' => ['type' => 'VARCHAR', 'constraint' => 36, 'null' => false], - 'security_class' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true], - 'resource_path' => ['type' => 'VARCHAR', 'constraint' => 500, 'null' => true], - 'previous_value' => ['type' => 'JSON', 'null' => true], - 'new_value' => ['type' => 'JSON', 'null' => true], - 'mechanism' => ['type' => 'ENUM', 'constraint' => ['MANUAL', 'AUTOMATIC'], 'null' => false, 'default' => 'MANUAL'], - 'application_id' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true], - 'web_page' => ['type' => 'VARCHAR', 'constraint' => 500, 'null' => true], - 'session_id' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true], - 'event_type' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true], - 'site_id' => ['type' => 'VARCHAR', 'constraint' => 36, 'null' => true], - 'workstation_id' => ['type' => 'VARCHAR', 'constraint' => 36, 'null' => true], - 'pc_name' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true], - 'ip_address' => ['type' => 'VARCHAR', 'constraint' => 45, 'null' => true], - 'user_id' => ['type' => 'VARCHAR', 'constraint' => 36, 'null' => false], - 'created_at' => ['type' => 'DATETIME', 'null' => false], - 'reason' => ['type' => 'TEXT', 'null' => true], - 'context' => ['type' => 'JSON', 'null' => true] - ]); - $this->forge->addKey('id', true); - $this->forge->addKey('idx_operation_created', ['operation', 'created_at']); - $this->forge->addKey('idx_entity', ['entity_type', 'entity_id', 'created_at']); - $this->forge->addKey('idx_security_class', ['security_class', 'created_at']); - $this->forge->addKey('idx_user_created', ['user_id', 'created_at']); - $this->forge->addKey('idx_event_type', ['event_type', 'created_at']); - $this->forge->addKey('idx_site', ['site_id', 'created_at']); - $this->forge->addKey('idx_created', 'created_at'); - $this->forge->addKey('idx_session', ['session_id', 'created_at']); - $this->forge->createTable('security_audit_log', true); - - // Create error_audit_log table - $this->forge->addField([ - 'id' => ['type' => 'BIGINT', 'constraint' => 20, 'unsigned' => true, 'auto_increment' => true], - 'operation' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => false], - 'entity_type' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => false], - 'entity_id' => ['type' => 'VARCHAR', 'constraint' => 36, 'null' => false], - 'error_code' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true], - 'error_message' => ['type' => 'TEXT', 'null' => true], - 'error_details' => ['type' => 'JSON', 'null' => true], - 'previous_value' => ['type' => 'JSON', 'null' => true], - 'new_value' => ['type' => 'JSON', 'null' => true], - 'mechanism' => ['type' => 'ENUM', 'constraint' => ['MANUAL', 'AUTOMATIC'], 'null' => false, 'default' => 'MANUAL'], - 'application_id' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true], - 'web_page' => ['type' => 'VARCHAR', 'constraint' => 500, 'null' => true], - 'session_id' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true], - 'event_type' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true], - 'site_id' => ['type' => 'VARCHAR', 'constraint' => 36, 'null' => true], - 'workstation_id' => ['type' => 'VARCHAR', 'constraint' => 36, 'null' => true], - 'pc_name' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true], - 'ip_address' => ['type' => 'VARCHAR', 'constraint' => 45, 'null' => true], - 'user_id' => ['type' => 'VARCHAR', 'constraint' => 36, 'null' => false], - 'created_at' => ['type' => 'DATETIME', 'null' => false], - 'reason' => ['type' => 'TEXT', 'null' => true], - 'context' => ['type' => 'JSON', 'null' => true] - ]); - $this->forge->addKey('id', true); - $this->forge->addKey('idx_operation_created', ['operation', 'created_at']); - $this->forge->addKey('idx_entity', ['entity_type', 'entity_id', 'created_at']); - $this->forge->addKey('idx_error_code', ['error_code', 'created_at']); - $this->forge->addKey('idx_event_type', ['event_type', 'created_at']); - $this->forge->addKey('idx_user_created', ['user_id', 'created_at']); - $this->forge->addKey('idx_site', ['site_id', 'created_at']); - $this->forge->addKey('idx_created', 'created_at'); - $this->forge->createTable('error_audit_log', true); - } - - public function down() { - $this->forge->dropTable('error_audit_log'); - $this->forge->dropTable('security_audit_log'); - $this->forge->dropTable('service_audit_log'); - $this->forge->dropTable('data_audit_log'); - } -} diff --git a/app/Database/Seeds/TestSeeder.php b/app/Database/Seeds/TestSeeder.php index b845faf..bf45ce8 100644 --- a/app/Database/Seeds/TestSeeder.php +++ b/app/Database/Seeds/TestSeeder.php @@ -127,19 +127,19 @@ class TestSeeder extends Seeder $data = ['SiteID' => '1', 'TestSiteCode' => 'BMI', 'TestSiteName' => 'Body Mass Index', 'TestType' => 'CALC', 'Description' => 'Indeks Massa Tubuh - weight/(height^2)', 'SeqScr' => '45', 'SeqRpt' => '45', 'IndentLeft' => '0', 'VisibleScr' => '1', 'VisibleRpt' => '1', 'CountStat' => '0', 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['BMI'] = $this->db->insertID(); - $data = ['TestSiteID' => $tIDs['BMI'], 'DisciplineID' => '10', 'DepartmentID' => '', 'FormulaInput' => 'WEIGHT,HEIGHT', 'FormulaCode' => 'WEIGHT / ((HEIGHT/100) * (HEIGHT/100))', 'ResultType' => 'NMRIC', 'RefType' => 'RANGE', 'Unit1' => 'kg/m2', 'Factor' => '', 'Unit2' => '', 'Decimal' => '1', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['BMI'], 'DisciplineID' => '10', 'DepartmentID' => '', 'FormulaInput' => 'WEIGHT,HEIGHT', 'FormulaCode' => 'WEIGHT / ((HEIGHT/100) * (HEIGHT/100))', 'RefType' => 'RANGE', 'Unit1' => 'kg/m2', 'Factor' => '', 'Unit2' => '', 'Decimal' => '1', 'CreateDate' => "$now"]; $this->db->table('testdefcal')->insert($data); $data = ['SiteID' => '1', 'TestSiteCode' => 'EGFR', 'TestSiteName' => 'eGFR (CKD-EPI)', 'TestType' => 'CALC', 'Description' => 'Estimated Glomerular Filtration Rate', 'SeqScr' => '20', 'SeqRpt' => '20', 'IndentLeft' => '1', 'VisibleScr' => '1', 'VisibleRpt' => '1', 'CountStat' => '0', 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['EGFR'] = $this->db->insertID(); - $data = ['TestSiteID' => $tIDs['EGFR'], 'DisciplineID' => '2', 'DepartmentID' => '2', 'FormulaInput' => 'CREA,AGE,GENDER', 'FormulaCode' => 'CKD_EPI(CREA,AGE,GENDER)', 'ResultType' => 'NMRIC', 'RefType' => 'RANGE', 'Unit1' => 'mL/min/1.73m2', 'Factor' => '', 'Unit2' => '', 'Decimal' => '0', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['EGFR'], 'DisciplineID' => '2', 'DepartmentID' => '2', 'FormulaInput' => 'CREA,AGE,GENDER', 'FormulaCode' => 'CKD_EPI(CREA,AGE,GENDER)', 'RefType' => 'RANGE', 'Unit1' => 'mL/min/1.73m2', 'Factor' => '', 'Unit2' => '', 'Decimal' => '0', 'CreateDate' => "$now"]; $this->db->table('testdefcal')->insert($data); $data = ['SiteID' => '1', 'TestSiteCode' => 'LDLCALC', 'TestSiteName' => 'LDL Cholesterol (Calculated)', 'TestType' => 'CALC', 'Description' => 'Friedewald formula: TC - HDL - (TG/5)', 'SeqScr' => '21', 'SeqRpt' => '21', 'IndentLeft' => '1', 'VisibleScr' => '1', 'VisibleRpt' => '1', 'CountStat' => '0', 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['LDLCALC'] = $this->db->insertID(); - $data = ['TestSiteID' => $tIDs['LDLCALC'], 'DisciplineID' => '2', 'DepartmentID' => '2', 'FormulaInput' => 'CHOL,HDL,TG', 'FormulaCode' => 'CHOL - HDL - (TG/5)', 'ResultType' => 'NMRIC', 'RefType' => 'RANGE', 'Unit1' => 'mg/dL', 'Factor' => '', 'Unit2' => '', 'Decimal' => '0', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['LDLCALC'], 'DisciplineID' => '2', 'DepartmentID' => '2', 'FormulaInput' => 'CHOL,HDL,TG', 'FormulaCode' => 'CHOL - HDL - (TG/5)', 'RefType' => 'RANGE', 'Unit1' => 'mg/dL', 'Factor' => '', 'Unit2' => '', 'Decimal' => '0', 'CreateDate' => "$now"]; $this->db->table('testdefcal')->insert($data); // ========================================