|
@@ -121,44 +121,58 @@ SELECT effective_date, count(*), sum(number_of_units) as units FROM bill WHERE c
|
|
|
public function billingReport(Request $request)
|
|
|
{
|
|
|
|
|
|
+ $filters = $request->all();
|
|
|
+
|
|
|
$claimStatus = $request->get('status');
|
|
|
|
|
|
- $rows = BillingReport::paginate(50);
|
|
|
+
|
|
|
+
|
|
|
+ $rows = BillingReport::whereHas('client', function($clientQuery){
|
|
|
+ return $clientQuery->where('client_engagement_status_category','<>' ,'DUMMY');
|
|
|
+ })->orderBy('note_date', 'desc');
|
|
|
+
|
|
|
+ $no_claims = $request->get('no_claims');
|
|
|
+ $zero_deductible = $request->get('zero_deductible');
|
|
|
+ $claim_status = $request->get('claim_status');
|
|
|
+ $verified = $request->get('verified');
|
|
|
|
|
|
- if($claimStatus){
|
|
|
- if($claimStatus == 'NO_CLAIMS'){
|
|
|
- $rows = BillingReport::whereHas('note', function($noteQuery) use ($claimStatus){
|
|
|
- return $noteQuery->has('claims', '=', 0);
|
|
|
- })->whereHas('client', function($clientQuery){
|
|
|
- return $clientQuery->where('client_engagement_status_category','<>' ,'DUMMY');
|
|
|
- })->orderBy('note_date', 'desc')->paginate(50);
|
|
|
- }elseif($claimStatus == 'NO_CLAIMS_AND_ZERO_DEDUCTIBLE'){
|
|
|
- $rows = BillingReport::whereHas('note', function($noteQuery) use ($claimStatus){
|
|
|
- return $noteQuery->has('claims', '=', 0);
|
|
|
- })->whereHas('client', function($clientQuery){
|
|
|
- return $clientQuery->where('client_engagement_status_category','<>' ,'DUMMY')
|
|
|
- ->whereHas('latestClientPrimaryCoverage', function($lcpcQuery){
|
|
|
- return $lcpcQuery->where('auto_medicare_mpb_deductible', 0);
|
|
|
- });
|
|
|
- })->orderBy('note_date', 'desc')->paginate(50);
|
|
|
- }else{
|
|
|
- $rows = BillingReport::whereHas('note', function($noteQuery) use ($claimStatus){
|
|
|
- return $noteQuery->whereHas('claims', function($claimQuery) use ($claimStatus) {
|
|
|
- return $claimQuery->where('status', $claimStatus);
|
|
|
- });
|
|
|
- })->whereHas('client', function($clientQuery){
|
|
|
- return $clientQuery->where('client_engagement_status_category','<>' ,'DUMMY');
|
|
|
- })->orderBy('note_date', 'desc')->paginate(50);
|
|
|
- }
|
|
|
- }else {
|
|
|
- $rows = BillingReport::whereHas('client', function($clientQuery){
|
|
|
- return $clientQuery->where('client_engagement_status_category','<>' ,'DUMMY');
|
|
|
- })->orderBy('note_date', 'desc')->paginate(50);
|
|
|
+ if($no_claims){
|
|
|
+ $rows = $rows->whereHas('note', function($noteQuery){
|
|
|
+ return $noteQuery->has('claims', '=', 0);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if($zero_deductible){
|
|
|
+ $rows = $rows->whereHas('client', function($clientQuery){
|
|
|
+ return $clientQuery->where('client_engagement_status_category','<>' ,'DUMMY')
|
|
|
+ ->whereHas('latestClientPrimaryCoverage', function($lcpcQuery){
|
|
|
+ return $lcpcQuery->where('auto_medicare_mpb_deductible', 0);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if($claim_status){
|
|
|
+ $rows = $rows->whereHas('note', function($noteQuery) use ($claimStatus){
|
|
|
+ return $noteQuery->whereHas('claims', function($claimQuery) use ($claimStatus) {
|
|
|
+ return $claimQuery->where('status', $claimStatus);
|
|
|
+ });
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
+ if($verified){
|
|
|
+ $rows = $rows->whereHas('note', function($noteQuery){
|
|
|
+ return $noteQuery->whereHas('bills', function($billQuery) {
|
|
|
+ return $billQuery->where('is_verified', true)->where('is_cancelled', false);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $rows = $rows->paginate(50);
|
|
|
+
|
|
|
$claimStatuses = DB::select('SELECT distinct status FROM claim ORDER BY status DESC');
|
|
|
|
|
|
- return view('app.practice-management.billing-report', compact('rows', 'claimStatuses'));
|
|
|
+ return view('app.practice-management.billing-report', compact('rows', 'claimStatuses', 'filters'));
|
|
|
}
|
|
|
|
|
|
public function dashboard(Request $request)
|