Skip to content

Commit

Permalink
updated sync file
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanwilliammd committed Oct 27, 2023
1 parent 09585e9 commit bc970c5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 21 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"illuminate/config": "^10.25",
"illuminate/database": "^10.25",
"illuminate/support": "^10.25",
"jeroenzwart/laravel-csv-seeder": "^1.6",
"phpseclib/phpseclib": "^3.0",
"vlucas/phpdotenv": "^5.5"
},
Expand Down
31 changes: 12 additions & 19 deletions database/seeders/Icd10Seeder.php.stub
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
<?php
namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Satusehat\Integration\Models\Icd10;
use JeroenZwart\CsvSeeder\CsvSeeder;
use DB;

class Icd10Seeder extends Seeder
class Icd10Seeder extends CsvSeeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function __construct(){
$this->file = base_path().'/database/seeders/csv/icd10.csv';
$this->tablename = config('satusehatintegration.icd10_table_name');
$this->delimiter = ';';
}

public function run()
{
Icd10::truncate();

$csvFile = fopen(database_path("/seeders/csv/icd10.csv"), "r");

$firstline = true;
while (($data = fgetcsv($csvFile, 2000, ";")) !== FALSE) {
if (!$firstline) {
Icd10::create([
"icd10_code" => $data['0'],
"icd10_en" => $data['1'],
"icd10_id" => $data['2']
]);
}
$firstline = false;
}
// Recommended when importing larger CSVs
DB::disableQueryLog();

fclose($csvFile);
parent::run();
}
}
4 changes: 2 additions & 2 deletions src/Models/Icd10.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
* Satusehat\Integration\Models\Icd10.
*
* @property string $icd10_code
* @property string $icd10_display_en
* @property string $icd10_display_id
* @property string $icd10_en
* @property string $icd10_id
* @property bool $active
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
Expand Down

0 comments on commit bc970c5

Please sign in to comment.