Prechádzať zdrojové kódy

NA is prompted by the UI for a billable signed note

Vijayakrishnan 3 rokov pred
rodič
commit
b0e1e3b5ec

+ 41 - 1
app/Http/Controllers/HomeController.php

@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
 use App\Lib\Backend;
 use App\Models\Appointment;
 use App\Models\AppSession;
+use App\Models\ClientProChange;
 use App\Models\ClientSMS;
 use App\Models\Facility;
 use App\Models\IncomingReport;
@@ -377,10 +378,49 @@ class HomeController extends Controller
             ->whereRaw('created_by_session_id IN (SELECT id FROM app_session where pro_id = ?)', [$performer->pro->id])
             ->count();
 
+        $newMCPAssociations = ClientProChange
+            ::where('new_pro_id', $performerProID)
+            ->where('responsibility_type', 'MCP')
+            ->whereNull('current_client_pro_change_decision_id')
+            ->get();
+
+        $newNAAssociations = ClientProChange
+            ::where('new_pro_id', $performerProID)
+            ->where('responsibility_type', 'DEFAULT_NA')
+            ->whereNull('current_client_pro_change_decision_id')
+            ->get();
+
+        $naBillableSignedNotes = DB::select(DB::raw("
+SELECT count(note.id) as na_billable_notes
+FROM note
+WHERE
+        note.is_signed_by_hcp = TRUE AND
+        note.ally_pro_id = :pro_id AND
+        note.is_cancelled = FALSE AND
+        (
+            SELECT count(bill.id) 
+            FROM bill 
+            WHERE 
+                  bill.is_cancelled = FALSE AND 
+                  bill.generic_pro_id = :pro_id AND 
+                  bill.note_id = note.id
+        ) = 0
+        "), ["pro_id" => $performerProID]);
+
+        if(!$naBillableSignedNotes || !count($naBillableSignedNotes)) {
+            $naBillableSignedNotes = 0;
+        }
+        else {
+            $naBillableSignedNotes = $naBillableSignedNotes[0]->na_billable_notes;
+        }
+
+        $keyNumbers['naBillableSignedNotes'] = $naBillableSignedNotes;
+
         return view('app/dashboard', compact('keyNumbers', 'reimbursement', 'milliseconds',
             'businessNumbers',
             'incomingReports', 'tickets', 'supplyOrders',
-            'numERx', 'numLabs', 'numImaging', 'numSupplyOrders'));
+            'numERx', 'numLabs', 'numImaging', 'numSupplyOrders',
+            'newMCPAssociations', 'newNAAssociations'));
     }
 
     public function dashboardMeasurementsTab(Request $request, $page = 1) {

+ 21 - 0
app/Http/Controllers/PracticeManagementController.php

@@ -129,6 +129,27 @@ class PracticeManagementController extends Controller
         return view('app.practice-management.notes', compact('notes', 'filter'));
     }
 
+    public function naBillableSignedNotes(Request $request)
+    {
+
+        $notes = Note
+            ::where('is_signed_by_hcp', TRUE)
+            ->where('ally_pro_id', $this->performer()->pro->id)
+            ->where('is_cancelled', FALSE)
+            ->whereRaw("
+            (
+                SELECT count(bill.id) 
+                FROM bill WHERE 
+                      bill.is_cancelled = FALSE AND 
+                      bill.generic_pro_id = {$this->performer()->pro->id} AND 
+                      bill.note_id = note.id
+            ) = 0
+            ");
+
+        $notes = $notes->orderBy('created_at', 'desc')->get();
+        return view('app.practice-management.na-billable-signed-notes', compact('notes'));
+    }
+
     public function bills(Request $request, $filter = '')
     {
         $proID = $this->performer()->pro->id;

+ 15 - 0
app/Models/ClientProChange.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Relations\HasMany;
+use Illuminate\Database\Eloquent\Relations\HasOne;
+
+class ClientProChange extends Model
+{
+    protected $table = 'client_pro_change';
+
+    public function patient(){
+        return $this->hasOne(Client::class, 'id', 'client_id');
+    }
+}

+ 8 - 0
resources/views/app/dashboard.blade.php

@@ -74,6 +74,14 @@
                                         <a href="/patients/having-birthday-today">Patients having birthday today</a>
                                     </th>
                                 </tr>
+                                @if(@$keyNumbers['naBillableSignedNotes'])
+                                    <tr>
+                                        <th class="px-2 text-center">{{$keyNumbers['naBillableSignedNotes']}}</th>
+                                        <th class="pl-2">
+                                            <a href="/practice-management/na-billable-signed-notes">Billable signed notes</a>
+                                        </th>
+                                    </tr>
+                                @endif
                             </tbody>
                         </table>
                     </div>

+ 57 - 0
resources/views/app/practice-management/na-billable-signed-notes.blade.php

@@ -0,0 +1,57 @@
+@extends ('layouts/template')
+
+@section('content')
+
+    <div 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>
+                Billable Signed Notes ({{count($notes)}})
+            </strong>
+        </div>
+        <div class="card-body p-0">
+
+            <table class="table table-sm table-condensed p-0 m-0">
+                <thead class="bg-light">
+                <tr>
+                    <th class="px-3 border-0">Created</th>
+                    <th class="border-0">Effective Date</th>
+                    <th class="border-0">Patient</th>
+                    <th class="border-0 w-50">Content</th>
+                </tr>
+                </thead>
+                <tbody>
+                @foreach ($notes as $note)
+                    <tr class="{{ $note->is_cancelled ? 'cancelled-item always-clickable' : '' }}">
+                        <td class="px-3">
+                            {{ friendly_date_time($note->created_at, true) }}
+                        </td>
+                        <td class="">
+                            <a href="/patients/view/{{ $note->client->uid }}/notes/view/{{ $note->uid }}" class="font-weight-bold">
+                                {{ friendly_date_time($note->effective_dateest, false) }}
+                            </a>
+                            <span class="ml-1">{{ $note->is_cancelled ? '[cancelled]' : '' }}</span>
+                        </td>
+                        <td class="">
+                            <a href="/patients/view/{{ $note->client->uid }}">{{ $note->client->displayName() }}</a>
+                        </td>
+                        <td class="">
+                            <?php
+                            $textContent = strip_tags($note->free_text_html);
+                            if(strlen($textContent) > 200) {
+                                $textContent = substr($textContent, 0, 200) . '…';
+                            }
+                            ?>
+                            {!! empty($textContent) ? '-' : $textContent !!}
+                        </td>
+                    </tr>
+                @endforeach
+                </tbody>
+            </table>
+        </div>
+    </div>
+    </div>
+
+@endsection

+ 1 - 0
routes/web.php

@@ -82,6 +82,7 @@ Route::middleware('pro.auth')->group(function () {
         Route::get('w9', 'PracticeManagementController@w9')->name('w9');
         Route::get('contract', 'PracticeManagementController@contract')->name('contract');
         Route::get('notes/{filter?}', 'PracticeManagementController@notes')->name('notes');
+        Route::get('na-billable-signed-notes/{filter?}', 'PracticeManagementController@naBillableSignedNotes')->name('na-billable-signed-notes');
         Route::get('bills/{filter?}', 'PracticeManagementController@bills')->name('bills');
         Route::get('unacknowledged-cancelled-bills', 'PracticeManagementController@unacknowledgedCancelledBills')->name('unacknowledged-cancelled-bills');
         Route::get('my-tickets/{filter?}', 'PracticeManagementController@myTickets')->name('myTickets');