Add Diagnosis Exclusion

This commit is contained in:
2022-08-03 11:24:09 +07:00
parent 8c78fd3d84
commit f72a641f56
27 changed files with 20708 additions and 3 deletions

View File

@@ -14,7 +14,7 @@ return new class extends Migration
public function up()
{
Schema::create('import_logs', function (Blueprint $table) {
$table->uuid();
$table->uuid()->primary();
$table->morphs('importable');
$table->string('type')->nullable();
$table->string('file_path')->nullable();

View File

@@ -0,0 +1,43 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('icd', function (Blueprint $table) {
$table->id();
$table->string('rev');
$table->string('version')->nullable();
$table->string('code');
$table->string('name');
$table->text('description')->nullable();
$table->string('parent_code')->nullable()->index();
$table->timestamps();
$table->softDeletes();
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->unsignedBigInteger('deleted_by')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('icd_x');
}
};

View File

@@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('exclusions', function (Blueprint $table) {
$table->id();
$table->foreignId('corporate_id');
$table->string('service_code')->index();
$table->string('type');
$table->morphs('exclusionable');
$table->timestamps();
$table->softDeletes();
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->unsignedBigInteger('deleted_by')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('exclusions');
}
};

View File

@@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('exclusion_rules', function (Blueprint $table) {
$table->id();
$table->foreignId('exclusion_id');
$table->string('name');
$table->text('values');
$table->timestamps();
$table->softDeletes();
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->unsignedBigInteger('deleted_by')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('exclusion_rules');
}
};

View File

@@ -0,0 +1,64 @@
<?php
namespace Database\Seeders;
use App\Models\Icd;
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class IcdSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$file_path = resource_path('files/ICD-X-Halodoc.csv');
$reader = ReaderEntityFactory::createReaderFromFile($file_path);
$reader->open($file_path);
Icd::truncate();
$chunks = [];
$time = now();
foreach ($reader->getSheetIterator() as $sheet) {
foreach ($sheet->getRowIterator() as $index => $row) {
if ($index != 1) {
$row_data = [
'rev' => 'X',
'version' => 'Halodoc',
'created_at' => $time,
];
foreach ($row->getCells() as $cell_index => $cell) {
if ($cell_index == 0) {
$row_data['code'] = $cell->getValue();
} else if ($cell_index == 1) {
$row_data['name'] = $cell->getValue();
}
}
$exploded_code = explode('.', $row_data['code']);
if (count($exploded_code) > 1) {
$row_data['parent_code'] = $exploded_code[0];
} else {
$row_data['parent_code'] = NULL;
}
$chunks[] = $row_data;
}
if ($chunks && count($chunks) == 1000) {
Icd::insert($chunks);
$chunks = [];
}
}
}
if ($chunks && count($chunks) > 0) {
Icd::insert($chunks);
$chunks = [];
}
}
}