|
@@ -187,9 +187,13 @@ class AdminController extends Controller
|
|
|
$insurance = $request->get('insurance');
|
|
|
if($insurance){
|
|
|
if($insurance === 'MEDICARE'){
|
|
|
- $patients = $patients->where('is_part_b_primary', 'YES');
|
|
|
+ $patients = $patients->whereHas('latestClientPrimaryCoverage', function($cpcQuery){
|
|
|
+ return $cpcQuery->where('is_partbprimary', '=', 'YES');
|
|
|
+ });
|
|
|
}else{
|
|
|
- $patients = $patients->where('is_part_b_primary', '!=', 'YES');
|
|
|
+ $patients = $patients->whereDoesntHave('latestClientPrimaryCoverage', function($cpcQuery){
|
|
|
+ return $cpcQuery->where('is_partbprimary', '=', 'YES');
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
|