Add insurance coverage limit verification while accept health care sheet
This commit is contained in:
parent
6af9b094e7
commit
c5452710b4
|
@ -1433,9 +1433,16 @@ class HealthCareSheetController extends Controller
|
|||
try {
|
||||
DB::beginTransaction();
|
||||
if ($action == 'ACCEPT') {
|
||||
$nhConfig = NhNetworksConfig::where('network_id', $sheet->insurance->network_id)->first();
|
||||
if (!isset($nhConfig)) {
|
||||
return $this->errorResponse(trans('errors.nano_health_not_activated'));
|
||||
}
|
||||
// Verification de la limite de couverture
|
||||
$this->verifyInsuranceCoverageAmount($nhConfig, $sheet->insurance, $sheet, $sheet->beneficiary);
|
||||
|
||||
$sheet->state = InsuranceSubscriptionState::ACCEPTED;
|
||||
$message = trans('messages.care_sheet_accepted');
|
||||
// Mettre à jour lq couverture d'assurance de chaque assuré
|
||||
// Mettre à jour la couverture d'assurance de chaque assuré
|
||||
$sheet->insurance_consumed_at = $datetime;
|
||||
if (!empty($sheet->beneficiary)) {
|
||||
$sheet->beneficiary->insurance_coverage_amount += $sheet->insurance_amount;
|
||||
|
@ -1457,6 +1464,8 @@ class HealthCareSheetController extends Controller
|
|||
DB::commit();
|
||||
return $this->successResponse($message);
|
||||
|
||||
} catch (AppException $e) {
|
||||
return $this->errorResponse($e->getMessage(), $e->getCode());
|
||||
} catch (Throwable $e) {
|
||||
Log::error($e->getMessage() . '\n' . $e->getTraceAsString());
|
||||
DB::rollBack();
|
||||
|
|
Loading…
Reference in New Issue