add exclusion diagnosis done
This commit is contained in:
@@ -252,11 +252,22 @@ class CorporateController extends Controller
|
||||
public function show($id)
|
||||
{
|
||||
$corporate = Corporate::query()
|
||||
->with(['currentPolicy'])
|
||||
->with(['currentPolicy', 'plans'])
|
||||
->withCount('corporatePlans')
|
||||
->withCount('employees')
|
||||
// ->withCount('employees.claims')
|
||||
->findOrFail($id);
|
||||
$plans = $corporate['plans']->map(function ($plan) {
|
||||
return [
|
||||
'id' => $plan['id'],
|
||||
'code' => $plan['code'],
|
||||
'corporate_id' => $plan['corporate_id'],
|
||||
'corporate_plan_id' => $plan['corporate_plan_id'],
|
||||
];
|
||||
});
|
||||
|
||||
unset($corporate['plans']);
|
||||
$corporate['plans'] = $plans;
|
||||
|
||||
return response()->json($corporate);
|
||||
}
|
||||
|
||||
@@ -117,9 +117,7 @@ class CorporateServiceController extends Controller
|
||||
->where('service_code', $service_code)
|
||||
->with([
|
||||
'configs', 'service',
|
||||
'specialities' => function ($speciality) {
|
||||
$speciality->where('active', true);
|
||||
},
|
||||
'specialities',
|
||||
'specialities.speciality',
|
||||
'specialities.exclusions.rules'
|
||||
])
|
||||
@@ -206,16 +204,25 @@ class CorporateServiceController extends Controller
|
||||
->with('exclusions.rules')
|
||||
->first();
|
||||
|
||||
if (empty($corporateServiceSpeciality)) {
|
||||
$corporateServiceSpeciality = CorporateServiceSpeciality::create([
|
||||
'corporate_service_id' => $corporateService->id,
|
||||
'speciality_id' => $request->speciality_id,
|
||||
'active' => false,
|
||||
]);
|
||||
|
||||
$corporateServiceSpeciality->exclusions()->updateOrCreate([
|
||||
'corporate_id' => $corporate_id,
|
||||
'service_code' => $service_code,
|
||||
], [
|
||||
'corporate_id' => $corporate_id,
|
||||
'service_code' => $service_code,
|
||||
'type' => 'speciality',
|
||||
]);
|
||||
}
|
||||
|
||||
$exclusion = $corporateServiceSpeciality->exclusions()->where('corporate_id', $corporate_id)->where('service_code', $service_code)->first();
|
||||
// dd($exclusion);
|
||||
// ->updateOrCreate([
|
||||
// 'corporate_id' => $corporate_id,
|
||||
// 'service_code' => $service_code,
|
||||
// ], [
|
||||
// 'corporate_id' => $corporate_id,
|
||||
// 'service_code' => $service_code,
|
||||
// 'type' => 'speciality',
|
||||
// ]);
|
||||
|
||||
|
||||
if ($request->type == 'msc') {
|
||||
|
||||
@@ -372,7 +379,36 @@ class CorporateServiceController extends Controller
|
||||
'name' => 'plan',
|
||||
], [
|
||||
'name' => 'plan',
|
||||
'values' => $plan,
|
||||
'values' => $plan ?? '',
|
||||
]);
|
||||
}
|
||||
|
||||
if ($request->type == "one_row") {
|
||||
$data = $request->one_row;
|
||||
|
||||
$exclusion->rules()->updateOrCreate([
|
||||
'exclusion_id' => $exclusion->id,
|
||||
'name' => 'min_age',
|
||||
], [
|
||||
'name' => 'min_age',
|
||||
'values' => $data['min_age'] ?? '',
|
||||
]);
|
||||
|
||||
|
||||
$exclusion->rules()->updateOrCreate([
|
||||
'exclusion_id' => $exclusion->id,
|
||||
'name' => 'max_age',
|
||||
], [
|
||||
'name' => 'max_age',
|
||||
'values' => $data['max_age'] ?? '',
|
||||
]);
|
||||
|
||||
$exclusion->rules()->updateOrCreate([
|
||||
'exclusion_id' => $exclusion->id,
|
||||
'name' => 'plan',
|
||||
], [
|
||||
'name' => 'plan',
|
||||
'values' => $data['plan'] ?? '',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -389,9 +425,7 @@ class CorporateServiceController extends Controller
|
||||
->where('service_code', $service_code)
|
||||
->with([
|
||||
'configs', 'service',
|
||||
'specialities' => function ($speciality) {
|
||||
$speciality->where('active', true);
|
||||
},
|
||||
'specialities',
|
||||
'specialities.speciality',
|
||||
'specialities.exclusions.rules'
|
||||
])
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Modules\Internal\Http\Controllers\Api;
|
||||
use App\Exceptions\ImportRowException;
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Corporate;
|
||||
use App\Models\CorporateService;
|
||||
use App\Models\Exclusion;
|
||||
use App\Models\Icd;
|
||||
use App\Models\ImportLog;
|
||||
@@ -26,10 +27,11 @@ class DiagnosisExclusionController extends Controller
|
||||
public function index(Request $request, $corporate_id)
|
||||
{
|
||||
$exclusions = Exclusion::query()
|
||||
->where('corporate_id', $corporate_id)
|
||||
->with(['exclusionable', 'rules'])
|
||||
->filter($request->toArray())
|
||||
->paginate();
|
||||
->where('corporate_id', $corporate_id)
|
||||
->where('type', 'diagnosis')
|
||||
->with(['exclusionable', 'rules'])
|
||||
->filter($request->toArray())
|
||||
->paginate();
|
||||
// return $exclusions;
|
||||
return Helper::paginateResources(DiagnosisExclusionResource::collection($exclusions));
|
||||
}
|
||||
@@ -100,10 +102,10 @@ class DiagnosisExclusionController extends Controller
|
||||
'file' => 'required|file|mimes:xls,xlsx,csv,txt',
|
||||
]);
|
||||
// dd($request->toArray());
|
||||
$file_name = now()->getPreciseTimestamp(3).'-'.$request->file('file')->getClientOriginalName();
|
||||
$file_name = now()->getPreciseTimestamp(3) . '-' . $request->file('file')->getClientOriginalName();
|
||||
$file = $request->file('file')->storeAs('temp', $file_name);
|
||||
$corporate = Corporate::findOrFail($corporate_id);
|
||||
|
||||
|
||||
// $importLog = $corporate->importLogs()->create([
|
||||
// 'type' => 'diagnosis-exclusions',
|
||||
// 'file_path' => $file,
|
||||
@@ -112,8 +114,8 @@ class DiagnosisExclusionController extends Controller
|
||||
// ]);
|
||||
|
||||
$import = new ImportService();
|
||||
$import->read(Storage::path('temp/'.$file_name));
|
||||
$import->write(Storage::disk('public')->path('temp/result-'.$file_name), 'xsls');
|
||||
$import->read(Storage::path('temp/' . $file_name));
|
||||
$import->write(Storage::disk('public')->path('temp/result-' . $file_name), 'xsls');
|
||||
|
||||
foreach ($import->sheetsIterator() as $sheetIndex => $sheet) {
|
||||
$doc_headers_indexes = [];
|
||||
@@ -121,8 +123,8 @@ class DiagnosisExclusionController extends Controller
|
||||
if ($index == 1) { // First Row Must be Header
|
||||
foreach ($row->getCells() as $index => $cell) {
|
||||
$title = $cell->getValue();
|
||||
$title = preg_replace( "/\r|\n/", " ", $title );
|
||||
$title = preg_replace('/\xc2\xa0/', " ", $title );
|
||||
$title = preg_replace("/\r|\n/", " ", $title);
|
||||
$title = preg_replace('/\xc2\xa0/', " ", $title);
|
||||
$title = rtrim($title);
|
||||
$title = ltrim($title);
|
||||
$doc_headers_indexes[$index] = $title;
|
||||
@@ -148,12 +150,12 @@ class DiagnosisExclusionController extends Controller
|
||||
9 => 'keterangan',
|
||||
10 => 'maternity_waiting'
|
||||
];
|
||||
|
||||
|
||||
foreach ($row->getCells() as $header_index => $cell) {
|
||||
if (isset($row_map[$header_index])) {
|
||||
$value = $cell->getValue();
|
||||
$value = preg_replace( "/\r|\n/", " ", $value );
|
||||
$value = preg_replace('/\xc2\xa0/', " ", $value );
|
||||
$value = preg_replace("/\r|\n/", " ", $value);
|
||||
$value = preg_replace('/\xc2\xa0/', " ", $value);
|
||||
$value = rtrim($value);
|
||||
$value = ltrim($value);
|
||||
$row_data[$row_map[$header_index]] = $cell->getValue();
|
||||
@@ -171,7 +173,8 @@ class DiagnosisExclusionController extends Controller
|
||||
empty($row_data['sp_exclusion']) &&
|
||||
empty($row_data['pre_exis_exclusion']) &&
|
||||
empty($row_data['op_de_exclusion']) &&
|
||||
empty($row_data['maternity_waiting'])) {
|
||||
empty($row_data['maternity_waiting'])
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -184,7 +187,6 @@ class DiagnosisExclusionController extends Controller
|
||||
'Ingest Code' => 200,
|
||||
'Ingest Note' => 'Success',
|
||||
]), $sheet->getName());
|
||||
|
||||
} catch (ImportRowException $e) {
|
||||
// Write Data Validation Error to File
|
||||
$import->addArrayToRow(array_merge($row_data, [
|
||||
@@ -205,7 +207,7 @@ class DiagnosisExclusionController extends Controller
|
||||
break; // Only Read First Row
|
||||
}
|
||||
$import->reader->close();
|
||||
Storage::delete('temp/'.$file_name);
|
||||
Storage::delete('temp/' . $file_name);
|
||||
$import->writer->close();
|
||||
|
||||
return [
|
||||
@@ -213,9 +215,102 @@ class DiagnosisExclusionController extends Controller
|
||||
// 'total_failed_row' => count($failed_plan_data),
|
||||
// 'failed_row' => $failed_plan_data,
|
||||
'result_file' => [
|
||||
'url' => Storage::disk('public')->url('temp/result-'.$file_name),
|
||||
'name' => 'result-'.$file_name,
|
||||
'url' => Storage::disk('public')->url('temp/result-' . $file_name),
|
||||
'name' => 'result-' . $file_name,
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function storeExclusion(Request $request, $corporate_id)
|
||||
{
|
||||
$exclusion = Exclusion::where('corporate_id', $corporate_id)
|
||||
->where('id', $request->icd_id)
|
||||
->where('type', 'diagnosis')
|
||||
->first();
|
||||
|
||||
|
||||
if ($request->type == "one_row") {
|
||||
$data = $request->one_row;
|
||||
|
||||
foreach ($data['msc'] as $key => $value) {
|
||||
if ($key == 'm' && $value == "1") {
|
||||
$msc[] = $key;
|
||||
} elseif ($key == 's' && $value == "1") {
|
||||
$msc[] = $key;
|
||||
} elseif ($key == 'c' && $value == "1") {
|
||||
$msc[] = $key;
|
||||
} else {
|
||||
$msc[] = "";
|
||||
}
|
||||
}
|
||||
|
||||
$msc = implode(",", $msc);
|
||||
$msc = trim($msc, ",");
|
||||
$msc = str_replace(",,", ",", $msc);
|
||||
|
||||
foreach ($data['gender'] as $key => $value) {
|
||||
if ($key == 'male' && $value == "1") {
|
||||
$gender[] = $key;
|
||||
} elseif ($key == 'female' && $value == "1") {
|
||||
$gender[] = $key;
|
||||
} else {
|
||||
$gender[] = "";
|
||||
}
|
||||
}
|
||||
|
||||
$gender = implode(",", $gender);
|
||||
$gender = trim($gender, ",");
|
||||
|
||||
|
||||
$exclusion->rules()->updateOrCreate([
|
||||
'exclusion_id' => $exclusion->id,
|
||||
'name' => 'msc',
|
||||
], [
|
||||
'name' => 'msc',
|
||||
'values' => $msc ?? '',
|
||||
]);
|
||||
|
||||
$exclusion->rules()->updateOrCreate([
|
||||
'exclusion_id' => $exclusion->id,
|
||||
'name' => 'gender',
|
||||
], [
|
||||
'name' => 'gender',
|
||||
'values' => $gender ?? '',
|
||||
]);
|
||||
|
||||
$exclusion->rules()->updateOrCreate([
|
||||
'exclusion_id' => $exclusion->id,
|
||||
'name' => 'min_age',
|
||||
], [
|
||||
'name' => 'min_age',
|
||||
'values' => $data['min_age'] ?? '',
|
||||
]);
|
||||
|
||||
|
||||
$exclusion->rules()->updateOrCreate([
|
||||
'exclusion_id' => $exclusion->id,
|
||||
'name' => 'max_age',
|
||||
], [
|
||||
'name' => 'max_age',
|
||||
'values' => $data['max_age'] ?? '',
|
||||
]);
|
||||
|
||||
$exclusion->rules()->updateOrCreate([
|
||||
'exclusion_id' => $exclusion->id,
|
||||
'name' => 'plan',
|
||||
], [
|
||||
'name' => 'plan',
|
||||
'values' => $data['plan'] ?? '',
|
||||
]);
|
||||
}
|
||||
|
||||
$exclusions = Exclusion::query()
|
||||
->where('corporate_id', $corporate_id)
|
||||
->where('type', 'diagnosis')
|
||||
->with(['exclusionable', 'rules'])
|
||||
->filter($request->toArray())
|
||||
->paginate();
|
||||
// return $exclusions;
|
||||
return Helper::paginateResources(DiagnosisExclusionResource::collection($exclusions));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user