Browse Source

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

Samson Mutunga 3 năm trước cách đây
mục cha
commit
d24bd8981d
100 tập tin đã thay đổi với 7508 bổ sung2166 xóa
  1. BIN
      .env.swp
  2. 72 2
      app/Helpers/helpers.php
  3. 112 0
      app/Http/Controllers/AdminController.php
  4. 5 0
      app/Http/Controllers/DnaController.php
  5. 25 16
      app/Http/Controllers/FDBPGController.php
  6. 6 0
      app/Http/Controllers/HomeController.php
  7. 5 0
      app/Http/Controllers/McpController.php
  8. 4 0
      app/Http/Controllers/NoteController.php
  9. 1095 26
      app/Http/Controllers/PracticeManagementController.php
  10. 8 3
      app/Http/Controllers/StatTreeController.php
  11. BIN
      app/Models/.Segment.php.swp
  12. 22 0
      app/Models/AdministratorBillFlagUpdate.php
  13. 16 0
      app/Models/Bill.php
  14. 19 0
      app/Models/CareMonth.php
  15. 32 4
      app/Models/Client.php
  16. 22 0
      app/Models/ClientCarePlanFlagUpdate.php
  17. 12 0
      app/Models/ClientPrimaryCoverage.php
  18. 21 0
      app/Models/ClientStickyNote.php
  19. 35 1
      app/Models/Note.php
  20. 116 0
      app/Models/Pro.php
  21. 3 2
      app/Models/Segment.php
  22. 4 1
      app/Models/SegmentSummarySuggestion.php
  23. 5 0
      app/Models/SupplyOrder.php
  24. 4 2
      config/app.php
  25. 7 0
      config/stag.php
  26. 284 0
      coverage_spec_april_29_2022.txt
  27. 21 4
      js-dev/click-to-copy.js
  28. 2 2
      js-dev/icd-autocomplete.js
  29. 29 4
      js-dev/option-list.js
  30. 164 1
      js-dev/stag-popup.js
  31. 1 1
      js-dev/stag-suggest.js
  32. 5 0
      js-dev/yemi.js
  33. 133 7
      public/css/style.css
  34. 2 0
      public/css/yemi.css
  35. 2 2
      public/js/icd-autocomplete.js
  36. 5 1
      public/v-splitter-px/v-splitter.js
  37. 36 2
      resources/views/app/admin/notes_pending_summary_suggestion.blade.php
  38. 2 2
      resources/views/app/admin/notes_rejected_summary_suggestion.blade.php
  39. 5 5
      resources/views/app/admin/part_b_patients-table.blade.php
  40. 26 8
      resources/views/app/admin/patients-table-extended.blade.php
  41. 2 2
      resources/views/app/admin/patients-table.blade.php
  42. 12 0
      resources/views/app/admin/patients_filters.blade.php
  43. 67 0
      resources/views/app/admin/patients_missing_default_settings.blade.php
  44. 163 0
      resources/views/app/admin/patients_missing_defsult_settings_filters.blade.php
  45. 16 7
      resources/views/app/dashboard-admin.blade.php
  46. 23 3
      resources/views/app/dashboard-mcp.blade.php
  47. 5 5
      resources/views/app/dna/patients-table.blade.php
  48. 1 1
      resources/views/app/mc.blade.php
  49. 2 2
      resources/views/app/mcp/notes_pending_billing.blade.php
  50. 2 2
      resources/views/app/mcp/notes_pending_signature.blade.php
  51. 2 2
      resources/views/app/mcp/notes_pending_summary_suggestion.blade.php
  52. 2 2
      resources/views/app/mcp/notes_rejected_summary_suggestion.blade.php
  53. 10 10
      resources/views/app/mcp/patients-table.blade.php
  54. 1 1
      resources/views/app/patient/allergies-center.blade.php
  55. 1 1
      resources/views/app/patient/canvas-sections/vitals/form.blade.php
  56. 1 1
      resources/views/app/patient/canvas-sections/vitals/summary.php
  57. 3 1
      resources/views/app/patient/care-month/_create-claim.blade.php
  58. 9 7
      resources/views/app/patient/care-month/_matrix.blade.php
  59. 9 7
      resources/views/app/patient/care-month/_work_matrix.blade.php
  60. 80 0
      resources/views/app/patient/care-month/care-month-update-mcp-onboarding-visit-info.blade.php
  61. 28 100
      resources/views/app/patient/care-month/dashboard.blade.php
  62. 0 59
      resources/views/app/patient/care-month/put-rm-reasons.blade.php
  63. 17 0
      resources/views/app/patient/care-month/refresh-suggestions-json.blade.php
  64. 3 46
      resources/views/app/patient/care-month/rm-reasons.blade.php
  65. 1 1
      resources/views/app/patient/careteam-center.blade.php
  66. 2 2
      resources/views/app/patient/client-primary-coverages.blade.php
  67. 193 174
      resources/views/app/patient/coverage-status.blade.php
  68. 205 0
      resources/views/app/patient/coverage-status_depricated.blade.php
  69. 14 4
      resources/views/app/patient/coverage_column_renderer.blade.php
  70. 12 12
      resources/views/app/patient/dashboard.blade.php
  71. 1 1
      resources/views/app/patient/goals-center.blade.php
  72. 1 1
      resources/views/app/patient/medications-center.blade.php
  73. 68 9
      resources/views/app/patient/medications-reconcile.blade.php
  74. 2 2
      resources/views/app/patient/module-specific-summary-renderers/allergy/plan.blade.php
  75. 2 2
      resources/views/app/patient/module-specific-summary-renderers/behavior/plan.blade.php
  76. 2 2
      resources/views/app/patient/module-specific-summary-renderers/care_team_member/plan.blade.php
  77. 2 2
      resources/views/app/patient/module-specific-summary-renderers/exercise/plan.blade.php
  78. 2 2
      resources/views/app/patient/module-specific-summary-renderers/goal/plan.blade.php
  79. 2 2
      resources/views/app/patient/module-specific-summary-renderers/medication/plan.blade.php
  80. 2 2
      resources/views/app/patient/module-specific-summary-renderers/nutrition/plan.blade.php
  81. 2 2
      resources/views/app/patient/module-specific-summary-renderers/problem/plan.blade.php
  82. 7 1
      resources/views/app/patient/note/_create-bill-only.blade.php
  83. 12 2
      resources/views/app/patient/note/_create-bill.blade.php
  84. 32 5
      resources/views/app/patient/note/_create-claim.blade.php
  85. 4 4
      resources/views/app/patient/note/_create-note-reason.blade.php
  86. 48 12
      resources/views/app/patient/note/dashboard-bu-b4-pure-soap.blade.php
  87. 3025 0
      resources/views/app/patient/note/dashboard-old.blade.php
  88. 44 8
      resources/views/app/patient/note/dashboard-univ.blade.php
  89. 288 1542
      resources/views/app/patient/note/dashboard.blade.php
  90. 9 0
      resources/views/app/patient/note/dashboard_script.blade.php
  91. 201 0
      resources/views/app/patient/note/flag-bill.blade.php
  92. 200 0
      resources/views/app/patient/note/flag-care-plan.blade.php
  93. 3 3
      resources/views/app/patient/note/follow-up-appointment.blade.php
  94. 17 13
      resources/views/app/patient/note/lhs-tree.blade.php
  95. 14 0
      resources/views/app/patient/note/note-segment-list-resolve.blade.php
  96. 33 0
      resources/views/app/patient/note/note-segment-list-single-col.blade.php
  97. 5 1
      resources/views/app/patient/note/note-segment-list-slim.blade.php
  98. 64 0
      resources/views/app/patient/note/partials/bill-flags-history.blade.php
  99. 100 0
      resources/views/app/patient/note/partials/care-plan-details.blade.php
  100. 63 0
      resources/views/app/patient/note/partials/care-plan-flags-history.blade.php

BIN
.env.swp


+ 72 - 2
app/Helpers/helpers.php

@@ -149,6 +149,25 @@ if(!function_exists('get_current_date')) {
 }
 }
 
 
 
 
+if(!function_exists('friendly_date_est')) {
+    function friendly_date_est($value, $default = '-') {
+
+        if(!$value || empty($value)) return $default;
+        try {
+
+            $realTimezone = resolve_timezone('EASTERN');
+            $date = new DateTime($value);
+            $date->setTimezone(new DateTimeZone($realTimezone));
+
+            return $date->format("m/d/y");
+
+        }
+        catch (Exception $e) {
+            return $e->getMessage();
+        }
+    }
+}
+
 
 
 if(!function_exists('friendly_date_time')) {
 if(!function_exists('friendly_date_time')) {
     function friendly_date_time($value, $includeTime = true, $default = '-', $long_year=false) {
     function friendly_date_time($value, $includeTime = true, $default = '-', $long_year=false) {
@@ -561,8 +580,9 @@ if(!function_exists('year_part_from_date')) {
 }
 }
 
 
 if(!function_exists('friendly_money')){
 if(!function_exists('friendly_money')){
-    function friendly_money($value){
-        return number_format((float)$value, 2, '.', '');
+    function friendly_money($value, $decimals = 2) {
+        // if($decimals === 0) return intval($value);
+        return number_format((float)$value, $decimals, '.', '');
     }
     }
 }
 }
 
 
@@ -885,3 +905,53 @@ if(!function_exists('get_doc_templates')){
         return $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";
+    }
+}
+
+if(!function_exists('format_number')) {
+    function format_number($number, $places = 2) {     
+        return number_format((float)$number, $places, '.', '');
+    }
+}
+
+if(!function_exists('toHumanReadable')) {
+    function toHumanReadable($name) {     
+        return ucwords(preg_replace("/[^0-9a-z]/i", " ", $name));
+    }
+}
+if(!function_exists('parseRender')) {
+    function parseRender($_data) {     
+        if($_data) {
+            $type = gettype($_data);
+            if(is_string($_data) || is_numeric($_data)) {
+                echo $_data;
+            }
+            else {
+                echo "<table class='table table-sm border w-100'>";
+                foreach($_data as $k => $v) {
+                    echo "<tr>";
+                    echo "<td><b class='text-secondary'>" . toHumanReadable($k) . "</b></td>";
+                    echo "<td>";
+                    if(is_object($v)) {
+                        parseRender($v);
+                    }
+                    elseif(is_array($v)) {
+                        foreach($v as $k2 => $v2) {
+                            parseRender($v2);
+                        }
+                    }
+                    else {
+                        echo $v;
+                    }
+                    echo "</td>";
+                    echo "</tr>";
+                }
+                echo "</table>";
+            }
+        }
+    }
+}

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

@@ -142,6 +142,8 @@ class AdminController extends Controller
                     return $q->where('client_engagement_status_category', $status)
                     return $q->where('client_engagement_status_category', $status)
                     ->orWhereNull('client_engagement_status_category');
                     ->orWhereNull('client_engagement_status_category');
                 });    
                 });    
+            }elseif($status = 'NONE'){
+                $patients->whereNull('client_engagement_status_category');
             }else {
             }else {
                 $patients->where('client_engagement_status_category', $status);
                 $patients->where('client_engagement_status_category', $status);
             }
             }
@@ -162,6 +164,13 @@ class AdminController extends Controller
             });
             });
         }
         }
 
 
+        $zero_deductible = $request->input('zero_deductible');
+        if($zero_deductible){
+            $patients = $patients->where(function ($q) {
+                $q->where('mpb_remaining', 0);
+            });
+        }
+
         $insurance = $request->get('insurance');
         $insurance = $request->get('insurance');
         if($insurance){
         if($insurance){
             if($insurance === 'MEDICARE'){
             if($insurance === 'MEDICARE'){
@@ -175,6 +184,12 @@ class AdminController extends Controller
             }
             }
         }
         }
 
 
+        $sortBy = $request->input('sort_by') ?: 'name_first';
+        $sortDir = $request->input('sort_dir') ?: 'ASC';
+
+        $patients = $patients->orderByRaw("$sortBy $sortDir NULLS LAST");
+
+
         $patients = $patients->orderBy('created_at', 'DESC')->paginate(25);
         $patients = $patients->orderBy('created_at', 'DESC')->paginate(25);
         return view('app.admin.patients', compact('patients', 'filters'));
         return view('app.admin.patients', compact('patients', 'filters'));
     }
     }
@@ -463,4 +478,101 @@ class AdminController extends Controller
         return view('app.admin.bdt_devices', compact('bdtDevices', 'filters'));
         return view('app.admin.bdt_devices', compact('bdtDevices', 'filters'));
     }
     }
 
 
+    public function patientsMissingDefasultSettings(Request $request){
+        $filters = $request->all();
+        $patients = Client::whereNull('shadow_pro_id');
+
+        $patients = $patients->where(function($qry){
+            return $qry->orWhereNull('mcp_pro_id')->orWhereNull('default_mcp_company_pro_id')->orWhereNull('default_mcp_company_pro_payer_id')->orWhereNull('default_mcp_company_location_id');
+        });
+
+        if ($request->input('name')) {
+            $name = trim($request->input('name'));
+            if ($name) {
+                $patients = $patients->where(function ($q) use ($name) {
+                    $q->where('name_first', 'ILIKE', '%' . $name . '%')
+                        ->orWhere('name_last', 'ILIKE', '%' . $name . '%');
+                });
+            }
+        }
+
+        if ($request->input('mcp')) {
+            if($request->input('mcp') == 'NO_MCP'){
+                $patients = $patients->whereNull('mcp_pro_id');
+            }else{
+                $mcp = Pro::where('uid', trim($request->input('mcp')))->first();
+                if ($mcp) {
+                    $patients = $patients->where('mcp_pro_id', $mcp->id);
+                }
+            }
+        }
+
+        if ($request->input('chart_number')) {
+            $patients = $patients->where('chart_number', 'ILIKE' , '%'.$request->input('chart_number').'%');
+        }
+
+        $status = $request->input('status');
+        if($status){
+            if($status == 'ACTIVE'){
+                $patients->where('is_active', true)->where(function($q) use ($status){
+                    return $q->where('client_engagement_status_category', $status)
+                    ->orWhereNull('client_engagement_status_category');
+                });    
+            }else {
+                $patients->where('client_engagement_status_category', $status);
+            }
+
+        }
+        
+        $insurance = $request->get('insurance');
+        if($insurance){
+            if($insurance === 'MEDICARE'){
+                $patients = $patients->whereHas('latestClientPrimaryCoverage', function($cpcQuery){
+                    return $cpcQuery->where('is_partbprimary', '=', 'YES');
+                });
+            }elseif($insurance === 'MEDICARE_PENDING'){
+                $patients = $patients->whereHas('latestClientPrimaryCoverage', function($cpcQuery){
+                    return $cpcQuery->where('plan_type', 'MEDICARE')->where('is_covered', '!=', 'YES');
+                });
+            }elseif($insurance === 'NOT_COVERED'){
+                $patients = $patients->whereHas('latestClientPrimaryCoverage', function($cpcQuery){
+                    return $cpcQuery->where('is_covered', '!=', 'YES');
+                });
+            }elseif($insurance === 'PENDING'){
+                $patients = $patients->whereHas('latestClientPrimaryCoverage', function($cpcQuery){
+                    return $cpcQuery->where('is_covered', '=', 'UNKNOWN');
+                });
+            }
+            else{
+                $patients = $patients->whereDoesntHave('latestClientPrimaryCoverage', function($cpcQuery){
+                    return $cpcQuery->where('is_partbprimary', '=', 'YES');
+                });
+            }
+        }
+        
+        $missing_default_settings = $request->get('missing_default_settings');
+        if($missing_default_settings){
+            if($missing_default_settings === 'NO_MCP') $patients = $patients->whereNull('mcp_pro_id');
+            if($missing_default_settings === 'NO_MCP_COMPANY_PRO') $patients = $patients->whereNull('default_mcp_company_pro_id');
+            if($missing_default_settings === 'NO_MCP_COMPANY_PRO_PAYER') $patients = $patients->whereNull('default_mcp_company_pro_payer_id');
+            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'));
+    }
+
 } 
 } 

+ 5 - 0
app/Http/Controllers/DnaController.php

@@ -79,6 +79,11 @@ class DnaController extends Controller
                 $patients->where('is_active', '<>', true);
                 $patients->where('is_active', '<>', true);
                 break;
                 break;
         }
         }
+        $sortBy = $request->input('sort_by') ?: 'name_first';
+        $sortDir = $request->input('sort_dir') ?: 'ASC';
+
+        $patients = $patients->orderByRaw("$sortBy $sortDir NULLS LAST");
+        
         $patients = $patients->orderBy('created_at', 'DESC')->paginate(20);
         $patients = $patients->orderBy('created_at', 'DESC')->paginate(20);
         return view('app.dna.patients', compact('patients', 'filters'));
         return view('app.dna.patients', compact('patients', 'filters'));
     }
     }

+ 25 - 16
app/Http/Controllers/FDBPGController.php

@@ -87,15 +87,16 @@ SELECT r_med.medid,
        r_med.med_medid_desc as text,
        r_med.med_medid_desc as text,
        r_med.gcn_seqno,
        r_med.gcn_seqno,
        r_dosage_form.routed_dosage_form_med_id,
        r_dosage_form.routed_dosage_form_med_id,
-       r_route.routed_med_id
+       r_route.routed_med_id,
+       SIMILARITY(r_med.med_medid_desc, :term) as sim1
 FROM rmiid1_med r_med
 FROM rmiid1_med r_med
          JOIN rmidfid1_routed_dose_form_med r_dosage_form
          JOIN rmidfid1_routed_dose_form_med r_dosage_form
               ON r_med.routed_dosage_form_med_id = r_dosage_form.routed_dosage_form_med_id
               ON r_med.routed_dosage_form_med_id = r_dosage_form.routed_dosage_form_med_id
          JOIN rmirmid1_routed_med r_route ON r_dosage_form.routed_med_id = r_route.routed_med_id
          JOIN rmirmid1_routed_med r_route ON r_dosage_form.routed_med_id = r_route.routed_med_id
 WHERE r_med.med_status_cd = '0'
 WHERE r_med.med_status_cd = '0'
-  AND r_med.med_medid_desc ILIKE :term
-ORDER BY REPLACE(r_med.med_medid_desc, '-', 'x')",
-            ['term' => $term . '%']
+  AND SIMILARITY(r_med.med_medid_desc, :term) >= " . config('stag.fuzzySearchMinimumSimilarityScore')['medication'] . "
+ORDER BY sim1 DESC",
+            ['term' => $term]
         );
         );
         return json_encode([
         return json_encode([
             "success" => true,
             "success" => true,
@@ -229,16 +230,24 @@ where r1.related_dxid = :dxid
         $term = $request->input('term') ? trim($request->input('term')) : '';
         $term = $request->input('term') ? trim($request->input('term')) : '';
         if (empty($term)) return '';
         if (empty($term)) return '';
         $matches = DB::connection('pgsql_fdb')->select("
         $matches = DB::connection('pgsql_fdb')->select("
-SELECT DISTINCT ON (r1.search_icd_cd) search_icd_cd as sub_text, r1.icd_cd_type, r2.icd_desc as text, r1.related_dxid as dxid, r1.fml_clin_code, r1.fml_nav_code, r3.dxid_desc56
+SELECT distinct on (sim1) SIMILARITY(r2.icd_desc, :term) as sim1,
+       search_icd_cd                            as sub_text,
+       r1.icd_cd_type,
+       r2.icd_desc                              as text,
+       r1.related_dxid                          as dxid,
+       r1.fml_clin_code,
+       r1.fml_nav_code,
+       r3.dxid_desc56
 FROM RFMLISR1_ICD_SEARCH r1
 FROM RFMLISR1_ICD_SEARCH r1
-JOIN RFMLINM1_ICD_DESC r2 ON r1.search_icd_cd = r2.icd_cd
-LEFT OUTER JOIN RFMLDX0_DXID r3 ON r1.related_dxid = r3.dxid
+         JOIN RFMLINM1_ICD_DESC r2 ON r1.search_icd_cd = r2.icd_cd
+         LEFT OUTER JOIN RFMLDX0_DXID r3 ON r1.related_dxid = r3.dxid
 WHERE r1.icd_cd_type = '05'
 WHERE r1.icd_cd_type = '05'
-    AND r1.fml_clin_code = '01'
-    AND (r2.icd_desc ILIKE :term OR r1.search_icd_cd ILIKE :term)
-ORDER BY r1.search_icd_cd ASC, r1.fml_nav_code ASC
+  AND r1.fml_clin_code = '01'
+  AND (SIMILARITY(r2.icd_desc, :term) >= " . config('stag.fuzzySearchMinimumSimilarityScore')['problem'] . " OR
+       r1.search_icd_cd ILIKE :term2)
+ORDER BY sim1 DESC
 ",
 ",
-            ['term' => '%' . $term . '%']
+            ['term' => $term, 'term2' => $term . '%']
         );
         );
         return response()->json(['success'=>true, 'data'=>$matches]);
         return response()->json(['success'=>true, 'data'=>$matches]);
     }
     }
@@ -265,13 +274,13 @@ ORDER BY r1.dam_concept_id_desc
         $term = $request->input('term') ? trim($request->input('term')) : '';
         $term = $request->input('term') ? trim($request->input('term')) : '';
         if (empty($term)) return '';
         if (empty($term)) return '';
         $matches = DB::connection('pgsql_fdb')->select("
         $matches = DB::connection('pgsql_fdb')->select("
-SELECT r1.dam_concept_id, r1.dam_concept_id_typ, r1.dam_concept_id_desc as text,
-r2.dam_concept_id_typ_desc as sub_text
+SELECT distinct on (sim1) SIMILARITY(r1.dam_concept_id_desc, :term) as sim1,
+       r1.dam_concept_id, r1.dam_concept_id_typ, r1.dam_concept_id_desc as text
 FROM rdamca0_concept r1 join rdamcd0_picklist_con_typ_desc r2 on r1.dam_concept_id_typ = r2.dam_concept_id_typ
 FROM rdamca0_concept r1 join rdamcd0_picklist_con_typ_desc r2 on r1.dam_concept_id_typ = r2.dam_concept_id_typ
-WHERE (r1.dam_concept_id_desc ILIKE :term)
-ORDER BY r1.dam_concept_id_desc
+WHERE SIMILARITY(r1.dam_concept_id_desc, :term) >= " . config('stag.fuzzySearchMinimumSimilarityScore')['allergy'] . "
+ORDER BY sim1 DESC
 ",
 ",
-            ['term' => $term . '%']
+            ['term' => $term]
         );
         );
         return json_encode([
         return json_encode([
             "success" => true,
             "success" => true,

+ 6 - 0
app/Http/Controllers/HomeController.php

@@ -1894,6 +1894,12 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
                 case 'non-admin':
                 case 'non-admin':
                     $pros->where('pro_type', '!=', 'ADMIN');
                     $pros->where('pro_type', '!=', 'ADMIN');
                     break;
                     break;
+                case 'rmm':
+                    $pros->where('is_considered_for_rmm', TRUE);
+                    break;
+                case 'rme':
+                    $pros->where('is_considered_for_rme', TRUE);
+                    break;
             }
             }
         }
         }
 
 

+ 5 - 0
app/Http/Controllers/McpController.php

@@ -130,6 +130,11 @@ class McpController extends Controller
             $patients = $patients->where('chart_number', 'ILIKE' , '%'.$request->input('chart_number').'%');
             $patients = $patients->where('chart_number', 'ILIKE' , '%'.$request->input('chart_number').'%');
         }
         }
 
 
+        $sortBy = $request->input('sort_by') ?: 'name_first';
+        $sortDir = $request->input('sort_dir') ?: 'ASC';
+
+        $patients = $patients->orderByRaw("$sortBy $sortDir NULLS LAST");
+
         $patients = $patients->orderBy('created_at', 'DESC')->paginate(50);
         $patients = $patients->orderBy('created_at', 'DESC')->paginate(50);
         return view('app.mcp.patients', compact('patients', 'filters'));
         return view('app.mcp.patients', compact('patients', 'filters'));
     }
     }

+ 4 - 0
app/Http/Controllers/NoteController.php

@@ -118,6 +118,10 @@ class NoteController extends Controller
         return view("app.patient.note.print", compact('patient', 'note'));
         return view("app.patient.note.print", compact('patient', 'note'));
     }
     }
 
 
+    public function resolve(Request $request, Client $patient, Note $note) {
+        return view("app.patient.note.resolve", compact('patient', 'note'));
+    }
+
     public function getHtmlForSegment($segmentUid, $sessionKey){
     public function getHtmlForSegment($segmentUid, $sessionKey){
 
 
         $summaryHtml = '';
         $summaryHtml = '';

+ 1095 - 26
app/Http/Controllers/PracticeManagementController.php

@@ -38,6 +38,7 @@ use App\Models\ClientMeasurementDaysPerMonth;
 use App\Models\ClientBDTDevice;
 use App\Models\ClientBDTDevice;
 use App\Models\ClientMemo;
 use App\Models\ClientMemo;
 use Carbon\Carbon;
 use Carbon\Carbon;
+use Illuminate\Pagination\LengthAwarePaginator;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Http;
 use Illuminate\Support\Facades\Http;
 use PDF;
 use PDF;
@@ -114,8 +115,29 @@ SELECT effective_date, count(*), sum(number_of_units) as units FROM bill WHERE c
 
 
     public function clientProChanges(Request $request)
     public function clientProChanges(Request $request)
     {
     {
-        $rows = ClientProChange::orderByRaw('created_at::date DESC')->orderBy('client_id', 'desc')->paginate(20);
-        return view ('app.practice-management.client-pro-changes', compact('rows'));
+        $filters = $request->all();
+        $rows = ClientProChange::query();
+        $associationTypes = DB::table('client_pro_change')->select('responsibility_type')->distinct()->pluck('responsibility_type')->toArray();
+
+        $this->filterMultiQuery($request, $rows, 'created_at', 'date_category', 'date_value_1', 'date_value_2');
+        $this->filterSimpleQuery($request, $rows, 'responsibility_type', 'responsibility_type');
+
+        $oldProUid = $request->get('old_pro');
+        if($oldProUid){
+            $oldPro = Pro::where('uid', $oldProUid)->first();
+            $rows = $rows->where('previous_pro_id',$oldPro->id);
+
+        }
+
+        $newProUid = $request->get('new_pro');
+        if($newProUid){
+            $newPro = Pro::where('uid', $newProUid)->first();
+            $rows = $rows->where('new_pro_id',$newPro->id);
+
+        }
+
+        $rows = $rows->orderByRaw('created_at::date DESC')->orderBy('client_id', 'desc')->paginate(20);
+        return view ('app.practice-management.client-pro-changes', compact('rows', 'filters', 'associationTypes'));
     }
     }
 
 
     public function billingReport(Request $request)
     public function billingReport(Request $request)
@@ -306,10 +328,11 @@ SELECT effective_date, count(*), sum(number_of_units) as units FROM bill WHERE c
 
 
     public function allNotes(Request $request)
     public function allNotes(Request $request)
     {
     {
+        $filters = $request->all();
         $query = Note::query();
         $query = Note::query();
+        $query = $query->where('is_core_note', false);
+        
         
         
-        $filters = $request->all();
-
         $this->filterMultiQuery($request, $query, 'created_at', 'created_at_category', 'created_at_value_1', 'created_at_value_2');
         $this->filterMultiQuery($request, $query, 'created_at', 'created_at_category', 'created_at_value_1', 'created_at_value_2');
         $this->filterMultiQuery($request, $query, 'effective_dateest', 'effective_date_category', 'effective_date_value_1', 'effective_date_value_2');
         $this->filterMultiQuery($request, $query, 'effective_dateest', 'effective_date_category', 'effective_date_value_1', 'effective_date_value_2');
        
        
@@ -318,6 +341,11 @@ SELECT effective_date, count(*), sum(number_of_units) as units FROM bill WHERE c
             $query = $query->whereIn('hcp_pro_id', $filterByProsIDs);
             $query = $query->whereIn('hcp_pro_id', $filterByProsIDs);
         }
         }
 
 
+        $filterByAllyProsIDs = $request->get('ally_pros');
+        if($filterByAllyProsIDs && count($filterByAllyProsIDs)){
+            $query = $query->whereIn('ally_pro_id', $filterByAllyProsIDs);
+        }
+
         $filterByPatientsIDs = $request->get('patients');
         $filterByPatientsIDs = $request->get('patients');
         if($filterByPatientsIDs && count($filterByPatientsIDs)){
         if($filterByPatientsIDs && count($filterByPatientsIDs)){
             $query = $query->whereIn('client_id', $filterByPatientsIDs);
             $query = $query->whereIn('client_id', $filterByPatientsIDs);
@@ -326,21 +354,27 @@ SELECT effective_date, count(*), sum(number_of_units) as units FROM bill WHERE c
         $status = $request->get('status');
         $status = $request->get('status');
         if($status){
         if($status){
             if($status == 'CANCELLED') $query = $query->where('is_cancelled', true);
             if($status == 'CANCELLED') $query = $query->where('is_cancelled', true);
+            if($status == 'SIGNED') $query = $query->where('is_signed_by_hcp', true);
             if($status == 'NOT_YET_SIGNED') $query = $query->where('is_signed_by_hcp', false);
             if($status == 'NOT_YET_SIGNED') $query = $query->where('is_signed_by_hcp', false);
             if($status == 'NOT_YET_SIGNED_BUT_ALLY_SIGNED') $query = $query->where('is_signed_by_hcp', false)->where('is_signed_by_ally', true);
             if($status == 'NOT_YET_SIGNED_BUT_ALLY_SIGNED') $query = $query->where('is_signed_by_hcp', false)->where('is_signed_by_ally', true);
+            if($status == 'WITH_BILLS') $query = $query->where('is_signed_by_hcp', true)->where('is_cancelled', false)->whereHas('bills');
             if($status == 'WITHOUT_BILLS') $query = $query->where('is_signed_by_hcp', true)->where('is_cancelled', false)->whereDoesntHave('bills');
             if($status == 'WITHOUT_BILLS') $query = $query->where('is_signed_by_hcp', true)->where('is_cancelled', false)->whereDoesntHave('bills');
+            
         }
         }
 
 
         
         
-        $allProsWithNotesIDs = Note::pluck('hcp_pro_id')->toArray();
+        $allProsWithNotesIDs = DB::table('note')->pluck('hcp_pro_id')->toArray();
         $allProsWithNotes = Pro::whereIn('id', $allProsWithNotesIDs)->get();
         $allProsWithNotes = Pro::whereIn('id', $allProsWithNotesIDs)->get();
 
 
-        $allPatientsWithNotesIDs = Note::pluck('client_id')->toArray();
+        $allPatientsWithNotesIDs = DB::table('note')->pluck('client_id')->toArray();
         $allPatientsWithNotes = Client::whereIn('id', $allPatientsWithNotesIDs)->get();
         $allPatientsWithNotes = Client::whereIn('id', $allPatientsWithNotesIDs)->get();
 
 
+        $allAllyProsIDs = DB::table('note')->pluck('ally_pro_id')->toArray();
+        $allAllyPros = Pro::whereIn('id', $allAllyProsIDs)->get();
+
         $notes = $query->orderBy('created_at', 'desc')->paginate(30);
         $notes = $query->orderBy('created_at', 'desc')->paginate(30);
 
 
-        return view('app.practice-management.all-notes', compact('notes', 'filters','allProsWithNotes', 'allPatientsWithNotes'));
+        return view('app.practice-management.all-notes', compact('notes', 'filters','allProsWithNotes', 'allPatientsWithNotes', 'allAllyPros'));
     }
     }
 
 
     public function dnaNotesPendingMcpSign(Request $request)
     public function dnaNotesPendingMcpSign(Request $request)
@@ -485,7 +519,7 @@ SELECT effective_date, count(*), sum(number_of_units) as units FROM bill WHERE c
                 ->orWhere('manager_pro_id', $performer->pro_id)
                 ->orWhere('manager_pro_id', $performer->pro_id)
                 ->orWhere('ordering_pro_id', $performer->pro_id)
                 ->orWhere('ordering_pro_id', $performer->pro_id)
                 ->orWhere('initiating_pro_id', $performer->pro_id);
                 ->orWhere('initiating_pro_id', $performer->pro_id);
-        });
+        })->where('category', 'other');
         if ($filter === 'open') {
         if ($filter === 'open') {
             $myTickets = $myTickets->where('is_open', true);
             $myTickets = $myTickets->where('is_open', true);
         } else if ($filter === 'closed') {
         } else if ($filter === 'closed') {
@@ -967,6 +1001,24 @@ SELECT effective_date, count(*), sum(number_of_units) as units FROM bill WHERE c
         } else {
         } else {
             $targetPro = $performerPro;
             $targetPro = $performerPro;
         }
         }
+
+        // calculate totals (without pagination)
+        $fPros = Pro::whereNotNull('balance')->where('balance', '>', 0)->get();
+        $grandTotal = 0;
+        $companies = [];
+        foreach ($fPros as $row) {
+            foreach($row->companyPros as $companyPro) {
+                if($companyPro->balance) {
+                    if(!isset($companies[$companyPro->company->name])) {
+                        $companies[$companyPro->company->name] = 0;
+                    }
+                    $companies[$companyPro->company->name] += $companyPro->balance;
+                    $grandTotal += $companyPro->balance;
+                }
+            }
+        }
+        arsort($companies);
+
         $fPros = Pro::whereNotNull('balance');
         $fPros = Pro::whereNotNull('balance');
         if($targetPro) {
         if($targetPro) {
             $fPros = $fPros->where('uid', $targetPro->uid);
             $fPros = $fPros->where('uid', $targetPro->uid);
@@ -976,7 +1028,7 @@ SELECT effective_date, count(*), sum(number_of_units) as units FROM bill WHERE c
             ->orderBy('name_first')
             ->orderBy('name_first')
             ->orderBy('name_last')
             ->orderBy('name_last')
             ->paginate();
             ->paginate();
-        return view('app.practice-management.pro-financials', compact('fPros', 'targetPro'));
+        return view('app.practice-management.pro-financials', compact('fPros', 'targetPro', 'grandTotal', 'companies'));
     }
     }
 
 
     public function hcpBillMatrix(Request $request, $proUid = null)
     public function hcpBillMatrix(Request $request, $proUid = null)
@@ -1134,11 +1186,11 @@ SELECT client.name_first, client.name_last,
        client.rmm_pro_id,
        client.rmm_pro_id,
        client.rme_pro_id,
        client.rme_pro_id,
        client.cell_number,
        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
 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 = (
      left join note mrmnote on mrmnote.id = (
         select max(n.id) from note n 
         select max(n.id) from note n 
@@ -1202,11 +1254,11 @@ SELECT client.name_first, client.name_last,
        client.rmm_pro_id,
        client.rmm_pro_id,
        client.rme_pro_id,
        client.rme_pro_id,
        client.cell_number,
        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
 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 = (
      left join note mrmnote on mrmnote.id = (
         select max(n.id) from note n 
         select max(n.id) from note n 
@@ -1225,6 +1277,645 @@ WHERE care_month.uid = '{$careMonthUid}' AND client.uid = '{$clientUid}'
         return view('app.practice-management.remote-monitoring-row', ['iPatient' => $patients[0], 'trIndex' => $request->input('trIndex')]);
         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 remoteMonitoring_RowForAdmin(Request $request) {
+
+        $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-for-admin', ['iPatient' => $patients[0], 'trIndex' => $request->input('trIndex')]);
+    }
+
+    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";
+
+        // special case of if-bill-exists
+        if($sortBy === 'mcp_rm_generic_bill_id' || $sortBy === 'rmm_rm_generic_bill_id') {
+            if($sortDir === 'ASC') {
+                $orderBy = "ORDER BY $sortBy $sortDir NULLS FIRST";
+            }
+            else {
+                $orderBy = "ORDER BY $sortBy $sortDir NULLS LAST";
+            }
+        }
+
+        // default sort
+        if(!$request->input('sort_by')) {
+            if($mode === 'mcp') {
+                $orderBy = "ORDER BY care_month.number_of_days_with_remote_measurements DESC NULLS LAST, care_month.rm_total_time_in_seconds_by_mcp DESC NULLS LAST";
+            }
+            elseif ($mode === 'rmm') {
+                $orderBy = "ORDER BY care_month.number_of_days_with_remote_measurements DESC NULLS LAST, care_month.rm_total_time_in_seconds_by_rmm_pro DESC NULLS LAST";
+            }
+            else {
+                $orderBy = "ORDER BY care_month.number_of_days_with_remote_measurements DESC NULLS LAST";
+            }
+        }
+        else {
+            $sortBy = $request->input('sort_by');
+            $sortDir = $request->input('sort_dir');
+            if($sortBy && $sortDir) {
+                if(!in_array($sortBy, ['number_of_days_with_remote_measurements', 'rm_total_time_in_seconds_by_mcp', 'rm_total_time_in_seconds_by_rmm_pro'])) {
+                    if($mode === 'mcp') {
+                        $orderBy = "ORDER BY $sortBy $sortDir NULLS LAST, care_month.number_of_days_with_remote_measurements DESC NULLS LAST, care_month.rm_total_time_in_seconds_by_mcp DESC NULLS LAST";
+                    }
+                    elseif ($mode === 'rmm') {
+                        $orderBy = "ORDER BY $sortBy $sortDir NULLS LAST, care_month.number_of_days_with_remote_measurements DESC NULLS LAST, care_month.rm_total_time_in_seconds_by_rmm_pro DESC NULLS LAST";
+                    }
+                    else {
+                        $orderBy = "ORDER BY $sortBy $sortDir NULLS LAST, care_month.number_of_days_with_remote_measurements DESC NULLS LAST";
+                    }
+                }
+                else {
+                    $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($mode === 'mcp' || $mode === 'rmm') {
+            if(trim($request->input('f_billable'))) {
+                $v = trim($request->input('f_billable'));
+                if($v === 'yes') {
+                    $conditions[] = "(care_month.{$mode}_rm_generic_bill_id IS NOT NULL)";
+                }
+                elseif($v === 'no') {
+                    $conditions[] = "(care_month.{$mode}_rm_generic_bill_id IS NULL)";
+                }
+            }
+        }
+
+        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})";
+        }
+
+        if($request->input('not-enrolled')) {
+            $conditions[] = "(client.is_enrolled_in_rm != 'YES')";
+        }
+        else {
+            $conditions[] = "(client.is_enrolled_in_rm = 'YES')";
+        }
+
+        $proTypeCondition = '';
+        $genericBillIdColumns = '';
+        $genericBillJoinClause = '';
+        switch($mode) {
+            case 'mcp':
+                $proTypeCondition = "care_month.mcp_pro_id = {$performer->pro->id}";
+                $genericBillIdColumns = "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,
+                   bill.is_signed_by_generic_pro as mcp_rm_generic_bill_signed";
+                $genericBillJoinClause = 'left join bill on care_month.mcp_rm_generic_bill_id = bill.id';
+                break;
+            case 'rmm':
+                $proTypeCondition = "care_month.rmm_pro_id = {$performer->pro->id}";
+                $genericBillIdColumns = "care_month.rmm_rm_generic_bill_id,
+                   bill.uid as rmm_rm_generic_bill_uid,
+                   bill.generic_pro_id as rmm_rm_generic_bill_generic_pro_id,
+                   bill.generic_pro_expected_payment_amount as rmm_rm_generic_bill_expected_payment_amount,
+                   bill.is_signed_by_generic_pro as rmm_rm_generic_bill_signed";
+                $genericBillJoinClause = 'left join bill on care_month.rmm_rm_generic_bill_id = bill.id';
+                break;
+            case 'rme':
+                $proTypeCondition = "left join bill on 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,
+       {$genericBillIdColumns}
+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
+    {$genericBillJoinClause}
+    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 rpmMatrixForAdmin(Request $request) {
+
+        $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";
+
+        // special case of if-bill-exists
+        if($sortBy === 'mcp_rm_generic_bill_id' || $sortBy === 'rmm_rm_generic_bill_id') {
+            if($sortDir === 'ASC') {
+                $orderBy = "ORDER BY $sortBy $sortDir NULLS FIRST";
+            }
+            else {
+                $orderBy = "ORDER BY $sortBy $sortDir NULLS LAST";
+            }
+        }
+
+        // default sort
+        if(!$request->input('sort_by')) {
+            $orderBy = "ORDER BY care_month.number_of_days_with_remote_measurements DESC NULLS LAST, care_month.rm_total_time_in_seconds_by_mcp DESC NULLS LAST, care_month.rm_total_time_in_seconds_by_rmm_pro DESC NULLS LAST";
+        }
+        else {
+            $sortBy = $request->input('sort_by');
+            $sortDir = $request->input('sort_dir');
+            if($sortBy && $sortDir) {
+                if(!in_array($sortBy, ['number_of_days_with_remote_measurements', 'rm_total_time_in_seconds_by_mcp', 'rm_total_time_in_seconds_by_rmm_pro'])) {
+                    $orderBy = "ORDER BY $sortBy $sortDir NULLS LAST, care_month.number_of_days_with_remote_measurements DESC NULLS LAST, care_month.rm_total_time_in_seconds_by_mcp DESC NULLS LAST, care_month.rm_total_time_in_seconds_by_rmm_pro DESC NULLS LAST";
+                }
+                else {
+                    $orderBy = "ORDER BY $sortBy $sortDir NULLS LAST";
+                }
+            }
+        }
+
+        // filters from the UI
+        if(trim($request->input('f_ces'))) {
+            $v = trim($request->input('f_ces'));
+            if($v === 'ACTIVE') {
+                $conditions[] = "(client.client_engagement_status_category IS NULL OR client.client_engagement_status_category = '{$v}')";
+            }
+            else {
+                $conditions[] = "(client.client_engagement_status_category = '{$v}')";
+            }
+        }
+        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_mcp'))) {
+            $v = trim($request->input('f_mcp'));
+            $conditions[] = "(mcpPro.uid = '{$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_lmb'))) {
+            $v = trim($request->input('f_lmb'));
+            switch($v) {
+                case '1':
+                    $conditions[] = "(GREATEST(client.most_recent_cellular_bp_measurement_at::DATE, client.most_recent_cellular_weight_measurement_at::DATE)::DATE < (NOW() - INTERVAL '1 DAY')::DATE)";
+                    break;
+                case '2':
+                    $conditions[] = "(GREATEST(client.most_recent_cellular_bp_measurement_at::DATE, client.most_recent_cellular_weight_measurement_at::DATE)::DATE < (NOW() - INTERVAL '2 DAYS')::DATE)";
+                    break;
+                case '3':
+                    $conditions[] = "(GREATEST(client.most_recent_cellular_bp_measurement_at::DATE, client.most_recent_cellular_weight_measurement_at::DATE)::DATE < (NOW() - INTERVAL '3 DAYS')::DATE)";
+                    break;
+                case '3+':
+                    $conditions[] = "(GREATEST(client.most_recent_cellular_bp_measurement_at::DATE, client.most_recent_cellular_weight_measurement_at::DATE)::DATE < (NOW() - INTERVAL '4 DAYS')::DATE)";
+                    break;
+            }
+        }
+        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_mcp_billable'))) {
+            $v = trim($request->input('f_mcp_billable'));
+            if($v === 'yes') {
+                $conditions[] = "(care_month.mcp_rm_generic_bill_id IS NOT NULL)";
+            }
+            elseif($v === 'no') {
+                $conditions[] = "(care_month.mcp_rm_generic_bill_id IS NULL)";
+            }
+        }
+
+        if(trim($request->input('f_rmm_billable'))) {
+            $v = trim($request->input('f_rmm_billable'));
+            if($v === 'yes') {
+                $conditions[] = "(care_month.rmm_rm_generic_bill_id IS NOT NULL)";
+            }
+            elseif($v === 'no') {
+                $conditions[] = "(care_month.rmm_rm_generic_bill_id IS NULL)";
+            }
+        }
+
+        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_mcp_mins_op')) && trim($request->input('f_mcp_mins')) !== '') {
+            $o = trim($request->input('f_mcp_mins_op'));
+            $v = intval(trim($request->input('f_mcp_mins'))) * 60;
+            $conditions[] = "(care_month.rm_total_time_in_seconds_by_mcp {$o} {$v})";
+        }
+        if(trim($request->input('f_rmm_mins_op')) && trim($request->input('f_rmm_mins')) !== '') {
+            $o = trim($request->input('f_rmm_mins_op'));
+            $v = intval(trim($request->input('f_rmm_mins'))) * 60;
+            $conditions[] = "(care_month.rm_total_time_in_seconds_by_rmm_pro {$o} {$v})";
+        }
+
+        if($request->input('not-enrolled')) {
+            $conditions[] = "(client.is_enrolled_in_rm != 'YES')";
+        }
+        else {
+            $conditions[] = "(client.is_enrolled_in_rm = 'YES')";
+        }
+
+        $genericBillIdColumns = "care_month.mcp_rm_generic_bill_id,
+                   mcpBill.uid as mcp_rm_generic_bill_uid,
+                   mcpBill.generic_pro_id as mcp_rm_generic_bill_generic_pro_id,
+                   mcpBill.generic_pro_expected_payment_amount as mcp_rm_generic_bill_expected_payment_amount,
+                   mcpBill.is_signed_by_generic_pro as mcp_rm_generic_bill_signed,
+                   care_month.rmm_rm_generic_bill_id,
+                   rmmBill.uid as rmm_rm_generic_bill_uid,
+                   rmmBill.generic_pro_id as rmm_rm_generic_bill_generic_pro_id,
+                   rmmBill.generic_pro_expected_payment_amount as rmm_rm_generic_bill_expected_payment_amount,
+                   rmmBill.is_signed_by_generic_pro as rmm_rm_generic_bill_signed";
+        $genericBillJoinClause = "left join bill mcpBill on care_month.mcp_rm_generic_bill_id = mcpBill.id
+                   left join bill rmmBill on care_month.rmm_rm_generic_bill_id = rmmBill.id";
+
+        $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,
+       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,
+       mcpPro.mcp_rpm_payment_strategy,
+       mcpPro.mcp_rpm_payment_amount,
+       rmmPro.rmm_payment_strategy,
+       rmmPro.rmm_payment_amount,
+       {$genericBillIdColumns}
+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 pro mcpPro on care_month.mcp_pro_id = mcpPro.id
+    left join pro rmmPro on care_month.rmm_pro_id = rmmPro.id
+    {$genericBillJoinClause}
+WHERE
+      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-for-admin', compact('patients', 'daysRemaining', 'careMonthStart'));
+    }
+
+    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 remoteMonitoring_RowADMIN(Request $request) {
+        return $this->remoteMonitoring_RowForAdmin($request);
+    }
+
     public function rpm_work_matrix(Request $request) {
     public function rpm_work_matrix(Request $request) {
 
 
         // get the patient having most recent unstamped measurement
         // get the patient having most recent unstamped measurement
@@ -1343,7 +2034,8 @@ SELECT client.name_first, client.name_last,
        (client.name_first || ' ' || client.name_last) as client_name,
        (client.name_first || ' ' || client.name_last) as client_name,
        (mcp_pro.name_first || ' ' || mcp_pro.name_last) as mcp_pro_name,
        (mcp_pro.name_first || ' ' || mcp_pro.name_last) as mcp_pro_name,
        (rmm_pro.name_first || ' ' || rmm_pro.name_last) as rmm_pro_name,
        (rmm_pro.name_first || ' ' || rmm_pro.name_last) as rmm_pro_name,
-       client.uid as client_uid, 
+       client.uid as client_uid,
+       client.chart_number, 
        client.dob,
        client.dob,
        client.is_enrolled_in_rm,
        client.is_enrolled_in_rm,
        client.most_recent_completed_mcp_note_date,
        client.most_recent_completed_mcp_note_date,
@@ -1373,11 +2065,11 @@ SELECT client.name_first, client.name_last,
        client.rmm_pro_id,
        client.rmm_pro_id,
        client.rme_pro_id,
        client.rme_pro_id,
        client.cell_number,
        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
 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 = (
      left join note mrmnote on mrmnote.id = (
         select max(n.id) from note n 
         select max(n.id) from note n 
@@ -1500,7 +2192,7 @@ WHERE
         $c_lt16MeasurementDays = "care_month.number_of_days_with_remote_measurements < 16";
         $c_lt16MeasurementDays = "care_month.number_of_days_with_remote_measurements < 16";
         $c_gte16MeasurementDays = "care_month.number_of_days_with_remote_measurements >= 16";
         $c_gte16MeasurementDays = "care_month.number_of_days_with_remote_measurements >= 16";
         $c_subscribedToSMS = "client.send_sms_on_bdt_measurement = TRUE";
         $c_subscribedToSMS = "client.send_sms_on_bdt_measurement = TRUE";
-        $c_deviceUsed = "(client.most_recent_cellular_bp_measurement_at IS NOT NULL OR most_recent_cellular_weight_measurement_at IS NOT NULL)";
+        $c_deviceUsed = "(client.most_recent_cellular_bp_measurement_at IS NOT NULL OR client.most_recent_cellular_weight_measurement_at IS NOT NULL)";
         $c_lt20BillingMinutes = "care_month.rm_total_time_in_seconds_by_mcp < 1200";
         $c_lt20BillingMinutes = "care_month.rm_total_time_in_seconds_by_mcp < 1200";
         $c_gte20BillingMinutes = "care_month.rm_total_time_in_seconds_by_mcp >= 1200";
         $c_gte20BillingMinutes = "care_month.rm_total_time_in_seconds_by_mcp >= 1200";
 
 
@@ -2960,5 +3652,382 @@ ORDER BY c.name_last, c.name_first
 
 
     }
     }
 
 
+    public function notesResolutionCenter(Request $request) {
+
+        $columns = "(c.name_first || ' ' || c.name_last) as client_name,
+            (hcp.name_first || ' ' || hcp.name_last) as hcp_name,
+            (na.name_first || ' ' || na.name_last) as na_name,
+            c.chart_number,
+            c.uid as client_uid,
+            n.effective_dateest,
+            n.uid,
+            n.detail_json,
+	        n.is_claim_closed,
+	        n.visit_number,
+            ROUND(b.number_of_units * 60) as minutes,
+
+ n.note_reason_icd1 AS icd1,
+ n.note_reason_icd1description AS icd1description,
+ n.note_reason_icd2 AS icd2,
+ n.note_reason_icd2description AS icd2description,
+ n.note_reason_icd3 AS icd3,
+ n.note_reason_icd3description AS icd3description,
+ n.note_reason_icd4 AS icd4,
+ n.note_reason_icd4description AS icd4description,
+ n.note_reason_memo AS icd_memo,
+ n.visit_number
+
+            ";
+        $from = "FROM note AS n
+            LEFT JOIN pro AS hcp ON n.hcp_pro_id = hcp.id
+            LEFT JOIN pro AS na ON n.ally_pro_id = na.id
+            JOIN client AS c ON n.client_id = c.id
+	    JOIN bill AS b ON (b.note_id = n.id AND b.is_cancelled IS NOT TRUE AND b.code ILIKE '%treatment%')
+            ";
+        $where = "WHERE
+            -- n.visit_number IN (1,2) AND
+	    n.is_signed_by_hcp IS TRUE AND
+            -- n.is_claim_closed IS NOT TRUE AND
+            n.is_cancelled IS NOT TRUE AND 
+            n.created_at::DATE >= '2022-01-01'::DATE AND
+            c.client_engagement_status_category <> 'DUMMY' AND
+            c.name_first NOT ILIKE '%test%' AND 
+            c.name_last NOT ILIKE '%test%' AND
+            n.id IN (SELECT note_id FROM bill WHERE code ILIKE '%treatment%' AND bill.is_cancelled IS NOT TRUE AND note_id IS NOT NULL) AND
+            -- n.id NOT IN (SELECT note_id FROM claim WHERE note_id IS NOT NULL) AND
+            c.is_part_b_primary = 'YES' AND
+            c.latest_eligible_refresh_at::DATE >= '2022-01-01' AND
+            c.mpb_remaining = 0 AND
+            c.created_at::DATE >= '2022-01-01'::DATE
+            ";
+        $filters = [];
+        if($request->input('f')) {
+            $filters[] =  "(n.detail_json IS NOT NULL AND ((n.detail_json)::json->'farah_decision')::text = '\"" . $request->input('f') . "\"')";
+        }
+        if($request->input('s')) {
+            $filters[] =  "(n.detail_json IS NOT NULL AND ((n.detail_json)::json->'shawn_decision')::text = '\"" . $request->input('s') . "\"')";
+        }
+        if(count($filters)) {
+            $filters = 'AND ' . implode(' AND ',  $filters);
+        }
+        else {
+            $filters = '';
+        }
+        // $filters = '';
+        $orderBy = "ORDER BY c.id ASC, n.visit_number ASC";
+
+        $countQuery = "SELECT count(*) {$from} {$where} {$filters}";
+        // dd($countQuery);
+        $countResult = DB::select($countQuery);
+        $total = $countResult[0]->count;
+
+	$defaultPageSize = 25;
+
+        $page = $request->input('page') ?: 1;
+        $perPage = $request->input('per_page') ?: $defaultPageSize;
+        $offset = ($page - 1) * $perPage;
+
+        $dataQuery = "SELECT {$columns} {$from} {$where} {$filters} {$orderBy} OFFSET {$offset} LIMIT {$perPage}";
+        $rows = DB::select($dataQuery);
+
+        $paginator = new LengthAwarePaginator($rows, $total, $request->input('per_page') ?: $defaultPageSize, $request->input('page') ?: 1);
+        $paginator->setPath(route('practice-management.notes-resolution-center'));
+
+        return view('app.practice-management.notes-resolution-center', compact('rows', 'paginator'));
+    }
+
+    public function notesResolutionCenterV2(Request $request) {
+
+        $columns = "(c.name_first || ' ' || c.name_last) as client_name,
+            (hcp.name_first || ' ' || hcp.name_last) as hcp_name,
+            (na.name_first || ' ' || na.name_last) as na_name,
+            c.chart_number,
+            c.uid as client_uid,
+            n.effective_dateest,
+            n.uid,
+            n.detail_json,
+	        n.is_claim_closed,
+	        n.visit_number,
+            ROUND(b.number_of_units * 60) as minutes,
+
+ 		n.note_reason_icd1 AS icd1,
+ 		n.note_reason_icd1description AS icd1description,
+ 		n.note_reason_icd2 AS icd2,
+ 		n.note_reason_icd2description AS icd2description,
+ 		n.note_reason_icd3 AS icd3,
+ 		n.note_reason_icd3description AS icd3description,
+ 		n.note_reason_icd4 AS icd4,
+ 		n.note_reason_icd4description AS icd4description,
+ 		n.note_reason_memo AS icd_memo
+
+            ";
+        $from = "FROM note AS n
+            LEFT JOIN pro AS hcp ON n.hcp_pro_id = hcp.id
+            LEFT JOIN pro AS na ON n.ally_pro_id = na.id
+            JOIN client AS c ON n.client_id = c.id
+	    JOIN bill AS b ON (b.note_id = n.id AND b.is_cancelled IS NOT TRUE AND b.code ILIKE '%treatment%')
+            ";
+        $where = "WHERE
+            
+		-- n.visit_number = 2 AND
+		n.is_signed_by_hcp IS TRUE AND
+            -- n.effective_dateest < '2022-03-01' AND
+	    
+		n.is_claim_closed IS NOT TRUE AND
+            
+	    n.is_cancelled IS NOT TRUE AND 
+            c.client_engagement_status_category <> 'DUMMY' AND
+            c.name_first NOT ILIKE '%test%' AND 
+            c.name_last NOT ILIKE '%test%' AND
+            n.id IN (SELECT note_id FROM bill WHERE code ILIKE '%treatment%' AND bill.is_cancelled IS NOT TRUE AND note_id IS NOT NULL)
+		    -- AND	
+            -- n.id NOT IN (SELECT note_id FROM claim WHERE note_id IS NOT NULL) AND
+            ";
+        $filters = [];
+
+        if(trim($request->input('f_pb_primary'))) {
+            $v = trim($request->input('f_pb_primary'));
+            if($v === 'yes') {
+                $filters[] = "(c.is_part_b_primary = 'YES')";
+            }
+            else if($v === 'no') {
+                $filters[] = "(c.is_part_b_primary != 'YES')";
+            }
+        }
+        if(trim($request->input('f_deductible_zero'))) {
+            $v = trim($request->input('f_deductible_zero'));
+            if($v === 'yes') {
+                $filters[] = "(c.mpb_remaining = 0)";
+            }
+            else if($v === 'no') {
+                $filters[] = "(c.mpb_remaining > 0)";
+            }
+        }
+        if(trim($request->input('f_note_hcp'))) {
+            $v = trim($request->input('f_note_hcp'));
+            $filters[] = "(n.hcp_pro_id IN (SELECT id FROM pro WHERE uid = '{$v}'))";
+        }
+        if(trim($request->input('f_2022_patient'))) {
+            $v = trim($request->input('f_2022_patient'));
+            if($v === 'yes') {
+                $filters[] = "(c.created_at::DATE >= '2022-01-01'::DATE)";
+            }
+            else if($v === 'no') {
+                $filters[] = "(c.created_at::DATE < '2022-01-01'::DATE)";
+            }
+        }
+
+        if(count($filters)) {
+            $filters = 'AND ' . implode(' AND ',  $filters);
+        }
+        else {
+            $filters = '';
+        }
+        // $filters = '';
+        $orderBy = "ORDER BY 
+			-- c.id ASC, 
+		n.id ASC, n.effective_dateest ASC";
+
+        $countQuery = "SELECT count(*) {$from} {$where} {$filters}";
+        // dd($countQuery);
+        $countResult = DB::select($countQuery);
+        $total = $countResult[0]->count;
+
+        $defaultPageSize = 50;
+
+        $page = $request->input('page') ?: 1;
+        $perPage = $request->input('per_page') ?: $defaultPageSize;
+        $offset = ($page - 1) * $perPage;
+
+        $dataQuery = "SELECT {$columns} {$from} {$where} {$filters} {$orderBy} OFFSET {$offset} LIMIT {$perPage}";
+        $rows = DB::select($dataQuery);
+
+        $paginator = new LengthAwarePaginator($rows, $total, $request->input('per_page') ?: $defaultPageSize, $request->input('page') ?: 1);
+        $paginator->setPath(route('practice-management.notes-resolution-center-v2'));
+
+        return view('app.practice-management.notes-resolution-center-v2', compact('rows', 'paginator'));
+    }
+
+    public function coverages(Request $request) {
+
+        $columns = "(c.name_first || ' ' || c.name_last) as client_name,
+            c.id,
+            c.uid,
+            c.created_at,
+            c.sex,
+            c.dob,
+            c.age_in_years,
+            row_to_json(lcpc.*) as latest_client_primary_coverage,
+            row_to_json(lacpc.*) as latest_auto_client_primary_coverage,
+            row_to_json(lmcpc.*) as latest_manual_client_primary_coverage,
+            row_to_json(lmcpc_payer.*) as latest_manual_client_primary_coverage_payer
+            ";
+        $from = "FROM client AS c
+            LEFT JOIN client_primary_coverage lcpc on c.latest_client_primary_coverage_id = lcpc.id
+            LEFT JOIN client_primary_coverage lacpc on c.latest_auto_refresh_client_primary_coverage_id = lacpc.id
+            LEFT JOIN client_primary_coverage lmcpc on c.latest_manual_client_primary_coverage_id = lmcpc.id
+            LEFT JOIN payer lmcpc_payer on lmcpc.commercial_payer_id = lmcpc_payer.id
+            ";
+        $where = "WHERE
+            c.client_engagement_status_category <> 'DUMMY' AND
+            c.name_first NOT ILIKE '%test%' AND 
+            c.name_last NOT ILIKE '%test%' AND
+            c.created_at::DATE >= '2022-01-01'::DATE
+             -- lmcpc.id IS NOT NULL ANd lmcpc.plan_type != 'MEDICARE'
+            ";
+        $filters = [];
+
+        if(trim($request->input('f_name'))) {
+            $v = trim($request->input('f_name'));
+            $filters[] = "(c.name_first ILIKE '%{$v}%' OR c.name_last ILIKE '%{$v}%')";
+        }
+        if(trim($request->input('f_covered'))) {
+            $v = trim($request->input('f_covered'));
+            if($v !== 'any') {
+                switch($v) {
+                    case 'covered':
+                        $filters[] = "(
+                        (lmcpc.id IS NOT NULL AND lmcpc.is_cancelled IS NOT TRUE AND lmcpc.manual_determination_category = 'COVERED') OR
+                        ((lmcpc.id IS NULL OR lmcpc.is_cancelled IS TRUE) AND lacpc.id IS NOT NULL AND lacpc.is_cancelled IS NOT TRUE AND lacpc.auto_medicare_is_partbprimary = 'YES')
+                        )";
+                        break;
+                    case 'not-covered':
+                        $filters[] = "(
+                        (lmcpc.id IS NULL OR (lmcpc.is_cancelled IS TRUE OR lmcpc.manual_determination_category = 'NOT_COVERED')) AND
+                        (lacpc.id IS NULL OR (lacpc.is_cancelled IS TRUE OR lacpc.auto_medicare_is_partbprimary = 'NO')) AND
+                        (lmcpc.id IS NOT NULL OR lacpc.id IS NOT NULL)
+                        )";
+                        break;
+                    case 'unknown':
+                        $filters[] = "(
+                        (lmcpc.id IS NOT NULL AND lmcpc.is_cancelled IS NOT TRUE AND lmcpc.manual_determination_category = 'UNKNOWN') OR
+                        ((lmcpc.id IS NULL OR lmcpc.is_cancelled IS TRUE) AND lacpc.id IS NOT NULL AND lacpc.is_cancelled IS NOT TRUE AND lacpc.auto_medicare_is_partbprimary = 'UNKNOWN')
+                        )";
+                        break;
+                }
+            }
+        }
+        if(trim($request->input('f_covered'))) {
+            $v = trim($request->input('f_covered'));
+            if($v !== 'any') {
+                switch($v) {
+                    case 'covered':
+                        $filters[] = "(
+                (lmcpc.id IS NOT NULL AND lmcpc.is_cancelled IS NOT TRUE AND lmcpc.manual_determination_category = 'COVERED') OR
+                ((lmcpc.id IS NULL OR lmcpc.is_cancelled IS TRUE) AND lacpc.id IS NOT NULL AND lacpc.is_cancelled IS NOT TRUE AND lacpc.auto_medicare_is_partbprimary = 'YES')
+                )";
+                        break;
+                    case 'not-covered':
+                        $filters[] = "(
+                (lmcpc.id IS NULL OR (lmcpc.is_cancelled IS TRUE OR lmcpc.manual_determination_category = 'NOT_COVERED')) AND
+                (lacpc.id IS NULL OR (lacpc.is_cancelled IS TRUE OR lacpc.auto_medicare_is_partbprimary = 'NO')) AND
+                (lmcpc.id IS NOT NULL OR lacpc.id IS NOT NULL)
+                )";
+                        break;
+                    case 'unknown':
+                        $filters[] = "(
+                (lmcpc.id IS NOT NULL AND lmcpc.is_cancelled IS NOT TRUE AND lmcpc.manual_determination_category = 'UNKNOWN') OR
+                ((lmcpc.id IS NULL OR lmcpc.is_cancelled IS TRUE) AND lacpc.id IS NOT NULL AND lacpc.is_cancelled IS NOT TRUE AND lacpc.auto_medicare_is_partbprimary = 'UNKNOWN')
+                )";
+                        break;
+                }
+            }
+        }
+        if(trim($request->input('f_plan_type'))) {
+            $v = strtoupper(trim($request->input('f_plan_type')));
+            if($v !== 'ANY') {
+                $filters[] = "(
+                (lmcpc.id IS NOT NULL AND lmcpc.is_cancelled IS NOT TRUE AND lmcpc.plan_type = '{$v}') OR
+                ((lmcpc.id IS NULL OR lmcpc.is_cancelled IS TRUE) AND lacpc.id IS NOT NULL AND lacpc.is_cancelled IS NOT TRUE AND lacpc.plan_type = '{$v}')
+                )";
+            }
+        }
+        if(trim($request->input('f_pb_primary'))) {
+            $v = trim($request->input('f_pb_primary'));
+            if($v !== 'any') {
+                switch($v) {
+                    case 'primary':
+                        $filters[] = "(
+                (lmcpc.id IS NOT NULL AND lmcpc.is_cancelled IS NOT TRUE AND lmcpc.is_partbprimary = 'YES') OR
+                ((lmcpc.id IS NULL OR lmcpc.is_cancelled IS TRUE) AND lacpc.id IS NOT NULL AND lacpc.is_cancelled IS NOT TRUE AND lacpc.auto_medicare_is_partbprimary = 'YES')
+                )";
+                        break;
+                    case 'not-primary':
+                        $filters[] = "(
+                (lmcpc.id IS NOT NULL AND lmcpc.is_cancelled IS NOT TRUE AND lmcpc.is_partbprimary = 'NO') OR
+                ((lmcpc.id IS NULL OR lmcpc.is_cancelled IS TRUE) AND lacpc.id IS NOT NULL AND lacpc.is_cancelled IS NOT TRUE AND lacpc.auto_medicare_is_partbprimary = 'NO')
+                )";
+                        break;
+                    case 'unknown':
+                        $filters[] = "(
+                (lmcpc.id IS NOT NULL AND lmcpc.is_cancelled IS NOT TRUE AND lmcpc.is_partbprimary = 'UNKNOWN') OR
+                ((lmcpc.id IS NULL OR lmcpc.is_cancelled IS TRUE) AND lacpc.id IS NOT NULL AND lacpc.is_cancelled IS NOT TRUE AND lacpc.auto_medicare_is_partbprimary = 'UNKNOWN')
+                )";
+                        break;
+                }
+            }
+        }
+        if(trim($request->input('f_pb_active'))) {
+            $v = trim($request->input('f_pb_active'));
+            // TODO
+        }
+        if(trim($request->input('f_pc_active'))) {
+            $v = trim($request->input('f_pc_active'));
+            // TODO
+        }
+        if(trim($request->input('f_comm_payer'))) {
+            $v = trim($request->input('f_comm_payer'));
+            $filters[] = "(lmcpc_payer.name ILIKE '%{$v}%')";
+        }
+        if(trim($request->input('f_comm_member_id'))) {
+            $v = trim($request->input('f_comm_member_id'));
+            if($v !== 'any') {
+                $filters[] = "(
+                (lmcpc.id IS NOT NULL AND lmcpc.is_cancelled IS NOT TRUE AND lmcpc.commercial_member_identifier ILIKE '%{$v}%') OR
+                ((lmcpc.id IS NULL OR lmcpc.is_cancelled IS TRUE) AND lacpc.id IS NOT NULL AND lacpc.is_cancelled IS NOT TRUE AND lacpc.commercial_member_identifier ILIKE '%{$v}%')
+                )";
+            }
+        }
+        if(trim($request->input('f_comm_group_num'))) {
+            $v = trim($request->input('f_comm_group_num'));
+            if($v !== 'any') {
+                $filters[] = "(
+                (lmcpc.id IS NOT NULL AND lmcpc.is_cancelled IS NOT TRUE AND lmcpc.commercial_group_number ILIKE '%{$v}%') OR
+                ((lmcpc.id IS NULL OR lmcpc.is_cancelled IS TRUE) AND lacpc.id IS NOT NULL AND lacpc.is_cancelled IS NOT TRUE AND lacpc.commercial_group_number ILIKE '%{$v}%')
+                )";
+            }
+        }
+
+        if(count($filters)) {
+            $filters = 'AND ' . implode(' AND ',  $filters);
+        }
+        else {
+            $filters = '';
+        }
+        // $filters = '';
+        $orderBy = "ORDER BY client_name ASC";
+
+        $countQuery = "SELECT count(*) {$from} {$where} {$filters}";
+        // dd($countQuery);
+        $countResult = DB::select($countQuery);
+        $total = $countResult[0]->count;
+
+        $defaultPageSize = 10;
+
+        $page = $request->input('page') ?: 1;
+        $perPage = $request->input('per_page') ?: $defaultPageSize;
+        $offset = ($page - 1) * $perPage;
+
+        $dataQuery = "SELECT {$columns} {$from} {$where} {$filters} {$orderBy} OFFSET {$offset} LIMIT {$perPage}";
+        $rows = DB::select($dataQuery);
+
+        $paginator = new LengthAwarePaginator($rows, $total, $request->input('per_page') ?: $defaultPageSize, $request->input('page') ?: 1);
+        $paginator->setPath(route('practice-management.coverages'));
+
+        // dd($rows);
+
+        return view('app.practice-management.coverages', compact('rows', 'paginator'));
+    }
+
    
    
 }
 }

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

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

BIN
app/Models/.Segment.php.swp


+ 22 - 0
app/Models/AdministratorBillFlagUpdate.php

@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Models;
+
+# use Illuminate\Database\Eloquent\Model;
+
+class AdministratorBillFlagUpdate extends Model
+{
+    protected $table = 'administrator_bill_flag_update';
+
+    public function billl() {
+        return $this->hasOne(Bill::class, 'id', 'bill_id');
+    }
+
+    public function billFlagAcknowledgedByProAdmin() {
+        return $this->hasOne(Pro::class, 'id', 'flagged_by_administrator_pro_id');
+    }
+
+    public function billFlagAcknowledgedByPro() {
+        return $this->hasOne(Pro::class, 'id', 'administrator_flag_acknowledged_by_pro_id');
+    }
+}

+ 16 - 0
app/Models/Bill.php

@@ -37,6 +37,10 @@ class Bill extends Model
         return $this->hasOne(Pro::class, 'id', 'generic_pro_id');
         return $this->hasOne(Pro::class, 'id', 'generic_pro_id');
     }
     }
 
 
+    public function hcpCompany() {
+        return $this->hasOne(Company::class, 'id', 'hcp_company_id');
+    }
+
     public function hcpCompanyPro() {
     public function hcpCompanyPro() {
         return $this->hasOne(CompanyPro::class, 'id', 'hcp_company_pro_id');
         return $this->hasOne(CompanyPro::class, 'id', 'hcp_company_pro_id');
     }
     }
@@ -44,4 +48,16 @@ class Bill extends Model
     public function genericCompanyPro() {
     public function genericCompanyPro() {
         return $this->hasOne(CompanyPro::class, 'id', 'generic_company_pro_id');
         return $this->hasOne(CompanyPro::class, 'id', 'generic_company_pro_id');
     }
     }
+
+    public function billFlagAcknowledgedByProAdmin() {
+        return $this->hasOne(Pro::class, 'id', 'flagged_by_administrator_pro_id');
+    }
+
+    public function billFlagAcknowledgedByPro() {
+        return $this->hasOne(Pro::class, 'id', 'administrator_flag_acknowledged_by_pro_id');
+    }
+
+    public function markedVerifiedBySession() {
+        return $this->hasOne(AppSession::class, 'id', 'marked_verified_by_session_id');
+    }
 }
 }

+ 19 - 0
app/Models/CareMonth.php

@@ -4,6 +4,7 @@ namespace App\Models;
 
 
 # use Illuminate\Database\Eloquent\Model;
 # use Illuminate\Database\Eloquent\Model;
 
 
+use DateTime;
 use Illuminate\Support\Collection;
 use Illuminate\Support\Collection;
 
 
 class CareMonth extends Model
 class CareMonth extends Model
@@ -123,4 +124,22 @@ class CareMonth extends Model
         return $this->hasOne(Bill::class, 'id', 'rmm_rm_generic_bill_id');
         return $this->hasOne(Bill::class, 'id', 'rmm_rm_generic_bill_id');
     }
     }
 
 
+    public function showMeasurementDaysWarning(){
+        return ($this->daysSinceLastMeasurement() >= 2) || (16 - $this->number_of_days_with_remote_measurements) >= $this->daysTillEndOfMonth();
+    }
+
+    public function daysSinceLastMeasurement(){
+
+        if(!$this->most_recent_cellular_measurement_at) {
+            return 999;
+        }
+
+        $d1 = new DateTime($this->most_recent_cellular_measurement_at);
+        return $d1->diff(new DateTime())->days;
+    }
+
+    public function daysTillEndOfMonth(){
+        return  date('t') - date('j');
+
+    }
 }
 }

+ 32 - 4
app/Models/Client.php

@@ -16,6 +16,7 @@ class Client extends Model
     public function primaryCoverages()
     public function primaryCoverages()
     {
     {
         return $this->hasMany(ClientPrimaryCoverage::class, 'client_id', 'id')
         return $this->hasMany(ClientPrimaryCoverage::class, 'client_id', 'id')
+            ->whereRaw('(is_cancelled IS NULL OR is_cancelled IS FALSE)')
             ->orderBy('created_at', 'desc');
             ->orderBy('created_at', 'desc');
     }
     }
 
 
@@ -26,10 +27,12 @@ class Client extends Model
         return $this->hasOne(ClientPrimaryCoverage::class, 'id', 'latest_new_client_primary_coverage_id');
         return $this->hasOne(ClientPrimaryCoverage::class, 'id', 'latest_new_client_primary_coverage_id');
     }
     }
 	public function latestAutoRefreshClientPrimaryCoverage(){
 	public function latestAutoRefreshClientPrimaryCoverage(){
-        return $this->hasOne(ClientPrimaryCoverage::class, 'id', 'latest_auto_refresh_client_primary_coverage_id');
+        return $this->hasOne(ClientPrimaryCoverage::class, 'id', 'latest_auto_refresh_client_primary_coverage_id')
+            ->whereRaw('(is_cancelled IS NULL OR is_cancelled IS FALSE)');
     }
     }
 	public function latestManualClientPrimaryCoverage(){
 	public function latestManualClientPrimaryCoverage(){
-        return $this->hasOne(ClientPrimaryCoverage::class, 'id', 'latest_manual_client_primary_coverage_id');
+        return $this->hasOne(ClientPrimaryCoverage::class, 'id', 'latest_manual_client_primary_coverage_id')
+            ->whereRaw('(is_cancelled IS NULL OR is_cancelled IS FALSE)');
     }
     }
 	public function temporaryOutsiderNewClientPrimaryCoverage(){
 	public function temporaryOutsiderNewClientPrimaryCoverage(){
         return $this->hasOne(ClientPrimaryCoverage::class, 'id', 'temporary_outsider_new_client_primary_coverage_id');
         return $this->hasOne(ClientPrimaryCoverage::class, 'id', 'temporary_outsider_new_client_primary_coverage_id');
@@ -886,8 +889,27 @@ ORDER BY m.ts DESC
 
 
     public function getPrimaryCoverage()
     public function getPrimaryCoverage()
     {
     {
-        $coverage = $this->latestClientPrimaryCoverage;
-        return $coverage;
+        $coverage = $this->latestManualClientPrimaryCoverage;
+        if ($coverage) {
+            return  $coverage;
+        }
+
+        $latestAutoRefreshCoverage = $this->latestAutoRefreshClientPrimaryCoverage;
+        $latestNewCoverage = $this->latestNewClientPrimaryCoverage;
+
+        if($latestAutoRefreshCoverage && $latestNewCoverage){
+            if($latestAutoRefreshCoverage->created_at > $latestNewCoverage->created_at){
+                return $latestAutoRefreshCoverage;
+            }else {
+                return $latestNewCoverage;
+            }
+        }else if($latestAutoRefreshCoverage) {
+            return $latestAutoRefreshCoverage;
+        }else if( $latestNewCoverage){
+            return  $latestNewCoverage;
+        }
+        
+        return null;
     }
     }
 
 
     // return value will be YES, NO or UNKNOWN
     // return value will be YES, NO or UNKNOWN
@@ -1013,5 +1035,11 @@ ORDER BY m.ts DESC
         return $this->getDeviceDeliveryStatus(2);
         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');
+    }
+}

+ 12 - 0
app/Models/ClientPrimaryCoverage.php

@@ -48,6 +48,15 @@ class ClientPrimaryCoverage extends Model
         return null;
         return null;
 
 
     }
     }
+    public function insuranceDisplayPayerName(){
+        if($this->plan_type === 'MEDICAID'){
+            if($this->mcdPayer) return $this->mcdPayer->name;
+        } 
+        if($this->plan_type === 'COMMERCIAL'){
+            if($this->payer) return $this->payer->name;
+        } 
+        return $this->insuranceDisplayName();
+    }
 
 
     public function toString() {
     public function toString() {
         $parts = [];
         $parts = [];
@@ -74,4 +83,7 @@ class ClientPrimaryCoverage extends Model
     public function autoMedicareResult(){
     public function autoMedicareResult(){
         return $this->hasOne(MedicareResult::class, 'id', 'auto_medicare_result_id');
         return $this->hasOne(MedicareResult::class, 'id', 'auto_medicare_result_id');
     }
     }
+    public function autoCommercialMoreSpecificPayer(){
+        return $this->hasOne(Payer::class, 'id', 'auto_commercial_more_specific_payer_id');
+    }
 }
 }

+ 21 - 0
app/Models/ClientStickyNote.php

@@ -0,0 +1,21 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Relations\HasMany;
+use Illuminate\Database\Eloquent\Relations\HasOne;
+
+class ClientStickyNote extends Model
+{
+    protected $table = 'client_sticky_note';
+
+    public function createdBy(): HasOne
+    {
+        return $this->hasOne(AppSession::class, 'id', 'created_by_session_id');
+    }
+
+    public function client(): HasOne
+    {
+        return $this->hasOne(Client::class, 'id', 'client_id');
+    }
+}

+ 35 - 1
app/Models/Note.php

@@ -124,7 +124,16 @@ class Note extends Model
 
 
     public function reasons()
     public function reasons()
     {
     {
-        return $this->hasMany(NoteReason::class, 'note_id', 'id');
+        $reasons = [];
+        for ($i = 1; $i <= 4; $i++) {
+            if($this->{'note_reason_icd' . $i}) {
+                $reason = new \stdClass();
+                $reason->code = $this->{'note_reason_icd' . $i};
+                $reason->description = $this->{'note_reason_icd' . $i . 'description'};
+                $reasons[] = $reason;
+            }
+        }
+        return $reasons;
     }
     }
 
 
     public function claims()
     public function claims()
@@ -178,4 +187,29 @@ class Note extends Model
         return !!$bills;
         return !!$bills;
     }
     }
 
 
+    public function segmentsWithPendingSummarySuggestion() {
+        return $this->hasMany(Segment::class, 'note_id', 'id')
+            ->where('id', '!=', $this->core_segment_id) // dont include core-segment
+            ->where('is_active', true)
+            ->whereHas('proposedSegmentSummarySuggestion', function($sugQuery) {
+                return $sugQuery->where('status', '=', 'PENDING');
+            })
+            ->orderBy('position_index', 'asc');
+    }
+
+    public function hasUnacknowledgedCancelledBillsByPro(Pro $pro) {
+        return Bill::where('note_id', $this->id)
+            ->where('hcp_pro_id', $pro->id)
+            ->where('bill_service_type', '<>', 'GENERIC')
+            ->where('is_cancelled', true)
+            ->where('is_cancelled_by_administrator', true)
+            ->where('is_cancellation_acknowledged', false)
+            ->count();
+    }
+
+    public function hasClaims() {
+        return Claim::where('note_id', $this->id)
+            ->where('status', '!=', 'CANCELLED')
+            ->count();
+    }
 }
 }

+ 116 - 0
app/Models/Pro.php

@@ -371,6 +371,15 @@ class Pro extends Model
         return $favorites;
         return $favorites;
     }
     }
 
 
+    function get_patients_count_as_admin() {
+        $query = Client::whereNull('shadow_pro_id');
+        return $query->where('is_active', true)
+            ->where(function ($q) {
+                $q->whereNull('client_engagement_status_category')
+                    ->orWhere('client_engagement_status_category', '<>', 'DUMMY');
+            })->count();
+    }
+
     function get_patients_count_as_mcp() {
     function get_patients_count_as_mcp() {
         $query = Client::whereNull('shadow_pro_id');
         $query = Client::whereNull('shadow_pro_id');
         return $query->where('mcp_pro_id', $this->id)
         return $query->where('mcp_pro_id', $this->id)
@@ -387,6 +396,12 @@ class Pro extends Model
             ->count();
             ->count();
     }
     }
 
 
+    function get_new_patients_awaiting_visit_count_as_admin() {
+        $query = Client::whereNull('shadow_pro_id');
+        return $query->where('has_mcp_done_onboarding_visit', '!=', 'YES')
+            ->count();
+    }
+
     function get_notes_pending_signature_count_as_mcp() {
     function get_notes_pending_signature_count_as_mcp() {
         return Note::where('hcp_pro_id', $this->id)
         return Note::where('hcp_pro_id', $this->id)
             ->where('is_cancelled', '<>', true)
             ->where('is_cancelled', '<>', true)
@@ -395,6 +410,13 @@ class Pro extends Model
             ->count();
             ->count();
     }
     }
 
 
+    function get_notes_pending_signature_count_as_admin() {
+        return Note::where('is_cancelled', '<>', true)
+            ->where('is_core_note', '<>', true)
+            ->where('is_signed_by_hcp', '<>', true)
+            ->count();
+    }
+
     function get_notes_pending_summary_suggestion_as_mcp_query(){
     function get_notes_pending_summary_suggestion_as_mcp_query(){
         $segmentsWithProposedSummarySuggestion = Segment::whereHas('proposedSegmentSummarySuggestion', function($sugQuery){
         $segmentsWithProposedSummarySuggestion = Segment::whereHas('proposedSegmentSummarySuggestion', function($sugQuery){
             return $sugQuery->where('status', '=', 'PENDING');
             return $sugQuery->where('status', '=', 'PENDING');
@@ -493,6 +515,12 @@ class Pro extends Model
             ->count();
             ->count();
     }
     }
 
 
+    function get_notes_pending_billing_count_as_admin() {
+        return Note::where('is_cancelled', '<>', true)
+            ->where('is_signed_by_hcp', true)
+            ->where('is_billing_marked_done', '<>', true)
+            ->count();
+    }
 
 
     function get_measurements_awaiting_review_count_as_mcp() {
     function get_measurements_awaiting_review_count_as_mcp() {
         $result = DB::select(DB::raw("
         $result = DB::select(DB::raw("
@@ -529,6 +557,12 @@ WHERE mcp_pro_id = :pro_id
             ->count();
             ->count();
     }
     }
 
 
+    function get_incoming_reports_pending_signature_count_as_admin() {
+        return IncomingReport::where('has_hcp_pro_signed', '<>', true)
+            ->where('is_entry_error', '<>', true)
+            ->count();
+    }
+
     function get_patients_without_appointment_query() {
     function get_patients_without_appointment_query() {
         return Client::where('mcp_pro_id', $this->id)
         return Client::where('mcp_pro_id', $this->id)
                     ->whereNull('today_mcp_appointment_date')
                     ->whereNull('today_mcp_appointment_date')
@@ -551,6 +585,15 @@ WHERE mcp_pro_id = :pro_id
         return $this->get_patients_without_appointment_query()->count();
         return $this->get_patients_without_appointment_query()->count();
     }
     }
 
 
+    function get_patients_without_appointment_count_as_admin() {
+        return Client::whereNull('shadow_pro_id')
+            ->whereNull('today_mcp_appointment_date')
+            ->where(function($q){
+                $q->whereNull('next_mcp_appointment_id')
+                    ->orWhere('next_mcp_appointment_date', '<=', DB::raw('NOW()::DATE'));
+            })->count();
+    }
+
     function get_patients_overdue_for_visit_query() {
     function get_patients_overdue_for_visit_query() {
         return Client::where('mcp_pro_id', $this->id)
         return Client::where('mcp_pro_id', $this->id)
                     ->where(function($q){
                     ->where(function($q){
@@ -633,6 +676,66 @@ WHERE mcp_pro_id = :pro_id
             ->count();
             ->count();
     }
     }
 
 
+    function get_unsigned_rpm_bills_count_as_mcp() {
+
+        $query = "
+SELECT count(distinct(care_month.id))
+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
+      care_month.mcp_pro_id = {$this->id}
+      AND EXTRACT(MONTH from care_month.start_date) = EXTRACT(MONTH from now())
+      AND EXTRACT(YEAR from care_month.start_date) = EXTRACT(YEAR from now())
+      AND care_month.mcp_rm_generic_bill_id IS NOT NULL
+      AND bill.is_signed_by_generic_pro = TRUE
+";
+
+        // dd($query);
+
+        $count = DB::select($query);
+
+        return $count[0]->count;
+    }
+
+    function get_unsigned_rpm_bills_count_as_rmm() {
+
+        $query = "
+SELECT count(distinct(care_month.id))
+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.rmm_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
+      care_month.rmm_pro_id = {$this->id}
+      AND EXTRACT(MONTH from care_month.start_date) = EXTRACT(MONTH from now())
+      AND EXTRACT(YEAR from care_month.start_date) = EXTRACT(YEAR from now())
+      AND care_month.rmm_rm_generic_bill_id IS NOT NULL
+      AND bill.is_signed_by_generic_pro = TRUE
+";
+
+        // dd($query);
+
+        $count = DB::select($query);
+
+        return $count[0]->count;
+    }
+
     function get_birthdays_today_as_mcp(){
     function get_birthdays_today_as_mcp(){
         return;
         return;
         $queryClients = $this->performer()->pro->getAccessibleClientsQuery();
         $queryClients = $this->performer()->pro->getAccessibleClientsQuery();
@@ -954,6 +1057,19 @@ WHERE mcp_pro_id = :pro_id
         return 0;
         return 0;
     }
     }
 
 
+    public function get_open_tickets_count_as_mcp(){
+        $self = $this;
+        return Ticket::where(function ($q) use ($self) {
+                $q->where('assigned_pro_id', $self->id)
+                    ->orWhere('manager_pro_id', $self->id)
+                    ->orWhere('ordering_pro_id', $self->id)
+                    ->orWhere('initiating_pro_id', $self->id);
+            })
+            ->where('category', 'other')
+            ->where('is_open', true)
+            ->count();
+    }
+
     //DNA_DASHBOARD
     //DNA_DASHBOARD
     
     
     //queries
     //queries

+ 3 - 2
app/Models/Segment.php

@@ -37,7 +37,7 @@ class Segment extends Model
         return $this->hasOne(SegmentSummarySuggestion::class, 'id', 'accepted_segment_summary_suggestion_id');
         return $this->hasOne(SegmentSummarySuggestion::class, 'id', 'accepted_segment_summary_suggestion_id');
     }
     }
 
 
-    public function getRecalculatedHtml($performer, $sessionKey){
+    public function getRecalculatedHtml($performer, $sessionKey, $getSummaryOnly = false){
         $pro = $performer->pro;
         $pro = $performer->pro;
         $segment = $this; 
         $segment = $this; 
         $segmentTemplate = $this->segmentTemplate;
         $segmentTemplate = $this->segmentTemplate;
@@ -64,7 +64,8 @@ class Segment extends Model
             'intake_supplements',
             'intake_supplements',
             'plan_supplements'
             'plan_supplements'
         ];
         ];
-        if(!in_array($segmentTemplate->internal_name, $wizardPowered)) {
+	$editHtml = null;
+        if(!in_array($segmentTemplate->internal_name, $wizardPowered) && !$getSummaryOnly) {
             $editHtml = view('app.patient.segment-templates.' . $segmentTemplate->internal_name . '/edit', $data)->render();
             $editHtml = view('app.patient.segment-templates.' . $segmentTemplate->internal_name . '/edit', $data)->render();
         }
         }
 
 

+ 4 - 1
app/Models/SegmentSummarySuggestion.php

@@ -8,6 +8,9 @@ class SegmentSummarySuggestion extends Model
 {
 {
     protected $table = 'segment_summary_suggestion';
     protected $table = 'segment_summary_suggestion';
 
 
-   
+    public function creator()
+    {
+        return $this->hasOne(Pro::class, 'id', 'created_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');
         return $this->hasOne(Pro::class, 'id', 'created_by_pro_id');
     }
     }
+
+    public function Note()
+    {
+        return $this->hasOne(Note::class, 'id', 'note_id');
+    }
 }
 }

+ 4 - 2
config/app.php

@@ -65,7 +65,7 @@ return [
 
 
     'hrm2_url' => env('HRM2_URL'),
     'hrm2_url' => env('HRM2_URL'),
 
 
-    'asset_version' => 78,
+    'asset_version' => 92,
 
 
     'temp_dir' => env('TEMP_DIR'),
     'temp_dir' => env('TEMP_DIR'),
 
 
@@ -76,6 +76,8 @@ return [
     'weightSmsNumber' => env('WEIGHT_SMS_NUMBER', ''),
     'weightSmsNumber' => env('WEIGHT_SMS_NUMBER', ''),
     'bpSmsNumber' => env('BP_SMS_NUMBER', ''),
     'bpSmsNumber' => env('BP_SMS_NUMBER', ''),
 
 
+    'nonMedicalVisitTemplateUid' => env('NON_MEDICAL_VISIT_TEMPLATE_UID'),
+
     /*
     /*
     |--------------------------------------------------------------------------
     |--------------------------------------------------------------------------
     | Application Timezone
     | Application Timezone
@@ -147,7 +149,7 @@ return [
     'googleSpreadsheetProductsSheetName' => env('GOOGLE_SPREADSHEET_PRODUCTS_SHEET_NAME'),
     'googleSpreadsheetProductsSheetName' => env('GOOGLE_SPREADSHEET_PRODUCTS_SHEET_NAME'),
 
 
     'adminNoteHcpProUid' => env('ADMIN_NOTE_HCP_PRO_UID'),
     'adminNoteHcpProUid' => env('ADMIN_NOTE_HCP_PRO_UID'),
-
+    @
     /*
     /*
     |--------------------------------------------------------------------------
     |--------------------------------------------------------------------------
     | Autoloaded Service Providers
     | Autoloaded Service Providers

+ 7 - 0
config/stag.php

@@ -5,6 +5,13 @@ return [
     'adminPortalUrl' => env('ADMIN_PORTAL_URL', 'https://fe.scholar.securecpu.com'),
     'adminPortalUrl' => env('ADMIN_PORTAL_URL', 'https://fe.scholar.securecpu.com'),
     'backendUrl' => env('BACKEND_URL','https://scholar.securecpu.com'),
     'backendUrl' => env('BACKEND_URL','https://scholar.securecpu.com'),
 
 
+    // tweak these to adjust fuzzy search match strictness
+    'fuzzySearchMinimumSimilarityScore' => [
+        'allergy' => 0.11,
+        'medication' => 0.11,
+        'problem' => 0.11,
+    ],
+
     'segmentRefreshConfig' => [
     'segmentRefreshConfig' => [
         'typeToSegments' => [
         'typeToSegments' => [
             'allergy' => [
             'allergy' => [

+ 284 - 0
coverage_spec_april_29_2022.txt

@@ -0,0 +1,284 @@
+Determine which client->primaryCoverage to use 
+
+if there is latest_manual_client_primary_coverage_id  and its not cancelled use it 
+else:
+    if there is latest_auto_refresh_client_primary_coverage_id and latest_new_client_primary_coverage_id use the latest 
+    else use whichever is there 
+    else
+        no coverage 
+
+TEST CASE
+    - create a new client 
+    - add manual coverage 
+    - cancel manual coverage 
+    - add new coverage 
+    - auto refresh the new coverage 
+    - add another new 
+
+
+=====================
+- add new (automatically when you create a client ), or when you go Primary Coverage -> Add +
+- go  primary coverage, on an exising coverage, do manual determination 
+- go to primary coverage, on an existing coverage, click refresh 
+
+
+client->getPrimaryCoverage(); //Already done 
+TODO: use this everywhere on the ui NO $client->latestClientPrimaryCoverage
+
+1. header blade 
+2. thin blade to be used for tables
+
+How to display on the header and table columns
+- is client covered  
+        $coverage->is_covered
+        - Medicare 
+            IF AUTO/NEW
+                autoMedicareIsPartBActive;
+                autoMedicareIsPartBPrimary;
+                autoMedicareIsPartCActive;
+                autoMedicareIsInpatient;
+                autoMedicareIsHospiceOrHomeHealth;
+                autoMedicareMpbRemaining
+            IF MANUAL 
+                manualDeterminationCategory
+                manualMedicareIsPartBActive
+                manualMedicareIsPartBPrimary
+                manualMedicareIsPartCActive
+                manualMedicareIsInpatient
+                manualMedicareIsHospiceOrHomeHealth
+                manualMedicareIsMsp
+                manualMedicareMspMemo
+        - Commercial
+                commercialPayerUid;
+                commercialPayerName;
+                **commercialMemberIdentifier;
+                **commercialGroupNumber;
+                **mcrNumber;
+                mcdPayerName;
+                **mcdNumber;
+            IF AUTO/NEW
+                autoCommercialIsMatchFound;
+                autoCommercialMoreSpecificPayerId; //gives official commerical name 
+                if has medicare 
+                    autoMedicareIsMatchFound
+                    autoMedicareIsPartBActive;
+                    autoMedicareIsPartBPrimary;
+                    autoMedicareIsPartCActive;
+                    autoMedicareIsInpatient;
+                    autoMedicareIsHospiceOrHomeHealth;
+                    mpbRemaining 
+                if has medicaid 
+                    autoMedicaidIsMatchFound
+
+            IF MANUAL 
+                manualDeterminationCategory
+                manualCommercialIsMatched
+                if has medicare 
+                    manualMedicareIsMatched
+                    manualMedicareIsPartBActive
+                    manualMedicareIsPartBPrimary
+                    manualMedicareIsPartCActive
+                    manualMedicareIsInpatient
+                    manualMedicareIsHospiceOrHomeHealth
+                    manualMedicareIsMsp
+                    manualMedicareMspMemo
+                if has medicaid 
+                    manualMedicaidIsMatched;
+
+        - Medicaid 
+            mcdPayerName;
+		    mcdNumber;
+            IF AUTO/NEW
+                autoMedicaidIsMatchFound
+            IF MANUAL
+                manualDeterminationCategory
+                manualMedicareIsMatched
+
+
+ 
+    latest_auto_refresh_client_primary_coverage_id //latest after refresh
+    latest_client_primary_coverage_id //lastest after manual or refresh
+    latest_manual_client_primary_coverage_id //latest after manual
+    latest_new_client_primary_coverage_id /latest after a client has just been created, always the latest client_primary_coverage, 
+
+How to display on client primary coverage section
+on coverage section show 3 tabs with all the columns 
+    latest_manual_client_primary_coverage_id //latest after manual
+    latest_auto_refresh_client_primary_coverage_id //latest after refresh
+    latest_new_client_primary_coverage_id
+- Highlight the one that is currently in use 
+
+auto_medicare_detail_json
+auto_commercial_detail_json
+auto_medicaid_detail_json
+
+
+
+client 
+    is_hospice
+    is_mcn_valid_number
+    is_medicare_advantage
+    is_part_b_primary
+    mcn
+    mcn_address_city
+    mcn_address_state
+    mcn_address_street_line1
+    mcn_address_street_line2
+    mcn_address_zip
+    mcn_error_details
+    mcn_follow_up_action_code
+    mcn_follow_up_action_description
+    mcn_reject_reason_code
+    mcn_reject_reason_description
+    mcn_response_detail
+    medicare_advantage_plan
+    mother_maiden_name
+    was_medicare_validation_successful
+    is_coverage_manually_verified
+    coverage_manual_verification_memo
+    latest_eligible_refresh_id
+    latest_eligible_refresh_at
+    mpb_active
+    mpb_start_date
+    mpb_end_date
+    mpb_deductible
+    mpb_remaining
+    mpb_insurance_type
+    mpb_insurance_type_label
+    mpb_coinsurance_percent
+    mpb_info_valid_until
+    mpb_info_valid_till
+    mpb_last_refreshed_atpayer_name
+    payer_name
+    payer_member_id
+    non_mc_primary_payer_id
+    non_mc_secondary_payer_id
+    latest_auto_refresh_client_primary_coverage_id
+    latest_client_primary_coverage_id
+    latest_manual_client_primary_coverage_id
+    latest_new_client_primary_coverage_id
+    temporary_outsider_new_client_primary_coverage_id
+    is_auto_part_b_primary
+
+
+
+client_primary_coverage
+    client_id
+    creation_strategy
+    auto_refresh_of_client_primary_coverage_id
+    manual_determination_of_client_primary_coverage_id
+    plan_type
+    is_partbprimary
+    is_manually_determined
+    is_entry_error
+    subscriber_name_first
+    subscriber_name_last
+    subscriber_sex
+    subscriber_dob
+    date_of_service
+    auto_medicare_is_partbprimary
+    auto_medicare_is_partbactive
+    auto_medicare_is_partcactive
+    auto_medicare_is_inpatient
+    auto_medicare_is_hospice_or_home_health
+    auto_medicare_is_msp
+    auto_medicare_msp_memo
+    auto_medicare_mpb_start_date
+    auto_medicare_mpb_end_date
+    auto_medicare_mpb_deductible
+    auto_medicare_mpb_remaining
+    auto_medicare_mpb_insurance_type
+    auto_medicare_mpb_insurance_type_label
+    auto_medicare_mpb_coinsurance_percent
+    auto_medicare_mpb_info_valid_until
+    auto_medicare_mpb_info_valid_till
+    auto_medicare_mpb_last_refreshed_at
+    was_successful
+    reject_reason_code
+    reject_reason_description
+    follow_up_action_code
+    follow_up_action_description
+    details
+    is_mcn_valid_number
+    address_street_line1
+    address_street_line2
+    address_city
+    address_state
+    address_zip
+    is_hospice
+    mcn_response_detail
+    billing_address
+    reason_not_partb
+    reason_not_partbmemo
+    is_medicare_advantage
+    medicare_advantage_plan
+    mpb_active
+    mpb_start_date
+    mpb_end_date
+    mpb_deductible
+    mpb_remaining
+    mpb_insurance_type
+    mpb_insurance_type_label
+    mpb_coinsurance_percent
+    mpb_info_valid_until
+    mpb_info_valid_till
+    mpb_last_refreshed_at
+    manual_determination_strategy
+    manual_determination_category
+    manual_determination_category_memo
+    manual_medicare_is_partbprimary
+    manual_medicare_is_partbactive
+    manual_medicare_is_partcactive
+    manual_medicare_is_inpatient
+    manual_medicare_is_hospice_or_home_health
+    manual_medicare_is_msp
+    manual_medicare_msp_memo
+    auto_medicare_result_id
+    mcd_number
+    mcr_number
+    subscriber_name_middle
+    subscriber_name_suffix
+    auto_commercial_detail_json
+    auto_commercial_is_match_found
+    auto_commercial_more_specific_payer_id
+    auto_medicaid_detail_json
+    auto_medicaid_is_match_found
+    auto_medicare_is_match_found
+    commercial_member_identifier
+    commercial_payer_id
+    commercial_payer_name
+    is_partcactive
+    is_patient_subscriber
+    manual_medicaid_is_matched
+    manual_medicare_is_matched
+    mcd_payer_id
+    patient_dob
+    patient_name_first
+    patient_name_last
+    patient_name_middle
+    patient_name_suffix
+    patient_relationship_to_subscriber
+    patient_sex
+    commercial_group_number
+    auto_medicare_detail_json
+    is_covered
+    last_updated_at
+    deductible_amount
+    family_deductible
+    member_accumulated_total
+    plan_description
+    plan_effective_date
+    provider_status
+    total_family_balance
+    total_individual_balance
+    mental_health_coverage
+    telehealth_coverage
+    cancellation_memo
+    cancelled_at
+    cancelled_by_session_id
+    is_cancelled
+
+
+    medicare
+    medicaid 
+    commercial

+ 21 - 4
js-dev/click-to-copy.js

@@ -1,5 +1,5 @@
 (function() {
 (function() {
-    function fallbackCopyTextToClipboard(text) {
+    function fallbackCopyTextToClipboard(text, pasteTo = false) {
         var textArea = document.createElement("textarea");
         var textArea = document.createElement("textarea");
         textArea.value = text;
         textArea.value = text;
 
 
@@ -17,13 +17,14 @@
             var msg = successful ? 'successful' : 'unsuccessful';
             var msg = successful ? 'successful' : 'unsuccessful';
             console.log('Fallback: Copying text command was ' + msg);
             console.log('Fallback: Copying text command was ' + msg);
             toastr.success('Copied!');
             toastr.success('Copied!');
+            pasteToElement(pasteTo, text);
         } catch (err) {
         } catch (err) {
             console.error('Fallback: Oops, unable to copy', err);
             console.error('Fallback: Oops, unable to copy', err);
         }
         }
 
 
         document.body.removeChild(textArea);
         document.body.removeChild(textArea);
     }
     }
-    function copyTextToClipboard(text) {
+    function copyTextToClipboard(text, pasteTo = false) {
         if (!navigator.clipboard) {
         if (!navigator.clipboard) {
             fallbackCopyTextToClipboard(text);
             fallbackCopyTextToClipboard(text);
             return;
             return;
@@ -31,17 +32,33 @@
         navigator.clipboard.writeText(text).then(function() {
         navigator.clipboard.writeText(text).then(function() {
             console.log('Async: Copying to clipboard was successful!');
             console.log('Async: Copying to clipboard was successful!');
             toastr.success('Copied!');
             toastr.success('Copied!');
+            pasteToElement(pasteTo, text);
         }, function(err) {
         }, function(err) {
             console.error('Async: Could not copy text: ', err);
             console.error('Async: Could not copy text: ', err);
         });
         });
     }
     }
+    function pasteToElement(_elem, _text) {
+        if(_elem && _elem.length) {
+            // if rte
+            if(_elem.is('.ql-container') && _elem[0].__quill) {
+                let qlRoot = _elem[0].__quill.root;
+                if($.trim($(qlRoot.innerHTML).text()) === '') {
+                    _elem[0].__quill.clipboard.dangerouslyPasteHTML(0, _text);
+                    _elem[0].__quill.root.focus();
+                }
+            }
+            else _elem.val(_text);
+        }
+    }
 
 
     function init() {
     function init() {
         $(document)
         $(document)
             .off('click.click-to-copy', '.click-to-copy')
             .off('click.click-to-copy', '.click-to-copy')
             .on('click.click-to-copy', '.click-to-copy', function(event) {
             .on('click.click-to-copy', '.click-to-copy', function(event) {
-            copyTextToClipboard($(this).text());
-        });
+                let self = $(this);
+                copyTextToClipboard(self.text(),
+                    self.is('[auto-paste]') ? self.closest('form').find(self.attr('auto-paste')) : false);
+            });
         window.copyTextToClipboard = copyTextToClipboard;
         window.copyTextToClipboard = copyTextToClipboard;
     }
     }
 
 

+ 2 - 2
js-dev/icd-autocomplete.js

@@ -4,7 +4,7 @@
         let self = this;
         let self = this;
         $('[icd-autocomplete-code]:not([ac-initialized])').each(function() {
         $('[icd-autocomplete-code]:not([ac-initialized])').each(function() {
             let elem = this, dynID = 'icd-' + Math.ceil(Math.random() * 1000000),
             let elem = this, dynID = 'icd-' + Math.ceil(Math.random() * 1000000),
-                codeElem = $(this), descElem = $(this).closest('form').find('[icd-autocomplete-description]');
+                codeElem = $(this), descElem = $(this).closest('form, tr').first().find('[icd-autocomplete-description]');
             var targetDescElem = $(this).data('target');
             var targetDescElem = $(this).data('target');
             if(targetDescElem){
             if(targetDescElem){
                 descElem = $(this).closest('form').find(targetDescElem);
                 descElem = $(this).closest('form').find(targetDescElem);
@@ -20,7 +20,7 @@
             window.Def.Autocompleter.Event.observeListSelections(dynID, function() {
             window.Def.Autocompleter.Event.observeListSelections(dynID, function() {
                 let autocomp = elem.autocomp, acData = autocomp.getSelectedItemData();
                 let autocomp = elem.autocomp, acData = autocomp.getSelectedItemData();
                 codeElem.val(acData[0].code).trigger('change');
                 codeElem.val(acData[0].code).trigger('change');
-                descElem.val(acData[0].data['name']).trigger('change');
+                descElem.val(acData[0].data['name']).attr('title', acData[0].data['name']).trigger('change');
                 return false;
                 return false;
             });
             });
             $(elem).attr('ac-initialized', 1);
             $(elem).attr('ac-initialized', 1);

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

@@ -3,13 +3,17 @@
         let ol = $(_input).next('.data-option-list');
         let ol = $(_input).next('.data-option-list');
         if(ol.length && !ol.is(':visible')) {
         if(ol.length && !ol.is(':visible')) {
             ol.show();
             ol.show();
+            return true;
         }
         }
+        return false;
     }
     }
     function hideOptionsList(_input) {
     function hideOptionsList(_input) {
         let ol = $(_input).next('.data-option-list');
         let ol = $(_input).next('.data-option-list');
         if(ol.length && ol.is(':visible')) {
         if(ol.length && ol.is(':visible')) {
             ol.hide();
             ol.hide();
+            return true;
         }
         }
+        return false;
     }
     }
     function init() {
     function init() {
         $(document)
         $(document)
@@ -18,9 +22,21 @@
                 _e.stopPropagation();
                 _e.stopPropagation();
                 _e.preventDefault();
                 _e.preventDefault();
                 markEventAsConsumed(_e);
                 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;
                 return false;
             });
             });
         $(document)
         $(document)
@@ -35,7 +51,16 @@
             .off('blur.trigger-option-list', 'input[data-option-list]')
             .off('blur.trigger-option-list', 'input[data-option-list]')
             .on('blur.trigger-option-list', 'input[data-option-list]', function() {
             .on('blur.trigger-option-list', 'input[data-option-list]', function() {
                 hideOptionsList(this);
                 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);
     addMCInitializer('option-list', init);
 })();
 })();

+ 164 - 1
js-dev/stag-popup.js

@@ -116,7 +116,7 @@ function openDynamicStagPopup(_url, initer, title, updateParent, style = '', rep
             popup = $('.dynamic-popup[stag-popup-key="' + url + '"]');
             popup = $('.dynamic-popup[stag-popup-key="' + url + '"]');
             if(!popup.length) {
             if(!popup.length) {
                 $('main.stag-content').append(
                 $('main.stag-content').append(
-                    '<div class="stag-popup ' + (style ? style : 'stag-popup-lg') + ' dynamic-popup mcp-theme-1" stag-popup-key="' + url + '">' +
+                    '<div class="stag-popup ' + (style ? style : 'stag-popup-lg') + ' dynamic-popup draggable resizable mcp-theme-1" stag-popup-key="' + url + '">' +
                     '<div class="stag-popup-content p-0">' +
                     '<div class="stag-popup-content p-0">' +
                     '<h3 class="stag-popup-title mb-0 mt-3 mx-3 pb-0 border-bottom-0"><span></span>' +
                     '<h3 class="stag-popup-title mb-0 mt-3 mx-3 pb-0 border-bottom-0"><span></span>' +
                     '<a href="#" class="ml-auto text-secondary" onclick="return closeStagPopup()"><i class="fa fa-times-circle"></i></a>\n' +
                     '<a href="#" class="ml-auto text-secondary" onclick="return closeStagPopup()"><i class="fa fa-times-circle"></i></a>\n' +
@@ -296,6 +296,169 @@ function hasResponseError(_data) {
                 closeStagPopup();
                 closeStagPopup();
                 return false;
                 return false;
             });
             });
+
+        // draggable
+        let dragging = false, dragX, dragY;
+        $(document)
+            .off('mousedown.start-drag', '.stag-popup.dynamic-popup.draggable .stag-popup-title')
+            .on('mousedown.start-drag', '.stag-popup.dynamic-popup.draggable .stag-popup-title', function(_e) {
+                if(dragging && dragging.length) {
+                    dragging = false;
+                }
+                dragging = $(this).closest('.stag-popup-content');
+                dragX = _e.screenX;
+                dragY = _e.screenY;
+            });
+        $(document)
+            .off('mousemove.drag')
+            .on('mousemove.drag', function(_e) {
+                if(dragging && dragging.length) {
+                    let targetX = dragging.position().left + (_e.screenX - dragX),
+                        targetY = dragging.position().top + (_e.screenY - dragY);
+                    if(targetX >= 0) dragX = _e.screenX;
+                    if(targetY >= 0) dragY = _e.screenY;
+                    if(targetX < 0) targetX = 0;
+                    if(targetY < 0) targetY = 0;
+                    dragging[0].style.left = targetX + 'px';
+                    dragging[0].style.top = targetY + 'px';
+                    dragging[0].style.transform = 'none';
+                    return false;
+                }
+            });
+
+        // resizable
+        let resizeHighlighting = false, resizeDirection = false, resizeAnchor = false, resizing = false, resizeGutter = 8, resizeX, resizeY;
+        $(document)
+            .off('mousemove.highlight-resize', '.stag-popup.dynamic-popup.resizable .stag-popup-content')
+            .on('mousemove.highlight-resize', '.stag-popup.dynamic-popup.resizable .stag-popup-content', function(_e) {
+                if(dragging && dragging.length) return;
+                if(resizing && resizing.length) return;
+                let mouseX = _e.pageX - $(this).offset().left,
+                    mouseY = _e.pageY - $(this).offset().top;
+                if((mouseX >= 0 && mouseX <= resizeGutter) || (mouseX >= $(this).outerWidth() - resizeGutter && mouseX <= $(this).outerWidth())) {
+                    $(this).addClass('resizing-x');
+                    resizeHighlighting = $(this);
+                    resizeDirection = 'x';
+                    resizeAnchor = (mouseX >= 0 && mouseX <= resizeGutter) ? 'left' : 'right';
+                }
+                else if((mouseY >= 0 && mouseY <= resizeGutter) || (mouseY >= $(this).outerHeight() - resizeGutter && mouseY <= $(this).outerHeight())) {
+                    $(this).addClass('resizing-y');
+                    resizeHighlighting = $(this);
+                    resizeDirection = 'y';
+                    resizeAnchor = (mouseY >= 0 && mouseY <= resizeGutter) ? 'top' : 'bottom';
+                }
+                else {
+                    $(this).removeClass('resizing-x');
+                    $(this).removeClass('resizing-y');
+                    resizeHighlighting = false;
+                }
+            });
+        $(document)
+            .off('mousedown.start-resize', '.stag-popup.dynamic-popup.resizable .stag-popup-content')
+            .on('mousedown.start-resize', '.stag-popup.dynamic-popup.resizable .stag-popup-content', function(_e) {
+                if(resizeHighlighting && resizeHighlighting.length) {
+                    if(resizing && resizing.length) {
+                        resizing.removeClass('resizing-x resizing-y');
+                        resizing = false;
+                    }
+                    resizing = $(this);
+                    resizeX = _e.screenX;
+                    resizeY = _e.screenY;
+                }
+            });
+        $(document)
+            .off('mousemove.resize')
+            .on('mousemove.resize', function(_e) {
+                if(resizing && resizing.length) {
+
+                    console.log(resizeDirection);
+                    console.log(resizeAnchor);
+
+                    // x
+                    if(resizeDirection === 'x') {
+
+                        let deltaX = _e.screenX - resizeX;
+
+                        // anchor: left => update left and width of the popup
+                        if(resizeAnchor === 'left') {
+                            resizing[0].style.left = resizing.position().left + deltaX + 'px';
+                            resizing[0].style.width = resizing.outerWidth() - deltaX + 'px';
+                            resizing[0].style.transform = 'none';
+                        }
+
+                        // anchor: right => update width of the popup
+                        else if(resizeAnchor === 'right') {
+                            resizing[0].style.left = resizing.position().left + 'px'
+                            resizing[0].style.width = resizing.outerWidth() + deltaX + 'px';
+                            resizing[0].style.transform = 'none';
+                        }
+                    }
+
+                    // x
+                    if(resizeDirection === 'y') {
+
+                        let deltaY = _e.screenY - resizeY;
+
+                        // anchor: top => update top and height of the popup
+                        if(resizeAnchor === 'top') {
+                            resizing[0].style.top = resizing.position().top + deltaY + 'px';
+                            resizing[0].style.height = resizing.outerHeight() - deltaY + 'px';
+                        }
+
+                        // anchor: bottom => update height of the popup
+                        else if(resizeAnchor === 'bottom') {
+                            resizing[0].style.height = resizing.outerHeight() + deltaY + 'px';
+                        }
+                    }
+
+                    resizeX = _e.screenX;
+                    resizeY = _e.screenY;
+                    return false;
+                }
+            });
+        $(document)
+            .off('mouseleave.stop-resize', '.stag-popup.dynamic-popup.resizable .stag-popup-content')
+            .on('mouseleave.stop-resize', '.stag-popup.dynamic-popup.resizable .stag-popup-content', function(_e) {
+                if(resizing && resizing.length) return;
+                if(resizeHighlighting && resizeHighlighting.length) {
+                    resizeHighlighting.removeClass('resizing-x resizing-y');
+                    resizeHighlighting = false;
+                    return false;
+                }
+            });
+
+        // common
+        $(document)
+            .off('mouseleave.stop-drag-resize')
+            .on('mouseleave.stop-drag-resize', function() {
+                if(dragging && dragging.length) {
+                    dragging = false;
+                }
+                if(resizeHighlighting && resizeHighlighting.length) {
+                    resizeHighlighting.removeClass('resizing-x resizing-y');
+                    resizeHighlighting = false;
+                }
+                if(resizing && resizing.length) {
+                    resizing.removeClass('resizing-x resizing-y');
+                    resizing = false;
+                }
+            });
+        $(document)
+            .off('mouseup.stop-drag-resize')
+            .on('mouseup.stop-drag-resize', function() {
+                if(dragging && dragging.length) {
+                    dragging = false;
+                }
+                if(resizeHighlighting && resizeHighlighting.length) {
+                    resizeHighlighting.removeClass('resizing-x resizing-y');
+                    resizeHighlighting = false;
+                }
+                if(resizing && resizing.length) {
+                    resizing.removeClass('resizing-x resizing-y');
+                    resizing = false;
+                }
+            });
+
     }
     }
     addMCInitializer('stag-popups', window.initStagPopupEvents);
     addMCInitializer('stag-popups', window.initStagPopupEvents);
 })();
 })();

+ 1 - 1
js-dev/stag-suggest.js

@@ -20,7 +20,7 @@
             let term = elem.val();
             let term = elem.val();
             let ep = $(elem).attr('stag-suggest-ep'), extra = $(elem).attr('stag-suggest-extra');
             let ep = $(elem).attr('stag-suggest-ep'), extra = $(elem).attr('stag-suggest-extra');
             if(!!ep) { // remote lookup
             if(!!ep) { // remote lookup
-                if (!!term) {
+                if (!!term && term.length >= 2) {
 
 
                     $.get(ep + '?term=' + $.trim(term) + (!!extra ? '&' + extra : ''), function (_data) {
                     $.get(ep + '?term=' + $.trim(term) + (!!extra ? '&' + extra : ''), function (_data) {
 
 

+ 5 - 0
js-dev/yemi.js

@@ -325,6 +325,11 @@ var initMoes = function() {
         var submit = moe.find('[submit]'); // REQUIRED
         var submit = moe.find('[submit]'); // REQUIRED
         var cancel = moe.find('[cancel]')[0]; // OPTIONAL
         var cancel = moe.find('[cancel]')[0]; // OPTIONAL
 
 
+        let moeRefreshContainer = moe.closest('[moe-refresh-container][id]');
+        if(!target && moeRefreshContainer.length) {
+            target = '#' + moeRefreshContainer.attr('id');
+        }
+
         // ajax load - OPTIONAL
         // ajax load - OPTIONAL
         var moeParent = $(form).closest('[moe-parent][url]');
         var moeParent = $(form).closest('[moe-parent][url]');
 
 

+ 133 - 7
public/css/style.css

@@ -41,6 +41,9 @@
 .w-70 {
 .w-70 {
   width: var(--w-70);
   width: var(--w-70);
 }
 }
+.text-warning-dark {
+    color: #856404!important;
+}
 .text-warning-mellow {
 .text-warning-mellow {
     color: #d8a714!important;
     color: #d8a714!important;
 }
 }
@@ -381,6 +384,9 @@ body>nav.navbar {
 .mcp-theme-1 .width-200px {
 .mcp-theme-1 .width-200px {
     width: 200px !important;
     width: 200px !important;
 }
 }
+.mcp-theme-1 .width-250px {
+    width: 250px !important;
+}
 .mcp-theme-1 .width-300px {
 .mcp-theme-1 .width-300px {
     width: 300px !important;
     width: 300px !important;
 }
 }
@@ -430,12 +436,21 @@ body>nav.navbar {
 .mcp-theme-1 .min-width-110px {
 .mcp-theme-1 .min-width-110px {
     min-width: 110px !important;
     min-width: 110px !important;
 }
 }
+.mcp-theme-1 .max-width-110px {
+    max-width: 110px !important;
+}
 .mcp-theme-1 .min-width-140px {
 .mcp-theme-1 .min-width-140px {
     min-width: 140px !important;
     min-width: 140px !important;
 }
 }
+.mcp-theme-1 .max-width-140px {
+    max-width: 140px !important;
+}
 .mcp-theme-1 .min-width-200px {
 .mcp-theme-1 .min-width-200px {
     min-width: 200px !important;
     min-width: 200px !important;
 }
 }
+.mcp-theme-1 .min-width-250px {
+    min-width: 250px !important;
+}
 .mcp-theme-1 .min-width-300px {
 .mcp-theme-1 .min-width-300px {
     min-width: 300px;
     min-width: 300px;
 }
 }
@@ -451,6 +466,9 @@ body>nav.navbar {
 .mcp-theme-1 .max-width-700px {
 .mcp-theme-1 .max-width-700px {
     max-width: 700px !important;
     max-width: 700px !important;
 }
 }
+.mcp-theme-1 .min-width-1100px {
+    min-width: 1100px !important;
+}
 .mcp-theme-1 .width-100px {
 .mcp-theme-1 .width-100px {
     width: 100px;
     width: 100px;
     min-width: unset !important;
     min-width: unset !important;
@@ -475,6 +493,9 @@ body>nav.navbar {
     width: 100% !important;
     width: 100% !important;
     min-width: unset !important;
     min-width: unset !important;
 }
 }
+.mcp-theme-1 .max-width-170px {
+    max-width: 170px;
+}
 .mcp-theme-1 .max-width-200px {
 .mcp-theme-1 .max-width-200px {
     max-width: 200px;
     max-width: 200px;
 }
 }
@@ -660,11 +681,16 @@ input.search_field, textarea.search_field {
         padding-top: 55px;
         padding-top: 55px;
     }
     }
 }
 }
-
+.d-xlarge {
+    display: none;
+}
 @media screen and (max-width: 1400px) {
 @media screen and (max-width: 1400px) {
   .flex-container > div:first-child {
   .flex-container > div:first-child {
     margin-bottom: 20px;
     margin-bottom: 20px;
   }
   }
+  .d-xlarge {
+      display: none;
+  }
 }
 }
 @media screen and (min-width: 1400px) {
 @media screen and (min-width: 1400px) {
   .flex-container{
   .flex-container{
@@ -680,6 +706,9 @@ input.search_field, textarea.search_field {
     margin-right: 20px;
     margin-right: 20px;
     padding-right: 20px;
     padding-right: 20px;
   }
   }
+  .d-xlarge {
+    display: inline-block;
+}
 }
 }
 
 
 .main-row > .sidebar .nav .nav-item a {
 .main-row > .sidebar .nav .nav-item a {
@@ -1296,6 +1325,29 @@ body .node input[type="number"] {
     border-top: 1px solid #e1e1e1;
     border-top: 1px solid #e1e1e1;
 }
 }
 
 
+/* draggable popup */
+.stag-popup.draggable .stag-popup-content {
+    position: absolute;
+    left: 50%;
+    transform: translate(-50%, 0);
+}
+.stag-popup.dynamic-popup.draggable .stag-popup-title {
+    cursor: move;
+}
+
+/* resizable popup */
+.stag-popup.resizable .stag-popup-content.resizing-x {
+    outline: 1px solid rgba(0, 128, 128, 0.3);
+    cursor: ew-resize;
+}
+.stag-popup.resizable .stag-popup-content.resizing-y {
+    outline: 1px solid rgba(0, 128, 128, 0.3);
+    cursor: ns-resize;
+}
+.stag-popup.resizable .stag-popup-content {
+    overflow: auto !important;
+}
+
 /* slide-in stag-popups */
 /* slide-in stag-popups */
 .stag-popup.stag-slide {
 .stag-popup.stag-slide {
     display: block;
     display: block;
@@ -1712,6 +1764,25 @@ table.table-edit-sheet .ql-editor[contenteditable] {
 .data-option-list>div:hover {
 .data-option-list>div:hover {
     background: aliceblue;
     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) {
 .measurement-item:not(:last-child) {
     border-bottom: 1px solid #e7e7e7;
     border-bottom: 1px solid #e7e7e7;
 }
 }
@@ -2531,9 +2602,6 @@ body.in-iframe .main-row > .sidebar {
     font-weight: bold;
     font-weight: bold;
     background: #fff;
     background: #fff;
 }
 }
-tr.relevant-to-visit td:nth-child(1) {
-    color: #17a2b8;
-}
 .autosave-indicator {
 .autosave-indicator {
     display: none;
     display: none;
 }
 }
@@ -2928,6 +2996,14 @@ table.stag-compact-grid>tbody>tr>td [if-grid-view] {
     text-decoration: none;
     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 */
 /* jstree overrides */
 .stat-tree-view .jstree-wholerow {
 .stat-tree-view .jstree-wholerow {
     border-bottom: 1px solid #f1f1f1;
     border-bottom: 1px solid #f1f1f1;
@@ -3289,7 +3365,7 @@ body.forced-masking #mask {
     box-shadow: none;
     box-shadow: none;
 }
 }
 .inline-input-underlined.width-50 {
 .inline-input-underlined.width-50 {
-    width: 50px;
+    width: 32px;
 }
 }
 .note_template_omega_soap_visit .system_segment .d-flex.border-bottom:last-of-type {
 .note_template_omega_soap_visit .system_segment .d-flex.border-bottom:last-of-type {
     border-bottom: 0 !important;
     border-bottom: 0 !important;
@@ -3365,6 +3441,7 @@ body.forced-masking #mask {
 .stag-sheet tbody tr td {
 .stag-sheet tbody tr td {
     padding: 0;
     padding: 0;
     background: #fff;
     background: #fff;
+    cursor: text;
 }
 }
 .stag-sheet tbody tr td input,
 .stag-sheet tbody tr td input,
 .stag-sheet tbody tr td textarea {
 .stag-sheet tbody tr td textarea {
@@ -3384,6 +3461,18 @@ body.forced-masking #mask {
 .stag-sheet tbody tr td textarea:focus-visible{
 .stag-sheet tbody tr td textarea:focus-visible{
     border: 1px solid steelblue;
     border: 1px solid steelblue;
 }
 }
+.mcp-theme-1 .stag-sheet .ql-container {
+    border: 0;
+}
+.mcp-theme-1 .stag-sheet .ql-editor[contenteditable] {
+    min-height: 28px;
+    border: 1px solid transparent;
+    padding: 3px;
+}
+.mcp-theme-1 .stag-sheet .ql-editor[contenteditable]:focus {
+    min-height: 28px;
+    border: 1px solid steelblue;
+}
 .note-container .summary-container p {
 .note-container .summary-container p {
     margin-top: 0 !important;
     margin-top: 0 !important;
     margin-bottom: 0 !important;
     margin-bottom: 0 !important;
@@ -3449,7 +3538,7 @@ body.forced-masking #mask {
 .mcp-theme-1 .point-table [if-read-mode] .inline-html-container {
 .mcp-theme-1 .point-table [if-read-mode] .inline-html-container {
     cursor: pointer;
     cursor: pointer;
 }
 }
-table.v-top td, 
+table.v-top td,
 table.v-top th {
 table.v-top th {
     vertical-align:top;
     vertical-align:top;
 }
 }
@@ -3475,4 +3564,41 @@ table.v-top th {
     border-color: #80bdff;
     border-color: #80bdff;
     outline: 0;
     outline: 0;
     box-shadow: 0 0 0 0.2rem rgb(0 123 255 / 25%);
     box-shadow: 0 0 0 0.2rem rgb(0 123 255 / 25%);
-}
+}
+.coverage-payer-name {
+    max-width: 120px;
+    white-space: nowrap;
+    overflow: hidden;
+    text-overflow: ellipsis;
+    display: inline-block;
+}
+.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_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_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_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;
+}
+.cpc-cancelled {
+    pointer-events: none;
+    opacity: 0.4;
+    border: 1px dashed #333;
+    padding: 5px;
+}
+.note-container .segments-list p>br:first-child:last-child,
+.note-container .segments-list p:empty {
+    display: none;
+}

+ 2 - 0
public/css/yemi.css

@@ -3,6 +3,7 @@
 }
 }
 [moe] {
 [moe] {
     display: inline-block;
     display: inline-block;
+    position: relative;
 }
 }
 [moe][relative] {
 [moe][relative] {
     position: relative;
     position: relative;
@@ -13,6 +14,7 @@
     background-color: white;
     background-color: white;
     padding: 10px;
     padding: 10px;
     border: 1px solid gray;
     border: 1px solid gray;
+    min-width: 180px;
 }
 }
 [moe][fixed-center] [url]:not([show]) {
 [moe][fixed-center] [url]:not([show]) {
     position: fixed !important;
     position: fixed !important;

+ 2 - 2
public/js/icd-autocomplete.js

@@ -4,7 +4,7 @@
         let self = this;
         let self = this;
         $('[icd-autocomplete-code]:not([ac-initialized])').each(function() {
         $('[icd-autocomplete-code]:not([ac-initialized])').each(function() {
             let elem = this, dynID = 'icd-' + Math.ceil(Math.random() * 1000000),
             let elem = this, dynID = 'icd-' + Math.ceil(Math.random() * 1000000),
-                codeElem = $(this), descElem = $(this).closest('form').find('[icd-autocomplete-description]');
+                codeElem = $(this), descElem = $(this).closest('form, tr').first().find('[icd-autocomplete-description]');
             var targetDescElem = $(this).data('target');
             var targetDescElem = $(this).data('target');
             if(targetDescElem){
             if(targetDescElem){
                 descElem = $(this).closest('form').find(targetDescElem);
                 descElem = $(this).closest('form').find(targetDescElem);
@@ -20,7 +20,7 @@
             window.Def.Autocompleter.Event.observeListSelections(dynID, function() {
             window.Def.Autocompleter.Event.observeListSelections(dynID, function() {
                 let autocomp = elem.autocomp, acData = autocomp.getSelectedItemData();
                 let autocomp = elem.autocomp, acData = autocomp.getSelectedItemData();
                 codeElem.val(acData[0].code).trigger('change');
                 codeElem.val(acData[0].code).trigger('change');
-                descElem.val(acData[0].data['name']).trigger('change');
+                descElem.val(acData[0].data['name']).attr('title', acData[0].data['name']).trigger('change');
                 return false;
                 return false;
             });
             });
             $(elem).attr('ac-initialized', 1);
             $(elem).attr('ac-initialized', 1);

+ 5 - 1
public/v-splitter-px/v-splitter.js

@@ -1,4 +1,4 @@
-function initVSplitter(_name, _left, _right, _alignTo = null) {
+function initVSplitter(_name, _left, _right, _alignTo = null, _style = null) {
 
 
     var minSplitWidth = 300;
     var minSplitWidth = 300;
 
 
@@ -17,6 +17,10 @@ function initVSplitter(_name, _left, _right, _alignTo = null) {
     _right.addClass('v-split-panel').css({maxWidth: 'unset', minWidth: 'unset'});
     _right.addClass('v-split-panel').css({maxWidth: 'unset', minWidth: 'unset'});
     const vSplit = $('<div/>').addClass('v-split').attr('data-name', _name).insertAfter(_left);
     const vSplit = $('<div/>').addClass('v-split').attr('data-name', _name).insertAfter(_left);
 
 
+    if(_style) {
+        vSplit.css(_style);
+    }
+
     function _setSplitterHeight() {
     function _setSplitterHeight() {
         if(!_alignTo) return;
         if(!_alignTo) return;
         vSplit.css({marginTop: (_alignTo.position().top + 'px'), height: (_alignTo.outerHeight())});
         vSplit.css({marginTop: (_alignTo.position().top + 'px'), height: (_alignTo.outerHeight())});

+ 36 - 2
resources/views/app/admin/notes_pending_summary_suggestion.blade.php

@@ -16,6 +16,7 @@
                     <th class="border-0">Patient</th>
                     <th class="border-0">Patient</th>
                     <th class="border-0">ICD</th>
                     <th class="border-0">ICD</th>
                     <th class="border-0">Status</th>
                     <th class="border-0">Status</th>
+                    <th class="border-0">Suggestions</th>
                 </tr>
                 </tr>
                 </thead>
                 </thead>
                 <tbody>
                 <tbody>
@@ -28,16 +29,49 @@
                         </td>
                         </td>
                         <td>{{$row->client->displayName()}}</td>
                         <td>{{$row->client->displayName()}}</td>
                         <td>
                         <td>
-                            @foreach($row->reasons as $reason)
+                            @foreach($row->reasons() as $reason)
                                 <span class="pr-2">{{$reason->code}}</span>
                                 <span class="pr-2">{{$reason->code}}</span>
                             @endforeach
                             @endforeach
-                            @if(!$row->reasons || !count($row->reasons))
+                            @if(!$row->reasons() || !count($row->reasons()))
                                 -
                                 -
                             @endif
                             @endif
                         </td>
                         </td>
                         <td>
                         <td>
                             {{$row->overallStatus()}}
                             {{$row->overallStatus()}}
                         </td>
                         </td>
+                        <td class="p-0">
+                            @php $segments = $row->segmentsWithPendingSummarySuggestion; @endphp
+                            <table class="table table-sm m-0">
+                                @foreach($segments as $segment)
+                                    <tr>
+                                        <td class="width-100px">
+                                            <div class="d-flex align-items-baseline grow-till-300px">
+                                                <span>{{$segment->display_title}}</span>
+                                                <div class="on-hover-show left on-hover-opaque">
+                                                    <i class="fa fa-info-circle ml-1"></i>
+                                                    <div class="on-hover-content p-2 text-sm">
+                                                        <div class="d-flex align-items-start border p-1 mb-2">
+                                                            <span class="mr-1 width-70px">Original:</span>
+                                                            <div class="bg-light inline-html-container max-height-100px max-width-300px overflow-hidden">
+                                                                {!! $segment->summary_html !!}
+                                                            </div>
+                                                        </div>
+                                                        <div class="d-flex align-items-start border p-1">
+                                                            <span class="mr-1 width-70px">Suggested:</span>
+                                                            <div class="bg-light inline-html-container max-height-100px max-width-300px overflow-hidden">
+                                                                {!! $segment->proposedSegmentSummarySuggestion->summary_html !!}
+                                                            </div>
+                                                        </div>
+                                                    </div>
+                                                </div>
+                                            </div>
+                                        </td>
+                                        <td>{{$segment->proposedSegmentSummarySuggestion->creator->displayName()}}</td>
+                                        <td>{{friendlier_date($segment->proposedSegmentSummarySuggestion->created_at)}}</td>
+                                    </tr>
+                                @endforeach
+                            </table>
+                        </td>
                     </tr>
                     </tr>
                 @endforeach
                 @endforeach
                 </tbody>
                 </tbody>

+ 2 - 2
resources/views/app/admin/notes_rejected_summary_suggestion.blade.php

@@ -28,10 +28,10 @@
                         </td>
                         </td>
                         <td>{{$row->client->displayName()}}</td>
                         <td>{{$row->client->displayName()}}</td>
                         <td>
                         <td>
-                            @foreach($row->reasons as $reason)
+                            @foreach($row->reasons() as $reason)
                                 <span class="pr-2">{{$reason->code}}</span>
                                 <span class="pr-2">{{$reason->code}}</span>
                             @endforeach
                             @endforeach
-                            @if(!$row->reasons || !count($row->reasons))
+                            @if(!$row->reasons() || !count($row->reasons()))
                                 -
                                 -
                             @endif
                             @endif
                         </td>
                         </td>

+ 5 - 5
resources/views/app/admin/part_b_patients-table.blade.php

@@ -34,15 +34,15 @@
 					@endforeach
 					@endforeach
 				</td>
 				</td>
 				<td>
 				<td>
-					@if($patient->latestClientPrimaryCoverage)
-						{{friendly_money($patient->latestClientPrimaryCoverage->auto_medicare_mpb_remaining)}}
+					@if($patient->mpb_remaining)
+						{{friendly_money($patient->mpb_remaining)}}
 					@else 
 					@else 
 						No data
 						No data
 					@endif	
 					@endif	
 				</td>
 				</td>
 				<td>
 				<td>
-					@if($patient->latestClientPrimaryCoverage)
-						{{friendly_date_time($patient->latestClientPrimaryCoverage->created_at)}}
+					@if($patient->getPrimaryCoverage())
+						{{friendly_date_time($patient->getPrimaryCoverage()->created_at)}}
 					@else 
 					@else 
 						No data
 						No data
 					@endif	
 					@endif	
@@ -52,7 +52,7 @@
                         <a href="" start show class="">Refresh</a>
                         <a href="" start show class="">Refresh</a>
 
 
                         <form url="/api/clientPrimaryCoverage/refreshCoverageForMedicare" class="mcp-theme-1">
                         <form url="/api/clientPrimaryCoverage/refreshCoverageForMedicare" class="mcp-theme-1">
-                            <input type="hidden" name="uid" value="{{$patient->latestClientPrimaryCoverage->uid}}" class="form-control input-sm" />
+                            <input type="hidden" name="uid" value="{{$patient->getPrimaryCoverage()->uid}}" class="form-control input-sm" />
                             <div class="form-group">
                             <div class="form-group">
                                 <p>Refresh?</p>
                                 <p>Refresh?</p>
                             </div>
                             </div>

+ 26 - 8
resources/views/app/admin/patients-table-extended.blade.php

@@ -9,7 +9,7 @@
         <thead class="bg-light">
         <thead class="bg-light">
         <tr>
         <tr>
             <th class="border-0 width-90px">#</th>
             <th class="border-0 width-90px">#</th>
-            <th class="border-0">Name</th>            
+            <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("admin.patients"), 'label' => 'Name', 'key' => 'name_first'])</th>            
             @if($pro->pro_type == 'ADMIN')
             @if($pro->pro_type == 'ADMIN')
                 <th class="border-0">MCP</th>
                 <th class="border-0">MCP</th>
                 {{--<th class="border-0">NA</th>--}}
                 {{--<th class="border-0">NA</th>--}}
@@ -19,15 +19,18 @@
             @endif
             @endif
             <th class="border-0">Mailing Address State</th>
             <th class="border-0">Mailing Address State</th>
             <th class="border-0">Insurance</th>
             <th class="border-0">Insurance</th>
-            <th class="border-0">Last Visit</th>
+            @if($performer->pro->pro_type == 'ADMIN')
+		<th class="border-0">Ded.</th>
+	    @endif
+            <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("admin.patients"), 'label' => 'Last Visit', 'key' => 'most_recent_completed_mcp_note_date'])</th>
             <th class="border-0">Next Appt.</th>
             <th class="border-0">Next Appt.</th>
-            <th class="border-0">BP/Pulse Timestamp</th>
-            <th class="border-0">Weight Timestamp</th>
-            <th class="border-0">Created</th>
+            <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("admin.patients"), 'label' => 'BP/Pulse Timestamp', 'key' => 'most_recent_cellular_bp_measurement_at'])</th>
+            <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("admin.patients"), 'label' => 'Weight Timestamp', 'key' => 'most_recent_cellular_weight_measurement_at'])</th>
+            <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("admin.patients"), 'label' => 'Created', 'key' => 'created_at'])</th>
             <th class="border-0">Assigned On</th>
             <th class="border-0">Assigned On</th>
             <th class="border-0">NA</th>
             <th class="border-0">NA</th>
             <th class="border-0">Notes</th>
             <th class="border-0">Notes</th>
-            <th class="border-0">Status</th>
+            <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("admin.patients"), 'label' => 'Status', 'key' => 'client_engagement_status_category'])</th>
             <th class="border-0">Temp. Gun</th>
             <th class="border-0">Temp. Gun</th>
             <th class="border-0">Pulse Ox.</th>
             <th class="border-0">Pulse Ox.</th>
             <th class="border-0">Cell. Bp</th>
             <th class="border-0">Cell. Bp</th>
@@ -71,9 +74,23 @@
                     {{--<td>{{$patient->source}}</td>--}}
                     {{--<td>{{$patient->source}}</td>--}}
                 @endif
                 @endif
                 <td>{{$patient->mailing_address_state}}</td>
                 <td>{{$patient->mailing_address_state}}</td>
-                <td>
+                <td class="{{ $patient->mpb_remaining === 0 ? 'deductible-zero' : '' }}">
                     @include('app.patient.coverage_column_renderer', ['patient'=>$patient])
                     @include('app.patient.coverage_column_renderer', ['patient'=>$patient])
+                    @if(false && $performer->pro->pro_type == 'ADMIN')
+                        @if(@$patient->mpb_remaining)
+                        <small class="d-block text-sm text-muted ml-3">
+                            Deductible: <span class="font-weight-bold">{{ format_number(@$patient->mpb_remaining)}}</span>
+                        </small>
+                        @endif
+                    @endif 
                 </td>
                 </td>
+		@if($performer->pro->pro_type == 'ADMIN')
+		<td>
+                        <small class="d-block text-sm text-muted">
+                            <span class="font-weight-bold">{{ format_number(@$patient->mpb_remaining)}}</span>
+                        </small>
+		</td>
+		@endif
                 <td>
                 <td>
                     {{ friendly_date($patient->most_recent_completed_mcp_note_date) }}
                     {{ friendly_date($patient->most_recent_completed_mcp_note_date) }}
                     {{-- {{$patient->lastMcpAppointment ? friendly_date_time($patient->lastMcpAppointment->raw_date.' '.$patient->lastMcpAppointment->raw_start_time) : '-'}}--}}
                     {{-- {{$patient->lastMcpAppointment ? friendly_date_time($patient->lastMcpAppointment->raw_date.' '.$patient->lastMcpAppointment->raw_start_time) : '-'}}--}}
@@ -332,8 +349,9 @@
 
 
     </table>
     </table>
 </div>
 </div>
-<div class="px-3 pt-3">
+<div class="px-3 pt-3 d-flex align-items-center">
     {{$patients->withQueryString()->links()}}
     {{$patients->withQueryString()->links()}}
+    <div class="ml-4 mb-3">Showing <b>{{$patients->firstItem()}}</b> to <b>{{$patients->lastItem()}}</b> (page {{$patients->currentPage()}}) of <b>{{$patients->total()}}</b> patients</div>
 </div>
 </div>
 
 
 <script>
 <script>

+ 2 - 2
resources/views/app/admin/patients-table.blade.php

@@ -163,8 +163,8 @@
 													{!! $note->hcpPro && $note->is_signed_by_hcp ? '<b class="text-success">Yes</b>' : 'No' !!}
 													{!! $note->hcpPro && $note->is_signed_by_hcp ? '<b class="text-success">Yes</b>' : 'No' !!}
 												</td>
 												</td>
 												<td class="max-width-200px">
 												<td class="max-width-200px">
-													@if(count($note->reasons))
-														@foreach ($note->reasons as $reason)
+													@if(count($note->reasons()))
+														@foreach ($note->reasons() as $reason)
 															<div class="mb-1">
 															<div class="mb-1">
 																<span>{{ $reason->code }}</span>
 																<span>{{ $reason->code }}</span>
 																<span class="text-secondary text-sm">{{ $reason->description}}</span>
 																<span class="text-secondary text-sm">{{ $reason->description}}</span>

+ 12 - 0
resources/views/app/admin/patients_filters.blade.php

@@ -150,6 +150,7 @@
 			<label>Status:</label>
 			<label>Status:</label>
 			<select name="status" class="form-control input-sm" v-model="filters.status">
 			<select name="status" class="form-control input-sm" v-model="filters.status">
 				<option value="">All</option>
 				<option value="">All</option>
+				<option value="NONE">None</option>
  				<option value="ACTIVE">Active</option>
  				<option value="ACTIVE">Active</option>
  				<option value="DUMMY">Test Record</option>
  				<option value="DUMMY">Test Record</option>
  				<option value="NO_LONGER_INTERESTED">No Longer Interested</option>
  				<option value="NO_LONGER_INTERESTED">No Longer Interested</option>
@@ -282,6 +283,16 @@
 			</div>
 			</div>
 		</div>
 		</div>
 	</div>
 	</div>
+	<div class="sm-section">
+		<div class="">
+			<div class="checkbox mt-4 pt-2">
+				<label class="text-nowrap font-weight-normal mr-2">
+					<input type="checkbox" name="zero_deductible"  v-model="filters.zero_deductible">
+					Zero deductible
+				</label>
+			</div>
+		</div>
+	</div>
 	@endif
 	@endif
 
 
 
 
@@ -367,6 +378,7 @@ $allFilterKeys = [
 	'initiative',
 	'initiative',
 	'insurance',
 	'insurance',
 	'include_test_records',
 	'include_test_records',
+	'zero_deductible',
 	'number_of_measurements',
 	'number_of_measurements',
 	'number_of_measurements_value_1',
 	'number_of_measurements_value_1',
 	'number_of_measurements_value_2',
 	'number_of_measurements_value_2',

+ 67 - 0
resources/views/app/admin/patients_missing_default_settings.blade.php

@@ -0,0 +1,67 @@
+@extends ('layouts/template')
+
+@section('content')
+<div class="p-3 mcp-theme-1" id="patients-list">
+	<div class="card border-bottom-0">
+
+		<div class="card-header px-3 py-2 d-flex align-items-center">
+			<strong class="mr-4">
+				<i class="fas fa-users"></i>
+				Patients Missing Default Settings
+			</strong>
+		</div>
+		<div class="p-3">
+			@include('app.admin.patients_missing_defsult_settings_filters')
+		</div>
+		<table class="table table-striped p-0 m-0 table-sm border-top border-bottom ">
+			<thead class="bg-light">
+				<tr>
+					<th class="border-0">Chart #</th>
+					<th class="border-0">Patient</th>
+					<th class="border-0">MCP</th>
+					<th class="border-0">Default MCP Company Pro</th>
+					<th class="border-0">Default MCP Company Pro Payer</th>
+					<th class="border-0">Default MCP Company Location</th>
+					<th class="border-0">Insurance</th>
+				</tr>
+			</thead>
+			<tbody>
+				@foreach($patients as $patient)
+				<tr>
+					<td>
+						<a href="{{route('patients.view.settings', $patient)}}">
+							{{$patient->chart_number}}
+						</a>
+					</td>
+					<td>
+						<a href="{{route('patients.view.settings', $patient)}}">
+							{{$patient->displayName()}}
+						</a>
+					</td>
+					<td>{{ $patient->mcp ? $patient->mcp->displayName() : 'NO' }}</td>
+					<td>{{ $patient->defaultMcpCompanyPro ? $patient->defaultMcpCompanyPro->company->name : 'NO' }}</td>
+					<td>{{ $patient->defaultMcpCompanyProPayer ? $patient->defaultMcpCompanyProPayer->payer->name : 'NO' }}</td>
+					<td>{{$patient->default_mcp_company_location_id? implode(" ", [$patient->defaultMcpCompanyLocation->line1, $patient->defaultMcpCompanyLocation->city, $patient->defaultMcpCompanyLocation->state]):'NO'}}</td>
+					<td>
+						@include('app.patient.coverage_column_renderer', ['patient'=>$patient])
+					</td>
+				</tr>
+				@endforeach
+
+				@if(count($patients) === 0)
+				<tr>
+					<td colspan="7">No records found!</td>
+				</tr>
+				@endif
+			</tbody>
+
+		</table>
+	</div>
+	<div class="p-3">
+		{{$patients->withQueryString()->links()}}
+	</div>
+
+</div>
+</div>
+</div>
+@endsection

+ 163 - 0
resources/views/app/admin/patients_missing_defsult_settings_filters.blade.php

@@ -0,0 +1,163 @@
+<style>
+	#admin-patients-filters label {
+		font-weight: bold;
+	}
+
+	#admin-patients-filters .mw-100px {
+		min-width: 100px;
+	}
+
+	.filter-container {
+		display: flex;
+		align-items: flex-start;
+		flex-wrap: wrap;
+	}
+
+	.filter-container>div {
+		width: 165px;
+	}
+
+	.filter-container>div:not(:last-child) {
+		margin-right: 10px;
+	}
+
+	.sm-section {
+		width: 150px !important;
+	}
+</style>
+<form id="admin-patients-filters" method="GET" action="{{ route('admin.patientsMissingDefasultSettings') }}" class="filter-container" v-cloak>
+	<div class="sm-section">
+		<div class="">
+			<label>Name:</label>
+			<input name="name" class="form-control input-sm" v-model="filters.name">
+		</div>
+	</div>
+
+	<div class="sm-section">
+		<div class="mcp-filter-container">
+			<label>MCP:</label>
+		</div>
+	</div>
+
+	<!-- STATUS -->
+	<div class="sm-section">
+		<div class="">
+			<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>
+			</select>
+		</div>
+	</div>
+
+	<div class="sm-section">
+		<div class="">
+			<label>Insurance:</label>
+			<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>
+				<option value="OTHER">Other</option>
+				<option value="PENDING">Pending</option>
+				<option value="NOT_COVERED">Not Covered</option>
+			</select>
+		</div>
+	</div>
+
+	<div class="sm-section">
+		<div class="">
+			<label>Chart #</label>
+			<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">
+				<option value="">Any</option>
+				<option value="NO_MCP">No MCP</option>
+				<option value="NO_MCP_COMPANY_PRO">No MCP Company Pro</option>
+				<option value="NO_MCP_COMPANY_PRO_PAYER">No MCP Company Pro Payer</option>
+				<option value="NO_MCP_COMPANY_LOCATION">No MCP Company Location</option>
+			</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>
+			<div class=" d-flex">
+				<button type="button" v-on:click.prevent="doSubmit()" class="btn btn-primary btn-sm mr-2"><i class="fas fa-filter"></i> Filter</button>
+				<a href="#" v-on:click.prevent="fastLoad('{{route('admin.patientsMissingDefasultSettings')}}')" class="btn btn-link btn-sm text-danger">Clear</a>
+			</div>
+		</div>
+	</div>
+</form>
+
+<?php
+$loadedFilters = $filters;
+$allFilterKeys = [
+	'name',
+	'status',
+	'insurance',
+	'chart_number',
+	'missing_default_settings',
+	'care_plan'
+];
+for ($i = 0; $i < count($allFilterKeys); $i++) {
+	if (!isset($loadedFilters[$allFilterKeys[$i]]) || !$loadedFilters[$allFilterKeys[$i]]) {
+		$loadedFilters[$allFilterKeys[$i]] = '';
+	}
+}
+?>
+<script>
+	(function() {
+		function init() {
+			new Vue({
+				el: '#admin-patients-filters',
+				delimiters: ['@{{', '}}'],
+				data: {
+					filters: <?= json_encode($loadedFilters) ?>
+				},
+				methods: {
+					init: function() {
+
+					},
+					doSubmit: function() {
+						fastLoad("{{ route('admin.patientsMissingDefasultSettings') }}?" + $('#admin-patients-filters').serialize());
+						return false;
+					}
+				},
+				mounted: function() {
+					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');
+					let naSelect = $('<select name="na" class="form-control min-width-unset input-sm" provider-search data-pro-uid="{{request()->input("na")}}" provider-type="non-hcp"><option value="">--select--</option></select>').appendTo('.na-filter-container');
+					initProSuggest();
+				},
+			});
+
+
+		}
+		addMCInitializer('admin-patients-filters', init, '#admin-patients-filters');
+	})();
+</script>

+ 16 - 7
resources/views/app/dashboard-admin.blade.php

@@ -25,15 +25,15 @@
                             <table class="table mb-0 dashboard-stats-table">
                             <table class="table mb-0 dashboard-stats-table">
                                 <tbody>
                                 <tbody>
                                 <tr>
                                 <tr>
-                                    <th class="px-2 text-center">{{$pro->get_patients_count_as_mcp()}}</th>
+                                    <th class="px-2 text-center">{{$pro->get_patients_count_as_admin()}}</th>
                                     <th class="pl-2">Patients</th>
                                     <th class="pl-2">Patients</th>
                                 </tr>
                                 </tr>
                                 <tr>
                                 <tr>
-                                    <th class="px-2 text-center">{{$pro->get_new_patients_awaiting_visit_count_as_mcp()}}</th>
+                                    <th class="px-2 text-center">{{$pro->get_new_patients_awaiting_visit_count_as_admin()}}</th>
                                     <th class="pl-2">New Patients Awaiting Visit</th>
                                     <th class="pl-2">New Patients Awaiting Visit</th>
                                 </tr>
                                 </tr>
                                 <tr>
                                 <tr>
-                                    <th class="px-2 text-center">{{$pro->get_notes_pending_signature_count_as_mcp()}}</th>
+                                    <th class="px-2 text-center">{{$pro->get_notes_pending_signature_count_as_admin()}}</th>
                                     <th class="pl-2">Notes Pending Signature</th>
                                     <th class="pl-2">Notes Pending Signature</th>
                                 </tr>
                                 </tr>
                                 <tr>
                                 <tr>
@@ -42,7 +42,7 @@
                                         <a href="{{ route('admin.notes_pending_summary_suggestion') }}"
                                         <a href="{{ route('admin.notes_pending_summary_suggestion') }}"
                                            native target="_blank"
                                            native target="_blank"
                                            open-in-stag-popup
                                            open-in-stag-popup
-                                           popup-style="tall"
+                                           popup-style="tall stag-popup-md"
                                            title="Notes With Pending Summary Suggestion">
                                            title="Notes With Pending Summary Suggestion">
                                             Notes With Pending Summary Suggestion
                                             Notes With Pending Summary Suggestion
                                         </a>
                                         </a>
@@ -61,16 +61,16 @@
                                     </th>
                                     </th>
                                 </tr>
                                 </tr>
                                 <tr>
                                 <tr>
-                                    <th class="px-2 text-center">{{$pro->get_notes_pending_billing_count_as_mcp()}}</th>
+                                    <th class="px-2 text-center">{{$pro->get_notes_pending_billing_count_as_admin()}}</th>
                                     <th class="pl-2">Notes Pending Billing</th>
                                     <th class="pl-2">Notes Pending Billing</th>
                                 </tr>
                                 </tr>
                                 <tr>
                                 <tr>
-                                    <th class="px-2 text-center">{{$pro->get_incoming_reports_pending_signature_count_as_mcp()}}</th>
+                                    <th class="px-2 text-center">{{$pro->get_incoming_reports_pending_signature_count_as_admin()}}</th>
                                     <th class="pl-2">Reports Pending Signature</th>
                                     <th class="pl-2">Reports Pending Signature</th>
                                 </tr>
                                 </tr>
 
 
                                 <tr>
                                 <tr>
-                                    <th class="px-2 text-center">{{$pro->get_patients_without_appointment_count_as_mcp()}}</th>
+                                    <th class="px-2 text-center">{{$pro->get_patients_without_appointment_count_as_admin()}}</th>
                                     <th class="pl-2">Patients w/o Appointments</th>
                                     <th class="pl-2">Patients w/o Appointments</th>
                                 </tr>
                                 </tr>
                                 <tr>
                                 <tr>
@@ -98,6 +98,15 @@
                                     <th class="px-2 text-center">{{$pro->get_supply_orders_awaiting_signature_count_as_mcp()}}</th>
                                     <th class="px-2 text-center">{{$pro->get_supply_orders_awaiting_signature_count_as_mcp()}}</th>
                                     <th class="pl-2">Supply Orders Pending Signature</th>
                                     <th class="pl-2">Supply Orders Pending Signature</th>
                                 </tr>
                                 </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_open_tickets_count_as_mcp()}}</th>
+                                    <th class="pl-2">
+                                        <a href="{{ route('practice-management.myTickets') }}">
+                                            Open Ticket{{$pro->get_open_tickets_count_as_mcp() !== 1 ? 's' : ''}}
+                                        </a>
+                                    </th>
+                                </tr>
+
                                 </tbody>
                                 </tbody>
                             </table>
                             </table>
                         </div>
                         </div>

+ 23 - 3
resources/views/app/dashboard-mcp.blade.php

@@ -70,7 +70,7 @@
                                         <a href="{{ route('mcp.notes_pending_summary_suggestion') }}"
                                         <a href="{{ route('mcp.notes_pending_summary_suggestion') }}"
                                            native target="_blank"
                                            native target="_blank"
                                            open-in-stag-popup
                                            open-in-stag-popup
-                                           popup-style="tall"
+                                           popup-style="tall stag-popup-md"
                                            title="Notes With Pending Summary Suggestion">
                                            title="Notes With Pending Summary Suggestion">
                                             Notes With Pending Summary Suggestion
                                             Notes With Pending Summary Suggestion
                                         </a>
                                         </a>
@@ -235,6 +235,26 @@
                                         </a>
                                         </a>
                                     </th>
                                     </th>
                                 </tr>
                                 </tr>
+                                @if($pro->is_enrolled_as_mcp)
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_unsigned_rpm_bills_count_as_mcp()}}</th>
+                                    <th class="pl-2">
+                                        <a href="{{ route('practice-management.rpm-matrix-mcp') }}?f_billable=yes">
+                                            Unsigned RPM Bills (MCP)
+                                        </a>
+                                    </th>
+                                </tr>
+                                @endif
+                                @if($pro->is_considered_for_rmm)
+                                    <tr>
+                                        <th class="px-2 text-center">{{$pro->get_unsigned_rpm_bills_count_as_rmm()}}</th>
+                                        <th class="pl-2">
+                                            <a href="{{ route('practice-management.rpm-matrix-rmm') }}?f_billable=yes">
+                                                Unsigned RPM Bills (RMM)
+                                            </a>
+                                        </th>
+                                    </tr>
+                                @endif
                                 </tbody>
                                 </tbody>
                             </table>
                             </table>
                         </div>
                         </div>
@@ -339,7 +359,7 @@
                             <div id="mcp-dashboard-appointments" class="mb-4">
                             <div id="mcp-dashboard-appointments" class="mb-4">
 
 
                             </div>
                             </div>
-                            @if($performer->pro->can_view_rm_matrix || $performer->pro->pro_type=='ADMIN')
+                            {{--@if($performer->pro->can_view_rm_matrix || $performer->pro->pro_type=='ADMIN')
                             <div class="card mb-4">
                             <div class="card mb-4">
                                 <div class="card-header pl-2">
                                 <div class="card-header pl-2">
                                     <strong>
                                     <strong>
@@ -350,7 +370,7 @@
                                     @include('app.practice-management.remote-monitoring-tree')
                                     @include('app.practice-management.remote-monitoring-tree')
                                 </div>
                                 </div>
                             </div>
                             </div>
-                            @endif
+                            @endif--}}
                             <div class="card mb-4">
                             <div class="card mb-4">
                                 <div class="card-header pl-2">
                                 <div class="card-header pl-2">
                                     <strong>
                                     <strong>

+ 5 - 5
resources/views/app/dna/patients-table.blade.php

@@ -3,11 +3,11 @@
 	<thead class="bg-light border-top">
 	<thead class="bg-light border-top">
 		<tr>
 		<tr>
 			<th class="border-0">#</th>
 			<th class="border-0">#</th>
-			<th class="border-0">Name</th>
-			<th class="border-0">DOB</th>
-			<th class="border-0">Age</th>
-			<th class="border-0">Sex</th>
-			<th class="border-0">BMI</th>
+			<th class="border-0">@include('app.practice-management._sort_header', ['route' => route("dna.patients"), 'label' => 'Name', 'key' => 'name_first'])</th>
+			<th class="border-0">@include('app.practice-management._sort_header', ['route' => route("dna.patients"), 'label' => 'DOB', 'key' => 'dob'])</th>
+			<th class="border-0">@include('app.practice-management._sort_header', ['route' => route("dna.patients"), 'label' => 'Age', 'key' => 'age_in_years'])</th>
+			<th class="border-0">@include('app.practice-management._sort_header', ['route' => route("dna.patients"), 'label' => 'Sex', 'key' => 'sex'])</th>
+			<th class="border-0">@include('app.practice-management._sort_header', ['route' => route("dna.patients"), 'label' => 'BMI', 'key' => 'usual_bmi_min'])</th>
 			<th class="border-0">Insurance</th>
 			<th class="border-0">Insurance</th>
 			<th class="border-0">MCP</th>
 			<th class="border-0">MCP</th>
 			<th class="border-0">RPM</th>
 			<th class="border-0">RPM</th>

+ 1 - 1
resources/views/app/mc.blade.php

@@ -5,7 +5,7 @@
     <meta charset="UTF-8">
     <meta charset="UTF-8">
     <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
     <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
     <meta http-equiv="X-UA-Compatible" content="ie=edge">
     <meta http-equiv="X-UA-Compatible" content="ie=edge">
-    <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
+    <script src="/js/jquery-3.5.1.min.js"></script>
     <link href="/css/app.css?v={{config('app.asset_version')}}" rel="stylesheet">
     <link href="/css/app.css?v={{config('app.asset_version')}}" rel="stylesheet">
     <link href="/css/style.css?v={{config('app.asset_version')}}" rel="stylesheet">
     <link href="/css/style.css?v={{config('app.asset_version')}}" rel="stylesheet">
     <link href="/v-splitter-px/v-splitter.css?v={{config('app.asset_version')}}" rel="stylesheet" >
     <link href="/v-splitter-px/v-splitter.css?v={{config('app.asset_version')}}" rel="stylesheet" >

+ 2 - 2
resources/views/app/mcp/notes_pending_billing.blade.php

@@ -21,10 +21,10 @@
                         </td>
                         </td>
                         <td>{{$row->client->displayName()}}</td>
                         <td>{{$row->client->displayName()}}</td>
                         <td>
                         <td>
-                            @foreach($row->reasons as $reason)
+                            @foreach($row->reasons() as $reason)
                                 <span class="pr-2">{{$reason->code}}</span>
                                 <span class="pr-2">{{$reason->code}}</span>
                             @endforeach
                             @endforeach
-                            @if(!$row->reasons || !count($row->reasons))
+                            @if(!$row->reasons() || !count($row->reasons()))
                                 -
                                 -
                             @endif
                             @endif
                         </td>
                         </td>

+ 2 - 2
resources/views/app/mcp/notes_pending_signature.blade.php

@@ -28,10 +28,10 @@
                         </td>
                         </td>
                         <td>{{$row->client->displayName()}}</td>
                         <td>{{$row->client->displayName()}}</td>
                         <td>
                         <td>
-                            @foreach($row->reasons as $reason)
+                            @foreach($row->reasons() as $reason)
                                 <span class="pr-2">{{$reason->code}}</span>
                                 <span class="pr-2">{{$reason->code}}</span>
                             @endforeach
                             @endforeach
-                            @if(!$row->reasons || !count($row->reasons))
+                            @if(!$row->reasons() || !count($row->reasons()))
                                 -
                                 -
                             @endif
                             @endif
                         </td>
                         </td>

+ 2 - 2
resources/views/app/mcp/notes_pending_summary_suggestion.blade.php

@@ -28,10 +28,10 @@
                         </td>
                         </td>
                         <td>{{$row->client->displayName()}}</td>
                         <td>{{$row->client->displayName()}}</td>
                         <td>
                         <td>
-                            @foreach($row->reasons as $reason)
+                            @foreach($row->reasons() as $reason)
                                 <span class="pr-2">{{$reason->code}}</span>
                                 <span class="pr-2">{{$reason->code}}</span>
                             @endforeach
                             @endforeach
-                            @if(!$row->reasons || !count($row->reasons))
+                            @if(!$row->reasons() || !count($row->reasons()))
                                 -
                                 -
                             @endif
                             @endif
                         </td>
                         </td>

+ 2 - 2
resources/views/app/mcp/notes_rejected_summary_suggestion.blade.php

@@ -28,10 +28,10 @@
                         </td>
                         </td>
                         <td>{{$row->client->displayName()}}</td>
                         <td>{{$row->client->displayName()}}</td>
                         <td>
                         <td>
-                            @foreach($row->reasons as $reason)
+                            @foreach($row->reasons() as $reason)
                                 <span class="pr-2">{{$reason->code}}</span>
                                 <span class="pr-2">{{$reason->code}}</span>
                             @endforeach
                             @endforeach
-                            @if(!$row->reasons || !count($row->reasons))
+                            @if(!$row->reasons() || !count($row->reasons()))
                                 -
                                 -
                             @endif
                             @endif
                         </td>
                         </td>

+ 10 - 10
resources/views/app/mcp/patients-table.blade.php

@@ -3,21 +3,21 @@
 		<thead class="bg-light">
 		<thead class="bg-light">
 			<tr>
 			<tr>
 				<th class="border-0">#</th>
 				<th class="border-0">#</th>
-				<th class="border-0">Name</th>
-				<th class="border-0">DOB</th>
-				<th class="border-0">Age</th>
-				<th class="border-0">Sex</th>
+				<th class="border-0">@include('app.practice-management._sort_header', ['route' => route("mcp.patients"), 'label' => 'Name', 'key' => 'name_first'])</th>
+				<th class="border-0">@include('app.practice-management._sort_header', ['route' => route("mcp.patients"), 'label' => 'DOB', 'key' => 'dob'])</th>
+				<th class="border-0">@include('app.practice-management._sort_header', ['route' => route("mcp.patients"), 'label' => 'Age', 'key' => 'age_in_years'])</th>
+				<th class="border-0">@include('app.practice-management._sort_header', ['route' => route("mcp.patients"), 'label' => 'Sex', 'key' => 'sex'])</th>
 				<th class="border-0">Insurance</th>
 				<th class="border-0">Insurance</th>
-				<th class="border-0">Last Visit</th>
+				<th class="border-0">@include('app.practice-management._sort_header', ['route' => route("mcp.patients"), 'label' => 'Last Visit', 'key' => 'most_recent_completed_mcp_note_date'])</th>
 				<th class="border-0">Next Appt.</th>
 				<th class="border-0">Next Appt.</th>
 				<th class="border-0">Status</th>
 				<th class="border-0">Status</th>
 
 
 				<th class="border-0">BP</th>
 				<th class="border-0">BP</th>
-				<th class="border-0"> <i class="fa fa-heartbeat"></i> </th>
-				<th class="border-0">Pulse</th>
-				<th class="border-0">BP/Pulse Timestamp</th>
-				<th class="border-0">Weight</th>
-				<th class="border-0">Weight Timestamp</th>
+				<th class="border-0"> <i class="fa fa-heartbeat"></i> @include('app.practice-management._sort_header', ['route' => route("mcp.patients"), 'label' => '', 'key' => 'most_recent_cellular_bp_value_irregular'])</th>
+				<th class="border-0">@include('app.practice-management._sort_header', ['route' => route("mcp.patients"), 'label' => 'Pulse', 'key' => 'most_recent_cellular_bp_value_pulse'])</th>
+				<th class="border-0">@include('app.practice-management._sort_header', ['route' => route("mcp.patients"), 'label' => 'BP/Pulse Timestamp', 'key' => 'most_recent_cellular_bp_measurement_at'])</th>
+				<th class="border-0">@include('app.practice-management._sort_header', ['route' => route("mcp.patients"), 'label' => 'Weight', 'key' => 'most_recent_cellular_weight_value'])</th>
+				<th class="border-0">@include('app.practice-management._sort_header', ['route' => route("mcp.patients"), 'label' => 'Weight Timestamp', 'key' => 'most_recent_cellular_weight_measurement_at'])</th>
 
 
 				{{-- <th>Scale <i class="fa fa-battery"></i></th>--}}
 				{{-- <th>Scale <i class="fa fa-battery"></i></th>--}}
 				{{-- <th class="border-0">RPM</th>--}}
 				{{-- <th class="border-0">RPM</th>--}}

+ 1 - 1
resources/views/app/patient/allergies-center.blade.php

@@ -60,7 +60,7 @@ if(!@$summaryView) {
             <thead>
             <thead>
             <tr class="">
             <tr class="">
                 @if($patient->core_note_id !== $note->id)
                 @if($patient->core_note_id !== $note->id)
-                    <th class="border-bottom-0 text-secondary text-center width-30px">Rel.</th>
+                    <th class="border-bottom-0 text-secondary text-center width-30px text-nowrap">Rel.</th>
                 @endif
                 @endif
                 <th class="border-bottom-0 text-secondary">Name</th>
                 <th class="border-bottom-0 text-secondary">Name</th>
                 <th class="border-bottom-0 text-secondary w-30">Subjective</th>
                 <th class="border-bottom-0 text-secondary w-30">Subjective</th>

+ 1 - 1
resources/views/app/patient/canvas-sections/vitals/form.blade.php

@@ -114,7 +114,7 @@ $formID = rand(0, 100000);
                                data-field="value" v-model="bmi">
                                data-field="value" v-model="bmi">
                         <p class="py-1 m-0 px-2 font-weight-bold bg-white" v-if="!!bmi">
                         <p class="py-1 m-0 px-2 font-weight-bold bg-white" v-if="!!bmi">
                             <span class="text-sm text-warning-mellow" v-if="+bmi < 18.5">Underweight</span>
                             <span class="text-sm text-warning-mellow" v-if="+bmi < 18.5">Underweight</span>
-                            <span class="text-sm text-success" v-if="+bmi >= 18.5 && +bmi < 25">Healthy Weight</span>
+                            <!--<span class="text-sm text-success" v-if="+bmi >= 18.5 && +bmi < 25">Healthy Weight</span>-->
                             <span class="text-sm text-warning-mellow" v-if="+bmi >= 25 && +bmi < 30">Overweight</span>
                             <span class="text-sm text-warning-mellow" v-if="+bmi >= 25 && +bmi < 30">Overweight</span>
                             <span class="text-sm text-warning-mellow" v-if="+bmi >= 30">Obese</span>
                             <span class="text-sm text-warning-mellow" v-if="+bmi >= 30">Obese</span>
                         </p>
                         </p>

+ 1 - 1
resources/views/app/patient/canvas-sections/vitals/summary.php

@@ -112,7 +112,7 @@ foreach ($vitalLabels as $k => $v) {
                         <span class="text-sm text-warning-mellow">(Underweight)</span>
                         <span class="text-sm text-warning-mellow">(Underweight)</span>
                     <?php endif; ?>
                     <?php endif; ?>
                     <?php if($bmi >= 18.5 && $bmi < 25): ?>
                     <?php if($bmi >= 18.5 && $bmi < 25): ?>
-                        <span class="text-sm text-success">(Healthy Weight)</span>
+                        <!--<span class="text-sm text-success">(Healthy Weight)</span>-->
                     <?php endif; ?>
                     <?php endif; ?>
                     <?php if($bmi >= 25 && $bmi < 30): ?>
                     <?php if($bmi >= 25 && $bmi < 30): ?>
                         <span class="text-sm text-warning-mellow">(Overweight)</span>
                         <span class="text-sm text-warning-mellow">(Overweight)</span>

+ 3 - 1
resources/views/app/patient/care-month/_create-claim.blade.php

@@ -236,8 +236,10 @@
             }
             }
         },
         },
         mounted: function () {
         mounted: function () {
-            this.initICDAutoSuggest();
             this.getPrefillValues();
             this.getPrefillValues();
+            Vue.nextTick(() => {
+                this.initICDAutoSuggest();
+            });
         }
         }
     });
     });
 </script>
 </script>

+ 9 - 7
resources/views/app/patient/care-month/_matrix.blade.php

@@ -178,13 +178,15 @@ foreach ($days as $k => $day) {
             @if($mIndex === 0)
             @if($mIndex === 0)
                 <td rowspan="{{count($days[$k])}}" class="px-2">
                 <td rowspan="{{count($days[$k])}}" class="px-2">
                     @if($performerRole === 'ADMIN')
                     @if($performerRole === 'ADMIN')
-                        <div class="my-1">
-                            <span class="text-secondary">MCP Unstamped:</span>
-                            <b class="{{count($unstampedMCP[$k]) ? '' : 'text-secondary font-weight-normal'}}">{{count($unstampedMCP[$k])}}</b>
-                        </div>
-                        <div class="">
-                            <span class="text-secondary">Non-HCP Unstamped:</span>
-                            <b class="{{count($unstampedNonHCP[$k]) ? '' : 'text-secondary font-weight-normal'}}">{{count($unstampedNonHCP[$k])}}</b>
+                        <div class="d-flex align-items-center flex-wrap">
+                            <div class="mr-2">
+                                <span class="text-secondary">MCP Unstamped:</span>
+                                <b class="{{count($unstampedMCP[$k]) ? '' : 'text-secondary font-weight-normal'}}">{{count($unstampedMCP[$k])}}</b>
+                            </div>
+                            <div class="">
+                                <span class="text-secondary">Non-HCP Unstamped:</span>
+                                <b class="{{count($unstampedNonHCP[$k]) ? '' : 'text-secondary font-weight-normal'}}">{{count($unstampedNonHCP[$k])}}</b>
+                            </div>
                         </div>
                         </div>
                     @elseif($performerRole === 'MCP')
                     @elseif($performerRole === 'MCP')
                         @if(count($unstampedMCP[$k]))
                         @if(count($unstampedMCP[$k]))

+ 9 - 7
resources/views/app/patient/care-month/_work_matrix.blade.php

@@ -202,13 +202,15 @@ $days = $daysWithUnstamped;
                 @if($mIndex === 0)
                 @if($mIndex === 0)
                     <td rowspan="{{count($days[$k])}}" class="px-2">
                     <td rowspan="{{count($days[$k])}}" class="px-2">
                         @if($performerRole === 'ADMIN')
                         @if($performerRole === 'ADMIN')
-                            <div class="my-1">
-                                <span class="text-secondary">MCP Unstamped:</span>
-                                <b class="{{count($unstampedMCP[$k]) ? '' : 'text-secondary font-weight-normal'}}">{{count($unstampedMCP[$k])}}</b>
-                            </div>
-                            <div class="">
-                                <span class="text-secondary">RMM Unstamped:</span>
-                                <b class="{{count($unstampedRMM[$k]) ? '' : 'text-secondary font-weight-normal'}}">{{count($unstampedRMM[$k])}}</b>
+                            <div class="d-flex align-items-center flex-wrap">
+                                <div>
+                                    <span class="text-secondary">MCP Unstamped:</span>
+                                    <b class="{{count($unstampedMCP[$k]) ? '' : 'text-secondary font-weight-normal'}}">{{count($unstampedMCP[$k])}}</b>
+                                </div>
+                                <div class="">
+                                    <span class="text-secondary">RMM Unstamped:</span>
+                                    <b class="{{count($unstampedRMM[$k]) ? '' : 'text-secondary font-weight-normal'}}">{{count($unstampedRMM[$k])}}</b>
+                                </div>
                             </div>
                             </div>
                             <div class="text-sm text-secondary">Only the MCP or RMM can stamp-all!</div>
                             <div class="text-sm text-secondary">Only the MCP or RMM can stamp-all!</div>
                         @elseif($performerRole === 'MCP')
                         @elseif($performerRole === 'MCP')

+ 80 - 0
resources/views/app/patient/care-month/care-month-update-mcp-onboarding-visit-info.blade.php

@@ -0,0 +1,80 @@
+<div moe>
+	<a start show>Update</a>
+	<form url="/api/client/updateMcpOnboardingVisitInfo" class="mcp-theme-1">
+		<input type="hidden" name="uid" value="{{$patient->uid}}">
+		<div id="updateMcpOnboardingVisit" v-cloak>
+		<div class="mb-2">
+			<select name="hasMcpDoneOnboardingVisit" class="form-control form-control-sm" onchange="toggleDisabledAsNeeded(this, 'YES', 'if-visit-done')"  v-model="form.hasMcpDoneOnboardingVisit">
+				<option value="">-- Select Status --</option>
+				<option value="YES" {{ $patient->has_mcp_done_onboarding_visit === 'YES' ? 'selected' : '' }}>YES</option>
+				<option value="NO" {{ $patient->has_mcp_done_onboarding_visit === 'NO' ? 'selected' : '' }}>NO</option>
+				<option value="UNKNOWN" {{ $patient->has_mcp_done_onboarding_visit === 'UNKNOWN' ? 'selected' : '' }}>UNKNOWN</option>
+			</select>
+		</div>
+		<div class="mb-2">
+			<input type="date" class="if-visit-done form-control form-control-sm" disabled name="mcpOnboardingVisitDate" max="{{ date('Y-m-d') }}">
+		</div>
+		<div class="mb-2">
+			<select name="mcpOnboardingVisitNoteUid" disabled class="form-control form-control-sm if-visit-done" onchange="toggleVisibilityAsNeeded(this, '', 'if-note-outside-system')">
+				<option value="">-- Visit Note --</option>
+				<?php $notes = \App\Models\Note::where('client_id', $patient->id)->get() ?>
+				@foreach ($notes as $note)
+				@if(!empty($note->title) && $note->client_id === $patient->id && !$note->is_cancelled)
+				<option value="{{$note->uid}}">{{$note->hcpPro->displayName()}} ({{friendly_date_time($note->effective_dateest, false)}})</option>
+				@endif
+				@endforeach
+			</select>
+		</div>
+		<div class="mb-2 if-note-outside-system">
+			<textarea class="form-control form-control-sm" name="reasonOnboardingVisitNoteOutsideSystem" placeholder="Visit note outside the system reason"></textarea>
+		</div>
+		</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>
+
+
+<script>
+	var updateMcpOnboardingVisit = new Vue({
+		el:'#updateMcpOnboardingVisit',
+		data:{
+			form:{
+				hasMcpDoneOnboardingVisit: '{{ $patient->has_mcp_done_onboarding_visit }}'
+			},
+			showEnterInfoAlert: false
+		},
+		methods:{
+			initValidation: function(){
+				var self= this;
+				var fields = $('[name=mcpOnboardingVisitNoteUid], [name=reasonOnboardingVisitNoteOutsideSystem]');
+				if(self.form.hasMcpDoneOnboardingVisit == 'YES'){					
+					fields.prop('required', true);
+					fields.on('change keyup', function(){
+						fields.prop('required', false);
+						$(this).prop('required', true);
+					});
+					self.showEnterInfoAlert = true;
+				}else{
+					fields.prop('required', false);
+					self.showEnterInfoAlert = false;
+				}
+			},
+			init: function(){
+				this.initValidation();
+			}
+		},
+		mounted: function(){
+			this.init();
+		},
+		updated: function(){
+			var self = this;
+
+			self.$nextTick(function(){
+				self.initValidation();
+			});
+		}
+	});
+</script>

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

@@ -46,47 +46,7 @@
                             <i class="fa fa-exclamation-triangle"></i>
                             <i class="fa fa-exclamation-triangle"></i>
                             MCP Onboarding Visit Pending
                             MCP Onboarding Visit Pending
                         </span>
                         </span>
-                        <div moe>
-                            <a start show>Update</a>
-                            <form url="/api/client/updateMcpOnboardingVisitInfo" class="mcp-theme-1">
-                                <input type="hidden" name="uid" value="{{$patient->uid}}">
-                                <div class="mb-2">
-                                    <select name="hasMcpDoneOnboardingVisit"
-                                            class="form-control form-control-sm"
-                                            onchange="toggleDisabledAsNeeded(this, 'YES', 'if-visit-done')">
-                                        <option value="">-- Select Status --</option>
-                                        <option value="YES" {{ $patient->has_mcp_done_onboarding_visit === 'YES' ? 'selected' : '' }}>YES</option>
-                                        <option value="NO" {{ $patient->has_mcp_done_onboarding_visit === 'NO' ? 'selected' : '' }}>NO</option>
-                                        <option value="UNKNOWN" {{ $patient->has_mcp_done_onboarding_visit === 'UNKNOWN' ? 'selected' : '' }}>UNKNOWN</option>
-                                    </select>
-                                </div>
-                                <div class="mb-2">
-                                    <input type="date" class="if-visit-done form-control form-control-sm" disabled name="mcpOnboardingVisitDate" max="{{ date('Y-m-d') }}">
-                                </div>
-                                <div class="mb-2">
-                                    <select name="mcpOnboardingVisitNoteUid" disabled
-                                            class="form-control form-control-sm if-visit-done"
-                                            onchange="toggleVisibilityAsNeeded(this, '', 'if-note-outside-system')">
-                                        <option value="">-- Visit Note --</option>
-                                        <?php $notes = \App\Models\Note::where('client_id', $patient->id)->get() ?>
-                                        @foreach ($notes as $note)
-                                            @if(!empty($note->title) && $note->client_id === $patient->id && !$note->is_cancelled)
-                                                <option value="{{$note->uid}}">{{$note->hcpPro->displayName()}} ({{friendly_date_time($note->effective_dateest, false)}})</option>
-                                            @endif
-                                        @endforeach
-                                    </select>
-                                </div>
-                                <div class="mb-2 if-note-outside-system">
-                                    <textarea class="form-control form-control-sm"
-                                              name="reasonOnboardingVisitNoteOutsideSystem"
-                                              placeholder="Visit note outside the system reason"></textarea>
-                                </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>
+                        @include('app.patient.care-month.care-month-update-mcp-onboarding-visit-info')
                     </div>
                     </div>
                 </div>
                 </div>
             </h6>
             </h6>
@@ -299,10 +259,16 @@
                                         </div>
                                         </div>
                                     @endif
                                     @endif
                                 </div>
                                 </div>
-                                @if($careMonth->number_of_days_with_remote_measurements < 16)
-                                    <div class="alert alert-warning p-2 mt-1">
-                                        Need <b>{{16 - $careMonth->number_of_days_with_remote_measurements}} more days</b> with measurements before RM becomes billable.
-                                    </div>
+                                @if($careMonth->showMeasurementDaysWarning())
+                                    <?php
+                                    $moreDays = 16 - $careMonth->number_of_days_with_remote_measurements;
+                                    if($moreDays < 0) $moreDays = 0;
+                                    ?>
+                                    @if($moreDays > 0)
+                                        <div class="alert alert-warning p-2 mt-1">
+                                            Need <b>{{$moreDays}} more day{{$moreDays !== 1 ? 's' : ''}}</b> with measurements before RM becomes billable.
+                                        </div>
+                                    @endif
                                 @endif
                                 @endif
 
 
                                 <div class="mt-2">
                                 <div class="mt-2">
@@ -376,13 +342,13 @@
                                 </div>
                                 </div>
                                 @endif
                                 @endif
 
 
-                                @if(($daysDiff !== -1 && $daysDiff <= 90) &&
+                                {{--@if(($daysDiff !== -1 && $daysDiff <= 90) &&
                                     $careMonth->number_of_days_with_remote_measurements >= 16 &&
                                     $careMonth->number_of_days_with_remote_measurements >= 16 &&
                                     $careMonth->has_mcp_interacted_with_client_about_rm)
                                     $careMonth->has_mcp_interacted_with_client_about_rm)
                                     <div class="mt-2 border border-info p-2">
                                     <div class="mt-2 border border-info p-2">
                                         @include('app.rm-bills.inline', ['patient' => $patient, 'entityType' => 'CareMonth', 'entityUid' => $careMonth->uid, 'label' => 'RM'])
                                         @include('app.rm-bills.inline', ['patient' => $patient, 'entityType' => 'CareMonth', 'entityUid' => $careMonth->uid, 'label' => 'RM'])
                                     </div>
                                     </div>
-                                @endif
+                                @endif--}}
 
 
                                 <div class="mt-2">
                                 <div class="mt-2">
                                     {{-- rm reasons --}}
                                     {{-- rm reasons --}}
@@ -1014,11 +980,10 @@
                             <table class="table table-sm tabe-striped mb-0 table-bordered">
                             <table class="table table-sm tabe-striped mb-0 table-bordered">
                                 <thead class="bg-light">
                                 <thead class="bg-light">
                                 <tr class="text-secondary">
                                 <tr class="text-secondary">
-                                    <?php /* <th class="border-bottom-0"></th> */ ?>
                                     <th class="border-bottom-0">Date</th>
                                     <th class="border-bottom-0">Date</th>
                                     <th class="border-bottom-0">Service</th>
                                     <th class="border-bottom-0">Service</th>
                                     <th class="border-bottom-0">Billable</th>
                                     <th class="border-bottom-0">Billable</th>
-                                    <th class="border-bottom-0">HCP</th>
+                                    <th class="border-bottom-0">Pro</th>
                                     <th class="border-bottom-0">Total</th>
                                     <th class="border-bottom-0">Total</th>
                                     <th class="border-bottom-0">Sign</th>
                                     <th class="border-bottom-0">Sign</th>
                                     <th class="border-bottom-0">Bal Post Date</th>
                                     <th class="border-bottom-0">Bal Post Date</th>
@@ -1030,26 +995,7 @@
                                 <tbody>
                                 <tbody>
                                 @foreach ($careMonth->bills as $bill)
                                 @foreach ($careMonth->bills as $bill)
                                     <tr class="{{$bill->is_cancelled ? 'bg-light text-secondary' : ''}}">
                                     <tr class="{{$bill->is_cancelled ? 'bg-light text-secondary' : ''}}">
-                                        <?php /* <td class="p-0">
-                                            <table class="table-striped table-sm table-condensed border border-left-0 border-top-0 border-bottom-0">
-                                                <tbody>
-                                                    <tr><td>collected_amount</td><td>{{$bill->collected_amount}}</td></tr>
-                                                    <tr><td>effective_date</td><td>{{$bill->effective_date}}</td></tr>
-                                                    <tr><td>has_hcp_been_paid</td><td>{{$bill->has_hcp_been_paid}}</td></tr>
-                                                    <tr><td>hcp_expected_payment_amount</td><td>{{$bill->hcp_expected_payment_amount}}</td></tr>
-                                                    <tr><td>hcp_payment_amount</td><td>{{$bill->hcp_payment_amount}}</td></tr>
-                                                    <tr><td>is_cancelled</td><td>{{$bill->is_cancelled}}</td></tr>
-                                                    <tr><td>hcp_payment_pro_transaction_id</td><td>{{$bill->hcp_payment_pro_transaction_id}}</td></tr>
-                                                    <tr><td>balance_post_date</td><td>{{$bill->balance_post_date}}</td></tr>
-                                                    <tr><td>is_verified</td><td>{{$bill->is_verified}}</td></tr>
-                                                    <tr><td>is_cancellation_acknowledged</td><td>{{$bill->is_cancellation_acknowledged}}</td></tr>
-                                                    <tr><td>is_cancelled_by_administrator</td><td>{{$bill->is_cancelled_by_administrator}}</td></tr>
-                                                    <tr><td>total_expected</td><td>{{$bill->total_expected}}</td></tr>
-                                                    <tr><td>total_paid</td><td>{{$bill->total_paid}}</td></tr>
-                                                </tbody>
-                                            </table>
-                                        </td> */ ?>
-                                        <td class="text-nowrap">{{friendlier_date_time($bill->effective_date, false)}}</td>
+                                        <td class="text-nowrap">{{friendlier_date_time($bill->careMonth->end_date, false)}}</td>
                                         <td>{{$bill->code}} {{$bill->cm_or_rm}} {{$bill->is_cancelled}}</td>
                                         <td>{{$bill->code}} {{$bill->cm_or_rm}} {{$bill->is_cancelled}}</td>
                                         <td class="">
                                         <td class="">
                                             @if(strpos(strtolower($bill->code), 'treatment services') !== FALSE)
                                             @if(strpos(strtolower($bill->code), 'treatment services') !== FALSE)
@@ -1075,42 +1021,22 @@
                                             @endif
                                             @endif
                                         </td>
                                         </td>
                                         <td class="">
                                         <td class="">
-                                            <div class="text-nowrap font-weight-bold text-secondary">{{ $bill->hcp->displayName() }} (HCP)</div>
+                                            <div class="text-nowrap font-weight-bold text-secondary">{{ $bill->genericPro ? $bill->genericPro->displayName() : '' }} (HCP)</div>
                                             <div class="text-nowrap mt-1">
                                             <div class="text-nowrap mt-1">
                                                 <span class="text-secondary">Paid: </span>
                                                 <span class="text-secondary">Paid: </span>
-                                                <span>{{ $bill->has_hcp_been_paid ? 'Yes' : 'No' }}</span>
+                                                <span>{{ $bill->has_generic_pro_been_paid ? 'Yes' : 'No' }}</span>
                                             </div>
                                             </div>
                                             @if(!$bill->has_hcp_been_paid)
                                             @if(!$bill->has_hcp_been_paid)
                                                 <div class="text-nowrap mt-1">
                                                 <div class="text-nowrap mt-1">
                                                     <span class="text-secondary">Expected: </span>
                                                     <span class="text-secondary">Expected: </span>
-                                                    <span class="font-weight-bold">${{ $bill->hcp_expected_payment_amount }}</span>
+                                                    <span class="font-weight-bold">${{ $bill->generic_pro_expected_payment_amount }}</span>
                                                 </div>
                                                 </div>
                                             @else
                                             @else
                                                 <div class="text-nowrap mt-1">
                                                 <div class="text-nowrap mt-1">
                                                     <span class="text-secondary">Amount: </span>
                                                     <span class="text-secondary">Amount: </span>
-                                                    <span class="font-weight-bold">${{ $bill->hcp_payment_amount }}</span>
-                                                </div>
-                                            @endif
-                                            @if($bill->ally)
-                                                <hr>
-                                                <div class="text-nowrap font-weight-bold text-secondary">{{ $bill->ally->displayName() }} (NA)</div>
-                                                <div class="text-nowrap mt-1">
-                                                    <span class="text-secondary">Paid: </span>
-                                                    <span>{{ $bill->has_na_been_paid ? 'Yes' : 'No' }}</span>
+                                                    <span class="font-weight-bold">${{ $bill->generic_pro_payment_amount }}</span>
                                                 </div>
                                                 </div>
-                                                @if(!$bill->has_na_been_paid)
-                                                    <div class="text-nowrap mt-1">
-                                                        <span class="text-secondary">Expected: </span>
-                                                        <span class="font-weight-bold">${{ $bill->na_expected_payment_amount }}</span>
-                                                    </div>
-                                                @else
-                                                    <div class="text-nowrap mt-1">
-                                                        <span class="text-secondary">Amount: </span>
-                                                        <span class="font-weight-bold">${{ $bill->na_payment_amount }}</span>
-                                                    </div>
-                                                @endif
                                             @endif
                                             @endif
-
                                         </td>
                                         </td>
                                         <td class="pr-3">
                                         <td class="pr-3">
                                             @if($bill->has_hcp_been_paid)
                                             @if($bill->has_hcp_been_paid)
@@ -1123,19 +1049,19 @@
                                         </td>
                                         </td>
                                         <td>
                                         <td>
                                             @if(!$bill->is_cancelled)
                                             @if(!$bill->is_cancelled)
-                                                @if($bill->is_signed_by_hcp)
+                                                @if($bill->is_signed_by_generic_pro)
                                                     <span class="d-block text-secondary text-nowrap">
                                                     <span class="d-block text-secondary text-nowrap">
                                                             <i class="fa fa-check"></i>
                                                             <i class="fa fa-check"></i>
-                                                            HCP Signed
+                                                            Pro Signed
                                                         </span>
                                                         </span>
                                                 @else
                                                 @else
                                                     <span moe
                                                     <span moe
                                                           class="d-block {{ $bill->hcp_pro_id !== $pro->id && $pro->pro_type !== 'ADMIN' ? 'moe-disabled' : '' }}"
                                                           class="d-block {{ $bill->hcp_pro_id !== $pro->id && $pro->pro_type !== 'ADMIN' ? 'moe-disabled' : '' }}"
-                                                          title="{{ $bill->hcp_pro_id !== $pro->id  && $pro->pro_type !== 'ADMIN' ? 'Only the bill\'s HCP can sign' : '' }}">
+                                                          title="{{ $bill->hcp_pro_id !== $pro->id  && $pro->pro_type !== 'ADMIN' ? 'Only the bill\'s Pro can sign' : '' }}">
                                                         <a class="" href="" show start>Sign As HCP</a>
                                                         <a class="" href="" show start>Sign As HCP</a>
-                                                        <form url="/api/bill/signAsHcp">
+                                                        <form url="/api/bill/signAsGenericPro">
                                                             <input type="hidden" name="uid" value="{{$bill->uid}}">
                                                             <input type="hidden" name="uid" value="{{$bill->uid}}">
-                                                            <p>Sign this bill as HCP?</p>
+                                                            <p>Sign this bill?</p>
                                                             <div class="mb-0">
                                                             <div class="mb-0">
                                                                 <button class="btn btn-success btn-sm" submit>Sign</button>
                                                                 <button class="btn btn-success btn-sm" submit>Sign</button>
                                                                 <button class="btn btn-default border btn-sm" cancel>Cancel</button>
                                                                 <button class="btn btn-default border btn-sm" cancel>Cancel</button>
@@ -1444,6 +1370,7 @@
                     <div class="">
                     <div class="">
                         <div class="d-flex align-items-center mb-2">
                         <div class="d-flex align-items-center mb-2">
                             <p class="font-weight-bold m-0">Claims</p>
                             <p class="font-weight-bold m-0">Claims</p>
+                            @include('app.patient.care-month.refresh-suggestions-json')
                             @include('app/patient/care-month/_create-claim')
                             @include('app/patient/care-month/_create-claim')
                             <div class="ml-auto">
                             <div class="ml-auto">
                                 <select class="form-control form-control-sm"
                                 <select class="form-control form-control-sm"
@@ -1802,6 +1729,7 @@
                 @else
                 @else
                     <div class="d-flex">
                     <div class="d-flex">
                         <p class="font-weight-bold mb-0">No claims in this care month</p>
                         <p class="font-weight-bold mb-0">No claims in this care month</p>
+                        @include('app.patient.care-month.refresh-suggestions-json')
                         @include('app/patient/care-month/_create-claim')
                         @include('app/patient/care-month/_create-claim')
                     </div>
                     </div>
                 @endif
                 @endif
@@ -1864,10 +1792,10 @@
 
 
         <hr class="m-negator my-3">
         <hr class="m-negator my-3">
 
 
-        {{-- generic bills --}}
+        {{-- generic bills --}}{{--
         <div class="row">
         <div class="row">
             @include('app.generic-bills.inline', ['patient' => $patient, 'class' => 'col-12', 'entityType' => 'CareMonth', 'entityUid' => $careMonth->uid])
             @include('app.generic-bills.inline', ['patient' => $patient, 'class' => 'col-12', 'entityType' => 'CareMonth', 'entityUid' => $careMonth->uid])
-        </div>
+        </div>--}}
 
 
     </div>
     </div>
 
 

+ 0 - 59
resources/views/app/patient/care-month/put-rm-reasons.blade.php

@@ -1,59 +0,0 @@
-<div moe relative>
-	<a start show><i class="fas fa-edit"></i></a>
-	<form url="/api/careMonth/putRmReasons" class="mcp-theme-1" right>
-		<input type="hidden" name="uid" value="{{$careMonth->uid}}">
-		<div>
-			<table class="table table-sm table-bordered">
-				<thead class="bg-light">
-					<tr>
-						<th class="border-bottom-0">ICD</th>
-						<th class="border-bottom-0">Description</th>
-					</tr>
-				</thead>
-				<tbody>
-					<tr>
-						<td>
-							<input type="text" class="icd-input" icd-autocomplete-code data-target="input[name=rmReasonIcd1Description]" name="rmReasonIcd1" value="{{ $careMonth->rm_reason_icd1 }}" placeholder="ICD 1" />
-						</td>
-						<td>
-							<input id="" type="text" class="form-control form-control-sm" icd-autocomplete-description name="rmReasonIcd1Description" value="{{ $careMonth->rm_reason_icd1description }}">
-						</td>
-					</tr>
-					<tr>
-						<td>
-							<input type="text" class="icd-input" icd-autocomplete-code name="rmReasonIcd2" data-target="input[name=rmReasonIcd2Description]" value="{{ $careMonth->rm_reason_icd2 }}" placeholder="ICD 2" />
-						</td>
-						<td>
-							<input type="text" class="form-control form-control-sm" icd-autocomplete-description name="rmReasonIcd2Description" value="{{ $careMonth->rm_reason_icd2description }}">
-						</td>
-					</tr>
-					<tr>
-						<td>
-							<input type="text" class="icd-input" icd-autocomplete-code name="rmReasonIcd3" data-target="input[name=rmReasonIcd3Description]" value="{{ $careMonth->rm_reason_icd3 }}" placeholder="ICD 3" />
-						</td>
-						<td>
-							<input type="text" class="form-control form-control-sm" icd-autocomplete-description name="rmReasonIcd3Description" value="{{ $careMonth->rm_reason_icd3description }}" >
-						</td>
-					</tr>
-					<tr>
-						<td>
-							<input type="text" class="icd-input" icd-autocomplete-code name="rmReasonIcd4" data-target="input[name=rmReasonIcd4Description]" value="{{ $careMonth->rm_reason_icd4 }}" placeholder="ICD 4"/>
-						</td>
-						<td>
-							<input type="text" class="form-control form-control-sm" icd-autocomplete-description name="rmReasonIcd4Description" value="{{ $careMonth->rm_reason_icd4description }}">
-						</td>
-					</tr>
-				</tbody>
-			</table>
-		</div>
-
-		<div class="mb-3">
-			<label class="font-weight-bold">RM Reason Memo</label>
-			<input type="text" class="form-control form-control-sm" name="rmReasonMemo" value="{{ $careMonth->rm_reason_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>

+ 17 - 0
resources/views/app/patient/care-month/refresh-suggestions-json.blade.php

@@ -0,0 +1,17 @@
+@if($pro->pro_type === 'ADMIN')
+<div class="d-flex align-items-center">
+    <span class="d-block ml-2" moe>
+        <a class="text-primary" href="" show start><i class="fas fa-sync" title="Refresh suggestions"></i></a>
+        <form url="api/careMonth/refreshSuggestionJson">
+            <input type="hidden" name="uid" value="{{$careMonth->uid}}">
+            <div class="form-group">
+                <label>Refresh suggestion?</label>
+            </div>
+            <div class="mb-0">
+                <button class="btn btn-success btn-sm" submit>Submit</button>
+                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+            </div>
+        </form>
+    </span>
+</div>
+@endif

+ 3 - 46
resources/views/app/patient/care-month/rm-reasons.blade.php

@@ -1,50 +1,7 @@
 <div class="d-flex align-items-center mb-1">
 <div class="d-flex align-items-center mb-1">
     <span class="mr-2">RM Reasons:</span>
     <span class="mr-2">RM Reasons:</span>
-    @include('app.patient.care-month.put-rm-reasons')
+    @include('app.patient.partials.put-rm-reasons', ['recordType' => 'CARE_MONTH', 'record' => $careMonth])
 </div>
 </div>
-<div class="">
-    <table class="table table-sm table-striped table-bordered">
-        <tbody>
-            <tr>
-                <td class="text-nowrap">ICD 1</td>
-                <td>
-                    <div class="d-flex">
-                        <span class="font-weight-bold text-sm mr-2" style="min-width:60px;">{{ $careMonth->rm_reason_icd1 ? $careMonth->rm_reason_icd1 . ':' : '' }}</span>
-                        <small class="text-muted text-sm">{{ $careMonth->rm_reason_icd1description }}</small>
-                    </div>
-                </td>
-            </tr>
-            <tr>
-                <td class="text-nowrap">ICD 2</td>
-                <td>
-                    <div class="d-flex">
-                        <span class="font-weight-bold text-sm mr-2" style="min-width:60px;">{{ $careMonth->rm_reason_icd2 ? $careMonth->rm_reason_icd2 . ':' :'' }}</span>
-                        <small class="text-muted text-sm">{{ $careMonth->rm_reason_icd2description }}</small>
-                    </div>
-                </td>
-            </tr>
-            <tr>
-                <td class="text-nowrap">ICD 3</td>
-                <td>
-                    <div class="d-flex">
-                        <span class="font-weight-bold text-sm mr-2" style="min-width:60px;">{{ $careMonth->rm_reason_icd3 ? $careMonth->rm_reason_icd3 . ':' : '' }}</span>
-                        <small class="text-muted text-sm">{{ $careMonth->rm_reason_icd3description }}</small>
-                    </div>
-                </td>
-            </tr>
-            <tr>
-                <td class="text-nowrap">ICD 4</td>
-                <td>
-                    <div class="d-flex">
-                        <span class="font-weight-bold text-sm mr-2" style="min-width:60px;">{{ $careMonth->rm_reason_icd4 ? $careMonth->rm_reason_icd4 . ':' : '' }}</span>
-                        <small class="text-muted text-sm">{{ $careMonth->rm_reason_icd4description }}</small>
-                    </div>
-                </td>
-            </tr>
-            <tr>
-                <td class="text-nowrap">Memo</td>
-                <td class="text-muted text-sm">{{ $careMonth->rm_reason_memo }}</td>
-            </tr>
-        </tbody>
-    </table>
+<div class="pl-3">
+    @include('app.patient.partials.rm-reasons-display', ['recordType' => 'CARE_MONTH', 'record' => $careMonth])
 </div>
 </div>

+ 1 - 1
resources/views/app/patient/careteam-center.blade.php

@@ -21,7 +21,7 @@ if(!@$careTeamMembers || !@$counts) {
             <thead>
             <thead>
             <tr class="">
             <tr class="">
                 @if($patient->core_note_id !== $note->id)
                 @if($patient->core_note_id !== $note->id)
-                    <th class="border-bottom-0 text-secondary text-center width-30px">Rel.</th>
+                    <th class="border-bottom-0 text-secondary text-center width-30px text-nowrap">Rel.</th>
                 @endif
                 @endif
                 <th class="border-bottom-0 text-secondary">Name/Details</th>
                 <th class="border-bottom-0 text-secondary">Name/Details</th>
                 <th class="border-bottom-0 text-secondary w-30">Subjective</th>
                 <th class="border-bottom-0 text-secondary w-30">Subjective</th>

+ 2 - 2
resources/views/app/patient/client-primary-coverages.blade.php

@@ -5,8 +5,8 @@
     <div class="mb-3 border rounded bg-light p-2">
     <div class="mb-3 border rounded bg-light p-2">
         <div class="mb-2">
         <div class="mb-2">
             Latest Client Primary Coverage:
             Latest Client Primary Coverage:
-            @if($patient->latestClientPrimaryCoverage)
-                <b>{{$patient->latestClientPrimaryCoverage->plan_type}}</b> (Member ID: {{$patient->latestClientPrimaryCoverage->payer_member_identifier}})
+            @if($patient->getPrimaryCoverage())
+                <b>{{$patient->getPrimaryCoverage()->plan_type}}</b> (Member ID: {{$patient->getPrimaryCoverage()->payer_member_identifier}})
             @else
             @else
                 -
                 -
             @endif
             @endif

+ 193 - 174
resources/views/app/patient/coverage-status.blade.php

@@ -1,205 +1,224 @@
+<?php
+  $coverage = $patient->getPrimaryCoverage();
+?>
+
 <div class="table-responsive">
 <div class="table-responsive">
-    @php
-        $coverage = $patient->latestClientPrimaryCoverage;
-        $mcnDetails = json_decode($patient->mcn_response_detail ?? null);
-    @endphp
-    @if(!$coverage)
-        <table class="table table-sm table-bordered">
+   @if(!$coverage)
+      <table class="table table-sm table-bordered mb-0">
           <tr>
           <tr>
             <td>
             <td>
               <b>No coverage info!</b>
               <b>No coverage info!</b>
             </td>
             </td>
           </tr>
           </tr>
         </table>
         </table>
-    @elseif($coverage->plan_type === 'MEDICARE')
-      @if($coverage->creation_strategy == 'NEW' || $coverage->creation_strategy == 'AUTO_REFRESH')
-      <table class="table table-sm table-bordered">
-        <tr>
-          <td class="font-weight-bold">Medicare Part B<br>(Primary)</td>
-          <td>
-            @if($mcnDetails && $mcnDetails->plan_details)
-            <span class="font-weight-bold">{{ $mcnDetails->plan_details->MC->payer_name }}</span> <br>
-              @if($mcnDetails->plan_details && $mcnDetails->plan_details->MC && $mcnDetails->plan_details->MC->contacts)
-	      @foreach($mcnDetails->plan_details->MC->contacts as $contact)
-                @if($contact->contact_type == 'telephone')
-                  <a href="tel:{{ $contact->contact_value }}"><b><i class="fas fa-phone-alt"></i></b> {{ $contact->contact_value }}</a> <br>
-                @endif
-              @endforeach
-	      @endif
-            @endif
-            @if($coverage->auto_medicare_is_partbprimary == 'YES')
-              <span><i class="fas fa-check-circle text-success"></i> <b>Part B Primary:</b> YES (auto)</span> <br>
-            @elseif(!$coverage->auto_medicare_is_match_found)
-              <span><i class="fas fa-times text-danger"></i> record not found (auto)</span> <br>
-            @else
-              <span><i class="fas fa-check-circle text-success"></i> record found</span> <br>
-              <span><i class="fas fa-times text-danger"></i> <b>Part B Primary:</b> {{$coverage->auto_medicare_is_partbprimary}}</span> <br>
-              <span><b>Part B Active:</b> {{$coverage->auto_medicare_is_partbactive}}</span> <br>
-              <span><b>Part C Active:</b> {{$coverage->auto_medicare_is_partcactive}}</span>
-            @endif
-          </td>
-        </tr>
-        @if($coverage->auto_medicare_is_partbactive == 'YES' && !$coverage->auto_medicare_is_partcactive)
-        <tr>
-          <td class="font-weight-bold">Part B Deductible</td>
-          <td>{{number_format($coverage->auto_medicare_mpb_deductible, 2, '.',',') ?? '-'}}</td>
-        </tr>
-        <tr>
-          <td class="font-weight-bold">Part B Remaining</td>
-          <td>{{number_format($coverage->auto_medicare_mpb_remaining,2, '.',',') ?? '-'}}</td>
-        </tr>
-        @endif
-        @if($coverage->manual_determination_category_memo)
-        <tr>
-          <td><b>Manual Determination Memo: </b></td>
-          <td>{{$coverage->manual_determination_category_memo}}</td>
-        </tr>
-        @endif
-      </table>
-      @else
-      <!-- Manual determination -->
-      <table class="table table-sm table-bordered">
-        <tr>
-          <td class="font-weight-bold">Medicare Part B<br>(Primary)</td>
-          <td>
-            @if($mcnDetails && $mcnDetails->plan_details)
-              <span class="font-weight-bold">{{ $mcnDetails->plan_details->MC->payer_name }}</span> <br>
-              @if($mcnDetails->plan_details->MC->contacts)
-              @foreach($mcnDetails->plan_details->MC->contacts as $contact)
-                @if($contact->contact_type == 'telephone')
-                  <a href="tel:{{ $contact->contact_value }}"><b><i class="fas fa-phone-alt"></i></b> {{ $contact->contact_value }}</a> <br>
-                @endif
-              @endforeach
-              @endif
+  @else
+  <table class="table table-sm table-bordered mb-0">
+    <tr>
+      <td class="border-right-0">
+          <b>{{ $coverage->plan_type }}</b>
+          @if($coverage->is_covered == 'YES')
+            <i class="ml-1 fas fa-check-circle text-success"></i>
+          @else
+          <i class="ml-1 far fa-times-circle text-danger"></i>
+          @endif
+      </td>
+      <td class="border-left-0 text-right">
+        <b>(<i class="ml-1 fas fa-map-pin"></i>
+          @if($coverage->creation_strategy == 'NEW' || $coverage->creation_strategy == 'AUTO_REFRESH')
+          Auto
+          @else
+          Manual
+          @endif)
+        </b>
+      </td>
+    </tr>
+    @if($coverage->plan_type === 'MEDICARE')
+        <!-- Auto -->
+        @if($coverage->creation_strategy == 'NEW' || $coverage->creation_strategy == 'AUTO_REFRESH')
+          <tr>
+            <td class="text-secondary">Matched</td>
+            <td>{{ $coverage->auto_medicare_is_match_found ? 'YES':'NO' }}</td>
+          </tr>
+          <tr class="{{!$coverage->auto_medicare_is_partbactive ? 'd-none' : ''}}">
+            <td class="text-secondary">Part B Active</td>
+            <td>{{ $coverage->auto_medicare_is_partbactive }}</td>
+          </tr>
+          <tr class="{{!$coverage->auto_medicare_is_partbprimary ? 'd-none' : ''}}">
+            <td class="text-secondary">Part B Primary</td>
+            <td>{{ $coverage->auto_medicare_is_partbprimary }}</td>
+          </tr>
+          <tr class="{{!$coverage->auto_medicare_is_partcactive ? 'd-none' : ''}}">
+            <td class="text-secondary">Part C Active</td>
+            <td>{{ $coverage->auto_medicare_is_partcactive }}</td>
+          </tr>
+          @if($coverage->auto_medicare_is_partcactive)
+            <?php   $detailJsonArray = json_decode($coverage->auto_medicare_detail_json, true); ?>
+            @if(isset($detailJsonArray['plan_details']['MC']))
+              <tr>
+                  <td class="text-secondary">MC Payer</td>
+                  <td><span class="coverage-payer-name" title="{{@$detailJsonArray['plan_details']['MC']['payer_name']}}">{{ @$detailJsonArray['plan_details']['MC']['payer_name'] }}</span></td>
+              </tr>
             @endif
             @endif
-
-            @if($coverage->manual_medicare_is_partbprimary == 'YES')
-              <span><i class="fas fa-check-circle text-success"></i> <b>Part B Primary:</b> YES ({{strtolower(implode(' ', explode('_', strtolower(implode(' ', explode('_', $coverage->manual_determination_strategy))))))}})</span> <br>
-            @elseif($coverage->manual_medicare_is_matched == 'NO')
-              <span><i class="fas fa-times text-danger"></i> record not found ({{strtolower(implode(' ', explode('_', $coverage->manual_determination_strategy)))}})</span> <br>
-            @else
-              <span><i class="fas fa-check-circle text-success"></i> record found</span> <br>
-              <span><i class="fas fa-times text-danger"></i> <b>Part B Primary:</b> {{$coverage->manual_medicare_is_partbprimary}}</span> <br>
-              <span><b>Part B Active:</b> {{$coverage->manual_medicare_is_partbactive}}</span> <br>
-              @if($coverage->manual_medicare_is_partcactive)
-              <span><b>Part C Active:</b> {{$coverage->manual_medicare_is_partcactive}}</span>
-              @endif
-              @endif
-          </td>
-        </tr>
-        @if($coverage->auto_medicare_is_partbactive && !$coverage->manual_medicare_is_partcactive)
-        <tr>
-          <td class="font-weight-bold">Part B Deductible</td>
-          <td>{{number_format($coverage->auto_medicare_mpb_deductible,2,'.',',') ?? '-'}}</td>
-        </tr>
-        <tr>
-          <td class="font-weight-bold">Part B Remaining</td>
-          <td>{{number_format($coverage->auto_medicare_mpb_remaining, 2, '.',',') ?? '-'}}</td>
-        </tr>
-        @endif
-        @if($coverage->manual_determination_category_memo)
-        <tr>
-          <td><b>Manual Determination Memo: </b></td>
-          <td>{{$coverage->manual_determination_category_memo}}</td>
-        </tr>
+          @endif
+        @else
+        <!-- Manual -->
+          <tr>
+            <td class="text-secondary">Matched</td>
+            <td>{{ $coverage->manual_medicare_is_matched ?? 'UNKNOWN' }}</td>
+          </tr>
+          <tr>
+            <td class="text-secondary">Category</td>
+            <td>{{ $coverage->manual_determination_category }}</td>
+          </tr>
+          <tr class="{{!$coverage->manual_medicare_is_partbactive ? 'd-none' : ''}}">
+            <td class="text-secondary">Part B Active</td>
+            <td>{{ $coverage->manual_medicare_is_partbactive }}</td>
+          </tr>
+          <tr class="{{!$coverage->manual_medicare_is_partbprimary ? 'd-none' : ''}}">
+            <td class="text-secondary">Part B Primary</td>
+            <td>{{ $coverage->manual_medicare_is_partbprimary }}</td>
+          </tr>
+          <tr class="{{!$coverage->manual_medicare_is_partcactive ? 'd-none' : ''}}">
+            <td class="text-secondary">Part C Active</td>
+            <td>{{ $coverage->manual_medicare_is_partcactive }}</td>
+          </tr>         
+          <tr class="{{!$coverage->manual_medicare_is_msp ? 'd-none' : ''}}">
+            <td class="text-secondary">Msp</td>
+            <td>{{ $coverage->manual_medicare_is_msp }}</td>
+          </tr>
+          <tr class="{{!$coverage->manual_medicare_msp_memo ? 'd-none' : ''}}">
+            <td class="text-secondary">Msp Memo</td>
+            <td>{{ $coverage->manual_medicare_msp_memo }}</td>
+          </tr>
         @endif
         @endif
-      </table>
-      @endif
-
     @elseif($coverage->plan_type === 'MEDICAID')
     @elseif($coverage->plan_type === 'MEDICAID')
-      @if($coverage->creation_strategy == 'NEW' || $coverage->creation_strategy == 'AUTO_REFRESH')
-      <table class="table table-sm table-bordered">
         <tr>
         <tr>
-          <td class="font-weight-bold">Medicaid<br>(Primary):</td>
-          <td>
-            <span><b>{{$coverage->mcdPayer->name ?? '-'}}</b></span> <br>
-            <span><i class="fas fa-hourglass-half text-warning"></i> Pending Validation</span> <br>
-          </td>
+          <td class="text-secondary">Medicaid Payer</td>
+          <td><span class="coverage-payer-name" title="{{$coverage->mcdPayer ? $coverage->mcdPayer->name :'--'}}">{{ $coverage->mcdPayer ? $coverage->mcdPayer->name :'--' }}</span></td>
         </tr>
         </tr>
+        <!-- Auto -->
+        @if($coverage->creation_strategy == 'NEW' || $coverage->creation_strategy == 'AUTO_REFRESH')
+            <tr>
+              <td class="text-secondary">Matched</td>
+              <td>{{ $coverage->auto_medicaid_is_match_found ? 'YES':'NO' }}</td>
+            </tr>
+        @else
+        <!-- Manual -->
+              <tr>
+                <td class="text-secondary">Category</td>
+                <td>{{ $coverage->manual_determination_category }}</td>
+              </tr>
+              <tr>
+                <td class="text-secondary">Matched</td>
+                <td>{{ $coverage->manual_medicare_is_matched }}</td>
+              </tr>
+        @endif
+    @elseif($coverage->plan_type === 'COMMERCIAL')
         <tr>
         <tr>
-          <td class="font-weight-bold">Date Created:</td>
-          <td><span>{{date_format($coverage->created_at, 'm/d/Y')}}</span></td>
+          <td colspan="2"><span>{{ $coverage->payer ? $coverage->payer->name : '--' }}</span></td>
         </tr>
         </tr>
-        @if($coverage->manual_determination_category_memo)
+        @if($coverage->mcdPayer)
         <tr>
         <tr>
-          <td><b>Manual Determination Memo: </b></td>
-          <td>{{$coverage->manual_determination_category_memo}}</td>
+          <td class="text-secondary">Medicaid Payer</td>
+          <td><span class="coverage-payer-name" title="{{$coverage->mcdPayer ? $coverage->mcdPayer->name :'--'}}">{{ $coverage->mcdPayer ? $coverage->mcdPayer->name :'--' }}</span></td>
         </tr>
         </tr>
         @endif
         @endif
-      </table>
-      @else
-        <table class="table table-sm table-bordered">
-          <tr>
-            <td class="font-weight-bold">Medicaid<br>(Primary):</td>
-            <td>
-              <span><b>{{$coverage->mcd_payer_name ?? '-'}}</b></span> <br>
-              @if($coverage->manual_determination_category == 'COVERED')
-              <span><i class="fas fa-check-circle text-success"></i></span>
-              @elseif($coverage->manual_determination_category == 'NOT_COVERED')
-              <span><i class="fas fa-check-circle text-success"></i> record found</span> <br>
-              <span><i class="fas fa-times text-danger"></i> not covered ({{strtolower(implode(' ', explode('_', $coverage->manual_determination_strategy)))}})</span>
-              @elseif($coverage->manual_determination_category == 'INVALID')
-              <span><i class="fas fa-times text-danger"></i> record not found ({{strtolower(implode(' ', explode('_', $coverage->manual_determination_strategy)))}})</span>
-              @else
-              <span><i class="fas fa-hourglass-half text-warning"></i> pending ({{strtolower(implode(' ', explode('_', $coverage->manual_determination_strategy)))}})</span>
-              @endif
-            </td>
-          </tr>
-          @if($coverage->manual_determination_category_memo)
+        <!-- Auto -->
+        @if($coverage->creation_strategy == 'NEW' || $coverage->creation_strategy == 'AUTO_REFRESH')
           <tr>
           <tr>
-            <td><b>Manual Determination Memo: </b></td>
-            <td>{{$coverage->manual_determination_category_memo}}</td>
+            <td class="text-secondary">Commercial Matched</td>
+            <td>{{ $coverage->auto_commercial_is_match_found ? 'YES':'NO' }}</td>
           </tr>
           </tr>
+          @if($coverage->autoCommercialMoreSpecificPayer)
+              <tr>
+                <td colspan="2"><span>{{ $coverage->autoCommercialMoreSpecificPayer->name }}</span></td>
+              </tr>
           @endif
           @endif
-        </table>
-      @endif
-
-    @elseif($coverage->plan_type === 'COMMERCIAL')
-      @if($coverage->creation_strategy == 'NEW' || $coverage->creation_strategy == 'AUTO_REFRESH')
-      <table class="table table-sm table-bordered">
-        <tr>
-          <td class="font-weight-bold">Commercial<br>(Primary):</td>
-          <td>
-            <span><b>{{$coverage->payer->name ?? '-'}}</b></span> <br>
-            <span><i class="fas fa-hourglass-half text-warning"></i> Pending Validation</span> <br>
-          </td>
-        </tr>
+          @if($coverage->mcr_number)
+            <tr>
+              <td class="text-secondary">Medicare Matched</td>
+              <td>{{ $coverage->auto_medicare_is_match_found ? 'YES':'NO' }}</td>
+            </tr>
+            <tr class="{{!$coverage->auto_medicare_is_partbactive ? 'd-none' : ''}}">
+              <td class="text-secondary">Part B Active</td>
+              <td>{{ $coverage->auto_medicare_is_partbactive }}</td>
+            </tr>
+            <tr class="{{!$coverage->auto_medicare_is_partbprimary ? 'd-none' : ''}}">
+              <td class="text-secondary">Part B Primary</td>
+              <td>{{ $coverage->auto_medicare_is_partbprimary }}</td>
+            </tr>
+            <tr class="{{!$coverage->auto_medicare_is_partcactive ? 'd-none' : ''}}">
+              <td class="text-secondary">Part C Active</td>
+              <td>{{ $coverage->auto_medicare_is_partcactive }}</td>
+            </tr>
+            @if($coverage->auto_medicare_is_partcactive)
+              <?php   $detailJsonArray = json_decode($coverage->auto_medicare_detail_json, true); ?>
+              @if(isset($detailJsonArray['plan_details']['MC']))
+                <tr>
+                    <td class="text-secondary">MC Payer Name</td>
+                    <td><span class="coverage-payer-name" title="{{@$detailJsonArray['plan_details']['MC']['payer_name']}}">{{ @$detailJsonArray['plan_details']['MC']['payer_name'] }}</span></td>
+                </tr>
+              @endif
+            @endif
+          @endif
+          @if($coverage->mcdPayer)
+            <tr>
+              <td class="text-secondary">Medicaid Matched</td>
+              <td>{{ $coverage->auto_medicaid_is_match_found ? 'YES':'NO' }}</td>
+            </tr>
+            <tr>
+              <td class="text-secondary">MCD Payer</td>
+              <td><span class="coverage-payer-name" title="{{$coverage->mcdPayer->name}}">{{ $coverage->mcdPayer->name }}</span></td>
+            </tr>
+          @endif
+      @else
+      <!-- Manual -->
         <tr>
         <tr>
-          <td class="font-weight-bold">Date Created:</td>
-          <td><span>{{date_format($coverage->created_at, 'm/d/Y')}}</span></td>
+          <td class="text-secondary">Category</td>
+          <td>{{ $coverage->manual_determination_category }}</td>
         </tr>
         </tr>
-        @if($coverage->manual_determination_category_memo)
         <tr>
         <tr>
-          <td><b>Manual Determination Memo: </b></td>
-          <td>{{$coverage->manual_determination_category_memo}}</td>
+          <td class="text-secondary">Commercial Matched</td>
+          <td>{{ $coverage->manual_commercial_is_matched }}</td>
         </tr>
         </tr>
-        @endif
-      </table>
-      @else
-        <table class="table table-sm table-bordered">
+        @if($coverage->mcr_number)
           <tr>
           <tr>
-            <td class="font-weight-bold">Commercial<br>(Primary):</td>
-            <td>
-              <span><b>{{$coverage->payer->name ?? '-'}}</b></span> <br>
-              @if($coverage->manual_determination_category == 'COVERED')
-              <span><i class="fas fa-check-circle text-success"></i></span>
-              @elseif($coverage->manual_determination_category == 'NOT_COVERED')
-              <span><i class="fas fa-check-circle text-success"></i> record found</span> <br>
-              <span><i class="fas fa-times text-danger"></i> not covered ({{strtolower(implode(' ', explode('_', $coverage->manual_determination_strategy)))}})</span>
-              @elseif($coverage->manual_determination_category == 'INVALID')
-              <span><i class="fas fa-times text-danger"></i> record not found ({{strtolower(implode(' ', explode('_', $coverage->manual_determination_strategy)))}})</span>
-              @else
-              <span><i class="fas fa-hourglass-half text-warning"></i> pending ({{strtolower(implode(' ', explode('_', $coverage->manual_determination_strategy)))}})</span>
-              @endif
-            </td>
+            <td class="text-secondary">Medicare Matched</td>
+            <td>{{ $coverage->manual_medicare_is_matched }}</td>
+          </tr>
+          <tr class="{{!$coverage->manual_medicare_is_partbactive ? 'd-none' : ''}}">
+            <td class="text-secondary">Part B Active</td>
+            <td>{{ $coverage->manual_medicare_is_partbactive }}</td>
           </tr>
           </tr>
-          @if($coverage->manual_determination_category_memo)
+          <tr class="{{!$coverage->manual_medicare_is_partbprimary ? 'd-none' : ''}}">
+            <td class="text-secondary">Part B Primary</td>
+            <td>{{ $coverage->manual_medicare_is_partbprimary }}</td>
+          </tr>
+          <tr class="{{!$coverage->manual_medicare_is_partcactive ? 'd-none' : ''}}">
+            <td class="text-secondary">Part C Active</td>
+            <td>{{ $coverage->manual_medicare_is_partcactive }}</td>
+          </tr>
+          <tr class="{{!$coverage->manual_medicare_is_msp ? 'd-none' : ''}}">
+            <td class="text-secondary">Msp</td>
+            <td>{{ $coverage->manual_medicare_is_msp }}</td>
+          </tr>
+          <tr class="{{!$coverage->manual_medicare_msp_memo ? 'd-none' : ''}}">
+            <td class="text-secondary">Msp Memo</td>
+            <td>{{ $coverage->manual_medicare_msp_memo }}</td>
+          </tr>
+        @endif
+        @if($coverage->mcdPayer)
           <tr>
           <tr>
-            <td><b>Manual Determination Memo: </b></td>
-            <td>{{$coverage->manual_determination_category_memo}}</td>
+            <td class="text-secondary">Medicaid Matched</td>
+            <td>{{ $coverage->manual_medicaid_is_matched }}</td>
           </tr>
           </tr>
-          @endif
-        </table>
+          <tr>
+              <td class="text-secondary">MCD Payer</td>
+              <td><span class="coverage-payer-name" title="{{$coverage->mcdPayer->name}}">{{ $coverage->mcdPayer->name }}</span></td>
+            </tr>
+        @endif
       @endif
       @endif
     @endif
     @endif
+  </table>
+   @endif
 </div>
 </div>

+ 205 - 0
resources/views/app/patient/coverage-status_depricated.blade.php

@@ -0,0 +1,205 @@
+<div class="table-responsive">
+    @php
+        $coverage = $patient->getPrimaryCoverage();
+        $mcnDetails = json_decode($patient->mcn_response_detail ?? null);
+    @endphp
+    @if(!$coverage)
+        <table class="table table-sm table-bordered mb-0">
+          <tr>
+            <td>
+              <b>No coverage info!</b>
+            </td>
+          </tr>
+        </table>
+    @elseif($coverage->plan_type === 'MEDICARE')
+      @if($coverage->creation_strategy == 'NEW' || $coverage->creation_strategy == 'AUTO_REFRESH')
+      <table class="table table-sm table-bordered mb-0">
+        <tr>
+          <td class="font-weight-bold">Medicare Part B<br>(Primary)</td>
+          <td>
+            @if($mcnDetails && $mcnDetails->plan_details)
+            <span class="font-weight-bold">{{ $mcnDetails->plan_details->MC->payer_name }}</span> <br>
+              @if($mcnDetails->plan_details && $mcnDetails->plan_details->MC && $mcnDetails->plan_details->MC->contacts)
+	      @foreach($mcnDetails->plan_details->MC->contacts as $contact)
+                @if($contact->contact_type == 'telephone')
+                  <a href="tel:{{ $contact->contact_value }}"><b><i class="fas fa-phone-alt"></i></b> {{ $contact->contact_value }}</a> <br>
+                @endif
+              @endforeach
+	      @endif
+            @endif
+            @if($coverage->auto_medicare_is_partbprimary == 'YES')
+              <span><i class="fas fa-check-circle text-success"></i> <b>Part B Primary:</b> YES (auto)</span> <br>
+            @elseif(!$coverage->auto_medicare_is_match_found)
+              <span><i class="fas fa-times text-danger"></i> record not found (auto)</span> <br>
+            @else
+              <span><i class="fas fa-check-circle text-success"></i> record found</span> <br>
+              <span><i class="fas fa-times text-danger"></i> <b>Part B Primary:</b> {{$coverage->auto_medicare_is_partbprimary}}</span> <br>
+              <span><b>Part B Active:</b> {{$coverage->auto_medicare_is_partbactive}}</span> <br>
+              <span><b>Part C Active:</b> {{$coverage->auto_medicare_is_partcactive}}</span>
+            @endif
+          </td>
+        </tr>
+        @if($coverage->auto_medicare_is_partbactive == 'YES' && !$coverage->auto_medicare_is_partcactive)
+        <tr>
+          <td class="font-weight-bold">Part B Deductible</td>
+          <td>{{number_format($coverage->auto_medicare_mpb_deductible, 2, '.',',') ?? '-'}}</td>
+        </tr>
+        <tr>
+          <td class="font-weight-bold">Part B Remaining</td>
+          <td>{{number_format($coverage->auto_medicare_mpb_remaining,2, '.',',') ?? '-'}}</td>
+        </tr>
+        @endif
+        @if($coverage->manual_determination_category_memo)
+        <tr>
+          <td><b>Manual Determination Memo: </b></td>
+          <td>{{$coverage->manual_determination_category_memo}}</td>
+        </tr>
+        @endif
+      </table>
+      @else
+      <!-- Manual determination -->
+      <table class="table table-sm table-bordered mb-0">
+        <tr>
+          <td class="font-weight-bold">Medicare Part B<br>(Primary)</td>
+          <td>
+            @if($mcnDetails && $mcnDetails->plan_details)
+              <span class="font-weight-bold">{{ $mcnDetails->plan_details->MC->payer_name }}</span> <br>
+              @if($mcnDetails->plan_details->MC->contacts)
+              @foreach($mcnDetails->plan_details->MC->contacts as $contact)
+                @if($contact->contact_type == 'telephone')
+                  <a href="tel:{{ $contact->contact_value }}"><b><i class="fas fa-phone-alt"></i></b> {{ $contact->contact_value }}</a> <br>
+                @endif
+              @endforeach
+              @endif
+            @endif
+
+            @if($coverage->manual_medicare_is_partbprimary == 'YES')
+              <span><i class="fas fa-check-circle text-success"></i> <b>Part B Primary:</b> YES ({{strtolower(implode(' ', explode('_', strtolower(implode(' ', explode('_', $coverage->manual_determination_strategy))))))}})</span> <br>
+            @elseif($coverage->manual_medicare_is_matched == 'NO')
+              <span><i class="fas fa-times text-danger"></i> record not found ({{strtolower(implode(' ', explode('_', $coverage->manual_determination_strategy)))}})</span> <br>
+            @else
+              <span><i class="fas fa-check-circle text-success"></i> record found</span> <br>
+              <span><i class="fas fa-times text-danger"></i> <b>Part B Primary:</b> {{$coverage->manual_medicare_is_partbprimary}}</span> <br>
+              <span><b>Part B Active:</b> {{$coverage->manual_medicare_is_partbactive}}</span> <br>
+              @if($coverage->manual_medicare_is_partcactive)
+              <span><b>Part C Active:</b> {{$coverage->manual_medicare_is_partcactive}}</span>
+              @endif
+              @endif
+          </td>
+        </tr>
+        @if($coverage->auto_medicare_is_partbactive && !$coverage->manual_medicare_is_partcactive)
+        <tr>
+          <td class="font-weight-bold">Part B Deductible</td>
+          <td>{{number_format($coverage->auto_medicare_mpb_deductible,2,'.',',') ?? '-'}}</td>
+        </tr>
+        <tr>
+          <td class="font-weight-bold">Part B Remaining</td>
+          <td>{{number_format($coverage->auto_medicare_mpb_remaining, 2, '.',',') ?? '-'}}</td>
+        </tr>
+        @endif
+        @if($coverage->manual_determination_category_memo)
+        <tr>
+          <td><b>Manual Determination Memo: </b></td>
+          <td>{{$coverage->manual_determination_category_memo}}</td>
+        </tr>
+        @endif
+      </table>
+      @endif
+
+    @elseif($coverage->plan_type === 'MEDICAID')
+      @if($coverage->creation_strategy == 'NEW' || $coverage->creation_strategy == 'AUTO_REFRESH')
+      <table class="table table-sm table-bordered mb-0">
+        <tr>
+          <td class="font-weight-bold">Medicaid<br>(Primary):</td>
+          <td>
+            <span class="coverage-payer-name" title="{{$coverage->mcdPayer->name ?? '-'}}"><b>{{$coverage->mcdPayer->name ?? '-'}}</b></span> <br>
+            <span><i class="fas fa-hourglass-half text-warning"></i> Pending Validation</span> <br>
+          </td>
+        </tr>
+        <tr>
+          <td class="font-weight-bold">Date Created:</td>
+          <td><span>{{date_format($coverage->created_at, 'm/d/Y')}}</span></td>
+        </tr>
+        @if($coverage->manual_determination_category_memo)
+        <tr>
+          <td><b>Manual Determination Memo: </b></td>
+          <td>{{$coverage->manual_determination_category_memo}}</td>
+        </tr>
+        @endif
+      </table>
+      @else
+        <table class="table table-sm table-bordered mb-0">
+          <tr>
+            <td class="font-weight-bold">Medicaid<br>(Primary):</td>
+            <td>
+              <span class="coverage-payer-name" title="{{$coverage->mcd_payer_name ?? '-'}}"><b>{{$coverage->mcd_payer_name ?? '-'}}</b></span> <br>
+              @if($coverage->manual_determination_category == 'COVERED')
+              <span><i class="fas fa-check-circle text-success"></i></span>
+              @elseif($coverage->manual_determination_category == 'NOT_COVERED')
+              <span><i class="fas fa-check-circle text-success"></i> record found</span> <br>
+              <span><i class="fas fa-times text-danger"></i> not covered ({{strtolower(implode(' ', explode('_', $coverage->manual_determination_strategy)))}})</span>
+              @elseif($coverage->manual_determination_category == 'INVALID')
+              <span><i class="fas fa-times text-danger"></i> record not found ({{strtolower(implode(' ', explode('_', $coverage->manual_determination_strategy)))}})</span>
+              @else
+              <span><i class="fas fa-hourglass-half text-warning"></i> pending ({{strtolower(implode(' ', explode('_', $coverage->manual_determination_strategy)))}})</span>
+              @endif
+            </td>
+          </tr>
+          @if($coverage->manual_determination_category_memo)
+          <tr>
+            <td><b>Manual Determination Memo: </b></td>
+            <td>{{$coverage->manual_determination_category_memo}}</td>
+          </tr>
+          @endif
+        </table>
+      @endif
+
+    @elseif($coverage->plan_type === 'COMMERCIAL')
+      @if($coverage->creation_strategy == 'NEW' || $coverage->creation_strategy == 'AUTO_REFRESH')
+      <table class="table table-sm table-bordered mb-0">
+        <tr>
+          <td class="font-weight-bold">Commercial<br>(Primary):</td>
+          <td>
+            <span class="coverage-payer-name" title="{{$coverage->payer->name ?? '-'}}"><b>{{$coverage->payer->name ?? '-'}}</b></span> <br>
+            <span><i class="fas fa-hourglass-half text-warning"></i> Pending Validation</span> <br>
+          </td>
+        </tr>
+        <tr>
+          <td class="font-weight-bold">Date Created:</td>
+          <td><span>{{date_format($coverage->created_at, 'm/d/Y')}}</span></td>
+        </tr>
+        @if($coverage->manual_determination_category_memo)
+        <tr>
+          <td><b>Manual Determination Memo: </b></td>
+          <td>{{$coverage->manual_determination_category_memo}}</td>
+        </tr>
+        @endif
+      </table>
+      @else
+        <table class="table table-sm table-bordered mb-0">
+          <tr>
+            <td class="font-weight-bold">Commercial<br>(Primary):</td>
+            <td>
+              <span class="coverage-payer-name" title="{{$coverage->payer->name ?? '-'}}"><b>{{$coverage->payer->name ?? '-'}}</b></span> <br>
+              @if($coverage->manual_determination_category == 'COVERED')
+              <span><i class="fas fa-check-circle text-success"></i></span>
+              @elseif($coverage->manual_determination_category == 'NOT_COVERED')
+              <span><i class="fas fa-check-circle text-success"></i> record found</span> <br>
+              <span><i class="fas fa-times text-danger"></i> not covered ({{strtolower(implode(' ', explode('_', $coverage->manual_determination_strategy)))}})</span>
+              @elseif($coverage->manual_determination_category == 'INVALID')
+              <span><i class="fas fa-times text-danger"></i> record not found ({{strtolower(implode(' ', explode('_', $coverage->manual_determination_strategy)))}})</span>
+              @else
+              <span><i class="fas fa-hourglass-half text-warning"></i> pending ({{strtolower(implode(' ', explode('_', $coverage->manual_determination_strategy)))}})</span>
+              @endif
+            </td>
+          </tr>
+          @if($coverage->manual_determination_category_memo)
+          <tr>
+            <td><b>Manual Determination Memo: </b></td>
+            <td>{{$coverage->manual_determination_category_memo}}</td>
+          </tr>
+          @endif
+        </table>
+      @endif
+    @endif
+</div>

+ 14 - 4
resources/views/app/patient/coverage_column_renderer.blade.php

@@ -1,13 +1,17 @@
 <div class="d-flex align-items-center">
 <div class="d-flex align-items-center">
     <?php 
     <?php 
         $coverage = $patient->getPrimaryCoverage();
         $coverage = $patient->getPrimaryCoverage();
-        $coverageStatus = $patient->getPrimaryCoverageStatus(); 
+        $coverageStatus = $patient->getPrimaryCoverageStatus();
     ?>
     ?>
     
     
     @if($coverageStatus === 'YES')
     @if($coverageStatus === 'YES')
         <i class="fa fa-check-circle text-success"></i>
         <i class="fa fa-check-circle text-success"></i>
     @elseif($coverageStatus === 'NO')
     @elseif($coverageStatus === 'NO')
-        <i class="fa fa-times text-danger"></i>
+        @if($coverage && !$coverage->manual_determination_category)
+            <i class="fas fa-hourglass-half text-warning" title="Pending Validation"></i>
+        @else
+            <i class="fa fa-times text-danger"></i>
+        @endif
     @else
     @else
         @if($coverage && $coverage->plan_type == 'MEDICARE' && !$coverage->auto_medicare_is_match_found)
         @if($coverage && $coverage->plan_type == 'MEDICARE' && !$coverage->auto_medicare_is_match_found)
             <i class="fa fa-times text-danger"></i>
             <i class="fa fa-times text-danger"></i>
@@ -21,8 +25,14 @@
     @endif
     @endif
     
     
     @if($coverage)
     @if($coverage)
-        <span class="ml-2">{{$coverage->insuranceDisplayName()}}</span>
+        @if($coverage->plan_type === 'MEDICAID' && $coverage->mcdPayer)
+            <span class="ml-2 {{ @$truncateName ? 'coverage-payer-name':'' }}" title="{{$coverage->mcdPayer->name}}">{{$coverage->mcdPayer->name}}</span>
+        @elseif($coverage->plan_type === 'COMMERCIAL' && $coverage->payer)
+            <span class="ml-2 {{ @$truncateName ? 'coverage-payer-name':'' }}" title="{{$coverage->payer->name}}">{{$coverage->payer->name}}</span>
+        @else
+            <span class="ml-2 {{ @$truncateName ? 'coverage-payer-name':'' }}" title="{{$coverage->insuranceDisplayName()}}">{{$coverage->insuranceDisplayName()}}</span>
+        @endif
     @else
     @else
-    <small class="ml-2 text-muted">(No insurance)</small>
+        <small class="ml-2 text-muted">(No insurance)</small>
     @endif
     @endif
 </div>
 </div>

+ 12 - 12
resources/views/app/patient/dashboard.blade.php

@@ -49,7 +49,7 @@
                 @if($isOldClient && $hasAllergiesInCanvas)
                 @if($isOldClient && $hasAllergiesInCanvas)
                 <div class="pt-2 mt-2 border-top">
                 <div class="pt-2 mt-2 border-top">
                     <div class="d-flex align-items-center pb-2">
                     <div class="d-flex align-items-center pb-2">
-                        <h6 class="my-0 font-weight-bold text-secondary">Allergies</h6>
+                        <h6 class="my-0 font-weight-bold">Allergies</h6>
                         <div class="px-2 font-weight-bold alert alert-warning text-sm my-0 ml-2 py-1">Deprecated</div>
                         <div class="px-2 font-weight-bold alert alert-warning text-sm my-0 ml-2 py-1">Deprecated</div>
                     </div>
                     </div>
                     <div class="bg-light border p-2 mb-3">
                     <div class="bg-light border p-2 mb-3">
@@ -67,7 +67,7 @@
                 @if($isOldClient && $hasRxInCanvas)
                 @if($isOldClient && $hasRxInCanvas)
                 <div class="pt-2 mt-2 border-top">
                 <div class="pt-2 mt-2 border-top">
                     <div class="d-flex align-items-center pb-2">
                     <div class="d-flex align-items-center pb-2">
-                        <h6 class="my-0 font-weight-bold text-secondary">Current Medications</h6>
+                        <h6 class="my-0 font-weight-bold">Current Medications</h6>
                         <div class="px-2 font-weight-bold alert alert-warning text-sm my-0 ml-2 py-1">Deprecated</div>
                         <div class="px-2 font-weight-bold alert alert-warning text-sm my-0 ml-2 py-1">Deprecated</div>
                     </div>
                     </div>
                     <div class="bg-light border p-2 mb-3">
                     <div class="bg-light border p-2 mb-3">
@@ -89,7 +89,7 @@
                 ?>
                 ?>
                 <div class="mt-2 pb-1" id="patient-dashboard-devices">
                 <div class="mt-2 pb-1" id="patient-dashboard-devices">
                     <div class="d-flex align-items-center mb-2 py-2 border-top border-bottom">
                     <div class="d-flex align-items-center mb-2 py-2 border-top border-bottom">
-                        <h6 class="my-0 font-weight-bold text-secondary">Devices</h6>
+                        <h6 class="my-0 font-weight-bold">Devices</h6>
                         @if($availableDevices > 0 && $pro->pro_type === 'ADMIN')
                         @if($availableDevices > 0 && $pro->pro_type === 'ADMIN')
                         <span class="mx-2 text-secondary">|</span>
                         <span class="mx-2 text-secondary">|</span>
                         <span moe>
                         <span moe>
@@ -206,7 +206,7 @@
                 @if($isOldClient && $hasVitalsInCanvas)
                 @if($isOldClient && $hasVitalsInCanvas)
                 <div class="pt-2 border-top">
                 <div class="pt-2 border-top">
                     <div class="d-flex align-items-center pb-2">
                     <div class="d-flex align-items-center pb-2">
-                        <h6 class="my-0 font-weight-bold text-secondary">Vitals</h6>
+                        <h6 class="my-0 font-weight-bold">Vitals</h6>
                         <div class="px-2 font-weight-bold alert alert-warning text-sm my-0 ml-2 py-1">Deprecated</div>
                         <div class="px-2 font-weight-bold alert alert-warning text-sm my-0 ml-2 py-1">Deprecated</div>
                     </div>
                     </div>
                     <div class="bg-light border p-2 mb-3">
                     <div class="bg-light border p-2 mb-3">
@@ -219,7 +219,7 @@
                 <?php $latestVitals = \App\Models\Point::where('client_id', $patient->id)->where('category', 'VITALS')->orderBy('id', 'DESC')->first(); ?>
                 <?php $latestVitals = \App\Models\Point::where('client_id', $patient->id)->where('category', 'VITALS')->orderBy('id', 'DESC')->first(); ?>
                 <div class="pt-2 mt-2">
                 <div class="pt-2 mt-2">
                     <div class="d-flex align-items-center pb-2">
                     <div class="d-flex align-items-center pb-2">
-                        <h6 class="my-0 font-weight-bold text-secondary">Vitals
+                        <h6 class="my-0 font-weight-bold">Vitals
                             @if(!!$latestVitals && $latestVitals->note && $latestVitals->note->effective_dateest)
                             @if(!!$latestVitals && $latestVitals->note && $latestVitals->note->effective_dateest)
                                 <span class="text-secondary font-weight-normal pl-1">(as on
                                 <span class="text-secondary font-weight-normal pl-1">(as on
                                     <a href="{{route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $latestVitals->note])}}">{{friendlier_date($latestVitals->note->effective_dateest)}}</a>)
                                     <a href="{{route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $latestVitals->note])}}">{{friendlier_date($latestVitals->note->effective_dateest)}}</a>)
@@ -248,7 +248,7 @@
                 @if($isOldClient)
                 @if($isOldClient)
                     <div class="pt-2 mb-2 border-top">
                     <div class="pt-2 mb-2 border-top">
                         <div class="d-flex align-items-center pb-2">
                         <div class="d-flex align-items-center pb-2">
-                            <h6 class="my-0 font-weight-bold text-secondary">Current Problems / Focus Areas</h6>
+                            <h6 class="my-0 font-weight-bold">Current Problems / Focus Areas</h6>
                             <div class="px-2 font-weight-bold alert alert-warning text-sm my-0 ml-2 py-1">Deprecated</div>
                             <div class="px-2 font-weight-bold alert alert-warning text-sm my-0 ml-2 py-1">Deprecated</div>
                         </div>
                         </div>
                         <div class="bg-light border p-2 mb-3">
                         <div class="bg-light border p-2 mb-3">
@@ -266,7 +266,7 @@
                 @if($isOldClient && $hasCareTeamInCanvas)
                 @if($isOldClient && $hasCareTeamInCanvas)
                     <div class="pt-2 mt-2 border-top">
                     <div class="pt-2 mt-2 border-top">
                         <div class="d-flex align-items-center pb-2">
                         <div class="d-flex align-items-center pb-2">
-                            <h6 class="my-0 font-weight-bold text-secondary">Care Team</h6>
+                            <h6 class="my-0 font-weight-bold">Care Team</h6>
                             <div class="px-2 font-weight-bold alert alert-warning text-sm my-0 ml-2 py-1">Deprecated</div>
                             <div class="px-2 font-weight-bold alert alert-warning text-sm my-0 ml-2 py-1">Deprecated</div>
                         </div>
                         </div>
                         <div class="bg-light border p-2 mb-3">
                         <div class="bg-light border p-2 mb-3">
@@ -284,7 +284,7 @@
                 @if($isOldClient && $hasPmhxInCanvas)
                 @if($isOldClient && $hasPmhxInCanvas)
                 <div class="pt-2 mt-2 border-top">
                 <div class="pt-2 mt-2 border-top">
                     <div class="d-flex align-items-center pb-2">
                     <div class="d-flex align-items-center pb-2">
-                        <h6 class="my-0 font-weight-bold text-secondary">Medical History</h6>
+                        <h6 class="my-0 font-weight-bold">Medical History</h6>
                         <div class="px-2 font-weight-bold alert alert-warning text-sm my-0 ml-2 py-1">Deprecated</div>
                         <div class="px-2 font-weight-bold alert alert-warning text-sm my-0 ml-2 py-1">Deprecated</div>
                     </div>
                     </div>
                     <div class="bg-light border p-2 mb-3">
                     <div class="bg-light border p-2 mb-3">
@@ -302,7 +302,7 @@
                 @if($isOldClient && $hasPshxInCanvas)
                 @if($isOldClient && $hasPshxInCanvas)
                 <div class="mt-2 border-top pt-2">
                 <div class="mt-2 border-top pt-2">
                     <div class="d-flex align-items-center pb-2">
                     <div class="d-flex align-items-center pb-2">
-                        <h6 class="my-0 font-weight-bold text-secondary">Surgical History</h6>
+                        <h6 class="my-0 font-weight-bold">Surgical History</h6>
                         <div class="px-2 font-weight-bold alert alert-warning text-sm my-0 ml-2 py-1">Deprecated</div>
                         <div class="px-2 font-weight-bold alert alert-warning text-sm my-0 ml-2 py-1">Deprecated</div>
                     </div>
                     </div>
                     <div class="bg-light border p-2 mb-3">
                     <div class="bg-light border p-2 mb-3">
@@ -320,7 +320,7 @@
                 @if($isOldClient && $hasFhxInCanvas)
                 @if($isOldClient && $hasFhxInCanvas)
                 <div class="mt-2 border-top pt-2">
                 <div class="mt-2 border-top pt-2">
                     <div class="d-flex align-items-center pb-2">
                     <div class="d-flex align-items-center pb-2">
-                        <h6 class="my-0 font-weight-bold text-secondary">Family History</h6>
+                        <h6 class="my-0 font-weight-bold">Family History</h6>
                         <div class="px-2 font-weight-bold alert alert-warning text-sm my-0 ml-2 py-1">Deprecated</div>
                         <div class="px-2 font-weight-bold alert alert-warning text-sm my-0 ml-2 py-1">Deprecated</div>
                     </div>
                     </div>
                     <div class="bg-light border p-2 mb-3">
                     <div class="bg-light border p-2 mb-3">
@@ -338,7 +338,7 @@
                 @if($isOldClient && $hasSochxInCanvas)
                 @if($isOldClient && $hasSochxInCanvas)
                 <div class="mt-2 border-top pt-2">
                 <div class="mt-2 border-top pt-2">
                     <div class="d-flex align-items-center pb-2">
                     <div class="d-flex align-items-center pb-2">
-                        <h6 class="my-0 font-weight-bold text-secondary">Social History</h6>
+                        <h6 class="my-0 font-weight-bold">Social History</h6>
                         <div class="px-2 font-weight-bold alert alert-warning text-sm my-0 ml-2 py-1">Deprecated</div>
                         <div class="px-2 font-weight-bold alert alert-warning text-sm my-0 ml-2 py-1">Deprecated</div>
                     </div>
                     </div>
                     <div class="bg-light border p-2 mb-3">
                     <div class="bg-light border p-2 mb-3">
@@ -530,7 +530,7 @@
                 <div  class="mb-2 pt-3 pb-2 border-top">
                 <div  class="mb-2 pt-3 pb-2 border-top">
                     <div class="">
                     <div class="">
                         <div class="d-flex align-items-start pb-2">
                         <div class="d-flex align-items-start pb-2">
-                            <h6 class="my-0 font-weight-bold text-secondary">Client Memos</h6>
+                            <h6 class="my-0 font-weight-bold">Client Memos</h6>
                         </div>
                         </div>
                         <div moe class="w-100 p-2 border mb-3">
                         <div moe class="w-100 p-2 border mb-3">
                             <form url="/api/clientMemo/create" show>
                             <form url="/api/clientMemo/create" show>

+ 1 - 1
resources/views/app/patient/goals-center.blade.php

@@ -21,7 +21,7 @@ if(!@$goals || !@$counts) {
             <thead>
             <thead>
             <tr class="">
             <tr class="">
                 @if($patient->core_note_id !== $note->id)
                 @if($patient->core_note_id !== $note->id)
-                    <th class="border-bottom-0 text-secondary text-center width-30px">Rel.</th>
+                    <th class="border-bottom-0 text-secondary text-center width-30px text-nowrap">Rel.</th>
                 @endif
                 @endif
                 <th class="border-bottom-0 text-secondary">Goal</th>
                 <th class="border-bottom-0 text-secondary">Goal</th>
                 <th class="border-bottom-0 text-secondary w-30">Subjective</th>
                 <th class="border-bottom-0 text-secondary w-30">Subjective</th>

+ 1 - 1
resources/views/app/patient/medications-center.blade.php

@@ -50,7 +50,7 @@ if(!@$summaryView) {
             <thead>
             <thead>
             <tr class="">
             <tr class="">
                 @if($patient->core_note_id !== $note->id)
                 @if($patient->core_note_id !== $note->id)
-                    <th class="border-bottom-0 text-secondary text-center width-30px">Rel.</th>
+                    <th class="border-bottom-0 text-secondary text-center width-30px text-nowrap">Rel.</th>
                 @endif
                 @endif
                 <th class="border-bottom-0 text-secondary">Name</th>
                 <th class="border-bottom-0 text-secondary">Name</th>
                 <th class="border-bottom-0 text-secondary w-30">Subj. Frequency / Experience</th>
                 <th class="border-bottom-0 text-secondary w-30">Subj. Frequency / Experience</th>

+ 68 - 9
resources/views/app/patient/medications-reconcile.blade.php

@@ -65,16 +65,14 @@ $medications = $points;
             ?>
             ?>
             <tr>
             <tr>
                 <td class="bg-light font-weight-bold">
                 <td class="bg-light font-weight-bold">
-                    {{$medication->data->name}}
+                    <span class="" if-active>{{$medication->data->name}}</span>
+                    <span class="text-secondary on-hover-opaque d-none" if-historic>{{$medication->data->name}}</span>
                     <div class="d-block font-weight-normal">
                     <div class="d-block font-weight-normal">
                         <div class="d-flex align-items-baseline">
                         <div class="d-flex align-items-baseline">
                             <span class="text-secondary mr-1">Active:</span>
                             <span class="text-secondary mr-1">Active:</span>
-                            @if($medication->is_removed)
-                                <span class="text-secondary">No</span>
-                            @else
-                                <span class="text-success">Yes</span>
-                            @endif
-                            <div moe class="ml-2">
+                            <span class="text-success font-weight-bold" if-active>Yes</span>
+                            <span class="text-warning-mellow font-weight-bold d-none" if-historic>No</span>
+                            <div moe class="ml-2" if-active>
                                 <a href="#" start show>Mark {{$medication->is_removed ? 'Active' : 'Historic'}}</a>
                                 <a href="#" start show>Mark {{$medication->is_removed ? 'Active' : 'Historic'}}</a>
                                 <form url="/api/visitPoint/updateTopLevel" no-auto-focus class="mcp-theme-1">
                                 <form url="/api/visitPoint/updateTopLevel" no-auto-focus class="mcp-theme-1">
                                     <p class="mb-2">Mark medication as {{$medication->is_removed ? 'Active' : 'Historic'}}</p>
                                     <p class="mb-2">Mark medication as {{$medication->is_removed ? 'Active' : 'Historic'}}</p>
@@ -82,7 +80,20 @@ $medications = $points;
                                     <input type="hidden" name="noteUid" value="{{$note->uid}}">
                                     <input type="hidden" name="noteUid" value="{{$note->uid}}">
                                     <input type="hidden" name="isRemoved" value="{{$medication->is_removed ? '0' : '1'}}">
                                     <input type="hidden" name="isRemoved" value="{{$medication->is_removed ? '0' : '1'}}">
                                     <div>
                                     <div>
-                                        <button submit class="btn btn-sm btn-primary mr-2">Save</button>
+                                        <button type="button" class="btn-mark-historic btn btn-sm btn-primary mr-2">Save</button>
+                                        <button cancel class="btn btn-sm bg-light btn-default border">Cancel</button>
+                                    </div>
+                                </form>
+                            </div>
+                            <div moe class="ml-2 d-none" if-historic>
+                                <a href="#" start show>Mark as Active</a>
+                                <form url="/api/visitPoint/updateTopLevel" no-auto-focus class="mcp-theme-1">
+                                    <p class="mb-2">Mark medication as Active</p>
+                                    <input type="hidden" name="uid" value="{{$medication->uid}}">
+                                    <input type="hidden" name="noteUid" value="{{$note->uid}}">
+                                    <input type="hidden" name="isRemoved" value="0">
+                                    <div>
+                                        <button type="button" class="btn-mark-active btn btn-sm btn-primary mr-2">Save</button>
                                         <button cancel class="btn btn-sm bg-light btn-default border">Cancel</button>
                                         <button cancel class="btn btn-sm bg-light btn-default border">Cancel</button>
                                     </div>
                                     </div>
                                 </form>
                                 </form>
@@ -137,7 +148,20 @@ $medications = $points;
                                 }
                                 }
                             }
                             }
                         }
                         }
-                    }
+                    },
+                    formats: [
+                        'bold',
+                        'italic',
+                        'link',
+                        'size',
+                        'strike',
+                        'underline',
+                        'blockquote',
+                        'header',
+                        'indent',
+                        'list',
+                        'align',
+                    ]
                 });
                 });
                 quill.root.innerHTML = existingContent;
                 quill.root.innerHTML = existingContent;
                 $(quill.container)
                 $(quill.container)
@@ -215,6 +239,41 @@ $medications = $points;
                     });
                     });
 
 
                 });
                 });
+
+            $('#medications-reconcile-{{$note->id}} .btn-mark-historic')
+                .off('click')
+                .on('click', function() {
+                    showMask();
+                    let form = $(this).closest('form'), row = $(this).closest('tr');
+                    $.post(form.attr('url'), form.serialize(), _data => {
+                        if(!hasResponseError(_data)) {
+                            row.find('[if-active], [if-historic]').addClass('d-none');
+                            row.find('[if-historic]').removeClass('d-none');
+                        }
+                    }, 'json').then(() => {
+                        $('[moe] form').hide();
+                        hideMask();
+                    });
+                    return false;
+                });
+
+            $('#medications-reconcile-{{$note->id}} .btn-mark-active')
+                .off('click')
+                .on('click', function() {
+                    showMask();
+                    let form = $(this).closest('form'), row = $(this).closest('tr');
+                    $.post(form.attr('url'), form.serialize(), _data => {
+                        if(!hasResponseError(_data)) {
+                            row.find('[if-active], [if-historic]').addClass('d-none');
+                            row.find('[if-active]').removeClass('d-none');
+                        }
+                    }, 'json').then(() => {
+                        $('[moe] form').hide();
+                        hideMask();
+                    });
+                    return false;
+                });
+
             __initRTEs($('#medications-reconcile-{{$note->id}} [note-rte]'))
             __initRTEs($('#medications-reconcile-{{$note->id}} [note-rte]'))
         }
         }
         addMCInitializer('medications-reconcile-{{$note->id}}', init, '#medications-reconcile-{{$note->id}}')
         addMCInitializer('medications-reconcile-{{$note->id}}', init, '#medications-reconcile-{{$note->id}}')

+ 2 - 2
resources/views/app/patient/module-specific-summary-renderers/allergy/plan.blade.php

@@ -16,9 +16,9 @@
                 <?php $j = 0; foreach ($points as $point): $j++; ?>
                 <?php $j = 0; foreach ($points as $point): $j++; ?>
                 <?php $rel = $point->relevanceToNote($note); ?>
                 <?php $rel = $point->relevanceToNote($note); ?>
                 <tr>
                 <tr>
-                    <td class="width-30px text-right pr-1 pl-0 {{ $rel ? ' text-info':'' }}">
+                    <td class="width-22px pr-1 pl-0 {{ $rel ? ' text-info':'' }}">
                         @if($rel)
                         @if($rel)
-                            *{{ $j }}.
+                            {{ $j }}.
                         @else
                         @else
                             {{ $j }}.
                             {{ $j }}.
                         @endif
                         @endif

+ 2 - 2
resources/views/app/patient/module-specific-summary-renderers/behavior/plan.blade.php

@@ -16,9 +16,9 @@
                 <?php $j = 0; foreach ($points as $point): $j++; ?>
                 <?php $j = 0; foreach ($points as $point): $j++; ?>
                 <?php $rel = $point->relevanceToNote($note); ?>
                 <?php $rel = $point->relevanceToNote($note); ?>
                 <tr>
                 <tr>
-                    <td class="width-30px text-right pr-1 pl-0 {{ $rel ? ' text-info':'' }}">
+                    <td class="width-22px pr-1 pl-0 {{ $rel ? ' text-info':'' }}">
                         @if($rel)
                         @if($rel)
-                            *{{ $j }}.
+                            {{ $j }}.
                         @else
                         @else
                             {{ $j }}.
                             {{ $j }}.
                         @endif
                         @endif

+ 2 - 2
resources/views/app/patient/module-specific-summary-renderers/care_team_member/plan.blade.php

@@ -16,9 +16,9 @@
                 <?php $j = 0; foreach ($points as $point): $j++; ?>
                 <?php $j = 0; foreach ($points as $point): $j++; ?>
                 <?php $rel = $point->relevanceToNote($note); ?>
                 <?php $rel = $point->relevanceToNote($note); ?>
                 <tr>
                 <tr>
-                    <td class="width-30px text-right pr-1 pl-0 {{ $rel ? ' text-info':'' }}">
+                    <td class="width-22px pr-1 pl-0 {{ $rel ? ' text-info':'' }}">
                         @if($rel)
                         @if($rel)
-                            *{{ $j }}.
+                            {{ $j }}.
                         @else
                         @else
                             {{ $j }}.
                             {{ $j }}.
                         @endif
                         @endif

+ 2 - 2
resources/views/app/patient/module-specific-summary-renderers/exercise/plan.blade.php

@@ -16,9 +16,9 @@
                 <?php $j = 0; foreach ($points as $point): $j++; ?>
                 <?php $j = 0; foreach ($points as $point): $j++; ?>
                 <?php $rel = $point->relevanceToNote($note); ?>
                 <?php $rel = $point->relevanceToNote($note); ?>
                 <tr>
                 <tr>
-                    <td class="width-30px text-right pr-1 pl-0 {{ $rel ? ' text-info':'' }}">
+                    <td class="width-22px pr-1 pl-0 {{ $rel ? ' text-info':'' }}">
                         @if($rel)
                         @if($rel)
-                            *{{ $j }}.
+                            {{ $j }}.
                         @else
                         @else
                             {{ $j }}.
                             {{ $j }}.
                         @endif
                         @endif

+ 2 - 2
resources/views/app/patient/module-specific-summary-renderers/goal/plan.blade.php

@@ -16,9 +16,9 @@
                 <?php $j = 0; foreach ($points as $point): $j++; ?>
                 <?php $j = 0; foreach ($points as $point): $j++; ?>
                 <?php $rel = $point->relevanceToNote($note); ?>
                 <?php $rel = $point->relevanceToNote($note); ?>
                 <tr>
                 <tr>
-                    <td class="width-30px text-right pr-1 pl-0 {{ $rel ? ' text-info':'' }}">
+                    <td class="width-22px pr-1 pl-0 {{ $rel ? ' text-info':'' }}">
                         @if($rel)
                         @if($rel)
-                            *{{ $j }}.
+                            {{ $j }}.
                         @else
                         @else
                             {{ $j }}.
                             {{ $j }}.
                         @endif
                         @endif

+ 2 - 2
resources/views/app/patient/module-specific-summary-renderers/medication/plan.blade.php

@@ -16,9 +16,9 @@
                 <?php $j = 0; foreach ($points as $point): $j++; ?>
                 <?php $j = 0; foreach ($points as $point): $j++; ?>
                 <?php $rel = $point->relevanceToNote($note); ?>
                 <?php $rel = $point->relevanceToNote($note); ?>
                 <tr>
                 <tr>
-                    <td class="width-30px text-right pr-1 pl-0 {{ $rel ? ' text-info':'' }}">
+                    <td class="width-22px pr-1 pl-0 {{ $rel ? ' text-info':'' }}">
                         @if($rel)
                         @if($rel)
-                            *{{ $j }}.
+                            {{ $j }}.
                         @else
                         @else
                             {{ $j }}.
                             {{ $j }}.
                         @endif
                         @endif

+ 2 - 2
resources/views/app/patient/module-specific-summary-renderers/nutrition/plan.blade.php

@@ -16,9 +16,9 @@
                 <?php $j = 0; foreach ($points as $point): $j++; ?>
                 <?php $j = 0; foreach ($points as $point): $j++; ?>
                 <?php $rel = $point->relevanceToNote($note); ?>
                 <?php $rel = $point->relevanceToNote($note); ?>
                 <tr>
                 <tr>
-                    <td class="width-30px text-right pr-1 pl-0 {{ $rel ? ' text-info':'' }}">
+                    <td class="width-22px pr-1 pl-0 {{ $rel ? ' text-info':'' }}">
                         @if($rel)
                         @if($rel)
-                            *{{ $j }}.
+                            {{ $j }}.
                         @else
                         @else
                             {{ $j }}.
                             {{ $j }}.
                         @endif
                         @endif

+ 2 - 2
resources/views/app/patient/module-specific-summary-renderers/problem/plan.blade.php

@@ -17,9 +17,9 @@
                 <?php $rel = $point->relevanceToNote($note); ?>
                 <?php $rel = $point->relevanceToNote($note); ?>
 		
 		
                 <tr>
                 <tr>
-                    <td class="width-30px text-right pr-1 pl-0 {{ $rel ? ' text-info':'' }}">
+                    <td class="width-22px pr-1 pl-0 {{ $rel ? ' text-info':'' }}">
                         @if($rel)
                         @if($rel)
-                            *{{ $j }}.
+                            {{ $j }}.
                         @else
                         @else
                             {{ $j }}.
                             {{ $j }}.
                         @endif
                         @endif

+ 7 - 1
resources/views/app/patient/note/_create-bill-only.blade.php

@@ -56,7 +56,13 @@
                                         onchange="calculateCoBillAmount(this)">
                                         onchange="calculateCoBillAmount(this)">
                                     <option value=""> -- select -- </option>
                                     <option value=""> -- select -- </option>
                                     <?php for ($i = 5; $i <= $maxMinutes; $i+=5) { ?>
                                     <?php for ($i = 5; $i <= $maxMinutes; $i+=5) { ?>
-                                    <option value="{{ $i/60 }}" {{ $i === 30 ? 'selected' : '' }}>{{ $i }} minutes</option>
+                                        @if($i == 20) {
+                                        <option value="{{ 21/60 }}" selected>{{ 21 }} minutes</option>
+                                        @else 
+                                            @if($i == 40 || $i <= 30 || $i >= 60)
+                                            <option value="{{ $i/60 }}">{{ $i }} minutes</option>        
+                                            @endif 
+                                        @endif
                                     <?php } ?>
                                     <?php } ?>
                                 </select>
                                 </select>
                             </div>
                             </div>

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

@@ -1,5 +1,11 @@
 <?php $noteRates = $note->hcpPro->noteRates(); ?>
 <?php $noteRates = $note->hcpPro->noteRates(); ?>
 @if(!$note->is_bill_closed && !$note->is_billing_marked_done)
 @if(!$note->is_bill_closed && !$note->is_billing_marked_done)
+    @if($note->hasUnacknowledgedCancelledBillsByPro($pro))
+        <b class="ml-3 text-warning-dark">
+            <i class="fa fa-exclamation-triangle"></i>
+            There are unacknowledged cancelled bills in this note!
+        </b>
+    @else
     <span class="mx-2 text-secondary">|</span>
     <span class="mx-2 text-secondary">|</span>
     <div moe relative wide bottom class="">
     <div moe relative wide bottom class="">
         <a class="" href="" show start>Create Bill</a>
         <a class="" href="" show start>Create Bill</a>
@@ -54,7 +60,9 @@
                                     @if($i == 20) {
                                     @if($i == 20) {
                                         <option value="{{ 21/60 }}" selected>{{ 21 }} minutes</option>
                                         <option value="{{ 21/60 }}" selected>{{ 21 }} minutes</option>
                                     @else 
                                     @else 
-                                        <option value="{{ $i/60 }}">{{ $i }} minutes</option>         
+                                        @if($i == 40 || $i <= 30 || $i >= 60)
+                                        <option value="{{ $i/60 }}">{{ $i }} minutes</option>        
+                                        @endif 
                                     @endif
                                     @endif
                                 <?php } ?>
                                 <?php } ?>
                             </select>
                             </select>
@@ -105,6 +113,7 @@
             <input type="hidden" name="numberOfUnits" value="1">
             <input type="hidden" name="numberOfUnits" value="1">
         </div>
         </div>
     </div>
     </div>
+    @endif
 @endif
 @endif
 @if($note->is_bill_closed)
 @if($note->is_bill_closed)
     <b class="ml-2 text-info">[BILLING CLOSED]</b>
     <b class="ml-2 text-info">[BILLING CLOSED]</b>
@@ -138,6 +147,7 @@
         </span>
         </span>
     @endif
     @endif
 @endif
 @endif
+@if(!$note->hasUnacknowledgedCancelledBillsByPro($pro))
 @if(!$note->is_billing_marked_done)
 @if(!$note->is_billing_marked_done)
     <span class="mx-2 text-secondary">|</span>
     <span class="mx-2 text-secondary">|</span>
     <span class="d-block" moe wide relative bottom>
     <span class="d-block" moe wide relative bottom>
@@ -166,7 +176,7 @@
         </form>
         </form>
     </span>
     </span>
 @endif
 @endif
-
+@endif
 
 
 <script>
 <script>
     (function() {
     (function() {

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

@@ -5,7 +5,7 @@
     <span class="text-warning-mellow font-weight-bold">
     <span class="text-warning-mellow font-weight-bold">
         <i class="fa fa-exclamation-triangle"></i>
         <i class="fa fa-exclamation-triangle"></i>
         Please sign off on the comprehensive care plan before creating claims.
         Please sign off on the comprehensive care plan before creating claims.
-    </span>
+    </span> 
 @else
 @else
     <span class="mx-2 text-secondary">|</span>
     <span class="mx-2 text-secondary">|</span>
     <a href="#" onclick="return showStagPopup('create-claim')">Create Claim</a>
     <a href="#" onclick="return showStagPopup('create-claim')">Create Claim</a>
@@ -126,6 +126,17 @@
         </div>
         </div>
     </form>
     </form>
 </div>
 </div>
+<script>
+    window.noteReasons = [];
+    @if(count($note->reasons()))
+    @foreach($note->reasons() as $reason)
+    window.noteReasons.push({
+        code: '{{$reason->code}}',
+        description: '{{$reason->description}}'
+    });
+    @endforeach
+    @endif
+</script>
 <script>
 <script>
     window.createClaimApp = new Vue({
     window.createClaimApp = new Vue({
         el: '#createClaimApp',
         el: '#createClaimApp',
@@ -136,18 +147,19 @@
                     {
                     {
                         cpt: '',
                         cpt: '',
                         dateOfService: '{{$note->created_at}}',
                         dateOfService: '{{$note->created_at}}',
-                        icds: JSON.parse(JSON.stringify(window.noteReasons)),
+                        icds: JSON.parse(JSON.stringify(window.noteReasons?window.noteReasons:[])),
                         numberOfUnits: 1
                         numberOfUnits: 1
                     }
                     }
                 ]
                 ]
-            }
+            },
+            saving: false,
         },
         },
         methods: {
         methods: {
             addLine: function () {
             addLine: function () {
                 this.payload.lines.push({
                 this.payload.lines.push({
                     cpt: '',
                     cpt: '',
                     dateOfService: '{{date_format($note->created_at, 'Y-m-d')}}',
                     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
                     numberOfUnits: 1
                 });
                 });
                 Vue.nextTick(() => {
                 Vue.nextTick(() => {
@@ -199,9 +211,13 @@
                 });
                 });
             },
             },
             saveClaim: function() {
             saveClaim: function() {
+                let self = this;
+                if(self.saving) return false;
+                self.saving = true;
                 let form = $('form#createClaimApp').first();
                 let form = $('form#createClaimApp').first();
                 if(!form[0].checkValidity()) {
                 if(!form[0].checkValidity()) {
                     form[0].reportValidity();
                     form[0].reportValidity();
+                    self.saving = false;
                     return false;
                     return false;
                 }
                 }
 
 
@@ -216,13 +232,16 @@
                         else {
                         else {
                             toastr.error('Unable to save the claim!');
                             toastr.error('Unable to save the claim!');
                         }
                         }
+                        self.saving = false;
                     }
                     }
                     else {
                     else {
                         toastr.success('Claim saved!');
                         toastr.success('Claim saved!');
                         closeStagPopup();
                         closeStagPopup();
                         fastReload();
                         fastReload();
                     }
                     }
-                }, 'json')
+                }, 'json').then(function() {
+                    self.saving = false;
+                });
             },
             },
             getPrefillValues: function() {
             getPrefillValues: function() {
                 @if(@$note && !empty($note->claim_suggestion_json))
                 @if(@$note && !empty($note->claim_suggestion_json))
@@ -231,6 +250,14 @@
                         this.payload.lines.splice(0, 1);
                         this.payload.lines.splice(0, 1);
                         this.payload.lines = csj.lines;
                         this.payload.lines = csj.lines;
                     }
                     }
+                    // clear empty icds
+                    for(let i=0; i<this.payload.lines.length; i++) {
+                        for (let j = this.payload.lines[i].icds.length - 1; j >=0; j--) {
+                            if(!this.payload.lines[i].icds[j].code && !this.payload.lines[i].icds[j].description) {
+                                this.payload.lines[i].icds.splice(j, 1);
+                            }
+                        }
+                    }
                 @endif
                 @endif
             }
             }
         },
         },

+ 4 - 4
resources/views/app/patient/note/_create-note-reason.blade.php

@@ -1,7 +1,7 @@
 <script>
 <script>
     window.noteReasons = [];
     window.noteReasons = [];
-    @if(count($note->reasons))
-        @foreach($note->reasons as $reason)
+    @if(count($note->reasons()))
+        @foreach($note->reasons() as $reason)
         window.noteReasons.push({
         window.noteReasons.push({
             code: '{{$reason->code}}',
             code: '{{$reason->code}}',
             description: '{{$reason->description}}'
             description: '{{$reason->description}}'
@@ -22,8 +22,8 @@
                 </tr>
                 </tr>
             </thead>
             </thead>
             <tbody>
             <tbody>
-                @if(count($note->reasons))
-                @foreach($note->reasons as $reason)
+                @if(count($note->reasons()))
+                @foreach($note->reasons() as $reason)
                 <tr class="data-row">
                 <tr class="data-row">
                     <td><input type="text" class="form-control note-reason-icd" data-index="{{$loop->index}}" id="icd_{{$loop->index}}" name="noteReasonDTOs[{{$loop->index}}].code" value="{{$reason->code}}"></td>
                     <td><input type="text" class="form-control note-reason-icd" data-index="{{$loop->index}}" id="icd_{{$loop->index}}" name="noteReasonDTOs[{{$loop->index}}].code" value="{{$reason->code}}"></td>
                     <td><input type="text" class="form-control note-reason-description" data-index="{{$loop->index}}" id="description_{{$loop->index}}" name="noteReasonDTOs[{{$loop->index}}].description" value="{{$reason->description}}"></td>
                     <td><input type="text" class="form-control note-reason-description" data-index="{{$loop->index}}" id="description_{{$loop->index}}" name="noteReasonDTOs[{{$loop->index}}].description" value="{{$reason->description}}"></td>

+ 48 - 12
resources/views/app/patient/note/dashboard-bu-b4-pure-soap.blade.php

@@ -979,7 +979,7 @@
                                         bmiCategory = '(Underweight)';
                                         bmiCategory = '(Underweight)';
                                     }
                                     }
                                     if (bmi >= 18.5 && bmi < 25) {
                                     if (bmi >= 18.5 && bmi < 25) {
-                                        bmiCategory = '(Healthy)';
+                                        bmiCategory = '';
                                     }
                                     }
                                     if (bmi >= 25 && bmi < 30) {
                                     if (bmi >= 25 && bmi < 30) {
                                         bmiCategory = '(Overweight)';
                                         bmiCategory = '(Overweight)';
@@ -1031,20 +1031,56 @@
                     <div class="">
                     <div class="">
                         <div class="d-flex align-items-center mb-2">
                         <div class="d-flex align-items-center mb-2">
                             <p class="font-weight-bold text-secondary m-0 mr-2">ICDs</p>
                             <p class="font-weight-bold text-secondary m-0 mr-2">ICDs</p>
-                            @include('app/patient/note/_create-note-reason')
+                            @include('app.patient.partials.put-rm-reasons', ['recordType' => 'NOTE', 'record' => $note])
                         </div>
                         </div>
+                        <?php
+                            $noteICDData = [
+                                'icd_1' => [
+                                    'title' => 'ICD 1',
+                                    'reason' => $note->note_reason_icd1,
+                                    'description' => $note->note_reason_icd1description
+                                ],
+                                'icd_2' => [
+                                    'title' => 'ICD 2',
+                                    'reason' => $note->note_reason_icd2,
+                                    'description' => $note->note_reason_icd2description
+                                ],
+                                'icd_3' => [
+                                    'title' => 'ICD 3',
+                                    'reason' => $note->note_reason_icd3,
+                                    'description' => $note->note_reason_icd3description
+                                ],
+                                'icd_4' => [
+                                    'title' => 'ICD 4',
+                                    'reason' => $note->note_reason_icd4,
+                                    'description' => $note->note_reason_icd4description
+                                ],
+                            ];
+                        ?>
                         <div class="d-flex align-items-start flex-wrap">
                         <div class="d-flex align-items-start flex-wrap">
-                        @if(count($note->reasons))
-                             @foreach ($note->reasons as $reason)
-                                <span class="badge badge-info p-2 mb-2 mr-2">
-                                    {{ $reason->description}} ({{ $reason->code }})
-                                </span>
-                            @endforeach
-                        @else
-                            <div class="alert alert-info position-static">No note reasons</div>
-                        @endif
+                            <?php $emptyNoteICDs = true; ?>
+                                @foreach ($noteICDData as $noteICDKey => $noteICD)
+                                    <?php 
+                                        $emptyICD = true;
+                                        if(!empty($noteICD['reason']) || !empty($noteICD['description'])){
+                                            $emptyNoteICDs = false;
+                                            $emptyICD = false;
+                                        }
+                                    ?>
+                                    @if(!$emptyICD)
+                                    <span class="badge badge-info px-2 mb-1 mr-2">{{$noteICD['reason']}} @if(!empty($noteICD['description']))({{ $noteICD['description'] }})@endif</span>
+                                    @endif
+                                @endforeach
+                            @if($emptyNoteICDs)
+                                <small class="text-dark">-</small>
+                            @endif
                         </div>
                         </div>
                     </div>
                     </div>
+                    @if(!empty($note->note_reason_memo))
+                        <div style="padding-left: 60px;">
+                            <small><b>Reason:</b> {{ $note->note_reason_memo }}</small>
+                        </div>
+                    @endif
                 </div>
                 </div>
 
 
                 @if($pro->pro_type === 'ADMIN')
                 @if($pro->pro_type === 'ADMIN')
@@ -1535,7 +1571,7 @@
                                                 </form>
                                                 </form>
                                             </span>
                                             </span>
                                         @else
                                         @else
-                                            <div class="text-success font-weight-bold"><i class="fa fa-check"></i> Verified</div>
+                                            <div class="text-success font-weight-bold"><i class="fa fa-check"></i> Verifiedxx</div>
                                             <span class="d-block mt-1" moe>
                                             <span class="d-block mt-1" moe>
                                                 <a class="" href="" show start>Undo</a>
                                                 <a class="" href="" show start>Undo</a>
                                                 <form url="/api/bill/undoMarkAsVerified">
                                                 <form url="/api/bill/undoMarkAsVerified">

+ 3025 - 0
resources/views/app/patient/note/dashboard-old.blade.php

@@ -0,0 +1,3025 @@
+<?php
+/** @var App\Models\Note $note */
+
+use App\Models\Handout;
+
+/** @var App\Models\Pro $pro */
+/** @var App\Models\Section $section */
+/** @var $allSections */
+?>
+@extends ('layouts.patient')
+
+@section('inner-content')
+
+    <?php
+    $hasBills = false;
+    if ($note->bills->count()) {
+        foreach ($note->bills as $bill) {
+            if (!$bill->is_cancelled) {
+                $hasBills = true;
+                break;
+            }
+        }
+    }
+
+    // is based on visit template
+    $isVisitTemplateBased = !!$note->visitTemplate;
+
+    $uiConfigsPath = $isVisitTemplateBased ? storage_path("visit-template-ui-configs/{$note->visitTemplate->internal_name}.json") : null;
+    $doesVisitTemplateUiConfigExist = $uiConfigsPath && file_exists($uiConfigsPath);
+    $visitTemplateUiConfig = $doesVisitTemplateUiConfigExist ? json_decode(file_get_contents($uiConfigsPath), true) : null;
+
+    $visitLayoutPath = '';
+    $doesVisitTemplateLayoutExist = false;
+
+    if($isVisitTemplateBased) {
+        $visitLayoutPath = "app.patient.note.visit-template-ui-layouts.{$note->visitTemplate->internal_name}";
+        $doesVisitTemplateLayoutExist = $isVisitTemplateBased && \Illuminate\Support\Facades\View::exists($visitLayoutPath);
+    }
+
+    $segmentMap = [];
+    foreach($note->segments as $segment):
+        $segmentMap[$segment->segmentTemplate->internal_name] = $segment;
+    endforeach;
+
+    $hasRightSegments = $isVisitTemplateBased && !!count($note->segmentsRight);
+
+    ?>
+    <div id="note-single-header" class="pb-3 d-flex align-items-start screen-only zero-height note_template_{{$note->visitTemplate ? $note->visitTemplate->internal_name : ''}}">
+        <h6 class="my-0 text-secondary d-flex align-items-center w-100">
+            <a href="/patients/view/{{ $patient->uid }}/notes" class="small text-decoration-none mr-3">
+                <i class="fa fa-chevron-left"></i>
+            </a>
+            <div class="mr-auto d-inline-flex align-items-center">
+                <span class="text-dark font-weight-bold">Note
+                    <span class="text-secondary font-weight-normal">{{ $note->is_cancelled ? '(CANCELLED)' : '' }}</span>
+                </span>
+                @if($pro->pro_type === 'ADMIN')
+                    @if(!!$note->visitTemplate)
+                        <a native target="_blank"
+                           href="{{route('note-pdf', ['note' => $note])}}"
+                           class="ml-3 btn btn-sm btn-primary text-white font-weight-bold"><i class="fa fa-print"></i> Print</a>
+                    @else
+                        <a href="#" class="print-note ml-3 btn btn-sm btn-primary text-white font-weight-bold invisible"><i class="fa fa-print"></i> Print</a>
+                    @endif
+                    <?php
+                    $isBad = false;
+                    $isGood = false;
+		            if($note->detail_json) {
+                        $parsed = json_decode($note->detail_json);
+                        $isBad = $parsed && @$parsed->isBad;
+			            $isGood = $parsed && @$parsed->isGood;
+                    }
+                    ?>
+                    @if(!$isBad)
+                        <div moe relative>
+                            <a href="#" start show  class="print-note ml-2 btn btn-sm btn-danger text-white font-weight-bold invisible"><i class="fa fa-exclamation-triangle"></i> Mark as Bad Note</a>
+                            <form url="/api/note/markNoteAsBad" class="mcp-theme-1">
+                                <input type="hidden" name="uid" value="{{$note->uid}}">
+                                <p class="min-width-200px">Mark this note as <b>bad</b>?</p>
+                                <div>
+                                    <button submit class="btn btn-sm btn-primary mr-1">Yes</button>
+                                    <button cancel class="btn btn-sm btn-default border">No</button>
+                                </div>
+                            </form>
+                        </div>
+                    @else
+                        <div moe relative>
+                            <a href="#" start show class="print-note ml-2 btn btn-sm btn-info text-white font-weight-bold invisible"><i class="fa fa-undo"></i> Marked as bad! Click to undo.</a>
+                            <form url="/api/note/undoMarkNoteAsBad" class="mcp-theme-1">
+                                <input type="hidden" name="uid" value="{{$note->uid}}">
+                                <p class="min-width-200px">Mark this note as <b>not bad</b>?</p>
+                                <div>
+                                    <button submit class="btn btn-sm btn-primary mr-1">Yes</button>
+                                    <button cancel class="btn btn-sm btn-default border">No</button>
+                                </div>
+                            </form>
+                        </div>
+                    @endif
+		            @if(!$isGood)
+                        <div moe relative>
+                            <a href="#" start show  class="print-note ml-2 btn btn-sm btn-success text-white font-weight-bold invisible"><i class="fa fa-check"></i> Mark as Good Note</a>
+                            <form url="/api/note/markNoteAsGood" class="mcp-theme-1">
+                                <input type="hidden" name="uid" value="{{$note->uid}}">
+                                <p class="min-width-200px">Mark this note as <b>good</b>?</p>
+                                <div>
+                                    <button submit class="btn btn-sm btn-primary mr-1">Yes</button>
+                                    <button cancel class="btn btn-sm btn-default border">No</button>
+                                </div>
+                            </form>
+                        </div>
+                    @else
+                        <div moe relative>
+                            <a href="#" start show class="print-note ml-2 btn btn-sm btn-info text-white font-weight-bold invisible"><i class="fa fa-undo"></i> Marked as good! Click to undo.</a>
+                            <form url="/api/note/undoMarkNoteAsGood" class="mcp-theme-1">
+                                <input type="hidden" name="uid" value="{{$note->uid}}">
+                                <p class="min-width-200px">Mark this note as <b>not good</b>?</p>
+                                <div>
+                                    <button submit class="btn btn-sm btn-primary mr-1">Yes</button>
+                                    <button cancel class="btn btn-sm btn-default border">No</button>
+                                </div>
+                            </form>
+                        </div>
+                    @endif
+                @endif
+            </div>
+            @if($patient->has_mcp_done_onboarding_visit !== 'YES')
+                <div class="ml-auto">
+                    <div moe relative>
+                        <a start show class="font-weight-bold">Mark as Onboarding Visit Note</a>
+                        <form url="/api/client/updateMcpOnboardingVisitInfo" class="mcp-theme-1" right>
+                            <input type="hidden" name="uid" value="{{$patient->uid}}">
+                            <input type="hidden" name="mcpOnboardingVisitNoteUid" value="{{$note->uid}}">
+                            <input type="hidden" name="hasMcpDoneOnboardingVisit" value="YES">
+                            <input type="hidden" name="mcpOnboardingVisitDate" value="{{$note->effective_dateest}}">
+                            <p class="min-width-200px">Mark this patient's onboarding as completed using this note?</p>
+                            <div>
+                                <button submit class="btn btn-sm btn-primary mr-1">Yes</button>
+                                <button cancel class="btn btn-sm btn-default border">No</button>
+                            </div>
+                        </form>
+                    </div>
+                </div>
+            @endif
+        </h6>
+    </div>
+
+    <div class="card mb-0 {{ $note->is_cancelled ? 'cancelled-item' : '' }} border-0 rounded-0">
+        <div class="card-header d-flex align-items-start px-3 py-2 border-bottom rounded-0" id="note-card-header">
+            <div class="pr-2">
+                {{$note->title}}
+                @if(!$note->is_signed_by_hcp || $pro->pro_type === 'ADMIN')
+                    <div moe class="ml-1">
+                        <a href="" show start><i class="fa fa-edit"></i></a>
+                        <form url="/api/note/putTitle">
+                            <input type="hidden" name="uid" value="{{$note->uid}}">
+                            <div class="mb-2">
+                                <input type="text" name="title" value="{{$note->title}}" class="form-control form-control-sm"
+                                       placeholder="Title">
+                            </div>
+                            <div class="form-group mb-0">
+                                <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                            </div>
+                        </form>
+                    </div>
+                    @if($note->visitTemplate && $note->visitTemplate->internal_name == 'omega_soap_visit' &&  $note->new_or_fu_or_na !== 'NEW')
+                        <div moe relative class="d-inline border-left pl-2 ml-2">
+                            <a start show>Clone</a>
+                            <form url="/api/visit/clone" class="mcp-theme-1" left
+                                  redir="/patients/view/{{$patient->uid}}/notes/view/[data]">
+                                <input type="hidden" name="visitToCloneUid" value="{{$note->uid}}">
+                                <div class="mb-2">
+                                    <label for="" class="text-sm text-secondary mb-1">Effective Date</label>
+                                    <input type="date" name="effectiveDate" class="form-control input-sm" value="{{get_current_date($pro->display_timezone)}}">
+                                </div>
+                                <div class="mb-2">
+                                    <label for="" class="text-secondary text-sm mb-1">New/Follow-up</label>
+                                    <div class="d-flex align-items-baseline py-1">
+                                        <label class="mr-3 my-0 d-inline-flex align-items-center c-pointer">
+                                            <input type="radio" name="newOrFuOrNa" value="NEW" required>
+                                            <span class="ml-1 text-dark">New</span>
+                                        </label>
+                                        <label class="my-0 d-inline-flex align-items-center c-pointer">
+                                            <input type="radio" name="newOrFuOrNa" value="FU" required checked>
+                                            <span class="ml-1 text-dark">Follow-Up</span>
+                                        </label>
+                                    </div>
+                                </div>
+
+                                <div class="mb-2">
+                                    <label for="" class="text-sm text-secondary mb-1">Method</label>
+                                    <select name="noteContactMethod" id="" class="form-control input-sm">
+                                        <option value="">--select--</option>
+                                        <option value="VIDEO">Video</option>
+                                        <option value="AUDIO">Audio</option>
+                                        <option value="IN_CLINIC">In Clinic</option>
+                                        <option value="HOUSE_CALL">House Call</option>
+                                    </select>
+                                </div>
+                                <div class="m-0">
+                                    <button submit class="btn btn-primary btn-sm">submit</button>
+                                </div>
+                            </form>
+                        </div>
+                    @endif
+                @endif
+            </div>
+            <div class="px-2 border-left border-right">
+                <div class="d-flex">
+                    <span class="mr-2">{{friendly_date_time($note->effective_dateest, false, '')}}</span>
+                    @if(!$note->is_signed_by_hcp || $pro->pro_type === 'ADMIN')
+                    <span moe class="ml-auto">
+                        <a href="" show start><i class="fa fa-calendar"></i></a>
+                        <form url="/api/note/putEffectiveDateEST">
+                            <input type="hidden" name="uid" value="{{$note->uid}}">
+                            <div class="mb-2">
+                                <label for="" class="text-secondary text-sm">Effective date EST</label>
+                                <input type="date" name="effectiveDateEST" value="{{$note->effective_dateest}}" class="form-control form-control-sm">
+                            </div>
+                            <div class="mb-0">
+                                <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                            </div>
+                        </form>
+                    </span>
+                    @endif
+                </div>
+            </div>
+
+            {{--<div class="px-2 border-left border-right">
+                <div class="d-flex">
+                    <span class="mr-2">{{friendly_time($note->effective_time, '')}}</span>
+                    @if(!$note->is_signed_by_hcp)
+                        <span moe class="ml-auto">
+                            <a href="" show start><i class="fa fa-clock"></i></a>
+                            <form url="/api/note/putEffectiveTime">
+                                <input type="hidden" name="uid" value="{{$note->uid}}">
+                                <div class="mb-2">
+                                    <label for="" class="text-secondary text-sm">Effective time </label>
+                                    <input type="time" name="effectiveTime" value="{{ date("H:i", strtotime($note->effective_time)) }}" class="form-control form-control-sm">
+                                </div>
+                                <div class="mb-0">
+                                    <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                </div>
+                            </form>
+                        </span>
+                    @endif
+                </div>
+            </div>--}}
+
+            <div class="px-2 border-right">
+                <div class="d-flex">
+                    <span><span class="text-secondary">HCP:</span> {{$note->hcpPro->displayName()}}</span>
+                    @if($pro->pro_type === 'ADMIN')
+                    <div moe class="ml-2">
+                        <a href="" show start><i class="fa fa-edit"></i></a>
+                        <form url="/api/note/putHcp">
+                            <input type="hidden" name="uid" value="{{$note->uid}}">
+                            <div class="mb-2">
+                                <select provider-search data-pro-uid="{{ @$note->hcpPro->uid }}"
+                                        name="hcpProUid" class="form-control form-control-sm">
+                                    <option value="">-- Select HCP Pro --</option>
+                                </select>
+                            </div>
+                            <div class="mb-0">
+                                <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                            </div>
+                        </form>
+                    </div>
+                    @endif
+                </div>
+            </div>
+
+
+            @if($performer->pro->pro_type == 'ADMIN' || ($note->allyPro && $note->allyPro->uid === $performer->pro->uid))
+                <span class="px-2 border-right d-flex">
+                    @if($note->allyPro)
+                        <span class="mr-2"><span class="text-secondary">NA:</span>  {{$note->allyPro->name_first}} {{$note->allyPro->name_last}}</span>
+                        @if($performer->pro->pro_type == 'ADMIN')
+                            <span class="d-inline-block" moe>
+                                <a class="text-danger" href="" show start>
+                                    <i class="fa fa-edit"></i>
+                                </a>
+                                <form url="/api/note/putNa">
+                                    <input type="hidden" name="uid" value="{{$note->uid}}">
+                                    <div class="mb-2">
+                                        <select provider-search data-pro-uid="{{ @$note->allyPro->uid }}"
+                                                name="naProUid" class="form-control form-control-sm">
+                                            <option value="">-- Select Ally Pro --</option>
+                                        </select>
+                                    </div>
+                                    <div class="mb-2">
+                                        <textarea class="form-control" name="memo" placeholder="memo"></textarea>
+                                    </div>
+                                    <div class="mb-0">
+                                        <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                    </div>
+                                </form>
+                            </span>
+                            <span class="inline-block ml-2"></span>
+                            <span class="d-inline-block" moe>
+                                <a class="text-danger" href="" show start>
+                                    <i class="fa fa-times"></i>
+                                </a>
+                                <form url="/api/note/removeNa">
+                                    <input type="hidden" name="uid" value="{{$note->uid}}">
+                                    <p>Remove NA ssss?</p>
+                                    <div class="mb-0">
+                                        <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                    </div>
+                                </form>
+                            </span>
+                        @endif
+                    @else
+                        <span class="mr-2"><span class="text-secondary">NA:</span> - </span>
+                        <span class="d-block" moe>
+                            <a class="" href="" show start>
+                                <i class="fa fa-edit"></i>
+                            </a>
+                            <form url="/api/note/putNa">
+                                <input type="hidden" name="uid" value="{{$note->uid}}">
+                                <div class="form-group">
+                                    <label for="" class="control-label">NA</label>
+                                    <select name="naProUid" class="form-control" provider-search>
+                                        <option value="">--select--</option>
+                                    </select>
+                                </div>
+                                <div class="mb-0">
+                                    <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                </div>
+                            </form>
+                        </span>
+                    @endif
+
+                </span>
+            @endif
+
+
+            <div class="px-2 border-right">
+                <div class="d-flex">
+                    <span class="mr-2"><span class="text-secondary">Type:</span> {{$note->new_or_fu_or_na ? ($note->new_or_fu_or_na === 'NEW' ? 'New Patient' : $note->new_or_fu_or_na) : '-'}}</span>
+                    @if(!$note->is_signed_by_hcp || $pro->pro_type === 'ADMIN')
+                        <div moe class="ml-auto">
+                            <a href="" show start><i class="fa fa-edit"></i></a>
+                            <form url="/api/note/updateNewOrFuOrNa">
+                                <input type="hidden" name="uid" value="{{$note->uid}}">
+                                <div class="mb-2">
+                                    <select name="newOrFuOrNa" class="form-control form-control-sm" required>
+                                        <option value="">-- select --</option>
+                                        <option value="NEW" {{ $note->new_or_fu_or_na === "NEW" ? "selected" : "" }}>New</option>
+                                        <option value="FU" {{ $note->new_or_fu_or_na === "FU" ? "selected" : "" }}>Follow-up</option>
+                                        <option value="NA" {{ $note->new_or_fu_or_na === "NA" ? "selected" : "" }}>N/A</option>
+                                    </select>
+                                </div>
+                                <div class="mb-0">
+                                    <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                </div>
+                            </form>
+                        </div>
+                    @endif
+                </div>
+            </div>
+
+            <div class="px-2">
+                <div class="d-flex">
+                    <span class="mr-2"><span class="text-secondary">Method:</span> {{$note->method ? noteMethodDisplay($note->method) : '-'}}</span>
+                    @if(!$note->is_signed_by_hcp || $pro->pro_type === 'ADMIN')
+                        <div moe class="ml-auto">
+                            <a href="" show start><i class="fa fa-edit"></i></a>
+                            <form url="/api/note/updateMethod" hook="onNoteMethodUpdate">
+                                <input type="hidden" name="uid" value="{{$note->uid}}">
+                                <div class="mb-2">
+                                    <select name="method" class="form-control form-control-sm note-method-select" required>
+                                        <option value="AUDIO" {{ $note->method === "AUDIO" ? "selected" : "" }}>Audio</option>
+                                        <option value="VIDEO" {{ $note->method === "VIDEO" ? "selected" : "" }}>Video</option>
+                                        <option value="IN_CLINIC" {{ $note->method === "IN_CLINIC" ? "selected" : "" }}>In-Clinic</option>
+                                        <option value="HOUSE_CALL" {{ $note->method === "HOUSE_CALL" ? "selected" : "" }}>House Call</option>
+                                    </select>
+                                </div>
+                                <div class="form-group if-in-clinic">
+                                    <label for="" class="text-secondary text-sm mb-1">Location</label>
+                                    <select name="hcpCompanyLocationUid" class="form-control">
+                                        <option value=""></option>
+                                        @foreach($pro->companyLocations() as $location)
+                                            <option value="{{$location->uid}}" {{$location->id === $note->hcp_company_location_id ? 'selected' : ''}}>{{$location->line1}} {{$location->city}}</option>
+                                        @endforeach
+                                    </select>
+                                </div>
+                                <div class="mb-0">
+                                    <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                </div>
+                            </form>
+                        </div>
+                    @endif
+                </div>
+            </div>
+
+            <div class="px-2 border-left screen-only">
+                <a href="{{route('print-note', ['patient' => $patient, 'note' => $note])}}" native target="_blank" class=""><i class="fa fa-print"></i> Print</a>
+            </div>
+
+            @if($pro->pro_type === 'ADMIN' || $pro->is_enrolled_as_mcp)
+            <div class="px-2 border-left screen-only">
+                <a native target="_blank"
+                   open-in-stag-popup
+                   mc-initer="patient-calendar-{{$patient->id}}"
+                   title="Calendar: {{$patient->displayName()}}"
+                   popup-style="medium-large"
+                   href="{{route('patients.view.calendar', ['patient' => $patient])}}?opUid={{$note->hcpPro ? $note->hcpPro->uid : ''}}">
+                    <i class="fa fa-clock"></i>
+                    Book Appt.
+                </a>
+            </div>
+            @endif
+
+            {{-- additional modules --}}
+            @if(!$note->is_signed_by_hcp)
+            <?php
+            $availableModules = [
+                [
+                    "name" => 'Nutrition Rx',
+                    "title" => '<img src=\'/img/nutrition-rx.png\'/> Nutrition Rx',
+                    "href" => "/nutrition-center/{$note->client->uid}/{$note->uid}",
+                    "initer" => "nutrition-center-{$note->id}"
+                ],
+                [
+                    "name" => 'Exercise Rx',
+                    "title" => '<img src=\'/img/exercise-rx.png\'/> Exercise Rx',
+                    "href" => "/exercise-center/{$note->client->uid}/{$note->uid}",
+                    "initer" => "exercise-center-{$note->id}"
+                ],
+                [
+                    "name" => 'Behavior Rx',
+                    "title" => '<img src=\'/img/behavior-rx.png\'/> Behavior Rx',
+                    "href" => "/behavior-center/{$note->client->uid}/{$note->uid}",
+                    "initer" => "behavior-center-{$note->id}"
+                ],
+                [], // for separator
+                [
+                    "name" => 'COVID-19 Intake',
+                    "title" => 'COVID-19 Intake',
+                    "href" => "/note-segment-view-by-name/{$note->uid}/covid_intake/edit",
+                    "initer" => "edit-module-covid-intake-{$note->id}"
+                ],
+                [
+                    "name" => 'COVID-19 Follow-up',
+                    "title" => 'COVID-19 Follow-up',
+                    "href" => "/note-segment-view-by-name/{$note->uid}/covid_follow-up/edit",
+                    "initer" => "covid-follow-up-{$note->id}"
+                ],
+                [], // for separator
+                [
+                    "name" => 'Lifestyle General',
+                    "title" => 'Lifestyle General',
+                    "style" => 'stag-popup-md',
+                    "href" => "/module-view/{$note->uid}/lifestyle_general/edit",
+                    "initer" => "edit-univ_sub_lifestyle_general-container-{$note->id}"
+                ],
+                [
+                    "name" => 'Lifestyle Nutrition',
+                    "title" => 'Lifestyle Nutrition',
+                    "style" => 'stag-popup-md',
+                    "href" => "/module-view/{$note->uid}/lifestyle_nutrition/edit",
+                    "initer" => "edit-univ_sub_nutrition_assessment-container-{$note->id}"
+                ],
+                [
+                    "name" => 'Lifestyle Physical Activity',
+                    "title" => 'Lifestyle Physical Activity',
+                    "style" => 'stag-popup-md',
+                    "href" => "/module-view/{$note->uid}/lifestyle_physical_activity/edit",
+                    "initer" => "edit-univ_sub_physical_activity_assessment-container-{$note->id}"
+                ],
+                [
+                    "name" => 'Lifestyle Sleep',
+                    "title" => 'Lifestyle Sleep',
+                    "style" => 'stag-popup-md',
+                    "href" => "/module-view/{$note->uid}/lifestyle_sleep/edit",
+                    "initer" => "edit-univ_sub_sleep_assessment-container-{$note->id}"
+                ],
+                [
+                    "name" => 'Lifestyle Social',
+                    "title" => 'Lifestyle Social',
+                    "style" => 'stag-popup-md',
+                    "href" => "/module-view/{$note->uid}/lifestyle_social/edit",
+                    "initer" => "edit-univ_sub_social_relationships_assessment-container-{$note->id}"
+                ],
+                [
+                    "name" => 'Lifestyle Stress',
+                    "title" => 'Lifestyle Stress',
+                    "style" => 'stag-popup-md',
+                    "href" => "/module-view/{$note->uid}/lifestyle_stress/edit",
+                    "initer" => "edit-univ_sub_stress_assessment-container-{$note->id}"
+                ],
+                [
+                    "name" => 'Lifestyle Substances',
+                    "title" => 'Lifestyle Substances',
+                    "style" => 'stag-popup-md',
+                    "href" => "/module-view/{$note->uid}/lifestyle_substances/edit",
+                    "initer" => "edit-univ_sub_substance_use_assessment-container-{$note->id}"
+                ],
+                [
+                    "name" => 'Weight Loss Intake',
+                    "title" => 'Weight Loss Intake',
+                    "style" => 'stag-popup-md',
+                    "href" => "/module-view/{$note->uid}/weight_loss_intake/edit",
+                    "initer" => "edit-weight_loss_intake-container-{$note->id}"
+                ],
+            ];
+            ?>
+            <div moe relative class="px-2 border-left screen-only">
+                <a href="#" start show>+ Form</a>
+                <form url="#" right>
+                    <p class="font-weight-bold text-secondary">Additional Forms</p>
+                    @foreach($availableModules as $module)
+                        @if(@$module['name'])
+                            <a href="{{$module['href']}}"
+                               open-in-stag-popup
+                               popup-style="overflow-visible {{@$module['style']}}"
+                               title="{!! $module['title'] !!}"
+                               mc-initer="{{ @$module['initer']  }}"
+                               class="d-block mb-1 text-nowrap">{!! $module['name'] !!}</a>
+                        @else
+                            <hr class="my-2">
+                        @endif
+                    @endforeach
+                </form>
+            </div>
+            @endif
+
+
+            @if($note->is_signed_by_hcp)
+                @php
+                    $suggestionMode = request()->get('suggestion_mode');
+                @endphp
+                @if($suggestionMode == 'on')
+                    <a class="ml-3 native font-weight-normal refresh-segment c-pointer screen-only"
+                        href="/patients/view/{{$note->client->uid}}/notes/view/{{$note->uid}}?suggestion_mode=off"
+                        title="Update with latest patient data">
+                        Suggestion Mode
+                    </a>
+                @else
+                    <a class="ml-3 native font-weight-normal refresh-segment c-pointer screen-only"
+                        href="/patients/view/{{$note->client->uid}}/notes/view/{{$note->uid}}?suggestion_mode=on"
+                        title="Update with latest patient data">
+                        Suggestion Mode
+                    </a>
+                @endif
+            @endif
+
+            <div class="ml-auto d-flex align-items-start">
+                <div class="">
+                    <div>
+
+                        @if($note->is_signed_by_hcp )
+                            <div class="d-flex align-items-baseline">
+                                <div class="text-secondary">
+                                    <i class="fa fa-check"></i>
+                                    Note Signed
+                                </div>
+                                @if($pro->pro_type === 'ADMIN')
+                                    <div class="ml-3">
+                                        <div moe>
+                                            <a class="" href="" show start>Undo Sign As HCP</a>
+                                            <form url="/api/note/adminUndoSignAsHcp" right>
+                                                <input type="hidden" name="uid" value="{{$note->uid}}">
+                                                <p>Undo HCP signature?</p>
+                                                <div class="mb-0">
+                                                    <button class="btn btn-primary btn-sm" submit>Undo</button>
+                                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                </div>
+                                            </form>
+                                        </div>
+                                    </div>
+                                @endif
+                                @if($pro->pro_type === 'ADMIN' || ($note->hcpPro && $pro->id === $note->hcpPro->id))
+                                    <div class="ml-3 screen-only">
+                                        @include('app/patient/note/_create-bill-only')
+                                    </div>
+                                @endif
+                            </div>
+                        @endif
+                        @if(!$note->is_signed_by_hcp )
+                            @if($note->hcp_pro_id !== $pro->id)
+                                <span class="text-sm text-secondary screen-only">Only the note's HCP can sign</span>
+                            @else
+                                @if(!$isVisitTemplateBased)
+                                    <div moe relative
+                                         class="{{ $note->hcp_pro_id !== $pro->id ? 'moe-disabled' : '' }} screen-only"
+                                         title="{{ $note->hcp_pro_id !== $pro->id ? 'Only the note\'s HCP can sign' : '' }}">
+                                        <a class="" href="" show start>Sign As HCP</a>
+                                        <form url="/api/note/signAsHcp" right>
+                                            <input type="hidden" name="uid" value="{{$note->uid}}">
+                                            <p>Sign this note as HCP?</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>
+                                @else
+                                    <a native target="_blank"
+                                       open-in-stag-popup
+                                       update-parent
+                                       mc-initer="note-sign-confirmation-{{$note->id}}"
+                                       popup-style="stag-popup-md"
+                                       title="Confirm and Sign"
+                                       class="screen-only"
+                                       href="{{route('patients.view.notes.view.sign-confirmation', compact('patient', 'note'))}}">
+                                        Sign Note As HCP
+                                    </a>
+                                @endif
+                            @endif
+                        @endif
+                    </div>
+                </div>
+                @if($note->allyPro && $pro->id === $note->allyPro->id)
+                <div class="ml-3">
+                    <div>
+                        @if($note->is_signed_by_ally)
+                            <span class="text-secondary">
+                                <i class="fa fa-check"></i>
+                                Note Signed By NA
+                                @if(!$note->is_signed_by_hcp)
+                                <span moe class="ml-2">
+                                    <a class="" href="" show start>Undo sign?</a>
+                                    <form url="/api/note/undoSignAsAlly" right>
+                                        <input type="hidden" name="uid" value="{{$note->uid}}">
+                                        <p>Undo sign?</p>
+                                        <div class="mb-0">
+                                            <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                        </div>
+                                    </form>
+                                </span>
+                                @endif
+                            </span>
+                        @else
+                            <div moe
+                                 class="{{ $note->ally_pro_id !== $pro->id ? 'moe-disabled' : '' }}"
+                                 title="{{ $note->ally_pro_id !== $pro->id ? 'Only the note\'s Ally can sign' : '' }}">
+                                <a class="" href="" show start>Sign As NA</a>
+                                <form url="/api/note/signAsAlly" right>
+                                    <input type="hidden" name="uid" value="{{$note->uid}}">
+                                    <p>Sign this NA?</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
+                    </div>
+                </div>
+                @endif
+                @if($note->is_cancelled || (!$note->is_cancelled && !$note->is_signed_by_hcp))
+                <div class="ml-2 pl-2 border-left">
+                    <div class="d-flex justify-content-end">
+                        @if(!$note->is_cancelled)
+                        <div moe relatve
+                             class="{{ $hasBills ? 'moe-disabled' : '' }}"
+                             title="{{ $hasBills ? 'Cannot cancel note since it has un-cancelled bills in it' : '' }}">
+                            <a class="text-danger" href="" show start>Cancel</a>
+                            <form url="/api/note/cancel" right>
+                                <input type="hidden" name="uid" value="{{$note->uid}}">
+                                <p class="small mb-2">Are you sure you want to cancel this note?</p>
+                                <div class="mb-2">
+                                    <textarea name="memo" id="" cols="30" rows="5" placeholder="Memo" class="memo-textarea form-control form-control-sm"></textarea>
+                                </div>
+                                <div class="d-flex align-items-center">
+                                    <button class="btn btn-sm btn-danger mr-2" submit>Yes</button>
+                                    <button class="btn btn-sm btn-default mr-2 border" cancel>No</button>
+                                </div>
+                            </form>
+                        </div>
+                        @else
+                            <span class="text-secondary font-weight-bold">CANCELLED</span>
+                        @endif
+                    </div>
+                </div>
+                @endif
+
+            </div>
+        </div>
+        <div class="card-body p-0">
+            <div class="note-container note_template_{{$note->visitTemplate ? $note->visitTemplate->internal_name : ''}}">
+                @if(!$hasRightSegments)
+                    @include('app.patient.note.lhs-tree')
+                @endif
+                <div class="note-rhs-content">
+                <div>
+                <div class="border-bottom pb-3">
+                    <div class="{{$hasRightSegments ? 'd-flex align-items-stretch' : ''}}">
+                        <?php
+                        $shortCutsObject = [];
+                        foreach ($pro->allShortcuts() as $shortcut) {
+
+                            // %replaceables%
+                            $shortcut->text = str_replace("%AGE%", $patient->age_in_years, $shortcut->text);
+                            $shortcut->text = str_replace("%GENDER%", $patient->sex, $shortcut->text);
+                            $shortcut->text = str_replace("%NAME%", $patient->displayName(), $shortcut->text);
+
+                            $shortCutsObject[] = [
+                                "name" => $shortcut->shortcut,
+                                "value" => $shortcut->text
+                            ];
+                        }
+                        ?>
+                        <script>window.userShortcuts = <?= json_encode($shortCutsObject); ?>;</script>
+                        <script>
+                            window.hpiShortcuts = [
+                                {
+                                    name: 'Explain the problem.',
+                                    value: 'Explain the problem. ',
+                                },
+                                {
+                                    name: 'What happened between today and our last visit?',
+                                    value: 'What happened between today and our last visit? ',
+                                },
+                                {
+                                    name: 'How did it go with the plan I gave you?',
+                                    value: 'How did it go with the plan I gave you? ',
+                                },
+                                {
+                                    name: 'What barriers have you felt following the plan?',
+                                    value: 'What barriers have you felt following the plan? ',
+                                },
+                                {
+                                    name: 'How long have you had this?',
+                                    value: 'How long have you had this? ',
+                                },
+                                {
+                                    name: 'When does it get worse?',
+                                    value: 'When does it get worse? ',
+                                },
+                                {
+                                    name: 'When does it get better?',
+                                    value: 'When does it get better? ',
+                                },
+                                {
+                                    name: 'What have you done for treatment?',
+                                    value: 'What have you done for treatment? ',
+                                },
+                                {
+                                    name: 'How does it affect your ADLs?',
+                                    value: 'How does it affect your ADLs? ',
+                                },
+                                {
+                                    name: 'How do you cope?',
+                                    value: 'How do you cope? ',
+                                },
+                                {
+                                    name: 'How does this affect you emotionally?',
+                                    value: 'How does this affect you emotionally? ',
+                                },
+                            ];
+                        </script>
+                        <script>window.segmentInitializers = {};</script>
+                        <?php
+                        $shortcuts = "";
+                        $latestSectionTS = 0;
+                        ?>
+                        <div class="{{ $note->is_signed_by_hcp ? 'note-signed-by-hcp' : '' }} {{$hasRightSegments ? 'w-30 border-right note-left-panel stag-scrollbar' : ''}}">
+                            <div class="min-width-300px stag-scrollbar">
+                                <?php $isOldClient = (date_diff(date_create(config('app.point_impl_date')), date_create($patient->created_at))->invert === 1); ?>
+                                @if($isOldClient)
+                                    <div class="p-2 bg-light border-bottom screen-only">
+                                        <div class="d-flex align-items-baseline">
+                                            <div class="font-weight-bold font-size-14 text-warning-dark">
+                                                <i class="fa fa-clock text-secondary text-sm"></i>
+                                                Data from old notes
+                                            </div>
+                                            <a href="#" class="ml-3" onclick="$(this).parent().next().toggleClass('d-none'); return false;">Toggle</a>
+                                        </div>
+                                        <div class="mt-3 ml-3 d-none">
+                                            <?php $hasAllergiesInCanvas = $patient->hasDataInCanvas('allergies'); ?>
+                                            @if($hasAllergiesInCanvas)
+                                                <div class="uucol-4">
+                                                    <div class="d-flex align-items-center pb-2">
+                                                        <h6 class="my-0 font-weight-bold text-secondary">Allergies</h6>
+                                                    </div>
+                                                    <div class="bg-light border p-2 mb-3">
+                                                        @include('app.patient.canvas-sections.allergies.summary')
+                                                    </div>
+                                                </div>
+                                            @endif
+                                            <?php $hasRxInCanvas = $patient->hasDataInCanvas('rx'); ?>
+                                            @if($hasRxInCanvas)
+                                                <div class="uucol-4">
+                                                    <div class="d-flex align-items-center pb-2">
+                                                        <h6 class="my-0 font-weight-bold text-secondary">Current Medications</h6>
+                                                    </div>
+                                                    <div class="bg-light border p-2 mb-3">
+                                                        @include('app.patient.canvas-sections.rx.summary')
+                                                    </div>
+                                                </div>
+                                            @endif
+                                            <?php $hasDxInCanvas = $patient->hasDataInCanvas('dx'); ?>
+                                            @if($hasDxInCanvas)
+                                                <div class="uucol-4">
+                                                    <div class="d-flex align-items-center pb-2">
+                                                        <h6 class="my-0 font-weight-bold text-secondary">Current Problems / Focus Areas</h6>
+                                                    </div>
+                                                    <div class="bg-light border p-2 mb-3">
+                                                        @include('app.patient.canvas-sections.dx.summary')
+                                                    </div>
+                                                </div>
+                                            @endif
+                                            <?php $hasCareTeamInCanvas = $patient->hasDataInCanvas('care-team'); ?>
+                                            @if($hasCareTeamInCanvas)
+                                                <div class="uucol-4">
+                                                    <div class="d-flex align-items-center pb-2">
+                                                        <h6 class="my-0 font-weight-bold text-secondary">Care Team</h6>
+                                                    </div>
+                                                    <div class="bg-light border p-2 mb-3">
+                                                        @include('app.patient.canvas-sections.care-team.summary')
+                                                    </div>
+                                                </div>
+                                            @endif
+                                            <?php $hasPmhxInCanvas = $patient->hasDataInCanvas('pmhx'); ?>
+                                            @if($hasPmhxInCanvas)
+                                                <div class="uucol-4">
+                                                    <div class="d-flex align-items-center pb-2">
+                                                        <h6 class="my-0 font-weight-bold text-secondary">Medical History</h6>
+                                                    </div>
+                                                    <div class="bg-light border p-2 mb-3">
+                                                        @include('app.patient.canvas-sections.pmhx.summary')
+                                                    </div>
+                                                </div>
+                                            @endif
+                                            <?php $hasPshxInCanvas = $patient->hasDataInCanvas('pshx'); ?>
+                                            @if($hasPshxInCanvas)
+                                                <div class="mt-2 border-top pt-2">
+                                                    <div class="d-flex align-items-center pb-2">
+                                                        <h6 class="my-0 font-weight-bold text-secondary">Surgical History</h6>
+                                                    </div>
+                                                    <div class="bg-light border p-2 mb-3">
+                                                        @include('app.patient.canvas-sections.pshx.summary')
+                                                    </div>
+                                                </div>
+                                            @endif
+                                            <?php $hasFhxInCanvas = $patient->hasDataInCanvas('fhx'); ?>
+                                            @if($hasFhxInCanvas)
+                                                <div class="uucol-4">
+                                                    <div class="d-flex align-items-center pb-2">
+                                                        <h6 class="my-0 font-weight-bold text-secondary">Family History</h6>
+                                                    </div>
+                                                    <div class="bg-light border p-2 mb-3">
+                                                        @include('app.patient.canvas-sections.fhx.summary')
+                                                    </div>
+                                                </div>
+                                            @endif
+                                            <?php $hasSochxInCanvas = $patient->hasDataInCanvas('sochx'); ?>
+                                            @if($hasSochxInCanvas)
+                                                <div class="uucol-4">
+                                                    <div class="d-flex align-items-center pb-2">
+                                                        <h6 class="my-0 font-weight-bold text-secondary">Social History</h6>
+                                                    </div>
+                                                    <div class="bg-light border p-2 mb-3">
+                                                        @include('app.patient.canvas-sections.sochx.summary')
+                                                    </div>
+                                                </div>
+                                            @endif
+                                        </div>
+                                    </div>
+                                @endif
+
+                                @if($isVisitTemplateBased && $doesVisitTemplateLayoutExist)
+                                    @include($visitLayoutPath)
+                                @elseif($isVisitTemplateBased && !$doesVisitTemplateUiConfigExist)
+                                    @if($note->visitTemplate->is_slim)
+                                        @include('app.patient.note.note-segment-list-slim')
+                                    @else
+                                        @include('app.patient.note.note-segment-list')
+                                    @endif
+                                @elseif($isVisitTemplateBased && $doesVisitTemplateUiConfigExist)
+                                    @include('app.patient.note.custom-visit')
+                                @else
+                                    @include('app.patient.note.note-section-list')
+                                @endif
+                            </div>
+                        </div>
+                        @if($hasRightSegments)
+                        <div class="w-70 border-left note-right-panel stag-scrollbar">
+                            <div class="min-width-700px">
+                                @include('app.patient.note.note-segment-list-rhs')
+                            </div>
+                        </div>
+                        @endif
+                    </div>
+                </div>
+
+                {{-- follow-up appt. --}}
+                <div class="pt-3 px-3 screen-only border-bottom" data-non-segment-section="Follow-up Appointment">
+                    @include('app/patient/note/follow-up-appointment')
+                </div>
+
+                <span class="d-none latest-section-ts">{{ $latestSectionTS }}</span>
+
+                <!-- handouts -->
+                <div class="p-3 border-bottom screen-only" data-non-segment-section="Handouts">
+                    <?php
+                        $handouts = Handout::where('is_active', true)->get();
+                        $clientHandouts = $patient->handouts($note);
+                    ?>
+                    @include('app.patient.handouts-list', compact('patient', 'clientHandouts', 'handouts', 'note'))
+                </div>
+
+                @if($pro->pro_type === 'ADMIN' && $note->hcpPro)
+                <div class="p-3 border-bottom mt-2 screen-only">
+                    <div class="">
+                        @include('app/patient/partials/company-pro-documents')
+                    </div>
+                </div>
+                @endif
+
+                <div class="p-3 border-bottom screen-only" data-non-segment-section="Prescriptions">
+                    @include('app.patient.prescriptions.list', compact('patient', 'note'))
+                </div>
+
+                <div class="p-3 border-bottom screen-only" data-non-segment-section="Incoming Reports">
+                    @include('app.patient.partials.incoming-reports')
+                </div>
+
+                <div class="p-3 border-bottom screen-only" data-non-segment-section="Supply Orders Summary">
+                    <div class="">
+                        <div class="d-flex align-items-center mb-2">
+                            <p class="font-weight-bold text-secondary m-0 font-size-14">Supply Orders Summary</p>
+                            <span class="mx-2 text-secondary screen-only">|</span>
+                            <a native target="_blank"
+                               class="screen-only"
+                               open-in-stag-popup
+                               update-parent
+                               mc-initer="patient-supply-orders"
+                               title="{{$patient->displayName()}} - Supply Orders"
+                               popup-style="medium"
+                               href="/patients/view/{{$patient->uid}}/supply-orders?popupmode=1&note-uid={{$note->uid}}&filter=active">
+                                Manage Supply Orders
+                            </a>
+                        </div>
+                        <div class="p-3 border">
+
+                            <p class="font-weight-bold text-secondary mb-2 mr-2">Associated with this note</p>
+                            <div>
+                                @if($supplyOrdersOnNote && count($supplyOrdersOnNote))
+                                    <table class="table table-sm table-bordered mb-0 bg-white">
+                                        <thead>
+                                        <tr class="bg-light">
+                                            <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Title</div></th>
+                                            <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Reason</div></th>
+                                            <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Created At</div></th>
+                                            <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Pro Signed?</div></th>
+                                            <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Cancelled?</div></th>
+                                            <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Shipment</div></th>
+                                        </tr>
+                                        </thead>
+                                        <tbody>
+                                        @foreach($supplyOrdersOnNote as $iSupplyOrder)
+                                            <tr class="">
+                                                <td class="px-2">
+                                                    {{ $iSupplyOrder->product->title }}
+                                                </td>
+                                                <td class="px-2">{{ $iSupplyOrder->reason }}</td>
+                                                <td class="px-2">{{ friendlier_date($iSupplyOrder->created_at) }} <i class="fas fa-info-circle text-primary" data-toggle="tooltip" data-placement="top" data-html="true" title="Created at: {{ friendlier_date_time($iSupplyOrder->created_at) }} By: {{ $iSupplyOrder->createdByPro->displayName() }}"></i> </td>
+                                                <td class="px-2">
+                                                    {{ $iSupplyOrder->is_signed_by_pro ? $iSupplyOrder->signedPro->displayName() : '-' }}
+                                                    <i class="fas fa-info-circle text-primary" data-toggle="tooltip" data-placement="top" data-html="true" title="Signed at: {{ friendlier_date_time($iSupplyOrder->pro_signed_at) }}"></i>
+                                                </td>
+                                                <td class="px-2">{{ $iSupplyOrder->is_cancelled ? 'Yes' : 'No' }}</td>
+                                                <td class="px-2">
+                                                    @if($iSupplyOrder->shipment_id)
+                                                        <i class="fa fa-building"></i>
+                                                        {{ucwords(strtolower($iSupplyOrder->shipment->status ? $iSupplyOrder->shipment->status : 'CREATED'))}}
+                                                    @elseif($iSupplyOrder->is_cleared_for_shipment)
+                                                        <span class="text-info">
+                                                        <i class="fa fa-user-nurse"></i>
+                                                        Cleared for shipment
+                                                    </span>
+                                                    @else
+                                                        <span class="text-warning-mellow">
+                                                        <i class="fa fa-user-nurse"></i>
+                                                        Not cleared for shipment
+                                                    </span>
+                                                    @endif
+                                                </td>
+                                            </tr>
+                                        @endforeach
+                                        </tbody>
+                                    </table>
+                                @else
+                                    <div class="text-secondary">-</div>
+                                @endif
+                            </div>
+
+                            <hr class="my-2">
+
+                            <p class="font-weight-bold text-secondary mb-2 mr-2">Others as of {{friendlier_date(date('Y-m-d'))}}</p>
+                            @if($otherOpenSupplyOrders && count($otherOpenSupplyOrders))
+                                <table class="table table-sm table-bordered mb-0 bg-white">
+                                    <thead>
+                                    <tr class="bg-light">
+                                        <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Title</div></th>
+                                        <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Reason</div></th>
+                                        <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Created At</div></th>
+                                        <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Pro Signed?</div></th>
+                                        <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Cancelled?</div></th>
+                                        <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Shipment</div></th>
+                                    </tr>
+                                    </thead>
+                                    <tbody>
+                                    @foreach($otherOpenSupplyOrders as $iSupplyOrder)
+                                        <tr class="">
+                                            <td class="px-2">
+                                                {{ $iSupplyOrder->product->title }}
+                                            </td>
+                                            <td class="px-2">{{ $iSupplyOrder->reason }}</td>
+                                            <td class="px-2">{{ friendlier_date_time($iSupplyOrder->created_at) }}</td>
+                                            <td class="px-2">{{ $iSupplyOrder->is_signed_by_pro ? $iSupplyOrder->signedPro->displayName() : '-' }}</td>
+                                            <td class="px-2">{{ $iSupplyOrder->is_cancelled ? 'Yes' : 'No' }}</td>
+                                            <td class="px-2">
+                                                @if($iSupplyOrder->shipment_id)
+                                                    <i class="fa fa-building"></i>
+                                                    {{ ucwords(strtolower($iSupplyOrder->shipment->status ? $iSupplyOrder->shipment->status : 'CREATED'))}}
+                                                @elseif($iSupplyOrder->is_cleared_for_shipment)
+                                                    <span class="text-info">
+                                                        <i class="fa fa-user-nurse"></i>
+                                                        Cleared for shipment
+                                                    </span>
+                                                @else
+                                                    <span class="text-warning-mellow">
+                                                        <i class="fa fa-user-nurse"></i>
+                                                        Not cleared for shipment
+                                                    </span>
+                                                @endif
+                                            </td>
+                                        </tr>
+                                    @endforeach
+                                    </tbody>
+                                </table>
+                            @else
+                                <div class="text-secondary">-</div>
+                            @endif
+
+                        </div>
+                    </div>
+                </div>
+
+                <div class="row border-bottom mx-0">
+                    <div class="col-12 px-0">
+                        <div class="p-3 screen-only h-100" data-non-segment-section="RM Setup">
+                            <div class="d-flex align-items-center mb-3">
+                                <p class="font-weight-bold text-secondary m-0 font-size-14">Remote Monitoring</p>
+                            </div>
+                            @include('app.patient.note.rm-setup')
+                        </div>
+
+                    </div>
+                </div>
+
+                <div class="p-3 border-bottom screen-only" data-non-segment-section="Vitals Settings">
+                    <div class="d-flex align-items-center mb-3">
+                        <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-4 border-right">
+                            <div class="d-flex align-items-baseline">
+                                <b>BMI/Weight Management</b>
+                                <span class="mx-2 text-secondary">|</span>
+                                @include('app.patient.vitals-settings.bmi-management-form')
+                            </div>
+                            <div class="pt-3">
+                                @include('app.patient.vitals-settings.bmi-management-summary')
+                            </div>
+                        </div>
+                        <div class="col-8">
+                            <div class="d-flex align-items-baseline">
+                                <b>BP Management</b>
+                                <span class="mx-2 text-secondary">|</span>
+                                @include('app.patient.vitals-settings.bp-management-form')
+                            </div>
+                            <div class="pt-3">
+                                @include('app.patient.vitals-settings.bp-management-summary')
+                            </div>
+                        </div>
+                    </div>
+                    <script>
+                        (function () {
+                            function calculateUsualBmi() {
+                                let h = $('#bmi-management-settings [name="currentHeightInInches"]').val(),
+                                    wMin = $('#bmi-management-settings [name="usualWeightInPoundsMin"]').val(),
+                                    wMax = $('#bmi-management-settings [name="usualWeightInPoundsMax"]').val();
+                                let bmiMinElem = $('#bmi-management-settings [name="usualBmiMin"]').val(''),
+                                    bmiMinCategoryElem = $('#bmi-management-settings [name="usualBmiMinCategory"]').val(''),
+                                    bmiMaxElem = $('#bmi-management-settings [name="usualBmiMax"]').val(''),
+                                    bmiMaxCategoryElem = $('#bmi-management-settings [name="usualBmiMaxCategory"]').val('');
+                                calculateBmi(h, wMin, bmiMinElem, bmiMinCategoryElem);
+                                calculateBmi(h, wMax, bmiMaxElem, bmiMaxCategoryElem);
+                                return false;
+                            }
+
+                            function calculateIdealBmi() {
+                                let h = $('#bmi-management-settings [name="currentHeightInInches"]').val(),
+                                    w = $('#bmi-management-settings [name="idealWeightInPounds"]').val();
+                                let bmiElem = $('#bmi-management-settings [name="idealBmi"]').val(''),
+                                    bmiCategoryElem = $('#bmi-management-settings [name="idealBmiCategory"]').val('');
+                                calculateBmi(h, w, bmiElem, bmiCategoryElem);
+                                return false;
+                            }
+
+                            function calculateBmi(h, w, bmiElem, bmiCategoryElem) {
+                                let bmi = 0,
+                                    bmiCategory = '';
+                                try {
+                                    h = +h;
+                                    w = +w;
+                                    bmi = (w / (h * h)) * 703;
+                                    bmiElem.val(bmi.toFixed(1));
+                                    if (bmi < 18.5) {
+                                        bmiCategory = '(Underweight)';
+                                    }
+                                    if (bmi >= 18.5 && bmi < 25) {
+                                        bmiCategory = '';
+                                    }
+                                    if (bmi >= 25 && bmi < 30) {
+                                        bmiCategory = '(Overweight)';
+                                    }
+                                    if (bmi >= 30) {
+                                        bmiCategory = '(Obese)';
+                                    }
+                                    bmiCategoryElem.show();
+                                    if (bmiCategory == '') {
+                                      bmiCategoryElem.hide();
+                                    }
+                                    bmiCategoryElem.val(bmiCategory);
+                                } catch (e) {
+                                    return false;
+                                }
+                            }
+
+                            function init() {
+                                $(function () {
+                                    $('[data-toggle="tooltip"]').tooltip({
+                                        html: true
+                                    })
+                                });
+                                $(document)
+                                    .off('change input paste keyup',
+                                        '#bmi-management-settings [name="currentHeightInInches"], #bmi-management-settings [name="usualWeightInPoundsMin"],  #bmi-management-settings [name="usualWeightInPoundsMax"]')
+                                    .on('change input paste keyup',
+                                        '#bmi-management-settings [name="currentHeightInInches"], #bmi-management-settings [name="usualWeightInPoundsMin"],  #bmi-management-settings [name="usualWeightInPoundsMax"]', function () {
+                                            return calculateUsualBmi();
+                                        });
+                                $(document)
+                                    .off('change input paste keyup',
+                                        '#bmi-management-settings [name="currentHeightInInches"], #bmi-management-settings [name="idealWeightInPounds"]')
+                                    .on('change input paste keyup',
+                                        '#bmi-management-settings [name="currentHeightInInches"], #bmi-management-settings [name="idealWeightInPounds"]', function () {
+                                            return calculateIdealBmi();
+                                        });
+
+                                $('#bmi-management-settings [name="currentHeightInInches"]').trigger('change');
+
+                                let parentSegment = $('#bmi-management-settings');
+                                parentSegment.find('[heightFeetInput], [heightInchesInput]').off('change input paste');
+                                parentSegment.find('[heightFeetInput], [heightInchesInput]').on('change input paste', function () {
+                                    let inches = 0;
+                                    let ft = +(parentSegment.find('[heightFeetInput]').val()),
+                                        inc = +(parentSegment.find('[heightInchesInput]').val());
+                                    inches = Math.round(ft * 12 + inc);
+                                    parentSegment.find('[name="currentHeightInInches"]').val(inches).trigger('change');
+                                });
+                            }
+
+                            addMCInitializer('vitals-settings-{{$patient->uid}}', init, '#vitals-settings-{{$patient->uid}}')
+                        }).call(window);
+                    </script>
+                </div>
+
+                <div class="px-2 pt-2 pb-1 border-bottom" data-non-segment-section="ICDs">
+                    <div class="d-flex alignt-items-start">
+                        <div class="d-flex mr-2">
+                            <p class="font-weight-bold text-secondary m-0 mr-2">ICDs</p>
+                            @include('app.patient.partials.put-rm-reasons', ['recordType' => 'NOTE', 'record' => $note])
+                        </div>
+                        <?php
+                            $noteICDData = [
+                                'icd_1' => [
+                                    'title' => 'ICD 1',
+                                    'reason' => $note->note_reason_icd1,
+                                    'description' => $note->note_reason_icd1description
+                                ],
+                                'icd_2' => [
+                                    'title' => 'ICD 2',
+                                    'reason' => $note->note_reason_icd2,
+                                    'description' => $note->note_reason_icd2description
+                                ],
+                                'icd_3' => [
+                                    'title' => 'ICD 3',
+                                    'reason' => $note->note_reason_icd3,
+                                    'description' => $note->note_reason_icd3description
+                                ],
+                                'icd_4' => [
+                                    'title' => 'ICD 4',
+                                    'reason' => $note->note_reason_icd4,
+                                    'description' => $note->note_reason_icd4description
+                                ],
+                            ];
+                        ?>
+                        <div class="d-flex align-items-start flex-wrap">
+                            <?php $emptyNoteICDs = true; ?>
+                                @foreach ($noteICDData as $noteICDKey => $noteICD)
+                                    <?php
+                                        $emptyICD = true;
+                                        if(!empty($noteICD['reason']) || !empty($noteICD['description'])){
+                                            $emptyNoteICDs = false;
+                                            $emptyICD = false;
+                                        }
+                                    ?>
+                                    @if(!$emptyICD)
+                                        <span class="badge badge-info px-2 mb-1 mr-2">{{$noteICD['reason']}} @if(!empty($noteICD['description']))({{ $noteICD['description'] }})@endif</span>
+                                    @endif
+                                @endforeach
+                            @if($emptyNoteICDs)
+                                <small class="text-dark">-</small>
+                            @endif
+                        </div>
+                    </div>
+                    @if(!empty($note->note_reason_memo))
+                        <div style="padding-left: 60px;">
+                            <small><b>Reason:</b> {{ $note->note_reason_memo }}</small>
+                        </div>
+                    @endif
+                </div>
+
+                @if($pro->pro_type === 'ADMIN')
+                <div class="p-3 border-bottom screen-only" data-non-segment-section="Bills & Claims Summary">
+                    <div>
+                        <h2 class="font-weight-bold text-secondary">Bills & Claims Summary</h2>
+                        <div class="d-flex justify-content-center align-items-start">
+                            <table class="w-25 flex-grow-1 table-bordered table-condensed table-sm table-striped">
+                                <tbody>
+                                <tr>
+                                    <td class="text-secondary">Bill Total Exp.</td>
+                                    <td>${{friendly_money($note->bill_total_expected)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">Is Billing Closed</td>
+                                    <td>{{$note->is_bill_closed ? 'Yes' : 'No'}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">Bill Summary</td>
+                                    <td>{{$note->bill_summary ? $note->bill_summary : '-'}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">Bill Total Paid</td>
+                                    <td>${{friendly_money($note->bill_total_paid)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">Billing Closed At</td>
+                                    <td>{{friendlier_date_time($note->bill_closed_at)}}</td>
+                                </tr>
+                                </tbody>
+                            </table>
+                            <table class="w-25 flex-grow-1 table-bordered table-condensed table-sm table-striped ml-2">
+                                <tbody>
+                                <tr>
+                                    <td class="text-secondary">Claim Total Exp.</td>
+                                    <td>${{friendly_money($note->claim_total_expected)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">Is Claiming Closed</td>
+                                    <td>{{$note->is_claim_closed ? 'Yes' : 'No'}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">Claim Summary</td>
+                                    <td>{{$note->claim_summary ? $note->claim_summary : '-'}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">Claim Total Paid</td>
+                                    <td>${{friendly_money($note->claim_total_paid)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">Claiming Closed At</td>
+                                    <td>{{$note->claim_closed_at ? friendlier_date_time($note->claim_closed_at) : '-'}}</td>
+                                </tr>
+                                </tbody>
+                            </table>
+                            <table class="w-25 flex-grow-1 table-bordered table-condensed table-sm table-striped ml-2">
+                                <tbody>
+                                <tr>
+                                    <td class="text-secondary">HCP Bill Total Exp.</td>
+                                    <td>${{friendly_money($note->hcp_bill_total_expected)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">NA Bill Total Exp.</td>
+                                    <td>${{friendly_money($note->na_bill_total_expected)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">RMM Bill Total Exp.</td>
+                                    <td>${{friendly_money($note->rmm_bill_total_expected)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">RME Bill Total Exp.</td>
+                                    <td>${{friendly_money($note->rme_bill_total_expected)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">RMS Bill Total Exp.</td>
+                                    <td>${{friendly_money($note->rms_bill_total_expected)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">RMG Bill Total Exp.</td>
+                                    <td>${{friendly_money($note->rmg_bill_total_expected)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">CM Bill Total Exp.</td>
+                                    <td>${{friendly_money($note->cm_bill_total_expected)}}</td>
+                                </tr>
+                                </tbody>
+                            </table>
+                            <table class="w-25 flex-grow-1 table-bordered table-condensed table-sm table-striped ml-2">
+                                <tbody>
+                                <tr>
+                                    <td class="text-secondary">HCP Bill Total Paid</td>
+                                    <td>${{friendly_money($note->hcp_bill_total_paid)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">NA Bill Total Paid</td>
+                                    <td>${{friendly_money($note->na_bill_total_paid)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">RMM Bill Total Paid</td>
+                                    <td>${{friendly_money($note->rmm_bill_total_paid)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">RME Bill Total Paid</td>
+                                    <td>${{friendly_money($note->rme_bill_total_paid)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">RMS Bill Total Paid</td>
+                                    <td>${{friendly_money($note->rms_bill_total_paid)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">RMG Bill Total Paid</td>
+                                    <td>${{friendly_money($note->rmg_bill_total_paid)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">CM Bill Total Paid</td>
+                                    <td>${{friendly_money($note->cm_bill_total_paid)}}</td>
+                                </tr>
+<!--                                <tr>
+                                    <td class="text-secondary">HCP Company Pro</td>
+                                    <td>{{$note->hcp_company_pro_id}}</td>
+                                </tr>-->
+                                </tbody>
+                            </table>
+                        </div>
+                    </div>
+                </div>
+                @endif
+
+                {{-- companyPro, payer and location --}}
+                @if($note->method === 'IN_CLINIC' || $pro->pro_type === 'ADMIN')
+                <div class="p-3 border-bottom screen-only" data-non-segment-section="Pro/Payer Settings">
+                    <div class="ml-auto d-flex align-items-center">
+
+                        <div class="d-inline-flex align-items-center">
+                            <span class="text-secondary font-weight-bold">Company Pro:&nbsp;</span>
+                            <b>{{$note->hcpCompanyPro && $note->hcpCompanyPro->company ? $note->hcpCompanyPro->pro->displayName() . ' / ' . $note->hcpCompanyPro->company->name : '-'}}</b>
+                            @if($note->hcpCompanyPro && $note->hcpCompanyPro->company)
+                                <div moe class="ml-1">
+                                    <a class="text-danger" href="" show start><i class="fa fa-trash-alt"></i></a>
+                                    <form url="/api/note/wipeHcpCompanyPro">
+                                        <input type="hidden" name="uid" value="{{$note->uid}}">
+                                        <p>Wipe company pro from this note?</p>
+                                        <div class="mb-0">
+                                            <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                        </div>
+                                    </form>
+                                </div>
+                            @else
+                                <div moe class="ml-1">
+                                    <a class="text-primary" href="" show start><i class="fa fa-edit"></i></a>
+                                    <form url="/api/note/putHcpCompanyPro">
+                                        <input type="hidden" name="uid" value="{{$note->uid}}">
+                                        <div class="mb-2">
+                                            <select name="hcpCompanyProUid" class="form-control form-control-sm">
+                                                <option value="">-- select --</option>
+                                                @foreach($note->hcpPro->companyPros as $companyPro)
+                                                    <option value="{{$companyPro->uid}}">{{$companyPro->pro->displayName() . ' / ' . $companyPro->company->name}}</option>
+                                                @endforeach
+                                            </select>
+                                        </div>
+                                        <div class="mb-0">
+                                            <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                        </div>
+                                    </form>
+                                </div>
+                            @endif
+                        </div>
+
+                        @if($note->hcpCompanyPro && $note->hcpCompanyPro->company)
+                            <span class="mx-2 text-secondary">|</span>
+                            <div class="d-inline-flex align-items-center">
+                                <span class="text-secondary font-weight-bold">Payer 1°:&nbsp;</span>
+                                <b>
+                                    {{$note->hcpCompanyProPayer && $note->hcpCompanyProPayer->payer ? $note->hcpCompanyProPayer->payer->name : '-'}}
+                                </b>
+                                @if($note->hcpCompanyProPayer && $note->hcpCompanyProPayer->payer)
+                                    <div moe class="ml-1">
+                                        <a class="text-danger" href="" show start><i class="fa fa-trash-alt"></i></a>
+                                        <form url="/api/note/wipeHcpCompanyProPayer">
+                                            <input type="hidden" name="uid" value="{{$note->uid}}">
+                                            <p>Wipe payer from this note?</p>
+                                            <div class="mb-0">
+                                                <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                            </div>
+                                        </form>
+                                    </div>
+                                @else
+                                    <div moe class="ml-1">
+                                        <a class="text-primary" href="" show start><i class="fa fa-edit"></i></a>
+                                        <form url="/api/note/putHcpCompanyProPayer">
+                                            <input type="hidden" name="uid" value="{{$note->uid}}">
+                                            <div class="mb-2">
+                                                <select name="hcpCompanyProPayerUid" class="form-control form-control-sm">
+                                                    <option value="">-- select --</option>
+                                                    @foreach($note->hcpCompanyPro->companyProPayers as $companyProPayer)
+                                                        <option value="{{$companyProPayer->uid}}">{{$companyProPayer->payer->name}}</option>
+                                                    @endforeach
+                                                </select>
+                                            </div>
+                                            <div class="mb-0">
+                                                <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                            </div>
+                                        </form>
+                                    </div>
+                                @endif
+                            </div>
+
+                            <span class="mx-2 text-secondary">|</span>
+                            <span>
+                                <span class="text-secondary font-weight-bold">Payer 2°: </span>
+                            </span>
+
+                            <span class="mx-2 text-secondary">|</span>
+                            <div class="d-inline-flex align-items-center">
+                                <span class="text-secondary font-weight-bold">Location:&nbsp;</span><b>{{$note->hcpCompanyLocation ? $note->hcpCompanyLocation->line1 . ', ' . $note->hcpCompanyLocation->city : '-'}}</b>
+                                @if($note->hcpCompanyLocation)
+                                    <div moe class="ml-1">
+                                        <a class="text-danger" href="" show start><i class="fa fa-trash-alt"></i></a>
+                                        <form url="/api/note/wipeHcpCompanyLocation">
+                                            <input type="hidden" name="uid" value="{{$note->uid}}">
+                                            <p>Wipe location from this note?</p>
+                                            <div class="mb-0">
+                                                <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                            </div>
+                                        </form>
+                                    </div>
+                                @else
+                                    <div moe class="ml-1">
+                                        <a class="text-primary" href="" show start><i class="fa fa-edit"></i></a>
+                                        <form url="/api/note/putHcpCompanyLocation">
+                                            <input type="hidden" name="uid" value="{{$note->uid}}">
+                                            <div class="mb-2">
+                                                <select name="hcpCompanyLocationUid" class="form-control form-control-sm">
+                                                    <option value="">-- select --</option>
+                                                    @if($note->hcpCompany && $note->hcpCompany->locations)
+                                                        @foreach($note->hcpCompany->locations as $location)
+                                                            <option value="{{$location->uid}}">{{$location->line1 . ', ' . $location->city}}</option>
+                                                        @endforeach
+                                                    @endif
+                                                </select>
+                                            </div>
+                                            <div class="mb-0">
+                                                <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                            </div>
+                                        </form>
+                                    </div>
+                                @endif
+                            </div>
+                        @endif
+                        <span class="mx-2 text-secondary">|</span>
+                        <div class="d-inline-flex align-items-center">
+                            <span class="text-secondary font-weight-bold">Primary Coverage:&nbsp;</span>
+                            <b>@include('app.patient.coverage_column_renderer', ['patient'=>$patient, 'truncateName' => true])</b>
+                        </div>
+                    </div>
+                </div>
+                @endif
+
+                {{-- bills --}}
+                @if($pro->pro_type === 'ADMIN' || ($note->hcpPro && $pro->id === $note->hcpPro->id))
+                    <div class="screen-only" data-non-segment-section="HCP Bills">
+                    @if($note->bills->count())
+                        <div class="p-3 border-bottom">
+                    <div class="d-flex align-items-center mb-2">
+                        <p class="font-weight-bold text-secondary font-size-13 m-0">Bills</p>
+                        @if($pro->pro_type === 'ADMIN' || ($note->hcpPro && $pro->id === $note->hcpPro->id))
+                            @include('app/patient/note/_create-bill')
+                        @endif
+                    </div>
+
+                    @if($pro->pro_type === 'ADMIN')
+                    <table class="table table-sm tabe-striped mb-0 table-bordered">
+                        <thead class="bg-light">
+                        <tr class="text-secondary">
+                            <?php /* <th class="border-bottom-0"></th> */ ?>
+                            <th class="border-bottom-0">Date</th>
+                            <th class="border-bottom-0">Service</th>
+                            <th class="border-bottom-0">Billable</th>
+                            <th class="border-bottom-0">HCP</th>
+                            <th class="border-bottom-0 screen-only">Total</th>
+                            <th class="border-bottom-0">Sign</th>
+                            <th class="border-bottom-0 screen-only">Bal Post Date</th>
+                            <th class="border-bottom-0">Verification</th>
+                            <th class="border-bottom-0">Cancellation</th>
+                            <th class="border-bottom-0 screen-only">Payment</th>
+                        </tr>
+                        </thead>
+                        <tbody>
+                        @foreach ($note->bills as $bill)
+                            <tr class="{{$bill->is_cancelled ? 'bg-light text-secondary' : ''}}">
+                                <?php /* <td class="p-0">
+                                    <table class="table-striped table-sm table-condensed border border-left-0 border-top-0 border-bottom-0">
+                                        <tbody>
+                                            <tr><td>collected_amount</td><td>{{$bill->collected_amount}}</td></tr>
+                                            <tr><td>effective_date</td><td>{{$bill->effective_date}}</td></tr>
+                                            <tr><td>has_hcp_been_paid</td><td>{{$bill->has_hcp_been_paid}}</td></tr>
+                                            <tr><td>hcp_expected_payment_amount</td><td>{{$bill->hcp_expected_payment_amount}}</td></tr>
+                                            <tr><td>hcp_payment_amount</td><td>{{$bill->hcp_payment_amount}}</td></tr>
+                                            <tr><td>is_cancelled</td><td>{{$bill->is_cancelled}}</td></tr>
+                                            <tr><td>hcp_payment_pro_transaction_id</td><td>{{$bill->hcp_payment_pro_transaction_id}}</td></tr>
+                                            <tr><td>balance_post_date</td><td>{{$bill->balance_post_date}}</td></tr>
+                                            <tr><td>is_verified</td><td>{{$bill->is_verified}}</td></tr>
+                                            <tr><td>is_cancellation_acknowledged</td><td>{{$bill->is_cancellation_acknowledged}}</td></tr>
+                                            <tr><td>is_cancelled_by_administrator</td><td>{{$bill->is_cancelled_by_administrator}}</td></tr>
+                                            <tr><td>total_expected</td><td>{{$bill->total_expected}}</td></tr>
+                                            <tr><td>total_paid</td><td>{{$bill->total_paid}}</td></tr>
+                                        </tbody>
+                                    </table>
+                                </td> */ ?>
+                                <td class="text-nowrap">{{friendlier_date_time($bill->effective_date, false)}}</td>
+                                <td>{{$bill->code}}</td>
+                                <td class="">
+                                    @if(strpos(strtolower($bill->code), 'treatment services') !== FALSE)
+                                        <?php
+                                        $totalSeconds = $bill->number_of_units * 3600;
+                                        $remainder = $totalSeconds % 60;
+                                        if ($remainder !== 0) {
+                                            if ($remainder < 30) {
+                                                $totalSeconds = $totalSeconds - $remainder;
+                                            } else {
+                                                $totalSeconds = $totalSeconds + (60 - $remainder);
+                                            }
+                                        }
+                                        ?>
+                                        {{ time_in_hrminsec($totalSeconds) }}
+                                    @else
+                                        @if(!!$bill->number_of_units)
+                                            {{ $bill->number_of_units }} unit(s)
+                                        @else
+                                            -
+                                        @endif
+                                    @endif
+                                </td>
+                                <td class="">
+                                    <div class="text-nowrap font-weight-bold text-secondary">{{ $bill->hcp->displayName() }} (HCP)</div>
+                                    <div class="text-nowrap mt-1 screen-only">
+                                        <span class="text-secondary">Paid: </span>
+                                        <span>{{ $bill->has_hcp_been_paid ? 'Yes' : 'No' }}</span>
+                                    </div>
+                                    @if(!$bill->has_hcp_been_paid)
+                                        <div class="text-nowrap mt-1 screen-only">
+                                            <span class="text-secondary">Expected: </span>
+                                            <span class="font-weight-bold">${{ $bill->hcp_expected_payment_amount }}</span>
+                                        </div>
+                                    @else
+                                        <div class="text-nowrap mt-1 screen-only">
+                                            <span class="text-secondary">Amount: </span>
+                                            <span class="font-weight-bold">${{ $bill->hcp_payment_amount }}</span>
+                                        </div>
+                                    @endif
+                                    @if($bill->ally && !!floatval($bill->na_expected_payment_amount))
+                                        <hr>
+                                        <div class="text-nowrap font-weight-bold text-secondary">{{ $bill->ally->displayName() }} (NA)</div>
+                                        <div class="text-nowrap mt-1 screen-only">
+                                            <span class="text-secondary">Paid: </span>
+                                            <span>{{ $bill->has_na_been_paid ? 'Yes' : 'No' }}</span>
+                                        </div>
+                                        @if(!$bill->has_na_been_paid)
+                                            <div class="text-nowrap mt-1 screen-only">
+                                                <span class="text-secondary">Expected: </span>
+                                                <span class="font-weight-bold">${{ $bill->na_expected_payment_amount }}</span>
+                                            </div>
+                                        @else
+                                            <div class="text-nowrap mt-1 screen-only">
+                                                <span class="text-secondary">Amount: </span>
+                                                <span class="font-weight-bold">${{ $bill->na_payment_amount }}</span>
+                                            </div>
+                                        @endif
+                                    @endif
+
+                                    @if($pro->pro_type === 'ADMIN')
+                                        <b>{{$bill->hcpCompanyPro && $bill->hcpCompanyPro->company ? $bill->hcpCompanyPro->pro->displayName() . ' / ' . $bill->hcpCompanyPro->company->name : '-'}}</b>
+                                        <div moe class="ml-1">
+                                            <a class="text-primary" href="" show start>Swap HCP Company Pro</a>
+                                            <form url="/api/bill/swapHcpCompanyPro">
+                                                <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                <div class="mb-2">
+                                                    <select name="hcpCompanyProUid" class="form-control form-control-sm">
+                                                        <option value="">-- select --</option>
+                                                        @foreach($bill->hcp->companyPros as $companyPro)
+                                                            <option value="{{$companyPro->uid}}">{{$companyPro->pro->displayName() . ' / ' . $companyPro->company->name}}</option>
+                                                        @endforeach
+                                                    </select>
+                                                </div>
+                                                <div class="mb-0">
+                                                    <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                </div>
+                                            </form>
+                                        </div>
+                                    @endif
+                                    <div>
+                                        @include('app.patient.note.flag-bill')
+                                    </div>
+
+                                </td>
+                                <td class="pr-3 screen-only">
+                                    @if($bill->has_hcp_been_paid)
+                                        <span class="text-secondary">Paid. </span>
+                                        <span class="font-weight-bold">${{ friendly_money($bill->total_paid) }}</span>
+                                    @else
+                                        <span class="text-secondary">Exp. </span>
+                                        <span class="font-weight-bold">{{ $bill->total_expected ? '$' . friendly_money($bill->total_expected) : '-' }}</span>
+                                    @endif
+                                </td>
+                                <td>
+                                    @if(!$bill->is_cancelled)
+                                        @if($bill->is_signed_by_hcp)
+                                            <span class="d-block text-secondary text-nowrap">
+                                                    <i class="fa fa-check"></i>
+                                                    HCP Signed
+                                                </span>
+                                        @else
+                                            <span moe
+                                                  class="d-block {{ $bill->hcp_pro_id !== $pro->id ? 'moe-disabled' : '' }}"
+                                                  title="{{ $bill->hcp_pro_id !== $pro->id ? 'Only the bill\'s HCP can sign' : '' }}">
+                                                <a class="" href="" show start>Sign As HCP</a>
+                                                <form url="/api/bill/signAsHcp">
+                                                    <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                    <p>Sign this bill as HCP?</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>
+                                            </span>
+                                        @endif
+
+                                        @if($bill->is_signed_by_na)
+                                            <span class="d-block text-secondary text-nowrap">
+                                                <i class="fa fa-check"></i>
+                                                NA Signed
+                                            </span>
+                                        @else
+                                            <span moe
+                                                  class="d-block {{ $bill->na_pro_id !== $pro->id ? 'moe-disabled' : '' }}"
+                                                  title="{{ $bill->na_pro_id !== $pro->id ? 'Only the bill\'s NA can sign' : '' }}">
+                                                <a class="" href="" show start>Sign As NA</a>
+                                                <form url="/api/bill/signAsNa">
+                                                    <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                    <p>Sign this bill as NA?</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>
+                                            </span>
+                                        @endif
+                                    @endif
+                                </td>
+                                <td class="screen-only">
+                                    @if(!$bill->is_cancelled)
+                                        <span class="d-block" moe>
+                                            <a class="" href="" show start>
+                                                {{$bill->balance_post_date ? friendlier_date_time($bill->balance_post_date, false) : '(not set)' }}
+                                            </a>
+                                            <form url="/api/bill/updateBalancePostDate">
+                                                <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                <p>Update Balance Post Date</p>
+                                                <div class="mb-0">
+                                                    <input type="date" class="text form-control form-control-sm"
+                                                           name="balancePostDate"
+                                                           value="{{$bill->balance_post_date}}"
+                                                           placeholder="balance post date"><br>
+                                                    <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                    <button class="btn btn-default border btn-sm"
+                                                            cancel>Cancel</button>
+                                                </div>
+                                            </form>
+                                        </span>
+                                    @endif
+                                </td>
+                                <td> <!-- verification -->
+                                    @if($pro->pro_type === 'ADMIN' && !$bill->is_cancelled)
+                                        @if(!$bill->is_verified)
+                                            <div class="text-warning-mellow font-weight-bold">Not Verified</div>
+                                            <span class="d-block mt-1" moe>
+                                                <a href="" show start>Mark Verified</a>
+                                                <form url="/api/bill/markAsVerified">
+                                                    <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                    <p>Mark As Verfified?</p>
+                                                    <div class="mb-0">
+                                                        <button class="btn btn-primary btn-sm"
+                                                                submit>Submit</button>
+                                                        <button class="btn btn-default border btn-sm"
+                                                                cancel>Cancel</button>
+                                                    </div>
+                                                </form>
+                                            </span>
+                                        @else
+                                            <div class="text-success font-weight-bold"><i class="fa fa-check"></i> Verifiedxxxx</div>
+                                            <span class="d-block mt-1" moe>
+                                                <a class="" href="" show start>Undo</a>
+                                                <form url="/api/bill/undoMarkAsVerified">
+                                                    <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                    <p>Undo Mark As Verfified?</p>
+                                                    <div class="mb-0">
+                                                        <button class="btn btn-primary btn-sm"
+                                                                submit>Submit</button>
+                                                        <button class="btn btn-default border btn-sm"
+                                                                cancel>Cancel</button>
+                                                    </div>
+                                                </form>
+                                            </span>
+                                        @endif
+                                    @endif
+                                </td>
+                                <td>  <!-- cancellation -->
+                                    @if($bill->is_cancelled)
+                                        <div class="text-warning-mellow font-weight-bold">Cancelled</div>
+                                        @if($bill->cancellation_memo)
+                                            <div class="text-dark text-sm font-italic my-1">{{$bill->cancellation_memo}}</div>
+                                        @endif
+                                        @if($bill->is_cancelled_by_administrator)
+                                            <div class="text-secondary text-sm">(by Administrator)</div>
+                                        @endif
+                                        <div moe class="mt-1">
+                                            <a class="" href="" show start>Update Memo</a>
+                                            <form url="/api/bill/updateCancellationMemo">
+                                                <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                <p>Update Cancellation Memo</p>
+                                                <div class="mb-2">
+                                                    <textarea class="text form-control form-control-sm"
+                                                              name="cancellationMemo"
+                                                              placeholder="">{{$bill->cancellation_memo ? $bill->cancellation_memo : 'Please contact billing.'}}</textarea>
+                                                </div>
+                                                <div>
+                                                    <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                    <button class="btn btn-default border btn-sm"
+                                                            cancel>Cancel</button>
+                                                </div>
+                                            </form>
+                                        </div>
+                                    @else
+                                        <span class="d-block" moe relative="">
+                                            <a class="text-danger" href="" show start>Cancel</a>
+                                            <form url="/api/bill/markCancelled" right="">
+                                                <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                <p class="mb-2">Cancel this bill?</p>
+                                                <div class="mb-2">
+                                                    <label class="mb-1 text-secondary">Cancellation Memo</label>
+                                                    <textarea type="text" name="memo" placeholder="Memo"
+                                                              class="form-control form-control-sm">Please contact billing.</textarea>
+                                                </div>
+                                                <div class="mb-0">
+                                                    <button class="btn btn-danger btn-sm" submit>Yes</button>
+                                                    <button class="btn btn-default border btn-sm" cancel>No</button>
+                                                </div>
+                                            </form>
+                                        </span>
+                                    @endif
+
+                                    @if($bill->is_cancelled && !$bill->is_cancellation_acknowledged)
+                                        <div class="mt-2 text-secondary">
+                                            <i class="fa fa-exclamation-triangle"></i>
+                                            Not Ack.
+                                        </div>
+                                        <div class="d-block mt-1" moe>
+                                            <a class="" href="" show start>Ack. Cancellation</a>
+                                            <form url="/api/bill/acknowledgeCancellation">
+                                                <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                <p>Acknowledge Cancellation?</p>
+                                                <div class="mb-0">
+                                                    {{--<input type="text" class="text form-control form-control-sm" name="cancellationMemo" value="{{$bill->cancellation_memo}}" placeholder=""><br>--}}
+                                                    <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                    <button class="btn btn-default border btn-sm"
+                                                            cancel>Cancel</button>
+                                                </div>
+                                            </form>
+                                        </div>
+                                    @endif
+
+                                    @if($bill->is_cancellation_acknowledged && !$note->is_billing_marked_done)
+                                        <div class="mt-2 text-secondary">
+                                            <i class="fa fa-check"></i>
+                                            Ack.
+                                        </div>
+                                        <div class="d-block mt-1" moe>
+                                            <a class="" href="" show start>Undo Cancellation Ack.</a>
+                                            <form url="/api/bill/undoAcknowledgeCancellation">
+                                                <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                <p>Undo Acknowledge Cancellation?</p>
+                                                <div class="mb-0">
+                                                    <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                    <button class="btn btn-default border btn-sm"
+                                                            cancel>Cancel</button>
+                                                </div>
+                                            </form>
+                                        </div>
+                                    @endif
+
+                                </td>
+                                <td class="screen-only"> <!-- submit payment -->
+                                    <div class="my-1">
+                                        @if(!$bill->is_cancelled && !$bill->has_hcp_been_paid )
+                                            @if(+$bill->hcp_expected_payment_amount && $bill->is_signed_by_hcp)
+                                                <span class="d-block" moe relative="">
+                                                    <a class="font-weight-bold" href="" show start>Submit Payment For HCP</a>
+                                                    <form url="/api/bill/payHcpAmount" right>
+                                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                        <p>Submit Payment</p>
+                                                        <div class="mb-0">
+                                                            <input type="text"
+                                                                   class="text form-control form-control-sm"
+                                                                   name="hcpPaymentAmount"
+                                                                   value="{{$bill->hcp_expected_payment_amount}}"
+                                                                   placeholder="amount"><br>
+                                                            <button class="btn btn-primary btn-sm"
+                                                                    submit>Submit</button>
+                                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                        </div>
+                                                    </form>
+                                                </span>
+                                            @else
+                                                @if(!+$bill->hcp_expected_payment_amount)
+                                                    <div class="mb-1 text-danger">
+                                                        <i class="fa fa-exclamation-triangle"></i>
+                                                        HCP expected amount is invalid
+                                                    </div>
+                                                @endif
+                                                @if(!$bill->is_signed_by_hcp)
+                                                    <div class="mb-1 text-danger">
+                                                        <i class="fa fa-exclamation-triangle"></i>
+                                                        HCP has not signed the bill
+                                                    </div>
+                                                @endif
+                                            @endif
+                                        @endif
+                                    </div>
+                                    <div class="my-1">
+                                        @if(!$bill->is_cancelled && !$bill->has_na_been_paid && $bill->ally)
+                                            @if(+$bill->na_expected_payment_amount && $bill->is_signed_by_na)
+                                                <span class="d-block" moe relative="">
+                                                    <a class="font-weight-bold" href="" show start>Submit Payment For NA</a>
+                                                    <form url="/api/bill/payNaAmount" right>
+                                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                        <p>Submit Payment For NA</p>
+                                                        <div class="mb-0">
+                                                            <input type="text"
+                                                                   class="text form-control form-control-sm"
+                                                                   name="naPaymentAmount"
+                                                                   value="{{$bill->na_expected_payment_amount}}"
+                                                                   placeholder="amount"><br>
+                                                            <button class="btn btn-primary btn-sm"
+                                                                    submit>Submit</button>
+                                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                        </div>
+                                                    </form>
+                                                </span>
+                                            @else
+                                                @if(!+$bill->na_expected_payment_amount)
+                                                    <div class="mb-1 text-danger">
+                                                        <i class="fa fa-exclamation-triangle"></i>
+                                                        NA expected amount is invalid
+                                                    </div>
+                                                @endif
+                                                @if(!$bill->is_signed_by_na)
+                                                    <div class="mb-1 text-danger">
+                                                        <i class="fa fa-exclamation-triangle"></i>
+                                                        NA has not signed the bill
+                                                    </div>
+                                                @endif
+                                            @endif
+                                        @endif
+                                    </div>
+                                </td>
+                            </tr>
+                        @endforeach
+                        </tbody>
+                    </table>
+                            @elseif($note->hcpPro && $pro->id === $note->hcpPro->id)
+                                <table class="table table-sm tabe-striped mb-3 border-left border-right border-bottom">
+                        <thead class="bg-light">
+                        <tr>
+                            <th class="border-bottom-0 pl-3">HCP</th>
+                            @if($note->ally_pro_id === $pro->id)
+                                <th class="border-bottom-0 pl-3">NA</th>
+                            @endif
+                            <th class="border-bottom-0 w-25 pl-3">Service</th>
+                            {{--<th class="border-bottom-0 w-25 pl-2">Reason</th>--}}
+                            <th class="border-bottom-0 pl-3">Billable</th>
+                            <th class="border-bottom-0 pl-2">Amount</th>
+                            <th class="border-bottom-0 pl-2">Verification</th>
+                            <th class="border-bottom-0"></th>
+                        </tr>
+                        </thead>
+                        <tbody>
+                        @foreach ($note->bills as $bill)
+                            <tr>
+                                <td class="pl-3">{{ $bill->hcp->displayName() }}</td>
+                                @if($note->ally_pro_id === $pro->id)
+                                    <td class="pl-3">{{ $note->allyPro->displayName() }}</td>
+                                @endif
+                                <td class="pl-3 {{ $bill->is_cancelled ? 'text-secondary' : '' }}">{{$bill->code}}</td>
+                                {{--<td class="pl-2">
+                                    {{ $bill->reason1 }}
+                                    <div class="text-secondary small">{{ $bill->reason2 }}</div>
+                                </td>--}}
+                                <td class="pl-3">
+                                    @if(strpos(strtolower($bill->code), 'treatment services') !== FALSE)
+                                        <?php
+                                        $totalSeconds = $bill->number_of_units * 3600;
+                                        $remainder = $totalSeconds % 60;
+                                        if ($remainder !== 0) {
+                                            if ($remainder < 30) {
+                                                $totalSeconds = $totalSeconds - $remainder;
+                                            } else {
+                                                $totalSeconds = $totalSeconds + (60 - $remainder);
+                                            }
+                                        }
+                                        ?>
+                                        {{ time_in_hrminsec($totalSeconds) }}
+                                    @else
+                                        @if(!!$bill->number_of_units)
+                                            {{ $bill->number_of_units }} unit(s)
+                                        @else
+                                            -
+                                        @endif
+                                    @endif
+                                </td>
+                                <td class="pl-2">
+                                    @if($bill->hcp_pro_id === $pro->id)
+                                        @if($bill->has_hcp_been_paid)
+                                            <span class="text-dark">Processed:</span><span
+                                                    class="font-weight-bold text-success ml-2">${{ $bill->hcp_payment_amount }}</span>
+                                        @else
+                                            <span class="text-dark">Expected:</span><span
+                                                    class="font-weight-bold text-dark ml-2">{{ $bill->hcp_expected_payment_amount ? '$' . $bill->hcp_expected_payment_amount : '-' }}</span>
+                                        @endif
+                                    @elseif($bill->na_pro_id === $pro->id)
+                                        @if($bill->has_na_been_paid)
+                                            <span class="text-dark">Processed:</span><span
+                                                    class="font-weight-bold text-success ml-2">${{ $bill->na_payment_amount }}</span>
+                                        @else
+                                            <span class="text-dark">Expected:</span><span
+                                                    class="font-weight-bold text-dark ml-2">{{ $bill->na_expected_payment_amount ? '$' . $bill->na_expected_payment_amount : '-' }}</span>
+                                        @endif
+                                    @endif
+                                </td>
+                                <td class="pl-2">
+                                    @if(!$bill->is_cancelled)
+                                        @if(!$bill->is_verified)
+                                            <div class="text-warning-mellow font-weight-bold">Not Verified</div>
+                                        @else
+                                            <div class="text-info font-weight-bold"><i class="fa fa-check"></i> Verified</div>
+                                        @endif
+                                    @endif
+                                </td>
+                                <td>
+                                    <div class="d-flex align-items-center">
+                                        @if(!$bill->is_cancelled)
+                                            @if($bill->is_signed_by_hcp)
+                                                <span class="d-block text-secondary">
+                                                    <i class="fa fa-check"></i>
+                                                    HCP Signed
+                                                </span>
+                                            @else
+                                                <span moe
+                                                      class="d-block {{ $bill->hcp_pro_id !== $pro->id ? 'moe-disabled' : '' }}"
+                                                      title="{{ $bill->hcp_pro_id !== $pro->id ? 'Only the bill\'s HCP can sign' : '' }}">
+                                                    <a class="" href="" show start>Sign as HCP</a>
+                                                    <form url="/api/bill/signAsHcp">
+                                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                        <p>Sign this bill as HCP?</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>
+                                                </span>
+                                            @endif
+                                            @if($bill->na_pro_id === $pro->id)
+                                                <span class="mx-2 text-secondary">|</span>
+                                                @if($bill->is_signed_by_na)
+                                                    <span class="d-block text-secondary">
+                                                        <i class="fa fa-check"></i>
+                                                        NA Signed
+                                                    </span>
+                                                @else
+                                                    <span moe
+                                                          class="d-block {{ $bill->na_pro_id !== $pro->id ? 'moe-disabled' : '' }}"
+                                                          title="{{ $bill->hcp_pro_id !== $pro->id ? 'Only the bill\'s NA can sign' : '' }}">
+                                                        <a class="" href="" show start>Sign as NA</a>
+                                                        <form url="/api/bill/signAsNa">
+                                                            <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                            <p>Sign this bill as NA?</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>
+                                                    </span>
+                                                @endif
+                                            @endif
+                                        @endif
+                                        @if(!$bill->has_hcp_been_paid && $pro->pro_type === 'ADMIN')
+                                            <span class="mx-2 text-secondary">|</span>
+                                            <span class="d-block" moe>
+                                                <a class="text-danger" href="" show start>Submit Payment</a>
+                                                <form url="/api/bill/payHcpAmount">
+                                                    <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                    <p>Submit payment:</p>
+                                                    <div class="mb-0">
+                                                        <input type="text" class="text form-control form-control-sm"
+                                                               name="hcpPaymentAmount"
+                                                               value="{{$bill->hcp_expected_payment_amount}}"
+                                                               placeholder="amount"><br>
+                                                        <button class="btn btn-primary btn-sm"
+                                                                submit>Submit</button>
+                                                        <button class="btn btn-default border btn-sm"
+                                                                cancel>Cancel</button>
+                                                    </div>
+                                                </form>
+                                            </span>
+                                        @endif
+                                        @if(!$bill->has_na_been_paid && $bill->ally && $pro->pro_type === 'ADMIN')
+                                            <span class="d-block" moe relative="">
+                                                <a class="font-weight-bold" href="" show
+                                                   start>Submit Payment For NA</a>
+                                                <form url="/api/bill/payNaAmount" right>
+                                                    <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                    <p>Submit Payment For NA</p>
+                                                    <div class="mb-0">
+                                                        <input type="text" class="text form-control form-control-sm"
+                                                               name="naPaymentAmount"
+                                                               value="{{$bill->na_expected_payment_amount}}"
+                                                               placeholder="amount"><br>
+                                                        <button class="btn btn-primary btn-sm"
+                                                                submit>Submit</button>
+                                                        <button class="btn btn-default border btn-sm"
+                                                                cancel>Cancel</button>
+                                                    </div>
+                                                </form>
+                                            </span>
+                                        @endif
+                                        @if($bill->is_cancelled)
+                                            <span class="mx-2 text-secondary">|</span>
+                                            <span class="d-block text-secondary">
+                                                Cancelled
+                                            </span>
+                                            @if($bill->is_cancelled && !$bill->is_cancellation_acknowledged)
+                                                <div class="ml-2 text-secondary">
+                                                    <i class="fa fa-exclamation-triangle"></i>
+                                                    Not Ack.
+                                                </div>
+                                                <div class="d-block ml-2" moe>
+                                                    <a class="" href="" show start>Ack. Cancellation</a>
+                                                    <form url="/api/bill/acknowledgeCancellation">
+                                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                        <p>Acknowledge Cancellation?</p>
+                                                        <div class="mb-0">
+                                                            {{--<input type="text" class="text form-control form-control-sm" name="cancellationMemo" value="{{$bill->cancellation_memo}}" placeholder=""><br>--}}
+                                                            <button class="btn btn-primary btn-sm"
+                                                                    submit>Submit</button>
+                                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                        </div>
+                                                    </form>
+                                                </div>
+                                            @endif
+
+                                            @if($bill->is_cancellation_acknowledged && !$note->is_billing_marked_done)
+                                                <div class="ml-2 text-secondary">
+                                                    <i class="fa fa-check"></i>
+                                                    Ack.
+                                                </div>
+                                                <div class="d-block ml-2" moe>
+                                                    <a class="" href="" show start>Undo</a>
+                                                    <form url="/api/bill/undoAcknowledgeCancellation">
+                                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                        <p>Undo Acknowledge Cancellation?</p>
+                                                        <div class="mb-0">
+                                                            <button class="btn btn-primary btn-sm"
+                                                                    submit>Submit</button>
+                                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                        </div>
+                                                    </form>
+                                                </div>
+                                            @endif
+                                        @else
+                                            <span class="mx-2 text-secondary">|</span>
+                                            <span class="d-block" moe>
+                                                <a class="text-danger" href="" show start>Cancel</a>
+                                                <form url="/api/bill/markCancelled" right>
+                                                    <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                    <p>Cancel this bill?</p>
+                                                    <div class="mb-0">
+                                                        <button class="btn btn-danger btn-sm" submit>Yes</button>
+                                                        <button class="btn btn-default border btn-sm"
+                                                                cancel>No</button>
+                                                    </div>
+                                                </form>
+                                            </span>
+                                        @endif
+                                    </div>
+                                    @include('app.patient.note.flag-bill')
+                                </td>
+                            </tr>
+                        @endforeach
+                        </tbody>
+                    </table>
+                    @endif
+
+
+                </div>
+                    @else
+                        <div class="p-3 d-flex  border-bottom">
+                            <p class="font-weight-bold mb-0 text-secondary">No bills in this note</p>
+                            @include('app/patient/note/_create-bill')
+                        </div>
+                    @endif
+                    </div>
+                @endif
+
+                {{-- generic bills --}}
+                @if($pro->pro_type === 'ADMIN' || ($note->allyPro && $pro->id === $note->allyPro->id))
+                    <div class="screen-only" data-non-segment-section="NA Bills">
+                    @include('app.generic-bills.inline', ['patient' => $patient, 'note' => $note, 'class' => 'p-3 border-bottom', 'label' => 'NA', 'entityType' => 'Note', 'entityUid' => $note->uid])
+                    </div>
+                @endif
+
+                {{-- claims --}}
+                @if($pro->pro_type === 'ADMIN')
+                    <div class="screen-only" data-non-segment-section="Claims">
+                    @if($note->claims->count())
+                        <div class="screen-only p-3">
+                        <div class="d-flex align-items-center mb-2">
+                            <p class="font-weight-bold text-secondary m-0">Claims</p>
+                            @include('app/patient/note/_create-claim')
+                            <div class="ml-auto">
+                                <select class="form-control form-control-sm"
+                                        onchange="fastLoad('{{route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $note])}}?claims-filter=' + this.value)">
+                                    <option value="active" {{!request('claims-filter') || request('claims-filter') === 'active' ? 'selected' : ''}}>Active Claims</option>
+                                    <option value="all" {{request('claims-filter') === 'all' ? 'selected' : ''}}>All Claims</option>
+                                </select>
+                            </div>
+                        </div>
+
+                        <table class="table table-sm tabe-striped mb-3 border-left border-right border-bottom">
+                            <thead class="bg-light">
+                            <tr>
+                                <th class="border-bottom-0 pl-2">IID</th>
+                                <th class="border-bottom-0">Details</th>
+                                <th class="border-bottom-0">Status</th>
+                                <th class="border-bottom-0">Submissions</th>
+                            </tr>
+                            </thead>
+                            <tbody>
+                            @foreach ($note->claims as $claim)
+                                @if($claim->status !== 'CANCELLED' || request('claims-filter') === 'all')
+                                    <tr class="bg-secondary on-hover-opaque">
+                                        <td colspan="5" class="pt-0 pb-1"></td>
+                                    </tr>
+                                    <tr class="{{ $claim->status === 'CANCELLED' ? 'text-secondary bg-light on-hover-opaque' : '' }}">
+                                        <td class="pl-2">
+                                            <div>{{ $claim->iid }}</div>
+                                            <div class="text-sm text-secondary font-weight-bold mt-1">Current Version:</div>
+                                            <div class="text-sm text-secondary">{{$claim->currentVersion ? friendlier_date_time($claim->currentVersion->created_at) : '-'}}</div>
+                                            @if($claim->status === 'CANCELLED')
+                                                <div class="text-secondary font-weight-bold text-sm mt-1">[CANCELLED]</div>
+                                            @else
+                                                <div moe class="text-left mt-1" title="Cancel Claim">
+                                                    <a class="" href="" show start>Cancel</a>
+                                                    <form url="/api/claim/updateStatus">
+                                                        <input type="hidden" name="uid" value="{{$claim->uid}}">
+                                                        <input type="hidden" name="status" value="CANCELLED">
+                                                        <p>Cancel this claim?</p>
+                                                        <div class="mb-2">
+                                                            <label for="" class="control-label">Cancellation Memo</label>
+                                                            <textarea name="memo" class="form-control"></textarea>
+                                                        </div>
+                                                        <div class="mb-0">
+                                                            <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                        </div>
+                                                    </form>
+                                                </div>
+                                            @endif
+                                        </td>
+                                        <td class="p-0 border-left border-right">
+                                            @if($claim->lines->count())
+                                                <table class="table table-sm table-condensed border-0 mb-0">
+                                                    <thead>
+                                                        <tr class="bg-light">
+                                                            <th class="border-0">CPT</th>
+                                                            <th class="border-0">DOS</th>
+                                                            <th class="border-0">ICDs</th>
+                                                        </tr>
+                                                    </thead>
+                                                    <tbody class="pb-3">
+                                                        @foreach($claim->lines as $line)
+                                                            <tr class="claim-line">
+                                                            <td>{{$line->cpt}}
+                                                                <div>Units: <b>{{!@$line->units ? 1 : $line->units}}</b></div>
+                                                            </td>
+                                                            <td class="text-nowrap">{{friendlier_date($line->date_of_service)}}</td>
+                                                            <td>
+                                                                @if(count($line->claimLineIcds))
+                                                                    @foreach($line->claimLineIcds as $icd)
+                                                                        <div>
+                                                                            <b class="c-pointer border-secondary border-bottom" title="{{$icd->description}}">{{$icd->code}}</b>
+                                                                        </div>
+                                                                    @endforeach
+                                                                @else
+                                                                    <p>No ICDs set</p>
+                                                                @endif
+                                                            </td>
+                                                        </tr>
+                                                        @endforeach
+                                                    </tbody>
+                                                </table>
+                                            @else
+                                                <p>No lines for this claim</p>
+                                            @endif
+                                        </td>
+                                        <td class="border-right p-0">
+
+                                            <!-- payer, company, location -->
+                                            <div class="p-1">
+                                                <div class="mt-1">
+                                                    <div>
+                                                    <span class="text-secondary text-sm">Payer (1°): </span>
+                                                    <b>{{$claim->primaryPayer ? $claim->primaryPayer->name : '-'}}</b>
+                                                    @if(0 && $claim->status !== 'CANCELLED')
+                                                            <span moe class="ml-1">
+                                                            <a class="text-primary" href="" show start><i class="fa fa-edit"></i></a>
+                                                            <form url="/api/claim/putPrimaryPayer">
+                                                                <input type="hidden" name="uid" value="{{$claim->uid}}">
+                                                                <div class="mb-2">
+                                                                    <select name="primaryPayerUid" class="form-control form-control-sm">
+                                                                        <option value="">-- select --</option>
+                                                                        @foreach($note->hcpPro->companyProPayers as $companyProPayer)
+                                                                            <option value="{{$companyProPayer->payer->uid}}"
+                                                                                    {{$claim->primaryPayer && $claim->primaryPayer->uid === $companyProPayer->payer->uid ? 'selected' : ''}}>{{$companyProPayer->payer->name}}</option>
+                                                                        @endforeach
+                                                                    </select>
+                                                                </div>
+                                                                <div class="mb-0">
+                                                                    <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                                </div>
+                                                            </form>
+                                                        </span>
+                                                            @if($claim->primaryPayer)
+                                                                <span moe class="ml-1">
+                                                            <a class="text-danger" href="" show start><i class="fa fa-trash-alt"></i></a>
+                                                            <form url="/api/claim/wipePrimaryPayer">
+                                                                <input type="hidden" name="uid" value="{{$claim->uid}}">
+                                                                <p>Wipe payer from this claim?</p>
+                                                                <div class="mb-0">
+                                                                    <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                                </div>
+                                                            </form>
+                                                        </span>
+                                                            @endif
+                                                        @endif
+                                                    </div>
+                                                    <div class="py-1 border-bottom d-flex align-items-center">
+                                                        <span class="text-secondary text-sm pr-1">Status: </span>
+                                                        <div>
+                                                            {{$claim->status ? $claim->status : '(not set)'}}
+                                                            @if($claim->status !== 'CANCELLED')
+                                                                <span moe class="d-inline-block text-left ml-1" title="Update Status">
+                                                                    <a class="" href="" show start><i class="fa fa-edit"></i></a>
+                                                                    <form url="/api/claim/updateStatus">
+                                                                        <input type="hidden" name="uid" value="{{$claim->uid}}">
+                                                                        <div class="mb-2">
+                                                                            <label for="" class="control-label">Status</label>
+                                                                            <select name="status" class="form-control form-control-sm" required>
+                                                                                <option value="">-- select --</option>
+                                                                                <option value="NEW" {{$claim->status === 'NEW' ? 'selected' : ''}}>New</option>
+                                                                                <option value="PICKED_UP" {{$claim->status === 'PICKED_UP' ? 'selected' : ''}}>Picked Up</option>
+                                                                                <option value="SUBMITTED" {{$claim->status === 'SUBMITTED' ? 'selected' : ''}}>Submitted</option>
+                                                                                <option value="IN_PROCESS" {{$claim->status === 'IN_PROCESS' ? 'selected' : ''}}>In Process</option>
+                                                                                <option value="ACCEPTED" {{$claim->status === 'ACCEPTED' ? 'selected' : ''}}>Accepted</option>
+                                                                                <option value="REJECTED" {{$claim->status === 'REJECTED' ? 'selected' : ''}}>Rejected</option>
+                                                                                <option value="ABANDONED" {{$claim->status === 'ABANDONED' ? 'selected' : ''}}>Abandoned</option>
+                                                                            </select>
+                                                                        </div>
+                                                                        <div class="mb-2">
+                                                                            <label for="" class="control-label">Status Memo</label>
+                                                                            <textarea name="memo" class="form-control"></textarea>
+                                                                        </div>
+                                                                        <div class="mb-0">
+                                                                            <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                                        </div>
+                                                                    </form>
+                                                                </span>
+                                                            @endif
+                                                        </div>
+                                                        @if($claim->status_memo)
+                                                            <div class="text-secondary font-italic text-sm">{{$claim->status_memo}}</div>
+                                                        @endif
+                                                    </div>
+                                                </div>
+
+                                                <div class="mt-1">
+                                                    <span class="text-secondary text-sm">Payer (2°): </span>
+                                                    <b>-</b>
+                                                </div>
+
+                                                <div class="mt-1">
+                                                    <span class="text-secondary text-sm">Company: </span>
+                                                    <b>{{$claim->companyPro && $claim->companyPro->company ? $claim->companyPro->company->name : '-'}}</b>
+                                                    @if(0 && $claim->status !== 'CANCELLED')
+                                                        <span moe class="ml-1">
+                                                            <a class="text-primary" href="" show start><i class="fa fa-edit"></i></a>
+                                                            <form url="/api/claim/putCompanyPro">
+                                                                <input type="hidden" name="uid" value="{{$claim->uid}}">
+                                                                <div class="mb-2">
+                                                                    <select name="companyProUid" class="form-control form-control-sm">
+                                                                        <option value="">-- select --</option>
+                                                                        @foreach($note->hcpPro->companyProPayers as $companyProPayer)
+                                                                            <option value="{{$companyProPayer->companyPro->uid}}"
+                                                                                    {{$claim->companyPro && $claim->companyPro->uid === $companyProPayer->companyPro->uid ? 'selected' : ''}}>{{$companyProPayer->company->name}}</option>
+                                                                        @endforeach
+                                                                    </select>
+                                                                </div>
+                                                                <div class="mb-0">
+                                                                    <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                                </div>
+                                                            </form>
+                                                        </span>
+                                                        @if($claim->companyPro && $claim->companyPro->company)
+                                                            <span moe class="ml-1">
+                                                                <a class="text-danger" href="" show start><i class="fa fa-trash-alt"></i></a>
+                                                                <form url="/api/claim/wipeCompanyPro">
+                                                                    <input type="hidden" name="uid" value="{{$claim->uid}}">
+                                                                    <p>Wipe company from this claim?</p>
+                                                                    <div class="mb-0">
+                                                                        <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                                    </div>
+                                                                </form>
+                                                            </span>
+                                                        @endif
+                                                    @endif
+                                                </div>
+
+                                                <div class="mt-1">
+                                                    <span class="text-secondary text-sm">Location: </span>
+                                                    <b>{{$claim->companyLocation ? $claim->companyLocation->line1 . ', ' . $claim->companyLocation->city : '-'}}</b>
+                                                    @if(0 && $claim->status !== 'CANCELLED')
+                                                        <span moe class="ml-1">
+                                                            <a class="text-primary" href="" show start><i class="fa fa-edit"></i></a>
+                                                            <form url="/api/claim/putCompanyLocation">
+                                                                <input type="hidden" name="uid" value="{{$claim->uid}}">
+                                                                <div class="mb-2">
+                                                                    <select name="companyLocationUid" class="form-control form-control-sm">
+                                                                        <option value="">-- select --</option>
+                                                                        @if($claim->company && $claim->company->locations)
+                                                                            @foreach($claim->company->locations as $location)
+                                                                                <option value="{{$location->uid}}"
+                                                                                        {{$claim->companyLocation && $claim->companyLocation->uid === $location->uid ? 'selected' : ''}}>
+                                                                                    {{$location->line1 . ', ' . $location->city}}
+                                                                                </option>
+                                                                            @endforeach
+                                                                        @endif
+                                                                    </select>
+                                                                </div>
+                                                                <div class="mb-0">
+                                                                    <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                                </div>
+                                                            </form>
+                                                        </span>
+                                                        @if($claim->companyLocation)
+                                                            <span moe class="ml-1">
+                                                            <a class="text-danger" href="" show start><i class="fa fa-trash-alt"></i></a>
+                                                            <form url="/api/claim/wipeCompanyLocation">
+                                                                <input type="hidden" name="uid" value="{{$claim->uid}}">
+                                                                <p>Wipe location from this claim?</p>
+                                                                <div class="mb-0">
+                                                                    <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                                </div>
+                                                            </form>
+                                                        </span>
+                                                        @endif
+                                                    @endif
+                                                </div>
+                                            </div>
+                                        </td>
+                                        <td class="p-0 border-left border-right">
+                                            <table class="table table-sm table-condensed border-0 mb-0">
+                                                @if($claim->status !== 'CANCELLED')
+                                                    <thead>
+                                                    <tr class="">
+                                                        <th colspan="3" class="border-top-0 border-bottom">
+                                                            <div>
+                                                                <span moe class="d-block" title="Submit Claim">
+                                                                    <a class="" href="" show start>Generate Submission to Payer (1°)</a>
+                                                                    <form url="/api/mbClaim/createFromClaimForPrimaryPayer">
+                                                                        <input type="hidden" name="claimUid" value="{{$claim->uid}}">
+                                                                        <p>Generate Submission?</p>
+                                                                        <div class="mb-0">
+                                                                            <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                                        </div>
+                                                                    </form>
+                                                                </span>
+                                                            </div>
+                                                        </th>
+                                                    </tr>
+                                                    </thead>
+                                                @endif
+                                                @if(count($claim->mbClaims))
+                                                    <thead>
+                                                    <tr class="bg-light">
+                                                        <th class="border-0">Created</th>
+                                                        <th class="border-0">Status</th>
+                                                        <th class="border-0">&nbsp;</th>
+                                                    </tr>
+                                                    </thead>
+                                                    <tbody class="pb-3">
+                                                    @foreach($claim->mbClaims as $mbClaim)
+                                                        <tr>
+                                                            <td>
+                                                                @if($mbClaim->claim_version_id !== $claim->current_version_id)
+                                                                    <i class="fa fa-exclamation-triangle text-warning-mellow text-sm" title="This submission was generated using an older version of the claim"></i>
+                                                                @else
+                                                                    <i class="fa fa-asterisk text-secondary text-sm" title="This submission is up to date"></i>
+                                                                @endif
+                                                                <a native target="_blank"
+                                                                   open-in-stag-popup
+                                                                   title="Submission Details"
+                                                                   href="{{route('mb-claim', ['patient' => $patient, 'mbClaim' => $mbClaim])}}">
+                                                                    {{ friendlier_date_time($mbClaim->created_at) }}
+                                                                </a>
+                                                            </td>
+                                                            <td>
+                                                                {{$mbClaim->status}}
+                                                                @if($mbClaim->status_memo)
+                                                                    <div class="font-italic text-secondary text-sm">{{$mbClaim->status_memo}}</div>
+                                                                @endif
+                                                            </td>
+                                                            <td class="text-right pr-2">
+                                                                 <span moe relative title="Submit Claim">
+                                                                    <a class="" href="" show start><i class="fa fa-edit"></i></a>
+                                                                    <form url="/api/mbClaim/updateStatus" right>
+                                                                        <input type="hidden" name="uid" value="{{$mbClaim->uid}}">
+                                                                        <div class="form-group">
+                                                                            <label for="" class="control-label">Status</label>
+                                                                            <select name="status" class="form-control form-control-sm" required>
+                                                                                <option value="">-- select --</option>
+                                                                                <option value="NEW" {{$mbClaim->status === 'NEW' ? 'selected' : ''}}>New</option>
+                                                                                <option value="PROCESSING" {{$mbClaim->status === 'PROCESSING' ? 'selected' : ''}}>Processing</option>
+                                                                                <option value="SUBMITTED" {{$mbClaim->status === 'SUBMITTED' ? 'selected' : ''}}>Submitted</option>
+                                                                                <option value="CANCELLED" {{$mbClaim->status === 'CANCELLED' ? 'selected' : ''}}>Cancelled</option>
+                                                                            </select>
+                                                                        </div>
+                                                                        <div class="form-group">
+                                                                            <label for="" class="control-label">Status Memo</label>
+                                                                            <textarea name="memo" class="form-control"></textarea>
+                                                                        </div>
+                                                                        <div class="mb-0">
+                                                                            <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                                        </div>
+                                                                    </form>
+                                                                </span>
+                                                                <a class="ml-1" target="_blank" native href="/api/mbClaim/downloadEDI/{{$mbClaim->uid}}" show start><i class="fa fa-file-download"></i></a>
+                                                                <a class="ml-1 text-success" href="" show start><i class="fa fa-arrow-right"></i></a>
+                                                            </td>
+                                                        </tr>
+                                                    @endforeach
+                                                    </tbody>
+                                                @else
+                                                    <tbody>
+                                                        <tr>
+                                                            <td colspan="3">
+                                                                <p class="p-1 text-secondary m-0">No submissions in this claim</p>
+                                                            </td>
+                                                        </tr>
+                                                    </tbody>
+                                                @endif
+                                            </table>
+                                        </td>
+                                    </tr>
+                                @endif
+                            @endforeach
+                            </tbody>
+                        </table>
+                    </div>
+                    @else
+                        <div class="screen-only p-3 d-flex">
+                        <p class="font-weight-bold mb-0 text-secondary">No claims in this note</p>
+                        @include('app/patient/note/_create-claim')
+                    </div>
+                    @endif
+                    </div>
+                @endif
+
+                {{-- addendums --}}
+                @if($note->is_signed_by_hcp)
+                <div class="border-top p-3" data-non-segment-section="Addendums">
+                    @if($note->addendums->count())
+                        <div class="">
+                            <div class="d-flex align-items-center mb-2">
+                                <p class="font-weight-bold text-secondary m-0">Addendums</p>
+                                @include('app/patient/note/_create-addendum')
+                            </div>
+                            <table class="table table-sm tabe-striped border-left border-right border-bottom m-0">
+                                <thead class="bg-light">
+                                <tr>
+                                    <th class="border-bottom-0 pl-2 w-75">Addendum</th>
+                                    <th class="border-bottom-0">Created</th>
+                                    <th class="border-bottom-0 delete-column"></th>
+                                </tr>
+                                </thead>
+                                <tbody>
+                                @foreach ($note->addendums as $addendum)
+                                    <tr>
+                                        <td class="pl-2">{{ $addendum->memo }}</td>
+                                        <td class="">{{ friendly_date_time($addendum->created_at, false)}}</td>
+                                        <td>
+                                            <div class="d-flex align-items-center">
+                                                <div moe relative class="mr-2">
+                                                    <a href="" show start><i class="fa fa-edit"></i></a>
+                                                    <form url="/api/noteAddendum/updateMemo" right>
+                                                        <input type="hidden" name="uid" value="{{$addendum->uid}}">
+                                                        <div class="mb-2 d-block">
+                                                            <label class="d-block text-sm text-secondary mb-1">Addendum</label>
+                                                            <textarea class="form-control form-control-sm" name="memo" rows="5">{{$addendum->memo}}</textarea>
+                                                        </div>
+                                                        <div class="form-group mb-0">
+                                                            <button class="btn btn-primary btn-sm mr-1" submit>Submit</button>
+                                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                        </div>
+                                                    </form>
+                                                </div>
+                                                <div moe relative class="mr-1">
+                                                    <a href="" show start class="text-danger"><i class="fa fa-trash"></i></a>
+                                                    <form url="/api/noteAddendum/remove" right>
+                                                        <input type="hidden" name="uid" value="{{$addendum->uid}}">
+                                                        <p>Remove this addendum?</p>
+                                                        <div class="form-group mb-0">
+                                                            <button class="btn btn-danger btn-sm mr-1" submit>Yes</button>
+                                                            <button class="btn btn-default border btn-sm" cancel>No</button>
+                                                        </div>
+                                                    </form>
+                                                </div>
+                                            </div>
+                                        </td>
+                                    </tr>
+                                @endforeach
+                                </tbody>
+                            </table>
+                        </div>
+                    @else
+                        <div class="d-flex">
+                            <p class="font-weight-bold mb-0 text-secondary">No addendums in this note</p>
+                            @include('app/patient/note/_create-addendum')
+                        </div>
+                    @endif
+                </div>
+                @endif
+
+                <div class="screen-only">
+                    @include('app/patient/note/_cancel-signed-note')
+                </div>
+
+                </div>
+
+                @if($isVisitTemplateBased && !$note->is_signed_by_hcp)
+                <div class="position-sticky note-bottom-toolbar border-top border-info p-0 bg-aliceblue d-flex align-items-stretch screen-only">
+                    <div class="nbt-container border-right border-info">
+                        <div native target="_blank"
+                             class="c-pointer d-inline-flex align-items-center px-2 py-1"
+                             open-in-stag-popup
+                             title="Medrisk Vigilence"
+                             popup-style="overflow-visible mrv-content"
+                             href="/mrv-summary/{{$note->uid}}">
+                            <span>MRV</span>
+                        </div>
+                    </div>
+                    <div class="nbt-container border-right border-info d-inline-flex align-self-stretch">
+                        <div native target="_blank"
+                             class="c-pointer d-inline-flex align-items-center medications-center-trigger px-2 py-1"
+                             open-in-stag-popup
+                             mc-initer="medications-center-{{$note->id}}"
+                             title="Medications Center"
+                             popup-style="overflow-visible"
+                             href="/medications-center/{{$patient->uid}}/{{$note->uid}}">
+                            <i class="fa fa-bolt mr-1"></i>
+                            <span>Rx</span>
+                        </div>
+                    </div>
+                    <div class="nbt-container border-right border-info d-inline-flex align-self-stretch">
+                        <div native target="_blank"
+                             class="c-pointer d-inline-flex align-items-center problems-center-trigger px-2 py-1"
+                             open-in-stag-popup
+                             mc-initer="problems-center-{{$note->id}}"
+                             title="Problems Center"
+                             popup-style="overflow-visible"
+                             href="/problems-center/{{$patient->uid}}/{{$note->uid}}">
+                            <i class="fa fa-bolt mr-1"></i>
+                            <span>Dx</span>
+                        </div>
+                    </div>
+                    <div class="nbt-container border-right border-info d-inline-flex align-self-stretch">
+                        <div native target="_blank"
+                             class="c-pointer d-inline-flex align-items-center goals-center-trigger px-2 py-1"
+                             open-in-stag-popup
+                             mc-initer="goals-center-{{$note->id}}"
+                             title="Goals Center"
+                             popup-style="overflow-visible"
+                             href="/goals-center/{{$patient->uid}}/{{$note->uid}}">
+                            <i class="fa fa-bolt mr-1"></i>
+                            <span>Goals</span>
+                        </div>
+                    </div>
+                    <div class="nbt-container border-right border-info d-inline-flex align-self-stretch">
+                        <div native target="_blank"
+                             class="c-pointer d-inline-flex align-items-center allergies-center-trigger px-2 py-1"
+                             open-in-stag-popup
+                             mc-initer="allergies-center-{{$note->id}}"
+                             title="Allergies Center"
+                             popup-style="overflow-visible"
+                             href="/allergies-center/{{$patient->uid}}/{{$note->uid}}">
+                            <i class="fa fa-bolt mr-1"></i>
+                            <span>Allergies</span>
+                        </div>
+                    </div>
+                    <div class="nbt-container border-right border-info d-inline-flex align-self-stretch">
+                        <div native target="_blank"
+                             class="c-pointer d-inline-flex align-items-center careteam-center-trigger px-2 py-1"
+                             open-in-stag-popup
+                             mc-initer="careteam-center-{{$note->id}}"
+                             title="Care Team Center"
+                             popup-style="overflow-visible"
+                             href="/careteam-center/{{$patient->uid}}/{{$note->uid}}">
+                            <i class="fa fa-bolt mr-1"></i>
+                            <span>Care Team</span>
+                        </div>
+                    </div>
+                    <div class="nbt-container border-right border-info d-inline-flex align-self-stretch">
+                        <a native="" target="_top"
+                           class="c-pointer d-inline-flex align-items-center handouts-trigger px-2 py-1 text-dark"
+                           data-non-segment-target="Incoming Reports" href="#">Inc. Rpts.</a>
+                    </div>
+                    <div class="nbt-container border-right border-info d-inline-flex align-self-stretch">
+                        <a native="" target="_top"
+                           class="c-pointer d-inline-flex align-items-center handouts-trigger px-2 py-1 text-dark"
+                           data-non-segment-target="Handouts" href="#">Handouts</a>
+                    </div>
+                    <div class="nbt-container border-right border-info d-inline-flex align-self-stretch">
+                        <a native="" target="_top"
+                           class="c-pointer d-inline-flex align-items-center handouts-trigger px-2 py-1 text-dark"
+                           data-non-segment-target="Prescriptions" href="#">ERx</a>
+                    </div>
+                    @if($pro->pro_type === 'ADMIN')
+                        <div class="nbt-container border-right border-info d-inline-flex align-self-stretch">
+                            <a native="" target="_top"
+                               class="c-pointer d-inline-flex align-items-center handouts-trigger px-2 py-1 text-dark"
+                               data-non-segment-target="HCP Bills" href="#">HCP Bills</a>
+                        </div>
+                        <div class="nbt-container border-right border-info d-inline-flex align-self-stretch">
+                            <a native="" target="_top"
+                               class="c-pointer d-inline-flex align-items-center handouts-trigger px-2 py-1 text-dark"
+                               data-non-segment-target="NA Bills" href="#">NA Bills</a>
+                        </div>
+                    @else
+                        @if($note->hcpPro && $pro->id === $note->hcpPro->id)
+                            <div class="nbt-container border-right border-info d-inline-flex align-self-stretch">
+                                <a native="" target="_top"
+                                   class="c-pointer d-inline-flex align-items-center handouts-trigger px-2 py-1 text-dark"
+                                   data-non-segment-target="HCP Bills" href="#">Bills</a>
+                            </div>
+                        @endif
+                        @if($note->allyPro && $pro->id === $note->allyPro->id)
+                            <div class="nbt-container border-right border-info d-inline-flex align-self-stretch">
+                                <a native="" target="_top"
+                                   class="c-pointer d-inline-flex align-items-center handouts-trigger px-2 py-1 text-dark"
+                                   data-non-segment-target="NA Bills" href="#">Bills</a>
+                            </div>
+                        @endif
+                    @endif
+                </div>
+                @endif
+
+                </div>
+                @if(1 || !$hasRightSegments)
+                    @include('app.patient.note.rhs-sidebar')
+                @endif
+            </div>
+        </div>
+    </div>
+    <div class="note-templates-underlay"></div>
+    @include('app.patient.note.dashboard_script')
+    @if(!$isVisitTemplateBased)
+    @include('app.patient.canvas-sections.canvas-editor-modal', ['key' => 'rx', 'class' => 'wide', 'noEditLink' => true])
+    <script>
+        (function() {
+            function init() {
+                $('.trigger-clone')
+                    .off('click.clone')
+                    .on('click.clone', function() {
+                        $.post('/api/note/clone', {
+                            uid: $(this).attr('data-uid')
+                        }, function(_data) {
+                            if(_data) {
+                                if(_data.success) {
+                                    toastr.success('Note cloned successfully');
+                                    fastLoad('/patients/view/{{$patient->uid}}/notes/view/' + _data.data);
+                                }
+                                else {
+                                    toastr.error(_data.message);
+                                }
+                            }
+                            else {
+                                toastr.error('Unable to clone the note!');
+                            }
+                        }, 'json');
+                    });
+            }
+            addMCInitializer('non-visit-template', init, '#note-single-header');
+        })();
+    </script>
+    @endif
+    @if($isVisitTemplateBased)
+    <script>
+        (function() {
+            function init() {
+                @if(1 || !$hasRightSegments)
+                fixTreeTopAndHeight();
+                $(window).on('resize', fixTreeTopAndHeight);
+                $(window).on('scroll', fixTreeTopAndHeight);
+                $('.note-tree-node>a[data-segment-uid]')
+                    .off('click.scroll-to-segment')
+                    .on('click.scroll-to-segment', function() {
+                        let section = $('div.note-section[data-segment-uid="' + $(this).attr('data-segment-uid') + '"]').first();
+                        if(section.length) {
+                            section[0].scrollIntoView({
+                                behavior: "smooth",
+                                block: "center",
+                                inline: "center"
+                            });
+                            section.addClass('spot-highlight');
+                            setTimeout(() => {
+                                section.removeClass('spot-highlight');
+                            }, 1500);
+                            $('.note-tree-node.active').removeClass('active');
+                            $(this).closest('.note-tree-node').addClass('active');
+                        }
+                        return false;
+                    });
+                // clicking node parent - go to first child
+                $('.note-tree-node.note-tree-heading>a:not([data-segment-uid])')
+                    .off('click.scroll-to-first-child-segment')
+                    .on('click.scroll-to-first-child-segment', function() {
+                         $(this).parent().find('>.note-tree-children>.note-tree-node>a[data-segment-uid]').first().trigger('click');
+                         return false;
+                    });
+                @endif
+                $(document)
+                    .off('click.scroll-to-non-segment', '[data-non-segment-target]')
+                    .on('click.scroll-to-non-segment', '[data-non-segment-target]', function() {
+                        closeStagPopup(true);
+                        let section = $('div[data-non-segment-section="' + $(this).attr('data-non-segment-target') + '"]').first();
+                        if(section.length) {
+                            section[0].scrollIntoView({
+                                behavior: "smooth",
+                                block: "center",
+                                inline: "center"
+                            });
+                            section.addClass('spot-highlight');
+                            setTimeout(() => {
+                                section.removeClass('spot-highlight');
+                            }, 1500);
+                            $('.note-tree-node.active').removeClass('active');
+                            $(this).closest('.note-tree-node').addClass('active');
+                        }
+                        return false;
+                    });
+
+                // update disclaimers on fastReload()
+                // NOTE: this is NOT the ideal place to put this
+                @if(!$note->is_signed_by_hcp)
+                refreshSegment('disclaimers');
+                @endif
+            }
+            function fixTreeTopAndHeight() {
+                let tree = $('#note-lhs-tree'), noteCardHeader = $('#note-card-header');
+                if(!noteCardHeader.length) return;
+                let resultTop = (noteCardHeader.offset().top + noteCardHeader.outerHeight(true)) - $(window).scrollTop();
+                if(resultTop <= 55) {
+                    @if(!$note->is_signed_by_hcp)
+                    tree.addClass('fixed');
+                    @else
+                    tree.addClass('fixed-left');
+                    @endif
+                }
+                else {
+                    @if(!$note->is_signed_by_hcp)
+                    tree.removeClass('fixed');
+                    @else
+                    tree.removeClass('fixed-left');
+                    @endif
+                    tree.css('height', 'calc(100vh - ' + resultTop + 'px)');
+                    tree.css('max-height', 'calc(100vh - ' + resultTop + 'px)');
+                }
+            }
+            addMCInitializer('note-tree', init, '#note-lhs-tree');
+        })();
+    </script>
+    <script>
+        (function() {
+            function init() {
+                fixRhsSidebarTopAndHeight();
+                $(window).on('resize', fixRhsSidebarTopAndHeight);
+                $(window).on('scroll', fixRhsSidebarTopAndHeight);
+            }
+            function fixRhsSidebarTopAndHeight() {
+                let rhsSidebar = $('#note-rhs-sidebar'), noteCardHeader = $('#note-card-header');
+                if(!noteCardHeader.length) return;
+                let resultTop = (noteCardHeader.offset().top + noteCardHeader.outerHeight(true)) - $(window).scrollTop();
+                if(resultTop <= 55) {
+                    @if(!$note->is_signed_by_hcp)
+                    rhsSidebar.addClass('fixed');
+                    rhsSidebar.closest('.note-container').addClass('rhs-sidebar-fixed');
+                    @endif
+                }
+                else {
+                    rhsSidebar.removeClass('fixed');
+                    rhsSidebar.closest('.note-container').removeClass('rhs-sidebar-fixed');
+                    rhsSidebar.css('height', 'calc(100vh - ' + resultTop + 'px)');
+                    rhsSidebar.css('max-height', 'calc(100vh - ' + resultTop + 'px)');
+                }
+            }
+            addMCInitializer('rhs-sidebar', init, '#note-rhs-sidebar');
+        })();
+    </script>
+
+        @if($isVisitTemplateBased)
+        <script>
+            (function() {
+                function init() {
+                    @if($hasRightSegments)
+                    initVSplitter('stag-note', $('.note-left-panel'), $('.note-right-panel'));
+                    initStagScrollbar({{$note->is_signed_by_hcp ? 1 : 34}});
+                    @endif
+                    addMCHook('onNoteMethodUpdate', function() {
+                        refreshSegment('disclaimers');
+                        fastReload();
+                    });
+                    $(document)
+                        .off('click.scroll-to-non-segment', '[data-non-segment-target]')
+                        .on('click.scroll-to-non-segment', '[data-non-segment-target]', function() {
+                            closeStagPopup(true);
+                            let section = $('div[data-non-segment-section="' + $(this).attr('data-non-segment-target') + '"]').first();
+                            if(section.length) {
+                                section[0].scrollIntoView({
+                                    behavior: "smooth",
+                                    block: "center",
+                                    inline: "center"
+                                });
+                                section.addClass('spot-highlight');
+                                setTimeout(() => {
+                                    section.removeClass('spot-highlight');
+                                }, 1500);
+                                $('.note-tree-node.active').removeClass('active');
+                                $(this).closest('.note-tree-node').addClass('active');
+                            }
+                            return false;
+                        });
+                }
+                addMCInitializer('soap-visit', init, '#note-single-header');
+            })();
+        </script>
+        @endif
+    @endif
+
+    @endsection
+@if(!$isVisitTemplateBased)
+@section('left-nav-content')
+    @if(!$note->is_signed_by_hcp)
+    <div class="left-nav-content" id="note-sections-app">
+        <div class="note-widget-title px-2 py-1">Note Sections</div>
+        <input type="search" class="d-block w-100 border-0 outline-0 px-2 py-1"
+               v-model="q" placeholder="Filter">
+        <div class="border-top py-1">
+            <div v-for="section in sections"
+                 v-show="section.title.toLowerCase().indexOf(q.toLowerCase()) !== -1">
+                <div class="d-flex pr-1 align-items-center note-widget-item c-pointer"
+                     :title="section.title + ' - Click to remove'"
+                     v-if="section.used"
+                     v-on:click.once="remove(section.section_uid)">
+                    <span class="mx-2">
+                        <a class="font-12 text-secondary" href="#">
+                            <i class="fa fa-minus-circle"></i>
+                        </a>
+                    </span>
+                    <span class="font-smaller text-ellipsis">
+                        @{{section.title}}
+                    </span>
+                </div>
+                <div class="d-flex pr-1 align-items-center note-widget-item c-pointer"
+                     :title="section.title + ' - Click to add'"
+                     v-if="!section.used"
+                     v-on:click.once="add(section.uid, section.internal_name)">
+                    <span class="mx-2">
+                        <a class="font-12" href="#">
+                            <i class="fa fa-plus-circle"></i>
+                        </a>
+                    </span>
+                    <span class="font-smaller text-ellipsis">
+                        @{{section.title}}
+                    </span>
+                </div>
+            </div>
+        </div>
+    </div>
+    <script>
+        (function() {
+            function initSectionsWidget() {
+                var allSections = <?= json_encode($allSections) ?>;
+                new Vue({
+                    el: '#note-sections-app',
+                    delimiters: ['@{{', '}}'],
+                    data: {
+                        q: '',
+                        sections: allSections
+                    },
+                    methods: {
+                        add: function(_uid, _section) {
+                            $.post('/api/section/create', {
+                                noteUid: '{{$note->uid}}',
+                                sectionTemplateUid: _uid,
+                            }, function(_data) {
+                                if(_data) {
+                                    if(_data.success) {
+                                        fastReload();
+                                    }
+                                    else {
+                                        toastr.error(_data.message);
+                                    }
+                                }
+                                else {
+                                    toastr.error('Unable to add section!');
+                                }
+                            }, 'json');
+                        },
+                        remove: function(_uid) {
+                            $.post('/api/section/deactivate', {
+                                uid: _uid,
+                                memo: 'Deactivated from note',
+                            }, function(_data) {
+                                if(_data) {
+                                    if(_data.success) {
+                                        fastReload();
+                                    }
+                                    else {
+                                        toastr.error(_data.message);
+                                    }
+                                }
+                                else {
+                                    toastr.error('Unable to remove section!');
+                                }
+                            }, 'json');
+                        }
+                    }
+                });
+
+                $('div[embed]').each(function() {
+                    $(this).load($(this).attr('embed'));
+                });
+            }
+            addMCInitializer('note-sections-widget', initSectionsWidget, '#note-sections-app');
+        })();
+    </script>
+    @endif
+@endsection
+@endif

+ 44 - 8
resources/views/app/patient/note/dashboard-univ.blade.php

@@ -864,20 +864,56 @@
                             <div class="">
                             <div class="">
                                 <div class="d-flex align-items-center mb-2">
                                 <div class="d-flex align-items-center mb-2">
                                     <p class="font-weight-bold text-secondary m-0 mr-2">ICDs</p>
                                     <p class="font-weight-bold text-secondary m-0 mr-2">ICDs</p>
-                                    @include('app/patient/note/_create-note-reason')
+                                    @include('app.patient.partials.put-rm-reasons', ['recordType' => 'NOTE', 'record' => $note])
                                 </div>
                                 </div>
+                                <?php
+                                    $noteICDData = [
+                                        'icd_1' => [
+                                            'title' => 'ICD 1',
+                                            'reason' => $note->note_reason_icd1,
+                                            'description' => $note->note_reason_icd1description
+                                        ],
+                                        'icd_2' => [
+                                            'title' => 'ICD 2',
+                                            'reason' => $note->note_reason_icd2,
+                                            'description' => $note->note_reason_icd2description
+                                        ],
+                                        'icd_3' => [
+                                            'title' => 'ICD 3',
+                                            'reason' => $note->note_reason_icd3,
+                                            'description' => $note->note_reason_icd3description
+                                        ],
+                                        'icd_4' => [
+                                            'title' => 'ICD 4',
+                                            'reason' => $note->note_reason_icd4,
+                                            'description' => $note->note_reason_icd4description
+                                        ],
+                                    ];
+                                ?>
                                 <div class="d-flex align-items-start flex-wrap">
                                 <div class="d-flex align-items-start flex-wrap">
-                                    @if(count($note->reasons))
-                                        @foreach ($note->reasons as $reason)
-                                            <span class="badge badge-info p-2 mb-2 mr-2">
-                                    {{ $reason->description}} ({{ $reason->code }})
-                                </span>
+                                    <?php $emptyNoteICDs = true; ?>
+                                        @foreach ($noteICDData as $noteICDKey => $noteICD)
+                                            <?php 
+                                                $emptyICD = true;
+                                                if(!empty($noteICD['reason']) || !empty($noteICD['description'])){
+                                                    $emptyNoteICDs = false;
+                                                    $emptyICD = false;
+                                                }
+                                            ?>
+                                            @if(!$emptyICD)
+                                            <span class="badge badge-info px-2 mb-1 mr-2">{{$noteICD['reason']}} @if(!empty($noteICD['description']))({{ $noteICD['description'] }})@endif</span>
+                                            @endif
                                         @endforeach
                                         @endforeach
-                                    @else
-                                        <div class="alert alert-info">No note reasons</div>
+                                    @if($emptyNoteICDs)
+                                        <small class="text-dark">-</small>
                                     @endif
                                     @endif
                                 </div>
                                 </div>
                             </div>
                             </div>
+                            @if(!empty($note->note_reason_memo))
+                                <div style="padding-left: 60px;">
+                                    <small><b>Reason:</b> {{ $note->note_reason_memo }}</small>
+                                </div>
+                            @endif
                         </div>
                         </div>
                         @if($pro->pro_type === 'ADMIN')
                         @if($pro->pro_type === 'ADMIN')
                             <div class="p-3 border-bottom screen-only">
                             <div class="p-3 border-bottom screen-only">

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 288 - 1542
resources/views/app/patient/note/dashboard.blade.php


+ 9 - 0
resources/views/app/patient/note/dashboard_script.blade.php

@@ -5,6 +5,15 @@
 
 
             function init() {
             function init() {
 
 
+                $(document)
+                    .off('keydown.capture-print')
+                    .on('keydown.capture-print', function(_e) {
+                        if(_e.which === 80 && _e.ctrlKey) {
+                            window.print(); // use "lhs" frame for printing, not "top"
+                            return false;
+                        }
+                    });
+
                 $(document)
                 $(document)
                     .off('change.check-book-fu-appt', '.fu-appt-container [name="is_follow_up_needed"]')
                     .off('change.check-book-fu-appt', '.fu-appt-container [name="is_follow_up_needed"]')
                     .on('change.check-book-fu-appt', '.fu-appt-container [name="is_follow_up_needed"]', function() {
                     .on('change.check-book-fu-appt', '.fu-appt-container [name="is_follow_up_needed"]', function() {

+ 201 - 0
resources/views/app/patient/note/flag-bill.blade.php

@@ -0,0 +1,201 @@
+@if(!$bill->is_cancelled)
+	<div <?= $bill->is_flagged_by_administrator && !$bill->is_administrator_flag_cleared ? 'class="alert alert-danger p-1 rounded-0" style="min-width: 380px;"' : '' ?>>
+	<?php #dump($bill); ?>
+	@if($pro->pro_type === 'ADMIN')
+		@if($bill->is_flagged_by_administrator && !$bill->is_administrator_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($bill->flagged_administrator_at) }}</span>
+					<small class="text-sm">By: <i class="fas fa-user"></i> {{ $bill->billFlagAcknowledgedByProAdmin->displayName() }}</small>
+				</div>
+				
+				<small class="text-muted"><b><i class="fas fa-comment on-hover-opaque text-primary"></i></b> {{ $bill->administrator_flag_memo }}</small>
+			</div>
+
+			@if($bill->is_administrator_flag_acknowledged && $bill->administrator_flag_acknowledged_at > $bill->flagged_administrator_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($bill->administrator_flag_acknowledged_at) }}</span>
+							<small class="text-sm">By: <i class="fas fa-user"></i> {{ $bill->billFlagAcknowledgedByPro->displayName() }}</small>
+						</div>
+						
+						<small class="text-muted"><b><i class="fas fa-comment on-hover-opaque"></i></b> {{ $bill->administrator_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($bill->is_administrator_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/bill/clearFlag" class="mcp-theme-1">
+									<input type="hidden" name="uid" value="{{$bill->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 Bill</a>
+								<form url="/api/bill/undoFlagAsAdministrator" class="mcp-theme-1">
+									<input type="hidden" name="uid" value="{{$bill->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 Bill</button>
+										<button cancel class="btn btn-sm btn-default border">Cancel</button>
+									</div>
+								</form>
+							</div>
+						@endif
+						<span class="mx-1 text-muted">|</span>
+						@if($bill->is_administrator_flag_acknowledged)
+							<div moe>
+								<a start show class="text-danger"><i class="fas fa-flag  on-hover-opaque"></i> Flag Bill Again</a>
+								<form url="/api/bill/flagAsAdministrator" class="mcp-theme-1">
+									<input type="hidden" name="uid" value="{{$bill->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 Bill</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/bill/updateFlagMemo" class="mcp-theme-1">
+									<input type="hidden" name="uid" value="{{$bill->uid}}">
+									<div class="form-group">
+										<label>Memo:</label>
+										<textarea name="memo" rows="2" class="form-control"><?= $bill->administrator_flag_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.bill-flags-history')
+					</div>
+				</div>
+			
+		@else
+			<!-- Not flagged, show flag popup -->
+			<!-- //api/bill//flagAsAdministrator -->
+			<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 Bill</a>
+					<form url="/api/bill/flagAsAdministrator" class="mcp-theme-1">
+						<input type="hidden" name="uid" value="{{$bill->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 Bill</button>
+							<button cancel class="btn btn-sm btn-default border">Cancel</button>
+						</div>
+					</form>
+				</div>
+				@include('app.patient.note.partials.bill-flags-history')
+			</div>
+			
+		@endif
+
+	@else
+	<!-- HCP -->
+		@if($bill->is_flagged_by_administrator && !$bill->is_administrator_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($bill->flagged_administrator_at) }}</span>
+					<small class="text-sm">By: <i class="fas fa-user"></i> {{ $bill->billFlagAcknowledgedByProAdmin->displayName() }}</small>
+				</div>			
+				<small class="text-muted"><b><i class="fas fa-comment on-hover-opaque text-primary"></i></b> {{ $bill->administrator_flag_memo }}</small>
+			</div>
+
+			@if($bill->is_administrator_flag_acknowledged && $bill->administrator_flag_acknowledged_at > $bill->flagged_administrator_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($bill->administrator_flag_acknowledged_at) }}</span>
+							<small class="text-sm">By: <i class="fas fa-user"></i> {{ $bill->billFlagAcknowledgedByPro->displayName() }}</small>
+						</div>
+						
+						<small class="text-muted"><b><i class="fas fa-comment on-hover-opaque"></i></b> {{ $bill->administrator_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/bill/undoAcknowledgeAdministratorFlag" class="mcp-theme-1">
+									<input type="hidden" name="uid" value="{{$bill->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/bill/updateAcknowledgementMemo" class="mcp-theme-1">
+									<input type="hidden" name="uid" value="{{$bill->uid}}">
+									<div class="form-group">
+										<label>Memo:</label>
+										<textarea name="memo" rows="2" class="form-control"><?= $bill->administrator_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/bill/acknowledgeAdministratorFlag" class="mcp-theme-1">
+						<input type="hidden" name="uid" value="{{$bill->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>
+@endif

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

+ 3 - 3
resources/views/app/patient/note/follow-up-appointment.blade.php

@@ -22,13 +22,13 @@
         </div>
         </div>
     @endif
     @endif
 
 
-    <div class="align-items-baseline mb-3 fu-appt-choices {{!is_null($note->is_follow_up_needed) ? 'd-none' : 'd-flex'}}">
+    <div class="align-items-center mb-3 fu-appt-choices {{!is_null($note->is_follow_up_needed) ? 'd-none' : 'd-flex'}}">
         <p class="font-weight-bold text-secondary my-0 mr-3">Would you like to book a follow-up appointment?</p>
         <p class="font-weight-bold text-secondary my-0 mr-3">Would you like to book a follow-up appointment?</p>
-        <label class="d-inline-flex align-items-center mr-3">
+        <label class="d-inline-flex align-items-center mr-3 my-0">
             <input type="radio" name="is_follow_up_needed" value="1">
             <input type="radio" name="is_follow_up_needed" value="1">
             <span class="ml-1">Yes</span>
             <span class="ml-1">Yes</span>
         </label>
         </label>
-        <label class="d-inline-flex align-items-center mr-3">
+        <label class="d-inline-flex align-items-center mr-3 my-0">
             <input type="radio" name="is_follow_up_needed" value="0">
             <input type="radio" name="is_follow_up_needed" value="0">
             <span class="ml-1 mr-3">No</span>
             <span class="ml-1 mr-3">No</span>
         </label>
         </label>

+ 17 - 13
resources/views/app/patient/note/lhs-tree.blade.php

@@ -1,4 +1,4 @@
-<div class="note-lhs-tree pb-4" id="note-lhs-tree">
+<div class="note-lhs-tree pb-4 screen-only" id="note-lhs-tree">
     <?php
     <?php
     $previousHeading = null;
     $previousHeading = null;
     $previousSubHeading = null;
     $previousSubHeading = null;
@@ -47,25 +47,29 @@
 
 
     <hr>
     <hr>
     <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="Handouts" href="#">Handouts</a></div>
     <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="Handouts" href="#">Handouts</a></div>
+    @if(!$note->is_non_medical)
     <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="Prescriptions" href="#">ERx &amp; Orders</a></div>
     <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="Prescriptions" href="#">ERx &amp; Orders</a></div>
+    @endif
     <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="Incoming Reports" href="#">Incoming Reports</a></div>
     <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="Incoming Reports" href="#">Incoming Reports</a></div>
     <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="RM Setup" href="#">RM Setup</a></div>
     <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="RM Setup" href="#">RM Setup</a></div>
     <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="Supply Orders Summary" href="#">Supply Orders Summary</a></div>
     <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="Supply Orders Summary" href="#">Supply Orders Summary</a></div>
     <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="Vitals Settings" href="#">Vitals Settings</a></div>
     <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="Vitals Settings" href="#">Vitals Settings</a></div>
     <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="ICDs" href="#">ICDs</a></div>
     <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="ICDs" href="#">ICDs</a></div>
-    @if($pro->pro_type === 'ADMIN')
-        <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="Bills & Claims Summary" href="#">Bills & Claims Summary</a></div>
-    @endif
-    @if($note->method === 'IN_CLINIC' || $pro->pro_type === 'ADMIN')
-        <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="Pro/Payer Settings" href="#">Pro/Payer Settings</a></div>
-    @endif
-    @if($pro->pro_type === 'ADMIN' || ($note->hcpPro && $pro->id === $note->hcpPro->id))
-        <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="HCP Bills" href="#">HCP Bills</a></div>
-    @endif
-    @if($pro->pro_type === 'ADMIN' || ($note->allyPro && $pro->id === $note->allyPro->id))
-        <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="NA Bills" href="#">NA Bills</a></div>
+    @if(!$note->is_non_medical)
+        @if($pro->pro_type === 'ADMIN')
+            <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="Bills & Claims Summary" href="#">Bills & Claims Summary</a></div>
+        @endif
+        @if($note->method === 'IN_CLINIC' || $pro->pro_type === 'ADMIN')
+            <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="Pro/Payer Settings" href="#">Pro/Payer Settings</a></div>
+        @endif
+        @if($pro->pro_type === 'ADMIN' || ($note->hcpPro && $pro->id === $note->hcpPro->id))
+            <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="HCP Bills" href="#">HCP Bills</a></div>
+        @endif
+        @if($pro->pro_type === 'ADMIN' || ($note->allyPro && $pro->id === $note->allyPro->id))
+            <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="NA Bills" href="#">NA Bills</a></div>
+        @endif
+        <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="Claims" href="#">Claims</a></div>
     @endif
     @endif
-    <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="Claims" href="#">Claims</a></div>
     @if($note->is_signed_by_hcp)
     @if($note->is_signed_by_hcp)
         <div class="note-tree-node mb-3"><a native="" target="_top" data-non-segment-target="Addendums" href="#">Addendums</a></div>
         <div class="note-tree-node mb-3"><a native="" target="_top" data-non-segment-target="Addendums" href="#">Addendums</a></div>
     @endif
     @endif

+ 14 - 0
resources/views/app/patient/note/note-segment-list-resolve.blade.php

@@ -0,0 +1,14 @@
+<div class="segments-list d-flex align-items-stretch" id="note-segments-list">
+
+	@if(count($note->segmentsLeft))
+		<div class="flex-grow-1">
+			@include('app.patient.note.note-segment-list-single-col', ['segments' => $note->segmentsLeft])
+		</div>
+	@endif
+	@if(count($note->segmentsRight))
+		<div class="min-width-50 width-50 border-left">
+			@include('app.patient.note.note-segment-list-single-col', ['segments' => $note->segmentsRight])
+		</div>
+	@endif
+</div>
+

+ 33 - 0
resources/views/app/patient/note/note-segment-list-single-col.blade.php

@@ -0,0 +1,33 @@
+<?php
+$previousHeading = null;
+$previousSubHeading = null;
+?>
+@foreach($segments as $segment)
+    @if($segment->segmentTemplate->internal_name !== 'medrisk_vigilence')
+        <?php
+        if ($segment->heading !== $previousHeading) {
+        if (!empty($previousHeading)) {
+            echo '</div></div>'; // <!-- end the previous parent section -->
+        }
+        if (!empty($segment->heading)) {
+
+        ?>
+        <div class="note-content-node note-content-heading">
+            <div class="py-2 px-3 border-bottom font-size-16 font-weight-bold bg-light text-secondary {{ $previousHeading ? 'mt-4 border-top' : '' }}">
+                {{ $segment->heading }}
+            </div>
+            <div class="note-content-children ml-5 border-left">
+                <!-- open new node -->
+        <?php
+        }
+        $previousHeading = $segment->heading;
+        }
+        ?>
+        @include('app.patient.note.segment-resolve')
+    @endif
+@endforeach
+<?php
+if (!empty($previousHeading)) {
+    echo '</div></div>'; // <!-- close any open parent section -->
+}
+?>

+ 5 - 1
resources/views/app/patient/note/note-segment-list-slim.blade.php

@@ -30,7 +30,11 @@
                 @if($suggestionModeOn)
                 @if($suggestionModeOn)
                     @include('app.patient.note.segment.suggestions_and_updates')
                     @include('app.patient.note.segment.suggestions_and_updates')
                 @else
                 @else
-                    @include('app.patient.note.segment-slim')
+                    @if($note->visitTemplate->segments_always_open && !$note->is_signed_by_hcp)
+                        @include('app.patient.note.segment-always-open')
+                    @else
+                        @include('app.patient.note.segment-slim')
+                    @endif
                 @endif
                 @endif
             </div>
             </div>
            
            

+ 64 - 0
resources/views/app/patient/note/partials/bill-flags-history.blade.php

@@ -0,0 +1,64 @@
+<?php
+
+use App\Models\AdministratorBillFlagUpdate;
+
+$recentBillFlags = AdministratorBillFlagUpdate::where('bill_id', $bill->id)->orderBy('created_at', 'DESC')->limit(5)->get();
+?>
+@if(count($recentBillFlags))
+<div moe relative wide center class="ml-2 mr-2">
+	<a start show title="View Bill 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 Bill 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">Admin Flag Memo</th>
+						<th class="border-bottom-0">HCP Ack. Memo</th>
+					</tr>
+				</thead>
+				<tbody>
+					@foreach($recentBillFlags 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->administrator_flag_memo ?></small>
+								@if($bf->billFlagAcknowledgedByProAdmin)
+								<div class="d-flex align-items-center">
+									<span class="text-sm">By: {{ $bf->billFlagAcknowledgedByProAdmin->displayName() }}</span>
+									<span class="text-sm ml-2">At: {{ friendly_date_time($bf->flagged_administrator_at) }}</span>
+								</div>
+								@endif
+							</div>
+						</td>
+						<td>
+							<div class="d-flex flex-column">
+								<small class="text-sm text-muted"><?= $bf->administrator_flag_acknowledgement_memo ?></small>
+								@if($bf->billFlagAcknowledgedByPro)
+								<div class="d-flex align-items-center">
+									<span class="text-sm">By: {{ $bf->billFlagAcknowledgedByPro->displayName() }}</span>
+									<span class="text-sm ml-2">At: {{ friendly_date_time($bf->administrator_flag_acknowledged_at) }}</span>
+								</div>
+								@endif
+							</div>
+						</td>
+					</tr>
+					@endforeach
+					@if(!count($recentBillFlags))
+						<tr>
+							<td colspan="3">No records found</td>
+						</tr>
+					@endif
+				</tbody>
+			</table>
+		</div>
+	</form>
+</div>
+@endif

+ 100 - 0
resources/views/app/patient/note/partials/care-plan-details.blade.php

@@ -0,0 +1,100 @@
+<table class="table-sm table-bordered v-top">
+    <tr>
+        <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">
+                            @if($patient->cm_setup_note_id === $note->id)
+                                <i class="fa fa-check"></i>
+                                <b>Created on this note</b>
+                            @elseif($patient->cmSetupNote)
+                                <i class="fa fa-check"></i>
+                                <b>Created on</b>
+                                <div class="d-inline position-relative on-click-menu">
+                                    <span class="text-primary c-pointer">{{friendly_date($patient->cmSetupNote->effective_dateest)}}</span>
+                                    <div menu right class="bg-white border">
+                                        <a native target="_blank"
+                                           href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $patient->cmSetupNote]) ?>"
+                                           class="px-2 py-1 d-block text-nowrap text-sm">Go to note</a>
+                                    </div>
+                                </div>
+                            @else
+                                <i class="fa fa-exclamation-triangle text-warning-mellow"></i>
+                                <b class="text-warning-mellow">Performed, but CM setup note missing!</b> <!-- will never reach this point -->
+                            @endif
+                        </div>
+                        @if($patient->mcp_pro_id === $pro->id || $pro->pro_type === 'ADMIN')
+                            <div moe class="ml-2">
+                                <a href="" show start>Undo</a>
+                                <form url="/api/note/undoMarkCmSetupPerformed" >
+                                    <input type="hidden" name="uid" value="{{$note->uid}}">
+                                    <p>Mark Comprehensive Care Plan as not created?</p>
+                                    <div class="mb-0">
+                                        <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                    </div>
+                                </form>
+                            </div>
+                        @endif
+                    @else
+                        <span class="text-nowrap text-warning-mellow">
+                                    <i class="fa fa-times"></i>
+                                    <b>Not Created</b>
+                                </span>
+                        @if($patient->mcp_pro_id === $pro->id || $pro->pro_type === 'ADMIN')
+                            <div moe class="ml-2">
+                                <a href="#" show start>Mark as created</a>
+                                <form url="/api/note/markCmSetupPerformed" >
+                                    <input type="hidden" name="uid" value="{{$note->uid}}">
+                                    <p>Mark Comprehensive Care Plan as created?</p>
+                                    <div class="mb-0">
+                                        <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                    </div>
+                                </form>
+                            </div>
+                        @endif
+                    @endif
+                </div>
+                @if($pro->pro_type === 'ADMIN' && $note->was_cm_setup_performed)
+                    <div class="d-flex align-items-baseline">
+                        <div class="d-inline-flex align-items-center flex-grow-1 ml-3">
+                            <span class="pr-1">Manager Signature:</span>
+                            @if($note->cm_setup_manager_signature_status !== 'SIGNED')
+                                <div moe class="">
+                                    <a start show>Sign</a>
+                                    <form url="/api/note/updateCmSetupManagerSignatureStatus" class="mcp-theme-1">
+                                        <input type="hidden" name="uid" value="{{$note->uid}}">
+                                        <input type="hidden" name="managerSignatureStatus" value="SIGNED">
+                                        <p>Sign Off Care Plan Creation as Manager?</p>
+                                        <div>
+                                            <button submit class="btn btn-sm btn-success mr-1">Sign</button>
+                                            <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                        </div>
+                                    </form>
+                                </div>
+                            @else
+                                <b class="pr-1">SIGNED</b>
+                                <div moe class="">
+                                    <a start show>Undo</a>
+                                    <form url="/api/note/updateCmSetupManagerSignatureStatus" class="mcp-theme-1">
+                                        <input type="hidden" name="uid" value="{{$note->uid}}">
+                                        <input type="hidden" name="managerSignatureStatus" value="">
+                                        <p>Undo sign as manager for Care Plan Creation?</p>
+                                        <div>
+                                            <button submit class="btn btn-sm btn-primary mr-1">Undo</button>
+                                            <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                        </div>
+                                    </form>
+                                </div>
+                            @endif
+                        </div>
+                    </div>
+                @endif
+                @include('app.patient.note.flag-care-plan')
+            </div>
+        </td>
+    </tr>
+</table>

+ 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

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác