Bladeren bron

fixed billing report filter

= 3 jaren geleden
bovenliggende
commit
700b0b9242

+ 45 - 31
app/Http/Controllers/PracticeManagementController.php

@@ -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)

+ 6 - 0
app/Models/BillingReport.php

@@ -26,6 +26,12 @@ class BillingReport extends Model
         return $this->hasOne(Note::class, 'id', 'note_id');
     }
 
+    public function bill()
+    {
+        return $this->hasOne(Bill::class, 'id', 'bill_id');
+    }
+
+
     public function client()
     {
         return $this->hasOne(Client::class, 'id', 'client_id');

+ 84 - 9
resources/views/app/practice-management/billing-report.blade.php

@@ -2,7 +2,7 @@
 
 @section('content')
 
-<div id="practice-bills" class="p-3 mcp-theme-1">
+<div id="admin-billing-report" class="p-3 mcp-theme-1">
     <div class="card">
 
         <div class="card-header px-2 py-1 d-flex align-items-center">
@@ -13,13 +13,43 @@
         </div>
         <div class="card-body p-0 border-0 table-responsive">
             <div class="m-2">
-                Claim status: 
-                <a href="/practice-management/billing-report" class="badge">ALL</a>
-                <a href="/practice-management/billing-report?status=NO_CLAIMS" class="badge">NO_CLAIMS</a>
-                <a href="/practice-management/billing-report?status=NO_CLAIMS_AND_ZERO_DEDUCTIBLE" class="badge">NO_CLAIMS_AND_ZERO_DEDUCTIBLE</a>
-                @foreach($claimStatuses as $claimStatus)
-                <a href="/practice-management/billing-report?status={{$claimStatus->status}}" class="badge">{{$claimStatus->status}}</a>
-                @endforeach
+                <form action="/practice-management/billing-report"  method="GET" class="form-inline" id="admin-billing-report-form">
+                    <div class="form-group mr-2">
+                        <div class="form-check">
+                            <input type="checkbox" name="no_claims" class="form-check-input" v-model="filters.no_claims">
+                            <label for="" class="form-check-label">No Claims</label>
+                        </div>
+                    </div>
+
+                    <div class="form-group mr-2">
+                        <div class="form-check">
+                            <input type="checkbox" name="zero_deductible" class="form-check-input" v-model="filters.zero_deductible">
+                            <label for="" class="form-check-label">Zero Deductible</label>
+                        </div>
+                    </div>
+
+                    <div class="form-group mr-2">
+                        <label class="control-label" for="">Claim Status</label>
+                        <select name="claim_status" class="form-control" v-model="filters.claim_status">
+                            <option value="">All</option>
+                            @foreach($claimStatuses as $claimStatus)
+                               <option value="{{$claimStatus->status}}">{{ucwords($claimStatus->status)}}</option>
+                            @endforeach
+                        </select>
+                    </div>
+                    
+                    <div class="form-group mr-2">
+                        <label class="control-label" for="">Bill Verification Status</label>
+                        <select name="verified" class="form-control" v-model="filters.verified">
+                            <option value="">All</option>
+                            <option value="VERIFIED">Verified</option>
+                            <option value="UNVERIFIED">Unverified</option>
+                        </select>
+                    </div>
+                    <div class="form-group mr-2">
+                        <button v-on:click.prevent="doSubmit()" class="btn btn-primary btn-sm">Filter</button>
+                    </div>
+                </form>
             </div>
             <table class="table table-sm table-striped border-0 p-0 m-0 text-nowrap">
                 <thead class="bg-light">
@@ -42,7 +72,7 @@
                     @foreach ($rows as $row)
                     <tr class="{{false ? 'bg-light' : ''}}">
                         <td class="text-nowrap border-left-0">
-                            <a href="/patients/view/{{$row->client_uid}}">
+                            <a native target="_blank" href="/patients/view/{{$row->client_uid}}/notes/view/{{$row->note_uid}}">
                                 {{$row->clientDisplayName()}}
                             </a>
                             @if($row->client->latestClientPrimaryCoverage )
@@ -109,5 +139,50 @@
         {{$rows->appends(request()->input())->links()}}
     </div>
 
+
 </div>
+    <?php
+$loadedFilters = $filters;
+$allFilterKeys = [
+	'no_claims',
+	'zero_deductible',
+	'claim_status',
+	'verified'
+];
+for ($i=0; $i < count($allFilterKeys); $i++) {
+	if (!isset($loadedFilters[$allFilterKeys[$i]]) || !$loadedFilters[$allFilterKeys[$i]]) {
+		$loadedFilters[$allFilterKeys[$i]] = '';
+	}
+}
+?>
+<script>
+	(function() {
+		function init() {
+			new Vue({
+				el: '#admin-billing-report',
+				delimiters: ['@{{', '}}'],
+				data: {
+					filters: <?= json_encode($loadedFilters) ?>
+				},
+				methods: {
+					init: function() {
+
+					},
+					doSubmit: function() {
+						fastLoad('{{ route('practice-management.billing-report') }}?' + $('#admin-billing-report-form').serialize());
+						return false;
+					}
+				},
+				mounted: function() {
+					console.log(this.filters);
+					this.init();
+				},
+			});
+
+
+		}
+		addMCInitializer('admin-billing-report', init, '#admin-billing-report');
+	})();
+</script>
+
 @endsection