Browse Source

RPM matrix tree

Vijayakrishnan 3 years ago
parent
commit
3425501885

+ 13 - 1
app/Http/Controllers/PracticeManagementController.php

@@ -1408,6 +1408,18 @@ WHERE care_month.uid = '{$careMonthUid}' AND client.uid = '{$clientUid}'
             $conditions[] = "(care_month.{$field} {$o} {$v})";
         }
 
+        $proTypeCondition = '';
+        switch($mode) {
+            case 'mcp':
+                $proTypeCondition = "care_month.mcp_pro_id = {$performer->pro->id}";
+                break;
+            case 'rmm':
+                $proTypeCondition = "care_month.rmm_pro_id = {$performer->pro->id}";
+            case 'rme':
+                $proTypeCondition = "care_month.rme_pro_id = {$performer->pro->id}";
+                break;
+        }
+
         $query = "
 SELECT client.name_first, client.name_last,
        (client.name_first || ' ' || client.name_last) as client_name,
@@ -1456,7 +1468,7 @@ FROM care_month join client on care_month.client_id = client.id join note mrnote
               n.effective_dateest::date < (care_month.start_date::date + INTERVAL '1 month')
      )
 WHERE
-      (care_month.mcp_pro_id = {$performer->pro->id} OR care_month.rmm_pro_id = {$performer->pro->id})
+      $proTypeCondition
       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) : '') . "

+ 8 - 3
app/Http/Controllers/StatTreeController.php

@@ -364,7 +364,7 @@ class StatTreeController extends Controller
         return $content;
     }
 
-    private function applyStatTreeLineQueryClauses(StatTreeLine $statTreeLine, $proUid = false)
+    private function applyStatTreeLineQueryClauses(StatTreeLine $statTreeLine, $proUid = false, $allInputs = [])
     {
         $model = $statTreeLine->statTree->model;
         $clauses = [];
@@ -381,6 +381,11 @@ class StatTreeController extends Controller
                     }
                 }
 
+                // if override available - replace with that
+                if(@$allInputs['st__' . $clauseArg->arg_text]) {
+                    $value = $allInputs['st__' . $clauseArg->arg_text];
+                }
+
                 if(!is_null($value)) {
                     $clauseText = str_replace(
                         ':' . $clauseArg->arg_text,                         // search for :xxx
@@ -488,7 +493,7 @@ class StatTreeController extends Controller
         // refresh counts
         $lines = $statTree->lines;
         foreach ($lines as $line) {
-            $query = $this->applyStatTreeLineQueryClauses($line, $request->input('proUid'));
+            $query = $this->applyStatTreeLineQueryClauses($line, $request->input('proUid'), $request->input());
             if ($query && $query !== 'error') {
                 $line->last_refresh_count = $query[0]->count;
             }
@@ -583,7 +588,7 @@ class StatTreeController extends Controller
             "text" => '<span class="stat-tree-anchor">' .
                 '<span class="text-secondary text-sm">' . ($line->tree_order_position_index + 1) . '.</span> ' .
                 $line->displayLabel() . '</span>' .
-                (count($argsLabel) ? '<span class="text-info text-sm ml-2">[' . implode(', ', $argsLabel) . ']</span>' : '') .
+                (count($argsLabel) ? '<span class="arg-label text-info text-sm ml-2">[' . implode(', ', $argsLabel) . ']</span>' : '') .
                 '<span class="ml-2 text-secondary line-count-label">(' .
                 (is_null($line->last_refresh_count) ? '…' :
                     ($line->last_refresh_count === -1 ?

+ 1 - 1
config/app.php

@@ -65,7 +65,7 @@ return [
 
     'hrm2_url' => env('HRM2_URL'),
 
-    'asset_version' => 83,
+    'asset_version' => 84,
 
     'temp_dir' => env('TEMP_DIR'),
 

+ 11 - 0
public/css/style.css

@@ -457,6 +457,9 @@ body>nav.navbar {
 .mcp-theme-1 .max-width-700px {
     max-width: 700px !important;
 }
+.mcp-theme-1 .min-width-1100px {
+    min-width: 1100px !important;
+}
 .mcp-theme-1 .width-100px {
     width: 100px;
     min-width: unset !important;
@@ -2950,6 +2953,14 @@ table.stag-compact-grid>tbody>tr>td [if-grid-view] {
     text-decoration: none;
 }
 
+.stat-tree-summary-view .stat-tree-anchor {
+    color: #212529 !important;
+    text-decoration: none;
+}
+.stat-tree-summary-view .arg-label {
+    display: none;
+}
+
 /* jstree overrides */
 .stat-tree-view .jstree-wholerow {
     border-bottom: 1px solid #f1f1f1;

+ 9 - 6
resources/views/app/practice-management/rpm-matrix-by-pro-type.blade.php

@@ -36,11 +36,11 @@
             padding: 0.5rem;
         }
     </style>
-    <div class="p-3 mcp-theme-1" id="practice-remote-monitoring" v-cloak>
+    <div class="p-3 mcp-theme-1 body-height" id="practice-remote-monitoring" v-cloak>
 
-        <div class="card">
+        <div class="card h-100">
 
-            <div class="card-header px-2 py-2 d-flex align-items-baseline overflow-hidden">
+            <div class="card-header px-2 py-2 d-flex align-items-baseline">
                 <form class="d-block w-100" action="" method="GET">
 
                     <div class="d-flex align-items-baseline">
@@ -246,8 +246,11 @@
             <?php $rc = request()->input('rc') ? request()->input('rc') : 1; ?>
 
             <div class="card-body p-0">
-                <div class="d-flex align-items-start m-0">
-                    <div class="flex-grow-1 px-0">
+                <div class="d-flex align-items-stretch m-0 h-100">
+                    <div class="overflow-auto border-right h-100">
+                        @include('app.stat-tree.summary', ['slug' => 'rm-tree-' . $mode, 'showForPro' => $pro, 'noDropVisualize' => true, 'stParams' => ['start_date' => $rcmStartDate]])
+                    </div>
+                    <div class="flex-grow-1 px-0 overflow-auto h-100">
                         <?php $trIndex = 0; ?>
                         @foreach ($patients as $iPatient)
                             <script>
@@ -260,7 +263,7 @@
                             </script>
                             <?php $trIndex++; ?>
                         @endforeach
-                        <table class="table table-sm table-striped table-hover p-0 m-0" id="table-rm-matrix">
+                        <table class="table table-sm table-striped table-hover p-0 m-0 min-width-1100px" id="table-rm-matrix">
                             <thead class="bg-light">
                             <tr>
                             <!--<th class="border-0 pl-2">Name</th>

+ 161 - 0
resources/views/app/stat-tree/summary.blade.php

@@ -0,0 +1,161 @@
+{{-- resolve --}}
+@if(!@$statTree)
+    @if(!@$slug)
+        <div class="alert alert-danger m-0">Slug missing!</div>
+    @endif
+    <?php $statTree = \App\Models\StatTree::where('slug', $slug)->first(); ?>
+    @if(!@$statTree)
+        <div class="alert alert-danger m-0">Stat tree no found!</div>
+    @endif
+@endif
+<link rel="stylesheet" href="/jstree/themes/default/style.min.css" />
+<script src="/jstree/jstree.min.js"></script>
+<div class="bg-light font-weight-bold text-secondary border-bottom" style="padding: 0.3rem;">Summary</div>
+<div id="statTreeView-{{$statTree->id}}">
+    <div class="stat-tree-view stat-tree-user-view stat-tree-summary-view overflow-auto min-height-300px" id="stat-tree-view-{{$statTree->id}}"></div>
+</div>
+<script>
+    (function() {
+        function init() {
+
+            (function ($, undefined) {
+                "use strict";
+                $.jstree.plugins.noclose = function () {
+                    this.close_node = $.noop;
+                };
+            })(jQuery);
+
+            // stat tree
+            let StatTree = {
+                el: $('#stat-tree-view-{{$statTree->id}}'),
+                changed: false,
+
+                onSelected: function(_e, _data) {
+                    {{--@if(!@$reportTarget)
+                        openDynamicStagPopup('/practice-management/stat-tree-lines/view-data/' + _data.node.data.uid + '{{@$showForPro ? '?proUid=' . $showForPro->uid : ''}}',
+                            null,
+                            _data.node.data.displayLabel,
+                            false,
+                            'medium');
+                    @else
+                        $.get('/practice-management/stat-tree-lines/view-data/' + _data.node.data.uid + '{{@$showForPro ? '?proUid=' . $showForPro->uid : ''}}', _data => {
+                            $('{{$reportTarget}}').html(_data);
+                        });
+                    @endif--}}
+                },
+
+                load: function() {
+
+                    // destroy if existing
+                    try {
+                        this.el.jstree('destroy');
+                    }
+                    catch (e) {}
+
+                    this.el = $('#stat-tree-view-{{$statTree->id}}');
+
+                    // get data
+                    showMask();
+
+                    <?php
+                    $params = [];
+                    if(@$showForPro) $params[] = 'proUid=' . $showForPro->uid;
+                    if(@$stParams) {
+                        foreach ($stParams as $k => $v) {
+                            $params[] = 'st__' . $k . '=' . $v;
+                        }
+                    }
+                    $params = '?' . implode('&', $params);
+                    ?>
+
+                    $.get('{{ route('practice-management.statTrees.view.linesJSON', $statTree) }}{!! $params !!}', _data => {
+
+                        // init tree with data
+                        this.el
+                            .on('redraw.jstree', () => {
+                                @if(!@$noDropVisualize)
+                                    StatTree.dropVisualize();
+                                @endif
+                            })
+                            .on('select_node.jstree', (_e, _data) => { StatTree.onSelected(_e, _data); })
+                            .jstree({
+                                "core": {
+                                    "select": false,
+                                    "multiple": false,
+                                    "animation": 0,
+                                    'data': _data
+                                },
+                                "contextmenu": {
+                                    show_at_node: false,
+                                    items: function (node) {
+                                        if(node.data.type === 'stat_tree_line') { // stat_tree_line
+                                            return {
+                                                "data": {
+                                                    "label": "<span class='text-sm'>View Data</span>",
+                                                    "action": function (obj) {
+                                                        openDynamicStagPopup('/practice-management/stat-tree-lines/view-data/' + node.data.uid,
+                                                            null,
+                                                            node.data.displayLabel,
+                                                            false,
+                                                            'medium');
+                                                    }
+                                                },
+                                            }
+                                        }
+                                    },
+                                },
+                                "plugins": [
+                                    "wholerow",
+                                    //"contextmenu",
+                                    "noclose"
+                                ]
+                            });
+                    }, 'json').then(hideMask);
+                },
+
+                dropVisualize: function() {
+                    console.log('redrawn')
+                    function calculateDropPercent(node, parent = null) {
+                        let realNode = StatTree.el.jstree(true).get_node(node.id);
+                        if(!realNode.data) return;
+                        if(parent && parent.data.lastRefreshCount !== null) {
+                            if(node.data.lastRefreshCount !== null) {
+                                realNode.data.dropPercent = (((parent.data.lastRefreshCount - node.data.lastRefreshCount) / parent.data.lastRefreshCount) * 100);
+                                if(realNode.data.dropPercent) {
+                                    let element = StatTree.el.jstree(true).get_node(node.id, true), cssClass = '';
+                                    if(realNode.data.dropPercent > 75) {
+                                        cssClass = 'drop-76-100';
+                                    }
+                                    else if(realNode.data.dropPercent > 50 && realNode.data.dropPercent <= 75) {
+                                        cssClass = 'drop-51-75';
+                                    }
+                                    else if(realNode.data.dropPercent > 25 && realNode.data.dropPercent <= 50) {
+                                        cssClass = 'drop-26-50';
+                                    }
+                                    else if(realNode.data.dropPercent > 0 && realNode.data.dropPercent <= 25) {
+                                        cssClass = 'drop-0-25';
+                                    }
+                                    element.find('>a.jstree-anchor')
+                                        .addClass('has-drop-visualization')
+                                        .addClass(cssClass)
+                                        .attr('data-drop-percent', (realNode.data.dropPercent.toFixed(1)) + '% ⤵');
+                                }
+                            }
+                        }
+                        for (let i = 0; i < node.children.length; i++) {
+                            calculateDropPercent(node.children[i], node);
+                        }
+                    }
+                    let raw = this.el.jstree('get_json');
+                    for (let i = 0; i < raw.length; i++) {
+                        calculateDropPercent(raw[i]);
+                    }
+                },
+            };
+
+            StatTree.load();
+
+        }
+        addMCInitializer('stat-tree-view-{{$statTree->id}}', init, '#statTreeView-{{$statTree->id}}');
+    }).call(window);
+</script>