Improve GET /authorizations-care-requests
This commit is contained in:
parent
e9bdba5eb7
commit
cdeee9a307
|
@ -108,7 +108,6 @@ class AuthorizationCareRequestController extends Controller
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$act_id = $request->input('act_id');
|
$act_id = $request->input('act_id');
|
||||||
$password = $request->input('password');
|
|
||||||
$insurance = NhInsurance::find($request->input('insurance_id'));
|
$insurance = NhInsurance::find($request->input('insurance_id'));
|
||||||
if ($insurance->state != InsuranceState::PAID) {
|
if ($insurance->state != InsuranceState::PAID) {
|
||||||
return $this->errorResponse(__('errors.insurance_not_in_order'));
|
return $this->errorResponse(__('errors.insurance_not_in_order'));
|
||||||
|
@ -285,6 +284,12 @@ class AuthorizationCareRequestController extends Controller
|
||||||
->paginate($request->input('perPage', 10));
|
->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') {
|
||||||
|
$r->user_lastname = $r->beneficiary_lastname;
|
||||||
|
$r->user_firstname = $r->beneficiary_firstname;
|
||||||
|
}
|
||||||
|
$r->to = trans('states.' . $r->to);
|
||||||
|
unset($r->beneficiary_lastname, $r->beneficiary_firstname);
|
||||||
}
|
}
|
||||||
return $this->successResponse($requests);
|
return $this->successResponse($requests);
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,6 +141,17 @@ class InsuranceController extends Controller
|
||||||
* enum={"ALL","EDITABLE"}
|
* enum={"ALL","EDITABLE"}
|
||||||
* )
|
* )
|
||||||
* ),
|
* ),
|
||||||
|
* @OA\Parameter(
|
||||||
|
* parameter="state",
|
||||||
|
* name="state",
|
||||||
|
* description="Etat d'assurance",
|
||||||
|
* in="query",
|
||||||
|
* required=false,
|
||||||
|
* @OA\Schema(
|
||||||
|
* type="string",
|
||||||
|
* enum={"STOPPED","PAID"}
|
||||||
|
* )
|
||||||
|
* ),
|
||||||
* @OA\Response(
|
* @OA\Response(
|
||||||
* response=200,
|
* response=200,
|
||||||
* description="OK",
|
* description="OK",
|
||||||
|
@ -166,14 +177,20 @@ class InsuranceController extends Controller
|
||||||
{
|
{
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'user_id' => 'required|integer|exists:users,id',
|
'user_id' => 'required|integer|exists:users,id',
|
||||||
'type' => 'nullable|in:ALL,EDITABLE'
|
'type' => 'nullable|in:ALL,EDITABLE',
|
||||||
|
'state' => 'nullable|in:PAID,STOPPED'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$userId = $request->input('user_id');
|
$userId = $request->input('user_id');
|
||||||
$type = $request->input('type');
|
$type = $request->input('type');
|
||||||
|
$state = $request->input('state');
|
||||||
|
|
||||||
$query = NhInsurance::with(['network:id,name', 'beneficiaries'])->where('user_id', $userId);
|
$query = NhInsurance::with(['network:id,name', 'beneficiaries'])->where('user_id', $userId);
|
||||||
|
|
||||||
|
if (!empty($state)) {
|
||||||
|
$query = $query->where('state', $state);
|
||||||
|
}
|
||||||
|
|
||||||
if ($request->has('type') && $type == 'EDITABLE') {
|
if ($request->has('type') && $type == 'EDITABLE') {
|
||||||
$query = $query->whereIn('state', [InsuranceState::PAID]);
|
$query = $query->whereIn('state', [InsuranceState::PAID]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,5 +26,6 @@ return [
|
||||||
'HAVING_RIGHT' => "HAVING RIGHT",
|
'HAVING_RIGHT' => "HAVING RIGHT",
|
||||||
'INSURED' => 'INSURED',
|
'INSURED' => 'INSURED',
|
||||||
'INVOICE_ISSUED' => 'INVOICE ISSUED',
|
'INVOICE_ISSUED' => 'INVOICE ISSUED',
|
||||||
'STOP_INSURANCE' => "STOP INSURANCE"
|
'STOP_INSURANCE' => "STOP INSURANCE",
|
||||||
|
'USED' => 'USED'
|
||||||
];
|
];
|
||||||
|
|
|
@ -26,5 +26,6 @@ return [
|
||||||
'HAVING_RIGHT' => "AYANT DROIT",
|
'HAVING_RIGHT' => "AYANT DROIT",
|
||||||
'INSURED' => 'ASSURÉ',
|
'INSURED' => 'ASSURÉ',
|
||||||
'INVOICE_ISSUED' => 'FACTURE ÉMISE',
|
'INVOICE_ISSUED' => 'FACTURE ÉMISE',
|
||||||
'STOP_INSURANCE' => "ARRÊT DE L'ASSURANCE"
|
'STOP_INSURANCE' => "ARRÊT DE L'ASSURANCE",
|
||||||
|
'USED' => 'UTILISÉE'
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in New Issue