diff --git a/Modules/Internal/Services/ExclusionService.php b/Modules/Internal/Services/ExclusionService.php index e0f875d4..cd6e4782 100644 --- a/Modules/Internal/Services/ExclusionService.php +++ b/Modules/Internal/Services/ExclusionService.php @@ -21,15 +21,13 @@ class ExclusionService 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', + 'service_code' => 'IP', 'type' => 'diagnosis' ]); @@ -71,6 +69,7 @@ class ExclusionService ]); } if (!empty($excl_array[5])) { //plans + $exclusion->rules()->create([ 'name' => 'plan', 'values' => $excl_array[5] @@ -130,10 +129,18 @@ class ExclusionService ]); } if (!empty($excl_array[5])) { //plans - $exclusion->rules()->create([ - 'name' => 'plan', - 'values' => $excl_array[5] - ]); + $codePlan = explode(',', $excl_array[5]); + collect($codePlan)->each(function ($codePlan) use ($corporate, $exclusion) { + $codePlan = Plan::where(['code' => $codePlan, 'corporate_id' => $corporate->id])->first(); + if (!$codePlan) { + throw new ImportRowException(__('codePlan.NOT_FOUND'), 0, NULL, $codePlan); + } + + $exclusion->rules()->create([ + 'name' => 'plan', + 'values' => $codePlan + ]); + }); } } } @@ -144,7 +151,7 @@ class ExclusionService $icd = Icd::where('code', $row['code'])->first(); $exclusion = $icd->exclusions()->create([ 'corporate_id' => $corporate->id, - 'service_code' => 'OP', + 'service_code' => 'DE', 'type' => 'diagnosis' ]); @@ -196,7 +203,6 @@ class ExclusionService if (!empty($row['ma_exclusion'])) { $excl_array = explode('|', $row['ma_exclusion']); - dd($excl_array); if ($excl_array[0]) { } }