221 lines
8.4 KiB
PHP
221 lines
8.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 ExclusionService
|
|
{
|
|
protected function validateDiagnosisExclusionRow($row)
|
|
{
|
|
// if (empty($row['service_code'])) {
|
|
// throw new ImportRowException(__('plan.RECORD_TYPE_REQUIRED'), 0, null, $row);
|
|
// }
|
|
}
|
|
|
|
public function handleDiagnosisExclusionRow(Corporate $corporate, $row)
|
|
{
|
|
try {
|
|
$this->validateDiagnosisExclusionRow($row);
|
|
|
|
if (!empty($row['ip_exclusion'])) {
|
|
$excl_array = explode('|', $row['ip_exclusion']);
|
|
if ($excl_array[0] == '3') {
|
|
$icd = Icd::where('code', $row['code'])->first();
|
|
$exclusion = $icd->exclusions()->create([
|
|
'corporate_id' => $corporate->id,
|
|
'service_code' => 'OP',
|
|
'type' => 'diagnosis'
|
|
]);
|
|
|
|
if (!empty($excl_array[1])) { //msc
|
|
$msc = explode(',', $excl_array[1]);
|
|
collect($msc)->each(function($m) use ($exclusion) {
|
|
$exclusion->rules()->create([
|
|
'name' => 'msc',
|
|
'values' => $m
|
|
]);
|
|
});
|
|
}
|
|
if (!empty($excl_array[2])) { //genders
|
|
$genders = explode(',', $excl_array[2]);
|
|
collect($genders)->each(function($gender) use ($exclusion) {
|
|
$exclusion->rules()->create([
|
|
'name' => 'gender',
|
|
'values' => $gender
|
|
]);
|
|
});
|
|
}
|
|
if (!empty($excl_array[3])) { //min_age
|
|
$exclusion->rules()->create([
|
|
'name' => 'min_age',
|
|
'values' => $excl_array[3]
|
|
]);
|
|
}
|
|
if (!empty($excl_array[4])) { //max_age
|
|
$exclusion->rules()->create([
|
|
'name' => 'max_age',
|
|
'values' => $excl_array[4]
|
|
]);
|
|
}
|
|
if (!empty($excl_array[5])) { //plans
|
|
$exclusion->rules()->create([
|
|
'name' => 'plan',
|
|
'values' => $excl_array[5]
|
|
]);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!empty($row['op_exclusion'])) {
|
|
$excl_array = explode('|', $row['op_exclusion']);
|
|
if ($excl_array[0] == '3') {
|
|
$icd = Icd::where('code', $row['code'])->first();
|
|
if (!$icd) {
|
|
throw new ImportRowException(__('icd.NOT_FOUND'), 0, NULL, $row);
|
|
}
|
|
$exclusion = $icd->exclusions()->create([
|
|
'corporate_id' => $corporate->id,
|
|
'service_code' => 'OP',
|
|
'type' => 'diagnosis'
|
|
]);
|
|
|
|
if (!empty($excl_array[1])) { //msc
|
|
$msc = explode(',', $excl_array[1]);
|
|
collect($msc)->each(function($m) use ($exclusion) {
|
|
$exclusion->rules()->create([
|
|
'name' => 'msc',
|
|
'values' => $m
|
|
]);
|
|
});
|
|
}
|
|
if (!empty($excl_array[2])) { //genders
|
|
$genders = explode(',', $excl_array[2]);
|
|
collect($genders)->each(function($gender) use ($exclusion) {
|
|
$exclusion->rules()->create([
|
|
'name' => 'gender',
|
|
'values' => $gender
|
|
]);
|
|
});
|
|
}
|
|
if (!empty($excl_array[3])) { //min_age
|
|
$exclusion->rules()->create([
|
|
'name' => 'min_age',
|
|
'values' => $excl_array[3]
|
|
]);
|
|
}
|
|
if (!empty($excl_array[4])) { //max_age
|
|
$exclusion->rules()->create([
|
|
'name' => 'max_age',
|
|
'values' => $excl_array[4]
|
|
]);
|
|
}
|
|
if (!empty($excl_array[5])) { //plans
|
|
$exclusion->rules()->create([
|
|
'name' => 'plan',
|
|
'values' => $excl_array[5]
|
|
]);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!empty($row['de_exclusion'])) {
|
|
$excl_array = explode('|', $row['de_exclusion']);
|
|
if ($excl_array[0] == '3') {
|
|
$icd = Icd::where('code', $row['code'])->first();
|
|
$exclusion = $icd->exclusions()->create([
|
|
'corporate_id' => $corporate->id,
|
|
'service_code' => 'OP',
|
|
'type' => 'diagnosis'
|
|
]);
|
|
|
|
if (!empty($excl_array[1])) { //msc
|
|
$msc = explode(',', $excl_array[1]);
|
|
collect($msc)->each(function($m) use ($exclusion) {
|
|
$exclusion->rules()->create([
|
|
'name' => 'msc',
|
|
'values' => $m
|
|
]);
|
|
});
|
|
}
|
|
if (!empty($excl_array[2])) { //genders
|
|
$genders = explode(',', $excl_array[2]);
|
|
collect($genders)->each(function($gender) use ($exclusion) {
|
|
$exclusion->rules()->create([
|
|
'name' => 'gender',
|
|
'values' => $gender
|
|
]);
|
|
});
|
|
}
|
|
if (!empty($excl_array[3])) { //min_age
|
|
$exclusion->rules()->create([
|
|
'name' => 'min_age',
|
|
'values' => $excl_array[3]
|
|
]);
|
|
}
|
|
if (!empty($excl_array[4])) { //max_age
|
|
$exclusion->rules()->create([
|
|
'name' => 'max_age',
|
|
'values' => $excl_array[4]
|
|
]);
|
|
}
|
|
if (!empty($excl_array[5])) { //plans
|
|
$exclusion->rules()->create([
|
|
'name' => 'plan',
|
|
'values' => $excl_array[5]
|
|
]);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!empty($row['ma_exclusion'])) {
|
|
$excl_array = explode('|', $row['ma_exclusion']);
|
|
dd($excl_array);
|
|
if ($excl_array[0]) {
|
|
|
|
}
|
|
}
|
|
|
|
if (!empty($row['sp_exclusion'])) {
|
|
$excl_array = explode('|', $row['sp_exclusion']);
|
|
dd($excl_array);
|
|
if ($excl_array[0]) {
|
|
|
|
}
|
|
}
|
|
|
|
if (!empty($row['pre_exist_exclusion'])) {
|
|
$excl_array = explode('|', $row['pre_exist_exclusion']);
|
|
dd($excl_array);
|
|
if ($excl_array[0]) {
|
|
|
|
}
|
|
}
|
|
|
|
if (!empty($row['op_de_exclusion'])) {
|
|
$excl_array = explode('|', $row['op_de_exclusion']);
|
|
dd($excl_array);
|
|
if ($excl_array[0]) {
|
|
|
|
}
|
|
}
|
|
|
|
if (!empty($row['maternity_waiting'])) {
|
|
$excl_array = explode('|', $row['maternity_waiting']);
|
|
dd($excl_array);
|
|
if ($excl_array[0]) {
|
|
|
|
}
|
|
}
|
|
return true;
|
|
} catch (\Exception $e) {
|
|
throw $e;
|
|
}
|
|
}
|
|
}
|