Add pagingation to somes endpoints

This commit is contained in:
Djery-Tom 2022-01-26 14:48:04 +01:00
parent 511587acd9
commit b938338627
6 changed files with 92 additions and 19 deletions

View File

@ -656,10 +656,13 @@ class HealthCareSheetController extends Controller
]); ]);
$healthCareSheet->user = $insurance->user; $healthCareSheet->user = $insurance->user;
$patient_name = $healthCareSheet->patient_lastname . ' ' . $healthCareSheet->patient_firstname;
$institution_name = $healthCareSheet->institution->lastname;
$practitioner_name = $healthCareSheet->practitioner_lastname . ' ' . $healthCareSheet->practitioner_firstname;
Event::dispatch(new InsuredConsultation($healthCareSheet, trans('messages.consultation_or_prescription_carried_out'), trans('messages.consultation_or_prescription_carried_out_mail', ['name' => $insurance->user->lastname, 'insured_id' => $insurance->insured_id, Event::dispatch(new InsuredConsultation($healthCareSheet, trans('messages.consultation_or_prescription_carried_out'), trans('messages.consultation_or_prescription_carried_out_mail', ['name' => $insurance->user->lastname, 'insured_id' => $insurance->insured_id,
'patient_name' => $healthCareSheet->patient_lastname . ' ' . $healthCareSheet->patient_firstname, 'patient_situation' => trans('states.' . $healthCareSheet->patient_situation), 'care_condition' => trans('states.' . $healthCareSheet->care_condition), 'patient_name' => $patient_name, 'patient_situation' => trans('states.' . $healthCareSheet->patient_situation), 'care_condition' => trans('states.' . $healthCareSheet->care_condition),
'gender' => trans('states.' . $insurance->user->identification->gender), 'insurance_name' => $nhConfig->network->name, 'practitioner_name' => $healthCareSheet->practitioner_lastname . ' ' . $healthCareSheet->practitioner_firstname, 'institution_name' => $healthCareSheet->institution->lastname]), 'gender' => trans('states.' . $insurance->user->identification->gender), 'insurance_name' => $nhConfig->network->name, 'practitioner_name' => $practitioner_name, 'institution_name' => $institution_name]),
trans('messages.consultation_or_prescription_carried_out_notification'))); trans('messages.consultation_or_prescription_carried_out_notification', ['patient_name' => $patient_name, 'practitioner_name' => $practitioner_name, 'institution_name' => $institution_name])));
DB::commit(); DB::commit();
return $this->successResponse(trans('messages.consultation_or_prescription_carried_out')); return $this->successResponse(trans('messages.consultation_or_prescription_carried_out'));
@ -914,10 +917,13 @@ class HealthCareSheetController extends Controller
]); ]);
$healthCareSheet->user = $insurance->user; $healthCareSheet->user = $insurance->user;
$patient_name = $healthCareSheet->patient_lastname . ' ' . $healthCareSheet->patient_firstname;
$institution_name = $healthCareSheet->institution->lastname;
$practitioner_name = $healthCareSheet->practitioner_lastname . ' ' . $healthCareSheet->practitioner_firstname;
Event::dispatch(new InsuredConsultation($healthCareSheet, trans('messages.execution_carried_out'), trans('messages.execution_carried_out_mail', ['name' => $insurance->user->lastname, 'insured_id' => $insurance->insured_id, Event::dispatch(new InsuredConsultation($healthCareSheet, trans('messages.execution_carried_out'), trans('messages.execution_carried_out_mail', ['name' => $insurance->user->lastname, 'insured_id' => $insurance->insured_id,
'patient_name' => $healthCareSheet->patient_lastname . ' ' . $healthCareSheet->patient_firstname, 'patient_situation' => trans('states.' . $healthCareSheet->patient_situation), 'care_condition' => trans('states.' . $healthCareSheet->care_condition), 'patient_name' => $patient_name, 'patient_situation' => trans('states.' . $healthCareSheet->patient_situation), 'care_condition' => trans('states.' . $healthCareSheet->care_condition),
'gender' => trans('states.' . $insurance->user->identification->gender), 'insurance_name' => $nhConfig->network->name, 'practitioner_name' => $healthCareSheet->practitioner_lastname . ' ' . $healthCareSheet->practitioner_firstname, 'institution_name' => $healthCareSheet->institution->lastname]), 'gender' => trans('states.' . $insurance->user->identification->gender), 'insurance_name' => $nhConfig->network->name, 'practitioner_name' => $practitioner_name, 'institution_name' => $institution_name]),
trans('messages.execution_carried_out'))); trans('messages.execution_carried_out', ['patient_name' => $patient_name, 'practitioner_name' => $practitioner_name, 'institution_name' => $institution_name])));
DB::commit(); DB::commit();
return $this->successResponse(trans('messages.execution_carried_out')); return $this->successResponse(trans('messages.execution_carried_out'));
@ -985,12 +991,32 @@ class HealthCareSheetController extends Controller
* description="Status des feuilles de soins", * description="Status des feuilles de soins",
* @OA\Schema( * @OA\Schema(
* type="string", * type="string",
* enum = {"UNTREATED","TREATED","ACCEPTED","TO_BILL"}, * enum = {"UNTREATED","TREATED","ACCEPTED","TO_BILL","ALL"},
* default = "UNTREATED" * default = "UNTREATED"
* ), * ),
* in="query", * in="query",
* required=false * required=false
* ), * ),
* @OA\Parameter(
* parameter="page",
* name="page",
* description="Page",
* in="query",
* required=false,
* @OA\Schema(
* type="integer"
* )
* ),
* @OA\Parameter(
* parameter="perPage",
* name="perPage",
* description="Pas de pagination",
* in="query",
* required=false,
* @OA\Schema(
* type="integer"
* )
* ),
* @OA\Response( * @OA\Response(
* response=200, * response=200,
* description="OK", * description="OK",
@ -1018,7 +1044,7 @@ class HealthCareSheetController extends Controller
'beneficiary_id' => 'nullable|integer|exists:nh_having_rights,id', 'beneficiary_id' => 'nullable|integer|exists:nh_having_rights,id',
'network_agent_id' => 'required_without:user_id|integer|exists:networks_agents,id', 'network_agent_id' => 'required_without:user_id|integer|exists:networks_agents,id',
'type' => 'nullable|in:CONSULTATION,EXECUTION', 'type' => 'nullable|in:CONSULTATION,EXECUTION',
'state' => 'nullable|in:UNTREATED,TREATED,ACCEPTED,TO_BILL' 'state' => 'nullable|in:UNTREATED,TREATED,ACCEPTED,TO_BILL,ALL'
]); ]);
$type = $request->input('type'); $type = $request->input('type');
@ -1032,7 +1058,9 @@ class HealthCareSheetController extends Controller
if (!empty($beneficiary_id)) { if (!empty($beneficiary_id)) {
$query = $query->where('beneficiary_id', $beneficiary_id); $query = $query->where('beneficiary_id', $beneficiary_id);
} else { } else {
$query = $query->whereNull('beneficiary_id'); if ($state != 'ALL') {
$query = $query->whereNull('beneficiary_id');
}
} }
if (!empty($network_agent_id)) { if (!empty($network_agent_id)) {
$query = $query->where('network_agent_id', $network_agent_id); $query = $query->where('network_agent_id', $network_agent_id);
@ -1079,21 +1107,23 @@ class HealthCareSheetController extends Controller
} }
} }
$sheets = $query->orderBy('created_at', 'DESC')->get(); $sheets = $query->orderBy('created_at', 'DESC')->paginate($request->input('perPage', 10));
if (!empty($state) && $state == 'TO_BILL') { if (!empty($state) && $state == 'TO_BILL') {
// Liste des feuilles de soins a afficher pour l'execution , // Liste des feuilles de soins a afficher pour l'execution ,
// Retirer les feuilles de soins qui n'ont ni exams ou prescriptions non soldes // Retirer les feuilles de soins qui n'ont ni exams ou prescriptions non soldes
$notEmptySheets = []; $notEmptySheets = [];
foreach ($sheets as $s) { foreach ($sheets->items() as $s) {
if (sizeof($s->exams) == 0 && sizeof($s->prescriptions) == 0) { if (sizeof($s->exams) == 0 && sizeof($s->prescriptions) == 0) {
continue; continue;
} }
$notEmptySheets[] = $s; $notEmptySheets[] = $s;
} }
$sheets = $notEmptySheets; // $sheets = $notEmptySheets;
$sheets->setCollection(collect($notEmptySheets));
} }
foreach ($sheets as $sheet) { foreach ($sheets->items() as $sheet) {
$this->formalizeHealthCareSheet($sheet); $this->formalizeHealthCareSheet($sheet);
} }

View File

@ -683,6 +683,26 @@ class InsuranceSubscriptionController extends Controller
* enum={"ALL","ACCEPTED"} * enum={"ALL","ACCEPTED"}
* ) * )
* ), * ),
* @OA\Parameter(
* parameter="page",
* name="page",
* description="Page",
* in="query",
* required=false,
* @OA\Schema(
* type="integer"
* )
* ),
* @OA\Parameter(
* parameter="perPage",
* name="perPage",
* description="Pas de pagination",
* in="query",
* required=false,
* @OA\Schema(
* type="integer"
* )
* ),
* @OA\Response( * @OA\Response(
* response=200, * response=200,
* description="OK", * description="OK",
@ -725,8 +745,8 @@ class InsuranceSubscriptionController extends Controller
} }
} }
$subscriptions = $query->get(); $subscriptions = $query->paginate($request->input('perPage', 10));;
foreach ($subscriptions as $subscription) { foreach ($subscriptions->items() as $subscription) {
$subscription->state = trans('states.' . $subscription->state); $subscription->state = trans('states.' . $subscription->state);
$subscription->insurance_action = trans('states.' . $subscription->insurance_action); $subscription->insurance_action = trans('states.' . $subscription->insurance_action);
$subscription->bonus_amount = $this->toMoneyWithCurrencyCode($subscription->bonus_amount, $currency_code); $subscription->bonus_amount = $this->toMoneyWithCurrencyCode($subscription->bonus_amount, $currency_code);

View File

@ -164,6 +164,26 @@ class InvoiceController extends Controller
* in="query", * in="query",
* required=false * required=false
* ), * ),
* @OA\Parameter(
* parameter="page",
* name="page",
* description="Page",
* in="query",
* required=false,
* @OA\Schema(
* type="integer"
* )
* ),
* @OA\Parameter(
* parameter="perPage",
* name="perPage",
* description="Pas de pagination",
* in="query",
* required=false,
* @OA\Schema(
* type="integer"
* )
* ),
* @OA\Response( * @OA\Response(
* response=200, * response=200,
* description="OK", * description="OK",
@ -202,8 +222,8 @@ class InvoiceController extends Controller
$query = $query->where('network_agent_id', $network_agent_id); $query = $query->where('network_agent_id', $network_agent_id);
} }
$invoices = $query->orderBy('created_at', 'DESC')->get(); $invoices = $query->orderBy('created_at', 'DESC')->paginate($request->input('perPage', 10));
foreach ($invoices as $i) { foreach ($invoices->items() as $i) {
$i->amount = $this->toMoneyWithCurrencyCode($i->amount, $i->currency_code); $i->amount = $this->toMoneyWithCurrencyCode($i->amount, $i->currency_code);
$i->insured_amount = $this->toMoneyWithCurrencyCode($i->insured_amount, $i->currency_code); $i->insured_amount = $this->toMoneyWithCurrencyCode($i->insured_amount, $i->currency_code);
$i->insurer_amount = $this->toMoneyWithCurrencyCode($i->insurer_amount, $i->currency_code); $i->insurer_amount = $this->toMoneyWithCurrencyCode($i->insurer_amount, $i->currency_code);

View File

@ -61,6 +61,7 @@ class InsuredConsultationNotification
$data->data = new stdClass(); $data->data = new stdClass();
$data->data->id = $event->healthCareSheet->id; $data->data->id = $event->healthCareSheet->id;
$body->data = $data; $body->data = $data;
$data->not_saved = true; // Notification non sauvegardé
$client->request('POST', '/onesignal/pushToUser', ['json' => $body, 'headers' => $headers]); $client->request('POST', '/onesignal/pushToUser', ['json' => $body, 'headers' => $headers]);
} }

View File

@ -108,11 +108,12 @@ A new consultation or prescription has been made with your insurance.
Log in to the application to have more details and validate this operation. Log in to the application to have more details and validate this operation.
", ",
'consultation_or_prescription_carried_out_notification' => "A new consultation or prescription has just been made with your insurance", 'consultation_or_prescription_carried_out_notification' => "Consultation or prescription carried out for the insured :patient_name in the institution :institution_name by :practitioner_name",
"care_sheet_accepted" => "The care sheet has been accepted", "care_sheet_accepted" => "The care sheet has been accepted",
"care_sheet_rejected" => "The care sheet has been rejected", "care_sheet_rejected" => "The care sheet has been rejected",
"care_sheet_resubmitted" => "The care sheet has been resubmitted", "care_sheet_resubmitted" => "The care sheet has been resubmitted",
'execution_carried_out' => "Execution of prescription carried out", 'execution_carried_out' => "Execution of prescription carried out",
'execution_carried_out_notification' => "Execution of prescription carried out for the insured :patient_name in the institution :institution_name by :practitioner_name",
'consultation_or_prescription_updated' => "Consultation or prescription updated", 'consultation_or_prescription_updated' => "Consultation or prescription updated",
'amount' => 'Amount', 'amount' => 'Amount',
'total_amount' => 'Total Amount', 'total_amount' => 'Total Amount',

View File

@ -108,11 +108,12 @@ Une nouvelle consultation ou prescription vient d'etre effectuée sur votre assu
Connectez-vous à l'application pour avoir plus de details et valider cette opération. Connectez-vous à l'application pour avoir plus de details et valider cette opération.
", ",
'consultation_or_prescription_carried_out_notification' => "Une nouvelle consultation ou prescription vient d'etre effectuée sur votre assurance", 'consultation_or_prescription_carried_out_notification' => "Consultation ou prescription effectuée pour l'assuré :patient_name dans l'établissement :institution_name par :practitioner_name",
"care_sheet_accepted" => "La feuille de soins a été acceptée", "care_sheet_accepted" => "La feuille de soins a été acceptée",
"care_sheet_rejected" => "La feuille de soins a été rejetée", "care_sheet_rejected" => "La feuille de soins a été rejetée",
"care_sheet_resubmitted" => "La feuille de soins a été re-soumise", "care_sheet_resubmitted" => "La feuille de soins a été re-soumise",
'execution_carried_out' => "Execution de prescription effectuée", 'execution_carried_out' => "Execution de prescription effectuée",
'execution_carried_out_notification' => "Execution de prescription effectuée pour l'assuré :patient_name dans l'établissement :institution_name par :practitioner_name",
'execution_carried_out_mail' => ":gender :name , 'execution_carried_out_mail' => ":gender :name ,
Une nouvelle execution de prescription vient d'etre effectuée sur votre assurance. Une nouvelle execution de prescription vient d'etre effectuée sur votre assurance.