<?php

namespace App\Database\Seeds;

use CodeIgniter\Database\Seeder;
use App\Libraries\ValueSet;

class OrganizationSeeder extends Seeder
{
  public function run()
  {
    $now = date('Y-m-d H:i:s');

    // Organization
    $data = [
      [ '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);

    $data = [
      [ 'SiteID' => 1, 'SiteCode' => 'Q1', 'SiteName' => 'Dummy Site', 'AccountID' => 1, 'Parent' => null, 'CreateDate' => "$now" ],
      [ 'SiteID' => 2, 'SiteCode' => 'X1', 'SiteName' => 'Dummy Child Site', 'AccountID' => 1,  'Parent' => 1, 'CreateDate' => "$now" ],
    ];
    $this->db->table('site')->insertBatch($data);

    $data = [
      ['DisciplineID' => '1', 'DisciplineCode' => 'HEMA', 'DisciplineName' => 'Hematology', 'Parent' => null, 'SeqScr' => 10, 'SeqRpt' => 10, 'CreateDate' => "$now"],
      ['DisciplineID' => '2', 'DisciplineCode' => 'CHEM', 'DisciplineName' => 'Clinical Chemistry', 'Parent' => null, 'SeqScr' => 20, 'SeqRpt' => 20, 'CreateDate' => "$now"],
      ['DisciplineID' => '3', 'DisciplineCode' => 'IMSR', 'DisciplineName' => 'Immunology/Serology', 'Parent' => null, 'SeqScr' => 30, 'SeqRpt' => 30, 'CreateDate' => "$now"],
      ['DisciplineID' => '4', 'DisciplineCode' => 'URIN', 'DisciplineName' => 'Urinalysis', 'Parent' => null, 'SeqScr' => 40, 'SeqRpt' => 40, 'CreateDate' => "$now"],
      ['DisciplineID' => '5', 'DisciplineCode' => 'FECAL', 'DisciplineName' => 'Fecal Analysis', 'Parent' => null, 'SeqScr' => 50, 'SeqRpt' => 50, 'CreateDate' => "$now"],
      ['DisciplineID' => '6', 'DisciplineCode' => 'HC', 'DisciplineName' => 'Pathology/Cytology', 'Parent' => null, 'SeqScr' => 60, 'SeqRpt' => 60, 'CreateDate' => "$now"],
      ['DisciplineID' => '7', 'DisciplineCode' => 'MICRO', 'DisciplineName' => 'Microbiology', 'Parent' => null, 'SeqScr' => 70, 'SeqRpt' => 70, 'CreateDate' => "$now"],
      ['DisciplineID' => '8', 'DisciplineCode' => 'TXC', 'DisciplineName' => 'Toxicology', 'Parent' => null, 'SeqScr' => 80, 'SeqRpt' => 80, 'CreateDate' => "$now"],
      ['DisciplineID' => '9', 'DisciplineCode' => 'LF', 'DisciplineName' => 'Life Sciences', 'Parent' => null, 'SeqScr' => 90, 'SeqRpt' => 90, 'CreateDate' => "$now"],
      ['DisciplineID' => '10', 'DisciplineCode' => 'ND', 'DisciplineName' => 'Non-discipline', 'Parent' => null, 'SeqScr' => 100, 'SeqRpt' => 100, 'CreateDate' => "$now"],
      ['DisciplineID' => '11', 'DisciplineCode' => 'HEMO', 'DisciplineName' => 'Hemostasis', 'Parent' => '1', 'SeqScr' => 15, 'SeqRpt' => 15, 'CreateDate' => "$now"],
      ['DisciplineID' => '12', 'DisciplineCode' => 'BLGLU', 'DisciplineName' => 'Blood Glucose', 'Parent' => '2', 'SeqScr' => 25, 'SeqRpt' => 25, 'CreateDate' => "$now"],
      ['DisciplineID' => '13', 'DisciplineCode' => 'KIDF', 'DisciplineName' => 'Kidney Function', 'Parent' => '2', 'SeqScr' => 26, 'SeqRpt' => 26, 'CreateDate' => "$now"],
    ];
    $this->db->table('discipline')->insertBatch($data);

    $data = [
      ['DepartmentID' => '1', 'DisciplineID' => '1', 'SiteID' => '165', 'DepartmentCode' => 'HRTN', 'DepartmentName' => 'Hematologi Rutin', 'CreateDate' => "$now"],
      ['DepartmentID' => '2', 'DisciplineID' => '1', 'SiteID' => '165', 'DepartmentCode' => 'HKHS', 'DepartmentName' => 'Hematologi Khusus', 'CreateDate' => "$now"],
      ['DepartmentID' => '3', 'DisciplineID' => '2', 'SiteID' => '165', 'DepartmentCode' => 'KK', 'DepartmentName' => 'Kimia Klinik', 'CreateDate' => "$now"],
      ['DepartmentID' => '4', 'DisciplineID' => '3', 'SiteID' => '165', 'DepartmentCode' => 'IMS', 'DepartmentName' => 'Imunologi', 'CreateDate' => "$now"],
      ['DepartmentID' => '5', 'DisciplineID' => '3', 'SiteID' => '165', 'DepartmentCode' => 'SRL', 'DepartmentName' => 'Serologi', 'CreateDate' => "$now"],
      ['DepartmentID' => '6', 'DisciplineID' => '4', 'SiteID' => '165', 'DepartmentCode' => 'UF', 'DepartmentName' => 'Urin', 'CreateDate' => "$now"]
    ];
    $this->db->table('department')->insertBatch($data);

    $data = [
      ['WorkstationID' => '1', 'DepartmentID' => '1', 'WorkstationCode' => 'HAUTO', 'WorkstationName' => 'Hematologi Auto', 'Type' => '0', 'LinkTo' => '', 'isEnable' => '1', 'CreateDate' => "$now"],
      ['WorkstationID' => '2', 'DepartmentID' => '1', 'WorkstationCode' => 'HBACK', 'WorkstationName' => 'Hematologi Backup', 'Type' => '1', 'LinkTo' => '1', 'isEnable' => '1', 'CreateDate' => "$now"],
      ['WorkstationID' => '3', 'DepartmentID' => '3', 'WorkstationCode' => 'CAUTO', 'WorkstationName' => 'Kimia Auto', 'Type' => '0', 'LinkTo' => '', 'isEnable' => '1', 'CreateDate' => "$now"],
      ['WorkstationID' => '4', 'DepartmentID' => '3', 'WorkstationCode' => 'CBACK', 'WorkstationName' => 'Kimia Backup', 'Type' => '1', 'LinkTo' => '3', 'isEnable' => '1', 'CreateDate' => "$now"],
      ['WorkstationID' => '5', 'DepartmentID' => '3', 'WorkstationCode' => 'CMAN', 'WorkstationName' => 'Kimia Manual', 'Type' => '0', 'LinkTo' => '', 'isEnable' => '1', 'CreateDate' => "$now"],
      ['WorkstationID' => '6', 'DepartmentID' => '4', 'WorkstationCode' => 'IAUTO', 'WorkstationName' => 'Imunologi Auto', 'Type' => '0', 'LinkTo' => '', 'isEnable' => '1', 'CreateDate' => "$now"],
      ['WorkstationID' => '7', 'DepartmentID' => '4', 'WorkstationCode' => 'IMAN', 'WorkstationName' => 'Imunologi Manual', 'Type' => '0', 'LinkTo' => '', 'isEnable' => '1', 'CreateDate' => "$now"],
			['WorkstationID' => '8', 'DepartmentID' => '6', 'WorkstationCode' => 'UAUTO', 'WorkstationName' => 'Urin Auto', 'Type' => '0', 'LinkTo' => '', 'isEnable' => '1', 'CreateDate' => "$now"],
      ['WorkstationID' => '9', 'DepartmentID' => '6', 'WorkstationCode' => 'UMAN', 'WorkstationName' => 'Urin Manual', 'Type' => '0', 'LinkTo' => '', 'isEnable' => '1', 'CreateDate' => "$now"],
    ];
    $this->db->table('workstation')->insertBatch($data);

    // Equipment/Instruments for each workstation
    $data = [
      // Hematology Auto (WorkstationID: 1)
      ['EID' => 1, 'IEID' => 'EQ-HEM-001', 'DepartmentID' => '1', 'InstrumentID' => 'SYSMEX_XN1000', 'InstrumentName' => 'Sysmex XN-1000 Hematology Analyzer', 'WorkstationID' => 1, 'isEnable' => 1, 'EquipmentRole' => 'A', 'CreateDate' => "$now"],
      ['EID' => 2, 'IEID' => 'EQ-HEM-002', 'DepartmentID' => '1', 'InstrumentID' => 'SYSMEX_XS1000', 'InstrumentName' => 'Sysmex XS-1000i', 'WorkstationID' => 1, 'isEnable' => 1, 'EquipmentRole' => 'A', 'CreateDate' => "$now"],
      // Hematology Backup (WorkstationID: 2)
      ['EID' => 3, 'IEID' => 'EQ-HEM-003', 'DepartmentID' => '1', 'InstrumentID' => 'SYSMEX_XN550', 'InstrumentName' => 'Sysmex XN-550 Backup', 'WorkstationID' => 2, 'isEnable' => 1, 'EquipmentRole' => 'B', 'CreateDate' => "$now"],
      ['EID' => 4, 'IEID' => 'EQ-HEM-004', 'DepartmentID' => '1', 'InstrumentID' => 'MANUAL_DIFF', 'InstrumentName' => 'Manual Differential Counter', 'WorkstationID' => 2, 'isEnable' => 1, 'EquipmentRole' => 'M', 'CreateDate' => "$now"],
      // Chemistry Auto (WorkstationID: 3)
      ['EID' => 5, 'IEID' => 'EQ-CHEM-001', 'DepartmentID' => '3', 'InstrumentID' => 'COBAS_C501', 'InstrumentName' => 'Roche Cobas C501 Chemistry Analyzer', 'WorkstationID' => 3, 'isEnable' => 1, 'EquipmentRole' => 'A', 'CreateDate' => "$now"],
      ['EID' => 6, 'IEID' => 'EQ-CHEM-002', 'DepartmentID' => '3', 'InstrumentID' => 'COBAS_C311', 'InstrumentName' => 'Roche Cobas C311', 'WorkstationID' => 3, 'isEnable' => 1, 'EquipmentRole' => 'A', 'CreateDate' => "$now"],
      // Chemistry Backup (WorkstationID: 4)
      ['EID' => 7, 'IEID' => 'EQ-CHEM-003', 'DepartmentID' => '3', 'InstrumentID' => 'COBAS_E411', 'InstrumentName' => 'Roche Cobas E411 Immunoassay', 'WorkstationID' => 4, 'isEnable' => 1, 'EquipmentRole' => 'B', 'CreateDate' => "$now"],
      // Chemistry Manual (WorkstationID: 5)
      ['EID' => 8, 'IEID' => 'EQ-CHEM-004', 'DepartmentID' => '3', 'InstrumentID' => 'SPEC_MANUAL', 'InstrumentName' => 'Spectrophotometer Manual', 'WorkstationID' => 5, 'isEnable' => 1, 'EquipmentRole' => 'M', 'CreateDate' => "$now"],
      // Immunology Auto (WorkstationID: 6)
      ['EID' => 9, 'IEID' => 'EQ-IMM-001', 'DepartmentID' => '4', 'InstrumentID' => 'ARCH_I2000', 'InstrumentName' => 'Architect i2000 Immunoassay', 'WorkstationID' => 6, 'isEnable' => 1, 'EquipmentRole' => 'A', 'CreateDate' => "$now"],
      ['EID' => 10, 'IEID' => 'EQ-IMM-002', 'DepartmentID' => '4', 'InstrumentID' => 'COBAS_E601', 'InstrumentName' => 'Roche Cobas E601', 'WorkstationID' => 6, 'isEnable' => 1, 'EquipmentRole' => 'A', 'CreateDate' => "$now"],
      // Immunology Manual (WorkstationID: 7)
      ['EID' => 11, 'IEID' => 'EQ-IMM-003', 'DepartmentID' => '4', 'InstrumentID' => 'ELISA_READER', 'InstrumentName' => 'ELISA Plate Reader', 'WorkstationID' => 7, 'isEnable' => 1, 'EquipmentRole' => 'M', 'CreateDate' => "$now"],
      ['EID' => 12, 'IEID' => 'EQ-IMM-004', 'DepartmentID' => '4', 'InstrumentID' => 'FLUORIMETER', 'InstrumentName' => 'Fluorimeter Manual', 'WorkstationID' => 7, 'isEnable' => 1, 'EquipmentRole' => 'M', 'CreateDate' => "$now"],
      // Urinalysis Auto (WorkstationID: 8)
      ['EID' => 13, 'IEID' => 'EQ-URI-001', 'DepartmentID' => '6', 'InstrumentID' => 'URISYS_1100', 'InstrumentName' => 'Urisys 1100 Urine Analyzer', 'WorkstationID' => 8, 'isEnable' => 1, 'EquipmentRole' => 'A', 'CreateDate' => "$now"],
      ['EID' => 14, 'IEID' => 'EQ-URI-002', 'DepartmentID' => '6', 'InstrumentID' => 'CLINITEK', 'InstrumentName' => 'Clinitek Urine Chemistry', 'WorkstationID' => 8, 'isEnable' => 1, 'EquipmentRole' => 'A', 'CreateDate' => "$now"],
      // Urinalysis Manual (WorkstationID: 9)
      ['EID' => 15, 'IEID' => 'EQ-URI-003', 'DepartmentID' => '6', 'InstrumentID' => 'MICROSCOPE', 'InstrumentName' => 'Microscope Manual', 'WorkstationID' => 9, 'isEnable' => 1, 'EquipmentRole' => 'M', 'CreateDate' => "$now"],
      ['EID' => 16, 'IEID' => 'EQ-URI-004', 'DepartmentID' => '6', 'InstrumentID' => 'CENTRIFUGE', 'InstrumentName' => 'Centrifuge Urine', 'WorkstationID' => 9, 'isEnable' => 1, 'EquipmentRole' => 'M', 'CreateDate' => "$now"],
      // Additional equipment (disabled)
      ['EID' => 17, 'IEID' => 'EQ-HEM-005', 'DepartmentID' => '1', 'InstrumentID' => 'OLD_ANALYZER', 'InstrumentName' => 'Old Hematology Analyzer', 'WorkstationID' => 1, 'isEnable' => 0, 'EquipmentRole' => 'B', 'CreateDate' => "$now"],
      ['EID' => 18, 'IEID' => 'EQ-CHEM-005', 'DepartmentID' => '3', 'InstrumentID' => 'MAINTENANCE', 'InstrumentName' => 'Chemistry Analyzer Under Maintenance', 'WorkstationID' => 3, 'isEnable' => 0, 'EquipmentRole' => 'B', 'CreateDate' => "$now"],
    ];
    $this->db->table('equipmentlist')->insertBatch($data);
  }
}
