Ver código fonte

Merge branch 'dev' of rav.triplestart.com:jmudaka/stagfe2 into dev

= 3 anos atrás
pai
commit
df0a42755f
42 arquivos alterados com 2208 adições e 328 exclusões
  1. 6 0
      app/Helpers/helpers.php
  2. 13 0
      app/Http/Controllers/AdminController.php
  3. 267 10
      app/Http/Controllers/PracticeManagementController.php
  4. 8 3
      app/Http/Controllers/StatTreeController.php
  5. 6 0
      app/Models/Client.php
  6. 22 0
      app/Models/ClientCarePlanFlagUpdate.php
  7. 5 0
      app/Models/SupplyOrder.php
  8. 1 1
      config/app.php
  9. 29 4
      js-dev/option-list.js
  10. 47 8
      public/css/style.css
  11. 35 20
      resources/views/app/admin/patients_missing_defsult_settings_filters.blade.php
  12. 1 1
      resources/views/app/patient/care-month/dashboard.blade.php
  13. 2 2
      resources/views/app/patient/note/_create-claim.blade.php
  14. 2 2
      resources/views/app/patient/note/dashboard.blade.php
  15. 200 0
      resources/views/app/patient/note/flag-care-plan.blade.php
  16. 63 0
      resources/views/app/patient/note/partials/care-plan-flags-history.blade.php
  17. 190 195
      resources/views/app/patient/note/rm-setup.blade.php
  18. 49 54
      resources/views/app/patient/partials/client_bp_weight_phone_number_status.blade.php
  19. 6 4
      resources/views/app/patient/partials/rm-reasons-display.blade.php
  20. 44 3
      resources/views/app/patient/segment-templates/biopsychosocial_assessment/edit.blade.php
  21. 30 0
      resources/views/app/patient/segment-templates/biopsychosocial_assessment/point-log.blade.php
  22. 35 1
      resources/views/app/patient/segment-templates/medication_comments/edit.blade.php
  23. 25 1
      resources/views/app/patient/segment-templates/medication_comments/summary.blade.php
  24. 42 0
      resources/views/app/patient/segment-templates/medication_comments_followup/edit.blade.php
  25. 30 0
      resources/views/app/patient/segment-templates/medication_comments_followup/summary.blade.php
  26. 4 0
      resources/views/app/patient/segment-templates/medication_response/edit.blade.php
  27. 3 0
      resources/views/app/patient/segment-templates/medication_response/summary.blade.php
  28. 60 0
      resources/views/app/patient/segment-templates/psych_plan_free_text_followup/edit.blade.php
  29. 24 0
      resources/views/app/patient/segment-templates/psych_plan_free_text_followup/summary.blade.php
  30. 30 4
      resources/views/app/patient/segment-templates/psych_risk_assessment/edit.blade.php
  31. 23 3
      resources/views/app/patient/segment-templates/psych_vitals/edit.blade.php
  32. 2 0
      resources/views/app/patient/segment-templates/psych_vitals/summary.blade.php
  33. 5 0
      resources/views/app/patient/shipments.blade.php
  34. 2 2
      resources/views/app/patient/vitals-settings/bp-management-summary.blade.php
  35. 7 9
      resources/views/app/practice-management/_sort_header.blade.php
  36. 18 0
      resources/views/app/practice-management/remote-monitoring-row-by-pro-type.blade.php
  37. 269 0
      resources/views/app/practice-management/remote-monitoring-row-markup-by-pro-type.blade.php
  38. 425 0
      resources/views/app/practice-management/rpm-matrix-by-pro-type.blade.php
  39. 1 0
      resources/views/app/rm-bills/inline.blade.php
  40. 161 0
      resources/views/app/stat-tree/summary.blade.php
  41. 9 1
      resources/views/layouts/template.blade.php
  42. 7 0
      routes/web.php

+ 6 - 0
app/Helpers/helpers.php

@@ -885,3 +885,9 @@ if(!function_exists('get_doc_templates')){
         return $templates;
     }
 }
+if(!function_exists('format_phone_number')) {
+    function format_phone_number($number, $default = '-') {     
+        if(empty($number)) return $default;   
+        return preg_replace('~.*(\d{3})[^\d]{0,7}(\d{3})[^\d]{0,7}(\d{4}).*~', '($1) $2-$3', $number). "\n";
+    }
+}

+ 13 - 0
app/Http/Controllers/AdminController.php

@@ -549,6 +549,19 @@ class AdminController extends Controller
             if($missing_default_settings === 'NO_MCP_COMPANY_LOCATION') $patients = $patients->whereNull('default_mcp_company_location_id');
         }
 
+        $care_plan = $request->get('care_plan');
+        if($care_plan){
+            if($care_plan === 'UNSIGNED_CARE_PLANS'){
+              $patients = $patients->whereHas('notes', function($noteQuery){ 
+                return $noteQuery->where('cm_setup_manager_signature_status', '!=', 'SIGNED');
+                });  
+            }
+            if($care_plan === 'UNCLEARED_CARE_PLANS'){
+                $patients = $patients->where('has_care_plan_flag', true)->where('is_flag_cleared', false);
+            }
+            
+        }
+
         $patients = $patients->orderBy('created_at', 'DESC')->paginate(50);
         return view('app.admin.patients_missing_default_settings', compact('patients', 'filters'));
     }

+ 267 - 10
app/Http/Controllers/PracticeManagementController.php

@@ -1166,11 +1166,11 @@ SELECT client.name_first, client.name_last,
        client.rmm_pro_id,
        client.rme_pro_id,
        client.cell_number,
-       client.most_recent_cellular_bp_dbp_mm_hg,
-       client.most_recent_cellular_bp_sbp_mm_hg,
-       client.most_recent_cellular_bp_measurement_at,      
-       client.most_recent_cellular_weight_value,
-       client.most_recent_cellular_weight_measurement_at
+       care_month.most_recent_cellular_bp_dbp_mm_hg,
+       care_month.most_recent_cellular_bp_sbp_mm_hg,
+       care_month.most_recent_cellular_bp_measurement_at,      
+       care_month.most_recent_cellular_weight_value,
+       care_month.most_recent_cellular_weight_measurement_at
 FROM care_month join client on care_month.client_id = client.id join note mrnote on client.most_recent_completed_mcp_note_id = mrnote.id
      left join note mrmnote on mrmnote.id = (
         select max(n.id) from note n 
@@ -1234,11 +1234,11 @@ SELECT client.name_first, client.name_last,
        client.rmm_pro_id,
        client.rme_pro_id,
        client.cell_number,
-       client.most_recent_cellular_bp_dbp_mm_hg,
-       client.most_recent_cellular_bp_sbp_mm_hg,
-       client.most_recent_cellular_bp_measurement_at,      
-       client.most_recent_cellular_weight_value,
-       client.most_recent_cellular_weight_measurement_at
+       care_month.most_recent_cellular_bp_dbp_mm_hg,
+       care_month.most_recent_cellular_bp_sbp_mm_hg,
+       care_month.most_recent_cellular_bp_measurement_at,      
+       care_month.most_recent_cellular_weight_value,
+       care_month.most_recent_cellular_weight_measurement_at
 FROM care_month join client on care_month.client_id = client.id join note mrnote on client.most_recent_completed_mcp_note_id = mrnote.id
      left join note mrmnote on mrmnote.id = (
         select max(n.id) from note n 
@@ -1257,6 +1257,263 @@ WHERE care_month.uid = '{$careMonthUid}' AND client.uid = '{$clientUid}'
         return view('app.practice-management.remote-monitoring-row', ['iPatient' => $patients[0], 'trIndex' => $request->input('trIndex')]);
     }
 
+    private function remoteMonitoring_RowByProType(Request $request, $mode) {
+
+        $clientUid = $request->input('clientUid');
+        $careMonthUid = $request->input('careMonthUid');
+
+        $query = "
+SELECT client.name_first, client.name_last,
+       (client.name_first || ' ' || client.name_last) as client_name,
+       client.uid as client_uid, 
+       client.dob,
+       client.is_enrolled_in_rm,
+       client.most_recent_completed_mcp_note_date,
+       client.most_recent_completed_mcp_note_id,
+       mrmnote.effective_dateest::date as most_recent_completed_mcp_note_date_cm,
+       mrmnote.id as most_recent_completed_mcp_note_id_cm,
+       mrmnote.uid as most_recent_completed_mcp_note_uid_cm,
+       client.cell_number,
+       client.is_assigned_cellular_bp_device,
+       client.is_assigned_cellular_weight_scale_device,
+       care_month.uid as care_month_uid,
+       care_month.id as care_month_id,
+       care_month.start_date,
+       care_month.rm_total_time_in_seconds_by_mcp,
+       care_month.rm_total_time_in_seconds_by_rmm_pro,
+       care_month.number_of_days_with_remote_measurements,
+       care_month.has_mcp_interacted_with_client_about_rm,
+       care_month.rm_num_measurements_not_stamped_by_mcp,
+       care_month.rm_num_measurements_not_stamped_by_non_hcp,
+       care_month.rm_num_measurements_not_stamped_by_rmm,
+       care_month.rm_num_measurements_not_stamped_by_rme,
+       care_month.mcp_pro_id as care_month_mcp_pro_id,
+       care_month.rmm_pro_id as care_month_rmm_pro_id,
+       client.mcp_pro_id,
+       client.default_na_pro_id,
+       client.rmm_pro_id,
+       client.rme_pro_id,
+       client.cell_number,
+       care_month.most_recent_cellular_bp_dbp_mm_hg,
+       care_month.most_recent_cellular_bp_sbp_mm_hg,
+       care_month.most_recent_cellular_bp_measurement_at,      
+       care_month.most_recent_cellular_weight_value,
+       care_month.most_recent_cellular_weight_measurement_at
+FROM care_month join client on care_month.client_id = client.id join note mrnote on client.most_recent_completed_mcp_note_id = mrnote.id
+     left join note mrmnote on mrmnote.id = (
+        select max(n.id) from note n 
+        where 
+              n.client_id = client.id AND 
+              n.is_cancelled = FALSE AND
+              (n.is_signed_by_hcp IS NOT NULL AND n.is_signed_by_hcp = TRUE) AND
+              n.effective_dateest::date >= care_month.start_date::date AND 
+              n.effective_dateest::date < (care_month.start_date::date + INTERVAL '1 month')
+     )
+WHERE care_month.uid = '{$careMonthUid}' AND client.uid = '{$clientUid}'
+";
+
+        $patients = DB::select($query);
+
+        return view('app.practice-management.remote-monitoring-row-by-pro-type', ['iPatient' => $patients[0], 'trIndex' => $request->input('trIndex'), 'mode' => $mode]);
+    }
+
+    private function rpmMatrixByProType(Request $request, $mode) {
+
+        $performer = $this->performer();
+
+        // abort_if($performer->pro->pro_type !== 'ADMIN' && !$performer->pro->can_view_rm_matrix, 403);
+
+        $ym = ($request->input('y') ?: 'Y') . '-' . ($request->input('m') ?: 'm');
+        $careMonthStart = date($ym . '-01');
+
+        $rc = $request->input('rc') ?: 1;
+        $rc2 = $request->input('rc2') ?: 2;
+
+        $conditions = [];// $this->rpmConditions($performer, $rc, $rc2);
+
+        $sortBy = $request->input('sort_by') ?: 'name_first';
+        $sortDir = $request->input('sort_dir') ?: 'ASC';
+        $orderBy = "ORDER BY $sortBy $sortDir NULLS LAST";
+
+        // filters from the UI
+        if(trim($request->input('f_name'))) {
+            $v = trim($request->input('f_name'));
+            $conditions[] = "(client.name_first ILIKE '%{$v}%' OR client.name_last ILIKE '%{$v}%')";
+        }
+        if(trim($request->input('f_dob_op')) && trim($request->input('f_dob'))) {
+            $o = trim($request->input('f_dob_op'));
+            $v = trim($request->input('f_dob'));
+            $conditions[] = "(client.dob {$o} '{$v}')";
+        }
+        if(trim($request->input('f_rpm'))) {
+            $v = trim($request->input('f_rpm'));
+            if($v === 'yes') {
+                $conditions[] = "(client.is_enrolled_in_rm IS NOT NULL AND client.is_enrolled_in_rm = 'YES')";
+            }
+            elseif($v === 'no') {
+                $conditions[] = "(client.is_enrolled_in_rm IS NULL OR client.is_enrolled_in_rm != 'YES')";
+            }
+        }
+        if(trim($request->input('f_cell_bp'))) {
+            $v = trim($request->input('f_cell_bp'));
+            if($v === 'yes') {
+                $conditions[] = "(client.is_assigned_cellular_bp_device IS NOT NULL AND client.is_assigned_cellular_bp_device = TRUE)";
+            }
+            elseif($v === 'no') {
+                $conditions[] = "(client.is_assigned_cellular_bp_device IS NULL OR client.is_assigned_cellular_bp_device = FALSE)";
+            }
+        }
+        if(trim($request->input('f_cell_wt'))) {
+            $v = trim($request->input('f_cell_wt'));
+            if($v === 'yes') {
+                $conditions[] = "(client.is_assigned_cellular_weight_scale_device IS NOT NULL AND client.is_assigned_cellular_weight_scale_device = TRUE)";
+            }
+            elseif($v === 'no') {
+                $conditions[] = "(client.is_assigned_cellular_weight_scale_device IS NULL OR client.is_assigned_cellular_weight_scale_device = FALSE)";
+            }
+        }
+        if(trim($request->input('f_comm'))) {
+            $v = trim($request->input('f_comm'));
+            if($v === 'yes') {
+                $conditions[] = "(care_month.has_mcp_interacted_with_client_about_rm IS NOT NULL AND care_month.has_mcp_interacted_with_client_about_rm = TRUE)";
+            }
+            elseif($v === 'no') {
+                $conditions[] = "(care_month.has_mcp_interacted_with_client_about_rm IS NULL OR care_month.has_mcp_interacted_with_client_about_rm = FALSE)";
+            }
+        }
+
+        if(trim($request->input('f_md_op')) && trim($request->input('f_md')) !== '') {
+            $o = trim($request->input('f_md_op'));
+            $v = trim($request->input('f_md'));
+            $conditions[] = "(care_month.number_of_days_with_remote_measurements {$o} {$v})";
+        }
+        if(trim($request->input('f_unst_op')) && trim($request->input('f_unst')) !== '') {
+            $o = trim($request->input('f_unst_op'));
+            $v = trim($request->input('f_unst'));
+            $conditions[] = "(care_month.rm_num_measurements_not_stamped_by_mcp {$o} {$v})";
+        }
+        if(trim($request->input('f_mins_op')) && trim($request->input('f_mins')) !== '') {
+            $o = trim($request->input('f_mins_op'));
+            $v = intval(trim($request->input('f_mins'))) * 60;
+            $field = 'rm_total_time_in_seconds_by_mcp';
+            switch($mode) {
+                case 'mcp':
+                    $field = 'rm_total_time_in_seconds_by_mcp';
+                    break;
+                case 'rmm':
+                    $field = 'rm_total_time_in_seconds_by_rmm_pro';
+                    break;
+                break;
+            }
+            $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,
+       client.uid as client_uid, 
+       client.dob,
+       client.is_enrolled_in_rm,
+       client.most_recent_completed_mcp_note_date,
+       client.most_recent_completed_mcp_note_id,
+       mrmnote.effective_dateest::date as most_recent_completed_mcp_note_date_cm,
+       mrmnote.id as most_recent_completed_mcp_note_id_cm,
+       mrmnote.uid as most_recent_completed_mcp_note_uid_cm,
+       client.cell_number,
+       client.is_assigned_cellular_bp_device,
+       client.is_assigned_cellular_weight_scale_device,
+       care_month.uid as care_month_uid,
+       care_month.id as care_month_id,
+       care_month.start_date,
+       care_month.rm_total_time_in_seconds_by_mcp,
+       care_month.rm_total_time_in_seconds_by_rmm_pro,
+       care_month.number_of_days_with_remote_measurements,
+       care_month.has_mcp_interacted_with_client_about_rm,
+       care_month.rm_num_measurements_not_stamped_by_mcp,
+       care_month.rm_num_measurements_not_stamped_by_non_hcp,
+       care_month.rm_num_measurements_not_stamped_by_rmm,
+       care_month.rm_num_measurements_not_stamped_by_rme,
+       care_month.mcp_pro_id as care_month_mcp_pro_id,
+       care_month.rmm_pro_id as care_month_rmm_pro_id,
+       client.mcp_pro_id,
+       client.default_na_pro_id,
+       client.rmm_pro_id,
+       client.rme_pro_id,
+       client.cell_number,
+       care_month.most_recent_cellular_bp_dbp_mm_hg,
+       care_month.most_recent_cellular_bp_sbp_mm_hg,
+       care_month.most_recent_cellular_bp_measurement_at,      
+       care_month.most_recent_cellular_weight_value,
+       care_month.most_recent_cellular_weight_measurement_at,
+       care_month.mcp_rm_generic_bill_id,
+       bill.uid as mcp_rm_generic_bill_uid,
+       bill.generic_pro_id as mcp_rm_generic_bill_generic_pro_id,
+       bill.generic_pro_expected_payment_amount as mcp_rm_generic_bill_expected_payment_amount 
+FROM care_month join client on care_month.client_id = client.id join note mrnote on client.most_recent_completed_mcp_note_id = mrnote.id
+    left join bill  on care_month.mcp_rm_generic_bill_id = bill.id
+    left join note mrmnote on mrmnote.id = (
+        select max(n.id) from note n 
+        where 
+              n.client_id = client.id AND 
+              n.is_cancelled = FALSE AND
+              (n.is_signed_by_hcp IS NOT NULL AND n.is_signed_by_hcp = TRUE) AND
+              n.effective_dateest::date >= care_month.start_date::date AND 
+              n.effective_dateest::date < (care_month.start_date::date + INTERVAL '1 month')
+     )
+WHERE
+      $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) : '') . "
+      $orderBy
+";
+
+        // dd($query);
+
+        $patients = DB::select($query);
+
+        $timestamp = strtotime(date('Y-m-d'));
+        $daysRemaining = (int)date('t', $timestamp) - (int)date('j', $timestamp);
+
+        return view('app.practice-management.rpm-matrix-by-pro-type', compact('patients', 'daysRemaining', 'careMonthStart', 'mode'));
+    }
+
+    public function remoteMonitoringMCP(Request $request) {
+        return $this->rpmMatrixByProType($request, 'mcp');
+    }
+
+    public function remoteMonitoringRMM(Request $request) {
+        return $this->rpmMatrixByProType($request, 'rmm');
+    }
+
+    public function remoteMonitoringRME(Request $request) {
+        return $this->rpmMatrixByProType($request, 'rme');
+    }
+
+    public function remoteMonitoring_RowMCP(Request $request) {
+        return $this->remoteMonitoring_RowByProType($request, 'mcp');
+    }
+
+    public function remoteMonitoring_RowRMM(Request $request) {
+        return $this->remoteMonitoring_RowByProType($request, 'rmm');
+    }
+
+    public function remoteMonitoring_RowRME(Request $request) {
+        return $this->remoteMonitoring_RowByProType($request, 'rme');
+    }
+
     public function rpm_work_matrix(Request $request) {
 
         // get the patient having most recent unstamped measurement

+ 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 ?

+ 6 - 0
app/Models/Client.php

@@ -1013,5 +1013,11 @@ ORDER BY m.ts DESC
         return $this->getDeviceDeliveryStatus(2);
     }
 
+    public function carePlanFlaggedBy(){
+        return $this->hasOne(Pro::class, 'id', 'flagged_by_pro_id');
+    }
+    public function carePlanFlagAcknowledgedBy(){
+        return $this->hasOne(Pro::class, 'id', 'flag_acknowledged_by_pro_id');
+    }
 
 }

+ 22 - 0
app/Models/ClientCarePlanFlagUpdate.php

@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Models;
+
+# use Illuminate\Database\Eloquent\Model;
+
+class ClientCarePlanFlagUpdate extends Model
+{
+    protected $table = 'client_care_plan_flag_update';
+
+    public function client() {
+        return $this->hasOne(Client::class, 'id', 'client_id');
+    }
+
+    public function carePlanFlagAcknowledgedBy() {
+        return $this->hasOne(Pro::class, 'id', 'flag_acknowledged_by_pro_id');
+    }
+
+    public function carePlanFlaggedBy() {
+        return $this->hasOne(Pro::class, 'id', 'flagged_by_pro_id');
+    }
+}

+ 5 - 0
app/Models/SupplyOrder.php

@@ -49,4 +49,9 @@ class SupplyOrder extends Model
     {
         return $this->hasOne(Pro::class, 'id', 'created_by_pro_id');
     }
+
+    public function Note()
+    {
+        return $this->hasOne(Note::class, 'id', 'note_id');
+    }
 }

+ 1 - 1
config/app.php

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

+ 29 - 4
js-dev/option-list.js

@@ -3,13 +3,17 @@
         let ol = $(_input).next('.data-option-list');
         if(ol.length && !ol.is(':visible')) {
             ol.show();
+            return true;
         }
+        return false;
     }
     function hideOptionsList(_input) {
         let ol = $(_input).next('.data-option-list');
         if(ol.length && ol.is(':visible')) {
             ol.hide();
+            return true;
         }
+        return false;
     }
     function init() {
         $(document)
@@ -18,9 +22,21 @@
                 _e.stopPropagation();
                 _e.preventDefault();
                 markEventAsConsumed(_e);
-                $(this).parent().prev('input[data-option-list]').val('').focus();
-                document.execCommand('insertText', false, $(this).text());
-                $(this).closest('.data-option-list').hide();
+                let elem = $(this).parent().prev('input[data-option-list]'),
+                    text = $(this).text();
+                if(!elem.is('[multi-option-list]')) {
+                    elem.val('');
+                }
+                else {
+                    elem.val($.trim(elem.val()));
+                    elem[0].selectionStart = elem[0].selectionEnd = elem.val().length;
+                    if(elem.val() !== '') text = ', ' + text;
+                }
+                elem.focus();
+                document.execCommand('insertText', false, text);
+                if(!elem.is('[sticky-option-list]')) {
+                    $(this).closest('.data-option-list').hide();
+                }
                 return false;
             });
         $(document)
@@ -35,7 +51,16 @@
             .off('blur.trigger-option-list', 'input[data-option-list]')
             .on('blur.trigger-option-list', 'input[data-option-list]', function() {
                 hideOptionsList(this);
-            });
+            })
+            .off('keydown.discard-option-list', 'input[data-option-list]')
+            .on('keydown.discard-option-list', 'input[data-option-list]', function(_e) {
+                if(_e.which === 27) {
+                    if(hideOptionsList(this)) {
+                        markEventAsConsumed(_e);
+                        return false;
+                    }
+                }
+            })
     }
     addMCInitializer('option-list', init);
 })();

+ 47 - 8
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;
@@ -666,11 +669,16 @@ input.search_field, textarea.search_field {
         padding-top: 55px;
     }
 }
-
+.d-xlarge {
+    display: none;
+}
 @media screen and (max-width: 1400px) {
   .flex-container > div:first-child {
     margin-bottom: 20px;
   }
+  .d-xlarge {
+      display: none;
+  }
 }
 @media screen and (min-width: 1400px) {
   .flex-container{
@@ -686,6 +694,9 @@ input.search_field, textarea.search_field {
     margin-right: 20px;
     padding-right: 20px;
   }
+  .d-xlarge {
+    display: inline-block;
+}
 }
 
 .main-row > .sidebar .nav .nav-item a {
@@ -1718,6 +1729,25 @@ table.table-edit-sheet .ql-editor[contenteditable] {
 .data-option-list>div:hover {
     background: aliceblue;
 }
+input[multi-col-option-list]+.data-option-list {
+    max-width: unset;
+    width: 500px !important;
+}
+input[multi-col-option-list][tiny]+.data-option-list {
+    max-width: unset;
+    width: 100px !important;
+}
+input[multi-col-option-list]+.data-option-list>div {
+    display: inline-block;
+    width: calc(50% - 10px);
+    border: 0 !important;
+}
+input[multi-col-option-list][multi-option-list]+.data-option-list>div:before {
+    content: '+';
+    color: #777;
+    font-weight: bold;
+    margin-right: 4px;
+}
 .measurement-item:not(:last-child) {
     border-bottom: 1px solid #e7e7e7;
 }
@@ -2931,6 +2961,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;
@@ -3499,22 +3537,23 @@ table.v-top th {
     text-overflow: ellipsis;
     display: inline-block;
 }
-.note_template_psych_visit .edit-container .ql-editor[contenteditable] {
+.note_template_psych_intake_visit .edit-container .ql-editor[contenteditable],
+.note_template_psych_followup_visit .edit-container .ql-editor[contenteditable] {
     min-height: 80px;
     background: #fff;
 }
-.note_template_psych_visit .edit-container .ql-toolbar {
+.note_template_psych_intake_visit .edit-container .ql-toolbar,
+.note_template_psych_followup_visit .edit-container .ql-toolbar {
     height: 0;
     overflow: hidden;
     padding: 0;
     border-bottom: 0;
 }
-/*.note_template_psych_visit .edit-container [visit-moe]>form>div:last-child {
-    margin: 0 !important;
-}*/
-.note_template_psych_visit .edit-container [visit-moe]>form>div:last-child>.btn.btn-primary {
+.note_template_psych_intake_visit .edit-container [visit-moe]>form>div:last-child>.btn.btn-primary,
+.note_template_psych_followup_visit .edit-container [visit-moe]>form>div:last-child>.btn.btn-primary {
     display: none;
 }
-.note_template_psych_visit .edit-container [visit-moe]>form>div:last-child>.d-inline-flex {
+.note_template_psych_intake_visit .edit-container [visit-moe]>form>div:last-child>.d-inline-flex,
+.note_template_psych_followup_visit .edit-container [visit-moe]>form>div:last-child>.d-inline-flex {
     display: flex !important;
 }

+ 35 - 20
resources/views/app/admin/patients_missing_defsult_settings_filters.blade.php

@@ -6,17 +6,21 @@
 	#admin-patients-filters .mw-100px {
 		min-width: 100px;
 	}
-	.filter-container{
+
+	.filter-container {
 		display: flex;
 		align-items: flex-start;
 		flex-wrap: wrap;
 	}
-	.filter-container >div {
+
+	.filter-container>div {
 		width: 165px;
 	}
-	.filter-container >div:not(:last-child) {
+
+	.filter-container>div:not(:last-child) {
 		margin-right: 10px;
 	}
+
 	.sm-section {
 		width: 150px !important;
 	}
@@ -41,14 +45,14 @@
 			<label>Status:</label>
 			<select name="status" class="form-control input-sm" v-model="filters.status">
 				<option value="">All</option>
- 				<option value="ACTIVE">Active</option>
- 				<option value="DUMMY">Test Record</option>
- 				<option value="NO_LONGER_INTERESTED">No Longer Interested</option>
- 				<option value="INACTIVE">Inactive</option>
- 				<option value="ENTRY_ERROR">Entry Error</option>
- 				<option value="DUPLICATE">Duplicate</option>
- 				<option value="DECEASED">Deceased</option>
- 				<option value="BAD_RECORD">Bad Record</option>
+				<option value="ACTIVE">Active</option>
+				<option value="DUMMY">Test Record</option>
+				<option value="NO_LONGER_INTERESTED">No Longer Interested</option>
+				<option value="INACTIVE">Inactive</option>
+				<option value="ENTRY_ERROR">Entry Error</option>
+				<option value="DUPLICATE">Duplicate</option>
+				<option value="DECEASED">Deceased</option>
+				<option value="BAD_RECORD">Bad Record</option>
 			</select>
 		</div>
 	</div>
@@ -56,7 +60,7 @@
 	<div class="sm-section">
 		<div class="">
 			<label>Insurance:</label>
-			<select class="form-control"  name="insurance" v-model="filters.insurance">
+			<select class="form-control" name="insurance" v-model="filters.insurance">
 				<option value=""></option>
 				<option value="MEDICARE_PENDING">Medicare Pending</option>
 				<option value="MEDICARE">Medicare (Part B)</option>
@@ -70,14 +74,14 @@
 	<div class="sm-section">
 		<div class="">
 			<label>Chart #</label>
-			<input class="form-control"  name="chart_number" v-model="filters.chart_number">
+			<input class="form-control" name="chart_number" v-model="filters.chart_number">
 		</div>
 	</div>
 
 	<div class="sm-section" style="width: 185px !important;">
 		<div class="">
 			<label>Missing Default Setting(s):</label>
-			<select class="form-control"  name="missing_default_settings" v-model="filters.missing_default_settings">
+			<select class="form-control" name="missing_default_settings" v-model="filters.missing_default_settings">
 				<option value="">Any</option>
 				<option value="NO_MCP">No MCP</option>
 				<option value="NO_MCP_COMPANY_PRO">No MCP Company Pro</option>
@@ -86,7 +90,18 @@
 			</select>
 		</div>
 	</div>
-	
+
+	<div class="sm-section" style="width: 185px !important;">
+		<div class="">
+			<label>Care Plan:</label>
+			<select class="form-control" name="care_plan" v-model="filters.care_plan">
+				<option value="">Any</option>
+				<option value="UNSIGNED_CARE_PLANS">Unsigned Care Plans</option>
+				<option value="UNCLEARED_CARE_PLANS">Uncleared Care Plans</option>
+			</select>
+		</div>
+	</div>
+
 	<div>
 		<div class="">
 			<label>&nbsp;</label>
@@ -101,13 +116,14 @@
 <?php
 $loadedFilters = $filters;
 $allFilterKeys = [
-	'name',	
+	'name',
 	'status',
 	'insurance',
 	'chart_number',
-	'missing_default_settings'
+	'missing_default_settings',
+	'care_plan'
 ];
-for ($i=0; $i < count($allFilterKeys); $i++) {
+for ($i = 0; $i < count($allFilterKeys); $i++) {
 	if (!isset($loadedFilters[$allFilterKeys[$i]]) || !$loadedFilters[$allFilterKeys[$i]]) {
 		$loadedFilters[$allFilterKeys[$i]] = '';
 	}
@@ -132,7 +148,6 @@ for ($i=0; $i < count($allFilterKeys); $i++) {
 					}
 				},
 				mounted: function() {
-					console.log(this.filters);
 					this.init();
 
 					let mcpSelect = $('<select name="mcp" class="form-control min-width-unset input-sm" provider-search data-pro-uid="{{request()->input("mcp")}}" provider-type="hcp"><option value="">--select--</option></select>').appendTo('.mcp-filter-container');
@@ -145,4 +160,4 @@ for ($i=0; $i < count($allFilterKeys); $i++) {
 		}
 		addMCInitializer('admin-patients-filters', init, '#admin-patients-filters');
 	})();
-</script>
+</script>

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

@@ -336,7 +336,7 @@
                                 </div>
                                 @endif
 
-                                @if(($daysDiff !== -1 && $daysDiff <= 90) &&
+                                @if(($daysDiff !== -1 && $daysDiff <= 90) && 
                                     $careMonth->number_of_days_with_remote_measurements >= 16 &&
                                     $careMonth->has_mcp_interacted_with_client_about_rm)
                                     <div class="mt-2 border border-info p-2">

+ 2 - 2
resources/views/app/patient/note/_create-claim.blade.php

@@ -147,7 +147,7 @@
                     {
                         cpt: '',
                         dateOfService: '{{$note->created_at}}',
-                        icds: JSON.parse(JSON.stringify(window.noteReasons)),
+                        icds: JSON.parse(JSON.stringify(window.noteReasons?window.noteReasons:[])),
                         numberOfUnits: 1
                     }
                 ]
@@ -158,7 +158,7 @@
                 this.payload.lines.push({
                     cpt: '',
                     dateOfService: '{{date_format($note->created_at, 'Y-m-d')}}',
-                    icds: JSON.parse(JSON.stringify(window.noteReasons)),
+                    icds: JSON.parse(JSON.stringify(window.noteReasons?window.noteReasons:[])),
                     numberOfUnits: 1
                 });
                 Vue.nextTick(() => {

+ 2 - 2
resources/views/app/patient/note/dashboard.blade.php

@@ -965,7 +965,7 @@ use App\Models\Handout;
                         <p class="font-weight-bold text-secondary m-0 font-size-14">Vitals Settings</p>
                     </div>
                     <div class="row" id="vitals-settings-{{$patient->uid}}">
-                        <div class="col-5 border-right">
+                        <div class="col-4 border-right">
                             <div class="d-flex align-items-baseline">
                                 <b>BMI/Weight Management</b>
                                 <span class="mx-2 text-secondary">|</span>
@@ -975,7 +975,7 @@ use App\Models\Handout;
                                 @include('app.patient.vitals-settings.bmi-management-summary')
                             </div>
                         </div>
-                        <div class="col-7">
+                        <div class="col-8">
                             <div class="d-flex align-items-baseline">
                                 <b>BP Management</b>
                                 <span class="mx-2 text-secondary">|</span>

+ 200 - 0
resources/views/app/patient/note/flag-care-plan.blade.php

@@ -0,0 +1,200 @@
+
+
+	<div <?= $patient->has_care_plan_flag && !$patient->is_flag_cleared ? 'class="alert alert-danger p-1 rounded-0" style="min-width: 380px;"' : 'class="ml-2"' ?>>
+	<?php #dump($patient); ?>
+	@if($pro->pro_type === 'ADMIN')
+		@if($patient->has_care_plan_flag && !$patient->is_flag_cleared)
+			<div class="d-flex flex-column">
+				<div class="d-flex align-items-center flex-wrap">
+					<span class="mr-2"><b>Flagged At:</b> {{ friendly_date_time($patient->flagged_at) }}</span>
+					<small class="text-sm">By: <i class="fas fa-user"></i> {{ $patient->carePlanFlaggedBy->displayName() }}</small>
+				</div>
+				
+				<small class="text-muted"><b><i class="fas fa-comment on-hover-opaque text-primary"></i></b> {{ $patient->memo }}</small>
+			</div>
+
+			@if($patient->is_flag_acknowledged && $patient->flag_acknowledged_at > $patient->flagged_at)
+				<!-- This is resolved -->
+				<div class="border-top mt-1 pt-1" style="border-color: #f3bcc1!important;">
+					<div class="d-flex flex-column">
+						<div class="d-flex align-items-center flex-wrap">
+							<span class="mr-2"><b>Ack. At:</b> {{ friendly_date_time($patient->flag_acknowledged_at) }}</span>
+							<small class="text-sm">By: <i class="fas fa-user"></i> {{ $patient->carePlanFlagAcknowledgedBy->displayName() }}</small>
+						</div>
+						
+						<small class="text-muted"><b><i class="fas fa-comment on-hover-opaque"></i></b> {{ $patient->flag_acknowledgement_memo }}</small>
+					</div>
+				</div>
+			@endif
+				<!-- Flagged by admin, pending ack. by pro -->
+				<div class="border-top mt-1 pt-1" style="border-color: #f3bcc1!important;">
+					<div class="d-flex">
+						@if($patient->is_flag_acknowledged)
+							<div moe>
+								<a start show class="text-success"><i class="fas fa-flag  on-hover-opaque"></i> Clear Flag</a>
+								<form url="/api/client/clearFlag" class="mcp-theme-1">
+									<input type="hidden" name="uid" value="{{$patient->uid}}">
+									<div class="form-group">
+										<label>Memo:</label>
+										<textarea name="memo" rows="2" class="form-control"></textarea>
+									</div>
+									<div>
+										<button submit class="btn btn-sm btn-success mr-1">Clear Flag</button>
+										<button cancel class="btn btn-sm btn-default border">Cancel</button>
+									</div>
+								</form>
+							</div>
+						@else
+							<div moe>
+								<a start show class="text-success"><i class="fas fa-flag  on-hover-opaque"></i> Unflag Care Plan</a>
+								<form url="/api/client/undoCarePlanFlag" class="mcp-theme-1">
+									<input type="hidden" name="uid" value="{{$patient->uid}}">
+									<div class="form-group">
+										<label>Memo:</label>
+										<textarea name="memo" rows="2" class="form-control"></textarea>
+									</div>
+									<div>
+										<button submit class="btn btn-sm btn-success mr-1">Unflag Care Plan</button>
+										<button cancel class="btn btn-sm btn-default border">Cancel</button>
+									</div>
+								</form>
+							</div>
+						@endif
+						<span class="mx-1 text-muted">|</span>
+						@if($patient->is_flag_acknowledged)
+							<div moe>
+								<a start show class="text-danger"><i class="fas fa-flag  on-hover-opaque"></i> Flag Care Plan Again</a>
+								<form url="/api/client/flagCarePlan" class="mcp-theme-1">
+									<input type="hidden" name="uid" value="{{$patient->uid}}">
+									<div class="form-group">
+										<label>Memo:</label>
+										<textarea name="memo" rows="2" class="form-control" required></textarea>
+									</div>
+									<div>
+										<button submit class="btn btn-sm btn-danger mr-1">Flag Care Plan</button>
+										<button cancel class="btn btn-sm btn-default border">Cancel</button>
+									</div>
+								</form>
+							</div>
+						@else
+							<div moe>
+								<a start show class="text-primary">Update Memo</a>
+								<form url="/api/client/updateFlagMemo" class="mcp-theme-1">
+									<input type="hidden" name="uid" value="{{$patient->uid}}">
+									<div class="form-group">
+										<label>Memo:</label>
+										<textarea name="memo" rows="2" class="form-control"><?= $patient->memo ?></textarea>
+									</div>
+									<div>
+										<button submit class="btn btn-sm btn-primary mr-1">Update</button>
+										<button cancel class="btn btn-sm btn-default border">Cancel</button>
+									</div>
+								</form>
+							</div>
+						@endif
+						<span class="ml-1 text-muted">|</span>
+						@include('app.patient.note.partials.care-plan-flags-history')
+					</div>
+				</div>
+			
+		@else
+			<!-- Not flagged, show flag popup -->
+			<div class="d-flex align-items-center">
+				<div moe>
+					<a start show class="text-danger"><i class="fas fa-flag  on-hover-opaque"></i> Flag Care Plan</a>
+					<form url="/api/client/flagCarePlan" class="mcp-theme-1">
+						<input type="hidden" name="uid" value="{{$patient->uid}}">
+						<div class="form-group">
+							<label>Memo:</label>
+							<textarea name="memo" rows="2" class="form-control" required></textarea>
+						</div>
+						<div>
+							<button submit class="btn btn-sm btn-danger mr-1">Flag Care Plan</button>
+							<button cancel class="btn btn-sm btn-default border">Cancel</button>
+						</div>
+					</form>
+				</div>
+				@include('app.patient.note.partials.care-plan-flags-history')
+			</div>
+			
+		@endif
+
+	@else
+	<!-- HCP -->
+		@if($patient->has_care_plan_flag && !$patient->is_flag_cleared)
+			<div class="d-flex flex-column">
+				<div class="d-flex align-items-center flex-wrap">
+					<span class="mr-2"><b>Flagged At:</b> {{ friendly_date_time($patient->flagged_at) }}</span>
+					<small class="text-sm">By: <i class="fas fa-user"></i> {{ $patient->carePlanFlaggedBy->displayName() }}</small>
+				</div>			
+				<small class="text-muted"><b><i class="fas fa-comment on-hover-opaque text-primary"></i></b> {{ $patient->memo }}</small>
+			</div>
+
+			@if($patient->is_flag_acknowledged && $patient->flag_acknowledged_at > $patient->flagged_at)
+				<!-- hcp has ack. -->
+				<div class="border-top mt-1 pt-1" style="border-color: #f3bcc1!important;">
+					<div class="d-flex flex-column">
+						<div class="d-flex align-items-center flex-wrap">
+							<span class="mr-2"><b>Ack. At:</b> {{ friendly_date_time($patient->flag_acknowledged_at) }}</span>
+							<small class="text-sm">By: <i class="fas fa-user"></i> {{ $patient->carePlanFlagAcknowledgedBy->displayName() }}</small>
+						</div>
+						
+						<small class="text-muted"><b><i class="fas fa-comment on-hover-opaque"></i></b> {{ $patient->flag_acknowledgement_memo }}</small>
+						
+						<div class="border-top mt-1 pt-1" style="border-color: #f3bcc1!important;">
+							<div moe>
+								<a start show class="text-danger"><i class="fas fa-undo fa-fw  on-hover-opaque"></i> Undo Ack.</a>
+								<form url="/api/client/undoAcknowledgeCarePlanFlag" class="mcp-theme-1">
+									<input type="hidden" name="uid" value="{{$patient->uid}}">
+									<div class="form-group">
+										<label>Memo:</label>
+										<textarea name="memo" rows="2" class="form-control"></textarea>
+									</div>
+									<div>
+										<button submit class="btn btn-sm btn-danger mr-1">Undo Ack.</button>
+										<button cancel class="btn btn-sm btn-default border">Cancel</button>
+									</div>
+								</form>
+							</div>
+							<span class="mx-1 text-muted">|</span>
+							<div moe>
+								<a start show class="text-primary">Update Memo</a>
+								<form url="/api/client/updateAcknowledgementMemo" class="mcp-theme-1">
+									<input type="hidden" name="uid" value="{{$patient->uid}}">
+									<div class="form-group">
+										<label>Memo:</label>
+										<textarea name="memo" rows="2" class="form-control"><?= $patient->flag_acknowledgement_memo ?></textarea>
+									</div>
+									<div>
+										<button submit class="btn btn-sm btn-primary mr-1">Update</button>
+										<button cancel class="btn btn-sm btn-default border">Cancel</button>
+									</div>
+								</form>
+							</div>
+						</div>
+					</div>
+				</div>
+			
+			@else
+				<!-- Needs hcp ack. -->
+				<div class="border-top mt-1 pt-1" style="border-color: #f3bcc1!important;">
+				<div moe>
+					<a start show class="text-primary"><i class="fa fa-check text-sm on-hover-opaque"></i> Ack.</a>
+					<form url="/api/client/acknowledgeCarePlanFlag" class="mcp-theme-1">
+						<input type="hidden" name="uid" value="{{$patient->uid}}">
+						<div class="form-group">
+							<label>Memo:</label>
+							<textarea name="memo" rows="2" class="form-control" required></textarea>
+						</div>
+						<div>
+							<button submit class="btn btn-sm btn-primary mr-1">Ack. Flag</button>
+							<button cancel class="btn btn-sm btn-default border">Cancel</button>
+						</div>
+					</form>
+				</div>
+				</div>
+
+			@endif
+		@endif
+	@endif
+	</div>

+ 63 - 0
resources/views/app/patient/note/partials/care-plan-flags-history.blade.php

@@ -0,0 +1,63 @@
+<?php
+use App\Models\ClientCarePlanFlagUpdate;
+
+$recentClientCarePlanFlags = ClientCarePlanFlagUpdate::where('client_id', $patient->id)->orderBy('created_at', 'DESC')->limit(5)->get();
+?>
+@if(count($recentClientCarePlanFlags))
+<div moe relative wide center class="ml-2 mr-2">
+	<a start show title="View Care Plan Flag History"><i class="fas fa-history fa-fw on-hover-opaque"></i></a>
+	<form url="" class="mcp-theme-1">
+		<div>
+			<div class="d-flex align-items-center justify-content-between pb-2 mb-1">
+				<h5 class="mb-0 font-weight-bold">Recent Care Plan Flags</h5>
+				<button cancel class="btn btn-sm btn-default border">
+					<i class="fas fa-times"></i>
+				</button>
+			</div>
+			<table class="table table-sm table-striped table-bordered">
+				<thead class="bg-light">
+					<tr>
+						<th class="border-bottom-0">Date</th>
+						<th class="border-bottom-0">Flag Memo</th>
+						<th class="border-bottom-0">Ack. Memo</th>
+					</tr>
+				</thead>
+				<tbody>
+					@foreach($recentClientCarePlanFlags as $bf)
+					<tr>
+						<td>{{ friendly_date_time($bf->created_at) }}</td>
+						<td>
+							<div class="d-flex flex-column">
+								<small class="text-sm text-muted"><?= $bf->memo ?></small>
+								@if($bf->carePlanFlaggedBy)
+								<div class="d-flex align-items-center">
+									<span class="text-sm">By: {{ $bf->carePlanFlaggedBy->displayName() }}</span>
+									<span class="text-sm ml-2">At: {{ friendly_date_time($bf->flagged_at) }}</span>
+								</div>
+								@endif
+							</div>
+						</td>
+						<td>
+							<div class="d-flex flex-column">
+								<small class="text-sm text-muted"><?= $bf->flag_acknowledgement_memo ?></small>
+								@if($bf->carePlanFlagAcknowledgedBy)
+								<div class="d-flex align-items-center">
+									<span class="text-sm">By: {{ $bf->carePlanFlagAcknowledgedBy->displayName() }}</span>
+									<span class="text-sm ml-2">At: {{ friendly_date_time($bf->flag_acknowledged_at) }}</span>
+								</div>
+								@endif
+							</div>
+						</td>
+					</tr>
+					@endforeach
+					@if(!count($recentClientCarePlanFlags))
+						<tr>
+							<td colspan="3">No records found</td>
+						</tr>
+					@endif
+				</tbody>
+			</table>
+		</div>
+	</form>
+</div>
+@endif

+ 190 - 195
resources/views/app/patient/note/rm-setup.blade.php

@@ -1,135 +1,129 @@
 <div class="row" id="rm-setup">
-    <div class="col-6">
+    <div class="col-7">
         @if($pro->pro_type === 'ADMIN')
-            <div>
-                <table class="table table-sm table-striped table-bordered mb-1">
-                    <tr>
-                        <td>Is Eligible for RM?</td>
-                        <td>
-                            <div class="">
-                                <div class="d-inline-flex align-items-start">
-                                    <b>{{ ucwords($patient->is_eligible_for_rm ? $patient->is_eligible_for_rm : '-') }}</b>
-                                    <div moe class="ml-2">
-                                        <a start show><i class="fa fa-edit on-hover-opaque"></i></a>
-                                        <form url="/api/client/updateRmEligibility" class="mcp-theme-1">
-                                            <input type="hidden" name="uid" value="{{$patient->uid}}">
-                                            <div class="mb-2">
-                                                <label class="text-sm mb-1 text-secondary">Is Eligible?</label>
-                                                <select name="isEligibleForRm"
-                                                        class="form-control form-control-sm"
-                                                        onchange="toggleDisabledAsNeeded(this, 'NO', 'not-eligible-for-rm')">
-                                                    <option value="">-- Select Status --</option>
-                                                    <option value="YES" {{ $patient->is_eligible_for_rm === 'YES' ? 'selected' : '' }}>YES</option>
-                                                    <option value="NO" {{ $patient->is_eligible_for_rm === 'NO' ? 'selected' : '' }}>NO</option>
-                                                    <option value="UNKNOWN" {{ $patient->is_eligible_for_rm === 'UNKNOWN' ? 'selected' : '' }}>UNKNOWN</option>
-                                                </select>
-                                            </div>
-                                            <div class="mb-2">
-                                                <label class="text-sm mb-1 text-secondary">Why not eligible category</label>
-                                                <input type="text" class="not-eligible-for-rm form-control form-control-sm"
-                                                    {{$patient->is_eligible_for_rm === 'NO' ? '' : 'disabled' }}
-                                                    name="whyNotEligibleForRmCategory" value="{{$patient->why_not_eligible_for_rm_category}}">
-                                            </div>
-                                            <div class="mb-2">
-                                                <label class="text-sm mb-1 text-secondary">Why not eligible memo</label>
-                                                <input type="text" class="not-eligible-for-rm form-control form-control-sm"
-                                                    {{$patient->is_eligible_for_rm === 'NO' ? '' : 'disabled' }}
-                                                    name="whyNotEligibleForRmMemo" value="{{$patient->why_not_eligible_for_rm_memo}}">
-                                            </div>
-                                            <div>
-                                                <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
-                                                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-                                            </div>
-                                        </form>
-                                    </div>
+            <div class="mb-2">
+                <div class="d-flex flex-wrap">
+                    <div class="d-flex align-items-center">
+                        <span class="mr-2 text-secondary">Eligible for RM?</span>
+                        <span class="mr-1">{{ ucwords($patient->is_eligible_for_rm ? $patient->is_eligible_for_rm : '-') }}</span>
+                        <div moe class="">
+                            <a start show><i class="fa fa-edit on-hover-opaque"></i></a>
+                            <form url="/api/client/updateRmEligibility" class="mcp-theme-1">
+                                <input type="hidden" name="uid" value="{{$patient->uid}}">
+                                <div class="mb-2">
+                                    <label class="text-sm mb-1 text-secondary">Is Eligible?</label>
+                                    <select name="isEligibleForRm"
+                                            class="form-control form-control-sm"
+                                            onchange="toggleDisabledAsNeeded(this, 'NO', 'not-eligible-for-rm')">
+                                        <option value="">-- Select Status --</option>
+                                        <option value="YES" {{ $patient->is_eligible_for_rm === 'YES' ? 'selected' : '' }}>YES</option>
+                                        <option value="NO" {{ $patient->is_eligible_for_rm === 'NO' ? 'selected' : '' }}>NO</option>
+                                        <option value="UNKNOWN" {{ $patient->is_eligible_for_rm === 'UNKNOWN' ? 'selected' : '' }}>UNKNOWN</option>
+                                    </select>
+                                </div>
+                                <div class="mb-2">
+                                    <label class="text-sm mb-1 text-secondary">Why not eligible category</label>
+                                    <input type="text" class="not-eligible-for-rm form-control form-control-sm"
+                                        {{$patient->is_eligible_for_rm === 'NO' ? '' : 'disabled' }}
+                                        name="whyNotEligibleForRmCategory" value="{{$patient->why_not_eligible_for_rm_category}}">
+                                </div>
+                                <div class="mb-2">
+                                    <label class="text-sm mb-1 text-secondary">Why not eligible memo</label>
+                                    <input type="text" class="not-eligible-for-rm form-control form-control-sm"
+                                        {{$patient->is_eligible_for_rm === 'NO' ? '' : 'disabled' }}
+                                        name="whyNotEligibleForRmMemo" value="{{$patient->why_not_eligible_for_rm_memo}}">
+                                </div>
+                                <div>
+                                    <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
+                                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                </div>
+                            </form>
+                        </div>
+                        @if($patient->is_eligible_for_rm === 'NO')
+                        <span class="ml-1 on-hover-show d-inline-block on-hover-opaque">
+                            <i class="fa fa-info-circle"></i>
+                            <div class="on-hover-content py-2 pl-3 text-nowrap text-dark" style="left:0;right:auto;">
+                                <div>
+                                    <small class="text-sm"><b>Category:</b> {{$patient->why_not_eligible_for_rm_category ?: '-'}}</small>
+                                </div>
+                                <div>
+                                    <small class="text-sm"><b>Memo:</b> {{$patient->why_not_eligible_for_rm_memo ?: '-'}}</small>
                                 </div>
-                                @if($patient->is_eligible_for_rm === 'NO')
-                                    <div class="mt-1">
-                                        <span>{{$patient->why_not_eligible_for_rm_category ?: '-'}}</span>
-                                        /
-                                        <span class="text-secondary">{{$patient->why_not_eligible_for_rm_memo ?: '-'}}</span>
-                                    </div>
-                                @endif
                             </div>
-                        </td>
-                    </tr>
+                        </span>
+                        @endif
+                    </div>
+                    <span class="text-secondary mx-2">|</span>
                     <?php $currentCareMonth = $patient->currentCareMonth(); ?>
                     @if($currentCareMonth && $pro->id === $currentCareMonth->mcp_pro_id)
                     <?php $spoken = $currentCareMonth->has_anyone_interacted_with_client_about_rm_outside_note; ?>
-                        <tr>
-                            <td>
-                            Comm. this month:
-                            </td>
-                            <td>
-                                <b class="{{$spoken ? 'text-success' : ''}}">
-                                    {{$spoken ? 'Yes' : 'No'}}
-                                    @if(!$spoken)
-                                        <i class="fa fa-exclamation-triangle"></i>
-                                    @else
-                                        <i class="fa fa-check"></i>
-                                    @endif
-                                </b>
-                                @if($currentCareMonth->mcp && $pro->id === $currentCareMonth->mcp->id)
-                                    <div moe relative class="ml-2">
-                                        <a href="#" start show class="">Toggle</a>
-                                        <form url="/api/careMonth/setHasAnyoneInteractedWithClientAboutRmOutsideNoteTo{{$spoken ? 'False' : 'True'}}" right>
-                                            <input type="hidden" name="uid" value="{{$currentCareMonth->uid}}">
-                                            <p>Set to {{$spoken ? 'No' : 'Yes'}}?</p>
-                                            <div class="d-flex align-items-center">
-                                                <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
-                                                <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
-                                            </div>
-                                        </form>
+                    <div class="d-flex align-items-center">
+                        <span class="mr-1 text-secondary">Comm. this month:</span>
+                        <span class="{{$spoken ? 'text-success' : ''}}">
+                            {{$spoken ? 'Yes' : 'No'}}
+                            @if(!$spoken)
+                                <i class="fa fa-exclamation-triangle"></i>
+                            @else
+                                <i class="fa fa-check"></i>
+                            @endif
+                        </span>
+                        @if($currentCareMonth->mcp && $pro->id === $currentCareMonth->mcp->id)
+                            <div moe relative class="ml-1">
+                                <a href="#" start show class=""><i class="fa fa-edit on-hover-opaque"></i></a>
+                                <form url="/api/careMonth/setHasAnyoneInteractedWithClientAboutRmOutsideNoteTo{{$spoken ? 'False' : 'True'}}" right>
+                                    <input type="hidden" name="uid" value="{{$currentCareMonth->uid}}">
+                                    <p>Set to {{$spoken ? 'No' : 'Yes'}}?</p>
+                                    <div class="d-flex align-items-center">
+                                        <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
+                                        <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
                                     </div>
-                                @endif
-                            </td>
-                        </tr>
+                                </form>
+                            </div>
+                        @endif
+                    </div>
+                    <span class="text-secondary mx-2 d-xlarge">|</span>
                     @endif
-                    <tr>
-                        <td>Enrollment:</td>
-                        <td>
-                            <div class="">
-                                <div class="d-inline-flex align-items-start">
-                                    <b>{{ ucwords($patient->is_enrolled_in_rm ? $patient->is_enrolled_in_rm : '-') }}</b>
-                                    @if($patient->is_enrolled_in_rm === 'YES')
-                                        <div moe class="ml-2">
-                                            <a start show>Toggle</a>
-                                            <form url="/api/client/setIsEnrolledInRmToFalse" class="mcp-theme-1">
-                                                <input type="hidden" name="uid" value="{{$patient->uid}}">
-                                                <p>Un-enroll from RPM?</p>
-                                                <div>
-                                                    <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
-                                                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
-                                                </div>
-                                            </form>
-                                        </div>
-                                    @else
-                                        <a native target="_blank"
-                                        class="screen-only ml-2"
-                                        open-in-stag-popup
-                                        popup-style="medium overflow-visible"
-                                        mc-initer="rpm-agreement-{{$note->id}}"
-                                        title="Leadership Health Remote Patient Monitoring Consent Form"
-                                        href="/note/rpm-agreement/{{$note->uid}}?popupmode=1">
-                                            Mark as enrolled
-                                        </a>
-                                    @endif
-                                </div>
+
+                    <div class="d-flex align-items-center">
+                        <span class="mr-1 text-secondary">Enrollment:</span>
+                        <span>{{ ucwords($patient->is_enrolled_in_rm ? $patient->is_enrolled_in_rm : '-') }}</span>
+                        @if($patient->is_enrolled_in_rm === 'YES')
+                            <div moe class="ml-1">
+                                <a start show><i class="fa fa-edit on-hover-opaque"></i></a>
+                                <form url="/api/client/setIsEnrolledInRmToFalse" class="mcp-theme-1">
+                                    <input type="hidden" name="uid" value="{{$patient->uid}}">
+                                    <p>Un-enroll from RPM?</p>
+                                    <div>
+                                        <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
+                                        <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                    </div>
+                                </form>
                             </div>
-                        </td>
-                    </tr>
-                </table>
+                        @else
+                            <a native target="_blank"
+                            class="screen-only ml-2"
+                            open-in-stag-popup
+                            popup-style="medium overflow-visible"
+                            mc-initer="rpm-agreement-{{$note->id}}"
+                            title="Leadership Health Remote Patient Monitoring Consent Form"
+                            href="/note/rpm-agreement/{{$note->uid}}?popupmode=1">
+                                Mark as enrolled
+                            </a>
+                        @endif
+                    </div>
+                </div>
+                
             </div> 
         @endif
         
-        <div class="d-flex align-items-baseline mb-3">
+        <div class="d-flex align-items-baseline mb-1">
             <div class="flex-grow-1">
                 <div>
                     <div class="d-flex align-items-center mb-1">
-                        <span class="mr-2">RM Reasons:</span>
+                        <span class="mr-2 text-secondary">RM Reasons:</span>
                         @include('app.patient.partials.put-rm-reasons', ['recordType' => 'CLIENT', 'record' => $patient])
                     </div>
-                    <div class="">
+                    <div class="pl-3">
                         @include('app.patient.partials.rm-reasons-display', ['recordType' => 'CLIENT', 'record' => $patient])
                     </div>
                 </div>
@@ -234,11 +228,12 @@
                 </div>--}}
             </div>
         </div>
-        <div class="mb-3">
-            <table class="table-sm table-striped table-bordered w-100 v-top">
+        <div class="my-2">
+            <table class="table-sm table-bordered v-top">
                 <tr>
-                    <td>Care Plan:</td>
+                    <td class="text-secondary">Care Plan:</td>
                     <td>
+                        <div class="{{ $patient->has_care_plan_flag && !$patient->is_flag_cleared ? '':'d-flex' }}">
                         <div class="d-inline-flex align-items-center">
                             @if($patient->has_cm_setup_been_performed)
                                 <div class="text-nowrap text-success">
@@ -329,6 +324,8 @@
                                 </div>
                             </div>
                         @endif
+                        @include('app.patient.note.flag-care-plan')
+                        </div>
                     </td>
                 </tr>
             </table>
@@ -338,10 +335,10 @@
 
         @if($pro->pro_type === 'ADMIN')
             <div>
-                <table class="table table-sm table-bordered table-striped">
+                <table class="table-sm ">
                     <tr>
-                        <td>RME Pro:</td>
-                        <td>
+                        <td class="text-secondary p-1">RME Pro:</td>
+                        <td class="p-1">
                             <div class="">
                                 <div class="d-inline-flex align-items-start">
                                     <b>{{ $patient->rme ? $patient->rme->displayName() : '-' }}</b>
@@ -379,8 +376,8 @@
                         </td>
                     </tr>
                     <tr>
-                        <td>RMM Pro:</td>
-                        <td>
+                        <td class="text-secondary p-1">RMM Pro:</td>
+                        <td class="p-1">
                             <div class="">
                                 <div class="d-inline-flex align-items-start">
                                     <b>{{ $patient->rmm ? $patient->rmm->displayName() : '-' }}</b>
@@ -420,12 +417,12 @@
                 </table>
             </div>
         @endif
-        <div class="border-top mt-2 pt-2">
+        <div class="border-top mt-1 pt-2">
             @include('app.patient.partials.client_bp_weight_phone_number_status')
         </div>
         
     </div>
-    <div class="col-6 border-left">
+    <div class="col-5 border-left">
         <?php
         $bpDevice = null;
         $weightScale = null;
@@ -474,46 +471,45 @@
         ?>
 
         @if($bpDevice)
-            <div class="mb-3">
-                <div class="d-flex align-items-baseline mb-2">
-                    <span class="width-200px font-weight-bold">Cellular BP Device</span>
-                    <b class="ml-3">Yes</b>
-                    <span class="ml-3 text-secondary">IMEI: {{$bpDevice->device->imei}}</span>
-                </div>
-                <div class="">
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="width-200px pl-3">Arrived:</span>
-                        <span class="ml-3">Yes</span>
-                    </div>
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="width-200px pl-3">First Measurement:</span>
+            <div class="mb-2">
+                <table class="table table-sm table-bordered mb-0">
+                    <tr class="bg-light">
+                        <td class="text-secondary" style="width: 125px;">Cellular BP Device</td>
+                        <td colspan="2">Yes <i>({{$bpDevice->device->imei}})</i></td>
+                    </tr>
+                    <tr>
+                        <td class="text-secondary">Arrived</td>
+                        <td colspan="2">Yes</td>
+                    </tr>
+                    <tr>
+                        <td class="text-secondary">First Meas.</td>
                         @if($bpMeasurements["first"])
-                            <span class="ml-3">{{ $bpMeasurements["first"]->sbp_mm_hg . '/' . $bpMeasurements["first"]->dbp_mm_hg . '' }}</span>
-                            <span class="ml-3 text-secondary">{{date("Y-m-d", $bpMeasurements["first"]->ts/1000)}}</span>
-                            <span class="ml-3">{{date_diff(date_create(date("Y-m-d", $bpMeasurements["first"]->ts/1000)), date_create('now'))->days}} days ago</span>
+                        <td class="">{{ $bpMeasurements["first"]->sbp_mm_hg . '/' . $bpMeasurements["first"]->dbp_mm_hg . '' }}</td>
+                        <td class="">{{friendly_date_short(date("Y-m-d", $bpMeasurements["first"]->ts/1000))}} <i class="text-muted">- {{date_diff(date_create(date("Y-m-d", $bpMeasurements["first"]->ts/1000)), date_create('now'))->days}} <small class="text-sm">days ago</small></i></td>
                         @else
-                            -
+                            <td colspan="3">-</td>
                         @endif
-                    </div>
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="width-200px pl-3">Last Measurement:</span>
+                    </tr>
+                    <tr>
+                        <td class="text-secondary">Last Meas.</td>
                         @if($bpMeasurements["last"])
-                            <span class="ml-3">{{ $bpMeasurements["last"]->sbp_mm_hg . '/' . $bpMeasurements["last"]->dbp_mm_hg . '' }}</span>
-                            <span class="ml-3 text-secondary">{{date("Y-m-d", $bpMeasurements["last"]->ts/1000)}}</span>
-                            <span class="ml-3">{{date_diff(date_create(date("Y-m-d", $bpMeasurements["last"]->ts/1000)), date_create('now'))->days}} days ago</span>
+                            <td>{{ $bpMeasurements["last"]->sbp_mm_hg . '/' . $bpMeasurements["last"]->dbp_mm_hg . '' }}</td>
+                            <td>{{friendly_date_short(date("Y-m-d", $bpMeasurements["last"]->ts/1000))}} <i class="text-muted">- {{date_diff(date_create(date("Y-m-d", $bpMeasurements["last"]->ts/1000)), date_create('now'))->days}} <small class="text-sm">days ago</small></i></td>
                         @else
-                            -
+                           <td colspan="3">-</td>
                         @endif
-                    </div>
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="width-200px pl-3">How often to measure:</span>
-                        <span class="ml-3"> -- </span>
-                    </div>
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="width-200px pl-3">SMS reminders:</span>
-                        <span class="ml-3"> -- </span>
-                    </div>
-                </div>
+                    </tr>
+                    {{--
+                    <tr>
+                        <td class="text-secondary">How often to measure</td>
+                        <td colspan="2">-</td>
+                    </tr>
+                    <tr>
+                        <td class="text-secondary">SMS reminders</td>
+                        <td colspan="2">-</td>
+                    </tr>
+                    --}}
+                </table>
             </div>
         @else
             <div class="d-flex align-items-baseline mb-3">
@@ -523,46 +519,45 @@
         @endif
 
         @if($weightScale)
-            <div class="mb-3">
-                <div class="d-flex align-items-baseline mb-2">
-                    <span class="width-200px font-weight-bold">Cellular Weight Scale</span>
-                    <b class="ml-3">Yes</b>
-                    <span class="ml-3 text-secondary">IMEI: {{$weightScale->device->imei}}</span>
-                </div>
-                <div class="">
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="width-200px pl-3">Arrived:</span>
-                        <span class="ml-3">Yes</span>
-                    </div>
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="width-200px pl-3">First Measurement:</span>
-                        @if($weightMeasurements["first"])
-                            <span class="ml-3">{{ round($weightMeasurements["first"]->value, 2) . ' lbs' }}</span>
-                            <span class="ml-3 text-secondary">{{date("Y-m-d", $weightMeasurements["first"]->ts/1000)}}</span>
-                            <span class="ml-3">{{date_diff(date_create(date("Y-m-d", $weightMeasurements["first"]->ts/1000)), date_create('now'))->days}} days ago</span>
-                        @else
-                            -
-                        @endif
-                    </div>
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="width-200px pl-3">Last Measurement:</span>
+            <div class="mb-2">
+            <table class="table table-sm table-bordered mb-0">
+                <tr class="bg-light">
+                    <td class="text-secondary">Cellular Wt. Scale</td>
+                    <td colspan="3">Yes <i>({{$weightScale->device->imei}})</i></td>
+                </tr>
+                <tr>
+                    <td class="text-secondary">Arrived</td>
+                    <td colspan="3">Yes</td>
+                </tr>
+                <tr>
+                    <td class="text-secondary">First Meas.</td>
+                    @if($weightMeasurements["first"])
+                        <td>{{ round($weightMeasurements["first"]->value, 2) . ' lbs' }}</td>
+                        <td colspan="2">{{ friendly_date_short(date("Y-m-d", $weightMeasurements["first"]->ts/1000)) }} <i class="text-muted">- {{date_diff(date_create(date("Y-m-d", $weightMeasurements["first"]->ts/1000)), date_create('now'))->days}} <small class="text-asm">days ago</small></i></td>
+                    @else
+                        <td colspan="4"></td>
+                    @endif
+                </tr>
+                <tr>
+                        <td class="text-secondary">Last Meas.</td>
                         @if($weightMeasurements["last"])
-                            <span class="ml-3">{{ round($weightMeasurements["last"]->value, 2) . ' lbs' }}</span>
-                            <span class="ml-3 text-secondary">{{date("Y-m-d", $weightMeasurements["last"]->ts/1000)}}</span>
-                            <span class="ml-3">{{date_diff(date_create(date("Y-m-d", $weightMeasurements["last"]->ts/1000)), date_create('now'))->days}} days ago</span>
+                            <td>{{ round($weightMeasurements["last"]->value, 2) . ' lbs' }}</td>
+                            <td>{{ friendly_date_short(date("Y-m-d", $weightMeasurements["last"]->ts/1000)) }} <i class="text-muted">- {{date_diff(date_create(date("Y-m-d", $weightMeasurements["last"]->ts/1000)), date_create('now'))->days}} <small class="text-sm">days ago</small></i></td>
                         @else
-                            -
+                            <td colspan="4">-</td>
                         @endif
-                    </div>
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="width-200px pl-3">How often to measure:</span>
-                        <span class="ml-3"> -- </span>
-                    </div>
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="width-200px pl-3">SMS reminders:</span>
-                        <span class="ml-3"> -- </span>
-                    </div>
-                </div>
+                    </tr>
+                    {{--
+                    <tr>
+                        <td class="text-secondary">How often to measure</td>
+                        <td colspan="3">-</td>
+                    </tr>
+                    <tr>
+                        <td class="text-secondary">SMS reminders:</td>
+                        <td colspan="3">-</td>
+                    </tr>
+                    --}}
+            </table>
             </div>
         @else
             <div class="d-flex align-items-baseline mb-3">

+ 49 - 54
resources/views/app/patient/partials/client_bp_weight_phone_number_status.blade.php

@@ -1,59 +1,54 @@
 <div class="">
     <div class="mb-1">
-        <span class="mb-0 mr-2"><b>Please ask the client to save the following numbers for receiving measurement SMS messages.</b>
-        <div moe>
-            <a start show><i class="fa fa-edit"></i></a>
-            <form url="/api/client/updateClientBpWeightPhoneNumberStatus" class="mcp-theme-1">
-                <input type="hidden" name="uid" value="{{$patient->uid}}">
-                <div class="mb-2 checkbox">
-                    <input type="checkbox" name="hasClientSavedBpPhoneNumber">
-                    <label class="mb-1 text-secondary text-sm">Has client saved bp phone number?</label>
-                </div>
-                <div class="mb-2">
-                    <label class="mb-1 text-secondary text-sm">Saved BP phone number</label>
-                    <input type="text" name="savedBpPhoneNumber" class="form-control form-control-sm" value="{{config('app.bpSmsNumber')}}">
-                </div>
-                <div class="mb-2 checkbox">
-                    <input type="checkbox" name="hasClientSavedWeightPhoneNumber">
-                    <label class="mb-1 text-secondary text-sm">Has client saved weight phone number?</label>
-                </div>
-                <div class="mb-2">
-                    <label class="mb-1 text-secondary text-sm">Saved weight phone number</label>
-                    <input type="text" name="savedWeightPhoneNumber" class="form-control form-control-sm" value="{{config('app.weightSmsNumber')}}">
-                </div>
-                <div>
-                    <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
-                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
-                </div>
-            </form>
+        <div>
+            <p class="mb-1 text-secondary"><b>Please ask patient to store the following phone numbers for Cardio1st notifications:</b></p>
+            <p class="mb-1"><b>BP</b> {{ format_phone_number(config('app.bpSmsNumber')) }} <b class="ml-2">WT</b> {{ format_phone_number(config('app.weightSmsNumber')) }}</p>
+        </div>
+        <div class="d-flex align-items-center">
+            <p class="mb-0 mr-2 text-secondary">Has patient stored #s?</p>
+            <span class="mr-2">
+                @if($patient->clientBpWeightPhoneNumberStatus->has_client_saved_bp_phone_number)
+                <i class="fas fa-check-square text-success on-hover-opaque"></i>
+                @else
+                <i class="far fa-square text-secondary on-hover-opaque"></i>
+                @endif
+                BP
+            </span>
+            <span class="mr-2">
+                @if($patient->clientBpWeightPhoneNumberStatus->has_client_saved_weight_phone_number)
+                <i class="fas fa-check-square text-success on-hover-opaque"></i>
+                @else
+                <i class="far fa-square text-secondary on-hover-opaque"></i>
+                @endif
+                WT
+            </span>
+            
+            <div moe>
+                <a start show><i class="fa fa-edit"></i></a>
+                <form url="/api/client/updateClientBpWeightPhoneNumberStatus" class="mcp-theme-1">
+                    <input type="hidden" name="uid" value="{{$patient->uid}}">
+                    <div class="mb-2 checkbox">
+                        <input type="checkbox" name="hasClientSavedBpPhoneNumber" <?= $patient->clientBpWeightPhoneNumberStatus->has_client_saved_bp_phone_number ? 'checked':'' ?>>
+                        <label class="mb-1 text-secondary text-sm">Has client saved bp phone number?</label>
+                    </div>
+                    <div class="mb-2 d-none">
+                        <label class="mb-1 text-secondary text-sm">Saved BP phone number</label>
+                        <input type="text" name="savedBpPhoneNumber" class="form-control form-control-sm" value="{{ format_phone_number(config('app.bpSmsNumber')) }}">
+                    </div>
+                    <div class="mb-2 checkbox">
+                        <input type="checkbox" name="hasClientSavedWeightPhoneNumber" <?= $patient->clientBpWeightPhoneNumberStatus->has_client_saved_weight_phone_number ? 'checked':'' ?>>
+                        <label class="mb-1 text-secondary text-sm">Has client saved weight phone number?</label>
+                    </div>
+                    <div class="mb-2 d-none">
+                        <label class="mb-1 text-secondary text-sm">Saved weight phone number</label>
+                        <input type="text" name="savedWeightPhoneNumber" class="form-control form-control-sm" value="{{ format_phone_number(config('app.weightSmsNumber')) }}">
+                    </div>
+                    <div>
+                        <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
+                        <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                    </div>
+                </form>
+            </div>
         </div>
-        </span>
-        
     </div>
-    <table class="table table-sm table-striped table-bordered">
-        <tr>
-            <td>Cardio1st BP sms number:</td>
-            <td>{{config('app.bpSmsNumber')}}</td>
-        </tr>
-        <tr>
-            <td>Cardio1st Weight sms number:</td>
-            <td>{{config('app.weightSmsNumber')}}</td>
-        </tr>
-        <tr>
-            <td>Has client saved BP phone number:</td>
-            <td>{{ $patient->clientBpWeightPhoneNumberStatus && $patient->clientBpWeightPhoneNumberStatus->has_client_saved_bp_phone_number ? 'Yes': 'No' }}</td>
-        </tr>
-        <tr>
-            <td>Saved BP Phone number:</td>
-            <td>{{ $patient->clientBpWeightPhoneNumberStatus ?  $patient->clientBpWeightPhoneNumberStatus->saved_bp_phone_number: '-'}}</td>
-        </tr>
-        <tr>
-            <td>Has client saved Weight phone number:</td>
-            <td>{{ $patient->clientBpWeightPhoneNumberStatus && $patient->clientBpWeightPhoneNumberStatus->has_client_saved_weight_phone_number ? 'Yes': 'No' }}</td>
-        </tr>
-        <tr>
-            <td>Saved Weight Phone number:</td>
-            <td>{{ $patient->clientBpWeightPhoneNumberStatus ? $patient->clientBpWeightPhoneNumberStatus->saved_weight_phone_number : '-' }}</td>
-        </tr>
-    </table>
 </div>

+ 6 - 4
resources/views/app/patient/partials/rm-reasons-display.blade.php

@@ -34,15 +34,17 @@ $displayData = [
 			}
 			?>
 			@if(!$emptyICD)
-				<span class="mb-1 mr-2"><i class="fas fa-star text-warning"></i> {{$rmData['reason']}} @if(!empty($rmData['description']))({{ $rmData['description'] }})@endif</span>
+				<span class="mb-1 mr-2 d-flex align-items-center"><i class="fas fa-circle text-muted mr-1" style="font-size: 5px;"></i> {{$rmData['reason']}} @if(!empty($rmData['description']))({{ $rmData['description'] }})@endif</span>
 			@endif
 		@endforeach
 		@if($emptyICDs)
-		<small class="text-dark">-</small>
+		<small class="text-dark"></small>
 		@endif
 	</div>
+	@if($record->rm_reason_memo)
 	<div class="d-flex">
-			<span class="mr-2"><b>Memo:</b></span>
-			<small class="text-muted">{{ $record->rm_reason_memo }}</small>
+			<span class="text-secondary mr-2"><b>Memo:</b></span>
+			<small class="">{{ $record->rm_reason_memo }}</small>
 	</div>
+	@endif
 </div>

+ 44 - 3
resources/views/app/patient/segment-templates/biopsychosocial_assessment/edit.blade.php

@@ -137,6 +137,23 @@ if($otherImportantInformationPoint->lastChildReview && $otherImportantInformatio
 	$otherImportantInformationContent = $otherImportantInformationPoint->lastChildReview->data;
 }
 
+$tlPoints = [
+		'identification' => $identificationPoint,
+		'history_of_present_problem' => $historyOfPresentProblemPoint,
+		'psychiatric_history_prior_episodes_of_symptoms_diagnoses_courses_of_treatment_etc' => $psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcPoint,
+		'trauma_history' => $traumaHistoryPoint,
+		'family_psychiatric_history' => $familyPsychiatricHistoryPoint,
+		'medical_conditions_and_history' => $medicalConditionsAndHistoryPoint,
+		'substance_use' => $substanceUsePoint,
+		'family_history' => $familyHistoryPoint,
+		'social_history' => $socialHistoryPoint,
+		'spiritual_cultural_factors' => $spiritualCulturalFactorsPoint,
+		'developmental_history' => $developmentalHistoryPoint,
+		'educational_vocational_history' => $educationalVocationalHistoryPoint,
+		'legal_history' => $legalHistoryPoint,
+		'snap' => $snapPoint,
+		'other_important_information' => $otherImportantInformationPoint,
+];
 
 $contents = [
 	'identification' => $identificationContent,
@@ -210,7 +227,7 @@ $labels = [
 	'other_important_information' => 'Other Important Information', 
 ];
 ?>
-<div class="">
+<div id="biopsychosocial_assessment-container">
 	@foreach($contents as $field => $content)
 		<div visit-moe close-on-save close-on-cancel class="d-block" id="biopsychosocial_assessment-{{$field}}-{{$note->id}}">
 			<form show url="/api/visitPoint/upsertChildReview" class="mcp-theme-1 frm-upsert-review-psych-intake-current-mental-status">
@@ -224,10 +241,34 @@ $labels = [
 						<label class="control-label mb-0" style="font-size:13px;">{{$labels[$field]}}:</label>
 					</div>
 					<div class="col-md-8 pr-0">
-						<input type="text" name="value" class="form-control form-control-sm" placeholder="{{$placeholders[$field]}}" value="{{$content['value']}}" data-name="value">
+						<div class="d-flex align-items-center">
+							<input type="text" class="form-control form-control-sm flex-grow-1 bpsa-save-on-change" placeholder="{{$placeholders[$field]}}" value="{{$content['value']}}" data-name="value">
+							<a native="" target="_blank"
+							   class="c-pointer px-2 text-decoration-none"
+							   open-in-stag-popup=""
+							   title="{{$labels[$field]}} - Change Log"
+							   popup-style="medium"
+							   href="/note-segment-view/{{$patient->uid}}/{{$note->uid}}/{{$segment->uid}}/<?= $segment->segmentTemplate->internal_name ?>/point-log?tlp={{$tlPoints[$field]->category}}">
+								<i class="fas fa-history on-hover-opaque"></i>
+							</a>
+						</div>
 					</div>
 				</div>
 			</form> 
 		</div>
 	@endforeach  
-</div>
+</div>
+<script>
+	(function() {
+		function init() {
+			$('#biopsychosocial_assessment-container').find('.bpsa-save-on-change')
+				.off('input change paste')
+				.on('input change paste', function() {
+					let form = $(this).closest('form');
+					fillJsonDataField(form);
+					form.find('[name="data"]').trigger('save-trigger');
+				});
+		}
+		window.segmentInitializers.biopsychosocial_assessment = init;
+	}).call(window);
+</script>

+ 30 - 0
resources/views/app/patient/segment-templates/biopsychosocial_assessment/point-log.blade.php

@@ -0,0 +1,30 @@
+<?php
+
+use App\Models\Client;
+use App\Models\Point;
+use App\Models\Note;
+/** @var Client $patient */
+/** @var Note $note */
+
+$point = Point::getOnlyTopLevelPointOfCategory($note, request()->input('tlp'), true);
+
+if($point) {
+    ?> <div class="popup-content-container px-3"> <?php
+    foreach ($point->childReviews as $childReview) {
+        $contentData = $parsed = false;
+        if ($childReview->data) {
+            $childReview->data = json_decode($childReview->data, true);
+            $contentData = $parsed = $childReview->data;
+
+            if($contentData) {
+                ?>
+                <div class="mb-1 font-weight-bold">{{$childReview->creatorPro->displayName()}} - {{friendly_date($childReview->note->effective_dateest)}}</div>
+                <div class="pl-3 bg-light border p-3 mb-3">
+                    {{$contentData['value']}}
+                </div>
+                <?php
+            }
+        }
+    }
+    ?> </div> <?php
+}

+ 35 - 1
resources/views/app/patient/segment-templates/medication_comments/edit.blade.php

@@ -1,4 +1,38 @@
 <?php
+
+use App\Models\Point;
+
 $category = 'MEDICATION_COMMENTS';
 $endPoint = 'upsertNoteSingleton';
-include resource_path('views/app/patient/segment-templates/_simple_text_segment/edit.php');
+
+$point = Point::where('added_in_note_id', $note->id)->where('category', $category)->orderBy('id', 'DESC')->first();
+$parsed = null;
+if (!!@$point->data) {
+    $parsed = json_decode($point->data);
+}
+?>
+<div visit-moe close-on-save close-on-cancel class="d-block">
+    <form show url="/api/visitPoint/<?= $endPoint ?>" class="mcp-theme-1">
+        <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+        <input type="hidden" name="category" value="<?= $category ?>">
+        <input type="hidden" name="data">
+        <div note-rte
+             class="form-group mb-2 border-left border-right rte-holder"
+             data-field-name="free_text"
+        ><?= $parsed && @$parsed->free_text ? $parsed->free_text : '' ?></div>
+        <label class="mb-2 d-flex align-items-center">
+            <input type="checkbox" data-name="explained" {{@$parsed->explained ? 'checked' : ''}}>
+            <span class="ml-2">Changes in medication were explained to patient, including purpose, dosage, directions, side effects, risks, benefits, and options.</span>
+        </label>
+        <div class="m-2">
+            <button submit class="btn btn-sm btn-primary mr-2"><i class="fa fa-save"></i></button>
+            <div class="d-inline-flex align-self-stretch align-items-center">
+                <span class="autosave-indicator saving text-sm text-secondary">Saving changes &hellip;</span>
+                <span class="autosave-indicator saved text-sm text-secondary">
+                    <i class="fa fa-check"></i>
+                    Saved
+                </span>
+            </div>
+        </div>
+    </form>
+</div>

+ 25 - 1
resources/views/app/patient/segment-templates/medication_comments/summary.blade.php

@@ -1,3 +1,27 @@
 <?php
+use App\Models\Point;
+
 $category = 'MEDICATION_COMMENTS';
-include resource_path('views/app/patient/segment-templates/_simple_text_segment/summary.php');
+
+$point = Point::where('added_in_note_id', $note->id)->where('category', $category)->orderBy('id', 'DESC')->first();
+$parsed = null;
+if (!!@$point->data) {
+    $parsed = json_decode($point->data);
+}
+?>
+<div class="wrapping-pre-container">
+    <?php
+    if (!!$parsed && @$parsed->free_text) {
+        echo $parsed->free_text;
+    }
+    else {
+        echo "-";
+    }
+    ?>
+</div>
+@if(@$parsed->explained)
+<div class="mt-2">
+    <i class="fa fa-check"></i>
+    Changes in medication were explained to patient, including purpose, dosage, directions, side effects, risks, benefits, and options.
+</div>
+@endif

+ 42 - 0
resources/views/app/patient/segment-templates/medication_comments_followup/edit.blade.php

@@ -0,0 +1,42 @@
+<?php
+
+use App\Models\Point;
+
+$category = 'MEDICATION_COMMENTS';
+$endPoint = 'upsertNoteSingleton';
+
+$point = Point::where('added_in_note_id', $note->id)->where('category', $category)->orderBy('id', 'DESC')->first();
+$parsed = null;
+if (!!@$point->data) {
+    $parsed = json_decode($point->data);
+}
+?>
+<div visit-moe close-on-save close-on-cancel class="d-block">
+    <form show url="/api/visitPoint/<?= $endPoint ?>" class="mcp-theme-1">
+        <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+        <input type="hidden" name="category" value="<?= $category ?>">
+        <input type="hidden" name="data">
+        <div note-rte
+             class="form-group mb-2 border-left border-right rte-holder"
+             data-field-name="free_text"
+        ><?= $parsed && @$parsed->free_text ? $parsed->free_text : '' ?></div>
+        <label class="mb-2 d-flex align-items-center">
+            <input type="checkbox" data-name="explained" {{@$parsed->explained ? 'checked' : ''}}>
+            <span class="ml-2">Changes in medication were explained to patient, including purpose, dosage, directions, side effects, risks, benefits, and options.</span>
+        </label>
+        <div class="mb-2 w-50">
+            <div class="mb-1">Assessment:</div>
+            <input type="text" data-name="assessment" class="form-control form-control-sm" value="{{@$parsed->assessment}}">
+        </div>
+        <div class="m-2">
+            <button submit class="btn btn-sm btn-primary mr-2"><i class="fa fa-save"></i></button>
+            <div class="d-inline-flex align-self-stretch align-items-center">
+                <span class="autosave-indicator saving text-sm text-secondary">Saving changes &hellip;</span>
+                <span class="autosave-indicator saved text-sm text-secondary">
+                    <i class="fa fa-check"></i>
+                    Saved
+                </span>
+            </div>
+        </div>
+    </form>
+</div>

+ 30 - 0
resources/views/app/patient/segment-templates/medication_comments_followup/summary.blade.php

@@ -0,0 +1,30 @@
+<?php
+use App\Models\Point;
+
+$category = 'MEDICATION_COMMENTS';
+
+$point = Point::where('added_in_note_id', $note->id)->where('category', $category)->orderBy('id', 'DESC')->first();
+$parsed = null;
+if (!!@$point->data) {
+    $parsed = json_decode($point->data);
+}
+?>
+<div class="wrapping-pre-container">
+    <?php
+    if (!!$parsed && @$parsed->free_text) {
+        echo $parsed->free_text;
+    }
+    else {
+        echo "-";
+    }
+    ?>
+</div>
+@if(@$parsed->explained)
+<div class="mt-2">
+    <i class="fa fa-check"></i>
+    Changes in medication were explained to patient, including purpose, dosage, directions, side effects, risks, benefits, and options.
+</div>
+@endif
+<div class="mt-2">
+    Assessment: <b>{{@$parsed->assessment ?: '-'}}</b>
+</div>

+ 4 - 0
resources/views/app/patient/segment-templates/medication_response/edit.blade.php

@@ -0,0 +1,4 @@
+<?php
+$category = 'MEDICATION_RESPONSE';
+$endPoint = 'upsertNoteSingleton';
+include resource_path('views/app/patient/segment-templates/_simple_text_segment/edit.php');

+ 3 - 0
resources/views/app/patient/segment-templates/medication_response/summary.blade.php

@@ -0,0 +1,3 @@
+<?php
+$category = 'MEDICATION_RESPONSE';
+include resource_path('views/app/patient/segment-templates/_simple_text_segment/summary.php');

+ 60 - 0
resources/views/app/patient/segment-templates/psych_plan_free_text_followup/edit.blade.php

@@ -0,0 +1,60 @@
+<?php
+
+use App\Models\Point;
+
+$category = 'PLAN_FREE_TEXT';
+$endPoint = 'upsertNoteSingleton';
+
+$point = Point::where('added_in_note_id', $note->id)->where('category', $category)->orderBy('id', 'DESC')->first();
+$parsed = null;
+if (!!@$point->data) {
+    $parsed = json_decode($point->data);
+}
+?>
+<div visit-moe close-on-save close-on-cancel class="d-block">
+    <form show url="/api/visitPoint/<?= $endPoint ?>" class="mcp-theme-1">
+        <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+        <input type="hidden" name="category" value="<?= $category ?>">
+        <input type="hidden" name="data">
+        <div note-rte
+             class="form-group mb-2 border-left border-right rte-holder"
+             data-field-name="free_text"
+        ><?= $parsed && @$parsed->free_text ? $parsed->free_text : '' ?></div>
+        <div class="mb-2 row mx-0">
+            <div class="col-4 pl-0">
+                <div class="mb-2">Recommendation:</div>
+                <label class="d-flex align-items-center mb-1">
+                    <input type="radio" data-name="recommendation" value="Continue current therapeutic focus" {{@$parsed->recommendation === 'Continue current therapeutic focus' ? 'checked' : ''}}>
+                    <span class="ml-2">Continue current therapeutic focus</span>
+                </label>
+                <label class="d-flex align-items-center mb-1">
+                    <input type="radio" data-name="recommendation" value="Change treatment goals or objectives" {{@$parsed->recommendation === 'Change treatment goals or objectives' ? 'checked' : ''}}>
+                    <span class="ml-2">Change treatment goals or objectives</span>
+                </label>
+                <label class="d-flex align-items-center mb-1">
+                    <input type="radio" data-name="recommendation" value="Terminate treatment" {{@$parsed->recommendation === 'Terminate treatment' ? 'checked' : ''}}>
+                    <span class="ml-2">Terminate treatment</span>
+                </label>
+            </div>
+            <div class="col-4">
+                <div class="mb-2">Prescribed Frequency of Treatment:</div>
+                <label class="d-flex align-items-center mb-1">
+                    <input type="text" class="form-control form-control-sm" data-name="frequency" value="{{@$parsed->frequency}}">
+                </label>
+            </div>
+        </div>
+        <div class="m-2">
+            <button submit class="btn btn-sm btn-primary mr-2"><i class="fa fa-save"></i></button>
+            <div class="d-inline-flex align-self-stretch align-items-center">
+                <span class="autosave-indicator saving text-sm text-secondary">Saving changes &hellip;</span>
+                <span class="autosave-indicator saved text-sm text-secondary">
+                    <i class="fa fa-check"></i>
+                    Saved
+                </span>
+            </div>
+        </div>
+    </form>
+</div>
+
+
+

+ 24 - 0
resources/views/app/patient/segment-templates/psych_plan_free_text_followup/summary.blade.php

@@ -0,0 +1,24 @@
+<?php
+use App\Models\Point;
+$category = 'PLAN_FREE_TEXT';
+
+$point = Point::where('added_in_note_id', $note->id)->where('category', $category)->orderBy('id', 'DESC')->first();
+$parsed = null;
+if (!!@$point->data) {
+    $parsed = json_decode($point->data);
+}
+?>
+<div class="wrapping-pre-container">
+    <?php
+    if (!!$parsed && @$parsed->free_text) {
+        echo $parsed->free_text;
+    }
+    else {
+        echo "-";
+    }
+    ?>
+</div>
+<div class="mt-2">
+    Recommendation: <b>{{@$parsed->recommendation ?: '-'}}</b>
+    Prescribed Frequency of Treatment: <b>{{@$parsed->frequency ?: '-'}}</b>
+</div>

+ 30 - 4
resources/views/app/patient/segment-templates/psych_risk_assessment/edit.blade.php

@@ -69,7 +69,7 @@ if(!$contentData) {
                     <div class="d-flex align-items-baseline mb-2">
                         <label class="width-140px my-0">Area of Risk:</label>
                         <div class="flex-grow-1">
-                            <input type="text" class="form-control form-control-sm min-width-unset fg-1" data-option-list v-model="item.area" required>
+                            <input type="text" class="form-control form-control-sm min-width-unset" data-option-list v-model="item.area" required>
                             <div class="data-option-list">
                                 <div>Suicidal ideation</div>
                                 <div>Homicidal ideation</div>
@@ -161,15 +161,41 @@ if(!$contentData) {
                     </div>
                     <div class="d-flex align-items-baseline mb-1">
                         <label class="width-140px my-0">Risk Factors:</label>
-                        <input type="text" class="form-control form-control-sm min-width-unset fg-1" v-model="item.risk_factors" required>
+                        <div class="flex-grow-1 position-relative">
+                            <input type="text" class="form-control form-control-sm min-width-unset" data-option-list multi-option-list sticky-option-list multi-col-option-list v-model="item.risk_factors" required>
+                            <div class="data-option-list width-300px">
+                                <div>Current ideation</div>
+                                <div>Impulsivity</div>
+                                <div>Access to means</div>
+                                <div>Hopelessness</div>
+                                <div>History of attempts/behaviors</div>
+                                <div>Recent loss</div>
+                                <div>Alcohol/Substance use</div>
+                                <div>Family History</div>
+                            </div>
+                        </div>
                     </div>
                     <div class="d-flex align-items-baseline mb-1">
                         <label class="width-140px my-0">Protective Factors:</label>
-                        <input type="text" class="form-control form-control-sm min-width-unset fg-1" v-model="item.protective_factors" required>
+                        <div class="flex-grow-1 position-relative">
+                            <input type="text" class="form-control form-control-sm min-width-unset" data-option-list multi-option-list sticky-option-list multi-col-option-list v-model="item.protective_factors" required>
+                            <div class="data-option-list">
+                                <div>Positive social support</div>
+                                <div>Life satisfaction</div>
+                                <div>Cultural/religious beliefs</div>
+                                <div>Positive coping skills</div>
+                                <div>Social responsibility</div>
+                                <div>Sufficient problem-solving skills</div>
+                                <div>Children in the home</div>
+                                <div>Strong therapeutic rapport</div>
+                            </div>
+                        </div>
                     </div>
                     <div class="d-flex align-items-baseline mb-1">
                         <label class="width-140px my-0">Additional Details:</label>
-                        <input type="text" class="form-control form-control-sm min-width-unset fg-1" v-model="item.additional_details" required>
+                        <div class="flex-grow-1 position-relative">
+                            <input type="text" class="form-control form-control-sm min-width-unset" v-model="item.additional_details" required>
+                        </div>
                     </div>
                 </div>
 

+ 23 - 3
resources/views/app/patient/segment-templates/psych_vitals/edit.blade.php

@@ -14,6 +14,7 @@ $vitalLabels = [
     "respirationRatePerMinute" => "Resp.",
     "pulseOx" => "Pulse Ox.",
     "smokingStatus" => "Smoking Status",
+    "pain" => "Pain",
 ];
 $contentData = null;
 if ($point->lastChildReview && $point->lastChildReview->note->id === $note->id && $point->lastChildReview->data) {
@@ -34,6 +35,7 @@ if(!$contentData) {
         "respirationRatePerMinute" => '',
         "pulseOx" => '',
         "smokingStatus" => '',
+        "pain" => '',
     ];
 }else {
     if(!isset($contentData['date'])) $contentData['date'] = $note->effective_dateest;
@@ -48,7 +50,7 @@ $previousVitals = [];
 
 $previousVitals = \App\Models\Point::where('parent_point_id', $point->id)
     ->where('category', 'REVIEW')
-    ->where('added_in_note_id', '!=', $note->id)
+    ->where('added_in_note_id', '<', $note->id)
     ->orderBy('id', 'DESC')
     ->limit(4)
     ->get();
@@ -179,6 +181,24 @@ if(!@$segment) {
                                     <span class="pl-1 text-secondary bg-white">in.</span>
                                     <input type="hidden" data-name="heightInInches" value="{{$contentData['heightInInches']}}">
                                 </div>
+                            @elseif($k === 'pain')
+                                <input type="text"
+                                       class="form-control form-control-sm border-0"
+                                       data-name="pain"
+                                       placeholder="{{$v}}"
+                                       data-option-list="pain" multi-col-option-list tiny value="{{$contentData['pain']}}">
+                                <div id="pain" class="data-option-list">
+                                    <div>1</div>
+                                    <div>6</div>
+                                    <div>2</div>
+                                    <div>7</div>
+                                    <div>3</div>
+                                    <div>8</div>
+                                    <div>4</div>
+                                    <div>9</div>
+                                    <div>5</div>
+                                    <div>10</div>
+                                </div>
                             @else
                                 <input type="text"
                                        class="form-control form-control-sm border-0" data-name="{{$k}}" {{$k}}
@@ -243,8 +263,8 @@ if(!@$segment) {
     </form>
 </div>
 <script>
-    window.segmentInitializers.omega_vitals = function () {
-        let parentSegment = $('[data-segment-template-name="omega_vitals"] ');
+    window.segmentInitializers.psych_vitals = function () {
+        let parentSegment = $('[data-segment-template-name="psych_vitals"] ');
 
         function __refreshBMI() {
             var height = parseInt(parentSegment.find('[data-name="heightInInches"]').val());

+ 2 - 0
resources/views/app/patient/segment-templates/psych_vitals/summary.blade.php

@@ -14,6 +14,7 @@ $vitalLabels = [
     "respirationRatePerMinute" => "Resp.",
     "pulseOx" => "Pulse Ox.",
     "smokingStatus" => "Smoking Status",
+    "pain" => "Pain",
 ];
 $contentData = null;
 if ($point->lastChildReview && $point->lastChildReview->note->id === $note->id && $point->lastChildReview->data) {
@@ -34,6 +35,7 @@ if(!$contentData) {
         "respirationRatePerMinute" => '',
         "pulseOx" => '',
         "smokingStatus" => '',
+        "pain" => '',
     ];
 }else {
     if(!isset($contentData['date'])) $contentData['date'] = $note->effective_dateest;

+ 5 - 0
resources/views/app/patient/shipments.blade.php

@@ -178,6 +178,11 @@
                                                     </div>
                                                 </form>
                                             </div>
+                                            @if($iSupplyOrder->note && !$iSupplyOrder->note->is_signed_by_hcp)
+                                                <small class="text-danger text-sm">
+                                                <i class="fas fa-exclamation-triangle text-danger"></i> Note not signed by HCP.
+                                                </small>
+                                            @endif
                                         </td>
                                     </tr>
                                 @endforeach

+ 2 - 2
resources/views/app/patient/vitals-settings/bp-management-summary.blade.php

@@ -1,8 +1,8 @@
 <div class="w-100" moe center id="bp-management-settings-summary">
     <form start show url="">
       <fieldset disabled>
-        <div id="bpManagementComponentSummary" class="flex-container mx-0" v-cloak>
-            <div>
+        <div id="bpManagementComponentSummary" class="d-flex mx-0" v-cloak>
+            <div class="mr-3">
                 <div class="mb-2 d-flex align-items-center">
                     <span class="text-secondary min-width-140px w-50">BP Status</span>
                     <div class="w-50">

+ 7 - 9
resources/views/app/practice-management/_sort_header.blade.php

@@ -1,9 +1,7 @@
-<b class="{{request()->input('sort_by') === $key ? 'text-primary' : 'text-secondary'}}">{{$label}}</b>
-<span class="ml-2 d-inline-flex align-items-baseline">
-    <a href="{{ $route }}?{{queryLineExcept(['sort_by', 'sort_dir'])}}&sort_by={{$key}}&sort_dir=DESC" class="ml-1">
-        <i class="fa fa-arrow-up {{request()->input('sort_by') === $key && request()->input('sort_dir') === 'DESC' ? '' : 'on-hover-opaque text-secondary'}}"></i>
-    </a>
-    <a href="{{ $route }}?{{queryLineExcept(['sort_by', 'sort_dir'])}}&sort_by={{$key}}&sort_dir=ASC" class="ml-1">
-        <i class="fa fa-arrow-down {{request()->input('sort_by') === $key && request()->input('sort_dir') === 'ASC' ? '' : 'on-hover-opaque text-secondary'}}"></i>
-    </a>
-</span>
+<a href="{{ $route }}?{{queryLineExcept(['sort_by', 'sort_dir'])}}&sort_by={{$key}}&sort_dir={{request()->input('sort_by') === $key && request()->input('sort_dir') === 'ASC' ? 'DESC' : 'ASC'}}" class="ml-1 text-decoration-none">
+    <b class="{{request()->input('sort_by') === $key ? 'text-primary' : 'text-secondary'}}">{{$label}}</b>
+    <span class="ml-2 d-inline-flex align-items-baseline">
+        <i class="text-sm fa fa-chevron-up {{request()->input('sort_by') === $key && request()->input('sort_dir') === 'DESC' ? '' : 'on-hover-opaque text-secondary'}}"></i>
+        <i class="ml-1 text-sm fa fa-chevron-down {{request()->input('sort_by') === $key && request()->input('sort_dir') === 'ASC' ? '' : 'on-hover-opaque text-secondary'}}"></i>
+    </span>
+</a>

+ 18 - 0
resources/views/app/practice-management/remote-monitoring-row-by-pro-type.blade.php

@@ -0,0 +1,18 @@
+<?php
+
+$mStr = request()->input('m') ? request()->input('m') : date('m');
+$yStr = request()->input('y') ? request()->input('y') : date('Y');
+$rcmStartDate = $yStr . '-' . $mStr . '-' . '01';
+$m = +$mStr;
+$y = +$yStr;
+
+$daysDiff = -1;
+if($iPatient->most_recent_completed_mcp_note_date) {
+    $careMonthLastDay = date_add(date_create($rcmStartDate), date_interval_create_from_date_string("1 month"));
+    $careMonthLastDay = date_sub($careMonthLastDay, date_interval_create_from_date_string("1 day"));
+    $daysDiff = date_diff($careMonthLastDay, date_create($iPatient->most_recent_completed_mcp_note_date))->days;
+}
+$lastVisitWithin90Days = ($daysDiff !== -1 && $daysDiff <= 90);
+
+?>
+@include('app.practice-management.remote-monitoring-row-markup-by-pro-type')

+ 269 - 0
resources/views/app/practice-management/remote-monitoring-row-markup-by-pro-type.blade.php

@@ -0,0 +1,269 @@
+<tr data-client-uid="{{$iPatient->client_uid}}" data-care-month-uid="{{$iPatient->care_month_uid}}">
+    <td class="pl-2">
+        <a href="/patients/view/{{ $iPatient->client_uid }}/care-months/view/{{$iPatient->care_month_uid}}" class="text-nowrap"
+           native target="_blank"
+           open-in-stag-popup
+           update-parent="refresh-rpm-row-{{$trIndex}}"
+           popup-style="tall overflow-visible"
+           mc-initer="care-month-dashboard-{{$iPatient->client_uid}}"
+           title="{{$iPatient->client_name}}"
+        ><span class="sort-data">{{ $iPatient->client_name }}</span></a>
+    </td>
+
+    <td>{{friendly_date($iPatient->dob)}}</td>
+    <td>{!! $iPatient->is_enrolled_in_rm === 'YES' ? '<i class="fa fa-check text-success"></i>' : 'No' !!}</td>
+    <td>{!! $iPatient->is_assigned_cellular_bp_device ? '<i class="fa fa-check text-success"></i>' : 'No' !!}</td>
+    <td>{!! $iPatient->is_assigned_cellular_weight_scale_device ? '<i class="fa fa-check text-success"></i>' : 'No' !!}</td>
+    <td>
+        <div class="text-nowrap">
+            <span class="sort-data">{{$iPatient->most_recent_cellular_bp_sbp_mm_hg ?: '-'}}</span>/{{$iPatient->most_recent_cellular_bp_dbp_mm_hg ?: '-'}}
+            @if($iPatient->most_recent_cellular_bp_measurement_at)
+                <span class="text-sm text-secondary text-nowrap ml-1"
+                      title="{{friendly_date_time($iPatient->most_recent_cellular_bp_measurement_at)}}">({{friendly_date($iPatient->most_recent_cellular_bp_measurement_at)}})</span>
+            @endif
+        </div>
+    </td>
+    <td>
+        <div class="text-nowrap">
+            <span class="sort-data">{{$iPatient->most_recent_cellular_weight_value ? round($iPatient->most_recent_cellular_weight_value, 1) : '-'}}</span>
+            @if($iPatient->most_recent_cellular_weight_measurement_at)
+                <span class="text-sm text-secondary text-nowrap ml-1"
+                      title="{{friendly_date_time($iPatient->most_recent_cellular_weight_measurement_at)}}">({{friendly_date($iPatient->most_recent_cellular_weight_measurement_at)}})</span>
+            @endif
+        </div>
+    </td>
+    
+    <td>
+        <div class="d-flex align-items-baseline">
+            <i class="mr-1 text-sm fa {{$lastVisitWithin90Days ? 'fa-check text-success' : 'fa-exclamation-triangle text-danger on-hover-opaque'}}"></i>
+            <span class="sort-data">{{$daysDiff !== -1 ? $daysDiff : '-'}}</span>
+        </div>
+    </td>
+
+    @if($mode === 'mcp' || $mode === 'rmm')
+        @if($strategy === 'X16_DAYS_20_MINS_ON_OWN_MCP_COM_DURING_CM')
+            <td>
+                <div class="d-flex align-items-baseline">
+                    <i class="mr-1 text-sm fa {{$iPatient->has_mcp_interacted_with_client_about_rm ? 'fa-check text-success' : 'fa-exclamation-triangle text-danger on-hover-opaque'}}"></i>
+                    <span class="sort-data">{{$iPatient->has_mcp_interacted_with_client_about_rm ? 'Yes' : 'No'}}</span>
+                    @if($mode === 'mcp')
+                        <div moe large relative class="ml-2">
+                            <a start show class="py-0 mb-3 text-sm">Entry</a>
+                            <form url="/api/careMonthEntry/createForRm" right hook="refresh-rpm-row-{{$trIndex}}">
+                                <input type="hidden" name="careMonthUid" value="{{ $iPatient->care_month_uid }}">
+                                <input type="hidden" name="proUid" value="{{ $pro->uid }}">
+                                <div class="mb-2">
+                                    <div class="row">
+                                        <div class="col-6 pr-0">
+                                            <?php
+                                            $sD = strtotime($rcmStartDate);
+                                            $y = date('Y', $sD);
+                                            $m0 = date('m', $sD);
+                                            $d = date('t', $sD);
+                                            $defaultED = $sD >= strtotime(date('Y-m-d')) ? date('Y-m-d') : $rcmStartDate;
+                                            ?>
+                                            <label class="text-sm text-secondary mb-1">Effective Date</label>
+                                            <input autofocus type="date" min="{{ date($y . '-' . $m0 . '-01') }}" max="{{ date($y . '-' . $m0 . '-' . $d) }}"
+                                                   value="{{$defaultED}}"
+                                                   class="form-control form-control-sm w-100" name="effectiveDate"
+                                                   placeholder="Effective Date" required>
+                                        </div>
+                                        <div class="col-6">
+                                            <label class="text-sm text-secondary mb-1">Seconds</label>
+                                            <input type="number" min="75" max="300" class="form-control form-control-sm w-100 cm-time-value" name="timeInSeconds"
+                                                   value="75" placeholder="Time (secs.)" required>
+                                        </div>
+                                    </div>
+                                </div>
+                                <div class="mb-2 border border-info p-2 mt-2 bg-light">
+                                    <span>I have had interactive communication with <b>{{$iPatient->client_name}}</b>.</span>
+                                    <div class="d-flex border-top mt-2">
+                                        <label class="mt-2 mb-0 d-inline-flex align-items-center mr-3">
+                                            <input type="radio" class="mr-2" name="didProInteractWithClientAboutRm" value="true" required>
+                                            <span>Yes</span>
+                                        </label>
+                                        <label class="mt-2 mb-0 d-inline-flex align-items-center">
+                                            <input type="radio" class="mr-2" name="didProInteractWithClientAboutRm" value="false" required>
+                                            <span>No</span>
+                                        </label>
+                                    </div>
+                                </div>
+                                <div class="mb-2">
+                                    <label class="text-sm text-secondary mb-1">Memo</label>
+                                    <textarea class="form-control form-control-sm w-100" name="contentText"
+                                              required>Interacted with the patient</textarea>
+                                </div>
+                                <div class="d-flex align-items-center">
+                                    <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
+                                    <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
+                                </div>
+                            </form>
+                        </div>
+                    @endif
+                </div>
+            </td>
+        @endif
+        <td>
+            <div class="d-flex align-items-baseline">
+                <i class="mr-1 text-sm fa {{$iPatient->number_of_days_with_remote_measurements >= 16 ? 'fa-check text-success' : 'fa-exclamation-triangle text-danger on-hover-opaque'}}"></i>
+                <span class="sort-data">{{$iPatient->number_of_days_with_remote_measurements ?: 0}}</span>
+                @if($iPatient->number_of_days_with_remote_measurements < 16)
+                    <div moe relative class="ml-2">
+                        <a href="#" start show class="text-sm">SMS</a>
+                        <form url="/api/clientSms/createOutgoing" right="" class="mcp-theme-1" noreload="" style="display: none;">
+                            <input type="hidden" name="uid" value="{{ $iPatient->client_uid }}">
+                            <div class="mb-2">
+                                <label for="" class="text-sm text-secondary mb-1">Cell Number</label>
+                                <input type="text" class="form-control form-control-sm" name="cellNumber" value="{{$iPatient->cell_number}}">
+                            </div>
+                            <div class="mb-2">
+                                <label for="" class="text-sm text-secondary mb-1">Message</label>
+                                <textarea rows="5" class="form-control form-control-sm" name="message">Hi! This is {{$pro->displayName(true)}}, from Cardio 1st. Please check your blood pressure.</textarea>
+                            </div>
+                            <div class="d-flex align-items-center">
+                                <button class="btn btn-sm btn-primary mr-2" submit="">Send</button>
+                                <button class="btn btn-sm btn-default mr-2 border" cancel="">Cancel</button>
+                            </div>
+                        </form>
+                    </div>
+                @endif
+            </div>
+        </td>
+        @if($strategy === 'X16_DAYS_20_MINS_ON_OWN_MCP_COM_DURING_CM')
+            <td>
+                <div class="d-flex align-items-baseline">
+                    @if($mode === 'mcp')
+                        <span class="sort-data">{{$iPatient->rm_num_measurements_not_stamped_by_mcp}}</span>
+                        @if($iPatient->rm_num_measurements_not_stamped_by_mcp)
+                            <a href="{{ route('practice-management.rpm_work_matrix') }}?patientUid={{$iPatient->client_uid}}&careMonthUid={{$iPatient->care_month_uid}}"
+                               native target="_blank"
+                               open-in-stag-popup
+                               update-parent="refresh-rpm-row-{{$trIndex}}"
+                               popup-style="tall overflow-visible"
+                               class="ml-2 text-sm"
+                               mc-initer="rpm-work-matrix"
+                               title="RPM Work Matrix">
+                                View
+                            </a>
+                        @endif
+                    @elseif($mode === 'rmm')
+                        <span class="sort-data">{{$iPatient->rm_num_measurements_not_stamped_by_rmm}}</span>
+                        @if($iPatient->rm_num_measurements_not_stamped_by_rmm)
+                            <a href="{{ route('practice-management.rpm_work_matrix') }}?patientUid={{$iPatient->client_uid}}&careMonthUid={{$iPatient->care_month_uid}}"
+                               native target="_blank"
+                               open-in-stag-popup
+                               update-parent="refresh-rpm-row-{{$trIndex}}"
+                               popup-style="tall overflow-visible"
+                               class="ml-2 text-sm"
+                               mc-initer="rpm-work-matrix"
+                               title="RPM Work Matrix">
+                                View
+                            </a>
+                        @endif
+                    @endif
+                </div>
+            </td>
+        @endif
+    @elseif($mode === 'rme')
+        <td>
+            <div class="d-flex align-items-baseline">
+                <i class="mr-1 text-sm fa {{$iPatient->number_of_days_with_remote_measurements >= 16 ? 'fa-check text-success' : 'fa-exclamation-triangle text-danger on-hover-opaque'}}"></i>
+                <span class="sort-data">{{$iPatient->number_of_days_with_remote_measurements ?: 0}}</span>
+                @if($iPatient->number_of_days_with_remote_measurements < 16)
+                    <div moe relative class="ml-2">
+                        <a href="#" start show class="text-sm">SMS</a>
+                        <form url="/api/clientSms/createOutgoing" right="" class="mcp-theme-1" noreload="" style="display: none;">
+                            <input type="hidden" name="uid" value="{{ $iPatient->client_uid }}">
+                            <div class="mb-2">
+                                <label for="" class="text-sm text-secondary mb-1">Cell Number</label>
+                                <input type="text" class="form-control form-control-sm" name="cellNumber" value="{{$iPatient->cell_number}}">
+                            </div>
+                            <div class="mb-2">
+                                <label for="" class="text-sm text-secondary mb-1">Message</label>
+                                <textarea rows="5" class="form-control form-control-sm" name="message">Hi! This is {{$pro->displayName(true)}}, from Cardio 1st. Please check your blood pressure.</textarea>
+                            </div>
+                            <div class="d-flex align-items-center">
+                                <button class="btn btn-sm btn-primary mr-2" submit="">Send</button>
+                                <button class="btn btn-sm btn-default mr-2 border" cancel="">Cancel</button>
+                            </div>
+                        </form>
+                    </div>
+                @endif
+            </div>
+        </td>
+    @endif
+    <td>
+        @if($mode === 'mcp')
+            <div class="d-flex align-items-baseline">
+                <i class="mr-1 text-sm fa {{$iPatient->rm_total_time_in_seconds_by_mcp >= 1200 ? 'fa-check text-success' : 'fa-exclamation-triangle text-danger on-hover-opaque'}}"></i>
+                <span class="text-nowrap">{{round($iPatient->rm_total_time_in_seconds_by_mcp / 60)}}m {{round($iPatient->rm_total_time_in_seconds_by_mcp % 60)}}s</span>
+                <span class="sort-data d-none">{{$iPatient->rm_total_time_in_seconds_by_mcp}}</span>
+            </div>
+        @elseif($mode === 'rmm')
+            <div class="d-flex align-items-baseline">
+                <i class="mr-1 text-sm fa {{$iPatient->rm_total_time_in_seconds_by_rmm_pro >= 1200 ? 'fa-check text-success' : 'fa-exclamation-triangle text-danger on-hover-opaque'}}"></i>
+                <span class="text-nowrap">{{round($iPatient->rm_total_time_in_seconds_by_rmm_pro / 60)}}m {{round($iPatient->rm_total_time_in_seconds_by_rmm_pro % 60)}}s</span>
+                <span class="sort-data d-none">{{$iPatient->rm_total_time_in_seconds_by_rmm_pro}}</span>
+            </div>
+        @elseif($mode === 'rmm')
+            <div class="d-flex align-items-baseline">
+                <i class="mr-1 text-sm fa {{$iPatient->rm_total_time_in_seconds_by_rme_pro >= 1200 ? 'fa-check text-success' : 'fa-exclamation-triangle text-danger on-hover-opaque'}}"></i>
+                <span class="text-nowrap">{{round($iPatient->rm_total_time_in_seconds_by_rme_pro / 60)}}m {{round($iPatient->rm_total_time_in_seconds_by_rme_pro % 60)}}s</span>
+                <span class="sort-data d-none">{{$iPatient->rm_total_time_in_seconds_by_rme_pro}}</span>
+            </div>
+        @endif
+    </td>
+    <td>
+        @if($mode === 'mcp')
+            @if($lastVisitWithin90Days && $iPatient->has_mcp_interacted_with_client_about_rm && $iPatient->number_of_days_with_remote_measurements >= 16 && $iPatient->rm_total_time_in_seconds_by_mcp >= 1200)
+                <span class="text-success font-weight-bold">
+                    <i class="fa fa-check"></i>
+                    Yes 
+                    @if($iPatient->mcp_rm_generic_bill_id)
+                        (Billable: ${{friendly_money($iPatient->mcp_rm_generic_bill_expected_payment_amount)}})
+
+                        <div moe
+                                class="d-inline-block {{ $iPatient->mcp_rm_generic_bill_generic_pro_id !== $pro->id ? 'moe-disabled' : '' }}"
+                                title="{{ $iPatient->mcp_rm_generic_bill_generic_pro_id !== $pro->id ? 'Only the bill\'s pro can sign' : '' }}">
+                            <a class="text-nowrap" href="" show start>Sign</a>
+                            <form url="/api/bill/signAsGenericPro">
+                                <input type="hidden" name="uid" value="{{$iPatient->mcp_rm_generic_bill_uid}}">
+                                <p>Sign this bill?</p>
+                                <div class="mb-0">
+                                    <button class="btn btn-success btn-sm" submit>Sign</button>
+                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                </div>
+                            </form>
+                        </div>
+                    @endif
+                </span>
+            @else
+                <span class="text-danger font-weight-normal">
+                    Not yet
+                </span>
+            @endif
+        @elseif($mode === 'rmm')
+            @if($lastVisitWithin90Days && $iPatient->has_mcp_interacted_with_client_about_rm && $iPatient->number_of_days_with_remote_measurements >= 16 && $iPatient->rm_total_time_in_seconds_by_rmm_pro >= 1200)
+                <span class="text-success font-weight-bold">
+                    <i class="fa fa-check"></i>
+                    Yes
+                </span>
+            @else
+                <span class="text-danger font-weight-normal">
+                    Not yet
+                </span>
+            @endif
+        @elseif($mode === 'rme')
+            @if($lastVisitWithin90Days && $iPatient->number_of_days_with_remote_measurements >= 16)
+                <span class="text-success font-weight-bold">
+                    <i class="fa fa-check"></i>
+                    Yes
+                </span>
+            @else
+                <span class="text-danger font-weight-normal">
+                    Not yet
+                </span>
+            @endif
+        @endif
+    </td>
+</tr>

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

@@ -0,0 +1,425 @@
+@extends ('layouts/template')
+
+@section('content')
+    <?php
+    if (!function_exists('strategy_display')) {
+        function strategy_display($_strategy, $_mode)
+        {
+            switch ($_strategy) {
+                case 'X16_DAYS_20_MINS_ON_OWN_MCP_COM_DURING_CM':
+                    return '16 meas. days + 20 mins + comm. done during the caremonth';
+                case 'X16_DAYS':
+                    return '16 meas. days';
+                default:
+                    return '-';
+            }
+        }
+    }
+    ?>
+    <style>
+        #admin-table-rm-matrix_wrapper {
+            padding-top: 10px;
+        }
+    </style>
+    <link rel="stylesheet" href="https://cdn.datatables.net/1.11.5/css/jquery.dataTables.min.css">
+    <script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.min.js"></script>
+    <style>
+        #table-rm-matrix_length, #table-rm-matrix_info {
+            padding-left: 0.5rem;
+        }
+
+        #table-rm-matrix_filter {
+            padding-right: 0.5rem;
+        }
+
+        #table-rm-matrix_paginate {
+            padding: 0.5rem;
+        }
+    </style>
+    <div class="p-3 mcp-theme-1 body-height" id="practice-remote-monitoring" v-cloak>
+
+        <div class="card h-100">
+
+            <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">
+                        <span class="mr-4">
+                            <span class="font-size-14">Remote Monitoring</span>
+                            <i class="fas fa-arrow-right text-sm mx-1"></i>
+                            <b class="font-size-14">{{friendly_month(date((request()->input('y') ?: 'Y') . '-' . (request()->input('m') ?: 'm') . '-d'))}}</b>
+                        </span>
+                        <?php
+
+                        $mStr = request()->input('m') ? request()->input('m') : date('m');
+                        $yStr = request()->input('y') ? request()->input('y') : date('Y');
+                        $rcmStartDate = $yStr . '-' . $mStr . '-' . '01';
+                        $m = +$mStr;
+                        $y = +$yStr;
+                        ?>
+                        <a href="{{ route('practice-management.rpm_work_matrix') }}?m={{$mStr}}&y={{$yStr}}"
+                           native target="_blank"
+                           open-in-stag-popup
+                           update-parent
+                           popup-style="tall overflow-visible"
+                           class="mr-4 font-weight-bold"
+                           mc-initer="rpm-work-matrix"
+                           title="RPM Work Matrix">
+                            RPM Work Matrix
+                        </a>
+                        <span class="mr-2">Strategy:</span>
+                        @if($mode === 'mcp')
+                            {{strategy_display($pro->mcp_rpm_payment_strategy, $mode)}}
+                            <?php $strategy = $pro->mcp_rpm_payment_strategy; ?>
+                        @elseif($mode === 'rmm')
+                            {{strategy_display($pro->rme_payment_strategy, $mode)}}
+                            <?php $strategy = $pro->rmm_payment_strategy; ?>
+                        @elseif($mode === 'rmm')
+                            {{strategy_display($pro->rmm_payment_strategy, $mode)}}
+                            <?php $strategy = $pro->rme_payment_strategy; ?>
+                        @endif
+
+                        <?php $strategy = 'X16_DAYS_20_MINS_ON_OWN_MCP_COM_DURING_CM'; ?>
+
+                        <div class="ml-auto d-inline-flex flex-nowrap align-items-baseline">
+                            <span class="mr-2">Month</span>
+                            <select class="form-control form-control-sm min-width-unset width-100px mr-3" name="m"
+                                    onchange="fastLoad('{{route('practice-management.rpm-matrix-' . $mode)}}?' + $(this).closest('form').serialize())">
+                                <option value="01" {{$m === 1 ? 'selected' : ''}}>Jan</option>
+                                <option value="02" {{$m === 2 ? 'selected' : ''}}>Feb</option>
+                                <option value="03" {{$m === 3 ? 'selected' : ''}}>Mar</option>
+                                <option value="04" {{$m === 4 ? 'selected' : ''}}>Apr</option>
+                                <option value="05" {{$m === 5 ? 'selected' : ''}}>May</option>
+                                <option value="06" {{$m === 6 ? 'selected' : ''}}>Jun</option>
+                                <option value="07" {{$m === 7 ? 'selected' : ''}}>Jul</option>
+                                <option value="08" {{$m === 8 ? 'selected' : ''}}>Aug</option>
+                                <option value="09" {{$m === 9 ? 'selected' : ''}}>Sep</option>
+                                <option value="10" {{$m === 10 ? 'selected' : ''}}>Oct</option>
+                                <option value="11" {{$m === 11 ? 'selected' : ''}}>Nov</option>
+                                <option value="12" {{$m === 12 ? 'selected' : ''}}>Dec</option>
+                            </select>
+                            <span class="mr-2">Year</span>
+                            <select class="form-control form-control-sm min-width-unset width-100px" name="y"
+                                    onchange="fastLoad('{{route('practice-management.rpm-matrix-' . $mode)}}?' + $(this).closest('form').serialize())">
+                                <option value="2020" {{$y === 2020 ? 'selected' : ''}}>2020</option>
+                                <option value="2021" {{$y === 2021 ? 'selected' : ''}}>2021</option>
+                                <option value="2022" {{$y === 2022 ? 'selected' : ''}}>2022</option>
+                            </select>
+                        </div>
+                    </div>
+
+                    <hr class="m-neg-3 my-2"/>
+
+                    <div class="d-flex align-items-start">
+
+                        <div>
+                            <label class="mb-0 text-sm {{request()->input('f_name') ? 'text-info' : 'text-secondary'}}">Name</label>
+                            <input type="text"
+                                   class="mr-2 form-control form-control-sm min-width-unset max-width-110px"
+                                   name="f_name" value="{{request()->input('f_name')}}">
+                        </div>
+
+                        <div>
+                            <label class="mb-0 text-sm {{request()->input('f_dob') ? 'text-info' : 'text-secondary'}}">DOB</label>
+                            <div class="d-flex align-items-start">
+                                <select name="f_dob_op"
+                                        class="mr-1 form-control form-control-sm min-width-unset width-40px pl-0">
+                                    <option {{request()->input('f_dob_op') === '=' ? 'selected' : ''}} value="=">&equals;</option>
+                                    <option {{request()->input('f_dob_op') === '>' ? 'selected' : ''}} value=">">&gt;</option>
+                                    <option {{request()->input('f_dob_op') === '<' ? 'selected' : ''}} value="<">&lt;</option>
+                                    <option {{request()->input('f_dob_op') === '>=' ? 'selected' : ''}} value=">=">&ge;</option>
+                                    <option {{request()->input('f_dob_op') === '<=' ? 'selected' : ''}} value="<=">&le;</option>
+                                </select>
+                                <input type="date" name="f_dob"
+                                       value="{{request()->input('f_dob')}}"
+                                       class="mr-2 form-control form-control-sm min-width-unset max-width-140px">
+                            </div>
+                        </div>
+
+                        <div>
+                            <label class="mb-0 text-sm {{request()->input('f_rpm') && request()->input('f_rpm') !== 'any' ? 'text-info' : 'text-secondary'}}">RPM</label>
+                            <select name="f_rpm"
+                                    class="mr-2 form-control form-control-sm min-width-unset width-70px pl-0">
+                                <option {{request()->input('f_rpm') === 'any' ? 'selected' : ''}} value="any">Any</option>
+                                <option {{request()->input('f_rpm') === 'yes' ? 'selected' : ''}} value="yes">Yes</option>
+                                <option {{request()->input('f_rpm') === 'no' ? 'selected' : ''}} value="no">No</option>
+                            </select>
+                        </div>
+
+                        <div>
+                            <label class="mb-0 text-sm {{request()->input('f_cell_bp') && request()->input('f_cell_bp') !== 'any' ? 'text-info' : 'text-secondary'}}">Cell. BP</label>
+                            <select name="f_cell_bp"
+                                    class="mr-2 form-control form-control-sm min-width-unset width-70px pl-0">
+                                <option {{request()->input('f_cell_bp') === 'any' ? 'selected' : ''}} value="any">Any</option>
+                                <option {{request()->input('f_cell_bp') === 'yes' ? 'selected' : ''}} value="yes">Yes</option>
+                                <option {{request()->input('f_cell_bp') === 'no' ? 'selected' : ''}} value="no">No</option>
+                            </select>
+                        </div>
+
+                        <div>
+                            <label class="mb-0 text-sm {{request()->input('f_cell_wt') && request()->input('f_cell_wt') !== 'any' ? 'text-info' : 'text-secondary'}}">Cell. Wt</label>
+                            <select name="f_cell_wt"
+                                    class="mr-2 form-control form-control-sm min-width-unset width-70px pl-0">
+                                <option {{request()->input('f_cell_wt') === 'any' ? 'selected' : ''}} value="any">Any</option>
+                                <option {{request()->input('f_cell_wt') === 'yes' ? 'selected' : ''}} value="yes">Yes</option>
+                                <option {{request()->input('f_cell_wt') === 'no' ? 'selected' : ''}} value="no">No</option>
+                            </select>
+                        </div>
+
+                        @if($mode === 'mcp' || $mode === 'rmm')
+                        <div>
+                            <label class="mb-0 text-sm {{request()->input('f_comm') && request()->input('f_comm') !== 'any' ? 'text-info' : 'text-secondary'}}">Comm.</label>
+                            <select name="f_comm"
+                                    class="mr-2 form-control form-control-sm min-width-unset width-70px pl-0">
+                                <option {{request()->input('f_comm') === 'any' ? 'selected' : ''}} value="any">Any</option>
+                                <option {{request()->input('f_comm') === 'yes' ? 'selected' : ''}} value="yes">Yes</option>
+                                <option {{request()->input('f_comm') === 'no' ? 'selected' : ''}} value="no">No</option>
+                            </select>
+                        </div>
+                        @endif
+
+                        <div>
+                            <label class="mb-0 text-sm {{request()->input('f_md') ? 'text-info' : 'text-secondary'}}">Meas. Days</label>
+                            <div class="d-flex align-items-start">
+                                <select name="f_md_op"
+                                        class="mr-1 form-control form-control-sm min-width-unset width-40px pl-0">
+                                    <option {{request()->input('f_md_op') === '=' ? 'selected' : ''}} value="=">&equals;</option>
+                                    <option {{request()->input('f_md_op') === '>' ? 'selected' : ''}} value=">">&gt;</option>
+                                    <option {{request()->input('f_md_op') === '<' ? 'selected' : ''}} value="<">&lt;</option>
+                                    <option {{request()->input('f_md_op') === '>=' ? 'selected' : ''}} value=">=">&ge;</option>
+                                    <option {{request()->input('f_md_op') === '<=' ? 'selected' : ''}} value="<=">&le;</option>
+                                </select>
+                                <input type="number" name="f_md"
+                                       value="{{request()->input('f_md')}}"
+                                       class="mr-2 form-control form-control-sm min-width-unset width-70px">
+                            </div>
+                        </div>
+
+                        @if($mode === 'mcp' || $mode === 'rmm')
+                        <div>
+                            <label class="mb-0 text-sm {{request()->input('f_unst') ? 'text-info' : 'text-secondary'}}">Unstamped</label>
+                            <div class="d-flex align-items-start">
+                                <select name="f_unst_op"
+                                        class="mr-1 form-control form-control-sm min-width-unset width-40px pl-0">
+                                    <option {{request()->input('f_unst_op') === '=' ? 'selected' : ''}} value="=">&equals;</option>
+                                    <option {{request()->input('f_unst_op') === '>' ? 'selected' : ''}} value=">">&gt;</option>
+                                    <option {{request()->input('f_unst_op') === '<' ? 'selected' : ''}} value="<">&lt;</option>
+                                    <option {{request()->input('f_unst_op') === '>=' ? 'selected' : ''}} value=">=">&ge;</option>
+                                    <option {{request()->input('f_unst_op') === '<=' ? 'selected' : ''}} value="<=">&le;</option>
+                                </select>
+                                <input type="number" name="f_unst"
+                                       value="{{request()->input('f_unst')}}"
+                                       class="mr-2 form-control form-control-sm min-width-unset width-70px">
+                            </div>
+                        </div>
+                        @endif
+
+                        <div>
+                            <label class="mb-0 text-sm {{request()->input('f_mins') ? 'text-info' : 'text-secondary'}}">{{strtoupper($mode)}} Mins.</label>
+                            <div class="d-flex align-items-start">
+                                <select name="f_mins_op"
+                                        class="mr-1 form-control form-control-sm min-width-unset width-40px pl-0">
+                                    <option {{request()->input('f_mins_op') === '=' ? 'selected' : ''}} value="=">&equals;</option>
+                                    <option {{request()->input('f_mins_op') === '>' ? 'selected' : ''}} value=">">&gt;</option>
+                                    <option {{request()->input('f_mins_op') === '<' ? 'selected' : ''}} value="<">&lt;</option>
+                                    <option {{request()->input('f_mins_op') === '>=' ? 'selected' : ''}} value=">=">&ge;</option>
+                                    <option {{request()->input('f_mins_op') === '<=' ? 'selected' : ''}} value="<=">&le;</option>
+                                </select>
+                                <input type="number" name="f_mins"
+                                       value="{{request()->input('f_mins')}}"
+                                       class="mr-2 form-control form-control-sm min-width-unset width-70px">
+                            </div>
+                        </div>
+
+                        <div>
+                            <label class="mb-0 text-sm text-secondary">&nbsp;</label>
+                            <div class="d-flex align-items-start">
+                                <button class="btn-apply btn btn-sm btn-primary mr-2"><i class="fa fa-check"></i></button>
+                                <button class="btn-reset btn btn-sm btn-default bg-white text-secondary border"><i class="fa fa-times"></i></button>
+                            </div>
+                        </div>
+                    </div>
+
+                </form>
+            </div>
+
+            <?php $rc = request()->input('rc') ? request()->input('rc') : 1; ?>
+
+            <div class="card-body p-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>
+                                addMCHook(
+                                    'refresh-rpm-row-{{$trIndex}}',
+                                    function () {
+                                        refreshRpmRow({{$trIndex}});
+                                    }
+                                );
+                            </script>
+                            <?php $trIndex++; ?>
+                        @endforeach
+                        <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>
+                                <th class="border-0">DOB</th>
+                                <th class="border-0">RPM?</th>
+                                <th class="border-0">Cell. BP?</th>
+                                <th class="border-0">Cell. Scale?</th>
+                                <th class="border-0">Last BP</th>
+                                <th class="border-0">Last Wt</th>
+                                <th class="border-0">Days Since Last Visit</th>
+                                <th class="border-0">Interacted?</th>
+                                <th class="border-0">#Meas. Days</th>
+                                <th class="border-0">#Unstamped</th>
+                                <th class="border-0 {{$strategy === 'X16_DAYS_20_MINS_ON_OWN_MCP_COM_DURING_CM' ? '' : 'd-nonex'}}">#RPM Mins.</th>
+                                <th class="border-0">Billable</th>-->
+
+                                <th class="border-0 pl-2">@include('app.practice-management._sort_header', ['route' => route("practice-management.rpm-matrix-" . $mode), 'label' => 'Name', 'key' => 'client_name'])</th>
+                                <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("practice-management.rpm-matrix-" . $mode), 'label' => 'DOB', 'key' => 'dob'])</th>
+                                <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("practice-management.rpm-matrix-" . $mode), 'label' => 'RPM?', 'key' => 'is_enrolled_in_rm'])</th>
+                                <th class="border-0 text-secondary">Cell. BP?</th>
+                                <th class="border-0 text-secondary">Cell. Scale?</th>
+                                <th class="border-0 text-secondary">Latest BP</th>
+                                <th class="border-0 text-secondary">Latest Wt</th>
+                                <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("practice-management.rpm-matrix-" . $mode), 'label' => 'Days Since Last Visit', 'key' => 'most_recent_completed_mcp_note_date'])</th>
+                                @if($mode === 'mcp' || $mode === 'rmm')
+                                    @if($strategy === 'X16_DAYS_20_MINS_ON_OWN_MCP_COM_DURING_CM')
+                                        <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("practice-management.rpm-matrix-" . $mode), 'label' => 'Interacted?', 'key' => 'has_mcp_interacted_with_client_about_rm'])</th>
+                                    @endif
+                                    <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("practice-management.rpm-matrix-" . $mode), 'label' => '#Meas. Days', 'key' => 'number_of_days_with_remote_measurements'])</th>
+                                    @if($strategy === 'X16_DAYS_20_MINS_ON_OWN_MCP_COM_DURING_CM')
+                                        <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("practice-management.rpm-matrix-" . $mode), 'label' => '#Unstamped', 'key' => 'rm_num_measurements_not_stamped_by_mcp'])</th>
+                                    @endif
+                                    @if($mode === 'mcp')
+                                        <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("practice-management.rpm-matrix-" . $mode), 'label' => '#MCP Mins.', 'key' => 'rm_total_time_in_seconds_by_mcp'])</th>
+                                    @else
+                                        <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("practice-management.rpm-matrix-" . $mode), 'label' => '#RMM Mins.', 'key' => 'rm_total_time_in_seconds_by_rmm_pro'])</th>
+                                    @endif
+                                @elseif($mode === 'rme')
+                                    <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("practice-management.rpm-matrix-" . $mode), 'label' => '#Meas. Days', 'key' => 'number_of_days_with_remote_measurements'])</th>
+                                    <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("practice-management.rpm-matrix-" . $mode), 'label' => '#RME Mins.', 'key' => 'rm_total_time_in_seconds_by_rme_pro'])</th>
+                                @endif
+                                <th class="border-0 text-secondary"
+                                ">Billable</th>
+                            </tr>
+                            </thead>
+                            <tbody>
+                            <?php $trIndex = 0; ?>
+                            @foreach ($patients as $iPatient)
+                                <?php
+
+                                $daysDiff = -1;
+                                if ($iPatient->most_recent_completed_mcp_note_date) {
+                                    $careMonthLastDay = date_add(date_create($rcmStartDate), date_interval_create_from_date_string("1 month"));
+                                    $careMonthLastDay = date_sub($careMonthLastDay, date_interval_create_from_date_string("1 day"));
+                                    $daysDiff = date_diff($careMonthLastDay, date_create($iPatient->most_recent_completed_mcp_note_date))->days;
+                                }
+                                $lastVisitWithin90Days = ($daysDiff !== -1 && $daysDiff <= 90);
+
+                                ?>
+                                @include('app.practice-management.remote-monitoring-row-markup-by-pro-type')
+                                <?php $trIndex++; ?>
+                            @endforeach
+                            </tbody>
+                        </table>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+    <script>
+        (function () {
+            let dataTableInst = null;
+            window.refreshRpmRow = function (_index) {
+                let tr = $('#table-rm-matrix tbody tr:eq(' + _index + ')');
+                if (!tr.length) return;
+                let clientUid = tr.attr('data-client-uid'), careMonthUid = tr.attr('data-care-month-uid');
+                $.get('/rpm-matrix-row-{{$mode}}?m={{$mStr}}&y={{$yStr}}&clientUid=' + clientUid + '&careMonthUid=' + careMonthUid + '&trIndex=' + _index, _data => {
+                    let row = $(_data);
+                    @if(request()->input('dt'))
+                    row.find('>td').each(function (_columnIndex) {
+                        dataTableInst.cell(_index, _columnIndex).data(this.innerHTML); //.draw();
+                    });
+                    @else
+                    tr.replaceWith(row);
+                    @endif
+                    $('#practice-remote-monitoring [moe][initialized]').removeAttr('initialized');
+                    initMoes();
+                    tr.addClass('post-refresh-highlight');
+                    setTimeout(function () {
+                        tr.removeClass('post-refresh-highlight');
+                    }, 1000);
+                });
+            }
+
+            function init() {
+                @if(request()->input('dt'))
+                    dataTableInst = $('#table-rm-matrix').DataTable({
+                    paging: false,
+                    columnDefs: [
+                        {
+                            targets: [0, 8],
+                            type: 'string',
+                            render: function (data, type, row, meta) {
+                                if (type === 'sort') {
+                                    return $(data).find('.sort-data').first().text();
+                                }
+                                return data;
+                            },
+                        },
+                        {targets: 1, type: 'date'},
+                        {
+                            targets: 7,
+                            type: 'num',
+                            render: function (data, type, row, meta) {
+                                if (type === 'sort') {
+                                    return $(data).find('.sort-data').first().text();
+                                }
+                                return data;
+                            },
+                        },
+                        {
+                            targets: [5, 6, 10, 11, 12],
+                            type: 'num',
+                            render: function (data, type, row, meta) {
+                                if (type === 'sort') {
+                                    return +($(data).find('.sort-data').first().text());
+                                }
+                                return data;
+                            },
+                        },
+                    ]
+                });
+                @endif
+                $('#practice-remote-monitoring').removeAttr('v-cloak');
+                $('#practice-remote-monitoring [moe][initialized]').removeAttr('initialized');
+
+                let parent = $('#practice-remote-monitoring');
+
+                parent.find('.btn-apply')
+                    .off('click.filter')
+                    .on('click.filter', function() {
+                        fastLoad('{{route('practice-management.rpm-matrix-' . $mode)}}?' + $(this).closest('form').serialize());
+                        return false;
+                    });
+
+                parent.find('.btn-reset')
+                    .off('click.reset')
+                    .on('click.reset', function() {
+                        fastLoad('{{route("practice-management.rpm-matrix-" . $mode)}}');
+                        return false;
+                    });
+
+                initMoes();
+            }
+
+            addMCInitializer('practice-remote-monitoring', init, '#practice-remote-monitoring');
+        }).call(window);
+    </script>
+@endsection

+ 1 - 0
resources/views/app/rm-bills/inline.blade.php

@@ -12,6 +12,7 @@ use App\Models\Client;
 /** @var $entityUid */
 
 $genericBills = genericBills($pro, @$patient, @$entityType, @$entityUid);
+
 ?>
 
 @if(!count($genericBills))

+ 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>

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

@@ -129,7 +129,15 @@
                     </a>
                     <div class="dropdown-menu mcp-theme-1 no-overflow-menu p-0" aria-labelledby="practice-management">
                         @if($pro->pro_type !== 'ADMIN')
-                            <a class="dropdown-item" href="{{ route('practice-management.remote-monitoring') }}">Remote Monitoring</a>
+                            @if($pro->is_enrolled_as_mcp)
+                            <a class="dropdown-item" href="{{ route('practice-management.rpm-matrix-mcp') }}">RPM (MCP)</a>
+                            @endif
+                            @if($pro->is_considered_for_rmm)
+                            <a class="dropdown-item" href="{{ route('practice-management.rpm-matrix-rmm') }}">RPM (RMM)</a>
+                            @endif
+                            @if($pro->is_considered_for_rme)
+                            <a class="dropdown-item" href="{{ route('practice-management.rpm-matrix-rme') }}">RPM (RME)</a>
+                            @endif
                             <a class="dropdown-item" href="{{ route('practice-management.client-ccm-rm-status') }}">Client RM Status</a>
                         @else
                             <a class="dropdown-item" href="{{ route('practice-management.remote-monitoring-admin') }}">Remote Monitoring (admin)</a>

+ 7 - 0
routes/web.php

@@ -346,6 +346,10 @@ Route::middleware('pro.auth')->group(function () {
         Route::get('remote-monitoring-admin', 'PracticeManagementController@remoteMonitoringAdmin')->name('remote-monitoring-admin');
         Route::get('remote-monitoring-admin-count', 'PracticeManagementController@remoteMonitoringAdminCount')->name('remote-monitoring-admin-count');
 
+        Route::get('rpm-mcp', 'PracticeManagementController@remoteMonitoringMCP')->name('rpm-matrix-mcp');
+        Route::get('rpm-rmm', 'PracticeManagementController@remoteMonitoringRMM')->name('rpm-matrix-rmm');
+        Route::get('rpm-rme', 'PracticeManagementController@remoteMonitoringRME')->name('rpm-matrix-rme');
+
 
         //stat tree stuff
         Route::name('clauses.')->prefix('clauses/')->group(function () {
@@ -641,6 +645,9 @@ Route::middleware('pro.auth')->group(function () {
     // rpm matrix single row
     Route::get('/rpm-matrix-row', 'PracticeManagementController@remoteMonitoring_Row');
 
+    Route::get('rpm-matrix-row-mcp', 'PracticeManagementController@remoteMonitoring_RowMCP')->name('rpm-matrix-row-mcp');
+    Route::get('rpm-matrix-row-rmm', 'PracticeManagementController@remoteMonitoring_RowRMM')->name('rpm-matrix-row-rmm');
+    Route::get('rpm-matrix-row-rme', 'PracticeManagementController@remoteMonitoring_RowRME')->name('rpm-matrix-row-rme');
 
     Route::get('/appointment-confirmation-history/{appointment}', 'AppointmentController@appointmentConfirmationHistory')->name('appointment-confirmation-history');