ソースを参照

Merge branch 'master' into dev-vj

Vijayakrishnan 4 年 前
コミット
e31770b87f

+ 41 - 22
app/Http/Controllers/PracticeManagementController.php

@@ -3,6 +3,7 @@
 namespace App\Http\Controllers;
 
 use App\Models\AppSession;
+use App\Models\BillingReport;
 use App\Models\ClaimEDI;
 use App\Models\Measurement;
 use App\Models\Bill;
@@ -33,6 +34,13 @@ use Illuminate\Http\Request;
 
 class PracticeManagementController extends Controller
 {
+
+    public function billingReport(Request $request)
+    {
+        $rows = BillingReport::paginate(200);
+        return view('app.practice-management.billing-report', compact('rows'));
+    }
+
     public function dashboard(Request $request)
     {
         return view('app.practice-management.dashboard');
@@ -883,55 +891,66 @@ class PracticeManagementController extends Controller
         return view('app.practice-management.shipments-multi-print', compact('shipments'));
     }
 
-    public function patientClaimSummary(Request $request, $proUid=null)
+    public function patientClaimSummary(Request $request, $proUid = null)
     {
 
         $notesTotal = DB::select(DB::raw("SELECT COUNT(*) FROM note WHERE is_cancelled IS NOT TRUE"))[0]->count;
         $notesTotalWithBillingClosed = DB::select(DB::raw("SELECT COUNT(*) FROM note WHERE is_cancelled IS NOT TRUE AND is_bill_closed IS TRUE"))[0]->count;
         $notesTotalWithClaimingClosed = DB::select(DB::raw("SELECT COUNT(*) FROM note WHERE is_cancelled IS NOT TRUE AND is_claim_closed IS TRUE"))[0]->count;
 
+        $notes3rdPartyTotal = DB::select(DB::raw("SELECT COUNT(*) FROM note n LEFT JOIN client c ON n.client_id = c.id WHERE n.is_cancelled IS NOT TRUE AND c.is_part_b_primary <> 'YES'"))[0]->count;
+        $notes3rdPartyTotalWithBillingClosed = DB::select(DB::raw("SELECT COUNT(*) FROM note n LEFT JOIN client c ON n.client_id = c.id WHERE n.is_cancelled IS NOT TRUE AND n.is_bill_closed IS TRUE AND c.is_part_b_primary <> 'YES'"))[0]->count;
+        $notes3rdPartyTotalWithClaimingClosed = DB::select(DB::raw("SELECT COUNT(*) FROM note n LEFT JOIN client c ON n.client_id = c.id WHERE n.is_cancelled IS NOT TRUE AND n.is_claim_closed IS TRUE AND c.is_part_b_primary <> 'YES'"))[0]->count;
+
         $patientsTotal = DB::select(DB::raw("SELECT COUNT(*) FROM client WHERE is_active IS TRUE AND 0 NOT IN (SELECT c FROM (SELECT COUNT(*) c FROM note WHERE is_cancelled IS NOT TRUE AND note.client_id = client.id) x)"))[0]->count;
         $patientsTotalWithBillingClosed = DB::select(DB::raw("SELECT COUNT(*) FROM client WHERE is_active IS TRUE AND 0 NOT IN (SELECT c FROM (SELECT COUNT(*) c FROM note WHERE is_cancelled IS NOT TRUE AND note.client_id = client.id) y) AND 0 IN (SELECT c FROM (SELECT COUNT(*) c FROM note WHERE is_cancelled IS NOT TRUE AND is_bill_closed IS NOT TRUE AND note.client_id = client.id) x)"))[0]->count;
         $patientsTotalWithClaimingClosed = DB::select(DB::raw("SELECT COUNT(*) FROM client WHERE is_active IS TRUE AND 0 NOT IN (SELECT c FROM (SELECT COUNT(*) c FROM note WHERE is_cancelled IS NOT TRUE AND note.client_id = client.id) y) AND 0 IN (SELECT c FROM (SELECT COUNT(*) c FROM note WHERE is_cancelled IS NOT TRUE AND is_claim_closed IS NOT TRUE AND note.client_id = client.id) x)"))[0]->count;
 
+
         $performerPro = $this->performer->pro;
         $allPros = [];
         if ($performerPro->pro_type == 'ADMIN') {
             $allPros = Pro::all();
         } else {
-           $allPros = [$performerPro];
+            $allPros = [$performerPro];
         }
 
         //Patient | MCP | # Notes Total | # Notes without Billing Closed | # Notes without Claiming Closed
         $patientsQuery = Client::where('is_dummy', '=', false)
-            ->select('id', 'uid', 'name_first', 'name_last', 'mcp_pro_id',
+            ->select('id', 'uid', 'name_first', 'name_last', 'mcp_pro_id', 'is_part_b_primary', 'medicare_advantage_plan',
                 DB::raw("(SELECT name_first||' '||name_last FROM pro where pro.id = client.mcp_pro_id) as mcp"),
                 DB::raw("(SELECT uid FROM pro where pro.id = mcp_pro_id) as mcp_pro_uid"),
                 DB::raw("(SELECT COUNT(*) FROM note where note.client_id = client.id) as notes_total"),
                 DB::raw("(SELECT COUNT(*) FROM note where note.client_id = client.id AND is_bill_closed IS NOT true) as notes_without_billing_closed"),
                 DB::raw("(SELECT COUNT(*) FROM note where note.client_id = client.id AND is_claim_closed IS NOT true) as notes_without_claiming_closed")
-            )->orderBy('notes_without_claiming_closed', 'desc');
+            )->orderBy('is_part_b_primary', 'asc')->orderBy('notes_without_claiming_closed', 'desc');
 
-            if($proUid){
-                $mcpPro = Pro::where('uid', $proUid)->first();
-                if($mcpPro){
-                    $patientsQuery->where('client.mcp_pro_id','=', $mcpPro->id);
-                }
+        if ($proUid) {
+            $mcpPro = Pro::where('uid', $proUid)->first();
+            if ($mcpPro) {
+                $patientsQuery->where('client.mcp_pro_id', '=', $mcpPro->id);
             }
+        }
 
-           $patients =  $patientsQuery->paginate(50);
-
-            $data = [
-                'patients' => $patients,
-                'proUid' => $proUid,
-                'allPros' => $allPros,
-                'notesTotal' => $notesTotal,
-                'notesTotalWithBillingClosed' => $notesTotalWithBillingClosed,
-                'notesTotalWithClaimingClosed' => $notesTotalWithClaimingClosed,
-                'patientsTotal' => $patientsTotal,
-                'patientsTotalWithBillingClosed' => $patientsTotalWithBillingClosed,
-                'patientsTotalWithClaimingClosed' => $patientsTotalWithClaimingClosed
-            ];
+        $patients = $patientsQuery->paginate(50);
+
+        $data = [
+            'patients' => $patients,
+            'proUid' => $proUid,
+            'allPros' => $allPros,
+            'notesTotal' => $notesTotal,
+            'notesTotalWithBillingClosed' => $notesTotalWithBillingClosed,
+            'notesTotalWithClaimingClosed' => $notesTotalWithClaimingClosed,
+
+            'notes3rdPartyTotal' => $notes3rdPartyTotal,
+            'notes3rdPartyTotalWithBillingClosed' => $notes3rdPartyTotalWithBillingClosed,
+            'notes3rdPartyTotalWithClaimingClosed' => $notes3rdPartyTotalWithClaimingClosed,
+
+            'patientsTotal' => $patientsTotal,
+            'patientsTotalWithBillingClosed' => $patientsTotalWithBillingClosed,
+            'patientsTotalWithClaimingClosed' => $patientsTotalWithClaimingClosed
+
+        ];
 
         return view('app.practice-management.patient-claim-summary', $data);
     }

+ 34 - 0
app/Models/BillingReport.php

@@ -0,0 +1,34 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Relations\HasOne;
+use Illuminate\Support\Collection;
+
+# use Illuminate\Database\Eloquent\Model;
+
+class BillingReport extends Model
+{
+    protected $table = 'billing_report';
+
+    public function clientDisplayName()
+    {
+        return $this->client_last . ', ' . $this->client_first;
+    }
+
+    public function proDisplayName()
+    {
+        return $this->pro_last . ', ' . $this->pro_first;
+    }
+
+    public function note()
+    {
+        return $this->hasOne(Note::class, 'id', 'note_id');
+    }
+
+    public function client()
+    {
+        return $this->hasOne(Client::class, 'id', 'client_id');
+    }
+
+}

+ 24 - 5
resources/views/app/patient/claims-resolver.blade.php

@@ -22,6 +22,7 @@
     $totalNotesWithBillingClosed = 0;
     $totalNotesWithClaimingClosed = 0;
     foreach($patient->notesAscending as $note){
+        if($note->is_cancelled) continue;
         $hcpIdToProMap[$note->hcp_pro_id] = $note->hcpPro;
         $d = $note->effective_dateest;
         $firstDateSeenByHcpMap[$note->hcp_pro_id] = isset($firstDateSeenByHcpMap[$note->hcp_pro_id]) ? $firstDateSeenByHcpMap[$note->hcp_pro_id] : $d;
@@ -184,6 +185,14 @@
             margin:0 2em 2em;
         }
 
+        td.cr-check {
+            background-color: lightgreen;
+        }
+
+        td.cr-close {
+            background-color: lightcoral;
+        }
+
     </style>
     <div style="overflow: auto">
         <table class="table table-bordered table-condensed" id="notes-table">
@@ -221,7 +230,7 @@
             $loopLastContentByHcp = [];
             $rowIndex = 0;
             foreach($patient->notesAscending as $note){
-
+                if($note->is_cancelled) continue;
                 $rowIndex++;
 
                 $d = $note->effective_dateest;
@@ -296,23 +305,33 @@
 {{--            <td>--}}
 {{--                {{ $loopLastDateSeenByMcpTypePro }}--}}
 {{--            </td>--}}
-            <td>
-                {{ $note->is_signed_by_hcp ? 'Yes' : 'No' }}
+
+            <td class="cr-{{ $note->is_signed_by_hcp ? 'check' : 'close' }}">
+                <i class="fa fa-{{ $note->is_signed_by_hcp ? 'check' : 'times-circle' }}"></i>
+                HCP {{ $note->is_signed_by_hcp ? '' : 'Not' }} Signed
+            </td>
+            <td class="cr-{{ $note->is_bill_closed ? 'check' : 'close' }}">
+                <i class="fa fa-{{ $note->is_bill_closed ? 'check' : 'times-circle' }}"></i>
+                Billing {{ $note->is_bill_closed ? '' : 'Not' }} Closed
+            </td>
+            <td class="cr-{{ $note->is_claim_closed ? 'check' : 'close' }}">
+                <i class="fa fa-{{ $note->is_claim_closed ? 'check' : 'times-circle' }}"></i>
+                Claiming {{ $note->is_claim_closed ? '' : 'Not' }} Closed
             </td>
-            <td>{{ $note->is_bill_closed ? 'Yes' : 'No' }}</td>
-            <td>{{ $note->is_claim_closed ? 'Yes' : 'No' }}</td>
 {{--            <td><div style="max-height: 200px; overflow-y: auto;">{!! $content !!}</div></td>--}}
 
             <td class="p-0">
                 <div>
                     <table class="table table-sm m-0 border-0">
                     @foreach($note->bills as $bill)
+                        @if(!$bill->is_cancelled)
                         <tr>
                             <td>{{$bill->code}}</td>
                             <td style="width: 60px">
                                 {{str_contains($bill->code, 'Treatment Services') ? floor((float) $bill->number_of_units * 60) . ' mins.' : $bill->number_of_units}}
                             </td>
                         </tr>
+                        @endif
                     @endforeach
                     </table>
                 </div>

+ 81 - 0
resources/views/app/practice-management/billing-report.blade.php

@@ -0,0 +1,81 @@
+@extends ('layouts/template')
+
+@section('content')
+
+    <div id="practice-bills" class="p-3 mcp-theme-1">
+    <div class="card">
+
+        <div class="card-header px-3 py-2 d-flex align-items-center">
+            <strong class="mr-4">
+                <i class="fas fa-user-injured"></i>
+                Note Billing Report
+            </strong>
+        </div>
+        <div class="card-body p-0 border-0 table-responsive">
+            <table class="table table-sm table-condensed table-bordered border-0 p-0 m-0">
+                <thead class="bg-light">
+                <tr>
+                    <th>Patient</th>
+                    <th>Note</th>
+                    <th>Pro</th>
+                    <th>Date</th>
+                    <th>New/FU</th>
+                    <th>Method</th>
+                    <th>Billing Closed?</th>
+                    <th>Claiming Closed?</th>
+                    <th>Claims</th>
+                    <th>Bills</th>
+                    <th>ICDs</th>
+                </tr>
+                </thead>
+                <tbody>
+                @foreach ($rows as $row)
+                    <tr class="{{false ? 'bg-light' : ''}}">
+                        <td class="text-nowrap border-left-0">
+                            <a href="/patients/view/{{$row->client_uid}}">
+                                {{$row->clientDisplayName()}}
+                            </a>
+                        </td>
+                        <td class="text-nowrap border-left-0">
+                            <a href="/patients/view/{{$row->client_uid}}/notes/view/{{$row->note_uid}}">
+                                {{friendly_date_time($row->note_date, false)}}
+                            </a>
+                        </td>
+                        <td class="text-nowrap border-left-0">
+                            {{$row->proDisplayName()}}
+                        </td>
+                        <td class="text-nowrap border-left-0">
+                            {{$row->note_date}}
+                        </td>
+                        <td class="text-nowrap border-left-0">
+                            {{$row->new_or_fu_or_na}}
+                        </td>
+                        <td class="text-nowrap border-left-0">
+                            {{$row->method}}
+                        </td>
+                        <td class="text-nowrap border-left-0">
+                            {{$row->is_billing_closed}}
+                        </td>
+                        <td class="text-nowrap border-left-0">
+                            {{$row->is_claiming_closed}}
+                        </td>
+                        <td class="text-nowrap border-left-0">
+                            <pre>{{$row->claim_lines}}</pre>
+                        </td>
+                        <td class="text-nowrap border-left-0">
+                            <pre>{{$row->bills}}</pre>
+                        </td>
+                        <td class="text-nowrap border-left-0">
+                            <pre>{{$row->icds}}</pre>
+                        </td>
+                    </tr>
+                @endforeach
+                </tbody>
+            </table>
+            <div>
+                {{$rows->links()}}
+            </div>
+        </div>
+    </div>
+    </div>
+@endsection

+ 33 - 2
resources/views/app/practice-management/patient-claim-summary.blade.php

@@ -43,6 +43,35 @@
                         </td>
                     </tr>
 
+                    <tr>
+                        <th class="border-top-0 pl-2" style="width: 300px;">Total notes, 3rd party</th>
+                        <td class="border-top-0 px-2"  style="width: 100px;">{{$notes3rdPartyTotal}}</td>
+                        <td></td>
+                    </tr>
+                    <tr>
+                        <th class="pl-2">Notes with billing closed, 3rdParty</th>
+                        <td class="px-2">{{$notes3rdPartyTotalWithBillingClosed}} / {{ $notes3rdPartyTotal }}</td>
+                        <td>
+                            <div class="d-flex align-items-center">
+                                <span class="fill-percent-value">{{round(($notes3rdPartyTotalWithBillingClosed) *100/ $notes3rdPartyTotal, 1)}}%</span>
+                                <div class="flex-grow-1 position-relative fill-bar">
+                                    <div class="bg-info position-absolute" style="left: 0; top: 0; height: 100%; width: {{ ($notesTotalWithBillingClosed) * 100/ $notesTotal }}%"></div>
+                                </div>
+                            </div>
+                        </td>
+                    </tr>
+                    <tr>
+                        <th class="pl-2">Notes with claiming closed, 3rdParty</th>
+                        <td class="px-2">{{$notes3rdPartyTotalWithClaimingClosed}} / {{ $notes3rdPartyTotal }}</td>
+                        <td>
+                            <div class="d-flex align-items-center">
+                                <span class="fill-percent-value">{{round(($notes3rdPartyTotalWithClaimingClosed) *100/ $notes3rdPartyTotal, 1)}}%</span>
+                                <div class="flex-grow-1 position-relative fill-bar">
+                                    <div class="bg-info position-absolute" style="left: 0; top: 0; height: 100%; width: {{ ($notesTotalWithClaimingClosed) * 100/ $notesTotal }}%"></div>
+                                </div>
+                            </div>
+                        </td>
+                    </tr>
 
                     <tr>
                         <th class="border-top-0 pl-2" style="width: 250px;">Total patients w/ notes</th>
@@ -102,6 +131,7 @@
                     <tr>
                         <th>Patient</th>
                         <th>MCP</th>
+                        <th>Payer</th>
                         <th>#Notes without Billing Closed</th>
                         <th>#Notes without Claiming Closed</th>
                         <th>#Notes Total</th>
@@ -121,14 +151,15 @@
                                 </a>
                             </td>
                             <td>{{$patient->mcp}}</td>
+                            <td>{{$patient->is_part_b_primary == 'YES'?'Medicare Part B':($patient->medicare_advantage_plan?$patient->medicare_advantage_plan:'Manual: '.$patient->payer_name)}}</td>
                             <td>{{$patient->notes_without_billing_closed}}</td>
                             <td>{{$patient->notes_without_claiming_closed}}</td>
                             <td>{{$patient->notes_total}}</td>
                             <td>
                                 <div class="d-flex align-items-center">
-                                    <span class="fill-percent-value">{{round(($patient->notes_total - $patient->notes_without_claiming_closed) *100/$patient->notes_total, 1)}}%</span>
+                                    <span class="fill-percent-value">{{$patient->notes_total ? round(($patient->notes_total - $patient->notes_without_claiming_closed) *100/ $patient->notes_total, 1) : '-'}}%</span>
                                     <div class="flex-grow-1 position-relative fill-bar">
-                                        <div class="bg-info position-absolute" style="left: 0; top: 0; height: 100%; width: {{($patient->notes_total - $patient->notes_without_claiming_closed) *100/$patient->notes_total}}%"></div>
+                                        <div class="bg-info position-absolute" style="left: 0; top: 0; height: 100%; width: {{ $patient->notes_total ? ($patient->notes_total - $patient->notes_without_claiming_closed ) * 100 / $patient->notes_total : '-'}}%"></div>
                                     </div>
                                 </div>
                             </td>

+ 2 - 2
resources/views/layouts/patient.blade.php

@@ -161,9 +161,9 @@
                             <a class="nav-link {{ strpos($routeName, 'patients.view.pros') === 0 ? 'active' : '' }}"
                                href="{{ route('patients.view.pros', ['patient' => $patient]) }}">Pros</a>
                         </li>
-                        {{--<li class="nav-item">
+                        <li class="nav-item">
                             <a class="nav-link" href="/patients/view/{{ $patient->uid }}/intake">Intake</a>
-                        </li>--}}
+                        </li>
                         @if($performer->pro->pro_type == 'ADMIN')
                         <li class="nav-item">
                             <a class="nav-link {{ strpos($routeName, 'patients.view.mcp-requests') === 0 ? 'active' : '' }}"

+ 1 - 0
resources/views/layouts/template.blade.php

@@ -115,6 +115,7 @@
                         <a class="dropdown-item" href="{{ route('practice-management.proCalendar') }}">Pro Calendar</a>
 
                         <a class="dropdown-item" href="{{ route('practice-management.billingManager') }}">Billing Manager</a>
+                        <a class="dropdown-item" href="{{ route('practice-management.billing-report') }}">Billing Report</a>
 
                         @if($pro && $pro->pro_type == 'ADMIN')
                             <a class="dropdown-item" href="{{ route('practice-management.processingBillMatrix') }}">Processing Bills</a>

+ 3 - 0
routes/web.php

@@ -96,6 +96,9 @@ Route::middleware('pro.auth')->group(function () {
 
         Route::middleware('pro.auth.admin')->group(function(){
 
+            // BILLING REPORT
+            Route::get('billing-report', 'PracticeManagementController@billingReport')->name('billing-report');
+
             Route::get('patient-claim-summary/{proUid?}', 'PracticeManagementController@patientClaimSummary')->name('patientClaimSummary');
 
             Route::get('cellular-measurements', 'PracticeManagementController@cellularMeasurements')->name('cellularMeasurements');