Update endpoint fetch health care sheets
This commit is contained in:
parent
3c3d4c1d78
commit
3146f94378
|
@ -930,12 +930,25 @@ class HealthCareSheetController extends Controller
|
|||
* in="query",
|
||||
* required=true
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* * @OA\Parameter(
|
||||
* parameter="type",
|
||||
* name="type",
|
||||
* description="Type des feuilles de soins",
|
||||
* @OA\Schema(
|
||||
* type="string",
|
||||
* enum = {"CONSULTATION","EXECUTION"},
|
||||
* default = "CONSULTATION"
|
||||
* ),
|
||||
* in="query",
|
||||
* required=false
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* parameter="state",
|
||||
* name="state",
|
||||
* description="Status des feuilles de soins",
|
||||
* @OA\Schema(
|
||||
* type="string",
|
||||
* enum = {"UNTREATED","TREATED","ACCEPTED"},
|
||||
* default = "UNTREATED"
|
||||
* ),
|
||||
* in="query",
|
||||
|
@ -965,14 +978,30 @@ class HealthCareSheetController extends Controller
|
|||
{
|
||||
$this->validate($request, [
|
||||
'user_id' => 'required|integer|exists:users,id',
|
||||
'type' => 'nullable|in:UNTREATED'
|
||||
'type' => 'nullable|in:CONSULTATION,EXECUTION',
|
||||
'state' => 'nullable|in:UNTREATED,TREATED,ACCEPTED'
|
||||
]);
|
||||
|
||||
$type = $request->input('type');
|
||||
$state = $request->input('state');
|
||||
$query = NhInfosHealthCareSheets::with(['performances.act:id,code,name', 'exams.act:id,code,name', 'prescriptions.drug_or_device:id,name'])->where('user_id', $request->input('user_id'));
|
||||
|
||||
if (isset($type) && $type == 'UNTREATED') {
|
||||
if (!empty($type)) {
|
||||
$query = $query->where('type', $type);
|
||||
}
|
||||
|
||||
if (!empty($state)) {
|
||||
switch ($state) {
|
||||
case 'UNTREATED' :
|
||||
$query = $query->where('state', InsuranceSubscriptionState::UNDER_VALIDATION);
|
||||
break;
|
||||
case 'TREATED' :
|
||||
$query = $query->where('state', '!=', InsuranceSubscriptionState::UNDER_VALIDATION);
|
||||
break;
|
||||
case 'ACCEPTED' :
|
||||
$query = $query->where('state', InsuranceSubscriptionState::ACCEPTED);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$sheets = $query->get();
|
||||
|
|
Loading…
Reference in New Issue