= 4 rokov pred
rodič
commit
c771c514cd

+ 32 - 0
app/Helpers/helpers.php

@@ -61,6 +61,38 @@ if(!function_exists('friendly_date_time_short_with_tz')) {
     }
 }
 
+if(!function_exists('friendly_date_time_short_with_tz_from_timestamp')) {
+    function friendly_date_time_short_with_tz_from_timestamp($value, $tz='UTC', $default = '-') {
+
+        if(!$value || empty($value)) return $default;
+        try {
+
+            $realTimezone = resolve_timezone($tz);
+            $date = new DateTime("@$value");
+            $date->setTimezone(new DateTimeZone($realTimezone));
+
+            return $date->format("m/d/y, h:iA");
+
+        }
+        catch (Exception $e) {
+            return $e->getMessage();
+        }
+    }
+}
+
+if(!function_exists('friendly_date')) {
+    function friendly_date($value) {
+        if(!$value || empty($value)) return '';
+        try {
+            $result = strtotime($value);
+            $result = date("m/d/Y", $result);
+            return $result;
+        }
+        catch (Exception $e) {
+            return $value;
+        }
+    }
+}
 
 if(!function_exists('unfriendly_date')) {
     function unfriendly_date($value) {

+ 36 - 23
app/Http/Controllers/PracticeManagementController.php

@@ -89,7 +89,7 @@ class PracticeManagementController extends Controller
                 $query = $query->where('is_signed_by_hcp', false);
                 break;
 
-                // more cases can be added as needed
+            // more cases can be added as needed
             default:
                 break;
         }
@@ -138,7 +138,7 @@ class PracticeManagementController extends Controller
                     });
                 break;
 
-                // more cases can be added as needed
+            // more cases can be added as needed
             default:
                 break;
         }
@@ -245,7 +245,7 @@ class PracticeManagementController extends Controller
         $startDate = date('Y-m-d', strtotime("sunday -1 week"));
         $endDateTime = new DateTime($startDate);
         $endDateTime->modify('+6 day');
-        $endDate =  $endDateTime->format("Y-m-d");
+        $endDate = $endDateTime->format("Y-m-d");
 
         $eventsData = $pro->getAvailabilityEvents($startDate, $endDate);
         $events = json_encode($eventsData);
@@ -295,14 +295,16 @@ class PracticeManagementController extends Controller
     }
 
     // check video page
-    public function checkVideo(Request $request, $uid) {
+    public function checkVideo(Request $request, $uid)
+    {
         $session = AppSession::where('session_key', $request->cookie('sessionKey'))->first();
         $client = !empty($uid) ? Client::where('uid', $uid)->first() : null;
         $publish = false;
         return view('app.video.check-video-minimal', compact('session', 'client'));
     }
 
-    public function getParticipantInfo(Request $request) {
+    public function getParticipantInfo(Request $request)
+    {
         $sid = intval($request->get('uid')) - 1000000;
         $session = AppSession::where('id', $sid)->first();
         $result = [
@@ -382,27 +384,38 @@ class PracticeManagementController extends Controller
         return view('app.practice-management.calendar', compact('pros'));
     }
 
-    public function cellularDeviceManager(Request $request, $proUid = null){
+    public function cellularDeviceManager(Request $request, $proUid = null)
+    {
         $proUid = $proUid ? $proUid : $request->get('pro-uid');
         $performerPro = $this->performer->pro;
         $targetPro = null;
         $allPros = [];
         $expectedForHcp = null;
-        if($performerPro->pro_type == 'ADMIN'){
+        if ($performerPro->pro_type == 'ADMIN') {
             $allPros = Pro::all();
             $targetPro = Pro::where('uid', $proUid)->first();
-        }else{
+        } else {
             $targetPro = $performerPro;
         }
         $clients = [];
-        if($targetPro){
+        if ($targetPro) {
             $clients = Client::where('mcp_pro_id', $targetPro->id)->orderBy('created_at', 'desc')->paginate(100);
-        }else{
+        } else {
             $clients = Client::orderBy('created_at', 'desc')->paginate(100);
         }
         return view('app.practice-management.cellular-device-manager', compact('clients', 'allPros', 'targetPro', 'proUid'));
     }
 
+    public function treatmentServiceUtil(Request $request){
+        $view_treatment_service_utilization_org = DB::select(DB::raw("SELECT * FROM view_treatment_service_utilization_org ORDER BY effective_date DESC"));
+        $view_treatment_service_utilization = DB::select(DB::raw("SELECT * FROM view_treatment_service_utilization ORDER BY effective_date DESC, total_hrs DESC"));
+        $view_treatment_service_utilization_by_patient = DB::select(DB::raw("SELECT * FROM view_treatment_service_utilization_by_patient ORDER BY pro_lname ASC, pro_fname ASC, hcp_pro_id ASC, total_hrs DESC"));
+        return view('app.practice-management.treatment-services-util', compact(
+            'view_treatment_service_utilization_org',
+            'view_treatment_service_utilization',
+            'view_treatment_service_utilization_by_patient'));
+    }
+
     public function hcpBillMatrix(Request $request, $proUid = null)
     {
         $proUid = $proUid ? $proUid : $request->get('pro-uid');
@@ -410,18 +423,17 @@ class PracticeManagementController extends Controller
         $targetPro = null;
         $allPros = [];
         $expectedForHcp = null;
-        if($performerPro->pro_type == 'ADMIN'){
+        if ($performerPro->pro_type == 'ADMIN') {
             $allPros = Pro::all();
             $targetPro = Pro::where('uid', $proUid)->first();
-        }else{
+        } else {
             $targetPro = $performerPro;
         }
         $bills = [];
-        if($targetPro){
-            $expectedForHcp = DB::select(DB::raw("SELECT coalesce(SUM(hcp_expected_payment_amount),0) as expected_pay FROM bill WHERE hcp_pro_id = :targetProID  AND is_signed_by_hcp IS TRUE AND is_cancelled = false"), ['targetProID' => $targetPro->id])[0]->expected_pay;
-            $bills = Bill::where('hcp_pro_id', $targetPro->id)->orderBy('created_at', 'desc')->paginate(500);
-        }else{
-            $bills = Bill::orderBy('created_at', 'desc')->paginate(500);
+        if ($targetPro) {
+            $rows = DB::select(DB::raw("SELECT * FROM aemish_bill_report WHERE hcp_pro_id = :targetProID"), ['targetProID' => $targetPro->id]);
+        } else {
+            $rows = DB::select(DB::raw("SELECT * FROM aemish_bill_report"));
         }
         return view('app.practice-management.hcp-bill-matrix', compact('bills', 'allPros', 'expectedForHcp', 'targetPro', 'proUid'));
     }
@@ -433,17 +445,17 @@ class PracticeManagementController extends Controller
         $targetPro = null;
         $allPros = [];
         $expectedForHcp = null;
-        if($performerPro->pro_type == 'ADMIN'){
+        if ($performerPro->pro_type == 'ADMIN') {
             $allPros = Pro::all();
             $targetPro = Pro::where('uid', $proUid)->first();
-        }else{
+        } else {
             $targetPro = $performerPro;
         }
         $notes = [];
-        if($targetPro){
+        if ($targetPro) {
             $expectedForHcp = DB::select(DB::raw("SELECT coalesce(SUM(hcp_expected_payment_amount),0) as expected_pay FROM bill WHERE hcp_pro_id = :targetProID  AND is_signed_by_hcp IS TRUE AND is_cancelled = false"), ['targetProID' => $targetPro->id])[0]->expected_pay;
             $notes = Note::where('hcp_pro_id', $targetPro->id)->orderBy('effective_dateest', 'desc')->paginate();
-        }else{
+        } else {
             $notes = Note::orderBy('effective_dateest', 'desc')->paginate();
         }
         return view('app.practice-management.billing-manager', compact('notes', 'allPros', 'expectedForHcp', 'targetPro', 'proUid'));
@@ -456,14 +468,15 @@ class PracticeManagementController extends Controller
     }
 
     // Generate PDF
-    public function downloadClaims() {
+    public function downloadClaims()
+    {
         $claims = Claim::where('was_submitted', false)->orWhere('was_submitted', null)->orderBy('created_at', 'desc')->limit(100)->get();
         view()->share('claims', $claims);
 
         $pdf = PDF::loadView('app.practice-management.claims-pdf', $claims);
 
         return $pdf->download('pdf_file.pdf');
-      }
+    }
 
     public function tickets(Request $request, $proUid = null)
     {

+ 8 - 1
resources/views/app/patient/measurements.blade.php

@@ -42,7 +42,14 @@
                     @if(!empty($measurement->label))
                         @if(!in_array($measurement->label, ["SBP", "DBP"]))
                         <tr>
-                            <td class="px-2">{{ friendly_date_time($measurement->effective_date) }}</td>
+                            <td class="px-2">
+                                @if($measurement->client_bdt_measurement_id)
+                                    <?php $timestampInSec = floor($measurement->bdt_measurement_timestamp/1000); ?>
+                                    {{ friendly_date_time_short_with_tz_from_timestamp($timestampInSec, 'EASTERN') }}
+                                @else
+                                    {{ friendly_date_time_short_with_tz($measurement->effective_date, true, 'EASTERN') }} 
+                                @endif
+                            </td>
                             <td class="px-2">{{ $measurement->label }}</td>
                             <td class="px-2">
                                 @if(empty($measurement->client_bdt_measurement_id))

+ 8 - 10
resources/views/app/practice-management/hcp-bill-matrix.blade.php

@@ -11,7 +11,6 @@
                     <i class="fas fa-user-injured"></i>
                     HCP Bill Matrix
                 </strong>
-
                 <select class="ml-auto max-width-300px form-control form-control-sm"
                         onchange="fastLoad('/practice-management/hcp-bill-matrix/' + this.value, true, false, false)">
                     <option value="" {{ $proUid === '' ? 'selected' : '' }}>All Pros</option>
@@ -49,22 +48,21 @@
                     </tr>
                     </thead>
                     <tbody>
-                    @foreach ($bills as $bill)
-                        <?php $note = $bill->note; ?>
-                        <?php if(!$note) { continue; } ?>
+                    @foreach ($rows as $row)
                         <tr class="">
-
                             <td class="">
-                                <a href="/patients/view/{{ $note->client->uid }}/notes/view/{{ $note->uid }}">{{ $note->client->displayName() }}</a>
+                                <a href="/patients/view/{{ $row->client_uid }}/notes/view/{{ $row->note_uid }}">
+                                    {{ $row->client->name_last . ', ', $row->name_first }}
+                                </a>
                             </td>
                             <td class="">
-                                <a href="/patients/view/{{ $note->client->uid }}/notes/view/{{ $note->uid }}"
+                                <a href="/patients/view/{{ $row->client_uid }}/notes/view/{{ $row->note_uid }}"
                                    class="font-weight-bold">
-                                    {{ friendly_date_time($note->effective_dateest, false) }}
+                                    {{ friendly_date_time($row->effective_dateest, false) }}
                                 </a>
-                                <span class="ml-1">{{ $note->is_cancelled ? '[cancelled]' : '' }}</span>
+                                <span class="ml-1">{{ $row->is_note_cancelled ? '[cancelled]' : '' }}</span>
                             </td>
-                            <td>{{$note->hcpPro->name_first}} {{$note->hcpPro->name_first}}</td>
+                            <td>{{$row->hcpPro->name_first}} {{$note->hcpPro->name_first}}</td>
                             <td>{{$note->is_signed_by_hcp?'Yes':'No'}}</td>
 
 

+ 109 - 0
resources/views/app/practice-management/treatment-services-util.blade.php

@@ -0,0 +1,109 @@
+@extends ('layouts/template')
+
+@section('content')
+    <style>
+        .report-table-header {
+            font-size: large;
+            font-weight: bolder;
+        }
+    </style>
+    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.23/css/jquery.dataTables.css">
+    <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.23/js/jquery.dataTables.js"></script>
+    <div class="p-3 mcp-theme-1">
+
+        <div class="card">
+            <div class="card-body">
+                <h1 class="report-table-header">Treatment Service Utilization - Org.</h1>
+                <table class="table table-bordered table-striped table-sm" id="table0">
+                    <thead>
+                    <tr>
+                        <th>Date</th>
+                        <th>Total hrs.</th>
+                    </tr>
+                    </thead>
+                    <tbody>
+                    <?php
+                    $dowMap = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
+                    ?>
+                    @foreach($view_treatment_service_utilization_org as $x)
+                        <tr>
+                            <td>
+                                {{$x->effective_date}} ---
+                                {{ $dowMap[date('w', strtotime($x->effective_date))] }}
+                            </td>
+                            <td>{{$x->total_hrs}}</td>
+                        </tr>
+                    @endforeach
+                    </tbody>
+                </table>
+            </div>
+        </div>
+
+        <div class="card mt-4">
+            <div class="card-body">
+                <h1 class="report-table-header">Treatment Service Utilization</h1>
+                <table class="table table-bordered table-striped table-sm" id="table1">
+                    <thead>
+                    <tr>
+                        <th>HCP</th>
+                        <th>Date</th>
+                        <th>Total hrs.</th>
+                    </tr>
+                    </thead>
+                    <tbody>
+                    @foreach($view_treatment_service_utilization as $x)
+                        <tr>
+                            <td>{{$x->name_last}}, {{$x->name_first}}</td>
+                            <td>
+                                {{$x->effective_date}} ---
+                                {{ $dowMap[date('w', strtotime($x->effective_date))] }}
+                            </td>
+                            <td>{{$x->total_hrs}}</td>
+                        </tr>
+                    @endforeach
+                    </tbody>
+                </table>
+            </div>
+        </div>
+
+        <div class="card mt-4">
+            <div class="card-body">
+                <h1 class="report-table-header">Treatment Service Utilization By Patient</h1>
+                <table class="table table-bordered table-striped table-sm" id="table2">
+                    <thead>
+                    <tr>
+                        <th>HCP</th>
+                        <th>Pt.</th>
+                        <th>Total hrs.</th>
+                    </tr>
+                    </thead>
+                    <tbody>
+                    @foreach($view_treatment_service_utilization_by_patient as $x)
+                        <tr>
+                            <td>
+                                {{$x->pro_lname}}, {{$x->pro_fname}}
+                            </td>
+                            <td>
+                                <a href="{{route('patients.view.notes', $x->pt_uid)}}">
+                                    {{$x->pt_lname}}, {{$x->pt_fname}}
+                                </a>
+                            </td>
+                            <td>{{$x->total_hrs}}</td>
+                        </tr>
+                    @endforeach
+                    </tbody>
+                </table>
+            </div>
+        </div>
+    </div>
+
+    <script>
+        $(document).ready( function () {
+            setTimeout(function(){
+                $('#table1').DataTable();
+                $('#table2').DataTable();
+            }, 3000);
+        } );
+    </script>
+
+@endsection

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

@@ -119,6 +119,7 @@
                             <a class="dropdown-item" href="{{ route('practice-management.cellularDeviceManager') }}">Cellular Device Manager</a>
                             <a class="dropdown-item" href="{{ route('practice-management.claims') }}">Claims</a>
                             <a class="dropdown-item" href="{{ route('practice-management.hcpBillMatrix') }}">HCP Bill Matrix</a>
+                            <a class="dropdown-item" href="{{ route('practice-management.treatmentServiceUtil') }}">Treatment Service Util.</a>
                             <a class="dropdown-item" href="/practice-management/tickets">Tickets</a>
                         @endif
                     </div>

+ 2 - 0
routes/web.php

@@ -94,6 +94,8 @@ Route::middleware('pro.auth')->group(function () {
             Route::get('claims', 'PracticeManagementController@claims')->name('claims');
             Route::get('claims-download', 'PracticeManagementController@downloadClaims')->name('download-claims');
 
+            Route::get('treatment-service-util', 'PracticeManagementController@treatmentServiceUtil')->name('treatmentServiceUtil');
+
         });
     });