Przeglądaj źródła

fixed patients insurance filter

= 3 lat temu
rodzic
commit
0159447156

+ 7 - 4
app/Http/Controllers/AdminController.php

@@ -175,12 +175,12 @@ class AdminController extends Controller
         $insurance = $request->get('insurance');
         if($insurance){
             if($insurance === 'MEDICARE'){
-                $patients = $patients->whereHas('effectiveClientPrimaryCoverage', function($cpcQuery){
+                $patients = $patients->whereHas('effectiveClientPrimaryCoverage', function($cpcQuery) {
                     return $cpcQuery->where('is_partbprimary', '=', 'YES');
                 });
             }else{
-                $patients = $patients->whereDoesntHave('effectiveClientPrimaryCoverage', function($cpcQuery){
-                    return $cpcQuery->where('is_partbprimary', '=', 'YES');
+                $patients = $patients->whereHas('effectiveClientPrimaryCoverage', function($cpcQuery) use ($insurance){
+                    return $cpcQuery->where('commercial_payer_id', '=', $insurance);
                 });
             }
         }
@@ -192,7 +192,10 @@ class AdminController extends Controller
 
 
         $patients = $patients->orderBy('created_at', 'DESC')->paginate(25);
-        return view('app.admin.patients', compact('patients', 'filters'));
+
+        $insurances = DB::select('SELECT DISTINCT commercial_payer_name, commercial_payer_id FROM client_primary_coverage WHERE commercial_payer_name IS NOT NULL ORDER BY commercial_payer_name ASC');
+
+        return view('app.admin.patients', compact('patients', 'filters', 'insurances'));
     }
 
     public function partBPatients(Request $request){

+ 3 - 1
resources/views/app/admin/patients_filters.blade.php

@@ -177,7 +177,9 @@
 			<select class="form-control"  name="insurance" v-model="filters.insurance">
 				<option value=""></option>
 				<option value="MEDICARE">Medicare (Part B)</option>
-				<option value="OTHER">Other</option>
+				@foreach($insurances as $insurance)
+				<option value="{{$insurance->commercial_payer_id}}">{{$insurance->commercial_payer_name}}</option>
+				@endforeach
 			</select>
 		</div>
 	</div>