Improve some routes

This commit is contained in:
Djery-Tom 2022-02-09 13:35:23 +01:00
parent 5fc64bb218
commit 9da81a6491
5 changed files with 16 additions and 12 deletions

View File

@ -281,7 +281,7 @@ class AuthorizationCareRequestController extends Controller
]); ]);
$requests = NhInfosAuthorizationOfCareRequest::with(['network:id,name'])->where('user_id', $request->input('user_id')) $requests = NhInfosAuthorizationOfCareRequest::with(['network:id,name'])->where('user_id', $request->input('user_id'))
->paginate($request->input('perPage', 10)); ->orderBy('created_at', 'DESC')->paginate($request->input('perPage', 10));
foreach ($requests->items() as $r) { foreach ($requests->items() as $r) {
$r->state = trans('states.' . $r->state); $r->state = trans('states.' . $r->state);
if ($r->to == 'HAVING_RIGHT') { if ($r->to == 'HAVING_RIGHT') {

View File

@ -669,7 +669,6 @@ class HealthCareSheetController extends Controller
'pregnancy_start_at' => (!empty($pregnancy_start_at)) ? $pregnancy_start_at : null, 'pregnancy_start_at' => (!empty($pregnancy_start_at)) ? $pregnancy_start_at : null,
'pregnancy_end_at' => (!empty($pregnancy_end_at)) ? $pregnancy_end_at : null, 'pregnancy_end_at' => (!empty($pregnancy_end_at)) ? $pregnancy_end_at : null,
]); ]);
$healthCareSheet->created_at = $healthCareSheet->udpated_at = $datetime; $healthCareSheet->created_at = $healthCareSheet->udpated_at = $datetime;
$healthCareSheet->save(); $healthCareSheet->save();
@ -681,28 +680,31 @@ class HealthCareSheetController extends Controller
'home_visit_fees' => $fees != 0 ? $fees : null, 'home_visit_fees' => $fees != 0 ? $fees : null,
'moderator_ticket' => $parts->insured_part * ($p['amount'] + $fees), // to calculate, 'moderator_ticket' => $parts->insured_part * ($p['amount'] + $fees), // to calculate,
'insurance_amount' => $parts->insurer_part * ($p['amount'] + $fees), // to calculate, montant de l'assurance 'insurance_amount' => $parts->insurer_part * ($p['amount'] + $fees), // to calculate, montant de l'assurance
'created_at' => $datetime, 'updated_at' => $datetime,
]); ]);
$performance->created_at = $performance->updated_at = $datetime;
$performance->save();
NhHealthCareSheetsPerformance::create([ $nhp = NhHealthCareSheetsPerformance::create([
'sheet_id' => $healthCareSheet->id, 'sheet_id' => $healthCareSheet->id,
'performance_id' => $performance->id, 'performance_id' => $performance->id,
'created_at' => $datetime, 'updated_at' => $datetime,
]); ]);
$nhp->created_at = $nhp->updated_at = $datetime;
$nhp->save();
$this->useAuthorizationRequest($p['act_id'], $insurance->id, $beneficiary_id, $healthCareSheet->id, $datetime); $this->useAuthorizationRequest($p['act_id'], $insurance->id, $beneficiary_id, $healthCareSheet->id, $datetime);
} }
foreach ($request->input('prescriptions', []) as $p) { foreach ($request->input('prescriptions', []) as $p) {
$prescription = NhMedicalPrescription::create(array_merge($p, [ $prescription = NhMedicalPrescription::create($p);
'created_at' => $datetime, 'updated_at' => $datetime, $prescription->created_at = $prescription->updated_at = $datetime;
])); $prescription->save();
NhHealthCareSheetsPrescription::create([ $nhp = NhHealthCareSheetsPrescription::create([
'sheet_id' => $healthCareSheet->id, 'sheet_id' => $healthCareSheet->id,
'prescription_id' => $prescription->id, 'prescription_id' => $prescription->id
'created_at' => $datetime, 'updated_at' => $datetime,
]); ]);
$nhp->created_at = $nhp->updated_at = $datetime;
$nhp->save();
} }
foreach ($request->input('exams', []) as $e) { foreach ($request->input('exams', []) as $e) {

View File

@ -671,7 +671,7 @@ class InsuranceController extends Controller
'bonus_amount' => $this->toMoneyWithCurrencyCode($bonus_amount, $currency), 'total_bonus_amount' => $this->toMoneyWithCurrencyCode($amountToPaid, $currency), 'number_of_beneficiaries' => $insurance->number_of_beneficiaries, 'bonus_amount' => $this->toMoneyWithCurrencyCode($bonus_amount, $currency), 'total_bonus_amount' => $this->toMoneyWithCurrencyCode($amountToPaid, $currency), 'number_of_beneficiaries' => $insurance->number_of_beneficiaries,
'gender' => trans('states.' . $user->identification->gender), 'insurance_name' => $insurance->network->name, 'months' => $insurance->number_of_months]))); 'gender' => trans('states.' . $user->identification->gender), 'insurance_name' => $insurance->network->name, 'months' => $insurance->number_of_months])));
DB::commit(); DB::commit();
return $this->successResponse(trans('messages.insurance_subscription_paid')); return $this->successResponse(trans('messages.insurance_renew_paid'));
} catch (Throwable $e) { } catch (Throwable $e) {
Log::error($e->getMessage() . '\n' . $e->getTraceAsString()); Log::error($e->getMessage() . '\n' . $e->getTraceAsString());
DB::rollBack(); DB::rollBack();

View File

@ -172,4 +172,5 @@ Your insurance has been renewed.
- Number of beneficiaries : :number_of_beneficiaries - Number of beneficiaries : :number_of_beneficiaries
- Number of months: :months - Number of months: :months
", ",
'insurance_renew_paid' => "Insurance renewal paid",
]; ];

View File

@ -189,4 +189,5 @@ Votre assurance a été renouvelée.
- Nombre d'ayants droit : :number_of_beneficiaries - Nombre d'ayants droit : :number_of_beneficiaries
- Nombre de mois : :months - Nombre de mois : :months
", ",
'insurance_renew_paid' => "Renouvellement de l'assurance payée",
]; ];