Преглед на файлове

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

root преди 3 години
родител
ревизия
5f09c0fa66
променени са 42 файла, в които са добавени 1707 реда и са изтрити 226 реда
  1. 43 1
      app/Helpers/helpers.php
  2. 144 7
      app/Http/Controllers/HomeController.php
  3. 1 3
      app/Http/Controllers/NoteController.php
  4. 183 0
      app/Http/Controllers/PracticeManagementController.php
  5. 10 0
      app/Models/Client.php
  6. 100 1
      app/Models/Pro.php
  7. 1 1
      config/app.php
  8. 12 0
      public/css/style.css
  9. 10 1
      public/js/mc.js
  10. 163 31
      resources/views/app/dashboard.blade.php
  11. 26 1
      resources/views/app/generic-bills/add-bill-form/Note.blade.php
  12. 4 0
      resources/views/app/generic-bills/add-bill-form/_default-actions.blade.php
  13. 30 24
      resources/views/app/generic-bills/add-bill-form/_default-fields.blade.php
  14. 54 37
      resources/views/app/generic-bills/add-bill-form/_default-script.blade.php
  15. 3 0
      resources/views/app/generic-bills/add-bill-form/default.blade.php
  16. 5 1
      resources/views/app/generic-bills/inline.blade.php
  17. 2 2
      resources/views/app/patient/care-months.blade.php
  18. 3 1
      resources/views/app/patient/note/_create-bill.blade.php
  19. 73 27
      resources/views/app/patient/note/dashboard.blade.php
  20. 12 6
      resources/views/app/patient/tickets.blade.php
  21. 2 0
      resources/views/app/patient/tickets/erx-data.blade.php
  22. 1 1
      resources/views/app/patient/tickets/erx.blade.php
  23. 2 0
      resources/views/app/patient/tickets/imaging-data.blade.php
  24. 1 1
      resources/views/app/patient/tickets/imaging.blade.php
  25. 2 0
      resources/views/app/patient/tickets/lab-data.blade.php
  26. 1 1
      resources/views/app/patient/tickets/lab.blade.php
  27. 12 0
      resources/views/app/patient/tickets/other.blade.php
  28. 9 1
      resources/views/app/patient/tickets/pharmacy-suggest.blade.php
  29. 20 8
      resources/views/app/patient/tickets/pharmacy.blade.php
  30. 1 0
      resources/views/app/pharmacy-suggest.blade.php
  31. 1 0
      resources/views/app/practice-management/notes.blade.php
  32. 58 0
      resources/views/app/practice-management/pro-financials.blade.php
  33. 133 46
      resources/views/app/practice-management/processing-bill-matrix.blade.php
  34. 182 0
      resources/views/app/practice-management/remote-monitoring-measurements.blade.php
  35. 117 0
      resources/views/app/practice-management/remote-monitoring.blade.php
  36. 153 0
      resources/views/app/practice-management/rm-bills-to-sign.blade.php
  37. 1 1
      resources/views/app/practice-management/supply-orders.blade.php
  38. 9 7
      resources/views/layouts/patient.blade.php
  39. 1 0
      resources/views/layouts/template-no-mc.blade.php
  40. 17 16
      resources/views/layouts/template.blade.php
  41. 8 0
      routes/web.php
  42. 97 0
      spec/rm-care-month-spec.txt

+ 43 - 1
app/Helpers/helpers.php

@@ -355,7 +355,49 @@ if(!function_exists('friendly_month')) {
         if(!$value || empty($value)) return "-";
         try {
             $result = strtotime($value);
-            $result = date("M o", $result);
+            $result = date("F o", $result);
+            return $result;
+        }
+        catch (Exception $e) {
+            return $value;
+        }
+    }
+}
+
+if(!function_exists('day_part_from_date')) {
+    function day_part_from_date($value) {
+        if(!$value || empty($value)) return "-";
+        try {
+            $result = strtotime($value);
+            $result = date("d", $result);
+            return $result;
+        }
+        catch (Exception $e) {
+            return $value;
+        }
+    }
+}
+
+if(!function_exists('month_part_from_date')) {
+    function month_part_from_date($value) {
+        if(!$value || empty($value)) return "-";
+        try {
+            $result = strtotime($value);
+            $result = date("m", $result);
+            return $result;
+        }
+        catch (Exception $e) {
+            return $value;
+        }
+    }
+}
+
+if(!function_exists('year_part_from_date')) {
+    function year_part_from_date($value) {
+        if(!$value || empty($value)) return "-";
+        try {
+            $result = strtotime($value);
+            $result = date("Y", $result);
             return $result;
         }
         catch (Exception $e) {

+ 144 - 7
app/Http/Controllers/HomeController.php

@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
 use App\Lib\Backend;
 use App\Models\Appointment;
 use App\Models\AppSession;
+use App\Models\ClientMemo;
 use App\Models\ClientProChange;
 use App\Models\ClientSMS;
 use App\Models\Facility;
@@ -238,6 +239,11 @@ class HomeController extends Controller
             })->count();
             $keyNumbers['pendingNotesToSign'] = $pendingNotesToSign;
 
+        $pendingNotesToSignAllySigned = Note::where(function ($query) use ($performerProID) {
+            $query->where('hcp_pro_id', $performerProID)->where('is_signed_by_hcp', false)->where('is_signed_by_ally', true)->where('is_cancelled', false);;
+        })->count();
+        $keyNumbers['pendingNotesToSignAllySigned'] = $pendingNotesToSignAllySigned;
+
 
         $signedNotesWithoutBills = Note::where(function ($query) use ($performerProID) {
             $query->where('hcp_pro_id', $performerProID)->where('is_signed_by_hcp', true)->where('is_cancelled', false);;
@@ -255,9 +261,6 @@ class HomeController extends Controller
             })
             ->count();
 
-        // num measurements that need stamping
-        $keyNumbers['measurementsToBeStamped'] = ($this->performer()->pro->pro_type === 'ADMIN' ? '-' : count($this->performer()->pro->getMeasurements(true)));
-
         // unacknowledged cancelled bills for authed pro
         $keyNumbers['unacknowledgedCancelledBills'] = Bill::where('hcp_pro_id', $performerProID)
             ->where('is_cancelled', true)
@@ -390,6 +393,32 @@ class HomeController extends Controller
             ->whereNull('current_client_pro_change_decision_id')
             ->get();
 
+        // unstamped client memos
+        // for mcp
+        $mcpClientMemos = DB::select(
+            DB::raw("
+SELECT c.uid as client_uid, c.name_first, c.name_last,
+       cm.uid, cm.content, cm.created_at
+FROM client c join client_memo cm on c.id = cm.client_id
+WHERE
+      c.mcp_pro_id = {$performerProID} AND
+      cm.mcp_stamp_id IS NULL
+ORDER BY cm.created_at DESC
+            ")
+        );
+        // for na
+        $naClientMemos = DB::select(
+            DB::raw("
+SELECT c.uid as client_uid, c.name_first, c.name_last,
+       cm.uid, cm.content, cm.created_at
+FROM client c join client_memo cm on c.id = cm.client_id
+WHERE
+      c.default_na_pro_id = {$performerProID} AND
+      cm.default_na_stamp_id IS NULL
+ORDER BY cm.created_at DESC
+            ")
+        );
+
         $naBillableSignedNotes = DB::select(DB::raw("
 SELECT count(note.id) as na_billable_notes
 FROM note
@@ -416,11 +445,91 @@ WHERE
 
         $keyNumbers['naBillableSignedNotes'] = $naBillableSignedNotes;
 
+        $keyNumbers['rmBillsToSign'] = Bill
+            ::where('is_cancelled', false)
+            ->where('cm_or_rm', 'RM')
+            ->where(function ($q) use ($performerProID) {
+                $q
+                    ->where(function ($q2) use ($performerProID) {
+                        $q2->where('hcp_pro_id', $performerProID)->where('is_signed_by_hcp', false);
+                    })
+                    ->orWhere(function ($q2) use ($performerProID) {
+                        $q2->where('rme_pro_id', $performerProID)->where('is_signed_by_rme', false);
+                    })
+                    ->orWhere(function ($q2) use ($performerProID) {
+                        $q2->where('rmm_pro_id', $performerProID)->where('is_signed_by_rmm', false);
+                    })
+                    ->orWhere(function ($q2) use ($performerProID) {
+                        $q2->where('generic_pro_id', $performerProID)->where('is_signed_by_generic_pro', false);
+                    });
+            })
+            ->count();
+
+        $count = DB::select(
+            DB::raw(
+                "
+SELECT count(client.id) as cnt FROM client join care_month on care_month.client_id = client.id
+WHERE ((client.mcp_pro_id = {$performer->pro->id}) OR (client.rmm_pro_id = {$performer->pro->id})
+          OR (client.rme_pro_id = {$performer->pro->id}) OR (client.default_na_pro_id = {$performer->pro->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.number_of_days_with_remote_measurements < 16 OR care_month.number_of_days_with_remote_measurements IS NULL)
+"
+            )
+        );
+        $keyNumbers['rmPatientsWithLT16MD'] = $count[0]->cnt;
+
+        $count = DB::select(
+            DB::raw(
+                "
+SELECT count(client.id) as cnt FROM client join care_month on care_month.client_id = client.id
+WHERE ((client.mcp_pro_id = {$performer->pro->id}) OR (client.rmm_pro_id = {$performer->pro->id})
+          OR (client.rme_pro_id = {$performer->pro->id}) OR (client.default_na_pro_id = {$performer->pro->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.number_of_days_with_remote_measurements >= 16 AND care_month.number_of_days_with_remote_measurements IS NOT NULL)
+"
+            )
+        );
+        $keyNumbers['rmPatientsWithGTE16MD'] = $count[0]->cnt;
+
+        $count = DB::select(
+            DB::raw(
+                "
+SELECT count(client.id) as cnt FROM client join care_month on care_month.client_id = client.id
+WHERE ((client.mcp_pro_id = {$performer->pro->id}) OR (client.rmm_pro_id = {$performer->pro->id})
+          OR (client.rme_pro_id = {$performer->pro->id}) OR (client.default_na_pro_id = {$performer->pro->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.has_non_hcp_communicated_to_patient_about_rm = TRUE AND care_month.has_non_hcp_communicated_to_patient_about_rm IS NOT NULL)
+"
+            )
+        );
+        $keyNumbers['rmPatientsWithWhomCommDone'] = $count[0]->cnt;
+
+        $count = DB::select(
+            DB::raw(
+                "
+SELECT count(client.id) as cnt FROM client join care_month on care_month.client_id = client.id
+WHERE ((client.mcp_pro_id = {$performer->pro->id}) OR (client.rmm_pro_id = {$performer->pro->id})
+          OR (client.rme_pro_id = {$performer->pro->id}) OR (client.default_na_pro_id = {$performer->pro->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.has_non_hcp_communicated_to_patient_about_rm = FALSE OR care_month.has_non_hcp_communicated_to_patient_about_rm IS NULL)
+"
+            )
+        );
+        $keyNumbers['rmPatientsWithWhomCommNotDone'] = $count[0]->cnt;
+
+        // num measurements that need stamping
+        $keyNumbers['measurementsToBeStamped'] = $this->performer()->pro->getUnstampedMeasurementsFromCurrentMonth(true, null, null);
+
         return view('app/dashboard', compact('keyNumbers', 'reimbursement', 'milliseconds',
             'businessNumbers',
             'incomingReports', 'tickets', 'supplyOrders',
             'numERx', 'numLabs', 'numImaging', 'numSupplyOrders',
-            'newMCPAssociations', 'newNAAssociations'));
+            'newMCPAssociations', 'newNAAssociations',
+            'mcpClientMemos', 'naClientMemos'));
     }
 
     public function dashboardMeasurementsTab(Request $request, $page = 1) {
@@ -460,7 +569,7 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
 " .
                 (
                 $performer->pro->pro_type != 'ADMIN' ? $ifNotAdmin : ''
-                )
+  )
             )
         );
 
@@ -495,7 +604,7 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
 " .
                 (
                 $performer->pro->pro_type != 'ADMIN' ? $ifNotAdmin : ''
-                )
+  )
             ) .
             " ORDER BY measurement.ts DESC LIMIT 20 OFFSET " . (($page - 1) * 20)
 
@@ -661,6 +770,15 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
         $pro = $this->pro;
         $term = $request->input('term') ? trim($request->input('term')) : '';
         if (empty($term)) return '';
+
+        // if multiple words in query, check for all (max 2)
+        $term2 = '';
+        if(strpos($term, ' ') !== FALSE) {
+            $terms = explode(' ', $term);
+            $term = trim($terms[0]);
+            $term2 = trim($terms[1]);
+        }
+
         $clientQuery= Client::whereNull('shadow_pro_id')
             ->where(function ($q) use ($term) {
                 $q->where('name_first', 'ILIKE', '%' . $term . '%')
@@ -669,6 +787,15 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
                     ->orWhere('phone_home', 'ILIKE', '%' . $term . '%');
             });
 
+        if(!empty($term2)) {
+            $clientQuery = $clientQuery->where(function ($q) use ($term2) {
+                $q->where('name_first', 'ILIKE', '%' . $term2 . '%')
+                    ->orWhere('name_last', 'ILIKE', '%' . $term2 . '%')
+                    ->orWhere('cell_number', 'ILIKE', '%' . $term2 . '%')
+                    ->orWhere('phone_home', 'ILIKE', '%' . $term2 . '%');
+            });
+        }
+
         if(!($pro->pro_type === 'ADMIN' && $pro->can_see_any_client_via_search)) {
             $clientQuery->where(function ($q) use ($pro) {
                 $q->whereIn('id', $pro->getMyClientIds(true))
@@ -694,7 +821,17 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
                     ->orWhereRaw('LOWER(address_state::text) LIKE ?', ['%' . $term . '%'])
                     ->orWhereRaw('LOWER(phone::text) LIKE ?', ['%' . $term . '%'])
                     ->orWhereRaw('LOWER(address_zip::text) LIKE ?', ['%' . $term . '%']);
-            })
+            });
+        if($request->input('city')) {
+            $pharmacies = $pharmacies->whereRaw('LOWER(address_city::text) LIKE ?', ['%' . strtolower($request->input('city')) . '%']);
+        }
+        if($request->input('state')) {
+            $pharmacies = $pharmacies->whereRaw('LOWER(address_state::text) LIKE ?', ['%' . strtolower($request->input('state')) . '%']);
+        }
+        if($request->input('zip')) {
+            $pharmacies = $pharmacies->whereRaw('LOWER(address_zip::text) LIKE ?', ['%' . strtolower($request->input('zip')) . '%']);
+        }
+        $pharmacies = $pharmacies
             ->orderBy('name', 'asc')
             ->orderBy('address_line1', 'asc')
             ->orderBy('address_city', 'asc')

+ 1 - 3
app/Http/Controllers/NoteController.php

@@ -34,8 +34,6 @@ class NoteController extends Controller
             }
         }
 
-        $allyPros = Pro::all(); //TODO: paginate, use select2
-
         // load tickets created on note->effective_date for patient
         $ticketsOnNote = Ticket::where('client_id', $patient->id)
             ->where('is_entry_error', false)
@@ -63,7 +61,7 @@ class NoteController extends Controller
             ->get();
 
         return view('app.patient.note.dashboard', compact('patient', 'note',
-            'allyPros', 'allSections',
+            'allSections',
             'ticketsOnNote', 'otherOpenTickets',
             'supplyOrdersOnNote', 'otherOpenSupplyOrders'));
     }

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

@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
 
 use App\Models\AppSession;
 use App\Models\BillingReport;
+use App\Models\CareMonth;
 use App\Models\ClaimEDI;
 use App\Models\Handout;
 use App\Models\MBClaim;
@@ -116,6 +117,10 @@ class PracticeManagementController extends Controller
                 $query = $query->where('is_signed_by_hcp', false);
                 break;
 
+            case 'not-yet-signed-but-ally-signed':
+                $query = $query->where('is_signed_by_hcp', false)->where('is_signed_by_ally', true);
+                break;
+
             case 'without-bills':
                 $query = $query->where('is_signed_by_hcp', true)->where('is_cancelled', false)->whereDoesntHave('bills');
 
@@ -199,6 +204,31 @@ class PracticeManagementController extends Controller
         return view('app.practice-management.bills', compact('bills', 'filter'));
     }
 
+    public function rmBillsToSign(Request $request)
+    {
+        $performerProID = $this->performer()->pro->id;
+        $bills = Bill::where('is_cancelled', false)->where('cm_or_rm', 'RM')
+            ->where(function ($q) use ($performerProID) {
+                $q
+                    ->where(function ($q2) use ($performerProID) {
+                        $q2->where('hcp_pro_id', $performerProID)->where('is_signed_by_hcp', false);
+                    })
+                    ->orWhere(function ($q2) use ($performerProID) {
+                        $q2->where('rme_pro_id', $performerProID)->where('is_signed_by_rme', false);
+                    })
+                    ->orWhere(function ($q2) use ($performerProID) {
+                        $q2->where('rmm_pro_id', $performerProID)->where('is_signed_by_rmm', false);
+                    })
+                    ->orWhere(function ($q2) use ($performerProID) {
+                        $q2->where('generic_pro_id', $performerProID)->where('is_signed_by_generic_pro', false);
+                    });
+            })
+            ->orderBy('effective_date', 'desc')
+            ->get();
+
+        return view('app.practice-management.rm-bills-to-sign', compact('bills'));
+    }
+
     public function unacknowledgedCancelledBills(Request $request)
     {
         $bills = Bill::where('hcp_pro_id', $this->performer()->pro->id)
@@ -548,6 +578,16 @@ class PracticeManagementController extends Controller
                 break;
         }
 
+        $filter = $request->input('bs');
+        if ($filter) {
+            $bills = $bills->where('balance_post_date', '>=', $filter);
+        }
+
+        $filter = $request->input('be');
+        if ($filter) {
+            $bills = $bills->where('balance_post_date', '<=', $filter);
+        }
+
         $bills = $bills->orderBy('effective_date', 'desc')->paginate();
 
         $viewData = [
@@ -559,6 +599,28 @@ class PracticeManagementController extends Controller
         return view('app.practice-management.processing-bill-matrix', $viewData);
     }
 
+    public function proFinancials(Request $request, $proUid = null)
+    {
+        $proUid = $proUid ? $proUid : $request->get('pro-uid');
+        $performerPro = $this->performer->pro;
+        $targetPro = null;
+        if ($performerPro->pro_type == 'ADMIN') {
+            $targetPro = Pro::where('uid', $proUid)->first();
+        } else {
+            $targetPro = $performerPro;
+        }
+        $fPros = Pro::whereNotNull('balance');
+        if($targetPro) {
+            $fPros = $fPros->where('uid', $targetPro->uid);
+        }
+        $fPros = $fPros
+            ->where('balance', '>', 0)
+            ->orderBy('name_last')
+            ->orderBy('name_first')
+            ->paginate();
+        return view('app.practice-management.pro-financials', compact('fPros', 'targetPro'));
+    }
+
     public function hcpBillMatrix(Request $request, $proUid = null)
     {
         $proUid = $proUid ? $proUid : $request->get('pro-uid');
@@ -664,6 +726,127 @@ class PracticeManagementController extends Controller
         return view('app.practice-management.billing-manager', compact('notes', 'allPros', 'expectedForHcp', 'targetPro', 'proUid', 'filters'));
     }
 
+    public function remoteMonitoring(Request $request) {
+
+        $performer = $this->performer();
+
+        $ym = ($request->input('y') ?: 'Y') . '-' . ($request->input('m') ?: 'm');
+        $careMonthStart = date($ym . '-01');
+
+        // filters
+        $filters = '';
+        $fmd = $request->input('fmd');
+        if($fmd && $fmd !== 'all') {
+            switch($fmd) {
+                case 'lt16':
+                    $filters .= ' AND (care_month.number_of_days_with_remote_measurements < 16 OR care_month.number_of_days_with_remote_measurements IS NULL) ';
+                    break;
+                case 'gte16':
+                    $filters .= ' AND (care_month.number_of_days_with_remote_measurements >= 16 AND care_month.number_of_days_with_remote_measurements IS NOT NULL) ';
+                    break;
+            }
+        }
+        $fcomm = $request->input('fcomm');
+        if($fcomm && $fcomm !== 'all') {
+            switch($fcomm) {
+                case 'not-done':
+                    $filters .= ' AND (care_month.has_non_hcp_communicated_to_patient_about_rm = FALSE OR care_month.has_non_hcp_communicated_to_patient_about_rm IS NULL) ';
+                    break;
+                case 'done':
+                    $filters .= ' AND (care_month.has_non_hcp_communicated_to_patient_about_rm = TRUE AND care_month.has_non_hcp_communicated_to_patient_about_rm IS NOT NULL) ';
+                    break;
+            }
+        }
+        $c = $request->input('c');
+        if($c) {
+            $filters .= ' AND client.uid = \'' . $request->input('c') . '\' ';
+        }
+
+        $patients = DB::select(
+            DB::raw(
+                "
+SELECT client.name_first, client.name_last, client.uid as client_uid,
+       care_month.uid as care_month_uid,
+       care_month.id as care_month_id,
+       care_month.start_date,
+       care_month.number_of_days_with_remote_measurements,
+       care_month.has_non_hcp_communicated_to_patient_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,
+       client.mcp_pro_id,
+       client.default_na_pro_id,
+       client.rmm_pro_id,
+       client.rme_pro_id,
+       client.cell_number
+FROM care_month join client on care_month.client_id = client.id
+WHERE (
+          (client.mcp_pro_id = {$performer->pro->id})
+          OR (client.rmm_pro_id = {$performer->pro->id})
+          OR (client.rme_pro_id = {$performer->pro->id})
+          OR (client.default_na_pro_id = {$performer->pro->id})
+      )
+  AND EXTRACT(MONTH from care_month.start_date) = " . ($request->input('m') ?: 'EXTRACT(MONTH from now())') . "
+  AND EXTRACT(YEAR from care_month.start_date) = " . ($request->input('y') ?: 'EXTRACT(YEAR from now())') . "
+  {$filters}
+ORDER BY care_month.number_of_days_with_remote_measurements DESC NULLS LAST, client.name_first ASC, client.name_last ASC
+"
+            )
+        );
+
+        $timestamp = strtotime(date('Y-m-d'));
+        $daysRemaining = (int)date('t', $timestamp) - (int)date('j', $timestamp);
+
+        return view('app.practice-management.remote-monitoring', compact('patients', 'daysRemaining', 'careMonthStart'));
+    }
+
+    public function remoteMonitoringMeasurements(Request $request, CareMonth $careMonth) {
+
+        $performer = $this->performer();
+
+        $measurements = DB::select(
+            DB::raw(
+                "
+SELECT measurement.label,
+    measurement.ts,
+    measurement.effective_date,
+    measurement.sbp_mm_hg,
+    measurement.dbp_mm_hg,
+    measurement.value_pulse,
+    measurement.value_irregular,
+    measurement.numeric_value,
+    measurement.value,
+    measurement.uid,
+    client.name_first,
+    client.name_last,
+    client.mcp_pro_id,
+    client.default_na_pro_id,
+    client.rmm_pro_id,
+    client.rme_pro_id
+FROM measurement RIGHT JOIN client on measurement.client_id = client.id
+WHERE
+    client.id = {$careMonth->client_id}
+    AND measurement.label IS NOT NULL  
+    AND measurement.label NOT IN ('SBP', 'DBP')
+    AND (measurement.is_cellular_zero = FALSE or measurement.is_cellular_zero IS NULL)
+    AND measurement.is_removed IS FALSE
+    AND measurement.client_bdt_measurement_id IS NOT NULL
+    AND measurement.care_month_id = {$careMonth->id}
+    AND (
+        (client.mcp_pro_id = {$performer->pro->id} AND measurement.has_been_stamped_by_mcp IS FALSE)
+        OR (client.rmm_pro_id = {$performer->pro->id} AND measurement.has_been_stamped_by_rmm IS FALSE)
+        OR (client.rme_pro_id = {$performer->pro->id} AND measurement.has_been_stamped_by_rme IS FALSE)
+        OR (client.default_na_pro_id = {$performer->pro->id} AND measurement.has_been_stamped_by_non_hcp IS FALSE)
+    )
+ORDER BY ts DESC
+"
+            )
+        );
+
+        return view('app.practice-management.remote-monitoring-measurements', compact('careMonth', 'measurements'));
+    }
+
     public function billMatrix(Request $request)
     {
         $bClients = [];

+ 10 - 0
app/Models/Client.php

@@ -402,6 +402,8 @@ class Client extends Model
         if ($pro && $pro->id) $pros[] = ["pro" => $pro->displayName(), "association" => 'RMM'];
         $pro = $this->rme;
         if ($pro && $pro->id) $pros[] = ["pro" => $pro->displayName(), "association" => 'RME'];
+        $pro = $this->defaultNaPro;
+        if ($pro && $pro->id) $pros[] = ["pro" => $pro->displayName(), "association" => 'Default NA'];
 
         // via client pro access
         $cpAccesses = ClientProAccess::where('client_id', $this->id)->where('is_active', true)->get();
@@ -552,4 +554,12 @@ class Client extends Model
             ->get();
     }
 
+    public function firstPageByCategoryAndKey($_category, $_key) {
+        return Page
+            ::where('client_id', $this->id)
+            ->where('category', $_category)
+            ->where('key', $_key)
+            ->first();
+    }
+
 }

+ 100 - 1
app/Models/Pro.php

@@ -90,6 +90,14 @@ class Pro extends Model
             ->get();
     }
 
+    public function recentDebits() {
+        return ProTransaction
+            ::where('pro_id', $this->id)
+            ->where('plus_or_minus', 'PLUS')
+            ->orderBy('created_at', 'desc')
+            ->skip(0)->take(4)->get();
+    }
+
     public function shortcuts() {
         return $this->hasMany(ProTextShortcut::class, 'pro_id')->where('is_removed', false);
     }
@@ -311,6 +319,7 @@ class Pro extends Model
                     ->orWhere('rmm_pro_id', $proID)
                     ->orWhere('rme_pro_id', $proID)
                     ->orWhere('physician_pro_id', $proID)
+                    ->orWhere('default_na_pro_id', $proID)
                     ->orWhereRaw('id IN (SELECT client_id FROM client_pro_access WHERE is_active AND pro_id = ?)', [$proID])
                     ->orWhereRaw('id IN (SELECT client_id FROM appointment WHERE status NOT IN (\'CANCELLED\', \'ABANDONED\') AND pro_id = ?)', [$proID])
                     ->orWhereRaw('id IN (SELECT mcp_pro_id FROM client_program WHERE client_id = client.id AND is_active = TRUE)')
@@ -334,6 +343,7 @@ class Pro extends Model
                     ->orWhere('rmm_pro_id', $proID)
                     ->orWhere('rme_pro_id', $proID)
                     ->orWhere('physician_pro_id', $proID)
+                    ->orWhere('default_na_pro_id', $proID)
                     ->orWhereRaw('id IN (SELECT client_id FROM client_pro_access WHERE is_active AND pro_id = ?)', [$proID])
                     ->orWhereRaw('id IN (SELECT client_id FROM appointment WHERE status NOT IN (\'CANCELLED\', \'ABANDONED\') AND pro_id = ?)', [$proID])
                     ->orWhereRaw('id IN (SELECT mcp_pro_id FROM client_program WHERE client_id = client.id AND is_active = TRUE)')
@@ -368,6 +378,95 @@ class Pro extends Model
         return $allowed ? $clientPrograms : FALSE;
     }
 
+    public function getUnstampedMeasurementsFromCurrentMonth($_countOnly, $skip, $limit)
+    {
+
+        date_default_timezone_set('US/Eastern');
+
+        $start = strtotime(date('Y-m-01'));
+        $end = date_add(date_create(date('Y-m-01')), date_interval_create_from_date_string("1 month"))->getTimestamp();
+        $start *= 1000;
+        $end *= 1000;
+
+        $measurementsQuery = Measurement::where('is_removed', false)
+            ->join('client', 'client.id', '=', 'measurement.client_id')
+            ->whereNotNull('measurement.client_bdt_measurement_id')
+            ->whereNotNull('measurement.ts')
+            ->where('measurement.is_cellular_zero', false)
+            ->where('measurement.ts', '>=', $start)
+            ->where('measurement.ts', '<', $end)
+            ->whereIn('measurement.client_id', $this->getMyClientIds())
+            ->where(function ($q) {
+                $q
+                    ->where(function ($q2) {
+                        $q2
+                            ->where('client.mcp_pro_id', $this->id)
+                            ->where('measurement.has_been_stamped_by_mcp', false);
+                    })
+                    ->orWhere(function ($q2) {
+                        $q2
+                            ->where('client.default_na_pro_id', $this->id)
+                            ->where('measurement.has_been_stamped_by_non_hcp', false);
+                    })
+                    ->orWhere(function ($q2) {
+                        $q2
+                            ->where('client.rmm_pro_id', $this->id)
+                            ->where('measurement.has_been_stamped_by_rmm', false);
+                    })
+                    ->orWhere(function ($q2) {
+                        $q2
+                            ->where('client.rme_pro_id', $this->id)
+                            ->where('measurement.has_been_stamped_by_rme', false);
+                    });
+            });
+
+        if($_countOnly) {
+            return $measurementsQuery->count();
+        }
+
+        $x = [];
+        $measurements = $measurementsQuery
+            ->orderBy('ts', 'desc')
+            ->skip($skip)
+            ->take($limit)
+            ->get();
+
+        // eager load stuff needed in JS
+        foreach ($measurements as $measurement) {
+//            if ($measurement->client_bdt_measurement_id) {
+//                $measurement->bdtMeasurement = $measurement->clientBDTMeasurement->measurement;
+//            }
+            unset($measurement->clientBDTMeasurement); // we do not need this travelling to the frontend
+
+            $client = [
+                "uid" => $measurement->client->uid,
+                "name" => $measurement->client->displayName(),
+            ];
+            $measurement->patient = $client;
+
+            $measurement->careMonth = $measurement->client->currentCareMonth();
+            $measurement->timestamp = friendlier_date_time($measurement->created_at);
+
+            unset($measurement->client); // we do not need this travelling to the frontend
+
+            if(@$measurement->detail_json) unset($measurement->detail_json);
+            if(@$measurement->canvas_data) unset($measurement->canvas_data);
+            if(@$measurement->latest_measurements) unset($measurement->latest_measurements);
+            if(@$measurement->info_lines) unset($measurement->info_lines);
+            if(@$measurement->canvas_data_backup) unset($measurement->canvas_data_backup);
+            if(@$measurement->migrated_canvas_data_backup) unset($measurement->migrated_canvas_data_backup);
+
+            // if($measurement->label == 'SBP' || $measurement->label = 'DBP'){
+            //     continue;
+            // }
+            $x[] = $measurement;
+        }
+
+        // dd($measurements);
+
+        return $measurements;
+    }
+
     public function getMeasurements($_onlyUnstamped = true)
     {
         $measurementsQuery = Measurement::where('is_removed', false);
@@ -388,7 +487,7 @@ class Pro extends Model
                         });
                 });
         }
-	$x = [];
+	    $x = [];
         $measurements = $measurementsQuery->orderBy('ts', 'desc')->paginate(50);
 
         // eager load stuff needed in JS

+ 1 - 1
config/app.php

@@ -65,7 +65,7 @@ return [
 
     'hrm2_url' => env('HRM2_URL'),
 
-    'asset_version' => 4,
+    'asset_version' => 6,
 
     /*
     |--------------------------------------------------------------------------

+ 12 - 0
public/css/style.css

@@ -1860,3 +1860,15 @@ form.non-interactive .form-content * {
     overflow-y: auto;
     max-height: calc(100vh - 60px);
 }
+.zero-height-field {
+    height: 1px !important;
+    opacity: 0 !important;
+    pointer-events: none;
+    position: absolute;
+}
+table.dashboard-stats-table th {
+    padding: 0.5rem 0.75rem
+}
+.min-height-500px {
+    min-height: 500px;
+}

+ 10 - 1
public/js/mc.js

@@ -251,7 +251,16 @@ function fastLoad(_href, _history = true, _useCache = true, _replaceState = fals
     if (_useCache && !!fastCache[_href]) {
         onFastLoaded(fastCache[_href], _href, _history);
     } else {
-        $.get(_href, function (_data) {
+
+        let cleanedHREF = _href;
+        if(cleanedHREF.length > 1 && cleanedHREF[cleanedHREF.length - 1] === '/') {
+            cleanedHREF = cleanedHREF.substr(0, cleanedHREF.length - 1);
+        }
+        if(cleanedHREF.length > 2) {
+            cleanedHREF = cleanedHREF.replace('/?', '?');
+        }
+
+        $.get(cleanedHREF, function (_data) {
             onFastLoaded(_data, _href, _history);
         }).fail(function (_jqXhr) {
             onFastLoaded(_jqXhr.status, _href, _history);

+ 163 - 31
resources/views/app/dashboard.blade.php

@@ -15,7 +15,7 @@
                         </strong>
                     </div>
                     <div class="card-body p-0">
-                        <table class="table mb-0">
+                        <table class="table mb-0 dashboard-stats-table">
                             <tbody>
                                 <tr>
                                     <th class="border-top-0 px-2 text-center">{{$keyNumbers['totalPatients']}}</th>
@@ -37,19 +37,17 @@
                                     <th class="px-2 text-center">{{$keyNumbers['pendingNotesToSign']}}</th>
                                     <th class="pl-2"><a href="/practice-management/notes/not-yet-signed">Pending notes to sign</a></th>
                                 </tr>
+                                @if(!!$keyNumbers['pendingNotesToSignAllySigned'])
+                                <tr>
+                                    <th class="px-2 text-center">{{$keyNumbers['pendingNotesToSignAllySigned']}}</th>
+                                    <th class="pl-2"><a href="/practice-management/notes/not-yet-signed-but-ally-signed">Pending notes to sign (ally signed)</a></th>
+                                </tr>
+                                @endif
                                
                                 <tr>
                                     <th class="px-2 text-center">{{$keyNumbers['numOpenTickets']}}</th>
                                     <th class="pl-2"><a href="/practice-management/my-tickets/open">Open tickets</a></th>
                                 </tr>
-                                <tr>
-                                    <th class="px-2 text-center">{{$keyNumbers['measurementsToBeStamped']}}</th>
-                                    <th class="pl-2">
-                                        <a native target="_top"
-                                           href="#"
-                                           v-on:click.prevent="tab='measurements'">Unstamped Measurements</a>
-                                    </th>
-                                </tr>
                                 <tr>
                                     <th class="px-2 text-center">{{$keyNumbers['unacknowledgedCancelledBills']}}</th>
                                     <th class="pl-2">
@@ -82,6 +80,57 @@
                                         </th>
                                     </tr>
                                 @endif
+                                <tr>
+                                    <th class="px-2 text-center">{{$keyNumbers['rmBillsToSign']}}</th>
+                                    <th class="pl-2">
+                                        <a href="/practice-management/rm-bills-to-sign">RM Bills to Sign</a>
+                                    </th>
+                                </tr>
+                            </tbody>
+                        </table>
+                    </div>
+                </div>
+                <div class="card mb-4">
+                    <div class="card-header pl-2">
+                        <strong>
+                            Remote Monitoring: {{friendly_month(date('Y-m-d'))}}
+                        </strong>
+                    </div>
+                    <div class="card-body p-0">
+                        <table class="table mb-0 dashboard-stats-table">
+                            <tbody>
+                            <tr>
+                                <th class="px-2 text-center">{{$keyNumbers['rmPatientsWithLT16MD']}}</th>
+                                <th class="pl-2">
+                                    <b>Patients with < 16 meas. days</b>
+                                </th>
+                            </tr>
+                            <tr>
+                                <th class="px-2 text-center">{{$keyNumbers['rmPatientsWithGTE16MD']}}</th>
+                                <th class="pl-2">
+                                    <b>Patients with >= 16 meas. days</b>
+                                </th>
+                            </tr>
+                            @if(!$pro->is_hcp)
+                            <tr>
+                                <th class="px-2 text-center">{{$keyNumbers['rmPatientsWithWhomCommDone']}}</th>
+                                <th class="pl-2">
+                                    <b>Patients with whom comm. not done</b>
+                                </th>
+                            </tr>
+                            <tr>
+                                <th class="px-2 text-center">{{$keyNumbers['rmPatientsWithWhomCommNotDone']}}</th>
+                                <th class="pl-2">
+                                    <b>Patients with whom comm. done</b>
+                                </th>
+                            </tr>
+                            @endif
+                            <tr>
+                                <th class="px-2 text-center">{{$keyNumbers['measurementsToBeStamped']}}</th>
+                                <th class="pl-2">
+                                    <a href="{{route('practice-management.remote-monitoring')}}">Unstamped Measurements</a>
+                                </th>
+                            </tr>
                             </tbody>
                         </table>
                     </div>
@@ -93,7 +142,7 @@
                         </strong>
                     </div>
                     <div class="card-body p-0">
-                        <table class="table mb-0">
+                        <table class="table mb-0 dashboard-stats-table">
                             <tbody>
                                 <tr>
                                     <th class="border-top-0 px-2">${{friendly_money($reimbursement['currentBalance'])}}</th>
@@ -129,7 +178,7 @@
                         </strong>
                     </div>
                     <div class="card-body p-0">
-                        <table class="table mb-0">
+                        <table class="table mb-0 dashboard-stats-table">
                             <tbody>
                             
                             <tr>
@@ -152,30 +201,90 @@
             </div>
             <div class="col-md-9">
 
-                <!-- new associations -->
-                <?php /*
-                @if(count($newMCPAssociations))
-                    <div class="mb-3 border rounded px-3 py-2 ack-container">
-                        <p class="pt-1 mb-2"><b>New Patients</b></p>
-                        @foreach($newMCPAssociations as $assoc)
-                            <div class="mb-1">You have been assigned as the MCP for {{$assoc->patient->displayName()}}.
-                            <a href="#" class="ack-client-pro-change" data-uid="{{$assoc->uid}}">Acknowledge</a>
+                <div class="row">
+                    <div class="col-6">
+                        <!-- new associations -->
+                        @if(count($newMCPAssociations))
+                            <div class="mb-3 border rounded px-3 py-2 ack-container">
+                                <p class="pt-1 mb-2"><b>New Patients</b></p>
+                                @foreach($newMCPAssociations as $assoc)
+                                    <div class="mb-1">You have been assigned as the MCP for
+                                        <a href="/patients/view/{{$assoc->patient->uid}}" class="d-inline-block width-150px">{{$assoc->patient->displayName()}}</a>.
+                                        <a href="#" class="ack-client-pro-change ml-3" data-uid="{{$assoc->uid}}">Stamp</a>
+                                    </div>
+                                @endforeach
                             </div>
-                        @endforeach
-                    </div>
-                @endif
+                        @endif
 
-                @if(count($newNAAssociations))
-                    <div class="mb-3 border rounded px-3 py-2 ack-container">
-                        <p class="pt-1 mb-2"><b>New Patients</b></p>
-                        @foreach($newNAAssociations as $assoc)
-                            <div class="mb-1">You have been assigned as the Care Coordinator for {{$assoc->patient->displayName()}}.
-                                <a href="#" class="ack-client-pro-change" data-uid="{{$assoc->uid}}">Acknowledge</a>
+                        @if(count($newNAAssociations))
+                            <div class="mb-3 border rounded px-3 py-2 ack-container">
+                                <p class="pt-1 mb-2"><b>New Patients</b></p>
+                                @foreach($newNAAssociations as $assoc)
+                                    <div class="mb-1">You have been assigned as the Care Coordinator for
+                                        <a href="/patients/view/{{$assoc->patient->uid}}" class="d-inline-block width-150px">{{$assoc->patient->displayName()}}</a>.
+                                        <a href="#" class="ack-client-pro-change ml-3" data-uid="{{$assoc->uid}}">Stamp</a>
+                                    </div>
+                                @endforeach
                             </div>
-                        @endforeach
+                        @endif
                     </div>
-                @endif
-                */ ?>
+                    <div class="col-6">
+                        @if(count($mcpClientMemos))
+                            <div class="mb-3 border rounded px-3 py-2 ack-container">
+                                <p class="pt-1 mb-2"><b>New Patients Memos (MCP)</b></p>
+                                <table class="table table-sm table-hover table-bordered">
+                                    <thead>
+                                    <tr>
+                                        <th>Patient</th>
+                                        <th>Memo</th>
+                                        <th>Created</th>
+                                        <th></th>
+                                    </tr>
+                                    </thead>
+                                    <tbody>
+                                    @foreach($mcpClientMemos as $memo)
+                                        <tr>
+                                            <td class="">
+                                                <a href="/patients/view/{{$memo->client_uid}}">{{$memo->name_first}} {{$memo->name_last}}</a>
+                                            </td>
+                                            <td>{!! $memo->content !!}</td>
+                                            <td class="text-nowrap">{{friendlier_date_time($memo->created_at)}}</td>
+                                            <td><a href="#" class="ack-client-memo" data-uid="{{$memo->uid}}">Stamp</a></td>
+                                        </tr>
+                                    @endforeach
+                                    </tbody>
+                                </table>
+                            </div>
+                        @endif
+                        @if(count($naClientMemos))
+                            <div class="mb-3 border rounded px-3 py-2 ack-container">
+                                <p class="pt-1 mb-2"><b>New Patients Memos (NA)</b></p>
+                                <table class="table table-sm table-hover table-bordered">
+                                    <thead>
+                                    <tr>
+                                        <th>Patient</th>
+                                        <th>Memo</th>
+                                        <th>Created</th>
+                                        <th></th>
+                                    </tr>
+                                    </thead>
+                                    <tbody>
+                                    @foreach($naClientMemos as $memo)
+                                        <tr>
+                                            <td class="">
+                                                <a href="/patients/view/{{$memo->client_uid}}">{{$memo->name_first}} {{$memo->name_last}}</a>
+                                            </td>
+                                            <td>{!! $memo->content !!}</td>
+                                            <td class="text-nowrap">{{friendlier_date_time($memo->created_at)}}</td>
+                                            <td><a href="#" class="ack-client-memo" data-uid="{{$memo->uid}}">Stamp</a></td>
+                                        </tr>
+                                    @endforeach
+                                    </tbody>
+                                </table>
+                            </div>
+                        @endif
+                    </div>
+                </div>
 
                 <ul class="nav nav-tabs">
                     <li class="nav-item">
@@ -649,6 +758,29 @@
                     }, 'json');
                     return false;
                 });
+
+            $(document)
+                .off('click', '.ack-client-memo')
+                .on('click', '.ack-client-memo', function() {
+                    let trigger = $(this).text('…');
+                    $.post('/api/clientMemo/stamp', {
+                        uid: $(this).attr('data-uid')
+                    }, _data => {
+                        if(!hasResponseError(_data)) {
+                            trigger.hide();
+                            let doneElem = $('<i class="text-success fa fa-check"></i>');
+                            doneElem.insertAfter(trigger);
+                            setTimeout(() => {
+                                let tbody = trigger.closest('tbody');
+                                trigger.closest('tr').remove();
+                                if(!tbody.find('>tr').length) {
+                                    tbody.closest('.ack-container').remove();
+                                }
+                            }, 500);
+                        }
+                    }, 'json');
+                    return false;
+                });
         }
         addMCInitializer('pro-dashboard', init, '#pro-dashboard-container');
     })();

+ 26 - 1
resources/views/app/generic-bills/add-bill-form/Note.blade.php

@@ -1,11 +1,36 @@
+<?php $genericPro = @$note && $note->allyPro ? $note->allyPro : $pro; ?>
+<?php $genericRates = $genericPro->genericRates(); ?>
 <form url="/api/bill/createForGeneric">
-    @if(hasActiveGenericBill($pro, @$patient, @$entityType, @$entityUid))
+    @if(hasActiveGenericBill($genericPro, @$patient, @$entityType, @$entityUid))
         <div class="border rounded bg-aliceblue p-2 width-200px">
             <i class="fa fa-exclamation-triangle text-warning-mellow mr-1"></i>
             An uncancelled NA bill already exists for this note!
         </div>
     @else
         @include('app.generic-bills.add-bill-form._default-fields')
+        <div class="mb-2 border px-2 pt-2 generic-bill-actions">
+            <p class="text-sm mb-1 text-secondary font-weight-bold">Please indicate the activities time was spent on:</p>
+            <input type="text" name="genericDescription" value="" class="zero-height-field m-0 p-0 border-0" required>
+            <label class="d-flex align-items-center">
+                <input type="checkbox" class="mr-2 my-0 generic-bill-action"
+                       data-action="Note reviewed."
+                       onchange="return updateGenericBillAction(this)">
+                <span>Note reviewed.</span>
+            </label>
+            <label class="d-flex align-items-center">
+                <input type="checkbox" class="mr-2 my-0 generic-bill-action"
+                       data-action="Care coordinated."
+                       onchange="return updateGenericBillAction(this)">
+                <span>Care coordinated.</span>
+            </label>
+            <label class="d-flex align-items-center">
+                <input type="checkbox" class="mr-2 my-0 generic-bill-action"
+                       data-action="Admin. support for follow-up."
+                       onchange="return updateGenericBillAction(this)">
+                <span>Admin. support for follow-up.</span>
+            </label>
+        </div>
+        @include('app.generic-bills.add-bill-form._default-actions')
     @endif
 </form>
 @include('app.generic-bills.add-bill-form._default-script')

+ 4 - 0
resources/views/app/generic-bills/add-bill-form/_default-actions.blade.php

@@ -0,0 +1,4 @@
+<div class="">
+    <button class="btn btn-primary btn-sm" submit>Submit</button>
+    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+</div>

+ 30 - 24
resources/views/app/generic-bills/add-bill-form/_default-fields.blade.php

@@ -1,8 +1,8 @@
-<div class="mb-2">
+<div class="mb-2 min-width-300px">
     <label for="" class="text-secondary text-sm">Pro</label>
-    <input type="text" class="form-control form-control-sm" value="{{$pro->displayName()}}" readonly>
+    <input type="text" class="form-control form-control-sm" value="{{$genericPro->displayName()}}" readonly>
 </div>
-<input type="hidden" name="genericProUid" value="{{$pro->uid}}">
+<input type="hidden" name="genericProUid" value="{{$genericPro->uid}}">
 @if(@$note)
     <input type="hidden" name="optionalNoteUid" value="{{$note->uid}}">
 @endif
@@ -15,19 +15,27 @@
 @if(@$entityUid)
     <input type="hidden" name="genericTargetEntityUid" value="{{$entityUid}}">
 @endif
-<div class="mb-2">
-    <label for="" class="text-secondary text-sm">Service</label>
-    <select autofocus class="form-control" name="code"
-            data-entity-type="{{$entityType}}"
-            onchange="switchGenericRate(this)">
-        <option value="">-- Select Code --</option>
-        @foreach($pro->genericRates() as $genericRate)
-            <option data-amount="{{ $genericRate->amount }}" value="{{ $genericRate->code }}">
-                {{ $genericRate->code }} (${{ $genericRate->amount }})
-            </option>
-        @endforeach
-    </select>
-</div>
+@if(count($genericRates) === 1)
+    <input type="hidden" name="code"
+           data-entity-type="{{$entityType}}"
+           data-amount="{{ $genericRates[0]->amount }}"
+           value="{{$genericRates[0]->code}}">
+    <p class="mb-2">Service: <br><b>{{ $genericRates[0]->code }} (${{ $genericRates[0]->amount }}/hr)</b></p>
+@else
+    <div class="mb-2">
+        <label for="" class="text-secondary text-sm">Service</label>
+        <select autofocus class="form-control" name="code"
+                data-entity-type="{{$entityType}}"
+                onchange="switchGenericRate(this)">
+            <option value="">-- Select Code --</option>
+            @foreach($genericPro->genericRates() as $genericRate)
+                <option data-amount="{{ $genericRate->amount }}" value="{{ $genericRate->code }}">
+                    {{ $genericRate->code }} (${{ $genericRate->amount }})
+                </option>
+            @endforeach
+        </select>
+    </div>
+@endif
 <div class="mb-2">
     <?php $maxMinutes = 240; ?>
     <label for="" class="text-secondary text-sm">Minutes</label>
@@ -42,15 +50,13 @@
     </div>
     <div class="mb-2" calculated-generic-amount></div>
 </div>
-<div class="mb-2">
-    <label for="" class="text-secondary text-sm">Description</label>
-    <input type="text" name="genericDescription" class="form-control form-control-sm" value="">
-</div>
+@if($entityType !== 'Note')
+    <div class="mb-2">
+        <label for="" class="text-secondary text-sm">Description</label>
+        <input type="text" name="genericDescription" class="form-control form-control-sm" value="">
+    </div>
+@endif
 <div class="mb-2">
     <label for="" class="text-secondary text-sm">Effective Date</label>
     <input type="date" name="effectiveDate" class="form-control form-control-sm" value="{{date('Y-m-d')}}" required>
 </div>
-<div class="">
-    <button class="btn btn-primary btn-sm" submit>Submit</button>
-    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
-</div>

+ 54 - 37
resources/views/app/generic-bills/add-bill-form/_default-script.blade.php

@@ -1,48 +1,65 @@
 <script>
     (function() {
-        let selectedGenericRate = 0;
-        window.switchGenericRate = function(_trigger) {
-            selectedGenericRate = 0;
-            if($(_trigger).find('option:selected').first().length) {
-                selectedGenericRate = +($(_trigger).find('option:selected').first().attr('data-amount'));
-            }
-            $(_trigger).closest('form').find('[name="numberOfUnits"]').val('');
+        function init() {
+            let selectedGenericRate = 0;
+            window.switchGenericRate = function (_trigger) {
+                selectedGenericRate = 0;
+                if ($(_trigger).find('option:selected').first().length) {
+                    selectedGenericRate = +($(_trigger).find('option:selected').first().attr('data-amount'));
+                }
+                $(_trigger).closest('form').find('[name="numberOfUnits"]').val('');
 
-            // max num units to limit at $15
-            if($(_trigger).attr('data-entity-type') === 'Note') {
-                let maxNABillableAmount = 15,
-                    amountPer5Minutes = selectedGenericRate / 12,
-                    maxNumberOf5Minutes =  Math.ceil(maxNABillableAmount / amountPer5Minutes),
-                    maxHours = (maxNumberOf5Minutes * 5) / 60,
-                    unitsSelect = $(_trigger).closest('form').find('[name="numberOfUnits"]');
-                unitsSelect.find('option').each(function() {
-                    if(this.value) {
-                        if(+this.value > maxHours) {
-                            $(this).hide();
+                @if($genericRates && count($genericRates) && count($genericRates) === 1)
+                    selectedGenericRate = {{ $genericRates[0]->amount }};
+                @endif
+
+                // max num units to limit at $15
+                if ($(_trigger).attr('data-entity-type') === 'Note') {
+                    let maxNABillableAmount = 15,
+                        amountPer5Minutes = selectedGenericRate / 12,
+                        maxNumberOf5Minutes = Math.ceil(maxNABillableAmount / amountPer5Minutes),
+                        maxHours = (maxNumberOf5Minutes * 5) / 60,
+                        unitsSelect = $(_trigger).closest('form').find('[name="numberOfUnits"]');
+                    unitsSelect.find('option').each(function () {
+                        if (this.value) {
+                            if (+this.value > maxHours) {
+                                $(this).hide();
+                            }
+                            else {
+                                $(this).show();
+                            }
                         }
                         else {
                             $(this).show();
                         }
-                    }
-                    else {
-                        $(this).show();
-                    }
-                });
-            }
+                    });
+                }
 
-            calculateGenericBillAmount($(_trigger).closest('form').find('[name="numberOfUnits"]'));
-        };
-        window.calculateGenericBillAmount = function(_trigger) {
-            _trigger = $(_trigger);
-            let amountTarget = _trigger.closest('form').find('[calculated-generic-amount]');
-            if(!_trigger.find('option:selected').length) {
-                amountTarget.text('');
-                return;
-            }
-            let hours = +_trigger.find('option:selected').attr('value'),
-                reimbursable = hours * selectedGenericRate;
-            if(isNaN(reimbursable)) reimbursable = 0;
-            amountTarget.html('<b>Reimbursable:</b> $' + reimbursable.toFixed(2));
+                calculateGenericBillAmount($(_trigger).closest('form').find('[name="numberOfUnits"]'));
+            };
+            window.calculateGenericBillAmount = function (_trigger) {
+                _trigger = $(_trigger);
+                let amountTarget = _trigger.closest('form').find('[calculated-generic-amount]');
+                if (!_trigger.find('option:selected').length) {
+                    amountTarget.text('');
+                    return;
+                }
+                let hours = +_trigger.find('option:selected').attr('value'),
+                    reimbursable = hours * selectedGenericRate;
+                if (isNaN(reimbursable)) reimbursable = 0;
+                amountTarget.html('<b>Reimbursable:</b> $' + reimbursable.toFixed(2));
+            };
+            window.updateGenericBillAction = function (_trigger) {
+                let actions = [];
+                $(_trigger).closest('.generic-bill-actions').find('.generic-bill-action:checked').each(function () {
+                    actions.push($(this).attr('data-action'));
+                });
+                $(_trigger).closest('.generic-bill-actions').find('[name="genericDescription"]').val(actions.join("<br>"));
+            };
+            @if($genericRates && count($genericRates) && count($genericRates) === 1)
+            switchGenericRate($('[name="code"][data-entity-type]'));
+            @endif
         }
+        addMCInitializer('init-generic-add-bill', init);
     }).call(window);
 </script>

+ 3 - 0
resources/views/app/generic-bills/add-bill-form/default.blade.php

@@ -1,5 +1,8 @@
+<?php $genericPro = @$note && $note->allyPro ? $note->allyPro : $pro; ?>
+<?php $genericRates = $genericPro->genericRates(); ?>
 <form url="/api/bill/createForGeneric">
     @include('app.generic-bills.add-bill-form._default-fields')
+    @include('app.generic-bills.add-bill-form._default-actions')
 </form>
 @include('app.generic-bills.add-bill-form._default-script')
 

+ 5 - 1
resources/views/app/generic-bills/inline.blade.php

@@ -73,7 +73,11 @@ $genericBills = genericBills($pro, @$patient, @$entityType, @$entityUid);
                                 @include('app.generic-bills.context')
                             </td>
                         @endif
-                        <td>{{$bill->code}}</td>
+                        <td>{{$bill->code}}
+                            @if($bill->generic_description)
+                                <pre class="mb-0 text-sm text-secondary font-italic">{!! $bill->generic_description !!}</pre>
+                            @endif
+                        </td>
                         <td class="">
                             <?php
                             $totalSeconds = $bill->number_of_units * 3600;

+ 2 - 2
resources/views/app/patient/care-months.blade.php

@@ -90,9 +90,9 @@
                         <label class="text-secondary text-sm mb-1">Year *</label>
                         <select name="startYear" class="form-control form-control-sm" required>
                             <option value="">-- Start Year --</option>
-                            <option value="2020" {{ date('Y') === '2020' ? 'selected' : '' }}>2020</option>
+                            <option value="2021" {{ date('Y') === '2021' ? 'selected' : '' }}>2021</option>
                             @if(date('m') === '12')
-                                <option value="2021" {{ date('Y') === '2021' ? 'selected' : '' }}>2021</option>
+                                <option value="2022" {{ date('Y') === '2022' ? 'selected' : '' }}>2022</option>
                             @endif
                         </select>
                     </div>

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

@@ -1,4 +1,4 @@
-<?php $noteRates = $pro->noteRates(); ?>
+<?php $noteRates = $note->hcpPro->noteRates(); ?>
 @if(!$note->is_bill_closed && !$note->is_billing_marked_done)
     <span class="mx-2 text-secondary">|</span>
     <div moe wide class="">
@@ -62,9 +62,11 @@
 
             </div>
 
+            @if(@$note && $note->hcpPro->id === $pro->id)
             <div class="my-3">
                 <input type="checkbox" name="signAndMarkBillingDone" checked>&nbsp;Sign and Mark Billing Done
             </div>
+            @endif
 
             <div class="">
                 <button class="btn btn-primary btn-sm" submit>Submit</button>

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

@@ -252,11 +252,8 @@
                                 <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">
+                                    <select name="naProUid" class="form-control" provider-search>
                                         <option value="">--select--</option>
-                                        @foreach($allyPros as $allyPro)
-                                            <option value="{{$allyPro->uid}}">{{$allyPro->name_first}} {{$allyPro->name_last}}</option>
-                                        @endforeach
                                     </select>
                                 </div>
                                 <div class="mb-0">
@@ -336,23 +333,23 @@
                 <div class="">
                     <div>
                         @if($note->is_signed_by_hcp)
-                            <span class="text-secondary">
-                        <i class="fa fa-check"></i>
-                        Note Signed
-                        @if($pro->pro_type == 'ADMIN')
-                        <span moe class="ml-2">
-                            <a class="" href="" show start>Undo sign?</a>
-                            <form url="/api/note/adminUndoSignAsHcp" right>
-                                <input type="hidden" name="uid" value="{{$note->uid}}">
-                                <p>Undo sign?</p>
-                                <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>
-                        @endif
-                    </span>
+                            <div class="text-secondary">
+                                <i class="fa fa-check"></i>
+                                Note Signed
+                                @if($pro->pro_type == 'ADMIN')
+                                <span moe class="ml-2">
+                                    <a class="" href="" show start>Undo sign?</a>
+                                    <form url="/api/note/adminUndoSignAsHcp" right>
+                                        <input type="hidden" name="uid" value="{{$note->uid}}">
+                                        <p>Undo sign?</p>
+                                        <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>
+                                @endif
+                            </div>
                         @else
                             <div moe
                                  class="{{ $note->hcp_pro_id !== $pro->id ? 'moe-disabled' : '' }}"
@@ -370,14 +367,27 @@
                         @endif
                     </div>
                 </div>
-                @if($note->allyPro)
+                @if($note->allyPro && $pro->id === $note->allyPro->id)
                 <div class="mx-4">
                     <div>
                         @if($note->is_signed_by_ally)
                             <span class="text-secondary">
-                        <i class="fa fa-check"></i>
-                        Note Signed By NA
-                    </span>
+                                <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-success 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' : '' }}"
@@ -1181,7 +1191,7 @@
                                                 <span class="font-weight-bold">${{ $bill->hcp_payment_amount }}</span>
                                             </div>
                                         @endif
-                                        @if($bill->ally)
+                                        @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">
@@ -1453,7 +1463,7 @@
                             @endforeach
                             </tbody>
                         </table>
-                        @else
+                        @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>
@@ -1599,6 +1609,42 @@
                                                 <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 Acknowledged
+                                                    </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>
+                                                        Acknowledged
+                                                    </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-success 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>

+ 12 - 6
resources/views/app/patient/tickets.blade.php

@@ -191,16 +191,22 @@
                         <?php } ?>
 
                         <?php
-                            $contentData = false;
-                            if ($patient->canvas_data) {
-                                $canvasData = json_decode($patient->canvas_data, true);
-                                if (isset($canvasData['rx'])) {
-                                    $contentData = $canvasData['rx'];
+                            $contentData = $patient->firstPageByCategoryAndKey('CANVAS', 'rx');
+                            if ($contentData) {
+                                $contentData = json_decode($contentData);
+                                if($contentData && $contentData->data) {
+                                    $contentData = json_decode($contentData->data);
                                 }
+                                else {
+                                    $contentData = false;
+                                }
+                            }
+                            else {
+                                $contentData = false;
                             }
                         ?>
 
-                        patientRx: <?= $contentData ? json_encode($contentData['items']) : '[]' ?>,
+                        patientRx: <?= $contentData ? json_encode($contentData->items) : '[]' ?>,
                     },
                     computed: {
                         numAll: function() {

+ 2 - 0
resources/views/app/patient/tickets/erx-data.blade.php

@@ -32,6 +32,7 @@ erxModel: {
         pharmacyAddressMemo: '',
         pharmacyPhone: '',
         pharmacyFax: '',
+        pharmacyZip: '',
         comments: [{
             pro_id: '',
             message: '',
@@ -70,6 +71,7 @@ erxPopupItem: {
         pharmacyAddressMemo: '',
         pharmacyPhone: '',
         pharmacyFax: '',
+        pharmacyZip: '',
         comments: [{
             pro_id: '',
             message: '',

+ 1 - 1
resources/views/app/patient/tickets/erx.blade.php

@@ -246,7 +246,7 @@
             @include('app.patient.tickets.faxes', ['category' => 'erx'])
 
             <!-- bills -->
-            <div class="px-3 py-3 border-top">
+            <div class="px-3 py-3 border-top" v-if="erxPopupMode !== 'add'">
                 <a class="mb-0 font-weight-normal font-size-16 d-flex align-items-center"
                    native target="_blank"
                    open-in-stag-popup

+ 2 - 0
resources/views/app/patient/tickets/imaging-data.blade.php

@@ -17,6 +17,7 @@ imagingModel: {
         pharmacyAddressMemo: '',
         pharmacyPhone: '',
         pharmacyFax: '',
+        pharmacyZip: '',
         comments: [{
             pro_id: '',
             message: '',
@@ -40,6 +41,7 @@ imagingPopupItem: {
         pharmacyAddressMemo: '',
         pharmacyPhone: '',
         pharmacyFax: '',
+        pharmacyZip: '',
         comments: [{
             pro_id: '',
             message: '',

+ 1 - 1
resources/views/app/patient/tickets/imaging.blade.php

@@ -133,7 +133,7 @@
             @include('app.patient.tickets.attachments', ['category' => 'imaging'])
 
             <!-- bills -->
-            <div class="px-3 py-3 border-top">
+            <div class="px-3 py-3 border-top" v-if="imagingPopupMode !== 'add'">
                 <a class="mb-0 font-weight-normal font-size-16 d-flex align-items-center"
                    native target="_blank"
                    open-in-stag-popup

+ 2 - 0
resources/views/app/patient/tickets/lab-data.blade.php

@@ -17,6 +17,7 @@ labModel: {
         pharmacyAddressMemo: '',
         pharmacyPhone: '',
         pharmacyFax: '',
+        pharmacyZip: '',
         comments: [{
             pro_id: '',
             message: '',
@@ -40,6 +41,7 @@ labPopupItem: {
         pharmacyAddressMemo: '',
         pharmacyPhone: '',
         pharmacyFax: '',
+        pharmacyZip: '',
         comments: [{
             pro_id: '',
             message: '',

+ 1 - 1
resources/views/app/patient/tickets/lab.blade.php

@@ -137,7 +137,7 @@
             @include('app.patient.tickets.attachments', ['category' => 'lab'])
 
             <!-- bills -->
-            <div class="px-3 py-3 border-top">
+            <div class="px-3 py-3 border-top" v-if="labPopupMode !== 'add'">
                 <a class="mb-0 font-weight-normal font-size-16 d-flex align-items-center"
                    native target="_blank"
                    open-in-stag-popup

+ 12 - 0
resources/views/app/patient/tickets/other.blade.php

@@ -98,6 +98,18 @@
             <!-- attachments -->
             @include('app.patient.tickets.attachments', ['category' => 'other'])
 
+            <!-- bills -->
+            <div class="px-3 py-3 border-top" v-if="otherPopupMode !== 'add'">
+                <a class="mb-0 font-weight-normal font-size-16 d-flex align-items-center"
+                   native target="_blank"
+                   open-in-stag-popup
+                   popup-style="tall"
+                   title="Generic Bills"
+                   :href="'/generic-bill-view/Ticket/' + otherPopupMode.uid">
+                    Generic Bills
+                </a>
+            </div>
+
             <!-- comments -->
             @include('app.patient.tickets.comments', ['category' => 'other'])
         </form>

+ 9 - 1
resources/views/app/patient/tickets/pharmacy-suggest.blade.php

@@ -14,8 +14,15 @@
     var lastTerm = '';
     var returnedFunction = debounce(function () {
         var term = $('#{{$category}}-pharmacy-search').val();
+        var city = $('#{{$category}}-pharmacy-search-city').val(),
+            state = $('#{{$category}}-pharmacy-search-state').val(),
+            zip = $('#{{$category}}-pharmacy-search-zip').val();
         if (!!term && lastTerm !== term) {
-            $.get('/pharmacy-suggest?term=' + $.trim(term), function (_data) {
+            $.get('/pharmacy-suggest?term=' + encodeURIComponent($.trim(term)) +
+                (!!city ? '&city=' + encodeURIComponent(city) : '') +
+                (!!state ? '&state=' + encodeURIComponent(state) : '') +
+                (!!zip ? '&zip=' + encodeURIComponent(zip) : ''),
+            function (_data) {
                 $('.suggestions-outer.{{$category}}-pharmacy-suggestions').html(_data).removeClass('d-none');
             });
             lastTerm = term;
@@ -95,4 +102,5 @@
     this.{{$category}}PopupItem.data.pharmacyAddressMemo = $(_elem).attr('data-pharmacyAddressMemo');
     this.{{$category}}PopupItem.data.pharmacyPhone = $(_elem).attr('data-pharmacyPhone');
     this.{{$category}}PopupItem.data.pharmacyFax = $(_elem).attr('data-pharmacyFax');
+    this.{{$category}}PopupItem.data.pharmacyZip = $(_elem).attr('data-pharmacyZip');
 },

+ 20 - 8
resources/views/app/patient/tickets/pharmacy.blade.php

@@ -6,25 +6,37 @@
     </div>
     <div class="row mb-2">
         <div class="col-12">
-            <label class="text-sm text-secondary mb-1">Business Name</label>
+            <label class="text-sm text-secondary mb-1">Business Name <b class="text-sm">(fields marked <span class="text-sm text-info font-weight-bold">#</span> will be used to narrow down results)</b></label>
             <input type="text" autocomplete="donotdoit" placeholder="Business Name" id="{{$category}}-pharmacy-search" v-model="{{$category}}PopupItem.data.pharmacyName" class="form-control form-control-sm">
             <div class="suggestions-outer pharmacy-suggestions {{$category}}-pharmacy-suggestions position-absolute d-none"></div>
         </div>
     </div>
     <div class="row mb-2">
         <div class="col-4">
-            <label class="text-sm text-secondary mb-1">City</label>
-            <input type="text" placeholder="City" v-model="{{$category}}PopupItem.data.pharmacyCity" class="form-control form-control-sm min-width-unset">
+            <label class="text-sm text-secondary mb-1">City <span class="text-sm text-info font-weight-bold">#</span></label>
+            <input type="text" placeholder="City" v-model="{{$category}}PopupItem.data.pharmacyCity"
+                   id="{{$category}}-pharmacy-search-city"
+                   class="form-control form-control-sm min-width-unset">
         </div>
-        <div class="col-2 pl-0">
-            <label class="text-sm text-secondary mb-1">State</label>
-            <input type="text" placeholder="State" v-model="{{$category}}PopupItem.data.pharmacyState" class="form-control form-control-sm min-width-unset">
+        <div class="col-4 pl-0">
+            <label class="text-sm text-secondary mb-1">State <span class="text-sm text-info font-weight-bold">#</span></label>
+            <input type="text" placeholder="State" v-model="{{$category}}PopupItem.data.pharmacyState"
+                   id="{{$category}}-pharmacy-search-state"
+                   class="form-control form-control-sm min-width-unset">
         </div>
-        <div class="col-3 pl-0">
+        <div class="col-4 pl-0">
+            <label class="text-sm text-secondary mb-1">ZIP <span class="text-sm text-info font-weight-bold">#</span></label>
+            <input type="text" placeholder="Zip" v-model="{{$category}}PopupItem.data.pharmacyZip"
+                   id="{{$category}}-pharmacy-search-zip"
+                   class="form-control form-control-sm min-width-unset">
+        </div>
+    </div>
+    <div class="row mb-2">
+        <div class="col-4">
             <label class="text-sm text-secondary mb-1">Phone</label>
             <input type="text" placeholder="Phone" v-model="{{$category}}PopupItem.data.pharmacyPhone" class="form-control form-control-sm min-width-unset">
         </div>
-        <div class="col-3 pl-0">
+        <div class="col-4 pl-0">
             <label class="text-sm text-secondary mb-1">Fax</label>
             <input type="text" placeholder="Fax" v-model="{{$category}}PopupItem.data.pharmacyFax" class="form-control form-control-sm min-width-unset">
         </div>

+ 1 - 0
resources/views/app/pharmacy-suggest.blade.php

@@ -11,6 +11,7 @@
        data-pharmacyAddressMemo="{{$pharmacy->address_line1}}"
        data-pharmacyPhone="{{$pharmacy->phone}}"
        data-pharmacyFax="{{$pharmacy->fax}}"
+       data-pharmacyZip="{{$pharmacy->address_zip}}"
     >
         {{$pharmacy->displayString()}}
     </a>

+ 1 - 0
resources/views/app/practice-management/notes.blade.php

@@ -13,6 +13,7 @@
             <select class="ml-auto max-width-300px form-control form-control-sm" onchange="fastLoad('/practice-management/notes/' + this.value, true, false, false)">
                 <option value="" {{ $filter === '' ? 'selected' : '' }}>All notes</option>
                 <option value="not-yet-signed" {{ $filter === 'not-yet-signed' ? 'selected' : '' }}>Notes not yet signed</option>
+                <option value="not-yet-signed-but-ally-signed" {{ $filter === 'not-yet-signed-but-ally-signed' ? 'selected' : '' }}>Notes not yet signed (but ally signed)</option>
             </select>
         </div>
         <div class="card-body p-0">

+ 58 - 0
resources/views/app/practice-management/pro-financials.blade.php

@@ -0,0 +1,58 @@
+@extends ('layouts/template')
+
+@section('content')
+
+    <div class="p-3 mcp-theme-1" id="processing-bill-matrix">
+
+        <div class="card">
+
+            <div class="card-header px-3 py-2 d-flex align-items-center">
+                <strong class="text-nowrap">
+                    <i class="fas fa-user-injured"></i>
+                    Pro Financials
+                </strong>
+                <span class="mx-2">for</span>
+                <div class="width-200px">
+                    <select provider-search data-pro-uid="{{ @$targetPro->uid }}"
+                            name="proUid" class="form-control form-control-sm mr-auto width-200px min-width-unset"
+                            onchange="fastLoad('/practice-management/pro-financials/' + this.value)">
+                        <option value="" {{!@$targetPro ? 'selected' : ''}}>All Pros</option>
+                    </select>
+                </div>
+                @if(@$targetPro)
+                    <a href="/practice-management/pro-financials" class="ml-2">Clear Filter</a>
+                @endif
+            </div>
+            <div class="card-body p-0">
+                <table class="table table-sm table-condensed table-hover p-0 m-0">
+                    <thead class="bg-light">
+                    <tr>
+                        <th>Pro</th>
+                        <th>Balance Owed</th>
+                        <th class="w-75">Recent Debits</th>
+                    </tr>
+                    </thead>
+                    <tbody>
+                    @foreach ($fPros as $row)
+                        <tr>
+                            <td>{{$row->displayName()}}</td>
+                            <td><b>${{friendly_money($row->balance)}}</b></td>
+                            <td>
+                                @foreach($row->recentDebits() as $debit)
+                                    <div class="d-flex align-items-center mb-1">
+                                        <span class="width-90px">{{'$' . $debit->amount}}</span>
+                                        <span class="text-secondary">{{friendly_date_time($debit->created_at, false)}}</span>
+                                    </div>
+                                @endforeach
+                            </td>
+                        </tr>
+                    @endforeach
+                    </tbody>
+                </table>
+            </div>
+        </div>
+        <div class="mt-3">
+            {{$fPros->withQueryString()->links()}}
+        </div>
+    </div>
+@endsection

+ 133 - 46
resources/views/app/practice-management/processing-bill-matrix.blade.php

@@ -2,7 +2,7 @@
 
 @section('content')
 
-    <div class="p-3 mcp-theme-1">
+    <div class="p-3 mcp-theme-1" id="processing-bill-matrix">
 
         <div class="card">
 
@@ -14,104 +14,130 @@
                 <span class="mx-2">for</span>
                 <div class="width-200px">
                     <select provider-search data-pro-uid="{{ @$targetPro->uid }}"
-                            name="proUid" class="form-control form-control-sm mr-auto width-200px"
-                            onchange="fastLoad('/practice-management/processing-bill-matrix/' + this.value + '?f={{request()->input('f')}}&t={{request()->input('t')}}')">
+                            name="proUid" class="form-control form-control-sm mr-auto width-200px min-width-unset"
+                            onchange="fastLoad('/practice-management/processing-bill-matrix/' + this.value + '?f={{request()->input('f')}}&t={{request()->input('t')}}&bs={{request()->input('bs')}}&be={{request()->input('be')}}')">
                         <option value="" {{!@$targetPro ? 'selected' : ''}}>All Pros</option>
                     </select>
                 </div>
                 @if(@$targetPro)
                     <a href="/practice-management/processing-bill-matrix" class="ml-2">Clear Filter</a>
                 @endif
-                <div class="width-200px ml-2">
-                    <select name="filter" class="form-control form-control-sm mr-auto width-200px"
-                            onchange="fastLoad('/practice-management/processing-bill-matrix/{{@$targetPro ? $targetPro->uid : ''}}?f=' + this.value + '&t={{request()->input('t')}}')">
+                <div class="width-100px ml-2">
+                    <select name="filter" class="form-control form-control-sm mr-auto width-100px"
+                            onchange="fastLoad('/practice-management/processing-bill-matrix/{{@$targetPro ? $targetPro->uid : ''}}?f=' + this.value + '&t={{request()->input('t')}}&bs={{request()->input('bs')}}&be={{request()->input('be')}}')">
                         <option {{request()->input('f') === '' ? 'selected' : ''}} value="">All Bills</option>
-                        <option {{request()->input('f') === 'verified' ? 'selected' : ''}} value="verified">Verified Only</option>
-                        <option {{request()->input('f') === 'not-verified' ? 'selected' : ''}} value="not-verified">Not Verified Only</option>
+                        <option {{request()->input('f') === 'verified' ? 'selected' : ''}} value="verified">Verified
+                            Only
+                        </option>
+                        <option {{request()->input('f') === 'not-verified' ? 'selected' : ''}} value="not-verified">Not
+                            Verified Only
+                        </option>
                     </select>
                 </div>
-                <div class="width-200px ml-2">
-                    <select name="filter" class="form-control form-control-sm mr-auto width-200px"
-                            onchange="fastLoad('/practice-management/processing-bill-matrix/{{@$targetPro ? $targetPro->uid : ''}}?f={{request()->input('f')}}&t=' + this.value)">
-                        <option {{!request()->input('t') || request()->input('t') === 'hcp' ? 'selected' : ''}} value="hcp">HCP Bills</option>
+                <div class="width-100px ml-2">
+                    <select name="filter" class="form-control form-control-sm mr-auto width-100px"
+                            onchange="fastLoad('/practice-management/processing-bill-matrix/{{@$targetPro ? $targetPro->uid : ''}}?f={{request()->input('f')}}&bs={{request()->input('bs')}}&be={{request()->input('be')}}&t=' + this.value)">
+                        <option {{!request()->input('t') || request()->input('t') === 'hcp' ? 'selected' : ''}} value="hcp">
+                            HCP Bills
+                        </option>
                         <option {{request()->input('t') === 'na' ? 'selected' : ''}} value="na">NA Bills</option>
                     </select>
                 </div>
+                <div class="ml-3 d-inline-flex align-items-center">
+                    <b class="mr-2">Bal Post Date</b>
+                    <input type="date"
+                           value="{{request()->input('bs')}}"
+                           onchange="fastLoad('/practice-management/processing-bill-matrix/{{@$targetPro ? $targetPro->uid : ''}}?f={{request()->input('f')}}&t={{request()->input('t')}}&be={{request()->input('be')}}&bs=' + this.value)"
+                           class="form-control form-control-sm width-150px" name="bpdFrom">
+                    <span class="mx-2">to</span>
+                    <input type="date"
+                           value="{{request()->input('be')}}"
+                           onchange="fastLoad('/practice-management/processing-bill-matrix/{{@$targetPro ? $targetPro->uid : ''}}?f={{request()->input('f')}}&t={{request()->input('t')}}&bs={{request()->input('bs')}}&be=' + this.value)"
+                           class="form-control form-control-sm width-150px" name="bpdTo">
+                </div>
+                <button class="ml-auto btn btn-sm btn-primary pay-selected-pros px-3 font-weight-bold" disabled>Pay Selected</button>
             </div>
             <div class="card-body p-0">
-                <table class="table table-sm table-condensed p-0 m-0">
+                <table class="table table-sm table-condensed table-hover p-0 m-0">
                     <thead class="bg-light">
                     <tr>
-			<th><input type="checkbox"/> All</th>
-                        <th>Note Link</th>
+                        <th>
+                            <label class="d-flex align-items-center m-0">
+                                <input type="checkbox" class="chk-all-bills" /> <span class="ml-2">All</span>
+                            </label>
+                        </th>
+                        <th>Context</th>
                         <td>Effective Date</td>
-			<td>Balance Post Date</td>
-
+                        <td>Balance Post Date</td>
                         @if(!request()->input('t') || request()->input('t') === 'hcp')
                             <td>HCP Pro</td>
                         @elseif(request()->input('t') === 'na')
                             <td>NA Pro</td>
                         @endif
-
                         <td>Client</td>
                         <td>Code</td>
                         <td>Units</td>
-			<td>Verified?</td>
-
+                        <td>Verified?</td>
                         @if(!request()->input('t') || request()->input('t') === 'hcp')
                             <td>HCP Expected Amount</td>
                         @elseif(request()->input('t') === 'na')
                             <td>NA Expected Amount</td>
                         @endif
-
-                        <td>HCP Signed?</td>
-{{--                        <td>HCP Signed At</td>--}}
+                        <td>Pro Signed?</td>
+                        <td></td>
                     </tr>
                     </thead>
                     <tbody>
                     @foreach ($bills as $row)
-                        <tr class="">
-			    <td>
-				<input type="checkbox"/>
-			    </td>
+                        <tr>
+                            <td class="align-middle">
+                                @if($row->is_verified)
+                                    <input type="checkbox" data-uid="{{$row->uid}}" class="chk-bill align-middle" />
+                                @endif
+                            </td>
                             <td>
                                 @if($row->note)
-                                <a href="/patients/view/{{ $row->client->uid }}/notes/view/{{ $row->note->uid }}">
-                                    Note Link
-                                </a>
-                                @else
+                                    <a href="/patients/view/{{ $row->client->uid }}/notes/view/{{ $row->note->uid }}">
+                                        Note Link
+                                    </a>
+                                @elseif($row->client)
                                     <a href="/patients/view/{{ $row->client->uid }}">
                                         Chart
                                     </a>
+                                @else
+                                    Generic
                                 @endif
                             </td>
                             <td>{{friendly_date($row->effective_date)}}</td>
-			    <td>{{friendly_date($row->balance_post_date)}}</td>
-
+                            <td>{{friendly_date($row->balance_post_date)}}</td>
                             @if(!request()->input('t') || request()->input('t') === 'hcp')
                                 <td>{{$row->hcp->name_last}}, {{$row->hcp->name_first}}</td>
                             @elseif(request()->input('t') === 'na')
                                 <td>{{$row->genericPro->name_last}}, {{$row->genericPro->name_first}}</td>
                             @endif
-                            <td>{{$row->client->name_last}}, {{$row->client->name_first}}</td>
+                            <td>
+                                @if($row->client)
+                                    {{$row->client->name_last}}, {{$row->client->name_first}}
+                                @endif
+                            </td>
                             <td>{{$row->code}}</td>
-                            <td>{{$row->number_of_units}}</td>
-			    <td>{{$row->is_verified ? 'Verified: ' . friendly_date($row->marked_verified_at, true) : 'Not Verified'}} </td>
-
+                            <td>{{str_contains($row->code, 'Treatment Services') || str_contains($row->code, 'Administrative Services') ? ceil((float) $row->number_of_units * 60) . ' mins' : $row->number_of_units}}</td>
+                            <td>{{$row->is_verified ? 'Verified: ' . friendly_date($row->marked_verified_at, true) : 'Not Verified'}} </td>
                             @if(!request()->input('t') || request()->input('t') === 'hcp')
-                                <td>{{$row->hcp_expected_payment_amount}}</td>
+                                <td><b>${{$row->hcp_expected_payment_amount}}</b></td>
                             @elseif(request()->input('t') === 'na')
-                                <td>{{$row->generic_pro_expected_payment_amount}}</td>
+                                <td><b>${{number_format($row->generic_pro_expected_payment_amount, 2)}}</b></td>
                             @endif
-
                             @if(!request()->input('t') || request()->input('t') === 'hcp')
-                                <td>{{$row->is_signed_by_hcp}}</td>
+                                <td>{{$row->is_signed_by_hcp ? 'Yes' : 'No'}}</td>
                             @elseif(request()->input('t') === 'na')
-                                <td>{{$row->is_signed_by_generic_pro}}</td>
+                                <td>{{$row->is_signed_by_generic_pro ? 'Yes' : 'No'}}</td>
                             @endif
-
-
-{{--                            <td>{{$row->signed_by_hcp_at}}</td>--}}
+                            <td>
+                                @if($row->is_verified)
+                                    <a href="#" data-uid="{{$row->uid}}" class="pay-bill font-weight-bold">Pay</a>
+                                @endif
+                            </td>
                         </tr>
                     @endforeach
                     </tbody>
@@ -122,5 +148,66 @@
             {{$bills->withQueryString()->links()}}
         </div>
     </div>
-
+    <script>
+        (function() {
+            function init() {
+                $('.pay-bill')
+                    .off('click')
+                    .on('click', function () {
+                        showMask();
+                        $.post('/api/bill/payUnpaidProsOnBillExpectedAmount', {
+                            uid: $(this).attr('data-uid')
+                        }, _data => {
+                            if(!hasResponseError(_data)) {
+                                toastr.success('Bill paid successfully');
+                                fastReload();
+                            }
+                        }).then(function() {
+                            hideMask();
+                        });
+                        return false;
+                    });
+                $('.pay-selected-pros')
+                    .off('click')
+                    .on('click', function () {
+                        if(!$('.chk-bill:checked').length) return false;
+                        showMask();
+                        let uids = [];
+                        $('.chk-bill:checked').each(function() {
+                            uids.push($(this).attr('data-uid'));
+                        });
+                        $.post('/api/bill/bulkPayUnpaidProsOnBillExpectedAmount', {
+                            billUids: uids.join('|')
+                        }, _data => {
+                            if(!hasResponseError(_data)) {
+                                toastr.success('Selected bills paid successfully');
+                                fastReload();
+                            }
+                        }).then(function() {
+                            hideMask();
+                        });
+                        return false;
+                    });
+                $('.chk-bill')
+                    .off('change')
+                    .on('change', function() {
+                        console.log('123')
+                         $('.pay-selected-pros').prop('disabled', !$('.chk-bill:checked').length);
+                         $('.chk-all-bills').prop('checked', ($('.chk-bill:checked').length === $('.chk-bill').length));
+                         return false;
+                    });
+                $('.chk-all-bills')
+                    .off('change')
+                    .on('change', function() {
+                        console.log('12')
+                        $('.chk-bill')
+                            .prop('checked', this.checked)
+                            .first()
+                                .trigger('change');
+                        return false;
+                    });
+            }
+            addMCInitializer('processing-bill-matrix', init, '#processing-bill-matrix');
+        }).call(window);
+    </script>
 @endsection

+ 182 - 0
resources/views/app/practice-management/remote-monitoring-measurements.blade.php

@@ -0,0 +1,182 @@
+<div class="mcp-theme-1 px-3 py-2 border-top mt-3 min-height-500px" id="remote-monitoring-measurements-{{$careMonth->id}}">
+    <?php
+    $stampAllEndPoint = '';
+    if(count($measurements)) {
+        if ($measurements[0]->mcp_pro_id === $pro->id) {
+            $stampAllEndPoint = '/api/measurement/bulkStampAsMcp';
+        } elseif ($measurements[0]->default_na_pro_id === $pro->id || $measurements[0]->rmm_pro_id === $pro->id || $measurements[0]->rme_pro_id === $pro->id) {
+            $stampAllEndPoint = '/api/measurement/bulkStampAsNonHcp';
+        }
+        $measurementUids = [];
+        foreach($measurements as $measurement) {
+            if(!empty($measurement->label) && !in_array($measurement->label, ["SBP", "DBP"])) {
+                $measurementUids[] = $measurement->uid;
+            }
+        }
+        $measurementUids = implode('|', $measurementUids);
+    }
+    ?>
+    @if($stampAllEndPoint && !!$measurementUids)
+        <div moe relative class="btn-stamp-all">
+            <a href="#" start show class="btn btn-sm btn-primary text-white font-weight-bold">
+                Stamp All
+            </a>
+            <form url="{{$stampAllEndPoint}}">
+                <input type="hidden" name="measurementUids" value="{{$measurementUids}}">
+                <p class="mb-1">Stamp all measurements?</p>
+                @if($measurement->mcp_pro_id !== $pro->id)
+                    <div class="mb-2 border border-info p-2 mt-2 bg-light width-300px">
+                        <span>I have had interactive communication with {{$measurement->name_first}} {{$measurement->name_last}} during this care month.</span>
+                        <div class="d-flex border-top mt-2">
+                            <label class="mt-2 mb-0 d-inline-flex align-items-center mr-3">
+                                <input type="radio" class="mr-2" name="communicatedToPatient" value="true">
+                                <span>Yes</span>
+                            </label>
+                            <label class="mt-2 mb-0 d-inline-flex align-items-center">
+                                <input type="radio" class="mr-2" name="communicatedToPatient" value="false" checked>
+                                <span>No</span>
+                            </label>
+                        </div>
+                    </div>
+                @else
+                    <input type="hidden" name="communicatedToPatient" value="false">
+                @endif
+                <div class="mb-2">
+                    <label class="mb-1 text-secondary text-sm">Memo</label>
+                    <textarea class="form-control form-control-sm" name="memo"></textarea>
+                </div>
+                <div class="form-group m-0">
+                    <button submit class="btn btn-primary btn-sm mr-2">Submit</button>
+                    <button cancel class="btn btn-default border btn-sm mr-2">Cancel</button>
+                </div>
+            </form>
+        </div>
+    @endif
+    <div class="mt-0 pb-1">
+        <table class="table table-striped table-sm table-bordered mt-2 mb-0">
+            <thead>
+            <tr>
+                <th class="px-2 text-secondary w-25">Date</th>
+                <th class="px-2 text-secondary w-25">Category</th>
+                <th class="px-2 text-secondary w-25">Value</th>
+                <th class="px-2 text-secondary">Actions</th>
+            </tr>
+            </thead>
+            <tbody>
+            @foreach($measurements as $measurement)
+                @if(!empty($measurement->label))
+                    @if(!in_array($measurement->label, ["SBP", "DBP"]))
+                        <tr>
+                            <td class="px-2">
+                                @if($measurement->ts)
+                                    <?php $timestampInSec = floor($measurement->ts / 1000); ?>
+                                    {{ friendly_date_time_short_with_tz_from_timestamp($timestampInSec, 'EASTERN') }}
+                                @else
+                                    {{ friendly_date_time_short_with_tz($measurement->effective_date, true, 'EASTERN') }}
+                                @endif
+                                EST
+                            </td>
+                            <td class="px-2">{{ $measurement->label }}</td>
+                            <td class="px-2">
+                                @if($measurement->label === 'BP')
+                                    {{ round($measurement->sbp_mm_hg, 2) }}/{{ round($measurement->dbp_mm_hg, 2) }} mmHg
+                                    <span class="font-weight-normal d-inline-block pl-2">Pulse:</span>
+                                    {{ $measurement->value_pulse }} {{ $measurement->value_irregular === 0?'Irregular':'' }} {{ $measurement->value_irregular === 1?'Regular':'' }}
+                                @elseif($measurement->label === 'Wt. (lbs.)')
+                                    {{ round($measurement->numeric_value, 2) }} lbs
+                                @else
+                                    {{ $measurement->value }}
+                                @endif
+                            </td>
+                            <td class="px-2">
+                                <?php
+                                $stampEndPoint = '';
+                                if ($measurement->mcp_pro_id === $pro->id) {
+                                    $stampEndPoint = '/api/measurement/stampAsMcp';
+                                } elseif ($measurement->default_na_pro_id === $pro->id || $measurement->rmm_pro_id === $pro->id || $measurement->rme_pro_id === $pro->id) {
+                                    $stampEndPoint = '/api/measurement/stampAsNonHcp';
+                                }
+                                ?>
+                                @if($stampEndPoint)
+                                    <div moe relative>
+                                        <a href="#" start show>Stamp</a>
+                                        <form url="{{$stampEndPoint}}" right class="width-300px">
+                                            <input type="hidden" name="uid" value="{{$measurement->uid}}">
+                                            <p class="mb-1">Stamp this measurement?</p>
+                                            <div class="mt-2 bg-light border p-2">
+                                                <div class="mb-1 text-secondary">{{ $measurement->label }}</div>
+                                                <div class="font-weight-bold mb-1">
+                                                    @if($measurement->label === 'BP')
+                                                        {{ round($measurement->sbp_mm_hg, 2) }}/{{ round($measurement->dbp_mm_hg, 2) }} mmHg
+                                                        <span class="font-weight-normal d-inline-block pl-2">Pulse:</span>
+                                                        {{ $measurement->value_pulse }} {{ $measurement->value_irregular === 0?'Irregular':'' }} {{ $measurement->value_irregular === 1?'Regular':'' }}
+                                                    @elseif($measurement->label === 'Wt. (lbs.)')
+                                                        {{ round($measurement->numeric_value, 2) }} lbs
+                                                    @else
+                                                        {{ $measurement->value }}
+                                                    @endif
+                                                </div>
+                                                <div class="text-sm">
+                                                    <?php $timestampInSec = floor($measurement->ts / 1000); ?>
+                                                    {{ friendly_date_time_short_with_tz_from_timestamp($timestampInSec, 'EASTERN') }} EST
+                                                </div>
+                                            </div>
+                                            @if($measurement->mcp_pro_id !== $pro->id)
+                                                <div class="mb-2 border border-info p-2 mt-2 bg-light">
+                                                    <span>I have had interactive communication with {{$measurement->name_first}} {{$measurement->name_last}} during this care month.</span>
+                                                    <div class="d-flex border-top mt-2">
+                                                        <label class="mt-2 mb-0 d-inline-flex align-items-center mr-3">
+                                                            <input type="radio" class="mr-2" name="communicatedToPatient" value="true">
+                                                            <span>Yes</span>
+                                                        </label>
+                                                        <label class="mt-2 mb-0 d-inline-flex align-items-center">
+                                                            <input type="radio" class="mr-2" name="communicatedToPatient" value="false" checked>
+                                                            <span>No</span>
+                                                        </label>
+                                                    </div>
+                                                </div>
+                                            @else
+                                                <input type="hidden" name="communicatedToPatient" value="false">
+                                            @endif
+                                            <div class="mb-2">
+                                                <label class="mb-1 text-secondary text-sm">Memo</label>
+                                                <textarea class="form-control form-control-sm" name="memo"></textarea>
+                                            </div>
+                                            <div class="form-group m-0">
+                                                <button submit class="btn btn-primary btn-sm mr-2">Submit</button>
+                                                <button cancel class="btn btn-default border btn-sm mr-2">Cancel</button>
+                                            </div>
+                                        </form>
+                                    </div>
+                                @endif
+                            </td>
+                        </tr>
+                    @endif
+                @endif
+            @endforeach
+            @if(!$measurements || count($measurements) === 0)
+                <tr>
+                    <td class="text-secondary p-2 border-0" colspan="4">
+                        No items to show
+                    </td>
+                </tr>
+            @endif
+            </tbody>
+        </table>
+    </div>
+</div>
+<script>
+    (function () {
+        function init() {
+            $('.stag-popup-content .stag-popup-title .btn-stamp-all').remove();
+            $('.btn-stamp-all')
+                .addClass('ml-3')
+                .insertAfter(
+                    $('#remote-monitoring-measurements-{{$careMonth->id}}')
+                        .closest('.stag-popup-content')
+                        .find('.stag-popup-title>span')
+                );
+        }
+        addMCInitializer('remote-monitoring-measurements-{{$careMonth->id}}', init, '#remote-monitoring-measurements-{{$careMonth->id}}')
+    }).call(window);
+</script>

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

@@ -0,0 +1,117 @@
+@extends ('layouts/template')
+
+@section('content')
+
+    <div class="p-3 mcp-theme-1" id="practice-billing-manager">
+
+        <div class="card">
+
+            <div class="card-header px-3 py-2 d-flex align-items-center">
+                <span class="mr-4">
+                    <span class="font-size-16">Remote Monitoring</span>
+                    <i class="fas fa-arrow-right text-sm mx-1"></i>
+                    <b class="font-size-16">{{friendly_month(date((request()->input('y') ?: 'Y') . '-' . (request()->input('m') ?: 'm') . '-d'))}}</b>
+                </span>
+                <?php
+                $dateInput = [];
+                if(request()->input('m')) $dateInput[] = 'm=' . request()->input('m');
+                if(request()->input('y')) $dateInput[] = 'y=' . request()->input('y');
+                $dateInput = '&' . implode('&', $dateInput);
+                ?>
+                <select class="ml-auto max-width-200px form-control form-control-sm"
+                        onchange="fastLoad('/practice-management/remote-monitoring?fmd=' + this.value + '&fcomm={{request()->input('fcomm')}}{{$dateInput}}', true, false, false)">
+                    <option value="all" {{ !request()->input('fmd') || request()->input('fmd') === 'all' ? 'selected' : '' }}>All</option>
+                    <option value="lt16" {{ request()->input('fmd') === 'lt16' ? 'selected' : '' }}>Patients with &lt; 16 meas. days</option>
+                    <option value="gte16" {{ request()->input('fmd') === 'gte16' ? 'selected' : '' }}>Patients with &ge; 16 meas. days</option>
+                </select>
+                <select class="ml-3 max-width-200px form-control form-control-sm"
+                        onchange="fastLoad('/practice-management/remote-monitoring?fmd={{request()->input('fmd')}}&fcomm=' + this.value + '{{$dateInput}}', true, false, false)">
+                    <option value="all" {{ !request()->input('fcomm') || request()->input('fcomm') === 'all' ? 'selected' : '' }}>All</option>
+                    <option value="not-done" {{ request()->input('fcomm') === 'not-done' ? 'selected' : '' }}>Patients with whom comm. not done</option>
+                    <option value="done" {{ request()->input('fcomm') === 'done' ? 'selected' : '' }}>Patients with whom comm. done</option>
+                </select>
+            </div>
+            <div class="card-body p-0">
+                <table class="table table-sm table-condensed table-hover p-0 m-0">
+                    <thead class="bg-light">
+                    <tr>
+                        <th class="border-0">Patient</th>
+                        <th class="border-0">Relation</th>
+                        <th class="border-0">Measurement Days</th>
+                        <th class="border-0">Unstamped Measurements</th>
+                        @if(!$pro->is_hcp)
+                            <th class="border-0">Communicated With Patient</th>
+                        @endif
+                        <th class="border-0">Phone</th>
+                    </tr>
+                    </thead>
+                    <tbody>
+                    @foreach ($patients as $iPatient)
+                        <tr>
+                            <td class="">
+                                <a href="/patients/view/{{ $iPatient->client_uid }}">{{ $iPatient->name_first }} {{ $iPatient->name_last }}</a>
+                            </td>
+                            <td class="">
+                                @if($iPatient->mcp_pro_id === $pro->id)
+                                    <div>MCP</div>
+                                @endif
+                                @if($iPatient->default_na_pro_id === $pro->id)
+                                    <div>Default NA</div>
+                                @endif
+                                @if($iPatient->rmm_pro_id === $pro->id)
+                                    <div>RMM</div>
+                                @endif
+                                @if($iPatient->rme_pro_id === $pro->id)
+                                    <div>RME</div>
+                                @endif
+                            </td>
+                            <td class="">
+                                <span class="d-inline-block width-30px">{{$iPatient->number_of_days_with_remote_measurements ?: '0'}}</span>
+                                <span class="">
+                                <?php $moreMDNeeded = 16 - $iPatient->number_of_days_with_remote_measurements; ?>
+                                @if($iPatient->number_of_days_with_remote_measurements >= 16)
+                                    <i class="fa fa-check text-success" title="16 measurement days reached"></i>
+                                @elseif($daysRemaining >= $moreMDNeeded)
+                                    <i class="fa fa-exclamation-triangle text-warning-mellow" title="{{$moreMDNeeded}} more measurement day{{$moreMDNeeded > 1 ? 's' : ''}} needed"></i>
+                                @elseif($daysRemaining < $moreMDNeeded)
+                                    <i class="fa fa-exclamation-triangle text-secondary opacity-60" title="Can no longer reach 16 measurement days this month"></i>
+                                @endif
+                                </span>
+                            </td>
+                            <td class="">
+                                <?php $numUS = 0; ?>
+                                @if($iPatient->mcp_pro_id === $pro->id)
+                                    <?php $numUS = $iPatient->rm_num_measurements_not_stamped_by_mcp; ?>
+                                @elseif($iPatient->default_na_pro_id === $pro->id)
+                                    <?php $numUS = $iPatient->rm_num_measurements_not_stamped_by_non_hcp; ?>
+                                @elseif($iPatient->rmm_pro_id === $pro->id)
+                                    <?php $numUS = $iPatient->rm_num_measurements_not_stamped_by_rmm; ?>
+                                @elseif($iPatient->rme_pro_id === $pro->id)
+                                    <?php $numUS = $iPatient->rm_num_measurements_not_stamped_by_rme; ?>
+                                @endif
+                                <span class="d-inline-block width-30px">{{$numUS ?: '-'}}</span>
+                                @if($numUS || true)
+                                    <a native target="_blank"
+                                       open-in-stag-popup
+                                       update-parent
+                                       mc-initer="remote-monitoring-measurements-{{$iPatient->care_month_id}}"
+                                       title="{{ $iPatient->name_first }} {{ $iPatient->name_last }} / Unstamped Measurements / {{ friendly_month($careMonthStart) }}"
+                                       href="/remote-monitoring-measurements/{{$iPatient->care_month_uid}}">View</a>
+                                @endif
+                            </td>
+                            @if(!$pro->is_hcp)
+                                <td class="">
+                                    {{$iPatient->has_non_hcp_communicated_to_patient_about_rm ? 'Yes' : 'No'}}
+                                </td>
+                            @endif
+                            <td class="">
+                                {{$iPatient->cell_number}}
+                            </td>
+                        </tr>
+                    @endforeach
+                    </tbody>
+                </table>
+            </div>
+        </div>
+    </div>
+@endsection

+ 153 - 0
resources/views/app/practice-management/rm-bills-to-sign.blade.php

@@ -0,0 +1,153 @@
+@extends ('layouts/template')
+
+@section('content')
+
+    <div class="p-3 mcp-theme-1">
+    <div class="card">
+
+        <div class="card-header px-3 py-2 d-flex align-items-center">
+            <strong class="mr-4">
+                <i class="fas fa-user-injured"></i>
+                RM Bills to Sign
+            </strong>
+            @if($pro->is_hcp && $bills && count($bills))
+            <div moe="" relative class="ml-auto">
+                <a class="font-weight-bold" href="#" show start>Sign All Bills</a>
+                <form url="/api/bill/signAllPendingForRM" right>
+                    <p>Sign all bills?</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 class="card-body p-0">
+
+            <table class="table table-sm table-condensed table-hover p-0 m-0">
+                <thead class="bg-light">
+                <tr>
+                    <th class="px-3 border-0">Eff. Date</th>
+                    <th class="border-0">Patient</th>
+                    <th class="border-0">Context</th>
+                    <th class="border-0">Measurement Days</th>
+                    <th class="border-0">Role</th>
+                    <th class="border-0">Amount</th>
+                    <th class="border-0"></th>
+                </tr>
+                </thead>
+                <tbody>
+                @foreach ($bills as $bill)
+                    <tr class="{{ $bill->is_cancelled ? 'cancelled-item always-clickable' : '' }}">
+                        <td class="px-3">
+                            {{ friendly_date_time($bill->effective_date, false) }}
+                        </td>
+                        <td class="">
+                            <a href="/patients/view/{{ $bill->client->uid }}">{{ $bill->client->displayName() }}</a>
+                        </td>
+                        <td class="stag-no-wrap-td">
+                            @if($bill->careMonth)
+                                <b>{{ $bill->code }}</b>
+                                -
+                                <a href="/practice-management/remote-monitoring?m={{month_part_from_date($bill->careMonth->start_date)}}&y={{year_part_from_date($bill->careMonth->start_date)}}&c={{$bill->client->uid}}">
+                                    <b>{{ friendly_month($bill->careMonth->start_date) }}</b>
+                                </a>
+                            @endif
+                            @if(!empty($bill->reason1))
+                                <div class="text-secondary text-sm stag-no-wrap" title="{{ $bill->reason1 }}">{{ $bill->reason1 }}</div>
+                            @endif
+                        </td>
+                        <td class="">
+                            <span class="d-inline-block width-30px">{{$bill->careMonth->number_of_days_with_remote_measurements ?: '0'}}</span>
+                            <span class="">
+                                <?php $moreMDNeeded = 16 - $bill->careMonth->number_of_days_with_remote_measurements; ?>
+                                </span>
+                        </td>
+                        <td>
+                            <?php
+                            $roles = [];
+                            if($bill->hcp_pro_id === $pro->id) $roles[] = 'HCP';
+                            if($bill->cm_pro_id === $pro->id) $roles[] = 'CM';
+                            if($bill->rme_pro_id === $pro->id) $roles[] = 'RME';
+                            if($bill->rmm_pro_id === $pro->id) $roles[] = 'RMM';
+                            $roles = implode("<br>", $roles);
+                            ?>
+                            {!! $roles !!}
+                        </td>
+                        <td>
+                            @if($bill->hcp_pro_id === $pro->id)
+                                @if($bill->has_hcp_been_paid)
+                                    <div>
+                                        <span class="text-dark">HCP Received:</span>
+                                        <span class="font-weight-bold text-success ml-2">${{ $bill->hcp_payment_amount }}</span>
+                                    </div>
+                                @else
+                                    <div>
+                                        <span class="text-dark">HCP Expected:</span>
+                                        <span class="font-weight-bold text-dark ml-2">{{ $bill->hcp_expected_payment_amount ? '$' . $bill->hcp_expected_payment_amount : '-' }}</span>
+                                    </div>
+                                @endif
+                            @endif
+                            @if($bill->cm_pro_id === $pro->id)
+                                @if($bill->has_cm_been_paid)
+                                    <div>
+                                        <span class="text-dark">CM Received:</span>
+                                        <span class="font-weight-bold text-success ml-2">${{ $bill->cm_payment_amount }}</span>
+                                    </div>
+                                @else
+                                    <div>
+                                        <span class="text-dark">CM Expected:</span>
+                                        <span class="font-weight-bold text-dark ml-2">{{ $bill->cm_expected_payment_amount ? '$' . $bill->cm_expected_payment_amount : '-' }}</span>
+                                    </div>
+                                @endif
+                            @endif
+                            @if($bill->rmm_pro_id === $pro->id)
+                                @if($bill->has_rmm_been_paid)
+                                    <div>
+                                        <span class="text-dark">RMM Received:</span>
+                                        <span class="font-weight-bold text-success ml-2">${{ $bill->rmm_payment_amount }}</span>
+                                    </div>
+                                @else
+                                    <div>
+                                        <span class="text-dark">RMM Expected:</span>
+                                        <span class="font-weight-bold text-dark ml-2">{{ $bill->rmm_expected_payment_amount ? '$' . $bill->rmm_expected_payment_amount : '-' }}</span>
+                                    </div>
+                                @endif
+                            @endif
+                            @if($bill->rme_pro_id === $pro->id)
+                                @if($bill->has_rme_been_paid)
+                                    <div>
+                                        <span class="text-dark">RME Received:</span>
+                                        <span class="font-weight-bold text-success ml-2">${{ $bill->rme_payment_amount }}</span>
+                                    </div>
+                                @else
+                                    <div>
+                                        <span class="text-dark">RME Expected:</span>
+                                        <span class="font-weight-bold text-dark ml-2">{{ $bill->rme_expected_payment_amount ? '$' . $bill->rme_expected_payment_amount : '-' }}</span>
+                                    </div>
+                                @endif
+                            @endif
+                        </td>
+                        <td>
+                            <div moe="" relative>
+                                <a class="" href="#" show="" start="">Sign Bill</a>
+                                <form url="/api/bill/signGlobal" right="">
+                                    <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                    <p>Sign this bill?</p>
+                                    <div class="mb-0">
+                                        <button class="btn btn-success btn-sm" submit="">Sign</button>
+                                        <button class="btn btn-default border btn-sm" cancel="">Cancel</button>
+                                    </div>
+                                </form>
+                            </div>
+                        </td>
+                    </tr>
+                @endforeach
+                </tbody>
+            </table>
+        </div>
+    </div>
+    </div>
+
+@endsection

+ 1 - 1
resources/views/app/practice-management/supply-orders.blade.php

@@ -195,7 +195,7 @@
                 </tbody>
             </table>
             <div>
-                {{$supplyOrders->links()}}
+                {{$supplyOrders->withQueryString()->links()}}
             </div>
         </div>
     </div>

+ 9 - 7
resources/views/layouts/patient.blade.php

@@ -317,15 +317,17 @@
                                                 @elseif($patient->was_medicare_validation_successful)
                                                     <span>
                                                     @if($patient->is_part_b_primary == 'YES')
-                                                            Medicare Part B
-                                                        @else
-                                                            Not Medicare Part B <i class="fa fa-times"></i>
-                                                            @if($patient->is_medicare_advantage == 'YES')
-                                                                , Medicare Advantage,
-                                                                {{$patient->medicare_advantage_plan}}
-                                                            @endif
+                                                        Medicare Part B
+                                                    @else
+                                                        Not Medicare Part B <i class="fa fa-times"></i>
+                                                        @if($patient->is_medicare_advantage == 'YES')
+                                                            , Medicare Advantage,
+                                                            {{$patient->medicare_advantage_plan}}
                                                         @endif
+                                                    @endif
                                                 </span>
+                                                @elseif($patient->payer_name && $patient->payer_member_id)
+                                                    <b class="text-secondary">{{$patient->payer_name}}</b> {{--[{{$patient->payer_member_id}}]--}}
                                                 @else
                                                     <div moe>
                                                         <a href="" start show>

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

@@ -107,6 +107,7 @@
                         <a class="dropdown-item" href="{{ route('practice-management.financialTransactions') }}">Financial Transactions</a>
                         <a class="dropdown-item" href="/practice-management/bills/not-yet-signed">Pending Bills to Sign</a>
                         <a class="dropdown-item" href="/practice-management/notes/not-yet-signed">Pending Notes to Sign</a>
+                        <a class="dropdown-item" href="/practice-management/notes/not-yet-signed-but-ally-signed">Pending Notes to Sign (Ally Signed)</a>
                         <a class="dropdown-item" href="{{ route('unmapped-sms') }}">Unmapped SMS</a>
                         <a class="dropdown-item" href="{{ route('practice-management.myTickets') }}">My Tickets</a>
                         <a class="dropdown-item" href="{{ route('practice-management.myTextShortcuts') }}">My Text Shortcuts</a>

+ 17 - 16
resources/views/layouts/template.blade.php

@@ -110,6 +110,9 @@
                         <a class="dropdown-item" href="{{ route('practice-management.financialTransactions') }}">Financial Transactions</a>
                         <a class="dropdown-item" href="/practice-management/bills/not-yet-signed">Pending Bills to Sign</a>
                         <a class="dropdown-item" href="/practice-management/notes/not-yet-signed">Pending Notes to Sign</a>
+                        <a class="dropdown-item" href="/practice-management/notes/not-yet-signed-but-ally-signed">Pending Notes to Sign (Ally Signed)</a>
+                        <a class="dropdown-item" href="{{ route('practice-management.remote-monitoring') }}">Remote Monitoring</a>
+                        <a class="dropdown-item" href="{{ route('practice-management.rm-bills-to-sign') }}">RM Bills to Sign</a>
                         <a class="dropdown-item" href="{{ route('unmapped-sms') }}">Unmapped SMS</a>
                         <a class="dropdown-item" href="{{ route('practice-management.myTickets') }}">My Tickets</a>
                         <a class="dropdown-item" href="{{ route('practice-management.myTextShortcuts') }}">My Text Shortcuts</a>
@@ -123,6 +126,7 @@
 
                         @if($pro && $pro->pro_type == 'ADMIN')
                             <a class="dropdown-item" href="{{ route('practice-management.processingBillMatrix') }}">Processing Bills</a>
+                            <a class="dropdown-item" href="{{ route('practice-management.pro-financials') }}">Pro Financials</a>
                             <a class="dropdown-item" href="{{ route('practice-management.cellularMeasurements') }}">Cellular Measurements</a>
                             <a class="dropdown-item" href="{{ route('practice-management.cellularDeviceManager') }}">Cellular Device Manager</a>
                             <a class="dropdown-item" href="{{ route('practice-management.medicarePartBClaims') }}">Medicare Part B Claims</a>
@@ -144,10 +148,10 @@
                     </div>
                 </li>
             </ul>
-            {{-- if pro is working on a client and is not in tht client --}}
+            {{-- if pro is working on a client and is not in tht client
             <div class="current-work mr-2">
                 @include('app/current-work')
-            </div>
+            </div> --}}
             <a href="#" class="mr-2 text-white small" onclick="return fastReload()"><i class="fa fa-sync"></i></a>
             <div class="d-inline-flex pr-2 mcp-theme-1 position-relative">
                 <input id="patient-search" type="search" class="form-control form-control-sm outline-0" autocomplete="off" placeholder="Search Patients">
@@ -247,11 +251,16 @@
             var lastTerm = '';
             var returnedFunction = debounce(function() {
                 var term = $.trim($('#patient-search').val());
-                if (!!term && lastTerm !== term) {
-                    $.get('/patients-suggest?term=' + term, function(_data) {
-                        $('.patient-search-results.suggestions-outer').html(_data).removeClass('d-none');
-                    });
-                    lastTerm = term;
+                if (!!term) {
+                    if(lastTerm !== term) {
+                        $('.patient-search-results.suggestions-outer')
+                            .html('<span class="d-block no-suggest-items">Searching...</span>')
+                            .removeClass('d-none');
+                        $.get('/patients-suggest?term=' + term, function(_data) {
+                            $('.patient-search-results.suggestions-outer').html(_data).removeClass('d-none');
+                        });
+                        lastTerm = term;
+                    }
                 } else {
                     $('.patient-search-results.suggestions-outer').addClass('d-none');
                 }
@@ -305,15 +314,7 @@
                 });
 
             function onQueryChange() {
-                var term = $.trim($('#patient-search').val());
-                if (!!term) {
-                    $('.patient-search-results.suggestions-outer')
-                        .html('<span class="d-block no-suggest-items">Searching...</span>')
-                        .removeClass('d-none');
-                    returnedFunction();
-                } else {
-                    $('.patient-search-results.suggestions-outer').addClass('d-none');
-                }
+                returnedFunction();
             }
             $(document).on('mousedown', '.suggest-item.patient-suggest[data-target-uid]', function() {
                 $('#patient-search').val('');

+ 8 - 0
routes/web.php

@@ -84,6 +84,7 @@ Route::middleware('pro.auth')->group(function () {
         Route::get('notes/{filter?}', 'PracticeManagementController@notes')->name('notes');
         Route::get('na-billable-signed-notes/{filter?}', 'PracticeManagementController@naBillableSignedNotes')->name('na-billable-signed-notes');
         Route::get('bills/{filter?}', 'PracticeManagementController@bills')->name('bills');
+        Route::get('rm-bills-to-sign', 'PracticeManagementController@rmBillsToSign')->name('rm-bills-to-sign');
         Route::get('unacknowledged-cancelled-bills', 'PracticeManagementController@unacknowledgedCancelledBills')->name('unacknowledged-cancelled-bills');
         Route::get('my-tickets/{filter?}', 'PracticeManagementController@myTickets')->name('myTickets');
         Route::get('my-text-shortcuts', 'PracticeManagementController@myTextShortcuts')->name('myTextShortcuts');
@@ -114,6 +115,8 @@ Route::middleware('pro.auth')->group(function () {
 
             Route::get('processing-bill-matrix/{proUid?}/{filter?}', 'PracticeManagementController@processingBillMatrix')->name('processingBillMatrix');
 
+            Route::get('pro-financials/{proUid?}', 'PracticeManagementController@proFinancials')->name('pro-financials');
+
             //Route::get('hcp-bill-matrix/{proUid?}', 'PracticeManagementController@hcpBillMatrix')->name('hcpBillMatrix');
             Route::get('bill-matrix/{proUid?}', 'PracticeManagementController@billMatrix')->name('billMatrix');
 
@@ -148,6 +151,9 @@ Route::middleware('pro.auth')->group(function () {
 
         Route::get('supply-orders/cancelled-but-unacknowledged', 'PracticeManagementController@supplyOrdersCancelledButUnacknowledged')->name('supply-orders-cancelled-but-unacknowledged');
         Route::get('supply-orders/unsigned', 'PracticeManagementController@supplyOrdersUnsigned')->name('supply-orders-unsigned');
+
+        Route::get('remote-monitoring', 'PracticeManagementController@remoteMonitoring')->name('remote-monitoring');
+
     });
 
     Route::middleware('pro.auth.admin')->group(function(){
@@ -312,6 +318,8 @@ Route::middleware('pro.auth')->group(function () {
     Route::get("/log_in_as", 'HomeController@logInAs')->name('log-in-as');
     Route::post("/process-log_in_as", 'HomeController@processLogInAs')->name('process-log-in-as');
     Route::post("/back_to_admin_pro", 'HomeController@backToAdminPro')->name('back-to-admin-pro');
+
+    Route::get('/remote-monitoring-measurements/{careMonth}', 'PracticeManagementController@remoteMonitoringMeasurements')->name('remote-monitoring-measurements');
 });
 
 Route::post("/process_form_submit", 'NoteController@processFormSubmit')->name('process_form_submit');

+ 97 - 0
spec/rm-care-month-spec.txt

@@ -0,0 +1,97 @@
+
+	care_month:
+
+		1. There have to be 16 measurement days. (is_cellular).
+
+		2. At the 16th measurement day:
+
+			BOTH the MCP and the RME/RMM are prompted to sign off.
+		
+			--> we have to somehow make sure MCP time billed >= 30.
+			--> we have to somehow make sure EXTRA time >= 20.
+
+		3. THE EASIEST WAY to do this is going to be by enabling a stamp feature on measurements.
+
+			// stamp all within safe range on UI
+
+			class MeasurementStamp // have to be done within that month...
+				Measurement measurement;
+				Pro pro;
+				String memo; // auto-suggest
+				Boolean communicatedToPatient; // 
+
+					// NOT OKAY!!!!! FIRST TIME REQUIRED - after first time, no forcing - in order to click this checkbox, you first have to fire off an email or text message to the patient - autosuggested message: "Hi {name}! Your weight looks normal, keep it up!".
+
+					// THIS REQUIRES A PHONE-CALL ATTESTATION BY NON-HCP.
+
+			ALTER TABLE measurement ADD COLUMN has_been_stamped_by_mcp BOOLEAN DEFAULT FALSE;
+			ALTER TABLE measurement ADD COLUMN has_been_stamped_by_non_hcp BOOLEAN DEFAULT FALSE;
+			
+			** For curiosity sake...
+			ALTER TABLE measurement ADD COLUMN has_been_stamped_by_rme BOOLEAN DEFAULT FALSE;
+			ALTER TABLE measurement ADD COLUMN has_been_stamped_by_rmm BOOLEAN DEFAULT FALSE;
+
+		4. DISABLE THE CONVENTIONAL CRUD UI for 'care_month_entry' for anyone. 
+	
+			We literally ONLY want the time they can bill each month to = 30 / 20 and it only becomes relevant if 16 measurement days.
+
+			* From now on, we will only submit RM30_HCP or RM30_HCP_PLUS_20EXTRA. We don't want to bill anything else.
+
+			Remember - it is not possible for a care_month to be billed unless 16 days anyway, so no sense in care_month_entries that are accruing time that won't be paid anyway.
+
+			So once you reach day 16, auto care-month-entry to reach MCP to 30 mins.
+				
+				*** BAD IDEA *** If there is also a MeasurementStamp by a non-HCP, then there is another prompt for any non-MCP to bill their 20 mins.
+					*** WE DON'T WANT THEM TO RMM to think in 'minutes', just measurement days and at least one stamp needs to be communicatedToPatient = true.
+					*** So literally, for non-HCP it's just a scoreboard - hit 16 and get paid!!!
+			
+			There are two possibilities: 
+				
+				MCP can bill 30 mins. but the non-MCP can or can't bill 20 mins. properly - because they did not have communicatedToPatient=true.
+
+			ONCE WE HAVE REACHED THE APPROPRIATE #16 measurement days and generated approp. MINUTES (30 HCP, and possibly 20 non-HCP extra IF there is a communicatedToPatient=true record), we auto-generate RM30_HCP_PLUS_EXTRA20 if possible OR... at the stroke of midnight EST on the next month start 1st of month (**or some weird logic for Feb. maybe), we generate RM30_HCP and digitize warning to the RMM.
+
+				*** so offline, what may happen in a bad case is: "Hey NA/RMM, did you guys not do anything? Oh - okay. Guess we will bill RM30_HCP, but next month please focus and let's do RM30_HCP_PLUS_EXTRA20 aka, you need to stamp and contact patient at least once on a month they measured 16 times!"
+
+			For MCP:
+
+				MCP sees a pending bill for them to sign, and they sign it.
+
+				The UI should not say "RM30_HCP" it should say simply "Billable time: 30 minutes, {{RM30_HCP rate}}"
+
+			For RMM:
+
+				RMM sees a pending bill for them to sign, and they sign it.
+
+				The UI should not say "RM30_HCP_PLUS_EXTRA20" it should say simply "Congrats! 16 days achieved. {{RM30_HCP rate for RMM}}"
+
+		5. TO PROCESS THESE CARE-MONTHS:
+
+			- understand that what we need flows like this:
+			
+				- ENCOURAGE VIGILENCE to make sure everyone reaches 16.
+
+					- Pt. list with measurement days column, green row if >= 16.
+					- red row if 15...
+					- orange if 14...
+					- gray if dead... can't achieve 16 even if they want.
+
+			FOR BILLERS: no work.
+
+				Auto-generate claim as per billable code.
+
+				There needs to be a simple UI similar to Note Resolver where you see the CareMonth including stamps and the ultra-important ONE or TWO care-month-entries that correlate to what bill to process. With one click - generate claim with lines as per spec. That's it.
+
+				FOR ICD:::
+
+					- ClientCmRmReason // ... limit to 4 per cm/rm
+					- CareMonthCmRmReason // ... TODO @Josh... make sure...
+
+					// NEEDED IN SYSTEM:
+
+						explicit crud on ClientCmRmReason && CareMonthCmRmReason
+
+						// Josh dev endpoint to generate...
+
+-------------------------------------------------------------------------------------
+	Ongoing: reminders to push ppl to reach 16.