Vijayakrishnan 3 роки тому
батько
коміт
0568d9f9ae

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

@@ -1072,6 +1072,75 @@ ORDER BY care_month.number_of_days_with_remote_measurements DESC NULLS LAST, cli
         return view('app.practice-management.remote-monitoring', compact('patients', 'daysRemaining', 'careMonthStart'));
     }
 
+    public function remoteMonitoringCount(Request $request) {
+
+        $performer = $this->performer();
+
+        $ym = ($request->input('y') ?: 'Y') . '-' . ($request->input('m') ?: 'm');
+        $careMonthStart = date($ym . '-01');
+
+        $rc = $request->input('rc') ?: 1;
+        $rc2 = $request->input('rc2') ?: 1;
+        $conditions = [];
+
+        $c_isMCP = "client.mcp_pro_id = {$performer->pro->id}";
+        $c_enrolledInRPM = "client.is_enrolled_in_rm = 'YES'";
+        $c_hasDevice = "(SELECT COUNT(client_bdt_device.id) FROM client_bdt_device JOIN bdt_device bd on client_bdt_device.device_id = bd.id WHERE client_bdt_device.client_id = client.id) > 0";
+        $c_lastVisitWithin90Days = "DATE_PART('day', client.most_recent_completed_mcp_note_date::timestamp - care_month.start_date::timestamp) <= 90";
+        $c_spokenToThisMonth = "care_month.has_anyone_interacted_with_client_about_rm_outside_note = TRUE";
+        $c_hasUnstamped = "care_month.rm_num_measurements_not_stamped_by_mcp > 0";
+        $c_hasNoUnstamped = "care_month.rm_num_measurements_not_stamped_by_mcp = 0";
+        $c_lt16MeasurementDays = "care_month.number_of_days_with_remote_measurements < 16";
+        $c_gte16MeasurementDays = "care_month.number_of_days_with_remote_measurements >= 16";
+        $c_subscribedToSMS = "client.send_sms_on_bdt_measurement = TRUE";
+        $c_deviceUsed = "(client.most_recent_cellular_bp_measurement_at IS NOT NULL OR most_recent_cellular_weight_measurement_at IS NOT NULL)";
+
+        switch ($rc) {
+            case 1:
+                $conditions = [$c_isMCP];
+                break;
+            case 2:
+                $conditions = [$c_isMCP, $c_enrolledInRPM];
+                break;
+            case 3:
+                $conditions = [$c_isMCP, $c_enrolledInRPM, $c_hasDevice];
+                break;
+            case 4:
+                $conditions = [$c_isMCP, $c_enrolledInRPM, $c_hasDevice, $c_lastVisitWithin90Days];
+                break;
+            case 5:
+                $conditions = [$c_isMCP, $c_enrolledInRPM, $c_hasDevice, $c_lastVisitWithin90Days, $c_spokenToThisMonth];
+                break;
+            case 6:
+                $conditions = [$c_isMCP, $c_enrolledInRPM, $c_hasDevice, $c_lastVisitWithin90Days, $c_spokenToThisMonth, ($rc2 == 1 ? $c_hasUnstamped : $c_hasNoUnstamped)];
+                break;
+            case 7:
+                $conditions = [$c_isMCP, $c_enrolledInRPM, $c_hasDevice, $c_lastVisitWithin90Days, $c_spokenToThisMonth, ($rc2 == 1 ? $c_lt16MeasurementDays : $c_gte16MeasurementDays)];
+                break;
+            case 8:
+                $conditions = [$c_isMCP, $c_enrolledInRPM, $c_subscribedToSMS];
+                break;
+            case 9:
+                $conditions = [$c_isMCP, $c_enrolledInRPM, $c_deviceUsed];
+                break;
+        }
+
+        $count = DB::select(
+            DB::raw(
+                "
+SELECT count(client.id)
+FROM care_month join client on care_month.client_id = client.id
+WHERE
+      client.mcp_pro_id = {$performer->pro->id}
+      AND EXTRACT(MONTH from care_month.start_date) = " . ($request->input('m') ?: 'EXTRACT(MONTH from now())') . "
+      AND EXTRACT(YEAR from care_month.start_date) = " . ($request->input('y') ?: 'EXTRACT(YEAR from now())') . "
+      " . (count($conditions) > 0 ? 'AND ' . implode(" AND ", $conditions) : '')
+            )
+        );
+
+        return $count[0]->count;
+    }
+
     public function remoteMonitoringMeasurements(Request $request, CareMonth $careMonth) {
 
         $performer = $this->performer();

+ 48 - 1
public/css/style.css

@@ -2637,5 +2637,52 @@ body.stag-scrollbar-scrolling .stag-scrollbar[stag-h-scrollbar] .stag-scrollbar-
     padding: 3px 5px;
 }
 .conditions-tree .condition-children {
-    padding-left: 1rem;
+    padding-left: 22px;
+    margin-left: -4px;
+    margin-top: -10px;
+    padding-top: 10px;
+}
+
+/* tree lines CSS */
+.conditions-tree {
+    margin-left: 10px;
+}
+.conditions-tree .condition {
+    position: relative;
+}
+.conditions-tree .condition>a {
+    position: relative;
+    display: block;
+    padding-left: 9px;
+    white-space: nowrap;
+    text-overflow: ellipsis;
+}
+.conditions-tree .condition>a:before {
+    position: absolute;
+    content: '';
+    left: -7px;
+    background: url(/img/node.png);
+    width: 8px;
+    height: 7px;
+    background-size: 100% 100%;
+    top: calc(50% - 4px);
+}
+.conditions-tree .condition-children .condition>a:after {
+    position: absolute;
+    content: '';
+    left: -92px;
+    border-top: 1px solid #aaa;
+    width: 90px;
+    top: calc(50% - 1px);
+}
+.conditions-tree .condition-children .condition>a>.rm-count:after {
+    position: absolute;
+    content: '';
+    left: -22px;
+    border-left: 1px solid #aaa;
+    height: 200px;
+    bottom: 50%;
+}
+.conditions-tree .condition-children {
+    overflow: hidden;
 }

BIN
public/img/node.png


+ 10 - 0
resources/views/app/dashboard-mcp.blade.php

@@ -301,6 +301,16 @@
                         <div class="col-md-6 mcp-theme-1">
                             <div id="mcp-dashboard-appointments" class="mb-4">
 
+                            </div>
+                            <div class="card mb-4">
+                                <div class="card-header pl-2">
+                                    <strong>
+                                        Remote Monitoring: {{friendly_month(date('Y-m-d'))}}
+                                    </strong>
+                                </div>
+                                <div class="card-body p-1">
+                                    @include('app.practice-management.remote-monitoring-tree')
+                                </div>
                             </div>
                             <div class="card mb-4">
                                 <div class="card-header pl-2">

+ 4 - 0
resources/views/app/patient/care-month/dashboard.blade.php

@@ -569,6 +569,7 @@
                                     @endif
                                 </div>
 
+                                @if($careMonth->mcp && $pro->id === $careMonth->mcp->id)
                                 <div class="mt-2">
                                     <?php
                                     $minsBilled = 0;
@@ -593,6 +594,7 @@
                                         @endif
                                         <span class="ml-1 text-secondary text-sm font-weight-normal">(20 needed)</span>
                                     </b>
+                                    @if($careMonth->number_of_days_with_remote_measurements >= 16)
                                     <div moe relative class="ml-2">
                                         <a href="#" start show class="text-sm">+ Entry</a>
                                         <form url="/api/careMonthEntry/createForRm" right>
@@ -621,7 +623,9 @@
                                             </div>
                                         </form>
                                     </div>
+                                    @endif
                                 </div>
+                                @endif
 
                                 @if(($daysDiff !== -1 && $daysDiff <= 90) &&
                                     $careMonth->number_of_days_with_remote_measurements >= 16 &&

+ 85 - 0
resources/views/app/practice-management/remote-monitoring-tree.blade.php

@@ -0,0 +1,85 @@
+<?php
+if(!@$rc) {
+    $rc = 0;
+}
+?>
+<div class="conditions-tree" id="remote-monitoring-tree">
+    <div class="condition">
+        <a href="{{route('practice-management.remote-monitoring')}}?rc=1"
+                {!! $rc == 1 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>Who am I the MCP for?
+            <span class="rm-count ml-1" data-rc="1"></span>
+        </a>
+        <div class="condition-children">
+            <div class="condition">
+                <a href="{{route('practice-management.remote-monitoring')}}?rc=2"
+                        {!! $rc == 2 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How many are enrolled in RPM?
+                    <span class="rm-count ml-1" data-rc="2"></span>
+                </a>
+                <div class="condition-children">
+                    <div class="condition">
+                        <a href="{{route('practice-management.remote-monitoring')}}?rc=3"
+                                {!! $rc == 3 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How many have been given a cellular device?
+                            <span class="rm-count ml-1" data-rc="3"></span>
+                        </a>
+                        <div class="condition-children">
+                            <div class="condition">
+                                <a href="{{route('practice-management.remote-monitoring')}}?rc=4"
+                                        {!! $rc == 4 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How many have I seen w/in 90 days?
+                                    <span class="rm-count ml-1" data-rc="4"></span>
+                                </a>
+                                <div class="condition-children">
+                                    <div class="condition">
+                                        <a href="{{route('practice-management.remote-monitoring')}}?rc=5"
+                                                {!! $rc == 5 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How many have I spoken to this month?
+                                            <span class="rm-count ml-1" data-rc="5"></span>
+                                        </a>
+                                        <div class="condition-children">
+                                            <div class="condition">
+                                                <a href="{{route('practice-management.remote-monitoring')}}?rc=6"
+                                                        {!! $rc == 6 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How many with unstamped measurements?
+                                                    <span class="rm-count ml-1" data-rc="6" data-rc-2="1"></span>
+                                                </a>
+                                            </div>
+                                            <div class="condition">
+                                                <a href="{{route('practice-management.remote-monitoring')}}?rc=7"
+                                                        {!! $rc == 7 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How many yet to hit 16 days?
+                                                    <span class="rm-count ml-1" data-rc="7" data-rc2="1"></span>
+                                                </a>
+                                            </div>
+                                        </div>
+                                    </div>
+                                </div>
+                            </div>
+                            <div class="condition">
+                                <a href="{{route('practice-management.remote-monitoring')}}?rc=8"
+                                        {!! $rc == 8 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>Home many have subscribed to SMS confirmation texts?
+                                    <span class="rm-count ml-1" data-rc="8"></span>
+                                </a>
+                            </div>
+                            <div class="condition">
+                                <a href="{{route('practice-management.remote-monitoring')}}?rc=9"
+                                        {!! $rc == 9 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How many have used the device?
+                                    <span class="rm-count ml-1" data-rc="9"></span>
+                                </a>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+<script>
+    (function() {
+        function init() {
+            $('#remote-monitoring-tree .rm-count').each(function() {
+                let params = '?rc=' + $(this).attr('data-rc');
+                if($(this).is('[data-rc2]')) params += '&rc2=' + $(this).attr('data-rc2');
+                $.get('{{route('practice-management.remote-monitoring-count')}}?' + params, _data => {
+                    $(this).text('(' + _data + ')');
+                });
+            });
+        }
+        addMCInitializer('remote-monitoring-tree', init, '#remote-monitoring-tree')
+    }).call(window);
+</script>

+ 6 - 44
resources/views/app/practice-management/remote-monitoring.blade.php

@@ -2,11 +2,11 @@
 
 @section('content')
 
-    <div class="p-3 mcp-theme-1" id="practice-billing-manager">
+    <div class="p-3 mcp-theme-1" id="practice-remote-monitoring">
 
         <div class="card">
 
-            <div class="card-header px-2 py-1 d-flex align-items-center">
+            <div class="card-header px-2 py-2 d-flex align-items-center">
                 <span class="mr-4">
                     <span class="font-size-14">Remote Monitoring</span>
                     <i class="fas fa-arrow-right text-sm mx-1"></i>
@@ -18,48 +18,10 @@
 
             <div class="card-body p-0">
                 <div class="row m-0">
-                    <div class="col-3 p-0">
-                        <div class="conditions-tree">
-                            <div class="condition">
-                                <a href="{{route('practice-management.remote-monitoring')}}?rc=1" {!! $rc == 1 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>Who am I the MCP for?</a>
-                                <div class="condition-children">
-                                    <div class="condition">
-                                        <a href="{{route('practice-management.remote-monitoring')}}?rc=2" {!! $rc == 2 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>Which of them is enrolled in RPM?</a>
-                                        <div class="condition-children">
-                                            <div class="condition">
-                                                <a href="{{route('practice-management.remote-monitoring')}}?rc=3" {!! $rc == 3 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>Which of them has been given a cellular device?</a>
-                                                <div class="condition-children">
-                                                    <div class="condition">
-                                                        <a href="{{route('practice-management.remote-monitoring')}}?rc=4" {!! $rc == 4 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>Which of them have I seen w/in 90 days?</a>
-                                                        <div class="condition-children">
-                                                            <div class="condition">
-                                                                <a href="{{route('practice-management.remote-monitoring')}}?rc=5" {!! $rc == 5 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>Which of them have I spoken to this month?</a>
-                                                                <div class="condition-children">
-                                                                    <div class="condition">
-                                                                        <a href="{{route('practice-management.remote-monitoring')}}?rc=6" {!! $rc == 6 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How am I doing regarding their stamping?</a>
-                                                                    </div>
-                                                                    <div class="condition">
-                                                                        <a href="{{route('practice-management.remote-monitoring')}}?rc=7" {!! $rc == 7 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How are they doing regarding hitting 16 days?</a>
-                                                                    </div>
-                                                                </div>
-                                                            </div>
-                                                        </div>
-                                                    </div>
-                                                    <div class="condition">
-                                                        <a href="{{route('practice-management.remote-monitoring')}}?rc=8" {!! $rc == 8 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>Which of them has subscribed to SMS confirmation texts?</a>
-                                                    </div>
-                                                    <div class="condition">
-                                                        <a href="{{route('practice-management.remote-monitoring')}}?rc=9" {!! $rc == 9 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>Which of them has used the device?</a>
-                                                    </div>
-                                                </div>
-                                            </div>
-                                        </div>
-                                    </div>
-                                </div>
-                            </div>
-                        </div>
+                    <div class="col-4 p-0">
+                        @include('app.practice-management.remote-monitoring-tree')
                     </div>
-                    <div class="col-9 border-left p-0">
+                    <div class="col-8 border-left p-0">
                         @if($rc == 6)
                             <?php $rc2 = request()->input('rc2') ? request()->input('rc2') : 1; ?>
                             <div class="d-flex align-items-baseline p-2 border-bottom">
@@ -126,7 +88,7 @@
                                         @endif
                                     </td>
                                     <td>
-                                        {{$iPatient->most_recent_cellular_weight_value ?: '-'}}
+                                        {{$iPatient->most_recent_cellular_weight_value ? round($iPatient->most_recent_cellular_weight_value, 1) : '-'}}
                                         @if($iPatient->most_recent_cellular_weight_measurement_at)
                                             <div class="text-sm text-secondary text-nowrap">{{friendly_date_time($iPatient->most_recent_cellular_weight_measurement_at)}}</div>
                                         @endif

+ 1 - 0
routes/web.php

@@ -301,6 +301,7 @@ Route::middleware('pro.auth')->group(function () {
         Route::get('supply-orders/unsigned', 'PracticeManagementController@supplyOrdersUnsigned')->name('supply-orders-unsigned');
 
         Route::get('remote-monitoring', 'PracticeManagementController@remoteMonitoring')->name('remote-monitoring');
+        Route::get('remote-monitoring-count', 'PracticeManagementController@remoteMonitoringCount')->name('remote-monitoring-count');
 
 
         //stat tree stuff