56 lines
1.4 KiB
PHP
56 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Modules\Internal\Services;
|
|
|
|
use App\Exceptions\ImportRowException;
|
|
use App\Models\Benefit;
|
|
use App\Models\Corporate;
|
|
use App\Models\Icd;
|
|
use App\Models\Plan;
|
|
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
|
|
|
class IcdService
|
|
{
|
|
protected function validateDiagnosisExclusionRow($row)
|
|
{
|
|
if (empty($row['code'])) {
|
|
throw new ImportRowException(__('code.REQUIRED'), 0, null, $row);
|
|
}
|
|
if (empty($row['description_en'])) {
|
|
throw new ImportRowException(__('name.REQUIRED'), 0, null, $row);
|
|
}
|
|
}
|
|
|
|
public function handleIcdRow($row)
|
|
{
|
|
try {
|
|
$this->validateDiagnosisExclusionRow($row);
|
|
$icd = Icd::updateOrCreate([
|
|
'code' => $row['code']
|
|
], [
|
|
"code" => $row['code'],
|
|
"parent_code" => $row['parent_code'] ?? null,
|
|
"rev" => $row['reff_exc'],
|
|
"name" => $row['description_en'],
|
|
"version" => $row["version"] ?? null,
|
|
"active" => $row["active"] ?? 0
|
|
]);
|
|
|
|
return true;
|
|
} catch (\Exception $e) {
|
|
throw $e;
|
|
}
|
|
}
|
|
|
|
public $listing_doc_headers = [
|
|
"Rev",
|
|
"Version",
|
|
"Code",
|
|
"Parent Code",
|
|
"Name",
|
|
"Description",
|
|
"Status",
|
|
"Type"
|
|
];
|
|
}
|