Update exclusion corporate setting

This commit is contained in:
2023-09-21 18:06:34 +07:00
parent ae1b213ff0
commit e8c2396442
11 changed files with 321 additions and 6 deletions

View File

@@ -6,6 +6,7 @@ use App\Exceptions\ImportRowException;
use App\Models\Benefit;
use App\Models\Corporate;
use App\Models\Icd;
use App\Models\Exclusion;
use App\Models\Plan;
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
@@ -87,7 +88,8 @@ class ExclusionService
$exclusion = $icd->exclusions()->create([
'corporate_id' => $corporate->id,
'service_code' => 'OP',
'type' => 'diagnosis'
'type' => 'diagnosis',
'active' => 1
]);
if (!empty($excl_array[1])) { //msc
@@ -141,6 +143,22 @@ class ExclusionService
]);
});
}
} else if (!$excl_array[0]){
$icd = Icd::where(['code' => $row['code']])->first();
if (!$icd) {
throw new ImportRowException(__('icd.NOT_FOUND'), 0, NULL, $row);
}
// Cari entitas Exclusion yang sesuai dengan kriteria tertentu
$exclusion = Exclusion::where([
'corporate_id' => $corporate->id,
'exclusionable_id' => $icd->id,
])->first();
// Jika entitas ditemukan, perbarui nilai 'active' menjadi 0
if ($exclusion) {
$exclusion->update(['active' => 0]);
}
}
}