diff --git a/app/Http/Controllers/HealthCareSheetController.php b/app/Http/Controllers/HealthCareSheetController.php index 0ba7446..b39b2dd 100755 --- a/app/Http/Controllers/HealthCareSheetController.php +++ b/app/Http/Controllers/HealthCareSheetController.php @@ -947,6 +947,17 @@ class HealthCareSheetController extends Controller * in="query", * required=false * ), + * @OA\Parameter( + * parameter="beneficiary_id", + * name="beneficiary_id", + * description="ID du beneficiaire", + * @OA\Schema( + * type="integer", + * default = 3 + * ), + * in="query", + * required=false + * ), * @OA\Parameter( * parameter="network_agent_id", * name="network_agent_id", @@ -1006,6 +1017,7 @@ class HealthCareSheetController extends Controller { $this->validate($request, [ 'user_id' => 'required_without:network_agent_id|integer|exists:users,id', + 'beneficiary_id' => 'nullable|integer|exists:nh_having_rights,id', 'network_agent_id' => 'required_without:user_id|integer|exists:networks_agents,id', 'type' => 'nullable|in:CONSULTATION,EXECUTION', 'state' => 'nullable|in:UNTREATED,TREATED,ACCEPTED,TO_BILL' @@ -1014,10 +1026,14 @@ class HealthCareSheetController extends Controller $type = $request->input('type'); $state = $request->input('state'); $user_id = $request->input('user_id'); + $beneficiary_id = $request->input('beneficiary_id'); $network_agent_id = $request->input('network_agent_id'); - if (!empty($user_id)) { + if (!empty($user_id) || !empty($beneficiary_id)) { $query = NhInfosHealthCareSheets::where('user_id', $user_id); + if (!empty($beneficiary_id)) { + $query = $query->where('beneficiary_id', $beneficiary_id); + } if (!empty($network_agent_id)) { $query = $query->where('network_agent_id', $network_agent_id); } @@ -1037,6 +1053,10 @@ class HealthCareSheetController extends Controller return $q->with(['drug_or_device:id,name'])->where('billed', 0); }])->where('state', InsuranceSubscriptionState::ACCEPTED) ->where('user_id', $request->input('user_id')); + + if (!empty($beneficiary_id)) { + $query = $query->where('beneficiary_id', $beneficiary_id); + } } if (!empty($type)) { diff --git a/app/Models/NhHealthCareSheet.php b/app/Models/NhHealthCareSheet.php index 0f0fab8..fa7cf5c 100644 --- a/app/Models/NhHealthCareSheet.php +++ b/app/Models/NhHealthCareSheet.php @@ -15,6 +15,7 @@ use Illuminate\Database\Eloquent\Model; * @property int $id * @property string $health_care_sheet_id * @property int $insurance_id + * @property int $beneficiary_id * @property int $network_agent_id * @property string $patient_lastname * @property string|null $patient_firstname @@ -40,6 +41,7 @@ class NhHealthCareSheet extends Model protected $casts = [ 'insurance_id' => 'int', + 'beneficiary_id' => 'int', 'network_agent_id' => 'int', 'prescription_sheet_id' => 'int' ]; @@ -53,6 +55,7 @@ class NhHealthCareSheet extends Model protected $fillable = [ 'health_care_sheet_id', 'insurance_id', + 'beneficiary_id', 'network_agent_id', 'patient_lastname', 'patient_firstname', @@ -79,6 +82,11 @@ class NhHealthCareSheet extends Model return $this->belongsTo(NhInsurance::class, 'insurance_id'); } + public function beneficiary() + { + return $this->belongsTo(NhHavingRight::class, 'beneficiary_id'); + } + public function performances() { return $this->hasManyThrough(NhPerformance::class, NhHealthCareSheetsPerformance::class, diff --git a/database/migrations/2022_01_12_093307_add_beneficiary_id_to_nh_health_care_sheets_table.php b/database/migrations/2022_01_12_093307_add_beneficiary_id_to_nh_health_care_sheets_table.php new file mode 100644 index 0000000..5024f00 --- /dev/null +++ b/database/migrations/2022_01_12_093307_add_beneficiary_id_to_nh_health_care_sheets_table.php @@ -0,0 +1,32 @@ +integer('beneficiary_id')->nullable()->after('insurance_id'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('nh_health_care_sheets', function (Blueprint $table) { + $table->dropColumn('beneficiary_id'); + }); + } +} diff --git a/database/migrations/2022_01_12_093617_update_nh_infos_health_care_sheets_view2.php b/database/migrations/2022_01_12_093617_update_nh_infos_health_care_sheets_view2.php new file mode 100644 index 0000000..2d3781b --- /dev/null +++ b/database/migrations/2022_01_12_093617_update_nh_infos_health_care_sheets_view2.php @@ -0,0 +1,51 @@ + "Consultation ou prescription mis à jour", + 'consultation_or_prescription_updated' => "Consultation ou prescription mise à jour", ];