update exclusion

This commit is contained in:
2023-09-15 11:20:27 +07:00
parent 9f3b59a634
commit 4a155b2b70

View File

@@ -21,15 +21,13 @@ class ExclusionService
public function handleDiagnosisExclusionRow(Corporate $corporate, $row) public function handleDiagnosisExclusionRow(Corporate $corporate, $row)
{ {
try { try {
$this->validateDiagnosisExclusionRow($row);
if (!empty($row['ip_exclusion'])) { if (!empty($row['ip_exclusion'])) {
$excl_array = explode('|', $row['ip_exclusion']); $excl_array = explode('|', $row['ip_exclusion']);
if ($excl_array[0] == '3') { if ($excl_array[0] == '3') {
$icd = Icd::where('code', $row['code'])->first(); $icd = Icd::where('code', $row['code'])->first();
$exclusion = $icd->exclusions()->create([ $exclusion = $icd->exclusions()->create([
'corporate_id' => $corporate->id, 'corporate_id' => $corporate->id,
'service_code' => 'OP', 'service_code' => 'IP',
'type' => 'diagnosis' 'type' => 'diagnosis'
]); ]);
@@ -71,6 +69,7 @@ class ExclusionService
]); ]);
} }
if (!empty($excl_array[5])) { //plans if (!empty($excl_array[5])) { //plans
$exclusion->rules()->create([ $exclusion->rules()->create([
'name' => 'plan', 'name' => 'plan',
'values' => $excl_array[5] 'values' => $excl_array[5]
@@ -130,10 +129,18 @@ class ExclusionService
]); ]);
} }
if (!empty($excl_array[5])) { //plans if (!empty($excl_array[5])) { //plans
$exclusion->rules()->create([ $codePlan = explode(',', $excl_array[5]);
'name' => 'plan', collect($codePlan)->each(function ($codePlan) use ($corporate, $exclusion) {
'values' => $excl_array[5] $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(); $icd = Icd::where('code', $row['code'])->first();
$exclusion = $icd->exclusions()->create([ $exclusion = $icd->exclusions()->create([
'corporate_id' => $corporate->id, 'corporate_id' => $corporate->id,
'service_code' => 'OP', 'service_code' => 'DE',
'type' => 'diagnosis' 'type' => 'diagnosis'
]); ]);
@@ -196,7 +203,6 @@ class ExclusionService
if (!empty($row['ma_exclusion'])) { if (!empty($row['ma_exclusion'])) {
$excl_array = explode('|', $row['ma_exclusion']); $excl_array = explode('|', $row['ma_exclusion']);
dd($excl_array);
if ($excl_array[0]) { if ($excl_array[0]) {
} }
} }