Przeglądaj źródła

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

Samson Mutunga 3 lat temu
rodzic
commit
5520b7b4a7
100 zmienionych plików z 6893 dodań i 1142 usunięć
  1. 170 0
      app/Http/Controllers/AdminController.php
  2. 3 8
      app/Http/Controllers/AppointmentController.php
  3. 211 0
      app/Http/Controllers/DnaController.php
  4. 6 12
      app/Http/Controllers/GuestController.php
  5. 370 59
      app/Http/Controllers/HomeController.php
  6. 269 0
      app/Http/Controllers/McpController.php
  7. 60 4
      app/Models/Client.php
  8. 12 0
      app/Models/Note.php
  9. 201 3
      app/Models/Pro.php
  10. 11 0
      app/Models/Status.php
  11. 62 0
      config/constants.php
  12. 4 1
      public/css/style.css
  13. 5 0
      resources/views/app/admin/appointments.blade.php
  14. 5 0
      resources/views/app/admin/bills.blade.php
  15. 1 0
      resources/views/app/admin/dashboard/calls_memos.blade.php
  16. 1 0
      resources/views/app/admin/dashboard/erx_orders.blade.php
  17. 1 0
      resources/views/app/admin/dashboard/measurements.blade.php
  18. 1 0
      resources/views/app/admin/dashboard/messages.blade.php
  19. 1 0
      resources/views/app/admin/dashboard/notifications.blade.php
  20. 1 0
      resources/views/app/admin/dashboard/supply_orders.blade.php
  21. 5 0
      resources/views/app/admin/erx_and_orders.blade.php
  22. 5 0
      resources/views/app/admin/notes.blade.php
  23. 6 0
      resources/views/app/admin/patients.blade.php
  24. 5 0
      resources/views/app/admin/reports.blade.php
  25. 5 0
      resources/views/app/admin/supply_orders.blade.php
  26. 913 0
      resources/views/app/dashboard-admin.blade.php
  27. 918 0
      resources/views/app/dashboard-dna.blade.php
  28. 746 0
      resources/views/app/dashboard-mcp.blade.php
  29. 0 988
      resources/views/app/dashboard.blade.php
  30. 5 0
      resources/views/app/dna/appointments.blade.php
  31. 5 0
      resources/views/app/dna/bills.blade.php
  32. 0 0
      resources/views/app/dna/cancelled_appointments_pending_review.blade.php
  33. 0 0
      resources/views/app/dna/cancelled_bills_pending_review.blade.php
  34. 0 0
      resources/views/app/dna/cancelled_supply_orders_pending_review.blade.php
  35. 1 0
      resources/views/app/dna/dashboard/calls_memos.blade.php
  36. 1 0
      resources/views/app/dna/dashboard/erx_orders.blade.php
  37. 1 0
      resources/views/app/dna/dashboard/measurements.blade.php
  38. 1 0
      resources/views/app/dna/dashboard/messages.blade.php
  39. 1 0
      resources/views/app/dna/dashboard/notifications.blade.php
  40. 1 0
      resources/views/app/dna/dashboard/supply_orders.blade.php
  41. 5 0
      resources/views/app/dna/erx_and_orders.blade.php
  42. 0 0
      resources/views/app/dna/erx_and_orders_pending_signature.blade.php
  43. 0 0
      resources/views/app/dna/new_patients_awaiting_visit.blade.php
  44. 5 0
      resources/views/app/dna/notes.blade.php
  45. 0 0
      resources/views/app/dna/notes_pending_billing.blade.php
  46. 0 0
      resources/views/app/dna/notes_pending_signature.blade.php
  47. 23 0
      resources/views/app/dna/patients.blade.php
  48. 0 0
      resources/views/app/dna/patients_overdue.blade.php
  49. 0 0
      resources/views/app/dna/patients_without_appointments.blade.php
  50. 5 0
      resources/views/app/dna/reports.blade.php
  51. 0 0
      resources/views/app/dna/reports_pending_signature.blade.php
  52. 5 0
      resources/views/app/dna/supply_orders.blade.php
  53. 0 0
      resources/views/app/dna/supply_orders_pending_signature.blade.php
  54. 2 0
      resources/views/app/generic-bills/inline.blade.php
  55. 1 1
      resources/views/app/guest/appointment-confirmation.blade.php
  56. 55 0
      resources/views/app/mcp/appointments.blade.php
  57. 100 0
      resources/views/app/mcp/appointments_filters.blade.php
  58. 53 0
      resources/views/app/mcp/bills.blade.php
  59. 87 0
      resources/views/app/mcp/bills_filters.blade.php
  60. 19 0
      resources/views/app/mcp/cancelled_appointments_pending_review.blade.php
  61. 44 0
      resources/views/app/mcp/cancelled_bills_pending_review.blade.php
  62. 45 0
      resources/views/app/mcp/cancelled_supply_orders_pending_review.blade.php
  63. 53 0
      resources/views/app/mcp/client_messages.blade.php
  64. 95 0
      resources/views/app/mcp/client_messages_filters.blade.php
  65. 70 0
      resources/views/app/mcp/dashboard/appointments.blade.php
  66. 1 0
      resources/views/app/mcp/dashboard/calls_memos.blade.php
  67. 1 0
      resources/views/app/mcp/dashboard/erx_orders.blade.php
  68. 1 0
      resources/views/app/mcp/dashboard/measurements.blade.php
  69. 1 0
      resources/views/app/mcp/dashboard/messages.blade.php
  70. 67 0
      resources/views/app/mcp/dashboard/notifications.blade.php
  71. 1 0
      resources/views/app/mcp/dashboard/reports.blade.php
  72. 1 0
      resources/views/app/mcp/dashboard/supply_orders.blade.php
  73. 51 0
      resources/views/app/mcp/erx_and_orders.blade.php
  74. 87 0
      resources/views/app/mcp/erx_and_orders_filters.blade.php
  75. 76 0
      resources/views/app/mcp/erx_and_orders_pending_signature.blade.php
  76. 79 0
      resources/views/app/mcp/new_patients_awaiting_visit.blade.php
  77. 51 0
      resources/views/app/mcp/notes.blade.php
  78. 87 0
      resources/views/app/mcp/notes_filters.blade.php
  79. 48 0
      resources/views/app/mcp/notes_pending_billing.blade.php
  80. 48 0
      resources/views/app/mcp/notes_pending_signature.blade.php
  81. 74 0
      resources/views/app/mcp/patients-table.blade.php
  82. 22 0
      resources/views/app/mcp/patients.blade.php
  83. 261 0
      resources/views/app/mcp/patients_filters.blade.php
  84. 19 0
      resources/views/app/mcp/patients_overdue_for_visit.blade.php
  85. 19 0
      resources/views/app/mcp/patients_without_appointments.blade.php
  86. 5 0
      resources/views/app/mcp/reports.blade.php
  87. 60 0
      resources/views/app/mcp/reports_pending_signature.blade.php
  88. 53 0
      resources/views/app/mcp/supply_orders.blade.php
  89. 87 0
      resources/views/app/mcp/supply_orders_filters.blade.php
  90. 45 0
      resources/views/app/mcp/supply_orders_pending_signature.blade.php
  91. 14 11
      resources/views/app/new-patient.blade.php
  92. 469 28
      resources/views/app/patient/appointment-calendar.blade.php
  93. 1 3
      resources/views/app/patient/appointments.blade.php
  94. 1 0
      resources/views/app/patient/note/_create-bill.blade.php
  95. 23 1
      resources/views/app/patient/note/dashboard.blade.php
  96. 1 1
      resources/views/app/patient/partials/appointment-confirmation-history.blade.php
  97. 21 12
      resources/views/app/patient/partials/appointment-confirmation.blade.php
  98. 2 3
      resources/views/app/patient/partials/appointments.blade.php
  99. 39 0
      resources/views/app/patient/partials/bulkstamp.http
  100. 396 7
      resources/views/app/patient/settings.blade.php

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

@@ -0,0 +1,170 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\Models\Appointment;
+use App\Models\BDTDevice;
+use App\Models\CareMonth;
+use App\Models\Client;
+use App\Models\ClientBDTDevice;
+use App\Models\ClientInfoLine;
+use App\Models\Erx;
+use App\Models\Facility;
+use App\Models\Handout;
+use App\Models\IncomingReport;
+use App\Models\MBClaim;
+use App\Models\MBPayer;
+use App\Models\Note;
+use App\Models\NoteTemplate;
+use App\Models\Pro;
+use App\Models\Product;
+use App\Models\ProProAccess;
+use App\Models\SectionTemplate;
+use App\Models\Shipment;
+use App\Models\SupplyOrder;
+use App\Models\Ticket;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\File;
+use App\Models\Bill;
+use App\Models\ClientSMS;
+
+use Illuminate\Support\Facades\Http;
+use PDF;
+
+class AdminController extends Controller
+{
+
+    public function patients(Request $request)
+    {
+        $filters = $request->all();
+        $patients = Client::whereNull('shadow_pro_id')->where('mcp_pro_id', $this->performer->pro->id);
+
+        // filters
+        /*
+        array:18 [▼
+          "age_category" => "LESS_THAN"
+          "age_value_1" => "34"
+          "age_value_2" => null
+          "sex" => "M"
+          "bmi_category" => "BETWEEN"
+          "bmi_value_1" => "20"
+          "bmi_value_2" => "25"
+          "last_visit_category" => "LESS_THAN"
+          "last_visit_value_1" => "2021-10-14"
+          "last_visit_value_2" => null
+          "next_appointment_category" => "LESS_THAN"
+          "next_appointment_value_1" => "2021-10-15"
+          "status" => "ACTIVE"
+          "last_weighed_in_category" => "EXACTLY"
+          "last_weighed_in_value_1" => "2021-10-07"
+          "last_bp_category" => "BETWEEN"
+          "last_bp_value_1" => "2021-10-01"
+          "last_bp_value_2" => "2021-10-31"
+        ]
+        */
+
+        $this->filterMultiQuery($request, $patients, 'age_in_years', 'age_category', 'age_value_1', 'age_value_2');
+        $this->filterSimpleQuery($request, $patients, 'sex', 'sex');
+        $this->filterMultiQuery($request, $patients, 'usual_bmi', 'bmi_category', 'bmi_value_1', 'bmi_value_2');
+        $this->filterMultiQuery($request, $patients, 'most_recent_weight_at', 'last_weighed_in_category', 'last_weighed_in_value_1', 'last_weighed_in_value_2');
+        $this->filterMultiQuery($request, $patients, 'most_recent_bp_at', 'last_bp_category', 'last_bp_value_1', 'last_bp_value_2');
+
+        switch($request->input('status')) {
+            case 'ACTIVE':
+                $patients->where('is_active', true)->where('has_mcp_done_onboarding_visit', true);
+                break;
+            case 'AWAITING_VISIT':
+                $patients->where('is_active', true)->where('has_mcp_done_onboarding_visit', false);
+                break;
+            case 'INACTIVE':
+                $patients->where('is_active', '<>', true);
+                break;
+        }
+
+        $patients = $patients->orderBy('created_at', 'DESC')->get();
+        return view('app.mcp.patients', compact('patients', 'filters'));
+    }
+
+    private function filterSimpleQuery(Request $request, $query, $columnName, $valueName) {
+        if($request->input($valueName)) {
+            $query->where($columnName, $request->input($valueName));
+        }
+    }
+    private function filterMultiQuery(Request $request, $query, $columnName, $keyName, $valueName1, $valueName2) {
+        switch($request->input($keyName)) {
+            case 'EXACTLY':
+                if($request->input($valueName1)) {
+                    $query->where($columnName, $request->input($valueName1));
+                }
+                break;
+            case 'LESS_THAN':
+                if($request->input($valueName1)) {
+                    $query->where($columnName, '<', $request->input($valueName1));
+                }
+                break;
+            case 'GREATER_THAN':
+                if($request->input($valueName1)) {
+                    $query->where($columnName, '>', $request->input($valueName1));
+                }
+                break;
+            case 'BETWEEN':
+                if($request->input($valueName1) && $request->input($valueName2)) {
+                    $query
+                        ->where($columnName, '>=', $request->input($valueName1))
+                        ->where($columnName, '<=', $request->input($valueName2));
+                }
+                break;
+            case 'NOT_BETWEEN':
+                if($request->input($valueName1) && $request->input($valueName2)) {
+                    $query
+                        ->where(function ($q) use ($request, $columnName, $valueName1, $valueName2) {
+                            $q->where($columnName, '<', $request->input($valueName1))
+                                ->orWhere($columnName, '>', $request->input($valueName2));
+                        });
+                }
+                break;
+        }
+    }
+
+    public function notes(Request $request)
+    {
+        $notes = Note::paginate(5);
+
+        // SELECT * FROM note WHERE client_id IN (SELECT id FROM client WHERE mcp_pro_id = :me.id);
+
+        return view('app.mcp.notes', compact('notes'));
+    }
+
+    public function appointments(Request $request)
+    {
+        $appointments = Appointment::paginate(5);
+        return view('app.mcp.appointments', compact('appointments'));
+    }
+
+    public function bills(Request $request)
+    {
+        $bills = Bill::paginate(5);
+        return view('app.mcp.bills', compact('bills'));
+    }
+
+    public function erx_and_orders(Request $request)
+    {
+        $erxAndOrders = Erx::paginate(5);
+        return view('app.mcp.erx_and_orders', compact('erxAndOrders'));
+    }
+
+    public function reports(Request $request)
+    {
+        $data = [];
+        return view('app.mcp.reports', $data);
+    }
+
+    public function supply_orders(Request $request)
+    {
+        $supplyOrders = SupplyOrder::paginate(5);
+        return view('app.mcp.supply_orders', compact('supplyOrders'));
+    }
+
+   
+}

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

@@ -78,7 +78,7 @@ class AppointmentController extends Controller
 
                 $shortStatus = '';
                 switch($appointment->status) {
-                    case 'CREATED':
+                    case 'PENDING':
                         $shortStatus = 'new';
                         break;
                     case 'CONFIRMED':
@@ -90,12 +90,6 @@ class AppointmentController extends Controller
                     case 'COMPLETED':
                         $shortStatus = 'done';
                         break;
-                    case 'ABANDONED':
-                        $shortStatus = 'aban';
-                        break;
-                    case 'REJECTED':
-                        $shortStatus = 'rej';
-                        break;
                 }
 
                 if(count($proIds) === 1) {
@@ -265,7 +259,7 @@ class AppointmentController extends Controller
 
                 // make already booked slots unavailable
                 $proAppointments = $appointments->filter(function ($record) use ($proId, $pro) {
-                    return ($record->pro_id == $proId || $record->client_id == $pro->shadow_client_id) && !in_array($record->status, ['CANCELLED', 'COMPLETED', 'ABANDONED']);
+                    return ($record->pro_id == $proId || $record->client_id == $pro->shadow_client_id) && !in_array($record->status, ['CANCELLED', 'COMPLETED']);
                 });
                 foreach ($proAppointments as $appointment) {
                     if ($appointment->start_time && $appointment->end_time) {
@@ -288,6 +282,7 @@ class AppointmentController extends Controller
                         "title" => $pro->displayName() . " (available)",
                         "proId" => $pro->id,
                         "proUid" => $pro->uid,
+                        "proName" => $pro->displayName(),
                         "start" => $eStart->format('Y-m-d H:i:s'),
                         "end" => $eEnd->format('Y-m-d H:i:s'),
                         "editable" => false

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

@@ -0,0 +1,211 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\Models\Appointment;
+use App\Models\BDTDevice;
+use App\Models\CareMonth;
+use App\Models\Client;
+use App\Models\ClientBDTDevice;
+use App\Models\ClientInfoLine;
+use App\Models\Erx;
+use App\Models\Facility;
+use App\Models\Handout;
+use App\Models\IncomingReport;
+use App\Models\MBClaim;
+use App\Models\MBPayer;
+use App\Models\Note;
+use App\Models\NoteTemplate;
+use App\Models\Pro;
+use App\Models\Product;
+use App\Models\ProProAccess;
+use App\Models\SectionTemplate;
+use App\Models\Shipment;
+use App\Models\SupplyOrder;
+use App\Models\Ticket;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\File;
+
+use Illuminate\Support\Facades\Http;
+use PDF;
+
+class DnaController extends Controller
+{
+
+    public function patients(Request $request)
+    {
+        $filters = $request->all();
+        $patients = Client::whereNull('shadow_pro_id')->where('default_na_pro_id', $this->performer->pro->id);
+
+        // filters
+        /*
+        array:18 [▼
+          "age_category" => "LESS_THAN"
+          "age_value_1" => "34"
+          "age_value_2" => null
+          "sex" => "M"
+          "bmi_category" => "BETWEEN"
+          "bmi_value_1" => "20"
+          "bmi_value_2" => "25"
+          "last_visit_category" => "LESS_THAN"
+          "last_visit_value_1" => "2021-10-14"
+          "last_visit_value_2" => null
+          "next_appointment_category" => "LESS_THAN"
+          "next_appointment_value_1" => "2021-10-15"
+          "status" => "ACTIVE"
+          "last_weighed_in_category" => "EXACTLY"
+          "last_weighed_in_value_1" => "2021-10-07"
+          "last_bp_category" => "BETWEEN"
+          "last_bp_value_1" => "2021-10-01"
+          "last_bp_value_2" => "2021-10-31"
+        ]
+        */
+
+        $this->filterMultiQuery($request, $patients, 'age_in_years', 'age_category', 'age_value_1', 'age_value_2');
+        $this->filterSimpleQuery($request, $patients, 'sex', 'sex');
+        $this->filterMultiQuery($request, $patients, 'usual_bmi', 'bmi_category', 'bmi_value_1', 'bmi_value_2');
+        $this->filterMultiQuery($request, $patients, 'most_recent_weight_at', 'last_weighed_in_category', 'last_weighed_in_value_1', 'last_weighed_in_value_2');
+        $this->filterMultiQuery($request, $patients, 'most_recent_bp_at', 'last_bp_category', 'last_bp_value_1', 'last_bp_value_2');
+
+        switch($request->input('status')) {
+            case 'ACTIVE':
+                $patients->where('is_active', true)->where('has_mcp_done_onboarding_visit', true);
+                break;
+            case 'AWAITING_VISIT':
+                $patients->where('is_active', true)->where('has_mcp_done_onboarding_visit', false);
+                break;
+            case 'INACTIVE':
+                $patients->where('is_active', '<>', true);
+                break;
+        }
+
+
+
+        $patients = $patients->orderBy('created_at', 'DESC')->paginate(20);
+        return view('app.dna.patients', compact('patients', 'filters'));
+    }
+
+    private function filterSimpleQuery(Request $request, $query, $columnName, $valueName) {
+        if($request->input($valueName)) {
+            $query->where($columnName, $request->input($valueName));
+        }
+    }
+    private function filterMultiQuery(Request $request, $query, $columnName, $keyName, $valueName1, $valueName2) {
+        switch($request->input($keyName)) {
+            case 'EXACTLY':
+                if($request->input($valueName1)) {
+                    $query->where($columnName, $request->input($valueName1));
+                }
+                break;
+            case 'LESS_THAN':
+                if($request->input($valueName1)) {
+                    $query->where($columnName, '<', $request->input($valueName1));
+                }
+                break;
+            case 'GREATER_THAN':
+                if($request->input($valueName1)) {
+                    $query->where($columnName, '>', $request->input($valueName1));
+                }
+                break;
+            case 'BETWEEN':
+                if($request->input($valueName1) && $request->input($valueName2)) {
+                    $query
+                        ->where($columnName, '>=', $request->input($valueName1))
+                        ->where($columnName, '<=', $request->input($valueName2));
+                }
+                break;
+            case 'NOT_BETWEEN':
+                if($request->input($valueName1) && $request->input($valueName2)) {
+                    $query
+                        ->where(function ($q) use ($request, $columnName, $valueName1, $valueName2) {
+                            $q->where($columnName, '<', $request->input($valueName1))
+                                ->orWhere($columnName, '>', $request->input($valueName2));
+                        });
+                }
+                break;
+        }
+    }
+
+    public function notes(Request $request)
+    {
+        $data = [];
+        return view('app.dna.notes', $data);
+    }
+
+    public function appointments(Request $request)
+    {
+        $data = [];
+        return view('app.dna.appointments', $data);
+    }
+
+    public function bills(Request $request)
+    {
+        $data = [];
+        return view('app.dna.bills', $data);
+    }
+
+    public function erx_and_orders(Request $request)
+    {
+        $data = [];
+        return view('app.dna.erx_and_orders', $data);
+    }
+
+    public function reports(Request $request)
+    {
+        $data = [];
+        return view('app.dna.reports', $data);
+    }
+
+    public function supply_orders(Request $request)
+    {
+        $data = [];
+        return view('app.dna.supply_orders', $data);
+    }
+
+    public function new_patients_awaiting_visit(Request $request){
+        $data = [];
+        return view('app.dna.new_patients_awaiting_visit', $data);
+    }
+    public function notes_pending_signature(Request $request){
+        $data = [];
+        return view('app.dna.notes_pending_signature', $data);
+    }
+    public function notes_pending_billing(Request $request){
+        $data = [];
+        return view('app.dna.notes_pending_billing', $data);
+    }
+    public function reports_pending_signature(Request $request){
+        $data = [];
+        return view('app.dna.reports_pending_signature', $data);
+    }
+    public function patients_without_appointments(Request $request){
+        $data = [];
+        return view('app.dna.patients_without_appointments', $data);
+    }
+    public function patients_overdue_for_visit(Request $request){
+        $data = [];
+        return view('app.dna.patients_overdue_for_visit', $data);
+    }
+    public function cancelled_appointments_pending_review(Request $request){
+        $data = [];
+        return view('app.dna.cancelled_appointments_pending_review', $data);
+    }
+    public function cancelled_bills_pending_review(Request $request){
+        $data = [];
+        return view('app.dna.cancelled_bills_pending_review', $data);
+    }
+    public function cancelled_supply_orders_pending_review(Request $request){
+        $data = [];
+        return view('app.dna.cancelled_supply_orders_pending_review', $data);
+    }
+    public function erx_and_orders_pending_signature(Request $request){
+        $data = [];
+        return view('app.dna.erx_and_orders_pending_signature', $data);
+    }
+    public function supply_orders_pending_signature(Request $request){
+        $data = [];
+        return view('app.dna.supply_orders_pending_signature', $data);
+    }
+
+}

+ 6 - 12
app/Http/Controllers/GuestController.php

@@ -58,10 +58,8 @@ class GuestController extends Controller
         $appointment = Appointment::where('uid', $appointmentUid)->first();
         abort_if(!count($appointment->confirmationRequests), 404, 'No confirmation requests on this appointment.');
         abort_if(!$appointment, 404, 'Invalid url');
-        abort_if($appointment->status == 'CANCELLED', 404, 'Appointment has been cancelled');
-        abort_if($appointment->status == 'COMPLETED', 404, 'Appointment has been completed'); 
-        abort_if($appointment->status == 'ABANDONED', 404, 'Appointment has been abandoned');
-       
+        abort_if($appointment->status == 'COMPLETED', 404, 'Appointment has been completed');
+
        return view('app.guest.appointment-confirmation', compact('appointment'));
     }
 
@@ -70,22 +68,18 @@ class GuestController extends Controller
         $appointment = Appointment::where('uid', $appointmentUid)->first();
         abort_if(!count($appointment->confirmationRequests), 404, 'No confirmation requests on this appointment.');
         abort_if(!$appointment, 404, 'Invalid url');
-        abort_if($appointment->status == 'CANCELLED', 404, 'Appointment has been cancelled');
-        abort_if($appointment->status == 'COMPLETED', 404, 'Appointment has been completed'); 
-        abort_if($appointment->status == 'ABANDONED', 404, 'Appointment has been abandoned');
+        abort_if($appointment->status == 'COMPLETED', 404, 'Appointment has been completed');
 
         $decision = $request->get('decision');
         $memo = $request->get('memo');
         $response = null;
         $data = [
             'uid' => $appointment->uid,
-            'memo' => $memo
+            'memo' => $memo,
+            'confirmationDecisionEnum' => ($decision == 'REJECT' ? 'CANCELLED' : 'CONFIRMED')
         ];
 
-        $url = '/appointment/confirmationDecisionAccept';
-        if($decision == 'REJECT'){
-            $url = '/appointment/confirmationDecisionReject';
-        }
+        $url = '/appointment/putConfirmationDecision';
 
         $response = $this->calljava($request, $url, $data);
 

+ 370 - 59
app/Http/Controllers/HomeController.php

@@ -188,49 +188,371 @@ class HomeController extends Controller
         }
     }
 
-    public function dashboard(Request $request)
-    {
+    private function dashboard_MCP(Request $request){
+
+
+        $keyNumbers = [];
+
+        // Patients // SELECT * FROM client WHERE mcp_pro_id = :me.id;
+        // New Patients Awaiting Visit // SELECT * FROM client WHERE mcp_pro_id = :me.id AND hasMcpDoneOnboardingVisit != 'YES';
+        // Notes Pending Signature // SELECT * FROM note WHERE hcp_pro_id = :me.id AND is_cancelled IS NOT TRUE AND has_hcp_signed IS NOT TRUE;
+        // Notes Pending Billing // SELECT * FROM note WHERE hcp_pro_id = :me.id AND is_cancelled IS NOT TRUE AND has_hcp_signed IS TRUE AND is_billing_marked_done IS FALSE;
+        // Reports Pending Signature // SELECT * FROM incoming_report WHERE hcp_pro_id = :me.id AND isEntryError IS NOT TRUE AND hasHcpProSigned IS NOT TRUE;
+        // Patients w/o Appointments // SELECT * FROM client WHERE mcp_pro_id = :me.id AND client.next_mcp_appointment_date < today();
+        // Patients Overdue for Visit // SELECT * FROM client WHERE mcp_pro_id = :me.id AND client.next_expected_mcp_visit_date < today();
+        // Cancelled Appts. Pending Review // SELECT * FROM appointment WHERE hcp_pro_id = :me.id AND status = 'REJECTED' AND wasAcknowledgedByAppointmentPro IS NOT TRUE;
+        // Cancelled Bills Pending Review // SELECT * FROM bill WHERE bill_service_type = 'NOTE' AND is_cancelled IS TRUE AND isCancellationAcknowledged IS FALSE;
+        // Cancelled Supply Orders Pending Review // SELECT * FROM supply_order WHERE signed_by_pro_id = :me.id AND is_cancelled IS TRUE AND isCancellationAcknowledged IS NOT TRUE;
+        // ERx & Orders Pending Signature // SELECT * FROM erx WHERE hcp_pro_id = :me.id AND pro_declared_status <> 'CANCELLED' AND hasHcpProSigned IS NOT TRUE;
+        // Supply Orders Pending Signature // SELECT supply_order.id FROM supply_order WHERE signed_by_pro_id IS NOT TRUE AND is_cancelled IS NOT TRUE AND created_by_pro_id = :me.id;
 
-        //patients where performer is the mcp
         $performer = $this->performer();
+        $pro = $performer->pro;
         $performerProID = $performer->pro->id;
-        $isAdmin = ($performer->pro->pro_type === 'ADMIN');
 
         $keyNumbers  = [];
 
         $queryClients = $this->performer()->pro->getAccessibleClientsQuery();
 
-        $keyNumbers['totalPatients'] = $queryClients->count();
+        $pendingNotesToSign = Note
+            ::where(function ($query) use ($performerProID) {
+                $query->where('hcp_pro_id', $performerProID)->where('is_signed_by_hcp', false)->where('is_cancelled', false);
+            })
+            ->orWhere(function ($query) use ($performerProID) {
+                $query->where('ally_pro_id', $performerProID)->where('is_signed_by_ally', false)->where('is_cancelled', false);
+            })
+            ->count();
+        $keyNumbers['pendingNotesToSign'] = $pendingNotesToSign;
 
-        // patientNotSeenYet
-        $patientNotSeenYet = $queryClients
-            ->where(function ($query) use ($performer) {     // own patient and primary OB visit pending
-                $query->where('mcp_pro_id', $performer->pro->id)
-                    ->where('has_mcp_done_onboarding_visit', '!=', 'YES');
+        // notes pending mcp sign (applicable to dnas only)
+        $pendingNotesToSignMCP = Note
+            ::where(function ($query) use ($performerProID) {
+                $query->where('ally_pro_id', $performerProID)->where('is_signed_by_hcp', false)->where('is_cancelled', false);
             })
-//            ->orWhere(function ($query) {   // mcp of any client program and program OB pending
-//                $query->where(function ($_query) {
-//                    $_query->select(DB::raw('COUNT(id)'))
-//                        ->from('client_program')
-//                        ->whereColumn('client_id', 'client.id')
-//                        ->where('has_mcp_done_onboarding_visit', '!=', 'YES');
-//                }, '>=', 1);
-//            })
             ->count();
-        $keyNumbers['patientsNotSeenYet'] = $patientNotSeenYet;
+        $keyNumbers['$pendingNotesToSignMCP'] = $pendingNotesToSignMCP;
 
-        $pendingBillsToSign = Bill::where('bill_service_type', '<>', 'CARE_MONTH')->where(function ($query) use ($performerProID) {
-            $query->where('hcp_pro_id', $performerProID)->where('is_signed_by_hcp', false)->where('is_cancelled', false);
-        })
-            ->orWhere(function ($query) use ($performerProID) {
-                $query->where('cm_pro_id', $performerProID)->where('is_signed_by_cm', false)->where('is_cancelled', false);;
-            })->orWhere(function ($query) use ($performerProID) {
-                $query->where('rme_pro_id', $performerProID)->where('is_signed_by_rme', false)->where('is_cancelled', false);;
-            })->orWhere(function ($query) use ($performerProID) {
-                $query->where('rmm_pro_id', $performerProID)->where('is_signed_by_rmm', false)->where('is_cancelled', false);;
-            })->count();
+        $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);
+        })->whereDoesntHave('bills')->count();
+
+        $keyNumbers['signedNotesWithoutBills'] = $signedNotesWithoutBills;
+
+        // open tickets
+        $keyNumbers['numOpenTickets'] = Ticket::where('is_open', true)
+            ->where(function ($q) use ($performerProID) {
+                $q->where('assigned_pro_id', $performerProID)
+                    ->orWhere('manager_pro_id', $performerProID)
+                    ->orWhere('ordering_pro_id', $performerProID)
+                    ->orWhere('initiating_pro_id', $performerProID);
+            })
+            ->count();
+
+        // unacknowledged cancelled bills for authed pro
+        $keyNumbers['unacknowledgedCancelledBills'] = Bill::where('hcp_pro_id', $performerProID)
+            ->where('is_cancelled', true)
+            ->where('is_cancellation_acknowledged', false)
+            ->count();
+
+        // unacknowledged cancelled supply orders for authed pro
+        $keyNumbers['unacknowledgedCancelledSupplyOrders'] = SupplyOrder::where('signed_by_pro_id', $performerProID)
+            ->where('is_cancelled', true)
+            ->where('is_cancellation_acknowledged', false)
+            ->count();
+
+        // unsigned supply orders created by authed pro
+        $keyNumbers['unsignedSupplyOrders'] = SupplyOrder
+            ::where('is_cancelled', false)
+            ->where('is_signed_by_pro', false)
+            ->whereRaw('created_by_session_id IN (SELECT id FROM app_session WHERE pro_id = ?)', [$performerProID])
+            ->count();
+
+        // patientsHavingBirthdayToday
+        $queryClients = $this->performer()->pro->getAccessibleClientsQuery();
+        $keyNumbers['patientsHavingBirthdayToday'] = $queryClients
+            ->whereRaw('EXTRACT(DAY from dob) = ?', [date('d')])
+            ->whereRaw('EXTRACT(MONTH from dob) = ?', [date('m')])
+            ->count();
+
+        $reimbursement = [];
+        $reimbursement["currentBalance"] =  $performer->pro->balance;
+        $reimbursement["nextPaymentDate"] = '--';
+        $lastPayment = ProTransaction::where('pro_id', $performerProID)->where('plus_or_minus', 'PLUS')->orderBy('created_at', 'DESC')->first();
+        if ($lastPayment) {
+            $reimbursement["lastPayment"] =  $lastPayment->amount;
+            $reimbursement["lastPaymentDate"] = $lastPayment->created_at;
+        } else {
+            $reimbursement["lastPayment"] = '--';
+            $reimbursement["lastPaymentDate"] = '--';
+        }
+
+        //if today is < 15th, next payment is 15th, else nextPayment is
+        $today = strtotime(date('Y-m-d'));
+        $todayDate = date('j', $today);
+
+        $todayMonth =  date('m', $today);
+        $todayYear = date('Y', $today);
+        if ($todayDate < 15) {
+            $nextPaymentDate = new DateTime();
+            $nextPaymentDate->setDate($todayYear, $todayMonth, 15);
+            $reimbursement['nextPaymentDate'] = $nextPaymentDate->format('m/d/Y');
+        } else {
+            $nextPaymentDate = new \DateTime();
+            $lastDayOfMonth = date('t', $today);
+            $nextPaymentDate->setDate($todayYear, $todayMonth, $lastDayOfMonth);
+            $reimbursement['nextPaymentDate'] = $nextPaymentDate->format('m/d/Y');
+        }
+
+        //expectedPay
+        $expectedForHcp = DB::select(DB::raw("SELECT coalesce(SUM(hcp_expected_payment_amount),0) as expected_pay FROM bill WHERE hcp_pro_id = :performerProID  AND has_hcp_been_paid = false AND is_signed_by_hcp IS TRUE AND is_cancelled = false"), ['performerProID' => $performerProID])[0]->expected_pay;
+        $expectedForCm = DB::select(DB::raw("SELECT coalesce(SUM(cm_expected_payment_amount),0) as expected_pay  FROM bill WHERE cm_pro_id = :performerProID  AND has_cm_been_paid = false AND is_signed_by_cm IS TRUE AND is_cancelled = false"), ['performerProID' => $performerProID])[0]->expected_pay;
+        $expectedForRme = DB::select(DB::raw("SELECT coalesce(SUM(rme_expected_payment_amount),0) as expected_pay  FROM bill WHERE rme_pro_id = :performerProID  AND has_rme_been_paid = false AND is_signed_by_rme IS TRUE AND is_cancelled = false"), ['performerProID' => $performerProID])[0]->expected_pay;
+        $expectedForRmm = DB::select(DB::raw("SELECT coalesce(SUM(rmm_expected_payment_amount),0) as expected_pay  FROM bill WHERE rmm_pro_id = :performerProID  AND has_rmm_been_paid = false AND is_signed_by_rmm IS TRUE AND is_cancelled = false"), ['performerProID' => $performerProID])[0]->expected_pay;
+        $expectedForNa = DB::select(DB::raw("SELECT coalesce(SUM(generic_pro_expected_payment_amount),0) as expected_pay  FROM bill WHERE generic_pro_id = :performerProID  AND has_generic_pro_been_paid = false AND is_signed_by_generic_pro IS TRUE AND is_cancelled = false"), ['performerProID' => $performerProID])[0]->expected_pay;
+
+        $totalExpectedAmount =  $expectedForHcp + $expectedForCm + $expectedForRme + $expectedForRmm + $expectedForNa;
+        $reimbursement['nextPaymentAmount'] =  $totalExpectedAmount;
+
+        $milliseconds = strtotime(date('Y-m-d')) . '000';
+
+        // bills & claims
+        $businessNumbers = [];
+
+        // Notes with bills to resolve
+        $businessNumbers['notesWithBillsToResolve'] = Note::where('is_cancelled', '!=', true)
+            ->where('is_bill_closed', '!=', true)
+            ->whereRaw('(SELECT count(id) FROM bill WHERE note_id = note.id AND is_cancelled = false AND is_verified = false) > 0')
+            ->count();
+
+        // Notes pending bill closure
+        $businessNumbers['notesPendingBillingClosure'] = Note::where('is_cancelled', '!=', true)
+            ->where('is_bill_closed', '!=', true)
+            ->whereRaw('(SELECT count(id) FROM bill WHERE note_id = note.id AND (is_cancelled = true OR is_verified = true)) = 0')
+            ->count();
+
+        // incoming reports not signed
+        $incomingReports = IncomingReport::where('hcp_pro_id', $performerProID)
+            ->where('has_hcp_pro_signed', false)
+            ->where('is_entry_error', false)
+            ->orderBy('created_at', 'ASC')
+            ->get();
+        // erx, labs & imaging that are not closed
+        $tickets = Ticket::where('ordering_pro_id', $performerProID)
+            ->where('is_entry_error', false)
+            ->where('is_open', true)
+            ->orderBy('created_at', 'ASC')
+            ->get();
+        $supplyOrders = SupplyOrder::where('is_cleared_for_shipment', false)
+            ->where('is_cancelled', false)
+            ->whereRaw('created_by_session_id IN (SELECT id FROM app_session where pro_id = ?)', [$performer->pro->id])
+            ->orderBy('created_at', 'ASC')
+            ->get();
+
+        $numERx = Ticket::where('ordering_pro_id', $performerProID)
+            ->where('category', 'erx')
+            ->where('is_entry_error', false)
+            ->where('is_open', true)
+            ->count();
+        $numLabs = Ticket::where('ordering_pro_id', $performerProID)
+            ->where('category', 'lab')
+            ->where('is_entry_error', false)
+            ->where('is_open', true)
+            ->count();
+        $numImaging = Ticket::where('ordering_pro_id', $performerProID)
+            ->where('category', 'imaging')
+            ->where('is_entry_error', false)
+            ->where('is_open', true)
+            ->count();
+        $numSupplyOrders = SupplyOrder::where('is_cleared_for_shipment', false)
+            ->where('is_cancelled', false)
+            ->whereRaw('created_by_session_id IN (SELECT id FROM app_session where pro_id = ?)', [$performer->pro->id])
+            ->count();
+
+        $newMCPAssociations = ClientProChange
+            ::where('new_pro_id', $performerProID)
+            ->where('responsibility_type', 'MCP')
+            ->whereNull('current_client_pro_change_decision_id')
+            ->get();
+
+        $newNAAssociations = ClientProChange
+            ::where('new_pro_id', $performerProID)
+            ->where('responsibility_type', 'DEFAULT_NA')
+            ->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
+            ")
+        );
+
+        $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_anyone_interacted_with_client_about_rm_outside_note = TRUE AND care_month.has_anyone_interacted_with_client_about_rm_outside_note 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_anyone_interacted_with_client_about_rm_outside_note = FALSE OR care_month.has_anyone_interacted_with_client_about_rm_outside_note IS NULL)
+"
+            )
+        );
+        $keyNumbers['rmPatientsWithWhomCommNotDone'] = $count[0]->cnt;
 
-        $keyNumbers['pendingBillsToSign'] = $pendingBillsToSign;
+        // num measurements that need stamping
+        $keyNumbers['measurementsToBeStamped'] = $this->performer()->pro->getUnstampedMeasurementsFromCurrentMonth(true, null, null);
+
+        if($performer->pro->pro_type === 'ADMIN') {
+
+            // patients without coverage information
+            $keyNumbers['patientsWithoutCoverageInformation'] = DB::select(DB::raw("
+SELECT count(DISTINCT (cl.id)) as cnt
+FROM client cl
+WHERE cl.shadow_pro_id IS NULL AND cl.latest_client_primary_coverage_id IS NULL -- no coverage record"
+            ))[0]->cnt;
+
+            // patients pending coverage verification
+            $keyNumbers['patientsPendingCoverageVerification'] = DB::select(DB::raw("
+SELECT count(DISTINCT (cl.id)) as cnt
+FROM client cl
+         LEFT JOIN client_primary_coverage cpc ON cl.latest_client_primary_coverage_id = cpc.id
+WHERE cl.shadow_pro_id IS NULL
+    AND (cl.latest_client_primary_coverage_id IS NOT NULL -- coverage exists, but status is null or unknown
+    AND (
+               (cpc.plan_type = 'MEDICARE' AND (cpc.is_partbprimary = 'UNKNOWN' OR cpc.is_partbprimary IS NULL))
+               OR
+               (cpc.plan_type != 'MEDICARE' AND
+                (cpc.manual_determination_category = 'UNKNOWN' OR cpc.manual_determination_category IS NULL))
+           ))"
+            ))[0]->cnt;
+
+        }
+
+        return view('app/dashboard-mcp', compact('keyNumbers', 'reimbursement', 'milliseconds',
+            'businessNumbers',
+            'incomingReports', 'tickets', 'supplyOrders',
+            'numERx', 'numLabs', 'numImaging', 'numSupplyOrders',
+            'newMCPAssociations', 'newNAAssociations',
+            'mcpClientMemos', 'naClientMemos'));
+    }
+
+    private function dashboard_DNA(Request $request){
+        $performer = $this->performer();
+        $pro = $performer->pro;
+    }
+
+    private function dashboard_ADMIN(Request $request){
+        $keyNumbers = [];
+
+        // Patients // SELECT * FROM client WHERE mcp_pro_id = :me.id;
+        // New Patients Awaiting Visit // SELECT * FROM client WHERE mcp_pro_id = :me.id AND hasMcpDoneOnboardingVisit != 'YES';
+        // Notes Pending Signature // SELECT * FROM note WHERE hcp_pro_id = :me.id AND is_cancelled IS NOT TRUE AND has_hcp_signed IS NOT TRUE;
+        // Notes Pending Billing // SELECT * FROM note WHERE hcp_pro_id = :me.id AND is_cancelled IS NOT TRUE AND has_hcp_signed IS TRUE AND is_billing_marked_done IS FALSE;
+        // Reports Pending Signature // SELECT * FROM incoming_report WHERE hcp_pro_id = :me.id AND isEntryError IS NOT TRUE AND hasHcpProSigned IS NOT TRUE;
+        // Patients w/o Appointments // SELECT * FROM client WHERE mcp_pro_id = :me.id AND client.next_mcp_appointment_date < today();
+        // Patients Overdue for Visit // SELECT * FROM client WHERE mcp_pro_id = :me.id AND client.next_expected_mcp_visit_date < today();
+        // Cancelled Appts. Pending Review // SELECT * FROM appointment WHERE hcp_pro_id = :me.id AND status = 'REJECTED' AND wasAcknowledgedByAppointmentPro IS NOT TRUE;
+        // Cancelled Bills Pending Review // SELECT * FROM bill WHERE bill_service_type = 'NOTE' AND is_cancelled IS TRUE AND isCancellationAcknowledged IS FALSE;
+        // Cancelled Supply Orders Pending Review // SELECT * FROM supply_order WHERE signed_by_pro_id = :me.id AND is_cancelled IS TRUE AND isCancellationAcknowledged IS NOT TRUE;
+        // ERx & Orders Pending Signature // SELECT * FROM erx WHERE hcp_pro_id = :me.id AND pro_declared_status <> 'CANCELLED' AND hasHcpProSigned IS NOT TRUE;
+        // Supply Orders Pending Signature // SELECT supply_order.id FROM supply_order WHERE signed_by_pro_id IS NOT TRUE AND is_cancelled IS NOT TRUE AND created_by_pro_id = :me.id;
+
+        $performer = $this->performer();
+        $pro = $performer->pro;
+        $performerProID = $performer->pro->id;
+
+        $keyNumbers  = [];
+
+        $queryClients = $this->performer()->pro->getAccessibleClientsQuery();
 
         $pendingNotesToSign = Note
             ::where(function ($query) use ($performerProID) {
@@ -464,32 +786,6 @@ ORDER BY cm.created_at DESC
             ")
         );
 
-        $naBillableSignedNotes = DB::select(DB::raw("
-SELECT count(note.id) as na_billable_notes
-FROM note
-WHERE
-        note.is_signed_by_hcp = TRUE AND
-        note.ally_pro_id = :pro_id AND
-        note.is_cancelled = FALSE AND
-        (
-            SELECT count(bill.id)
-            FROM bill
-            WHERE
-                  bill.is_cancelled = FALSE AND
-                  bill.generic_pro_id = :pro_id AND
-                  bill.note_id = note.id
-        ) = 0
-        "), ["pro_id" => $performerProID]);
-
-        if(!$naBillableSignedNotes || !count($naBillableSignedNotes)) {
-            $naBillableSignedNotes = 0;
-        }
-        else {
-            $naBillableSignedNotes = $naBillableSignedNotes[0]->na_billable_notes;
-        }
-
-        $keyNumbers['naBillableSignedNotes'] = $naBillableSignedNotes;
-
         $keyNumbers['rmBillsToSign'] = Bill
             ::where('is_cancelled', false)
             ->where('cm_or_rm', 'RM')
@@ -583,7 +879,7 @@ WHERE cl.shadow_pro_id IS NULL AND cl.latest_client_primary_coverage_id IS NULL
 SELECT count(DISTINCT (cl.id)) as cnt
 FROM client cl
          LEFT JOIN client_primary_coverage cpc ON cl.latest_client_primary_coverage_id = cpc.id
-WHERE cl.shadow_pro_id IS NULL 
+WHERE cl.shadow_pro_id IS NULL
     AND (cl.latest_client_primary_coverage_id IS NOT NULL -- coverage exists, but status is null or unknown
     AND (
                (cpc.plan_type = 'MEDICARE' AND (cpc.is_partbprimary = 'UNKNOWN' OR cpc.is_partbprimary IS NULL))
@@ -595,7 +891,7 @@ WHERE cl.shadow_pro_id IS NULL
 
         }
 
-        return view('app/dashboard', compact('keyNumbers', 'reimbursement', 'milliseconds',
+        return view('app/dashboard-admin', compact('keyNumbers', 'reimbursement', 'milliseconds',
             'businessNumbers',
             'incomingReports', 'tickets', 'supplyOrders',
             'numERx', 'numLabs', 'numImaging', 'numSupplyOrders',
@@ -604,6 +900,19 @@ WHERE cl.shadow_pro_id IS NULL
             'proApptUpdates', 'naApptUpdates'));
     }
 
+    public function dashboard(Request $request)
+    {
+        $performer = $this->performer();
+        $pro = $performer->pro;
+        if($pro->is_enrolled_as_mcp){
+            return $this->dashboard_MCP($request);
+        }elseif($pro->pro_type === 'ADMIN'){
+            return $this->dashboard_ADMIN($request);
+        }else{
+            return $this->dashboard_DNA($request);
+        }
+    }
+
     public function dashboardMeasurementsTab(Request $request, $page = 1) {
 
         $performer = $this->performer();
@@ -620,7 +929,7 @@ WHERE cl.shadow_pro_id IS NULL
             OR client.rme_pro_id = {$performer->pro->id}
             OR client.physician_pro_id = {$performer->pro->id}
             OR client.id in (SELECT client_id FROM client_pro_access WHERE is_active AND pro_id = {$performer->pro->id})
-            OR client.id in (SELECT client_id FROM appointment WHERE status NOT IN ('CANCELLED', 'ABANDONED') AND pro_id = {$performer->pro->id})
+            OR client.id in (SELECT client_id FROM appointment WHERE status NOT IN ('CANCELLED') AND pro_id = {$performer->pro->id})
         )";
 
         $numMeasurements = DB::select(
@@ -755,6 +1064,8 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
                 $appointment->client->age_in_years . ' y.o' .
                 ($appointment->client->sex ? ' ' . $appointment->client->sex : '') .
                 ')';
+            $appointment->clientAge = $appointment->client->age_in_years;
+            $appointment->clientSex = $appointment->client->sex;
 
             $appointment->started = false;
             $appointment->inHowManyHours = date_diff(date_create('now'), date_create($appointment->start_time), false)

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

@@ -0,0 +1,269 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\Models\Appointment;
+use App\Models\BDTDevice;
+use App\Models\CareMonth;
+use App\Models\Client;
+use App\Models\ClientBDTDevice;
+use App\Models\ClientInfoLine;
+use App\Models\Erx;
+use App\Models\Facility;
+use App\Models\Handout;
+use App\Models\IncomingReport;
+use App\Models\MBClaim;
+use App\Models\MBPayer;
+use App\Models\Note;
+use App\Models\NoteTemplate;
+use App\Models\Pro;
+use App\Models\Product;
+use App\Models\ProProAccess;
+use App\Models\SectionTemplate;
+use App\Models\Shipment;
+use App\Models\SupplyOrder;
+use App\Models\Ticket;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\File;
+use App\Models\Bill;
+use App\Models\ClientSMS;
+
+use Illuminate\Support\Facades\Http;
+use PDF;
+
+class McpController extends Controller
+{
+
+    public function patients(Request $request)
+    {
+        $filters = $request->all();
+        $patients = Client::whereNull('shadow_pro_id')->where('mcp_pro_id', $this->performer->pro->id);
+
+        // filters
+        /*
+        array:18 [▼
+          "age_category" => "LESS_THAN"
+          "age_value_1" => "34"
+          "age_value_2" => null
+          "sex" => "M"
+          "bmi_category" => "BETWEEN"
+          "bmi_value_1" => "20"
+          "bmi_value_2" => "25"
+          "last_visit_category" => "LESS_THAN"
+          "last_visit_value_1" => "2021-10-14"
+          "last_visit_value_2" => null
+          "next_appointment_category" => "LESS_THAN"
+          "next_appointment_value_1" => "2021-10-15"
+          "status" => "ACTIVE"
+          "last_weighed_in_category" => "EXACTLY"
+          "last_weighed_in_value_1" => "2021-10-07"
+          "last_bp_category" => "BETWEEN"
+          "last_bp_value_1" => "2021-10-01"
+          "last_bp_value_2" => "2021-10-31"
+        ]
+        */
+
+        $this->filterMultiQuery($request, $patients, 'age_in_years', 'age_category', 'age_value_1', 'age_value_2');
+        $this->filterSimpleQuery($request, $patients, 'sex', 'sex');
+        $this->filterMultiQuery($request, $patients, 'usual_bmi', 'bmi_category', 'bmi_value_1', 'bmi_value_2');
+        $this->filterMultiQuery($request, $patients, 'most_recent_weight_at', 'last_weighed_in_category', 'last_weighed_in_value_1', 'last_weighed_in_value_2');
+        $this->filterMultiQuery($request, $patients, 'most_recent_bp_at', 'last_bp_category', 'last_bp_value_1', 'last_bp_value_2');
+
+        switch($request->input('status')) {
+            case 'ACTIVE':
+                $patients->where('is_active', true)->where('has_mcp_done_onboarding_visit', true);
+                break;
+            case 'AWAITING_VISIT':
+                $patients->where('is_active', true)->where('has_mcp_done_onboarding_visit', false);
+                break;
+            case 'INACTIVE':
+                $patients->where('is_active', '<>', true);
+                break;
+        }
+
+        $patients = $patients->orderBy('created_at', 'DESC')->paginate(20);
+        return view('app.mcp.patients', compact('patients', 'filters'));
+    }
+
+    private function filterSimpleQuery(Request $request, $query, $columnName, $valueName) {
+        if($request->input($valueName)) {
+            $query->where($columnName, $request->input($valueName));
+        }
+    }
+    private function filterMultiQuery(Request $request, $query, $columnName, $keyName, $valueName1, $valueName2) {
+        switch($request->input($keyName)) {
+            case 'EXACTLY':
+                if($request->input($valueName1)) {
+                    $query->where($columnName, $request->input($valueName1));
+                }
+                break;
+            case 'LESS_THAN':
+                if($request->input($valueName1)) {
+                    $query->where($columnName, '<', $request->input($valueName1));
+                }
+                break;
+            case 'GREATER_THAN':
+                if($request->input($valueName1)) {
+                    $query->where($columnName, '>', $request->input($valueName1));
+                }
+                break;
+            case 'BETWEEN':
+                if($request->input($valueName1) && $request->input($valueName2)) {
+                    $query
+                        ->where($columnName, '>=', $request->input($valueName1))
+                        ->where($columnName, '<=', $request->input($valueName2));
+                }
+                break;
+            case 'NOT_BETWEEN':
+                if($request->input($valueName1) && $request->input($valueName2)) {
+                    $query
+                        ->where(function ($q) use ($request, $columnName, $valueName1, $valueName2) {
+                            $q->where($columnName, '<', $request->input($valueName1))
+                                ->orWhere($columnName, '>', $request->input($valueName2));
+                        });
+                }
+                break;
+        }
+    }
+
+    public function notes(Request $request)
+    {
+        $notes = Note::paginate(5);
+
+        // SELECT * FROM note WHERE client_id IN (SELECT id FROM client WHERE mcp_pro_id = :me.id);
+
+        return view('app.mcp.notes', compact('notes'));
+    }
+
+    public function appointments(Request $request)
+    {
+        $appointments = Appointment::paginate(5);
+        return view('app.mcp.appointments', compact('appointments'));
+    }
+
+    public function bills(Request $request)
+    {
+        $bills = Bill::paginate(5);
+        return view('app.mcp.bills', compact('bills'));
+    }
+
+    public function erx_and_orders(Request $request)
+    {
+        $erxAndOrders = Erx::paginate(5);
+        return view('app.mcp.erx_and_orders', compact('erxAndOrders'));
+    }
+
+    public function reports(Request $request)
+    {
+        $data = [];
+        return view('app.mcp.reports', $data);
+    }
+
+    public function supply_orders(Request $request)
+    {
+        $supplyOrders = SupplyOrder::paginate(5);
+        return view('app.mcp.supply_orders', compact('supplyOrders'));
+    }
+
+    public function client_messages(Request $request)
+    {
+        $clientMessages = ClientSMS::paginate(5);
+        return view('app.mcp.client_messages', compact('clientMessages'));
+    }
+
+    public function new_patients_awaiting_visit(Request $request){
+        $data = [
+            'records' => Client::where('mcp_pro_id', $this->performer->pro->id)
+                ->where('has_mcp_done_onboarding_visit', '!=', 'YES')
+                ->orderBy('created_at')
+                ->get()
+        ];
+        return view('app.mcp.new_patients_awaiting_visit', $data);
+    }
+    public function notes_pending_signature(Request $request){
+        $data = [
+            'records' => Note::where('hcp_pro_id', $this->performer->pro->id)
+                ->where('is_cancelled', '<>', true)
+                ->where('is_signed_by_hcp', '<>', true)
+                ->orderBy('created_at')
+                ->get()
+        ];
+        return view('app.mcp.notes_pending_signature', $data);
+    }
+    public function notes_pending_billing(Request $request){
+        $data = [
+            'records' => Note::where('hcp_pro_id', $this->performer->pro->id)
+                ->where('is_cancelled', '<>', true)
+                ->where('is_signed_by_hcp', true)
+                ->where('is_billing_marked_done', '<>', true)
+                ->orderBy('created_at')
+                ->get()
+        ];
+        return view('app.mcp.notes_pending_billing', $data);
+    }
+    public function reports_pending_signature(Request $request){
+        $data = [
+            'records' => IncomingReport::where('hcp_pro_id', $this->performer->pro->id)
+                ->where('has_hcp_pro_signed', '<>', true)
+                ->where('is_entry_error', '<>', true)
+                ->orderBy('created_at')
+                ->get()
+        ];
+        return view('app.mcp.reports_pending_signature', $data);
+    }
+    public function patients_without_appointments(Request $request){
+        $patients = $this->performer->pro->get_patients_without_appointment_query()->paginate(20);
+        return view('app.mcp.patients_without_appointments', compact('patients'));
+    }
+    public function patients_overdue_for_visit(Request $request){
+        $patients = $this->performer->pro->get_patients_overdue_for_visit_query()->paginate(20);
+        return view('app.mcp.patients_overdue_for_visit', compact('patients'));
+    }
+    public function cancelled_appointments_pending_review(Request $request){
+        $data = [];
+        return view('app.mcp.cancelled_appointments_pending_review', $data);
+    }
+    public function cancelled_bills_pending_review(Request $request){
+        $data = [
+            'records' => Bill::where('hcp_pro_id', $this->performer->pro->id)
+                ->where('bill_service_type', 'NOTE')
+                ->where('is_cancelled', true)
+                ->where('is_cancellation_acknowledged', '<>', true)
+                ->orderBy('created_at')
+                ->get()
+        ];
+        return view('app.mcp.cancelled_bills_pending_review', $data);
+    }
+    public function cancelled_supply_orders_pending_review(Request $request){
+        $data = [
+            'records' => SupplyOrder::where('signed_by_pro_id', $this->performer->pro->id)
+                ->where('is_cancelled', true)
+                ->where('is_cancellation_acknowledged', '<>', true)
+                ->orderBy('created_at')
+                ->get()
+        ];
+        return view('app.mcp.cancelled_supply_orders_pending_review', $data);
+    }
+    public function erx_and_orders_pending_signature(Request $request){
+        $data = [
+            'records' => Erx::where('hcp_pro_id', $this->performer->pro->id)
+                ->where('pro_declared_status', '<>', 'CANCELLED')
+                ->where('has_hcp_pro_signed', '<>', true)
+                ->orderBy('created_at')
+                ->get()
+        ];
+        return view('app.mcp.erx_and_orders_pending_signature', $data);
+    }
+    public function supply_orders_pending_signature(Request $request){
+        $data = [
+            'records' => SupplyOrder::where('created_by_pro_id', $this->performer->pro->id)
+                ->whereNull('signed_by_pro_id')
+                ->where('is_cancelled', '<>', true)
+                ->orderBy('created_at')
+                ->get()
+        ];
+        return view('app.mcp.supply_orders_pending_signature', $data);
+    }
+
+}

+ 60 - 4
app/Models/Client.php

@@ -45,6 +45,11 @@ class Client extends Model
         return $this->hasOne(Pro::class, 'id', 'mcp_pro_id');
     }
 
+    public function rd()
+    {
+        return $this->hasOne(Pro::class, 'id', 'rd_pro_id');
+    }
+
     public function pcp()
     {
         return $this->hasOne(Pro::class, 'id', 'physician_pro_id');
@@ -285,6 +290,29 @@ class Client extends Model
         return false;
     }
 
+    public function lastMcpAppointment()
+    {
+        if ($this->mcp) {
+            return Appointment::where('client_id', $this->id)
+                ->where('pro_id', $this->mcp->id)
+                ->where('start_time', '<', date('Y-m-d'))
+                ->orderBy('start_time', 'asc')
+                ->first();
+        }
+        return false;
+    }
+
+    public function lastMeasurementOfType($_type) {
+        return Measurement::where('client_id', $this->id)
+            ->whereNotNull('bdt_measurement_id')
+            ->whereNotNull('ts')
+            ->where('is_cellular_zero', false)
+            ->where('is_removed', false)
+            ->where('label', '=', $_type)
+            ->orderBy('ts', 'desc')
+            ->first();
+    }
+
     public function appointments()
     {
         return $this->hasMany(Appointment::class, 'client_id', 'id')
@@ -309,7 +337,7 @@ class Client extends Model
     {
         return $this->hasMany(Appointment::class, 'client_id', 'id')
             ->where('raw_date', '>=', date('Y-m-d'))
-            ->whereIn('status', ['CREATED', 'CONFIRMED'])
+            ->whereIn('status', ['PENDING', 'CONFIRMED'])
             ->orderBy('start_time', 'desc')
             ->limit(5);
     }
@@ -318,7 +346,7 @@ class Client extends Model
         return Appointment
             ::where('client_id', $this->id)
             ->where('raw_date', '>=', DB::raw('NOW()'))
-            ->whereIn('status', ['CONFIRMED', 'CREATED'])
+            ->whereIn('status', ['PENDING', 'CONFIRMED'])
             ->orderBy('start_time')
             ->first();
     }
@@ -326,11 +354,10 @@ class Client extends Model
     public function appointmentsFromLastWeek()
     {
 
-        $dateLastWeek = date_sub(date_create(), date_interval_create_from_date_string("7 days"));
+        $dateLastWeek = date_sub(date_create(), date_interval_create_from_date_string("14 days"));
         $dateLastWeek = date_format($dateLastWeek, "Y-m-d");
         return $this->hasMany(Appointment::class, 'client_id', 'id')
             ->where('raw_date', '>=', $dateLastWeek)
-            ->whereIn('status', ['CREATED', 'CONFIRMED'])
             ->orderBy('start_time', 'desc');
     }
 
@@ -690,6 +717,23 @@ class Client extends Model
         return $this->hasOne(ProTeam::class, 'id', 'system_source_pro_team_id');
     }
 
+    public function adminEngagementAssessmentStatus(){
+        return $this->hasOne(Status::class, 'id', 'admin_engagement_assessment_status_id');
+    }
+
+    public function mcpEngagementAssessmentStatus(){
+        return $this->hasOne(Status::class, 'id', 'mcp_engagement_assessment_status_id');
+    }
+
+    public function defaultNaEngagementAssessmentStatus(){
+        return $this->hasOne(Status::class, 'id', 'default_na_engagement_assessment_status_id');
+    }
+
+    public function clientSelfSatisfactionStatus(){
+        return $this->hasOne(Status::class, 'id', 'client_self_satisfaction_status_id');
+    }
+
+
     public function recentNotes($_pro = null) {
         $notes = Note::where('client_id', $this->id)->where('is_cancelled', false);
         if($_pro) {
@@ -777,4 +821,16 @@ ORDER BY m.ts DESC
         if(!$coverage) return 'NO';
         return $coverage->getStatus();
     }
+
+    public function getMcpAssignedOn() {
+        $change = ClientProChange::where('client_id', $this->id)
+            ->where('new_pro_id', $this->mcp_pro_id)
+            ->where('responsibility_type', 'MCP')
+            ->orderBy('created_at', 'DESC')
+            ->first();
+        if(!!$change) {
+            return friendlier_date($change->created_at);
+        }
+        return '-';
+    }
 }

+ 12 - 0
app/Models/Note.php

@@ -44,6 +44,18 @@ class Note extends Model
             ->where('status', '<>', 'CANCELLED');
     }
 
+    // Signed/Billed/Verified/Processed/Cancelled
+    public function overallStatus()
+    {
+        $status = 'New';
+        if ($this->is_cancelled) $status = 'Cancelled';
+        else {
+            if ($this->is_billing_marked_done) $status = 'Billed';
+            else if ($this->is_signed_by_hcp) $status = 'Signed';
+        }
+        return $status . ' **';
+    }
+
     public function bills()
     {
         return $this->hasMany(Bill::class, 'note_id', 'id')

+ 201 - 3
app/Models/Pro.php

@@ -59,7 +59,6 @@ class Pro extends Model
         $numTeams = ProTeam::where('assistant_pro_id', $this->id)
             ->where('is_active', true)
             ->count();
-
         return !!$numTeams;
     }
 
@@ -332,6 +331,201 @@ class Pro extends Model
             ->get();
     }
 
+    function get_patients_count_as_mcp() {
+        $query = Client::whereNull('shadow_pro_id');
+        return $query->where('mcp_pro_id', $this->id)->count();
+    }
+
+    function get_new_patients_awaiting_visit_count_as_mcp() {
+        $query = Client::whereNull('shadow_pro_id');
+        return $query->where('mcp_pro_id', $this->id)
+            ->where('has_mcp_done_onboarding_visit', '!=', 'YES')
+            ->count();
+    }
+
+    function get_notes_pending_signature_count_as_mcp() {
+        return Note::where('hcp_pro_id', $this->id)
+            ->where('is_cancelled', '<>', true)
+            ->where('is_signed_by_hcp', '<>', true)
+            ->count();
+    }
+
+    function get_notes_pending_signature_count_as_dna() {
+        return;
+        $naBillableSignedNotes = DB::select(DB::raw("
+SELECT count(note.id) as na_billable_notes
+FROM note
+WHERE
+        note.is_signed_by_hcp = TRUE AND
+        note.ally_pro_id = :pro_id AND
+        note.is_cancelled = FALSE AND
+        (
+            SELECT count(bill.id)
+            FROM bill
+            WHERE
+                  bill.is_cancelled = FALSE AND
+                  bill.generic_pro_id = :pro_id AND
+                  bill.note_id = note.id
+        ) = 0
+        "), ["pro_id" => $performerProID]);
+
+        if(!$naBillableSignedNotes || !count($naBillableSignedNotes)) {
+            $naBillableSignedNotes = 0;
+        }
+        else {
+            $naBillableSignedNotes = $naBillableSignedNotes[0]->na_billable_notes;
+        }
+    }
+
+    function get_notes_pending_billing_count_as_mcp() {
+        return Note::where('hcp_pro_id', $this->id)
+            ->where('is_cancelled', '<>', true)
+            ->where('is_signed_by_hcp', true)
+            ->where('is_billing_marked_done', '<>', true)
+            ->count();
+    }
+
+    function get_bills_pending_signature_count_as_mcp(){
+        return;
+        $pendingBillsToSign = Bill::where('bill_service_type', '<>', 'CARE_MONTH')->where(function ($query) use ($performerProID) {
+            $query->where('hcp_pro_id', $performerProID)->where('is_signed_by_hcp', false)->where('is_cancelled', false);
+        })
+            ->orWhere(function ($query) use ($performerProID) {
+                $query->where('cm_pro_id', $performerProID)->where('is_signed_by_cm', false)->where('is_cancelled', false);;
+            })->orWhere(function ($query) use ($performerProID) {
+                $query->where('rme_pro_id', $performerProID)->where('is_signed_by_rme', false)->where('is_cancelled', false);;
+            })->orWhere(function ($query) use ($performerProID) {
+                $query->where('rmm_pro_id', $performerProID)->where('is_signed_by_rmm', false)->where('is_cancelled', false);;
+            })->count();
+
+        $keyNumbers['pendingBillsToSign'] = $pendingBillsToSign;
+    }
+
+    function get_measurements_awaiting_review_count_as_mcp() {
+        return;
+    }
+
+    function get_incoming_reports_pending_signature_count_as_mcp() {
+        return IncomingReport::where('hcp_pro_id', $this->id)
+            ->where('has_hcp_pro_signed', '<>', true)
+            ->where('is_entry_error', '<>', true)
+            ->count();
+    }
+
+    function get_patients_without_appointment_query() {
+        return Client::where('mcp_pro_id', $this->id)
+                    ->where(function($q){
+                        $q->whereNull('next_mcp_appointment_id')
+                        ->orWhere('next_mcp_appointment_date', '<=', DB::raw('NOW()::DATE'));
+                    });
+    }
+
+    function get_patients_without_appointment_count_as_mcp() {
+        return $this->get_patients_without_appointment_query()->count();
+    }
+
+    function get_patients_overdue_for_visit_query() {
+        return Client::where('mcp_pro_id', $this->id)
+                    ->where(function($q){
+                        $q->whereNull('most_recent_completed_mcp_note_id')
+                        ->orWhere('most_recent_completed_mcp_note_date', '<', DB::raw("NOW()::DATE - INTERVAL '45 DAY'"));
+                    });
+    }
+
+    function get_patients_overdue_count_as_mcp() {
+        return $this->get_patients_overdue_for_visit_query()->count();
+    }
+
+    function get_patients_without_remote_measurement_in_48_hours_count_as_mcp() {
+    }
+
+    function get_cancelled_appointments_pending_acknowledgement_count_as_mcp_query() {
+        // SELECT * FROM appointment WHERE hcp_pro_id = :me.id AND status = 'REJECTED' AND wasAcknowledgedByAppointmentPro IS NOT TRUE;
+        return Appointment::where('pro_id', $this->id)
+            ->where('latest_confirmation_decision_enum', 'REJECTED')
+            ->where('is_decision_acknowledgement_from_appointment_pro_pending', true);
+    }
+    function get_cancelled_appointments_pending_acknowledgement_count_as_mcp() {
+        // SELECT * FROM appointment WHERE hcp_pro_id = :me.id AND status = 'REJECTED' AND wasAcknowledgedByAppointmentPro IS NOT TRUE;
+        return $this->get_cancelled_appointments_pending_acknowledgement_count_as_mcp_query()->count();
+    }
+
+    function get_cancelled_bills_awaiting_review_count_as_mcp() {
+        // SELECT * FROM bill WHERE bill_service_type = 'NOTE' AND is_cancelled IS TRUE AND isCancellationAcknowledged IS FALSE;
+        return Bill::where('hcp_pro_id', $this->id)
+            ->where('bill_service_type', 'NOTE')
+            ->where('is_cancelled', true)
+            ->where('is_cancellation_acknowledged', '<>', true)
+            ->count();
+    }
+
+    function get_cancelled_supply_orders_awaiting_review_count_as_mcp() {
+        // SELECT * FROM supply_order WHERE signed_by_pro_id = :me.id AND is_cancelled IS TRUE AND isCancellationAcknowledged IS NOT TRUE;
+        return SupplyOrder::where('signed_by_pro_id', $this->id)
+            ->where('is_cancelled', true)
+            ->where('is_cancellation_acknowledged', '<>', true)
+            ->count();
+    }
+
+    function get_erx_and_orders_awaiting_signature_count_as_mcp() {
+        // SELECT * FROM erx WHERE hcp_pro_id = :me.id AND pro_declared_status <> 'CANCELLED' AND hasHcpProSigned IS NOT TRUE;
+        return Erx::where('hcp_pro_id', $this->id)
+            ->where('pro_declared_status', '<>', 'CANCELLED')
+            ->where('has_hcp_pro_signed', '<>', true)
+            ->count();
+    }
+
+    function get_supply_orders_awaiting_signature_count_as_mcp() {
+        // SELECT supply_order.id FROM supply_order WHERE signed_by_pro_id IS NOT TRUE AND is_cancelled IS NOT TRUE AND created_by_pro_id = :me.id;
+        return SupplyOrder::where('created_by_pro_id', $this->id)
+            ->whereNull('signed_by_pro_id')
+            ->where('is_cancelled', '<>', true)
+            ->count();
+    }
+
+    function get_birthdays_today_as_mcp(){
+        return;
+        $queryClients = $this->performer()->pro->getAccessibleClientsQuery();
+        $keyNumbers['patientsHavingBirthdayToday'] = $queryClients
+            ->whereRaw('EXTRACT(DAY from dob) = ?', [date('d')])
+            ->whereRaw('EXTRACT(MONTH from dob) = ?', [date('m')])
+            ->count();
+
+        $reimbursement = [];
+        $reimbursement["currentBalance"] =  $performer->pro->balance;
+        $reimbursement["nextPaymentDate"] = '--';
+        $lastPayment = ProTransaction::where('pro_id', $performerProID)->where('plus_or_minus', 'PLUS')->orderBy('created_at', 'DESC')->first();
+        if ($lastPayment) {
+            $reimbursement["lastPayment"] =  $lastPayment->amount;
+            $reimbursement["lastPaymentDate"] = $lastPayment->created_at;
+        } else {
+            $reimbursement["lastPayment"] = '--';
+            $reimbursement["lastPaymentDate"] = '--';
+        }
+    }
+
+    public function getAppointmentsPendingStatusChangeAck() {
+        return Appointment::where('pro_id', $this->id)
+            ->where('is_status_acknowledgement_from_appointment_pro_pending', true)
+            ->where('raw_date', '>=', DB::raw('NOW()'))
+            ->orderBy('raw_date', 'asc')
+            ->get();
+    }
+    public function getAppointmentsPendingDecisionAck() {
+        return Appointment::where('pro_id', $this->id)
+            ->where('is_decision_acknowledgement_from_appointment_pro_pending', true)
+            ->where('raw_date', '>=', DB::raw('NOW()'))
+            ->orderBy('raw_date', 'asc')
+            ->get();
+    }
+    public function getAppointmentsPendingTimeChangeAck() {
+        return Appointment::where('pro_id', $this->id)
+            ->where('is_time_change_acknowledgement_from_appointment_pro_pending', true)
+            ->where('raw_date', '>=', DB::raw('NOW()'))
+            ->orderBy('raw_date', 'asc')
+            ->get();
+    }
+
     public function getAccessibleClientsQuery($_search = false) {
         $proID = $this->id;
         $query = Client::whereNull('shadow_pro_id');
@@ -346,7 +540,7 @@ class Pro extends Model
                     ->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 client_id FROM appointment WHERE status NOT IN (\'CANCELLED\') AND pro_id = ?)', [$proID])
                     ->orWhereRaw('id IN (SELECT mcp_pro_id FROM client_program WHERE client_id = client.id AND is_active = TRUE)')
                     ->orWhereRaw('id IN (SELECT manager_pro_id FROM client_program WHERE client_id = client.id AND is_active = TRUE)')
                     ->orWhereRaw('id IN (SELECT client_id FROM note WHERE ally_pro_id = ? AND is_cancelled = FALSE)', [$proID]);;
@@ -370,7 +564,7 @@ class Pro extends Model
                     ->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 client_id FROM appointment WHERE status NOT IN (\'CANCELLED\') AND pro_id = ?)', [$proID])
                     ->orWhereRaw('id IN (SELECT mcp_pro_id FROM client_program WHERE client_id = client.id AND is_active = TRUE)')
                     ->orWhereRaw('id IN (SELECT manager_pro_id FROM client_program WHERE client_id = client.id AND is_active = TRUE)')
                     ->orWhereRaw('id IN (SELECT client_id FROM note WHERE ally_pro_id = ? AND is_cancelled = FALSE)', [$proID]);
@@ -605,4 +799,8 @@ class Pro extends Model
         return $this->hasOne(NotePickupForProcessing::class, 'id', 'current_note_pickup_for_processing_id');
     }
 
+    public function get_patients_not_seen_in_45_days_count_as_mcp(){
+        return 0;
+    }
+
 }

+ 11 - 0
app/Models/Status.php

@@ -0,0 +1,11 @@
+<?php
+
+namespace App\Models;
+
+# use Illuminate\Database\Eloquent\Model;
+
+class Status extends Model
+{
+    protected $table = 'status';
+
+}

+ 62 - 0
config/constants.php

@@ -0,0 +1,62 @@
+<?php
+  return [
+      'medicaid_states' => [
+        "MEDICAID ALABAMA",
+        "MEDICAID ALASKA",
+        "MEDICAID ARIZONA",
+        "MEDICAID ARKANSAS",
+        "MEDICAID CALIFORNIA MEDI-CAL",
+        "MEDICAID COLORADO",
+        "MEDICAID CONNECTICUT",
+        "MEDICAID DELAWARE",
+        "MEDICAID DISTRICT OF COLUMBIA",
+        "MEDICAID FLORIDA",
+        "MEDICAID GEORGIA",
+        "MEDICAID HAWAII",
+        "MEDICAID IDAHO",
+        "MEDICAID ILLINOIS",
+        "MEDICAID INDIANA",
+        "MEDICAID IOWA",
+        "MEDICAID KANSAS",
+        "MEDICAID KENTUCKY",
+        "MEDICAID LOUISIANA",
+        "MEDICAID MAINE",
+        "MEDICAID MARYLAND",
+        "MEDICAID MARYLAND DHMH",
+        "MEDICAID MASSACHUSETTS",
+        "MEDICAID MICHIGAN",
+        "MEDICAID MINNESOTA",
+        "MEDICAID MISSISSIPPI",
+        "MEDICAID MISSISSIPPI",
+        "MEDICAID MISSOURI",
+        "MEDICAID MONTANA",
+        "MEDICAID NEBRASKA",
+        "MEDICAID NEVADA",
+        "MEDICAID NEW HAMPSHIRE",
+        "MEDICAID NEW JERSEY",
+        "MEDICAID NEW MEXICO",
+        "MEDICAID NEW YORK",
+        "MEDICAID NEW YORK",
+        "MEDICAID NORTH CAROLINA",
+        "MEDICAID NORTH DAKOTA",
+        "MEDICAID OHIO",
+        "MEDICAID OKLAHOMA",
+        "MEDICAID OREGON",
+        "MEDICAID OREGON (DHS OMAP)",
+        "MEDICAID PENNSYLVANIA",
+        "MEDICAID RHODE ISLAND",
+        "MEDICAID SOUTH CAROLINA",
+        "MEDICAID SOUTH DAKOTA",
+        "MEDICAID TENNESSEE",
+        "MEDICAID TEXAS",
+        "MEDICAID TEXAS AND TEXAS HEALTH STEPS",
+        "MEDICAID UTAH",
+        "MEDICAID VERMONT",
+        "MEDICAID VIRGINIA",
+        "MEDICAID WASHINGTON (PROVIDER ONE)",
+        "MEDICAID WEST VIRGINIA",
+        "MEDICAID WISCONSIN",
+        "MEDICAID WYOMING",
+      ]
+  ];
+?>

+ 4 - 1
public/css/style.css

@@ -1056,7 +1056,6 @@ body .node input[type="number"] {
     width: calc(100vw - 4rem);
 }
 .stag-popup.tall>form, .stag-popup.tall>.stag-popup-content {
-    height: 100%;
     min-height: 500px;
 }
 .stag-popup.narrow>form, .stag-popup.narrow>.stag-popup-content {
@@ -2107,3 +2106,7 @@ body.in-iframe .main-row > .sidebar {
 [open-in-stag-popup] * {
     pointer-events: none;
 }
+.stag-menu {
+    position: absolute;
+    z-index: 2;
+}

+ 5 - 0
resources/views/app/admin/appointments.blade.php

@@ -0,0 +1,5 @@
+@extends ('layouts/template')
+
+@section('content')
+    <h1>Hi</h1>
+@endsection

+ 5 - 0
resources/views/app/admin/bills.blade.php

@@ -0,0 +1,5 @@
+@extends ('layouts/template')
+
+@section('content')
+    <h1>Hi</h1>
+@endsection

+ 1 - 0
resources/views/app/admin/dashboard/calls_memos.blade.php

@@ -0,0 +1 @@
+<h1>Phone Calls & Memos</h1>

+ 1 - 0
resources/views/app/admin/dashboard/erx_orders.blade.php

@@ -0,0 +1 @@
+<h1>ERX & Orders</h1>

+ 1 - 0
resources/views/app/admin/dashboard/measurements.blade.php

@@ -0,0 +1 @@
+<div id="measurements-tab">Loading...</div>

+ 1 - 0
resources/views/app/admin/dashboard/messages.blade.php

@@ -0,0 +1 @@
+<h1>Messages</h1>

+ 1 - 0
resources/views/app/admin/dashboard/notifications.blade.php

@@ -0,0 +1 @@
+<h1>Notifications</h1>

+ 1 - 0
resources/views/app/admin/dashboard/supply_orders.blade.php

@@ -0,0 +1 @@
+<h1>Supply Orders</h1>

+ 5 - 0
resources/views/app/admin/erx_and_orders.blade.php

@@ -0,0 +1,5 @@
+@extends ('layouts/template')
+
+@section('content')
+    <h1>Hi</h1>
+@endsection

+ 5 - 0
resources/views/app/admin/notes.blade.php

@@ -0,0 +1,5 @@
+@extends ('layouts/template')
+
+@section('content')
+    <h1>Hi</h1>
+@endsection

+ 6 - 0
resources/views/app/admin/patients.blade.php

@@ -0,0 +1,6 @@
+@extends ('layouts/template')
+
+@section('content')
+    <h1>Hi</h1>
+@endsection
+

+ 5 - 0
resources/views/app/admin/reports.blade.php

@@ -0,0 +1,5 @@
+@extends ('layouts/template')
+
+@section('content')
+    <h1>Hi</h1>
+@endsection

+ 5 - 0
resources/views/app/admin/supply_orders.blade.php

@@ -0,0 +1,5 @@
+@extends ('layouts/template')
+
+@section('content')
+    <h1>Hi</h1>
+@endsection

+ 913 - 0
resources/views/app/dashboard-admin.blade.php

@@ -0,0 +1,913 @@
+@extends ('layouts.template')
+
+@section('content')
+
+    <style>
+        tr.thin th, tr.thin td {
+            padding: 0.25em;
+        }
+    </style>
+
+    <div class="p-3">
+        <div class="">
+            <div class="row mcp-theme-1" id="pro-dashboard-container" v-cloak>
+                <div class="col-md-3 mcp-theme-1">
+                    <div class="mb-4" v-show="tab==='appointments'">
+                        <div class="pro-dashboard-inline-calendar"></div>
+                    </div>
+                    <div class="card mb-4">
+                        <div class="card-header pl-2">
+                            <strong>
+                                Key Numbers
+                            </strong>
+                        </div>
+                        <div class="card-body p-0">
+                            <table class="table mb-0 dashboard-stats-table">
+                                <tbody>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_patients_count_as_mcp()}}</th>
+                                    <th class="pl-2">Patients</th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_new_patients_awaiting_visit_count_as_mcp()}}</th>
+                                    <th class="pl-2">New Patients Awaiting Visit</th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_notes_pending_signature_count_as_mcp()}}</th>
+                                    <th class="pl-2">Notes Pending Signature</th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_notes_pending_billing_count_as_mcp()}}</th>
+                                    <th class="pl-2">Notes Pending Billing</th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_incoming_reports_pending_signature_count_as_mcp()}}</th>
+                                    <th class="pl-2">Reports Pending Signature</th>
+                                </tr>
+
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_patients_without_appointment_count_as_mcp()}}</th>
+                                    <th class="pl-2">Patients w/o Appointments</th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_patients_not_seen_in_45_days_count_as_mcp()}}</th>
+                                    <th class="pl-2">Patients Not Seen in 45 Days</th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_cancelled_appointments_pending_acknowledgement_count_as_mcp()}}</th>
+                                    <th class="pl-2">Cancelled Appts. Pending Review</th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_cancelled_bills_awaiting_review_count_as_mcp()}}</th>
+                                    <th class="pl-2">Cancelled Bills Pending Review</th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_cancelled_supply_orders_awaiting_review_count_as_mcp()}}</th>
+                                    <th class="pl-2">Cancelled Supply Orders Pending Review</th>
+                                </tr>
+
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_erx_and_orders_awaiting_signature_count_as_mcp()}}</th>
+                                    <th class="pl-2">ERx & Orders Pending Signature</th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_supply_orders_awaiting_signature_count_as_mcp()}}</th>
+                                    <th class="pl-2">Supply Orders Pending Signature</th>
+                                </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">{{$pro->get_measurements_awaiting_review_count_as_mcp() ?? '-'}}</th>
+                                    <th class="pl-2">Measurements Pending Review</th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_patients_without_remote_measurement_in_48_hours_count_as_mcp() ?? '-'}}</th>
+                                    <th class="pl-2">Patients w/o Measurement in 48 hrs.</th>
+                                </tr>
+                                </tbody>
+                            </table>
+                        </div>
+                    </div>
+                    <div class="card mb-4">
+                        <div class="card-header pl-2">
+                            <strong>
+                                Practice Management
+                            </strong>
+                        </div>
+                        <div class="card-body p-0">
+                            <table class="table mb-0 dashboard-stats-table">
+                                <tbody>
+                                <tr>
+                                    <th colspan="2">Revenue Cycle Management</th>
+                                </tr>
+                                <tr class="thin">
+                                    <th class="font-weight-normal px-2 pl-4">
+                                        ${{friendly_money($reimbursement['currentBalance'])}}</th>
+                                    <th class="font-weight-normal pl-2 w-100"><a
+                                            href="/practice-management/financial-transactions">Current balance</a></th>
+                                </tr>
+                                <!-- <tr>
+                                    <th class="px-2">{{friendly_date_time($reimbursement['nextPaymentDate'], false)}}</th>
+                                    <th class="pl-2">Next Payment Date</th>
+                                </tr> -->
+                                <tr class="thin">
+                                    <th class="font-weight-normal px-2 pl-4">${{friendly_money($reimbursement['nextPaymentAmount'])}}</th>
+                                    <th class="font-weight-normal pl-2"><a
+                                            href="/practice-management/bills-under-processing">Processing</a></th>
+                                </tr>
+                                <tr class="thin">
+                                    <th class="font-weight-normal px-2 pl-5">${{friendly_money($reimbursement['nextPaymentAmount'])}}</th>
+                                    <th class="font-weight-normal pl-2"><a
+                                            href="/practice-management/bills-under-processing">Treatment Services</a></th>
+                                </tr>
+                                <tr class="thin">
+                                    <th class="font-weight-normal px-2 pl-5">${{friendly_money($reimbursement['nextPaymentAmount'])}}</th>
+                                    <th class="font-weight-normal pl-2"><a
+                                            href="/practice-management/bills-under-processing">Remote Monitoring</a></th>
+                                </tr>
+                                <tr class="thin">
+                                    <th class="font-weight-normal px-2 pl-5">${{friendly_money($reimbursement['nextPaymentAmount'])}}</th>
+                                    <th class="font-weight-normal pl-2"><a
+                                            href="/practice-management/bills-under-processing">Other Services</a></th>
+                                </tr>
+                                {{--
+                                <tr>
+                                    <th class="px-2">{{$reimbursement['lastPayment']}}</th>
+                                    <th class="pl-2"><a href="/practice-management/financial-transactions">Last payment</a></th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2">{{friendly_date_time($reimbursement['lastPaymentDate'], false)}}</th>
+                                    <th class="pl-2"><a href="/practice-management/financial-transactions">Last payment date</a></th>
+                                </tr>
+                                --}}
+                                </tbody>
+                            </table>
+                        </div>
+                    </div>
+                    @if($pro->pro_type === 'ADMIN')
+                        <div class="card mb-4">
+                            <div class="card-header pl-2">
+                                <strong>
+                                    Bills &amp; Claims
+                                </strong>
+                            </div>
+                            <div class="card-body p-0">
+                                <table class="table mb-0 dashboard-stats-table">
+                                    <tbody>
+
+                                    <tr>
+                                        <th class="border-top-1 px-2 text-center">{{$businessNumbers['notesWithBillsToResolve']}}</th>
+                                        <th class="border-top-1 pl-2">
+                                            <a href="/practice-management/billing-manager">Notes with bills to
+                                                resolve</a>
+                                        </th>
+                                    </tr>
+                                    <tr>
+                                        <th class="border-top-1 px-2 text-center">{{$businessNumbers['notesPendingBillingClosure']}}</th>
+                                        <th class="border-top-1 pl-2">
+                                            <a href="/practice-management/billing-manager">Notes pending billing
+                                                closure</a>
+                                        </th>
+                                    </tr>
+                                    </tbody>
+                                </table>
+                            </div>
+                        </div>
+                    @endif
+                </div>
+                <div class="col-md-9">
+
+                    <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="d-flex align-items-start bg-light mb-2 px-2 py-1">
+                                            <div class="flex-grow-1">
+                                                You are now the MCP for
+                                                <a href="/patients/view/{{$assoc->patient->uid}}"
+                                                   class="">{{$assoc->patient->displayName()}}</a>
+                                                <?php $nextAppt = $assoc->patient->nextAppointment(); ?>
+                                                @if($nextAppt)
+                                                    <div class="font-size-11">
+                                                        <span class="text-secondary font-size-11">Appt.</span>
+                                                        {{$nextAppt->pro->displayName()}}
+                                                        <span class="text-secondary font-size-11">on</span>
+                                                        {{friendlier_date_time($nextAppt->raw_date . ' ' . $nextAppt->raw_start_time)}}
+                                                    </div>
+                                                    @if($nextAppt->status === 'PENDING') {{-- WIP: ALIX overhaul --}}
+                                                        <div
+                                                            class="text-warning-mellow font-weight-bold font-size-11 mt-1">
+                                                            <i class="fa fa-exclamation-triangle"></i>
+                                                            Confirmation pending
+                                                        </div>
+                                                    @endif
+                                                    @if($nextAppt->status === 'CONFIRMED')
+                                                        <div class="text-success font-weight-bold font-size-11 mt-1">
+                                                            <i class="fa fa-check"></i>
+                                                            Confirmed by the patient
+                                                        </div>
+                                                    @endif
+                                                    @if($nextAppt->status === 'CANCELLED')
+                                                        <div class="text-danger font-weight-bold font-size-11 mt-1">
+                                                            <i class="fa fa-stop"></i>
+                                                            Cancelled
+                                                        </div>
+                                                    @endif
+                                                @endif
+                                            </div>
+                                            <a href="#" class="ack-client-pro-change ml-3" data-uid="{{$assoc->uid}}">Stamp</a>
+                                        </div>
+                                    @endforeach
+                                </div>
+                            @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="d-flex align-items-start bg-light mb-2 px-2 py-1">
+                                            <div class="flex-grow-1">
+                                                You are now the Care Coordinator for
+                                                <a href="/patients/view/{{$assoc->patient->uid}}"
+                                                   class="">{{$assoc->patient->displayName()}}</a>
+                                                <?php $nextAppt = $assoc->patient->nextAppointment(); ?>
+                                                @if($nextAppt)
+                                                    <div class="font-size-11">
+                                                        <span class="text-secondary font-size-11">Appt.</span>
+                                                        {{$nextAppt->pro->displayName()}}
+                                                        <span class="text-secondary font-size-11">on</span>
+                                                        {{friendlier_date_time($nextAppt->raw_date . ' ' . $nextAppt->raw_start_time)}}
+                                                    </div>
+                                                    @if($nextAppt->status === 'PENDING') {{-- WIP: ALIX overhaul --}}
+                                                        <div
+                                                            class="text-warning-mellow font-weight-bold font-size-11 mt-1">
+                                                            <i class="fa fa-exclamation-triangle"></i>
+                                                            Confirmation pending
+                                                        </div>
+                                                    @endif
+                                                    @if($nextAppt->status === 'CONFIRMED')
+                                                        <div class="text-success font-weight-bold font-size-11 mt-1">
+                                                            <i class="fa fa-check"></i>
+                                                            Confirmed by the patient
+                                                        </div>
+                                                    @endif
+                                                    @if($nextAppt->status === 'CANCELLED')
+                                                        <div class="text-danger font-weight-bold font-size-11 mt-1">
+                                                            <i class="fa fa-stop"></i>
+                                                            Cancelled
+                                                        </div>
+                                                    @endif
+                                                @endif
+                                            </div>
+                                            <a href="#" class="ack-client-pro-change"
+                                               data-uid="{{$assoc->uid}}">Stamp</a>
+                                        </div>
+                                    @endforeach
+                                </div>
+                            @endif
+                        </div>
+                        <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">
+                            <a native data-tab="appointments" class="nav-link"
+                               :class="tab == 'appointments' ? 'active' : ''" href="#"
+                               v-on:click.prevent="tab='appointments'; initLoadAppointments();">
+                                Appointments
+                            </a>
+                        </li>
+                        <li class="nav-item">
+                            <a native data-tab="measurements" class="nav-link"
+                               :class="tab == 'measurements' ? 'active' : ''" href="#"
+                               v-on:click.prevent="tab='measurements'; loadMeasurements();">
+                                Measurements
+                            </a>
+                        </li>
+                        <li class="nav-item">
+                            <a native data-tab="incoming_reports"
+                               class="nav-link {{count($incomingReports) ? 'text-danger font-weight-bold' : ''}}"
+                               :class="tab == 'incoming_reports' ? 'active' : ''" href="#"
+                               v-on:click.prevent="tab='incoming_reports'">
+                                Incoming Reports ({{count($incomingReports)}})
+                            </a>
+                        </li>
+                        <li class="nav-item">
+                            <a native data-tab="erx" class="nav-link {{$numERx ? 'text-danger font-weight-bold' : ''}}"
+                               :class="tab == 'erx' ? 'active' : ''" href="#"
+                               v-on:click.prevent="tab='erx'">
+                                ERx ({{$numERx}})
+                            </a>
+                        </li>
+                        <li class="nav-item">
+                            <a native data-tab="labs"
+                               class="nav-link {{$numLabs ? 'text-danger font-weight-bold' : ''}}"
+                               :class="tab == 'labs' ? 'active' : ''" href="#"
+                               v-on:click.prevent="tab='labs'">
+                                Labs ({{$numLabs}})
+                            </a>
+                        </li>
+                        <li class="nav-item">
+                            <a native data-tab="imaging"
+                               class="nav-link {{$numImaging ? 'text-danger font-weight-bold' : ''}}"
+                               :class="tab == 'imaging' ? 'active' : ''" href="#"
+                               v-on:click.prevent="tab='imaging'">
+                                Imaging ({{$numImaging}})
+                            </a>
+                        </li>
+                        <li class="nav-item">
+                            <a native data-tab="supply_orders"
+                               class="nav-link {{$numSupplyOrders ? 'text-danger font-weight-bold' : ''}}"
+                               :class="tab == 'supply_orders' ? 'active' : ''" href="#"
+                               v-on:click.prevent="tab='supply_orders'">
+                                Supply Orders ({{$numSupplyOrders}})
+                            </a>
+                        </li>
+                    </ul>
+
+                    <div class="border-left border-right border-bottom p-3">
+                        <div v-show="tab==='appointments'" class="appointments-tab">
+                            <div v-show="selectedDate">
+                                <div class="d-flex align-items-end mb-3">
+                                    <b class="large"><span class="text-secondary">Today:</span> @{{ selectedDate }}</b>
+                                    <div class="ml-auto d-inline-flex align-items-center">
+                                        <label class="text-secondary mr-2 my-0 text-nowrap">Filter by status:</label>
+                                        <select v-model="filterStatus"
+                                                class="form-control form-control-sm">
+                                            <option value="">All</option>
+                                            <option value="PENDING">Pending</option>
+                                            <option value="CONFIRMED">Confirmed</option>
+                                            <option value="CANCELLED">Cancelled</option>
+                                            <option value="COMPLETED">Completed</option>
+                                        </select>
+                                    </div>
+                                </div>
+                                <div v-for="event in events" class="align-items-end p-3 border rounded mb-3"
+                                     :class="(event.dateYMD === selectedDate && (filterStatus === '' || filterStatus === event.status) ? 'd-flex' : 'd-none') + ' ' + (event.isClientShadowOfPro ? 'training-event' : '')">
+                                    <div class="patient-avatar mr-3 align-self-center">
+                                        <i v-if="event.isClientShadowOfPro" class="fa fa-graduation-cap training-icon"
+                                           :title="event.proInitials"></i>
+                                        <span v-else class="">@{{ event.proInitials }}</span>
+                                    </div>
+                                    <div>
+                                        <div class="pb-1">
+                                            <b class="text-info">@{{ event.proName }}</b>
+                                            &nbsp;/&nbsp;
+                                            @{{ event.friendlyStartTime }} - @{{ event.friendlyEndTime }} <span
+                                                class="text-secondary">@{{ event.timezone }}</span>
+                                            &nbsp;/&nbsp;
+                                            <span class="d-inline-block ml- 2 text-secondary font-weight-bold">@{{ event.title }}</span>
+                                        </div>
+                                        <div class="pb-1">
+                                            <a :href="'/patients/view/' + event.clientUid" class="font-weight-bold">@{{
+                                                event.clientName }}</a>
+                                            <span class="small d-inline-block pl-2 text-secondary font-weight-normal">@{{ event.clientSummary }}</span>
+                                        </div>
+                                        <div class="d-flex align-items-baseline">
+                                            <div v-if="event.status === 'PENDING'"
+                                                 class="text-warning-mellow font-weight-bold">
+                                                <i class="fa fa-exclamation-triangle"></i>
+                                                Confirmation pending
+                                            </div>
+                                            <div v-else-if="event.status === 'CONFIRMED'"
+                                                 class="text-success font-weight-bold">
+                                                <i class="fa fa-check"></i>
+                                                Confirmed by the patient
+                                            </div>
+                                            <div v-else class="text-secondary">
+                                                Status: <b>@{{ event.status }}</b>
+                                            </div>
+                                            <span class="mx-2 text-secondary">|</span>
+                                            <a :href="'/patients/view/' + event.clientUid + '/calendar/' + event.uid">
+                                                <i class="fa fa-edit"></i>
+                                                Edit Appointment
+                                            </a>
+                                        </div>
+                                        <div class="mt-1"
+                                             :class="event.coverage !== 'YES' ? (event.coverage === 'NO' ? 'text-danger' : 'text-warning-mellow') : 'text-success'">
+                                            Coverage Status: <b>@{{ event.coverage }}</b>
+                                        </div>
+                                    </div>
+                                    <div class="ml-auto">
+                                        <select v-model="event.newStatus"
+                                                class="form-control form-control-sm bg-light"
+                                                v-on:change="updateStatus(event)">
+                                            <option value="PENDING">PENDING</option>
+                                            <option value="CONFIRMED">CONFIRMED</option>
+                                            <option value="CANCELLED">CANCELLED</option>
+                                            <option value="COMPLETED">COMPLETED</option>
+                                        </select>
+                                        <div v-if="selectedDate === '{{ date('Y-m-d') }}'"
+                                             class="pt-1 text-right"
+                                             :class="event.started ? 'text-danger': 'text-secondary'">
+                                            @{{ event.inHowManyHours }}
+                                        </div>
+                                    </div>
+                                </div>
+                                <div v-if="numEventsForDate === 0" class="bg-light p-3 text-secondary border bounded">
+                                    <span
+                                        v-if="filterStatus === ''">You have no appointments on <b>@{{ selectedDate }}</b></span>
+                                    <span
+                                        v-if="filterStatus !== ''">You have no appointments on <b>@{{ selectedDate }}</b> with status <b>@{{ filterStatus }}</b></span>
+                                </div>
+                            </div>
+                            <div v-show="!selectedDate" class="bg-light p-3 text-secondary border bounded">
+                                Please select a date from the calendar on the left
+                            </div>
+                        </div>
+                        <div v-show="tab==='measurements'">
+                            <div id="measurements-tab">Loading...</div>
+                        </div>
+                        <div v-show="tab==='incoming_reports'">
+                            @include('app.dashboard.incoming_reports')
+                        </div>
+                        <div v-show="tab==='erx'">
+                            @include('app.dashboard.erx')
+                        </div>
+                        <div v-show="tab==='labs'">
+                            @include('app.dashboard.labs')
+                        </div>
+                        <div v-show="tab==='imaging'">
+                            @include('app.dashboard.imaging')
+                        </div>
+                        <div v-show="tab==='supply_orders'">
+                            @include('app.dashboard.supply_orders')
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+
+    <div class="stag-popup stag-popup-md ticket-popup mcp-theme-1" stag-popup-key="ticket-popup"></div>
+
+    <script>
+        (function () {
+            function init() {
+                window.apapp = new Vue({
+                    el: '#pro-dashboard-container',
+                    delimiters: ['@{{', '}}'],
+                    data: {
+                        tab: '{{ request()->input('tab') ? request()->input('tab') : 'measurements' }}',
+                        datesWithEvents: [],
+                        selectedDate: '{{ date('Y-m-d') }}',
+                        selectedStatus: 'PENDING',
+                        events: [],
+                        numEventsForDate: 0,
+                        filterStatus: '',
+                        calendarElem: null,
+                        currentMonth: null,
+                        currentYear: null,
+                        measurementFilterStatus: 'ALL',
+                        measurements: {!! $pro->pro_type === 'ADMIN' ? '[]' : json_encode($pro->getMeasurements()) !!},
+                        appointmentsLoaded: false,
+                    },
+                    methods: {
+                        formatDate: function (date) {
+                            let d = new Date(date),
+                                month = '' + (d.getMonth() + 1),
+                                day = '' + d.getDate(),
+                                year = d.getFullYear();
+
+                            if (month.length < 2)
+                                month = '0' + month;
+                            if (day.length < 2)
+                                day = '0' + day;
+
+                            return [year, month, day].join('-');
+                        },
+                        onDateChange: function (_newDate) {
+                            let self = this;
+                            window.setTimeout(() => {
+                                // let dayValue = $('.pro-dashboard-inline-calendar td.day.active').first().text();
+                                // if(dayValue.length === 1) dayValue = '0' + dayValue;
+                                // self.selectedDate = _newDate.substr(0, 8) + dayValue;
+                                self.selectedDate = _newDate;
+                                showMask();
+                                self.loadEvents(self.selectedDate, function () {
+                                    hideMask();
+                                    Vue.nextTick(() => {
+                                        // self.highlightDatesWithEvents(self.datesWithEvents);
+                                        initFastLoad($('.appointments-tab'));
+                                    });
+                                });
+                            }, 25);
+                        },
+                        selectToday: function () {
+                            $('.pro-dashboard-inline-calendar table td[data-date]').removeClass('active');
+                            $('.pro-dashboard-inline-calendar table td[data-date="{{ $milliseconds }}"]')
+                                .addClass('active');
+                            // this.onDateChange('{{ date('Y-m-d') }}');
+                        },
+                        highlightDatesWithEvents: function (_dates) {
+                            $('.pro-dashboard-inline-calendar table td[data-date]').removeAttr('has-events');
+                            for (let i = 0; i < _dates.length; i++) {
+                                $('.pro-dashboard-inline-calendar table td[data-date="' + _dates[i] + '"]')
+                                    .attr('has-events', 1);
+                            }
+                        },
+                        updateStatus: function (_event) {
+                            $.post('/api/appointment/updateStatus', {
+                                uid: _event.uid,
+                                status: _event.newStatus
+                            }, function (_data) {
+                                if (!_data) {
+                                    toastr.error('Unable to update appointment status!');
+                                } else {
+                                    if (!_data.success) {
+                                        toastr.error(_data.message);
+                                    } else {
+                                        _event.status = _event.newStatus;
+                                        toastr.success('The appointment has been updated');
+                                    }
+                                }
+                            }, 'json')
+                        },
+                        showEditForm: function (_trigger) {
+                            let form = $(_trigger).closest('[moe]').find('form').first();
+                            showMoeFormMask();
+                            form.show();
+                            setTimeout(function () {
+                                initPrimaryForm(form);
+                            }, 0);
+                        },
+                        submitEditForm: function (_trigger) {
+                            let form = $(_trigger).closest('[moe]').find('form').first();
+                            if (!form[0].checkValidity()) {
+                                form[0].reportValidity();
+                                return;
+                            }
+                            $.post(form.attr('url'), form.serialize(), function (_data) {
+                                if (_data && _data.success) {
+                                    fastReload();
+                                } else {
+                                    if (_data.message) {
+                                        toastr.error(_data.message);
+                                    } else {
+                                        toastr.error('Unable to update the appointment');
+                                    }
+                                }
+                            });
+                        },
+                        cancelEditForm: function (_trigger) {
+                            let form = $(_trigger).closest('[moe]').find('form').first();
+                            hideMoeFormMask();
+                            form.hide();
+                        },
+                        loadEventDates: function (_refDate = false) {
+                            let today = new Date(_refDate ? _refDate : '{{date('Y-m-d')}}'),
+                                firstOfMonth = new Date(today.getFullYear(), today.getMonth(), 1),
+                                lastOfMonth = new Date(today.getFullYear(), today.getMonth() + 1, 0);
+
+                            this.selectedDate = null;
+                            $('td.day.active').removeClass('active');
+
+                            $.get('/pro-dashboard-event-dates/' +
+                                this.formatDate(firstOfMonth) + '/' +
+                                this.formatDate(lastOfMonth), (_data) => {
+                                this.datesWithEvents = _data;
+                                console.log(this.datesWithEvents);
+                                this.calendarElem.datepicker('refresh');
+                                // this.highlightDatesWithEvents(this.datesWithEvents);
+
+                                this.currentMonth = firstOfMonth.getMonth();
+                                this.currentYear = firstOfMonth.getFullYear();
+
+                                if (!_refDate && $('td.day[data-date="{{$milliseconds}}"]:visible').length) {
+                                    $('td.day[data-date="{{$milliseconds}}"]:visible').first().click();
+                                }
+
+                                this.appointmentsLoaded = true;
+                            }, 'json');
+                        },
+                        loadEvents: function (_date, _callback) {
+                            let self = this;
+                            $.get('/pro-dashboard-events/' + _date + '/' + _date, function (_data) {
+                                self.events = _data;
+                                self.numEventsForDate = (_data && _data.length) ? 1 : 0;
+                                _callback.call(self);
+                            }, 'json');
+                        },
+                        updateMeasurements: function () {
+                            $.get('/pro-dashboard-measurements/' + this.measurementFilterStatus, (_data) => {
+                                this.measurements = _data;
+                                Vue.nextTick(() => {
+                                    // this.initCMRTE();
+                                    $('#pro-dashboard-container').find('[moe][initialized]').removeAttr('initialized');
+                                    initMoes();
+                                });
+                            }, 'json');
+                        },
+                        setMeasurementStatus: function (_uid, _status) {
+                            $.post('/api/measurement/updateStatus', {
+                                uid: _uid,
+                                status: _status
+                            }, (_data) => {
+                                this.updateMeasurements();
+                            }, 'json');
+                        },
+                        initCMRTE: function () {
+                            $('#pro-dashboard-container [cm-rte]').each(function () {
+
+                                $(this).wrap(
+                                    $('<div class="border-left border-right rte-holder"/>')
+                                        .attr('data-shortcuts', '')
+                                );
+
+                                // give a unique id to this editor instance
+                                var editorID = Math.ceil(Math.random() * 99999), fieldName = $(this).attr('data-name');
+
+                                var el = this;
+                                var existingContent = $(el).attr('data-content');
+                                var quill = new Quill(el, {
+                                    theme: 'snow',
+                                    modules: stagQuillConfig
+                                });
+
+                                var toolbar = $(quill.container).prev('.ql-toolbar');
+
+                                // add button for new shortcut
+                                var newSCButton = $('<button class="btn bg-white btn-sm btn-default text-primary w-auto px-2 border py-0 ' +
+                                    'text-sm add-shortcut" data-editor-id="' + editorID + '">+ Shortcut</button>');
+                                toolbar.append(newSCButton);
+
+                                quill.root.innerHTML = existingContent;
+
+                                $('<input type="hidden" name="' + fieldName + '">').val(existingContent).insertAfter(el);
+
+                                quill.on('text-change', function (delta, oldDelta, source) {
+                                    $(el).next('[name="' + fieldName + '"]').val(quill.root.innerHTML);
+                                });
+
+                                $(quill.container)
+                                    .find('.ql-editor[contenteditable]')
+                                    .attr('data-field', fieldName)
+                                    .attr('data-editor-id', editorID)
+                                    .attr('with-shortcuts', 1);
+
+                            })
+                        },
+                        initLoadAppointments: function () {
+                            if (this.appointmentsLoaded) return false;
+                            this.loadEventDates();
+                        },
+                        loadMeasurements: function () {
+                            $('#measurements-tab').load('/pro-dashboard-measurements-tab', () => {
+                                initMoes();
+                                initFastLoad($('#measurements-tab'));
+                            });
+                        }
+                    },
+                    mounted: function () {
+                        let self = this;
+                        this.calendarElem = $('.pro-dashboard-inline-calendar');
+                        this.calendarElem.datepicker({
+                            dateFormat: 'yy-mm-dd',
+                            onSelect: function (_date) {
+                                self.onDateChange(_date);
+                            },
+                            onChangeMonthYear: function (_year, _month) {
+                                let date = _year + '-' + (_month < 10 ? '0' : '') + _month + '-05';
+                                self.loadEventDates(date);
+                            },
+                            beforeShowDay: function (d) {
+                                if (self.datesWithEvents && self.datesWithEvents.indexOf(self.formatDate(d)) !== -1) {
+                                    return [true, 'has-events'];
+                                }
+                                return [true, 'no-events'];
+                            }
+                        });
+                        // this.calendarElem
+                        //     .on('changeDate', function () {
+                        //         self.onDateChange(self.calendarElem.datepicker('getFormattedDate'));
+                        //     })
+                        //     .on('changeMonth', function () {
+                        //         window.setTimeout(function() {
+                        //             let ts = $('td.day[data-date]').first().closest('tr').find('td.day[data-date]').last().attr('data-date');
+                        //             if(ts) {
+                        //                 self.loadEventDates(ts);
+                        //             }
+                        //         }, 10);
+                        //     });
+
+
+                        $('#pro-dashboard-container').find('[moe][initialized]').removeAttr('initialized');
+                        initMoes();
+
+                        // init fast load
+                        initFastLoad($('#pro-dashboard-container'));
+
+                        $(document)
+                            .off('click', '.dashboard-measurements.pagination a.page-link')
+                            .on('click', '.dashboard-measurements.pagination a.page-link', function () {
+                                $('#measurements-tab').text('Loading...').load('/pro-dashboard-measurements-tab/' + $(this).attr('data-target-page'), () => {
+                                    initMoes();
+                                    initFastLoad($('#measurements-tab'));
+                                });
+                                return false;
+                            });
+
+                        this.loadMeasurements();
+                    }
+                });
+                /*// refresh once ticket popup is closed
+                $('body').off('stag-popup-closed')
+                $('body').on('stag-popup-closed', function() {
+                    if($('#pro-dashboard-container').length) {
+                        let activeTab = $('.nav-link.active[data-tab]').attr('data-tab');
+                        if(activeTab) {
+                            fastLoad('/?tab=' + activeTab);
+                        }
+                    }
+                });*/
+                // ticket-popup
+                $(document)
+                    .off('click', '.ticket-popup-trigger')
+                    .on('click', '.ticket-popup-trigger', function () {
+                        showMask();
+                        window.noMc = true;
+                        $.get(this.href, (_data) => {
+                            $('.ticket-popup').html(_data);
+                            showStagPopup('ticket-popup');
+                            $('.ticket-popup .stag-popup.stag-slide').attr('close-all-with-self', 1);
+                            runMCInitializer('patient-tickets'); // run specific mc initer
+                            hideMask();
+                        });
+                        return false;
+                    });
+
+                $(document)
+                    .off('click', '.ack-client-pro-change')
+                    .on('click', '.ack-client-pro-change', function () {
+                        let trigger = $(this).text('…');
+                        $.post('/api/clientProChange/accept', {
+                            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 ackContainer = trigger.closest('.ack-container');
+                                    trigger.closest('div').slideUp('fast', function () {
+                                        $(this).remove();
+                                        if (!ackContainer.find('>div').length) {
+                                            ackContainer.remove();
+                                        }
+                                    });
+                                }, 500);
+                            }
+                        }, '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;
+                    });
+
+                $(document)
+                    .off('click', '.ack-pro-appt-update')
+                    .on('click', '.ack-pro-appt-update', function () {
+                        let trigger = $(this).text('…');
+                        $.post('/api/appointmentConfirmationDecision/acknowledgeAsAppointmentPro', {
+                            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 ackContainer = trigger.closest('tbody');
+                                    trigger.closest('tr').slideUp('fast', function () {
+                                        $(this).remove();
+                                        if (!ackContainer.find('>tr').length) {
+                                            ackContainer.remove();
+                                        }
+                                    });
+                                }, 500);
+                            }
+                        }, 'json');
+                        return false;
+                    });
+
+                $(document)
+                    .off('click', '.ack-na-appt-update')
+                    .on('click', '.ack-na-appt-update', function () {
+                        let trigger = $(this).text('…');
+                        $.post('/api/appointmentConfirmationDecision/acknowledgeAsClientDefaultNa', {
+                            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 ackContainer = trigger.closest('tbody');
+                                    trigger.closest('tr').slideUp('fast', function () {
+                                        $(this).remove();
+                                        if (!ackContainer.find('>tr').length) {
+                                            ackContainer.remove();
+                                        }
+                                    });
+                                }, 500);
+                            }
+                        }, 'json');
+                        return false;
+                    });
+            }
+
+            addMCInitializer('pro-dashboard', init, '#pro-dashboard-container');
+        })();
+    </script>
+@endsection

+ 918 - 0
resources/views/app/dashboard-dna.blade.php

@@ -0,0 +1,918 @@
+@extends ('layouts.template')
+
+@section('content')
+
+    <style>
+        tr.thin th, tr.thin td {
+            padding: 0.25em;
+        }
+    </style>
+
+    <div class="p-3">
+        <div class="">
+            <div class="row mcp-theme-1" id="pro-dashboard-container" v-cloak>
+                <div class="col-md-3 mcp-theme-1">
+                    <div class="mb-4" v-show="tab==='appointments'">
+                        <div class="pro-dashboard-inline-calendar"></div>
+                    </div>
+                    <div class="card mb-4">
+                        <div class="card-header pl-2">
+                            <strong>
+                                Key Numbers
+                            </strong>
+                        </div>
+                        <div class="card-body p-0">
+                            <table class="table mb-0 dashboard-stats-table">
+                                <tbody>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_patients_count_as_mcp()}}</th>
+                                    <th class="pl-2">Patients</th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_new_patients_awaiting_visit_count_as_mcp()}}</th>
+                                    <th class="pl-2">New Patients Awaiting Visit</th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_notes_pending_signature_count_as_mcp()}}</th>
+                                    <th class="pl-2">Notes Pending Signature</th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_notes_pending_billing_count_as_mcp()}}</th>
+                                    <th class="pl-2">Notes Pending Billing</th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_incoming_reports_pending_signature_count_as_mcp()}}</th>
+                                    <th class="pl-2">Reports Pending Signature</th>
+                                </tr>
+
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_patients_without_appointment_count_as_mcp()}}</th>
+                                    <th class="pl-2">Patients w/o Appointments</th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_patients_not_seen_in_45_days_count_as_mcp()}}</th>
+                                    <th class="pl-2">Patients Not Seen in 45 Days</th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_cancelled_appointments_pending_acknowledgement_count_as_mcp()}}</th>
+                                    <th class="pl-2">Cancelled Appts. Pending Review</th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_cancelled_bills_awaiting_review_count_as_mcp()}}</th>
+                                    <th class="pl-2">Cancelled Bills Pending Review</th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_cancelled_supply_orders_awaiting_review_count_as_mcp()}}</th>
+                                    <th class="pl-2">Cancelled Supply Orders Pending Review</th>
+                                </tr>
+
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_erx_and_orders_awaiting_signature_count_as_mcp()}}</th>
+                                    <th class="pl-2">ERx & Orders Pending Signature</th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_supply_orders_awaiting_signature_count_as_mcp()}}</th>
+                                    <th class="pl-2">Supply Orders Pending Signature</th>
+                                </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">{{$pro->get_measurements_awaiting_review_count_as_mcp() ?? '-'}}</th>
+                                    <th class="pl-2">Measurements Pending Review</th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_patients_without_remote_measurement_in_48_hours_count_as_mcp() ?? '-'}}</th>
+                                    <th class="pl-2">Patients w/o Measurement in 48 hrs.</th>
+                                </tr>
+                                </tbody>
+                            </table>
+                        </div>
+                    </div>
+                    <div class="card mb-4">
+                        <div class="card-header pl-2">
+                            <strong>
+                                Practice Management
+                            </strong>
+                        </div>
+                        <div class="card-body p-0">
+                            <table class="table mb-0 dashboard-stats-table">
+                                <tbody>
+                                <tr>
+                                    <th colspan="2">Revenue Cycle Management</th>
+                                </tr>
+                                <tr class="thin">
+                                    <th class="font-weight-normal px-2 pl-4">
+                                        ${{friendly_money($reimbursement['currentBalance'])}}</th>
+                                    <th class="font-weight-normal pl-2 w-100"><a
+                                            href="/practice-management/financial-transactions">Current balance</a></th>
+                                </tr>
+                                <!-- <tr>
+                                    <th class="px-2">{{friendly_date_time($reimbursement['nextPaymentDate'], false)}}</th>
+                                    <th class="pl-2">Next Payment Date</th>
+                                </tr> -->
+                                <tr class="thin">
+                                    <th class="font-weight-normal px-2 pl-4">${{friendly_money($reimbursement['nextPaymentAmount'])}}</th>
+                                    <th class="font-weight-normal pl-2"><a
+                                            href="/practice-management/bills-under-processing">Processing</a></th>
+                                </tr>
+                                <tr class="thin">
+                                    <th class="font-weight-normal px-2 pl-5">${{friendly_money($reimbursement['nextPaymentAmount'])}}</th>
+                                    <th class="font-weight-normal pl-2"><a
+                                            href="/practice-management/bills-under-processing">Treatment Services</a></th>
+                                </tr>
+                                <tr class="thin">
+                                    <th class="font-weight-normal px-2 pl-5">${{friendly_money($reimbursement['nextPaymentAmount'])}}</th>
+                                    <th class="font-weight-normal pl-2"><a
+                                            href="/practice-management/bills-under-processing">Remote Monitoring</a></th>
+                                </tr>
+                                <tr class="thin">
+                                    <th class="font-weight-normal px-2 pl-5">${{friendly_money($reimbursement['nextPaymentAmount'])}}</th>
+                                    <th class="font-weight-normal pl-2"><a
+                                            href="/practice-management/bills-under-processing">Other Services</a></th>
+                                </tr>
+                                {{--
+                                <tr>
+                                    <th class="px-2">{{$reimbursement['lastPayment']}}</th>
+                                    <th class="pl-2"><a href="/practice-management/financial-transactions">Last payment</a></th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2">{{friendly_date_time($reimbursement['lastPaymentDate'], false)}}</th>
+                                    <th class="pl-2"><a href="/practice-management/financial-transactions">Last payment date</a></th>
+                                </tr>
+                                --}}
+                                </tbody>
+                            </table>
+                        </div>
+                    </div>
+                    @if($pro->pro_type === 'ADMIN')
+                        <div class="card mb-4">
+                            <div class="card-header pl-2">
+                                <strong>
+                                    Bills &amp; Claims
+                                </strong>
+                            </div>
+                            <div class="card-body p-0">
+                                <table class="table mb-0 dashboard-stats-table">
+                                    <tbody>
+
+                                    <tr>
+                                        <th class="border-top-1 px-2 text-center">{{$businessNumbers['notesWithBillsToResolve']}}</th>
+                                        <th class="border-top-1 pl-2">
+                                            <a href="/practice-management/billing-manager">Notes with bills to
+                                                resolve</a>
+                                        </th>
+                                    </tr>
+                                    <tr>
+                                        <th class="border-top-1 px-2 text-center">{{$businessNumbers['notesPendingBillingClosure']}}</th>
+                                        <th class="border-top-1 pl-2">
+                                            <a href="/practice-management/billing-manager">Notes pending billing
+                                                closure</a>
+                                        </th>
+                                    </tr>
+                                    </tbody>
+                                </table>
+                            </div>
+                        </div>
+                    @endif
+                </div>
+                <div class="col-md-9">
+
+                    <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="d-flex align-items-start bg-light mb-2 px-2 py-1">
+                                            <div class="flex-grow-1">
+                                                You are now the MCP for
+                                                <a href="/patients/view/{{$assoc->patient->uid}}"
+                                                   class="">{{$assoc->patient->displayName()}}</a>
+                                                <?php $nextAppt = $assoc->patient->nextAppointment(); ?>
+                                                @if($nextAppt)
+                                                    <div class="font-size-11">
+                                                        <span class="text-secondary font-size-11">Appt.</span>
+                                                        {{$nextAppt->pro->displayName()}}
+                                                        <span class="text-secondary font-size-11">on</span>
+                                                        {{friendlier_date_time($nextAppt->raw_date . ' ' . $nextAppt->raw_start_time)}}
+                                                    </div>
+                                                    @if($nextAppt->status === 'PENDING') {{-- WIP: ALIX overhaul --}}
+                                                        <div
+                                                            class="text-warning-mellow font-weight-bold font-size-11 mt-1">
+                                                            <i class="fa fa-exclamation-triangle"></i>
+                                                            Confirmation pending
+                                                        </div>
+                                                    @endif
+                                                    @if($nextAppt->status === 'CONFIRMED')
+                                                        <div class="text-success font-weight-bold font-size-11 mt-1">
+                                                            <i class="fa fa-check"></i>
+                                                            Confirmed by the patient
+                                                        </div>
+                                                    @endif
+                                                    @if($nextAppt->status === 'CANCELLED')
+                                                        <div class="text-danger font-weight-bold font-size-11 mt-1">
+                                                            <i class="fa fa-stop"></i>
+                                                            Cancelled
+                                                        </div>
+                                                    @endif
+                                                @endif
+                                            </div>
+                                            <a href="#" class="ack-client-pro-change ml-3" data-uid="{{$assoc->uid}}">Stamp</a>
+                                        </div>
+                                    @endforeach
+                                </div>
+                            @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="d-flex align-items-start bg-light mb-2 px-2 py-1">
+                                            <div class="flex-grow-1">
+                                                You are now the Care Coordinator for
+                                                <a href="/patients/view/{{$assoc->patient->uid}}"
+                                                   class="">{{$assoc->patient->displayName()}}</a>
+                                                <?php $nextAppt = $assoc->patient->nextAppointment(); ?>
+                                                @if($nextAppt)
+                                                    <div class="font-size-11">
+                                                        <span class="text-secondary font-size-11">Appt.</span>
+                                                        {{$nextAppt->pro->displayName()}}
+                                                        <span class="text-secondary font-size-11">on</span>
+                                                        {{friendlier_date_time($nextAppt->raw_date . ' ' . $nextAppt->raw_start_time)}}
+                                                    </div>
+                                                    @if($nextAppt->status === 'PENDING')
+                                                        <div
+                                                            class="text-warning-mellow font-weight-bold font-size-11 mt-1">
+                                                            <i class="fa fa-exclamation-triangle"></i>
+                                                            Confirmation pending
+                                                        </div>
+                                                    @endif
+                                                    @if($nextAppt->status === 'CONFIRMED')
+                                                        <div class="text-success font-weight-bold font-size-11 mt-1">
+                                                            <i class="fa fa-check"></i>
+                                                            Confirmed by the patient
+                                                        </div>
+                                                    @endif
+                                                    @if($nextAppt->status === 'CANCELLED')
+                                                        <div class="text-danger font-weight-bold font-size-11 mt-1">
+                                                            <i class="fa fa-stop"></i>
+                                                            Cancelled
+                                                        </div>
+                                                    @endif
+                                                @endif
+                                            </div>
+                                            <a href="#" class="ack-client-pro-change"
+                                               data-uid="{{$assoc->uid}}">Stamp</a>
+                                        </div>
+                                    @endforeach
+                                </div>
+                            @endif
+                        </div>
+                        <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">
+                            <a native data-tab="appointments" class="nav-link"
+                               :class="tab == 'appointments' ? 'active' : ''" href="#"
+                               v-on:click.prevent="tab='appointments'; initLoadAppointments();">
+                                Appointments
+                            </a>
+                        </li>
+                        <li class="nav-item">
+                            <a native data-tab="measurements" class="nav-link"
+                               :class="tab == 'measurements' ? 'active' : ''" href="#"
+                               v-on:click.prevent="tab='measurements'; loadMeasurements();">
+                                Measurements
+                            </a>
+                        </li>
+                        <li class="nav-item">
+                            <a native data-tab="incoming_reports"
+                               class="nav-link {{count($incomingReports) ? 'text-danger font-weight-bold' : ''}}"
+                               :class="tab == 'incoming_reports' ? 'active' : ''" href="#"
+                               v-on:click.prevent="tab='incoming_reports'">
+                                Incoming Reports ({{count($incomingReports)}})
+                            </a>
+                        </li>
+                        <li class="nav-item">
+                            <a native data-tab="erx" class="nav-link {{$numERx ? 'text-danger font-weight-bold' : ''}}"
+                               :class="tab == 'erx' ? 'active' : ''" href="#"
+                               v-on:click.prevent="tab='erx'">
+                                ERx ({{$numERx}})
+                            </a>
+                        </li>
+                        <li class="nav-item">
+                            <a native data-tab="labs"
+                               class="nav-link {{$numLabs ? 'text-danger font-weight-bold' : ''}}"
+                               :class="tab == 'labs' ? 'active' : ''" href="#"
+                               v-on:click.prevent="tab='labs'">
+                                Labs ({{$numLabs}})
+                            </a>
+                        </li>
+                        <li class="nav-item">
+                            <a native data-tab="imaging"
+                               class="nav-link {{$numImaging ? 'text-danger font-weight-bold' : ''}}"
+                               :class="tab == 'imaging' ? 'active' : ''" href="#"
+                               v-on:click.prevent="tab='imaging'">
+                                Imaging ({{$numImaging}})
+                            </a>
+                        </li>
+                        <li class="nav-item">
+                            <a native data-tab="supply_orders"
+                               class="nav-link {{$numSupplyOrders ? 'text-danger font-weight-bold' : ''}}"
+                               :class="tab == 'supply_orders' ? 'active' : ''" href="#"
+                               v-on:click.prevent="tab='supply_orders'">
+                                Supply Orders ({{$numSupplyOrders}})
+                            </a>
+                        </li>
+                    </ul>
+
+                    <div class="border-left border-right border-bottom p-3">
+                        <div v-show="tab==='appointments'" class="appointments-tab">
+                            <div v-show="selectedDate">
+                                <div class="d-flex align-items-end mb-3">
+                                    <b class="large"><span class="text-secondary">Today:</span> @{{ selectedDate }}</b>
+                                    <div class="ml-auto d-inline-flex align-items-center">
+                                        <label class="text-secondary mr-2 my-0 text-nowrap">Filter by status:</label>
+                                        <select v-model="filterStatus"
+                                                class="form-control form-control-sm">
+                                            <option value="">All</option>
+                                            <option value="PENDING">Pending</option>
+                                            <option value="CONFIRMED">Confirmed</option>
+                                            <option value="CANCELLED">Cancelled</option>
+                                            <option value="COMPLETED">Completed</option>
+                                        </select>
+                                    </div>
+                                </div>
+                                <div v-for="event in events" class="align-items-end p-3 border rounded mb-3"
+                                     :class="(event.dateYMD === selectedDate && (filterStatus === '' || filterStatus === event.status) ? 'd-flex' : 'd-none') + ' ' + (event.isClientShadowOfPro ? 'training-event' : '')">
+                                    <div class="patient-avatar mr-3 align-self-center">
+                                        <i v-if="event.isClientShadowOfPro" class="fa fa-graduation-cap training-icon"
+                                           :title="event.proInitials"></i>
+                                        <span v-else class="">@{{ event.proInitials }}</span>
+                                    </div>
+                                    <div>
+                                        <div class="pb-1">
+                                            <b class="text-info">@{{ event.proName }}</b>
+                                            &nbsp;/&nbsp;
+                                            @{{ event.friendlyStartTime }} - @{{ event.friendlyEndTime }} <span
+                                                class="text-secondary">@{{ event.timezone }}</span>
+                                            &nbsp;/&nbsp;
+                                            <span class="d-inline-block ml- 2 text-secondary font-weight-bold">@{{ event.title }}</span>
+                                        </div>
+                                        <div class="pb-1">
+                                            <a :href="'/patients/view/' + event.clientUid" class="font-weight-bold">@{{
+                                                event.clientName }}</a>
+                                            <span class="small d-inline-block pl-2 text-secondary font-weight-normal">@{{ event.clientSummary }}</span>
+                                        </div>
+                                        <div class="d-flex align-items-baseline">
+                                            <div v-if="event.status === 'PENDING'"
+                                                 class="text-warning-mellow font-weight-bold">
+                                                <i class="fa fa-exclamation-triangle"></i>
+                                                Confirmation pending
+                                            </div>
+                                            <div v-else-if="event.status === 'CONFIRMED'"
+                                                 class="text-success font-weight-bold">
+                                                <i class="fa fa-check"></i>
+                                                Confirmed by the patient
+                                            </div>
+                                            <div v-else-if="event.status === 'CANCELLED'"
+                                                 class="text-danger font-weight-bold">
+                                                <i class="fa fa-stop"></i>
+                                                Cancelled
+                                            </div>
+                                            <div v-else class="text-secondary">
+                                                Status: <b>@{{ event.status }}</b>
+                                            </div>
+                                            <span class="mx-2 text-secondary">|</span>
+                                            <a :href="'/patients/view/' + event.clientUid + '/calendar/' + event.uid">
+                                                <i class="fa fa-edit"></i>
+                                                Edit Appointment
+                                            </a>
+                                        </div>
+                                        <div class="mt-1"
+                                             :class="event.coverage !== 'YES' ? (event.coverage === 'NO' ? 'text-danger' : 'text-warning-mellow') : 'text-success'">
+                                            Coverage Status: <b>@{{ event.coverage }}</b>
+                                        </div>
+                                    </div>
+                                    <div class="ml-auto">
+                                        <select v-model="event.newStatus"
+                                                class="form-control form-control-sm bg-light"
+                                                v-on:change="updateStatus(event)">
+                                            <option value="PENDING">PENDING</option>
+                                            <option value="CONFIRMED">CONFIRMED</option>
+                                            <option value="CANCELLED">CANCELLED</option>
+                                            <option value="COMPLETED">COMPLETED</option>
+                                        </select>
+                                        <div v-if="selectedDate === '{{ date('Y-m-d') }}'"
+                                             class="pt-1 text-right"
+                                             :class="event.started ? 'text-danger': 'text-secondary'">
+                                            @{{ event.inHowManyHours }}
+                                        </div>
+                                    </div>
+                                </div>
+                                <div v-if="numEventsForDate === 0" class="bg-light p-3 text-secondary border bounded">
+                                    <span
+                                        v-if="filterStatus === ''">You have no appointments on <b>@{{ selectedDate }}</b></span>
+                                    <span
+                                        v-if="filterStatus !== ''">You have no appointments on <b>@{{ selectedDate }}</b> with status <b>@{{ filterStatus }}</b></span>
+                                </div>
+                            </div>
+                            <div v-show="!selectedDate" class="bg-light p-3 text-secondary border bounded">
+                                Please select a date from the calendar on the left
+                            </div>
+                        </div>
+                        <div v-show="tab==='measurements'">
+                            <div id="measurements-tab">Loading...</div>
+                        </div>
+                        <div v-show="tab==='incoming_reports'">
+                            @include('app.dashboard.incoming_reports')
+                        </div>
+                        <div v-show="tab==='erx'">
+                            @include('app.dashboard.erx')
+                        </div>
+                        <div v-show="tab==='labs'">
+                            @include('app.dashboard.labs')
+                        </div>
+                        <div v-show="tab==='imaging'">
+                            @include('app.dashboard.imaging')
+                        </div>
+                        <div v-show="tab==='supply_orders'">
+                            @include('app.dashboard.supply_orders')
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+
+    <div class="stag-popup stag-popup-md ticket-popup mcp-theme-1" stag-popup-key="ticket-popup"></div>
+
+    <script>
+        (function () {
+            function init() {
+                window.apapp = new Vue({
+                    el: '#pro-dashboard-container',
+                    delimiters: ['@{{', '}}'],
+                    data: {
+                        tab: '{{ request()->input('tab') ? request()->input('tab') : 'measurements' }}',
+                        datesWithEvents: [],
+                        selectedDate: '{{ date('Y-m-d') }}',
+                        selectedStatus: 'PENDING',
+                        events: [],
+                        numEventsForDate: 0,
+                        filterStatus: '',
+                        calendarElem: null,
+                        currentMonth: null,
+                        currentYear: null,
+                        measurementFilterStatus: 'ALL',
+                        measurements: {!! $pro->pro_type === 'ADMIN' ? '[]' : json_encode($pro->getMeasurements()) !!},
+                        appointmentsLoaded: false,
+                    },
+                    methods: {
+                        formatDate: function (date) {
+                            let d = new Date(date),
+                                month = '' + (d.getMonth() + 1),
+                                day = '' + d.getDate(),
+                                year = d.getFullYear();
+
+                            if (month.length < 2)
+                                month = '0' + month;
+                            if (day.length < 2)
+                                day = '0' + day;
+
+                            return [year, month, day].join('-');
+                        },
+                        onDateChange: function (_newDate) {
+                            let self = this;
+                            window.setTimeout(() => {
+                                // let dayValue = $('.pro-dashboard-inline-calendar td.day.active').first().text();
+                                // if(dayValue.length === 1) dayValue = '0' + dayValue;
+                                // self.selectedDate = _newDate.substr(0, 8) + dayValue;
+                                self.selectedDate = _newDate;
+                                showMask();
+                                self.loadEvents(self.selectedDate, function () {
+                                    hideMask();
+                                    Vue.nextTick(() => {
+                                        // self.highlightDatesWithEvents(self.datesWithEvents);
+                                        initFastLoad($('.appointments-tab'));
+                                    });
+                                });
+                            }, 25);
+                        },
+                        selectToday: function () {
+                            $('.pro-dashboard-inline-calendar table td[data-date]').removeClass('active');
+                            $('.pro-dashboard-inline-calendar table td[data-date="{{ $milliseconds }}"]')
+                                .addClass('active');
+                            // this.onDateChange('{{ date('Y-m-d') }}');
+                        },
+                        highlightDatesWithEvents: function (_dates) {
+                            $('.pro-dashboard-inline-calendar table td[data-date]').removeAttr('has-events');
+                            for (let i = 0; i < _dates.length; i++) {
+                                $('.pro-dashboard-inline-calendar table td[data-date="' + _dates[i] + '"]')
+                                    .attr('has-events', 1);
+                            }
+                        },
+                        updateStatus: function (_event) {
+                            $.post('/api/appointment/updateStatus', {
+                                uid: _event.uid,
+                                status: _event.newStatus
+                            }, function (_data) {
+                                if (!_data) {
+                                    toastr.error('Unable to update appointment status!');
+                                } else {
+                                    if (!_data.success) {
+                                        toastr.error(_data.message);
+                                    } else {
+                                        _event.status = _event.newStatus;
+                                        toastr.success('The appointment has been updated');
+                                    }
+                                }
+                            }, 'json')
+                        },
+                        showEditForm: function (_trigger) {
+                            let form = $(_trigger).closest('[moe]').find('form').first();
+                            showMoeFormMask();
+                            form.show();
+                            setTimeout(function () {
+                                initPrimaryForm(form);
+                            }, 0);
+                        },
+                        submitEditForm: function (_trigger) {
+                            let form = $(_trigger).closest('[moe]').find('form').first();
+                            if (!form[0].checkValidity()) {
+                                form[0].reportValidity();
+                                return;
+                            }
+                            $.post(form.attr('url'), form.serialize(), function (_data) {
+                                if (_data && _data.success) {
+                                    fastReload();
+                                } else {
+                                    if (_data.message) {
+                                        toastr.error(_data.message);
+                                    } else {
+                                        toastr.error('Unable to update the appointment');
+                                    }
+                                }
+                            });
+                        },
+                        cancelEditForm: function (_trigger) {
+                            let form = $(_trigger).closest('[moe]').find('form').first();
+                            hideMoeFormMask();
+                            form.hide();
+                        },
+                        loadEventDates: function (_refDate = false) {
+                            let today = new Date(_refDate ? _refDate : '{{date('Y-m-d')}}'),
+                                firstOfMonth = new Date(today.getFullYear(), today.getMonth(), 1),
+                                lastOfMonth = new Date(today.getFullYear(), today.getMonth() + 1, 0);
+
+                            this.selectedDate = null;
+                            $('td.day.active').removeClass('active');
+
+                            $.get('/pro-dashboard-event-dates/' +
+                                this.formatDate(firstOfMonth) + '/' +
+                                this.formatDate(lastOfMonth), (_data) => {
+                                this.datesWithEvents = _data;
+                                console.log(this.datesWithEvents);
+                                this.calendarElem.datepicker('refresh');
+                                // this.highlightDatesWithEvents(this.datesWithEvents);
+
+                                this.currentMonth = firstOfMonth.getMonth();
+                                this.currentYear = firstOfMonth.getFullYear();
+
+                                if (!_refDate && $('td.day[data-date="{{$milliseconds}}"]:visible').length) {
+                                    $('td.day[data-date="{{$milliseconds}}"]:visible').first().click();
+                                }
+
+                                this.appointmentsLoaded = true;
+                            }, 'json');
+                        },
+                        loadEvents: function (_date, _callback) {
+                            let self = this;
+                            $.get('/pro-dashboard-events/' + _date + '/' + _date, function (_data) {
+                                self.events = _data;
+                                self.numEventsForDate = (_data && _data.length) ? 1 : 0;
+                                _callback.call(self);
+                            }, 'json');
+                        },
+                        updateMeasurements: function () {
+                            $.get('/pro-dashboard-measurements/' + this.measurementFilterStatus, (_data) => {
+                                this.measurements = _data;
+                                Vue.nextTick(() => {
+                                    // this.initCMRTE();
+                                    $('#pro-dashboard-container').find('[moe][initialized]').removeAttr('initialized');
+                                    initMoes();
+                                });
+                            }, 'json');
+                        },
+                        setMeasurementStatus: function (_uid, _status) {
+                            $.post('/api/measurement/updateStatus', {
+                                uid: _uid,
+                                status: _status
+                            }, (_data) => {
+                                this.updateMeasurements();
+                            }, 'json');
+                        },
+                        initCMRTE: function () {
+                            $('#pro-dashboard-container [cm-rte]').each(function () {
+
+                                $(this).wrap(
+                                    $('<div class="border-left border-right rte-holder"/>')
+                                        .attr('data-shortcuts', '')
+                                );
+
+                                // give a unique id to this editor instance
+                                var editorID = Math.ceil(Math.random() * 99999), fieldName = $(this).attr('data-name');
+
+                                var el = this;
+                                var existingContent = $(el).attr('data-content');
+                                var quill = new Quill(el, {
+                                    theme: 'snow',
+                                    modules: stagQuillConfig
+                                });
+
+                                var toolbar = $(quill.container).prev('.ql-toolbar');
+
+                                // add button for new shortcut
+                                var newSCButton = $('<button class="btn bg-white btn-sm btn-default text-primary w-auto px-2 border py-0 ' +
+                                    'text-sm add-shortcut" data-editor-id="' + editorID + '">+ Shortcut</button>');
+                                toolbar.append(newSCButton);
+
+                                quill.root.innerHTML = existingContent;
+
+                                $('<input type="hidden" name="' + fieldName + '">').val(existingContent).insertAfter(el);
+
+                                quill.on('text-change', function (delta, oldDelta, source) {
+                                    $(el).next('[name="' + fieldName + '"]').val(quill.root.innerHTML);
+                                });
+
+                                $(quill.container)
+                                    .find('.ql-editor[contenteditable]')
+                                    .attr('data-field', fieldName)
+                                    .attr('data-editor-id', editorID)
+                                    .attr('with-shortcuts', 1);
+
+                            })
+                        },
+                        initLoadAppointments: function () {
+                            if (this.appointmentsLoaded) return false;
+                            this.loadEventDates();
+                        },
+                        loadMeasurements: function () {
+                            $('#measurements-tab').load('/pro-dashboard-measurements-tab', () => {
+                                initMoes();
+                                initFastLoad($('#measurements-tab'));
+                            });
+                        }
+                    },
+                    mounted: function () {
+                        let self = this;
+                        this.calendarElem = $('.pro-dashboard-inline-calendar');
+                        this.calendarElem.datepicker({
+                            dateFormat: 'yy-mm-dd',
+                            onSelect: function (_date) {
+                                self.onDateChange(_date);
+                            },
+                            onChangeMonthYear: function (_year, _month) {
+                                let date = _year + '-' + (_month < 10 ? '0' : '') + _month + '-05';
+                                self.loadEventDates(date);
+                            },
+                            beforeShowDay: function (d) {
+                                if (self.datesWithEvents && self.datesWithEvents.indexOf(self.formatDate(d)) !== -1) {
+                                    return [true, 'has-events'];
+                                }
+                                return [true, 'no-events'];
+                            }
+                        });
+                        // this.calendarElem
+                        //     .on('changeDate', function () {
+                        //         self.onDateChange(self.calendarElem.datepicker('getFormattedDate'));
+                        //     })
+                        //     .on('changeMonth', function () {
+                        //         window.setTimeout(function() {
+                        //             let ts = $('td.day[data-date]').first().closest('tr').find('td.day[data-date]').last().attr('data-date');
+                        //             if(ts) {
+                        //                 self.loadEventDates(ts);
+                        //             }
+                        //         }, 10);
+                        //     });
+
+
+                        $('#pro-dashboard-container').find('[moe][initialized]').removeAttr('initialized');
+                        initMoes();
+
+                        // init fast load
+                        initFastLoad($('#pro-dashboard-container'));
+
+                        $(document)
+                            .off('click', '.dashboard-measurements.pagination a.page-link')
+                            .on('click', '.dashboard-measurements.pagination a.page-link', function () {
+                                $('#measurements-tab').text('Loading...').load('/pro-dashboard-measurements-tab/' + $(this).attr('data-target-page'), () => {
+                                    initMoes();
+                                    initFastLoad($('#measurements-tab'));
+                                });
+                                return false;
+                            });
+
+                        this.loadMeasurements();
+                    }
+                });
+                /*// refresh once ticket popup is closed
+                $('body').off('stag-popup-closed')
+                $('body').on('stag-popup-closed', function() {
+                    if($('#pro-dashboard-container').length) {
+                        let activeTab = $('.nav-link.active[data-tab]').attr('data-tab');
+                        if(activeTab) {
+                            fastLoad('/?tab=' + activeTab);
+                        }
+                    }
+                });*/
+                // ticket-popup
+                $(document)
+                    .off('click', '.ticket-popup-trigger')
+                    .on('click', '.ticket-popup-trigger', function () {
+                        showMask();
+                        window.noMc = true;
+                        $.get(this.href, (_data) => {
+                            $('.ticket-popup').html(_data);
+                            showStagPopup('ticket-popup');
+                            $('.ticket-popup .stag-popup.stag-slide').attr('close-all-with-self', 1);
+                            runMCInitializer('patient-tickets'); // run specific mc initer
+                            hideMask();
+                        });
+                        return false;
+                    });
+
+                $(document)
+                    .off('click', '.ack-client-pro-change')
+                    .on('click', '.ack-client-pro-change', function () {
+                        let trigger = $(this).text('…');
+                        $.post('/api/clientProChange/accept', {
+                            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 ackContainer = trigger.closest('.ack-container');
+                                    trigger.closest('div').slideUp('fast', function () {
+                                        $(this).remove();
+                                        if (!ackContainer.find('>div').length) {
+                                            ackContainer.remove();
+                                        }
+                                    });
+                                }, 500);
+                            }
+                        }, '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;
+                    });
+
+                $(document)
+                    .off('click', '.ack-pro-appt-update')
+                    .on('click', '.ack-pro-appt-update', function () {
+                        let trigger = $(this).text('…');
+                        $.post('/api/appointmentConfirmationDecision/acknowledgeAsAppointmentPro', {
+                            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 ackContainer = trigger.closest('tbody');
+                                    trigger.closest('tr').slideUp('fast', function () {
+                                        $(this).remove();
+                                        if (!ackContainer.find('>tr').length) {
+                                            ackContainer.remove();
+                                        }
+                                    });
+                                }, 500);
+                            }
+                        }, 'json');
+                        return false;
+                    });
+
+                $(document)
+                    .off('click', '.ack-na-appt-update')
+                    .on('click', '.ack-na-appt-update', function () {
+                        let trigger = $(this).text('…');
+                        $.post('/api/appointmentConfirmationDecision/acknowledgeAsClientDefaultNa', {
+                            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 ackContainer = trigger.closest('tbody');
+                                    trigger.closest('tr').slideUp('fast', function () {
+                                        $(this).remove();
+                                        if (!ackContainer.find('>tr').length) {
+                                            ackContainer.remove();
+                                        }
+                                    });
+                                }, 500);
+                            }
+                        }, 'json');
+                        return false;
+                    });
+            }
+
+            addMCInitializer('pro-dashboard', init, '#pro-dashboard-container');
+        })();
+    </script>
+@endsection

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

@@ -0,0 +1,746 @@
+@extends ('layouts.template')
+
+@section('content')
+
+    <style>
+        #dashboard-mcp tr.thin th,
+        #dashboard-mcp tr.thin td,
+        #dashboard-mcp .dashboard-stats-table tr td,
+        #dashboard-mcp .dashboard-stats-table tr th {
+            padding: 0.25em;
+            font-weight: normal;
+        }
+
+        #dashboard-mcp table.appointments tr td {
+            vertical-align: middle;
+        }
+    </style>
+
+    <div id="dashboard-mcp">
+    <div class="p-3">
+        <div class="">
+            <div class="row mcp-theme-1" id="pro-dashboard-container" v-cloak>
+                <div class="col-md-3 mcp-theme-1">
+                    <div class="mb-4">
+                        <div class="pro-dashboard-inline-calendar"></div>
+                    </div>
+                    <div class="card mb-4">
+                        <div class="card-header pl-2">
+                            <strong>
+                                Key Numbers
+                            </strong>
+                        </div>
+                        <div class="card-body p-0">
+                            <table class="table table-sm mb-0 dashboard-stats-table">
+                                <tbody>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_patients_count_as_mcp()}}</th>
+                                    <th class="pl-2">
+                                        <a href="{{ route('mcp.patients') }}">Patients</a>
+                                    </th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_new_patients_awaiting_visit_count_as_mcp()}}</th>
+                                    <th class="pl-2">
+                                        <a href="{{ route('mcp.new_patients_awaiting_visit') }}"
+                                           native target="_blank"
+                                           open-in-stag-popup
+                                           popup-style="tall"
+                                           title="New Patients Awaiting Visit">
+                                            New Patients Awaiting Visit
+                                        </a>
+                                    </th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_notes_pending_signature_count_as_mcp()}}</th>
+                                    <th class="pl-2">
+                                        <a href="{{ route('mcp.notes_pending_signature') }}"
+                                           native target="_blank"
+                                           open-in-stag-popup
+                                           popup-style="tall"
+                                           title="Notes Pending Signature">
+                                            Notes Pending Signature
+                                        </a>
+                                    </th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_notes_pending_billing_count_as_mcp()}}</th>
+                                    <th class="pl-2">
+                                        <a href="{{ route('mcp.notes_pending_billing') }}"
+                                           native target="_blank"
+                                           open-in-stag-popup
+                                           popup-style="tall"
+                                           title="Notes Pending Billing">
+                                            Notes Pending Billing
+                                        </a>
+                                    </th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_incoming_reports_pending_signature_count_as_mcp()}}</th>
+                                    <th class="pl-2">
+                                        <a href="{{ route('mcp.reports_pending_signature') }}"
+                                           native target="_blank"
+                                           open-in-stag-popup
+                                           popup-style="tall"
+                                           title="Reports Pending Signature">
+                                            Reports Pending Signature
+                                        </a>
+                                    </th>
+                                </tr>
+
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_patients_without_appointment_count_as_mcp()}}</th>
+                                    <th class="pl-2">
+                                        <a href="{{ route('mcp.patients_without_appointments') }}"
+                                           native target="_blank"
+                                           open-in-stag-popup
+                                           popup-style="tall"
+                                           title="Patients w/o Appointments">
+                                            Patients w/o Appointments
+                                        </a>
+                                    </th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_patients_overdue_count_as_mcp()}}</th>
+                                    <th class="pl-2">
+                                        <a href="{{ route('mcp.patients_overdue_for_visit') }}"
+                                           native target="_blank"
+                                           open-in-stag-popup
+                                           popup-style="tall"
+                                           title="Patients Overdue for Visit">
+                                            Patients Overdue for Visit
+                                        </a>
+                                    </th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_cancelled_appointments_pending_acknowledgement_count_as_mcp()}}</th>
+                                    <th class="pl-2">
+                                        <a href="{{ route('mcp.cancelled_appointments_pending_review') }}"
+                                           native target="_blank"
+                                           open-in-stag-popup
+                                           popup-style="tall"
+                                           title="Cancelled Appts. Pending Review">
+                                            Cancelled Appts. Pending Review
+                                        </a>
+                                    </th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_cancelled_bills_awaiting_review_count_as_mcp()}}</th>
+                                    <th class="pl-2">
+                                        <a href="{{ route('mcp.cancelled_bills_pending_review') }}"
+                                           native target="_blank"
+                                           open-in-stag-popup
+                                           popup-style="tall"
+                                           title="Cancelled Bills Pending Review">
+                                            Cancelled Bills Pending Review
+                                        </a>
+                                    </th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_cancelled_supply_orders_awaiting_review_count_as_mcp()}}</th>
+                                    <th class="pl-2">
+                                        <a href="{{ route('mcp.cancelled_supply_orders_pending_review') }}"
+                                           native target="_blank"
+                                           open-in-stag-popup
+                                           popup-style="tall"
+                                           title="Cancelled Supply Orders Pending Review">
+                                            Cancelled Supply Orders Pending Review
+                                        </a>
+                                    </th>
+                                </tr>
+
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_erx_and_orders_awaiting_signature_count_as_mcp()}}</th>
+                                    <th class="pl-2">
+                                        <a href="{{ route('mcp.erx_and_orders_pending_signature') }}"
+                                           native target="_blank"
+                                           open-in-stag-popup
+                                           popup-style="tall"
+                                           title="ERx & Orders Pending Signature">
+                                            ERx & Orders Pending Signature
+                                        </a>
+                                    </th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_supply_orders_awaiting_signature_count_as_mcp()}}</th>
+                                    <th class="pl-2">
+                                        <a href="{{ route('mcp.supply_orders_pending_signature') }}"
+                                           native target="_blank"
+                                           open-in-stag-popup
+                                           popup-style="tall"
+                                           title="Supply Orders Pending Signature">
+                                            Supply Orders Pending Signature
+                                        </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 class="thin">
+                                    <th class="px-2 text-center">{{$pro->get_measurements_awaiting_review_count_as_mcp() ?? '-'}}</th>
+                                    <th class="pl-2">Measurements Pending Review</th>
+                                </tr>
+                                <tr class="thin">
+                                    <th class="px-2 text-center">{{$pro->get_patients_without_remote_measurement_in_48_hours_count_as_mcp() ?? '-'}}</th>
+                                    <th class="pl-2">Patients w/o Measurement in 48 hrs.</th>
+                                </tr>
+                                </tbody>
+                            </table>
+                        </div>
+                    </div>
+                    <div class="card mb-4">
+                        <div class="card-header pl-2">
+                            <strong>
+                                Practice Management
+                            </strong>
+                        </div>
+                        <div class="card-body p-0">
+                            <table class="table mb-0 dashboard-stats-table">
+                                <tbody>
+                                <tr class="thin">
+                                    <th colspan="2" class="font-weight-normal px-2 pl-2">Billing & Reimbursement</th>
+                                </tr>
+                                <tr class="thin">
+                                    <th class="font-weight-normal px-2 pl-4">{{friendly_date_time($reimbursement['nextPaymentDate'], false)}}</th>
+                                    <th class="font-weight-normal pl-2">Next Payment Date</th>
+                                </tr>
+                                <tr class="thin">
+                                    <th class="font-weight-normal px-2 pl-4">
+                                        ${{friendly_money($reimbursement['currentBalance'])}}</th>
+                                    <th class="font-weight-normal pl-2 w-100"><a
+                                            href="/practice-management/financial-transactions">Current balance</a></th>
+                                </tr>
+                                <tr class="thin">
+                                    <th class="font-weight-normal px-2 pl-4">
+                                        ${{friendly_money($reimbursement['nextPaymentAmount'])}}</th>
+                                    <th class="font-weight-normal pl-2"><a
+                                            href="/practice-management/bills-under-processing">Processing</a></th>
+                                </tr>
+                                <tr class="thin">
+                                    <th class="font-weight-normal px-2 pl-5">
+                                        ${{friendly_money($reimbursement['nextPaymentAmount'])}}</th>
+                                    <th class="font-weight-normal pl-2"><a
+                                            href="/practice-management/bills-under-processing">Treatment Services</a>
+                                    </th>
+                                </tr>
+                                <tr class="thin">
+                                    <th class="font-weight-normal px-2 pl-5">
+                                        ${{friendly_money($reimbursement['nextPaymentAmount'])}}</th>
+                                    <th class="font-weight-normal pl-2"><a
+                                            href="/practice-management/bills-under-processing">Remote Monitoring</a>
+                                    </th>
+                                </tr>
+                                <tr class="thin">
+                                    <th class="font-weight-normal px-2 pl-5">
+                                        ${{friendly_money($reimbursement['nextPaymentAmount'])}}</th>
+                                    <th class="font-weight-normal pl-2"><a
+                                            href="/practice-management/bills-under-processing">Other Services</a></th>
+                                </tr>
+                                {{--
+                                <tr>
+                                    <th class="px-2">{{$reimbursement['lastPayment']}}</th>
+                                    <th class="pl-2"><a href="/practice-management/financial-transactions">Last payment</a></th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2">{{friendly_date_time($reimbursement['lastPaymentDate'], false)}}</th>
+                                    <th class="pl-2"><a href="/practice-management/financial-transactions">Last payment date</a></th>
+                                </tr>
+                                --}}
+                                </tbody>
+                            </table>
+                        </div>
+                    </div>
+                </div>
+                <div class="col-md-9">
+
+                    <div class="row mcp-theme-1" id="pro-dashboard-container" v-cloak>
+                        <div class="col-md-6 mcp-theme-1">
+                            <div class="card mb-4">
+                                <div class="card-header pl-2">
+                                    <strong>
+                                        Appointments @{{ formatSelectedDate(selectedDate) }}
+                                    </strong>
+                                </div>
+                                <div class="card-body p-0">
+                                    @include('app.mcp.dashboard.appointments')
+                                </div>
+                            </div>
+                            <div class="card mb-4">
+                                <div class="card-header pl-2">
+                                    <strong>
+                                        Measurements
+                                    </strong>
+                                </div>
+                                <div class="card-body">
+                                    @include('app.mcp.dashboard.measurements')
+                                </div>
+                            </div>
+                        </div>
+                        <div class="col-md-6 mcp-theme-1">
+                            <div class="card mb-4">
+                                <div class="card-header pl-2">
+                                    <strong>
+                                        Notifications
+                                    </strong>
+                                </div>
+                                <div class="card-body px-3 py-2">
+                                    @include('app.mcp.dashboard.notifications')
+                                </div>
+                            </div>
+                            <div class="card mb-4">
+                                <div class="card-header pl-2">
+                                    <strong>
+                                        Messages
+                                    </strong>
+                                </div>
+                                <div class="card-body">
+                                    @include('app.mcp.dashboard.messages')
+                                </div>
+                            </div>
+                            <div class="card mb-4">
+                                <div class="card-header pl-2">
+                                    <strong>
+                                        Phone Calls & Memos
+                                    </strong>
+                                </div>
+                                <div class="card-body">
+                                    @include('app.mcp.dashboard.calls_memos')
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+    </div>
+
+    <div class="stag-popup stag-popup-md ticket-popup mcp-theme-1" stag-popup-key="ticket-popup"></div>
+
+    <script>
+        (function () {
+            function init() {
+                window.apapp = new Vue({
+                    el: '#pro-dashboard-container',
+                    delimiters: ['@{{', '}}'],
+                    data: {
+                        tab: '{{ request()->input('tab') ? request()->input('tab') : 'measurements' }}',
+                        datesWithEvents: [],
+                        selectedDate: '{{ date('Y-m-d') }}',
+                        selectedStatus: 'PENDING',
+                        events: [],
+                        numEventsForDate: 0,
+                        filterStatus: '',
+                        calendarElem: null,
+                        currentMonth: null,
+                        currentYear: null,
+                        measurementFilterStatus: 'ALL',
+                        measurements: {!! $pro->pro_type === 'ADMIN' ? '[]' : json_encode($pro->getMeasurements()) !!},
+                        appointmentsLoaded: false,
+                    },
+                    methods: {
+                        formatDate: function (date) {
+                            let d = new Date(date),
+                                month = '' + (d.getMonth() + 1),
+                                day = '' + d.getDate(),
+                                year = d.getFullYear();
+
+                            if (month.length < 2)
+                                month = '0' + month;
+                            if (day.length < 2)
+                                day = '0' + day;
+
+                            return [year, month, day].join('-');
+                        },
+                        onDateChange: function (_newDate) {
+                            let self = this;
+                            window.setTimeout(() => {
+                                // let dayValue = $('.pro-dashboard-inline-calendar td.day.active').first().text();
+                                // if(dayValue.length === 1) dayValue = '0' + dayValue;
+                                // self.selectedDate = _newDate.substr(0, 8) + dayValue;
+                                self.selectedDate = _newDate;
+                                showMask();
+                                self.loadEvents(self.selectedDate, function () {
+                                    hideMask();
+                                    Vue.nextTick(() => {
+                                        // self.highlightDatesWithEvents(self.datesWithEvents);
+                                        initFastLoad($('.appointments-tab'));
+                                    });
+                                });
+                            }, 25);
+                        },
+                        selectToday: function () {
+                            $('.pro-dashboard-inline-calendar table td[data-date]').removeClass('active');
+                            $('.pro-dashboard-inline-calendar table td[data-date="{{ $milliseconds }}"]')
+                                .addClass('active');
+                            // this.onDateChange('{{ date('Y-m-d') }}');
+                        },
+                        highlightDatesWithEvents: function (_dates) {
+                            $('.pro-dashboard-inline-calendar table td[data-date]').removeAttr('has-events');
+                            for (let i = 0; i < _dates.length; i++) {
+                                $('.pro-dashboard-inline-calendar table td[data-date="' + _dates[i] + '"]')
+                                    .attr('has-events', 1);
+                            }
+                        },
+                        updateStatus: function (_event) {
+                            $.post('/api/appointment/updateStatus', {
+                                uid: _event.uid,
+                                status: _event.newStatus
+                            }, function (_data) {
+                                if (!_data) {
+                                    toastr.error('Unable to update appointment status!');
+                                } else {
+                                    if (!_data.success) {
+                                        toastr.error(_data.message);
+                                    } else {
+                                        _event.status = _event.newStatus;
+                                        toastr.success('The appointment has been updated');
+                                    }
+                                }
+                            }, 'json')
+                        },
+                        showEditForm: function (_trigger) {
+                            let form = $(_trigger).closest('[moe]').find('form').first();
+                            showMoeFormMask();
+                            form.show();
+                            setTimeout(function () {
+                                initPrimaryForm(form);
+                            }, 0);
+                        },
+                        submitEditForm: function (_trigger) {
+                            let form = $(_trigger).closest('[moe]').find('form').first();
+                            if (!form[0].checkValidity()) {
+                                form[0].reportValidity();
+                                return;
+                            }
+                            $.post(form.attr('url'), form.serialize(), function (_data) {
+                                if (_data && _data.success) {
+                                    fastReload();
+                                } else {
+                                    if (_data.message) {
+                                        toastr.error(_data.message);
+                                    } else {
+                                        toastr.error('Unable to update the appointment');
+                                    }
+                                }
+                            });
+                        },
+                        cancelEditForm: function (_trigger) {
+                            let form = $(_trigger).closest('[moe]').find('form').first();
+                            hideMoeFormMask();
+                            form.hide();
+                        },
+                        loadEventDates: function (_refDate = false) {
+                            let today = new Date(_refDate ? _refDate : '{{date('Y-m-d')}}'),
+                                firstOfMonth = new Date(today.getFullYear(), today.getMonth(), 1),
+                                lastOfMonth = new Date(today.getFullYear(), today.getMonth() + 1, 0);
+
+                            this.selectedDate = null;
+                            $('td.day.active').removeClass('active');
+
+                            $.get('/pro-dashboard-event-dates/' +
+                                this.formatDate(firstOfMonth) + '/' +
+                                this.formatDate(lastOfMonth), (_data) => {
+                                this.datesWithEvents = _data;
+                                console.log(this.datesWithEvents);
+                                this.calendarElem.datepicker('refresh');
+                                // this.highlightDatesWithEvents(this.datesWithEvents);
+
+                                this.currentMonth = firstOfMonth.getMonth();
+                                this.currentYear = firstOfMonth.getFullYear();
+
+                                if (!_refDate && $('td.day[data-date="{{$milliseconds}}"]:visible').length) {
+                                    $('td.day[data-date="{{$milliseconds}}"]:visible').first().click();
+                                }
+
+                                this.appointmentsLoaded = true;
+                            }, 'json');
+                        },
+                        loadEvents: function (_date, _callback) {
+                            let self = this;
+                            $.get('/pro-dashboard-events/' + _date + '/' + _date, function (_data) {
+                                self.events = _data;
+                                self.numEventsForDate = (_data && _data.length) ? 1 : 0;
+                                _callback.call(self);
+                            }, 'json');
+                        },
+                        updateMeasurements: function () {
+                            $.get('/pro-dashboard-measurements/' + this.measurementFilterStatus, (_data) => {
+                                this.measurements = _data;
+                                Vue.nextTick(() => {
+                                    // this.initCMRTE();
+                                    $('#pro-dashboard-container').find('[moe][initialized]').removeAttr('initialized');
+                                    initMoes();
+                                });
+                            }, 'json');
+                        },
+                        setMeasurementStatus: function (_uid, _status) {
+                            $.post('/api/measurement/updateStatus', {
+                                uid: _uid,
+                                status: _status
+                            }, (_data) => {
+                                this.updateMeasurements();
+                            }, 'json');
+                        },
+                        initCMRTE: function () {
+                            $('#pro-dashboard-container [cm-rte]').each(function () {
+
+                                $(this).wrap(
+                                    $('<div class="border-left border-right rte-holder"/>')
+                                        .attr('data-shortcuts', '')
+                                );
+
+                                // give a unique id to this editor instance
+                                var editorID = Math.ceil(Math.random() * 99999), fieldName = $(this).attr('data-name');
+
+                                var el = this;
+                                var existingContent = $(el).attr('data-content');
+                                var quill = new Quill(el, {
+                                    theme: 'snow',
+                                    modules: stagQuillConfig
+                                });
+
+                                var toolbar = $(quill.container).prev('.ql-toolbar');
+
+                                // add button for new shortcut
+                                var newSCButton = $('<button class="btn bg-white btn-sm btn-default text-primary w-auto px-2 border py-0 ' +
+                                    'text-sm add-shortcut" data-editor-id="' + editorID + '">+ Shortcut</button>');
+                                toolbar.append(newSCButton);
+
+                                quill.root.innerHTML = existingContent;
+
+                                $('<input type="hidden" name="' + fieldName + '">').val(existingContent).insertAfter(el);
+
+                                quill.on('text-change', function (delta, oldDelta, source) {
+                                    $(el).next('[name="' + fieldName + '"]').val(quill.root.innerHTML);
+                                });
+
+                                $(quill.container)
+                                    .find('.ql-editor[contenteditable]')
+                                    .attr('data-field', fieldName)
+                                    .attr('data-editor-id', editorID)
+                                    .attr('with-shortcuts', 1);
+
+                            })
+                        },
+                        initLoadAppointments: function () {
+                            if (this.appointmentsLoaded) return false;
+                            this.loadEventDates();
+                        },
+                        loadMeasurements: function () {
+                            $('#measurements-tab').load('/pro-dashboard-measurements-tab', () => {
+                                initMoes();
+                                initFastLoad($('#measurements-tab'));
+                            });
+                        },
+                        getFormattedCurrentDate: function () {
+                            let date = new Date();
+                            let day = date.getDate();
+                            day = day < 10 ? '0' + day : day;
+
+                            return date.getFullYear() + '-' + parseInt(date.getMonth() + 1) + '-' + day;
+                        },
+                        formatSelectedDate: function (_date, _format) {
+                            _format = _format || 'MM/DD/YYYY';
+                            if (_date) {
+                                return moment(_date).format(_format);
+                            }
+                        },
+                        formatTimeZone: function (_tz) {
+                            switch (_tz) {
+                                case 'EASTERN':
+                                    return 'EST'
+                                    break;
+                                case 'CENTRAL':
+                                    return 'CST'
+                                    break;
+                                case 'MOUNTAIN':
+                                    return 'MST'
+                                    break;
+                                case 'PACIFIC':
+                                    return 'PST'
+                                    break;
+                                case 'ALASKA':
+                                    return 'Alaska'
+                                    break;
+                                case 'HAWAII':
+                                    return 'Hawaii'
+                                    break;
+                                case 'PUERTO_RICO':
+                                    return 'Puerto Rico'
+                                    break;
+                                default:
+                                    return 'N/A';
+                            }
+                        }
+                    },
+                    mounted: function () {
+                        let self = this;
+                        this.calendarElem = $('.pro-dashboard-inline-calendar');
+                        this.calendarElem.datepicker({
+                            dateFormat: 'yy-mm-dd',
+                            onSelect: function (_date) {
+                                self.onDateChange(_date);
+                            },
+                            onChangeMonthYear: function (_year, _month) {
+                                let date = _year + '-' + (_month < 10 ? '0' : '') + _month + '-05';
+                                self.loadEventDates(date);
+                            },
+                            beforeShowDay: function (d) {
+                                if (self.datesWithEvents && self.datesWithEvents.indexOf(self.formatDate(d)) !== -1) {
+                                    return [true, 'has-events'];
+                                }
+                                return [true, 'no-events'];
+                            },
+                            defaultDate: 0
+                        });
+                        // this.calendarElem
+                        //     .on('changeDate', function () {
+                        //         self.onDateChange(self.calendarElem.datepicker('getFormattedDate'));
+                        //     })
+                        //     .on('changeMonth', function () {
+                        //         window.setTimeout(function() {
+                        //             let ts = $('td.day[data-date]').first().closest('tr').find('td.day[data-date]').last().attr('data-date');
+                        //             if(ts) {
+                        //                 self.loadEventDates(ts);
+                        //             }
+                        //         }, 10);
+                        //     });
+
+
+                        $('#pro-dashboard-container').find('[moe][initialized]').removeAttr('initialized');
+                        initMoes();
+
+                        // init fast load
+                        initFastLoad($('#pro-dashboard-container'));
+
+                        $(document)
+                            .off('click', '.dashboard-measurements.pagination a.page-link')
+                            .on('click', '.dashboard-measurements.pagination a.page-link', function () {
+                                $('#measurements-tab').text('Loading...').load('/pro-dashboard-measurements-tab/' + $(this).attr('data-target-page'), () => {
+                                    initMoes();
+                                    initFastLoad($('#measurements-tab'));
+                                });
+                                return false;
+                            });
+
+                        this.loadMeasurements();
+                        this.initLoadAppointments();
+                        this.onDateChange(this.getFormattedCurrentDate());
+                        this.selectedDate = this.getFormattedCurrentDate();
+                    }
+                });
+                /*// refresh once ticket popup is closed
+                $('body').off('stag-popup-closed')
+                $('body').on('stag-popup-closed', function() {
+                    if($('#pro-dashboard-container').length) {
+                        let activeTab = $('.nav-link.active[data-tab]').attr('data-tab');
+                        if(activeTab) {
+                            fastLoad('/?tab=' + activeTab);
+                        }
+                    }
+                });*/
+                // ticket-popup
+                $(document)
+                    .off('click', '.ticket-popup-trigger')
+                    .on('click', '.ticket-popup-trigger', function () {
+                        showMask();
+                        window.noMc = true;
+                        $.get(this.href, (_data) => {
+                            $('.ticket-popup').html(_data);
+                            showStagPopup('ticket-popup');
+                            $('.ticket-popup .stag-popup.stag-slide').attr('close-all-with-self', 1);
+                            runMCInitializer('patient-tickets'); // run specific mc initer
+                            hideMask();
+                        });
+                        return false;
+                    });
+
+                $(document)
+                    .off('click', '.ack-client-pro-change')
+                    .on('click', '.ack-client-pro-change', function () {
+                        let trigger = $(this).text('…');
+                        $.post('/api/clientProChange/accept', {
+                            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 ackContainer = trigger.closest('.ack-container');
+                                    trigger.closest('div').slideUp('fast', function () {
+                                        $(this).remove();
+                                        if (!ackContainer.find('>div').length) {
+                                            ackContainer.remove();
+                                        }
+                                    });
+                                }, 500);
+                            }
+                        }, '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;
+                    });
+
+                $(document)
+                    .off('click', '.ack-pro-appt-update')
+                    .on('click', '.ack-pro-appt-update', function () {
+                        let trigger = $(this).text('…');
+                        $.post('/api/appointmentConfirmationDecision/acknowledgeAsAppointmentPro', {
+                            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 ackContainer = trigger.closest('tbody');
+                                    trigger.closest('tr').slideUp('fast', function () {
+                                        $(this).remove();
+                                        if (!ackContainer.find('>tr').length) {
+                                            ackContainer.remove();
+                                        }
+                                    });
+                                }, 500);
+                            }
+                        }, 'json');
+                        return false;
+                    });
+            }
+
+            addMCInitializer('pro-dashboard', init, '#pro-dashboard-container');
+        })();
+    </script>
+@endsection

+ 0 - 988
resources/views/app/dashboard.blade.php

@@ -1,988 +0,0 @@
-@extends ('layouts.template')
-
-@section('content')
-<div class="p-3">
-    <div class="">
-        <div class="row mcp-theme-1" id="pro-dashboard-container" v-cloak>
-            <div class="col-md-3 mcp-theme-1">
-                <div class="mb-4" v-show="tab==='appointments'">
-                    <div class="pro-dashboard-inline-calendar"></div>
-                </div>
-                <div class="card mb-4">
-                    <div class="card-header pl-2">
-                        <strong>
-                            Key Numbers
-                        </strong>
-                    </div>
-                    <div class="card-body p-0">
-                        <table class="table mb-0 dashboard-stats-table">
-                            <tbody>
-                                <tr>
-                                    <th class="border-top-0 px-2 text-center">{{$keyNumbers['totalPatients']}}</th>
-                                    <th class="border-top-0 pl-2"><a href="/patients">Total patients</a></th>
-                                </tr>
-                                <tr>
-                                    <th class="px-2 text-center">{{$keyNumbers['patientsNotSeenYet']}}</th>
-                                    <th class="pl-2"><a href="/patients/not-yet-seen">Patients I have not seen yet</a></th>
-                                </tr>
-                                <tr>
-                                    <th class="px-2 text-center">{{$keyNumbers['pendingBillsToSign']}}</th>
-                                    <th class="pl-2"><a href="/practice-management/bills/not-yet-signed">Pending bills to sign</a></th>
-                                </tr>
-                                <tr>
-                                    <th class="px-2 text-center">{{$keyNumbers['signedNotesWithoutBills']}}</th>
-                                    <th class="pl-2"><a href="/practice-management/notes/without-bills">Signed notes without bills</a></th>
-                                </tr>
-                                @if(!$pro->isDefaultNA())
-                                <tr>
-                                    <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>
-                                @else
-                                <tr>
-                                    <th class="px-2 text-center">{{$keyNumbers['$pendingNotesToSignMCP']}}</th>
-                                    <th class="pl-2"><a href="/practice-management/dna-notes-pending-mcp-sign">Pending notes to sign (MCP)</a></th>
-                                </tr>
-                                @endif
-                                @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['unacknowledgedCancelledBills']}}</th>
-                                    <th class="pl-2">
-                                        <a href="/practice-management/unacknowledged-cancelled-bills">Unacknowledged Cancelled Bills</a>
-                                    </th>
-                                </tr>
-                                <tr>
-                                    <th class="px-2 text-center">{{$keyNumbers['unacknowledgedCancelledSupplyOrders']}}</th>
-                                    <th class="pl-2">
-                                        <a href="/practice-management/supply-orders/cancelled-but-unacknowledged">Unacknowledged Cancelled Supply Orders</a>
-                                    </th>
-                                </tr>
-                                <tr>
-                                    <th class="px-2 text-center">{{$keyNumbers['unsignedSupplyOrders']}}</th>
-                                    <th class="pl-2">
-                                        <a href="/practice-management/supply-orders/unsigned">Unsigned Supply Orders</a>
-                                    </th>
-                                </tr>
-                                <tr>
-                                    <th class="px-2 text-center">{{$keyNumbers['patientsHavingBirthdayToday']}}</th>
-                                    <th class="pl-2">
-                                        <a href="/patients/having-birthday-today">Patients having birthday today</a>
-                                    </th>
-                                </tr>
-                                @if(@$keyNumbers['naBillableSignedNotes'])
-                                    <tr>
-                                        <th class="px-2 text-center">{{$keyNumbers['naBillableSignedNotes']}}</th>
-                                        <th class="pl-2">
-                                            <a href="/practice-management/na-billable-signed-notes">Billable signed notes</a>
-                                        </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>
-                                @if($pro->pro_type === 'ADMIN')
-                                    <tr>
-                                        <th class="px-2 text-center">{{$keyNumbers['patientsWithoutCoverageInformation']}}</th>
-                                        <th class="pl-2"><a href="/practice-management/patients-without-coverage/without-coverage-information">Without coverage information</a></th>
-                                    </tr>
-                                    <tr>
-                                        <th class="px-2 text-center">{{$keyNumbers['patientsPendingCoverageVerification']}}</th>
-                                        <th class="pl-2"><a href="/practice-management/patients-without-coverage/pending-coverage-verification">Pending coverage verification</a></th>
-                                    </tr>
-                                @endif
-                            </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>
-                </div>
-                <div class="card mb-4">
-                    <div class="card-header pl-2">
-                        <strong>
-                            Reimbursement
-                        </strong>
-                    </div>
-                    <div class="card-body p-0">
-                        <table class="table mb-0 dashboard-stats-table">
-                            <tbody>
-                                <tr>
-                                    <th class="border-top-0 px-2">${{friendly_money($reimbursement['currentBalance'])}}</th>
-                                    <th class="border-top-0 pl-2 w-100"><a href="/practice-management/financial-transactions">Current balance</a></th>
-                                </tr>
-                                <!-- <tr>
-                                    <th class="px-2">{{friendly_date_time($reimbursement['nextPaymentDate'], false)}}</th>
-                                    <th class="pl-2">Next Payment Date</th>
-                                </tr> -->
-                                <tr>
-                                    <th class="px-2">${{friendly_money($reimbursement['nextPaymentAmount'])}}</th>
-                                    <th class="pl-2"><a href="/practice-management/bills-under-processing">Processing</a></th>
-                                </tr>
-                                {{--
-                                <tr>
-                                    <th class="px-2">{{$reimbursement['lastPayment']}}</th>
-                                    <th class="pl-2"><a href="/practice-management/financial-transactions">Last payment</a></th>
-                                </tr>
-                                <tr>
-                                    <th class="px-2">{{friendly_date_time($reimbursement['lastPaymentDate'], false)}}</th>
-                                    <th class="pl-2"><a href="/practice-management/financial-transactions">Last payment date</a></th>
-                                </tr>
-                                --}}
-                            </tbody>
-                        </table>
-                    </div>
-                </div>
-                @if($pro->pro_type === 'ADMIN')
-                <div class="card mb-4">
-                    <div class="card-header pl-2">
-                        <strong>
-                            Bills &amp; Claims
-                        </strong>
-                    </div>
-                    <div class="card-body p-0">
-                        <table class="table mb-0 dashboard-stats-table">
-                            <tbody>
-                            
-                            <tr>
-                                <th class="border-top-1 px-2 text-center">{{$businessNumbers['notesWithBillsToResolve']}}</th>
-                                <th class="border-top-1 pl-2">
-                                    <a href="/practice-management/billing-manager">Notes with bills to resolve</a>
-                                </th>
-                            </tr>
-                            <tr>
-                                <th class="border-top-1 px-2 text-center">{{$businessNumbers['notesPendingBillingClosure']}}</th>
-                                <th class="border-top-1 pl-2">
-                                    <a href="/practice-management/billing-manager">Notes pending billing closure</a>
-                                </th>
-                            </tr>
-                            </tbody>
-                        </table>
-                    </div>
-                </div>
-                @endif
-            </div>
-            <div class="col-md-9">
-
-                <div class="row">
-                    <div class="col-6">
-
-                        <!-- Appointment Updates -->
-                        @if(count($proApptUpdates))
-                            <div class="mb-3 border rounded px-3 py-2 ack-container">
-                                <p class="pt-1 mb-2"><b>Appointment Updates</b></p>
-                                <table class="table table-sm table-hover table-bordered mb-0">
-                                    <thead>
-                                    <tr>
-                                        <th>Client</th>
-                                        <th>Appt. Date/Time</th>
-                                        <th>Status</th>
-                                        <th></th>
-                                    </tr>
-                                    </thead>
-                                    <tbody>
-                                        @foreach($proApptUpdates as $update)
-                                            <tr>
-                                                <td>{{$update->name_first}} {{$update->name_last}}</td>
-                                                <td>{{friendlier_date_time($update->start_time)}}</td>
-                                                <td>{{$update->status}}</td>
-                                                <td><a href="#" class="ack-pro-appt-update" data-uid="{{$update->uid}}">Acknowledge</a></td>
-                                            </tr>
-                                        @endforeach
-                                    </tbody>
-                                </table>
-                            </div>
-                        @endif
-
-                        @if(count($naApptUpdates))
-                            <div class="mb-3 border rounded px-3 py-2 ack-container">
-                                <p class="pt-1 mb-2"><b>Appointment Updates</b></p>
-                                <table class="table table-sm table-hover table-bordered mb-0">
-                                    <thead>
-                                    <tr>
-                                        <th>Client</th>
-                                        <th>Pro</th>
-                                        <th>Appt. Date/Time</th>
-                                        <th>Status</th>
-                                        <th></th>
-                                    </tr>
-                                    </thead>
-                                    <tbody>
-                                    @foreach($naApptUpdates as $update)
-                                        <tr>
-                                            <td>{{$update->name_first}} {{$update->name_last}}</td>
-                                            <td>{{$update->pro_name_first}} {{$update->pro_name_last}}</td>
-                                            <td>{{friendlier_date_time($update->start_time)}}</td>
-                                            <td>{{$update->status}}</td>
-                                            <td><a href="#" class="ack-na-appt-update" data-uid="{{$update->uid}}">Acknowledge</a></td>
-                                        </tr>
-                                    @endforeach
-                                    </tbody>
-                                </table>
-                            </div>
-                        @endif
-
-                        <!-- 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="d-flex align-items-start bg-light mb-2 px-2 py-1">
-                                        <div class="flex-grow-1">
-                                            You are now the MCP for
-                                            <a href="/patients/view/{{$assoc->patient->uid}}" class="">{{$assoc->patient->displayName()}}</a>
-                                            <?php $nextAppt = $assoc->patient->nextAppointment(); ?>
-                                            @if($nextAppt)
-                                                <div class="font-size-11">
-                                                    <span class="text-secondary font-size-11">Appt.</span>
-                                                    {{$nextAppt->pro->displayName()}}
-                                                    <span class="text-secondary font-size-11">on</span>
-                                                    {{friendlier_date_time($nextAppt->raw_date . ' ' . $nextAppt->raw_start_time)}}
-                                                </div>
-                                                @if($nextAppt->status === 'CREATED')
-                                                    <div class="text-warning-mellow font-weight-bold font-size-11 mt-1">
-                                                        <i class="fa fa-exclamation-triangle"></i>
-                                                        Confirmation pending
-                                                    </div>
-                                                @endif
-                                                @if($nextAppt->status === 'CONFIRMED')
-                                                    <div class="text-success font-weight-bold font-size-11 mt-1">
-                                                        <i class="fa fa-check"></i>
-                                                        Confirmed by the patient
-                                                    </div>
-                                                @endif
-                                                @if($nextAppt->status === 'REJECTED')
-                                                    <div class="text-danger font-weight-bold font-size-11 mt-1">
-                                                        <i class="fa fa-stop"></i>
-                                                        Rejected by the patient
-                                                    </div>
-                                                @endif
-                                            @endif
-                                        </div>
-                                        <a href="#" class="ack-client-pro-change ml-3" data-uid="{{$assoc->uid}}">Stamp</a>
-                                    </div>
-                                @endforeach
-                            </div>
-                        @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="d-flex align-items-start bg-light mb-2 px-2 py-1">
-                                        <div class="flex-grow-1">
-                                            You are now the Care Coordinator for
-                                            <a href="/patients/view/{{$assoc->patient->uid}}" class="">{{$assoc->patient->displayName()}}</a>
-                                            <?php $nextAppt = $assoc->patient->nextAppointment(); ?>
-                                            @if($nextAppt)
-                                                <div class="font-size-11">
-                                                    <span class="text-secondary font-size-11">Appt.</span>
-                                                    {{$nextAppt->pro->displayName()}}
-                                                    <span class="text-secondary font-size-11">on</span>
-                                                    {{friendlier_date_time($nextAppt->raw_date . ' ' . $nextAppt->raw_start_time)}}
-                                                </div>
-                                                @if($nextAppt->status === 'CREATED')
-                                                    <div class="text-warning-mellow font-weight-bold font-size-11 mt-1">
-                                                        <i class="fa fa-exclamation-triangle"></i>
-                                                        Confirmation pending
-                                                    </div>
-                                                @endif
-                                                @if($nextAppt->status === 'CONFIRMED')
-                                                    <div class="text-success font-weight-bold font-size-11 mt-1">
-                                                        <i class="fa fa-check"></i>
-                                                        Confirmed by the patient
-                                                    </div>
-                                                @endif
-                                                @if($nextAppt->status === 'REJECTED')
-                                                    <div class="text-danger font-weight-bold font-size-11 mt-1">
-                                                        <i class="fa fa-stop"></i>
-                                                        Rejected by the patient
-                                                    </div>
-                                                @endif
-                                            @endif
-                                        </div>
-                                        <a href="#" class="ack-client-pro-change" data-uid="{{$assoc->uid}}">Stamp</a>
-                                    </div>
-                                @endforeach
-                            </div>
-                        @endif
-                    </div>
-                    <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">
-                        <a native data-tab="appointments" class="nav-link"
-                           :class="tab == 'appointments' ? 'active' : ''" href="#"
-                           v-on:click.prevent="tab='appointments'; initLoadAppointments();">
-                            Appointments
-                        </a>
-                    </li>
-                    <li class="nav-item">
-                        <a native data-tab="measurements" class="nav-link"
-                           :class="tab == 'measurements' ? 'active' : ''" href="#"
-                           v-on:click.prevent="tab='measurements'; loadMeasurements();">
-                            Measurements
-                        </a>
-                    </li>
-                    <li class="nav-item">
-                        <a native data-tab="incoming_reports" class="nav-link {{count($incomingReports) ? 'text-danger font-weight-bold' : ''}}"
-                           :class="tab == 'incoming_reports' ? 'active' : ''" href="#"
-                           v-on:click.prevent="tab='incoming_reports'">
-                            Incoming Reports ({{count($incomingReports)}})
-                        </a>
-                    </li>
-                    <li class="nav-item">
-                        <a native data-tab="erx" class="nav-link {{$numERx ? 'text-danger font-weight-bold' : ''}}"
-                           :class="tab == 'erx' ? 'active' : ''" href="#"
-                           v-on:click.prevent="tab='erx'">
-                            ERx ({{$numERx}})
-                        </a>
-                    </li>
-                    <li class="nav-item">
-                        <a native data-tab="labs" class="nav-link {{$numLabs ? 'text-danger font-weight-bold' : ''}}"
-                           :class="tab == 'labs' ? 'active' : ''" href="#"
-                           v-on:click.prevent="tab='labs'">
-                            Labs ({{$numLabs}})
-                        </a>
-                    </li>
-                    <li class="nav-item">
-                        <a native data-tab="imaging" class="nav-link {{$numImaging ? 'text-danger font-weight-bold' : ''}}"
-                           :class="tab == 'imaging' ? 'active' : ''" href="#"
-                           v-on:click.prevent="tab='imaging'">
-                            Imaging ({{$numImaging}})
-                        </a>
-                    </li>
-                    <li class="nav-item">
-                        <a native data-tab="supply_orders" class="nav-link {{$numSupplyOrders ? 'text-danger font-weight-bold' : ''}}"
-                           :class="tab == 'supply_orders' ? 'active' : ''" href="#"
-                           v-on:click.prevent="tab='supply_orders'">
-                            Supply Orders ({{$numSupplyOrders}})
-                        </a>
-                    </li>
-                </ul>
-
-                <div class="border-left border-right border-bottom p-3">
-                    <div v-show="tab==='appointments'" class="appointments-tab">
-                        <div v-show="selectedDate">
-                            <div class="d-flex align-items-end mb-3">
-                                <b class="large"><span class="text-secondary">Today:</span> @{{ selectedDate }}</b>
-                                <div class="ml-auto d-inline-flex align-items-center">
-                                    <label class="text-secondary mr-2 my-0 text-nowrap">Filter by status:</label>
-                                    <select v-model="filterStatus"
-                                            class="form-control form-control-sm">
-                                        <option value="">All</option>
-                                        <option value="CREATED">Created</option>
-                                        <option value="CONFIRMED">Confirmed</option>
-                                        <option value="CANCELLED">Cancelled</option>
-                                        <option value="COMPLETED">Completed</option>
-                                        <option value="ABANDONED">Abandoned</option>
-                                    </select>
-                                </div>
-                            </div>
-                            <div v-for="event in events" class="align-items-end p-3 border rounded mb-3"
-                                 :class="(event.dateYMD === selectedDate && (filterStatus === '' || filterStatus === event.status) ? 'd-flex' : 'd-none') + ' ' + (event.isClientShadowOfPro ? 'training-event' : '')">
-                                <div class="patient-avatar mr-3 align-self-center">
-                                    <i v-if="event.isClientShadowOfPro" class="fa fa-graduation-cap training-icon" :title="event.proInitials"></i>
-                                    <span v-else class="">@{{ event.proInitials }}</span>
-                                </div>
-                                <div>
-                                    <div class="pb-1">
-                                        <b class="text-info">@{{ event.proName }}</b>
-                                        &nbsp;/&nbsp;
-                                        @{{ event.friendlyStartTime }} - @{{ event.friendlyEndTime }} <span class="text-secondary">@{{ event.timezone }}</span>
-                                        &nbsp;/&nbsp;
-                                        <span class="d-inline-block ml- 2 text-secondary font-weight-bold">@{{ event.title }}</span>
-                                    </div>
-                                    <div class="pb-1">
-                                        <a :href="'/patients/view/' + event.clientUid" class="font-weight-bold">@{{ event.clientName }}</a>
-                                        <span class="small d-inline-block pl-2 text-secondary font-weight-normal">@{{ event.clientSummary }}</span>
-                                    </div>
-                                    <div class="d-flex align-items-baseline">
-                                        <div v-if="event.status === 'CREATED'" class="text-warning-mellow font-weight-bold">
-                                            <i class="fa fa-exclamation-triangle"></i>
-                                            Confirmation pending
-                                        </div>
-                                        <div v-else-if="event.status === 'CONFIRMED'" class="text-success font-weight-bold">
-                                            <i class="fa fa-check"></i>
-                                            Confirmed by the patient
-                                        </div>
-                                        <div v-else-if="event.status === 'REJECTED'" class="text-danger font-weight-bold">
-                                            <i class="fa fa-stop"></i>
-                                            Rejected by the patient
-                                        </div>
-                                        <div v-else class="text-secondary">
-                                            Status: <b>@{{ event.status }}</b>
-                                        </div>
-                                        <span class="mx-2 text-secondary">|</span>
-                                        <a :href="'/patients/view/' + event.clientUid + '/calendar/' + event.uid">
-                                            <i class="fa fa-edit"></i>
-                                            Edit Appointment
-                                        </a>
-                                    </div>
-                                    <div class="mt-1" :class="event.coverage !== 'YES' ? (event.coverage === 'NO' ? 'text-danger' : 'text-warning-mellow') : 'text-success'">
-                                        Coverage Status: <b>@{{ event.coverage }}</b>
-                                    </div>
-                                </div>
-                                <div class="ml-auto">
-                                    <select v-model="event.newStatus"
-                                            class="form-control form-control-sm bg-light"
-                                            v-on:change="updateStatus(event)">
-                                        <option value="CREATED">CREATED</option>
-                                        <option value="CONFIRMED">CONFIRMED</option>
-                                        <option value="CANCELLED">CANCELLED</option>
-                                        <option value="COMPLETED">COMPLETED</option>
-                                        <option value="ABANDONED">ABANDONED</option>
-                                    </select>
-                                    <div v-if="selectedDate === '{{ date('Y-m-d') }}'"
-                                         class="pt-1 text-right" :class="event.started ? 'text-danger': 'text-secondary'">
-                                        @{{ event.inHowManyHours }}
-                                    </div>
-                                </div>
-                            </div>
-                            <div v-if="numEventsForDate === 0" class="bg-light p-3 text-secondary border bounded">
-                                <span v-if="filterStatus === ''">You have no appointments on <b>@{{ selectedDate }}</b></span>
-                                <span v-if="filterStatus !== ''">You have no appointments on <b>@{{ selectedDate }}</b> with status <b>@{{ filterStatus }}</b></span>
-                            </div>
-                        </div>
-                        <div v-show="!selectedDate" class="bg-light p-3 text-secondary border bounded">
-                            Please select a date from the calendar on the left
-                        </div>
-                    </div>
-                    <div v-show="tab==='measurements'">
-                        <div id="measurements-tab">Loading...</div>
-                    </div>
-                    <div v-show="tab==='incoming_reports'">
-                        @include('app.dashboard.incoming_reports')
-                    </div>
-                    <div v-show="tab==='erx'">
-                        @include('app.dashboard.erx')
-                    </div>
-                    <div v-show="tab==='labs'">
-                        @include('app.dashboard.labs')
-                    </div>
-                    <div v-show="tab==='imaging'">
-                        @include('app.dashboard.imaging')
-                    </div>
-                    <div v-show="tab==='supply_orders'">
-                        @include('app.dashboard.supply_orders')
-                    </div>
-                </div>
-            </div>
-        </div>
-    </div>
-</div>
-
-<div class="stag-popup stag-popup-md ticket-popup mcp-theme-1" stag-popup-key="ticket-popup"></div>
-
-<script>
-    (function() {
-        function init() {
-            window.apapp = new Vue({
-                el: '#pro-dashboard-container',
-                delimiters: ['@{{', '}}'],
-                data: {
-                    tab: '{{ request()->input('tab') ? request()->input('tab') : 'measurements' }}',
-                    datesWithEvents: [],
-                    selectedDate: '{{ date('Y-m-d') }}',
-                    selectedStatus: 'CREATED',
-                    events: [],
-                    numEventsForDate: 0,
-                    filterStatus: '',
-                    calendarElem: null,
-                    currentMonth: null,
-                    currentYear: null,
-                    measurementFilterStatus: 'ALL',
-                    measurements: {!! $pro->pro_type === 'ADMIN' ? '[]' : json_encode($pro->getMeasurements()) !!},
-                    appointmentsLoaded: false,
-                },
-                methods: {
-                    formatDate: function (date) {
-                        let d = new Date(date),
-                            month = '' + (d.getMonth() + 1),
-                            day = '' + d.getDate(),
-                            year = d.getFullYear();
-
-                        if (month.length < 2)
-                            month = '0' + month;
-                        if (day.length < 2)
-                            day = '0' + day;
-
-                        return [year, month, day].join('-');
-                    },
-                    onDateChange: function (_newDate) {
-                        let self = this;
-                        window.setTimeout(() => {
-                            // let dayValue = $('.pro-dashboard-inline-calendar td.day.active').first().text();
-                            // if(dayValue.length === 1) dayValue = '0' + dayValue;
-                            // self.selectedDate = _newDate.substr(0, 8) + dayValue;
-                            self.selectedDate = _newDate;
-                            showMask();
-                            self.loadEvents(self.selectedDate, function() {
-                                hideMask();
-                                Vue.nextTick(() => {
-                                    // self.highlightDatesWithEvents(self.datesWithEvents);
-                                    initFastLoad($('.appointments-tab'));
-                                });
-                            });
-                        }, 25);
-                    },
-                    selectToday: function () {
-                        $('.pro-dashboard-inline-calendar table td[data-date]').removeClass('active');
-                        $('.pro-dashboard-inline-calendar table td[data-date="{{ $milliseconds }}"]')
-                            .addClass('active');
-                        // this.onDateChange('{{ date('Y-m-d') }}');
-                    },
-                    highlightDatesWithEvents: function (_dates) {
-                        $('.pro-dashboard-inline-calendar table td[data-date]').removeAttr('has-events');
-                        for (let i = 0; i < _dates.length; i++) {
-                            $('.pro-dashboard-inline-calendar table td[data-date="' + _dates[i] + '"]')
-                                .attr('has-events', 1);
-                        }
-                    },
-                    updateStatus: function(_event) {
-                        $.post('/api/appointment/updateStatus', {
-                            uid: _event.uid,
-                            status: _event.newStatus
-                        }, function(_data) {
-                            if(!_data) {
-                                toastr.error('Unable to update appointment status!');
-                            }
-                            else {
-                                if(!_data.success) {
-                                    toastr.error(_data.message);
-                                }
-                                else {
-                                    _event.status = _event.newStatus;
-                                    toastr.success('The appointment has been updated');
-                                }
-                            }
-                        }, 'json')
-                    },
-                    showEditForm: function(_trigger) {
-                        let form = $(_trigger).closest('[moe]').find('form').first();
-                        showMoeFormMask();
-                        form.show();
-                        setTimeout(function() {
-                            initPrimaryForm(form);
-                        }, 0);
-                    },
-                    submitEditForm: function(_trigger) {
-                        let form = $(_trigger).closest('[moe]').find('form').first();
-                        if(!form[0].checkValidity()) {
-                            form[0].reportValidity();
-                            return;
-                        }
-                        $.post(form.attr('url'), form.serialize(), function(_data) {
-                            if(_data && _data.success) {
-                                fastReload();
-                            }
-                            else {
-                                if(_data.message) {
-                                    toastr.error(_data.message);
-                                }
-                                else {
-                                    toastr.error('Unable to update the appointment');
-                                }
-                            }
-                        });
-                    },
-                    cancelEditForm: function(_trigger) {
-                        let form = $(_trigger).closest('[moe]').find('form').first();
-                        hideMoeFormMask();
-                        form.hide();
-                    },
-                    loadEventDates: function(_refDate = false) {
-                        let today = new Date(_refDate ? _refDate : '{{date('Y-m-d')}}'),
-                            firstOfMonth = new Date(today.getFullYear(), today.getMonth(), 1),
-                            lastOfMonth = new Date(today.getFullYear(), today.getMonth() + 1, 0);
-
-                        this.selectedDate = null;
-                        $('td.day.active').removeClass('active');
-
-                        $.get('/pro-dashboard-event-dates/' +
-                            this.formatDate(firstOfMonth) + '/' +
-                            this.formatDate(lastOfMonth), (_data) => {
-                            this.datesWithEvents = _data;
-                            console.log(this.datesWithEvents);
-                            this.calendarElem.datepicker('refresh');
-                            // this.highlightDatesWithEvents(this.datesWithEvents);
-
-                            this.currentMonth = firstOfMonth.getMonth();
-                            this.currentYear = firstOfMonth.getFullYear();
-
-                            if(!_refDate && $('td.day[data-date="{{$milliseconds}}"]:visible').length) {
-                                $('td.day[data-date="{{$milliseconds}}"]:visible').first().click();
-                            }
-
-                            this.appointmentsLoaded = true;
-                        }, 'json');
-                    },
-                    loadEvents: function(_date, _callback) {
-                        let self = this;
-                        $.get('/pro-dashboard-events/' + _date + '/' + _date, function(_data) {
-                            self.events = _data;
-                            self.numEventsForDate = (_data && _data.length) ? 1 : 0;
-                            _callback.call(self);
-                        }, 'json');
-                    },
-                    updateMeasurements: function() {
-                        $.get('/pro-dashboard-measurements/' + this.measurementFilterStatus, (_data) => {
-                            this.measurements = _data;
-                            Vue.nextTick(() => {
-                                // this.initCMRTE();
-                                $('#pro-dashboard-container').find('[moe][initialized]').removeAttr('initialized');
-                                initMoes();
-                            });
-                        }, 'json');
-                    },
-                    setMeasurementStatus: function(_uid, _status) {
-                        $.post('/api/measurement/updateStatus', {
-                            uid: _uid,
-                            status: _status
-                        }, (_data) => {
-                            this.updateMeasurements();
-                        }, 'json');
-                    },
-                    initCMRTE: function() {
-                        $('#pro-dashboard-container [cm-rte]').each(function() {
-
-                            $(this).wrap(
-                                $('<div class="border-left border-right rte-holder"/>')
-                                    .attr('data-shortcuts', '')
-                            );
-
-                            // give a unique id to this editor instance
-                            var editorID = Math.ceil(Math.random() * 99999), fieldName = $(this).attr('data-name');
-
-                            var el = this;
-                            var existingContent = $(el).attr('data-content');
-                            var quill = new Quill(el, {
-                                theme: 'snow',
-                                modules: stagQuillConfig
-                            });
-
-                            var toolbar = $(quill.container).prev('.ql-toolbar');
-
-                            // add button for new shortcut
-                            var newSCButton = $('<button class="btn bg-white btn-sm btn-default text-primary w-auto px-2 border py-0 ' +
-                                'text-sm add-shortcut" data-editor-id="' + editorID + '">+ Shortcut</button>');
-                            toolbar.append(newSCButton);
-
-                            quill.root.innerHTML = existingContent;
-
-                            $('<input type="hidden" name="' + fieldName + '">').val(existingContent).insertAfter(el);
-
-                            quill.on('text-change', function(delta, oldDelta, source) {
-                                $(el).next('[name="' + fieldName + '"]').val(quill.root.innerHTML);
-                            });
-
-                            $(quill.container)
-                                .find('.ql-editor[contenteditable]')
-                                .attr('data-field', fieldName)
-                                .attr('data-editor-id', editorID)
-                                .attr('with-shortcuts', 1);
-
-                        })
-                    },
-                    initLoadAppointments: function() {
-                        if(this.appointmentsLoaded) return false;
-                        this.loadEventDates();
-                    },
-                    loadMeasurements: function() {
-                        $('#measurements-tab').load('/pro-dashboard-measurements-tab', () => {
-                            initMoes();
-                            initFastLoad($('#measurements-tab'));
-                        });
-                    }
-                },
-                mounted: function () {
-                    let self = this;
-                    this.calendarElem = $('.pro-dashboard-inline-calendar');
-                    this.calendarElem.datepicker({
-                        dateFormat: 'yy-mm-dd',
-                        onSelect: function(_date) {
-                            self.onDateChange(_date);
-                        },
-                        onChangeMonthYear: function(_year, _month) {
-                            let date = _year + '-' + (_month < 10 ? '0' : '') + _month + '-05';
-                            self.loadEventDates(date);
-                        },
-                        beforeShowDay: function(d) {
-                            if(self.datesWithEvents && self.datesWithEvents.indexOf(self.formatDate(d)) !== -1) {
-                                return [true, 'has-events'];
-                            }
-                            return [true, 'no-events'];
-                        }
-                    });
-                    // this.calendarElem
-                    //     .on('changeDate', function () {
-                    //         self.onDateChange(self.calendarElem.datepicker('getFormattedDate'));
-                    //     })
-                    //     .on('changeMonth', function () {
-                    //         window.setTimeout(function() {
-                    //             let ts = $('td.day[data-date]').first().closest('tr').find('td.day[data-date]').last().attr('data-date');
-                    //             if(ts) {
-                    //                 self.loadEventDates(ts);
-                    //             }
-                    //         }, 10);
-                    //     });
-
-
-
-                    $('#pro-dashboard-container').find('[moe][initialized]').removeAttr('initialized');
-                    initMoes();
-
-                    // init fast load
-                    initFastLoad($('#pro-dashboard-container'));
-
-                    $(document)
-                        .off('click', '.dashboard-measurements.pagination a.page-link')
-                        .on('click', '.dashboard-measurements.pagination a.page-link', function() {
-                            $('#measurements-tab').text('Loading...').load('/pro-dashboard-measurements-tab/' + $(this).attr('data-target-page'), () => {
-                                initMoes();
-                                initFastLoad($('#measurements-tab'));
-                            });
-                            return false;
-                        });
-
-                    this.loadMeasurements();
-                }
-            });
-            /*// refresh once ticket popup is closed
-            $('body').off('stag-popup-closed')
-            $('body').on('stag-popup-closed', function() {
-                if($('#pro-dashboard-container').length) {
-                    let activeTab = $('.nav-link.active[data-tab]').attr('data-tab');
-                    if(activeTab) {
-                        fastLoad('/?tab=' + activeTab);
-                    }
-                }
-            });*/
-            // ticket-popup
-            $(document)
-                .off('click', '.ticket-popup-trigger')
-                .on('click', '.ticket-popup-trigger', function() {
-                    showMask();
-                    window.noMc = true;
-                    $.get(this.href, (_data) => {
-                        $('.ticket-popup').html(_data);
-                        showStagPopup('ticket-popup');
-                        $('.ticket-popup .stag-popup.stag-slide').attr('close-all-with-self', 1);
-                        runMCInitializer('patient-tickets'); // run specific mc initer
-                        hideMask();
-                    });
-                    return false;
-                });
-
-            $(document)
-                .off('click', '.ack-client-pro-change')
-                .on('click', '.ack-client-pro-change', function() {
-                    let trigger = $(this).text('…');
-                    $.post('/api/clientProChange/accept', {
-                        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 ackContainer = trigger.closest('.ack-container');
-                                trigger.closest('div').slideUp('fast', function() {
-                                    $(this).remove();
-                                    if(!ackContainer.find('>div').length) {
-                                        ackContainer.remove();
-                                    }
-                                });
-                            }, 500);
-                        }
-                    }, '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;
-                });
-
-            $(document)
-                .off('click', '.ack-pro-appt-update')
-                .on('click', '.ack-pro-appt-update', function() {
-                    let trigger = $(this).text('…');
-                    $.post('/api/appointmentConfirmationDecision/acknowledgeAsAppointmentPro', {
-                        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 ackContainer = trigger.closest('tbody');
-                                trigger.closest('tr').slideUp('fast', function() {
-                                    $(this).remove();
-                                    if(!ackContainer.find('>tr').length) {
-                                        ackContainer.remove();
-                                    }
-                                });
-                            }, 500);
-                        }
-                    }, 'json');
-                    return false;
-                });
-
-            $(document)
-                .off('click', '.ack-na-appt-update')
-                .on('click', '.ack-na-appt-update', function() {
-                    let trigger = $(this).text('…');
-                    $.post('/api/appointmentConfirmationDecision/acknowledgeAsClientDefaultNa', {
-                        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 ackContainer = trigger.closest('tbody');
-                                trigger.closest('tr').slideUp('fast', function() {
-                                    $(this).remove();
-                                    if(!ackContainer.find('>tr').length) {
-                                        ackContainer.remove();
-                                    }
-                                });
-                            }, 500);
-                        }
-                    }, 'json');
-                    return false;
-                });
-        }
-        addMCInitializer('pro-dashboard', init, '#pro-dashboard-container');
-    })();
-</script>
-@endsection

+ 5 - 0
resources/views/app/dna/appointments.blade.php

@@ -0,0 +1,5 @@
+@extends ('layouts/template')
+
+@section('content')
+    <h1>Hi</h1>
+@endsection

+ 5 - 0
resources/views/app/dna/bills.blade.php

@@ -0,0 +1,5 @@
+@extends ('layouts/template')
+
+@section('content')
+    <h1>Hi</h1>
+@endsection

+ 0 - 0
resources/views/app/dna/cancelled_appointments_pending_review.blade.php


+ 0 - 0
resources/views/app/dna/cancelled_bills_pending_review.blade.php


+ 0 - 0
resources/views/app/dna/cancelled_supply_orders_pending_review.blade.php


+ 1 - 0
resources/views/app/dna/dashboard/calls_memos.blade.php

@@ -0,0 +1 @@
+<h1>Phone Calls & Memos</h1>

+ 1 - 0
resources/views/app/dna/dashboard/erx_orders.blade.php

@@ -0,0 +1 @@
+<h1>ERX & Orders</h1>

+ 1 - 0
resources/views/app/dna/dashboard/measurements.blade.php

@@ -0,0 +1 @@
+<div id="measurements-tab">Loading...</div>

+ 1 - 0
resources/views/app/dna/dashboard/messages.blade.php

@@ -0,0 +1 @@
+<h1>Messages</h1>

+ 1 - 0
resources/views/app/dna/dashboard/notifications.blade.php

@@ -0,0 +1 @@
+<h1>Notifications</h1>

+ 1 - 0
resources/views/app/dna/dashboard/supply_orders.blade.php

@@ -0,0 +1 @@
+<h1>Supply Orders</h1>

+ 5 - 0
resources/views/app/dna/erx_and_orders.blade.php

@@ -0,0 +1,5 @@
+@extends ('layouts/template')
+
+@section('content')
+    <h1>Hi</h1>
+@endsection

+ 0 - 0
resources/views/app/dna/erx_and_orders_pending_signature.blade.php


+ 0 - 0
resources/views/app/dna/new_patients_awaiting_visit.blade.php


+ 5 - 0
resources/views/app/dna/notes.blade.php

@@ -0,0 +1,5 @@
+@extends ('layouts/template')
+
+@section('content')
+    <h1>Hi</h1>
+@endsection

+ 0 - 0
resources/views/app/dna/notes_pending_billing.blade.php


+ 0 - 0
resources/views/app/dna/notes_pending_signature.blade.php


+ 23 - 0
resources/views/app/dna/patients.blade.php

@@ -0,0 +1,23 @@
+@extends ('layouts/template')
+
+@section('content')
+<div class="p-3 mcp-theme-1" id="patients-list">
+    <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>
+                Patients
+            </strong>
+        </div>
+
+        <div class="card-body p-0">
+            <div class="p-3">
+                @include('app.mcp.patients_filters')
+            </div>
+            @include('app.mcp.patients-table')
+        </div>
+    </div>
+</div>
+@endsection
+

+ 0 - 0
resources/views/app/dna/patients_overdue.blade.php


+ 0 - 0
resources/views/app/dna/patients_without_appointments.blade.php


+ 5 - 0
resources/views/app/dna/reports.blade.php

@@ -0,0 +1,5 @@
+@extends ('layouts/template')
+
+@section('content')
+    <h1>Hi</h1>
+@endsection

+ 0 - 0
resources/views/app/dna/reports_pending_signature.blade.php


+ 5 - 0
resources/views/app/dna/supply_orders.blade.php

@@ -0,0 +1,5 @@
+@extends ('layouts/template')
+
+@section('content')
+    <h1>Hi</h1>
+@endsection

+ 0 - 0
resources/views/app/dna/supply_orders_pending_signature.blade.php


+ 2 - 0
resources/views/app/generic-bills/inline.blade.php

@@ -206,6 +206,7 @@ $genericBills = genericBills($pro, @$patient, @$entityType, @$entityUid);
                             @endif
 
                         </td>
+                        @if($pro->pro_type !== 'ADMIN')
                         <td> <!-- verification -->
                             @if(!$bill->is_cancelled)
                                 @if(!$bill->is_verified)
@@ -215,6 +216,7 @@ $genericBills = genericBills($pro, @$patient, @$entityType, @$entityUid);
                                 @endif
                             @endif
                         </td>
+                        @endif
                         @if($pro->pro_type === 'ADMIN')
                         <td> <!-- verification -->
                             @if(!$bill->is_cancelled)

+ 1 - 1
resources/views/app/guest/appointment-confirmation.blade.php

@@ -29,7 +29,7 @@
                         <p class="mb-2 text-secondary font-weight-bold">Appointment status history</p>
                         <div class="bg-light px-2 pt-2 border rounded mb-3">
                             @foreach($appointment->confirmationDecisions as $decision)
-                                <div class="mb-2"><b>{{$decision->accepted_or_rejected_or_waived}}</b> on <b>{{friendlier_date_time($decision->created_at)}}</b>
+                                <div class="mb-2"><b>{{$decision->decision_enum}}</b> on <b>{{friendlier_date_time($decision->created_at)}}</b>
                                     @if($decision->session && $decision->session->pro)
                                         by <b>{{$decision->session->pro->displayName()}}</b>
                                     @elseif($decision->session && $decision->session->client)

+ 55 - 0
resources/views/app/mcp/appointments.blade.php

@@ -0,0 +1,55 @@
+@extends ('layouts/template')
+
+@section('content')
+<div class="p-3 mcp-theme-1" id="patients-list">
+    <div class="card">
+
+        <div class="card-header px-3 py-2 d-flex align-items-center">
+            <strong class="mr-4">
+                <i class="fas fa-calendar-alt"></i>
+                Appointments
+            </strong>
+        </div>
+
+        <div class="card-body p-0">
+            <div class="p-3">
+                @include('app.mcp.appointments_filters')
+            </div>
+            <table class="table table-condensed p-0 m-0">
+                <thead class="bg-light">
+                    <tr>
+                        <th class="px-3 border-0">Date</th>
+                        <th class="px-3 border-0">HCP</th>
+                        <th class="px-3 border-0">Patient</th>
+                        <th class="px-3 border-0">New or FU?</th>
+                        <th class="px-3 border-0">Status</th>
+                        <th class="px-3 border-0">Note</th>
+                    </tr>
+                </thead>
+                <tbody>
+                    @foreach($appointments as $appointment)
+                    <tr>
+                        <td>{{-- date --}} -</td>
+                        <td>{{-- hcp --}} -</td>
+                        <td>{{-- patient --}} - </td>
+                        <td>{{-- New or FU? --}} - </td>  
+                        <td>{{-- Status --}} - </td>  
+                        <td>{{-- Note --}} - </td>
+                    </tr>
+                    @endforeach
+
+                    @if(count($appointments) === 0)
+                    <tr>
+                        <td colspan="6">No records found!</td>
+                    </tr>
+                    @endif
+                </tbody>
+
+            </table>
+            <div class="ml-2 mt-2">
+                {{ $appointments->appends(request()->input())->links() }}
+            </div>
+        </div>
+    </div>
+</div>
+@endsection

+ 100 - 0
resources/views/app/mcp/appointments_filters.blade.php

@@ -0,0 +1,100 @@
+<style>
+	#mcp-appointments-filters label {
+		font-weight: bold;
+	}
+
+	#mcp-appointments-filters .mw-100px {
+		min-width: 100px;
+	}
+</style>
+<form id="mcp-appointments-filters" method="GET" action="{{ route('mcp.appointments') }}" class="row align-items-end" v-cloak>
+	   <!-- DATE -->
+	<div class="col-md-2">
+		<div class="form-group">
+			<label>Date:</label>
+			<select name="date_category" class="form-control input-sm" v-model="filters.date_category">
+				<option value="">All</option>
+				<option value="EXACTLY">Exactly</option>
+				<option value="LESS_THAN">Less Than</option>
+				<option value="GREATER_THAN">Greater Than</option>
+				<option value="BETWEEN">Between</option>
+				<option value="NOT_BETWEEN">Not Between</option>
+			</select>
+		</div>
+	</div>
+	<div v-if="filters.date_category" class="col-md-2">
+		<div class="form-group">
+			<label>&nbsp;</label>
+			<input name="date_value_1" value="{{ $date_value_1 ?? '' }}" type="date" class="form-control input-sm" :placeholder="(filters.date_category === 'BETWEEN' || filters.date_category === 'NOT_BETWEEN') ? 'From' : 'Date'" />
+		</div>
+	</div>
+	<div v-if="filters.date_category && (filters.date_category === 'BETWEEN' || filters.date_category === 'NOT_BETWEEN')" class="col-md-2">
+		<div class="form-group">
+			<label>&nbsp;</label>
+			<input name="date_value_2" value="{{ $date_value_2 ?? '' }}" type="date" class="form-control input-sm" placeholder="To" />
+		</div>
+	</div>
+	<!-- STATUS -->
+	<div class="col-md-2">
+		<div class="form-group">
+			<label>Status:</label>
+			<select name="status" class="form-control input-sm" v-model="filters.status">
+				<option value="ALL">All</option>
+				<option value="NEW">New</option>
+				<option value="SIGNED">Signed</option>
+				<option value="VERIFIED">Verified</option>
+				<option value="PROCESSED">Processed</option>
+				<option value="CANCELLED">Cancelled</option>
+			</select>
+		</div>
+	</div>
+	
+	<!-- NEW/FU -->
+	<div class="col-md-2">
+		<div class="form-group">
+			<label>New or FU:</label>
+			<select name="new_or_fu" class="form-control input-sm" v-model="filters.new_or_fu">
+				<option value="ALL">All</option>
+				<option value="NEW">New</option>
+				<option value="FU">FU</option>
+			</select>
+		</div>
+	</div>
+
+	<div class="col-md-2">
+		<div class="form-group d-flex">
+			<label>&nbsp;</label>
+			<button type="submit" class="btn btn-primary btn-sm mr-2 mw-100px">Apply Filters</button>
+			<a href="{{ route('mcp.patients') }}" class="btn btn-danger btn-sm text-white mw-100px">Clear Filters</a>
+		</div>
+	</div>
+</form>
+
+<script>
+	(function() {
+		function init() {
+			window.apapp = new Vue({
+				el: '#mcp-appointments-filters',
+				delimiters: ['@{{', '}}'],
+				data: {
+					filters: {
+						date_category: "<?= $date_category ?? '' ?>",
+						status: "<?= $status ?? '' ?>",
+						new_or_fu: "<?= $new_or_fu ?? '' ?>"
+					}
+				},
+				methods: {
+					init: function() {
+						
+					}
+				},
+				mounted: function() {
+					this.init();
+				},
+			});
+
+
+		}
+		addMCInitializer('mcp-appointments-filters', init, '#mcp-appointments-filters');
+	})();
+</script>

+ 53 - 0
resources/views/app/mcp/bills.blade.php

@@ -0,0 +1,53 @@
+@extends ('layouts/template')
+
+@section('content')
+<div class="p-3 mcp-theme-1" id="patients-list">
+    <div class="card">
+
+        <div class="card-header px-3 py-2 d-flex align-items-center">
+            <strong class="mr-4">
+                <i class="fas fa-file-invoice-dollar"></i>
+                Bills
+            </strong>
+        </div>
+
+        <div class="card-body p-0">
+            <div class="p-3">
+                @include('app.mcp.bills_filters')
+            </div>
+            <table class="table table-condensed p-0 m-0">
+                <thead class="bg-light">
+                    <tr>
+                        <th class="px-3 border-0">Date</th>
+                        <th class="px-3 border-0">Patient</th>
+                        <th class="px-3 border-0">Service</th>
+                        <th class="px-3 border-0">Amount</th>
+                        <th class="px-3 border-0">Status</th>
+                    </tr>
+                </thead>
+                <tbody>
+                    @foreach($bills as $bill)
+                    <tr>
+                        <td>{{-- date --}} -</td>
+                        <td>{{-- patient --}} -</td>
+                        <td>{{-- service --}} - </td>
+                        <td>{{-- amount --}} - </td>                        
+                        <td>{{-- status --}} - </td>
+                    </tr>
+                    @endforeach
+
+                    @if(count($bills) === 0)
+                    <tr>
+                        <td colspan="5">No records found!</td>
+                    </tr>
+                    @endif
+                </tbody>
+
+            </table>
+            <div class="ml-2 mt-2">
+                {{ $bills->appends(request()->input())->links() }}
+            </div>
+        </div>
+    </div>
+</div>
+@endsection

+ 87 - 0
resources/views/app/mcp/bills_filters.blade.php

@@ -0,0 +1,87 @@
+<style>
+	#mcp-bills-filters label {
+		font-weight: bold;
+	}
+
+	#mcp-bills-filters .mw-100px {
+		min-width: 100px;
+	}
+</style>
+<form id="mcp-bills-filters" method="GET" action="{{ route('mcp.notes') }}" class="row align-items-end" v-cloak>
+	<!-- DATE	 -->
+	<div class="col-md-2">
+		<div class="form-group">
+			<label>Date:</label>
+			<select name="date_category" class="form-control input-sm" v-model="filters.date_category">
+				<option value="">All</option>
+				<option value="EXACTLY">Exactly</option>
+				<option value="LESS_THAN">Less Than</option>
+				<option value="GREATER_THAN">Greater Than</option>
+				<option value="BETWEEN">Between</option>
+				<option value="NOT_BETWEEN">Not Between</option>
+			</select>
+		</div>
+	</div>
+	<div v-if="filters.date_category" class="col-md-2">
+		<div class="form-group">
+			<label>&nbsp;</label>
+			<input name="date_value_1" value="{{ $date_value_1 ?? '' }}" type="date" class="form-control input-sm" :placeholder="(filters.date_category === 'BETWEEN' || filters.date_category === 'NOT_BETWEEN') ? 'From' : 'Date'" />
+		</div>
+	</div>
+	<div v-if="filters.date_category && (filters.date_category === 'BETWEEN' || filters.date_category === 'NOT_BETWEEN')" class="col-md-2">
+		<div class="form-group">
+			<label>&nbsp;</label>
+			<input name="date_value_2" value="{{ $date_value_2 ?? '' }}" type="date" class="form-control input-sm" placeholder="To" />
+		</div>
+	</div>
+	<!-- STATUS -->
+	<div class="col-md-2">
+		<div class="form-group">
+			<label>Status:</label>
+			<select name="status" class="form-control input-sm" v-model="filters.status">
+				<option value="ALL">All</option>
+				<option value="NEW">New</option>
+				<option value="SIGNED">Signed</option>
+				<option value="VERIFIED">Verified</option>
+				<option value="PROCESSED">Processed</option>
+				<option value="CANCELLED">Cancelled</option>
+			</select>
+		</div>
+	</div>
+
+	<div class="col-md-2">
+		<div class="form-group d-flex">
+			<label>&nbsp;</label>
+			<button type="submit" class="btn btn-primary btn-sm mr-2 mw-100px">Apply Filters</button>
+			<a href="{{ route('mcp.patients') }}" class="btn btn-danger btn-sm text-white mw-100px">Clear Filters</a>
+		</div>
+	</div>
+</form>
+
+<script>
+	(function() {
+		function init() {
+			window.apapp = new Vue({
+				el: '#mcp-bills-filters',
+				delimiters: ['@{{', '}}'],
+				data: {
+					filters: {
+						date_category: "<?= $date_category ?? '' ?>",
+						status: "<?= $status ?? '' ?>"
+					}
+				},
+				methods: {
+					init: function() {
+
+					}
+				},
+				mounted: function() {
+					this.init();
+				},
+			});
+
+
+		}
+		addMCInitializer('mcp-bills-filters', init, '#mcp-bills-filters');
+	})();
+</script>

+ 19 - 0
resources/views/app/mcp/cancelled_appointments_pending_review.blade.php

@@ -0,0 +1,19 @@
+@extends ('layouts/template')
+
+@section('content')
+    <div class="p-3 mcp-theme-1" id="patients-list">
+        <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>
+                    Cancelled Appointments Pending Review
+                </strong>
+            </div>
+
+            <div class="card-body p-0">
+
+            </div>
+        </div>
+    </div>
+@endsection

+ 44 - 0
resources/views/app/mcp/cancelled_bills_pending_review.blade.php

@@ -0,0 +1,44 @@
+<div class="p-3 mcp-theme-1">
+    <div class="card">
+
+        <div class="card-header px-3 py-2 d-flex align-items-center border-bottom-0">
+            <strong class="mr-4">
+                <i class="fas fa-user-injured"></i>
+                Cancelled Bills Pending Review
+            </strong>
+        </div>
+
+        <div class="card-body p-0 border-top-0 pb-0">
+
+
+            <table class="table table-sm table-striped mb-0">
+                <thead>
+                <tr>
+                    <th class="border-bottom-0">Date</th>
+                    <th class="border-bottom-0">Patient</th>
+                    <th class="border-bottom-0">Service</th>
+                    <th class="border-bottom-0">Amount</th>
+                    <th class="border-bottom-0">Status</th>
+                </tr>
+                </thead>
+                <tbody>
+                @foreach($records as $row)
+                    <tr>
+                        <td>{{ friendly_date_time($row->effective_date, false) }}</td>
+                        <td>
+                            <a target="_blank" native href="{{route('patients.view.dashboard', $row->client)}}">
+                                {{$row->client->displayName()}}
+                            </a>
+                        </td>
+                        <td>{{ $row->code }}</td>
+                        <td>{{ $row->hcp_expected_payment_amount }}</td>
+                        <td>Cancelled</td>
+                    </tr>
+                @endforeach
+                </tbody>
+            </table>
+        </div>
+    </div>
+</div>
+
+

+ 45 - 0
resources/views/app/mcp/cancelled_supply_orders_pending_review.blade.php

@@ -0,0 +1,45 @@
+<div class="p-3 mcp-theme-1">
+    <div class="card">
+
+        <div class="card-header px-3 py-2 d-flex align-items-center border-bottom-0">
+            <strong class="mr-4">
+                <i class="fas fa-user-injured"></i>
+                Cancelled Supply Orders Pending Review
+            </strong>
+        </div>
+
+        <div class="card-body p-0 border-top-0 pb-0">
+
+
+            <table class="table table-sm table-striped mb-0">
+                <thead>
+                <tr>
+                    <th class="border-bottom-0">Date</th>
+                    <th class="border-bottom-0">Patient</th>
+                    <th class="border-bottom-0">Product</th>
+                    <th class="border-bottom-0">Reason</th>
+                    <th class="border-bottom-0">Status</th>
+                </tr>
+                </thead>
+                <tbody>
+                @foreach($records as $row)
+                    <tr>
+                        <td>{{ friendly_date_time($row->created_at, false) }}</td>
+                        <td>
+                            <a target="_blank" native href="{{route('patients.view.dashboard', $row->client)}}">
+                                {{$row->client->displayName()}}
+                            </a>
+                        </td>
+                        <td>{{ $row->product->title }}</td>
+                        <td>{{ $row->reason ?: '-' }}</td>
+                        <td>Cancelled</td>
+                    </tr>
+                @endforeach
+                </tbody>
+            </table>
+        </div>
+    </div>
+</div>
+
+
+

+ 53 - 0
resources/views/app/mcp/client_messages.blade.php

@@ -0,0 +1,53 @@
+@extends ('layouts/template')
+
+@section('content')
+<div class="p-3 mcp-theme-1" id="patients-list">
+    <div class="card">
+
+        <div class="card-header px-3 py-2 d-flex align-items-center">
+            <strong class="mr-4">
+                <i class="far fa-comments"></i>
+                Client Messages
+            </strong>
+        </div>
+
+        <div class="card-body p-0">
+            <div class="p-3">
+                @include('app.mcp.client_messages_filters')
+            </div>
+            <table class="table table-condensed p-0 m-0">
+                <thead class="bg-light">
+                    <tr>
+                        <th class="px-3 border-0">Date</th>
+                        <th class="px-3 border-0">To</th>
+                        <th class="px-3 border-0">From</th>
+                        <th class="px-3 border-0">Message</th>
+                        <th class="px-3 border-0">Status</th>
+                    </tr>
+                </thead>
+                <tbody>
+                    @foreach($clientMessages as $clientMessage)
+                    <tr>
+                        <td>{{ $clientMessage->created_at }}</td>
+                        <td>{{$clientMessage->to}}</td>
+                        <td>{{$clientMessage->from}}</td>
+                        <td><?= nl2br($clientMessage->body) ?></td>                        
+                        <td>{{-- status --}} - </td>
+                    </tr>
+                    @endforeach
+
+                    @if(count($clientMessages) === 0)
+                    <tr>
+                        <td colspan="5">No records found!</td>
+                    </tr>
+                    @endif
+                </tbody>
+
+            </table>
+            <div class="ml-2 mt-2">
+                {{ $clientMessages->appends(request()->input())->links() }}
+            </div>
+        </div>
+    </div>
+</div>
+@endsection

+ 95 - 0
resources/views/app/mcp/client_messages_filters.blade.php

@@ -0,0 +1,95 @@
+<style>
+	#mcp-client-messages-filters label {
+		font-weight: bold;
+	}
+
+	#mcp-client-messages-filters .mw-100px {
+		min-width: 100px;
+	}
+</style>
+<form id="mcp-client-messages-filters" method="GET" action="{{ route('mcp.client_messages') }}" class="row align-items-end" v-cloak>
+	<!-- DATE	 -->
+	<div class="col-md-2">
+		<div class="form-group">
+			<label>Date:</label>
+			<select name="date_category" class="form-control input-sm" v-model="filters.date_category">
+				<option value="">All</option>
+				<option value="EXACTLY">Exactly</option>
+				<option value="LESS_THAN">Less Than</option>
+				<option value="GREATER_THAN">Greater Than</option>
+				<option value="BETWEEN">Between</option>
+				<option value="NOT_BETWEEN">Not Between</option>
+			</select>
+		</div>
+	</div>
+	<div v-if="filters.date_category" class="col-md-2">
+		<div class="form-group">
+			<label>&nbsp;</label>
+			<input name="date_value_1" value="{{ $date_value_1 ?? '' }}" type="date" class="form-control input-sm" :placeholder="(filters.date_category === 'BETWEEN' || filters.date_category === 'NOT_BETWEEN') ? 'From' : 'Date'" />
+		</div>
+	</div>
+	<div v-if="filters.date_category && (filters.date_category === 'BETWEEN' || filters.date_category === 'NOT_BETWEEN')" class="col-md-2">
+		<div class="form-group">
+			<label>&nbsp;</label>
+			<input name="date_value_2" value="{{ $date_value_2 ?? '' }}" type="date" class="form-control input-sm" placeholder="To" />
+		</div>
+	</div>
+	<!-- TO OR FROM ME -->
+	<div class="col-md-2">
+		<div class="form-group">
+			<label>To or From Me:</label>
+			<select name="to_or_from_me" class="form-control input-sm" v-model="filters.to_or_from_me">
+				<option value="ALL">All</option>
+				<option value="TO_ME">To me</option>
+				<option value="FROM_ME">From Me</option>
+			</select>
+		</div>
+	</div>
+	<!-- STATUS -->
+	<div class="col-md-2">
+		<div class="form-group">
+			<label>Status:</label>
+			<select name="status" class="form-control input-sm" v-model="filters.status">
+				<option value="ALL">All</option>
+				<option value="AWAITING_REPLY">AWaiting Reply</option>
+			</select>
+		</div>
+	</div>
+
+	<div class="col-md-2">
+		<div class="form-group d-flex">
+			<label>&nbsp;</label>
+			<button type="submit" class="btn btn-primary btn-sm mr-2 mw-100px">Apply Filters</button>
+			<a href="{{ route('mcp.patients') }}" class="btn btn-danger btn-sm text-white mw-100px">Clear Filters</a>
+		</div>
+	</div>
+</form>
+
+<script>
+	(function() {
+		function init() {
+			window.apapp = new Vue({
+				el: '#mcp-client-messages-filters',
+				delimiters: ['@{{', '}}'],
+				data: {
+					filters: {
+						date_category: "<?= $date_category ?? '' ?>",
+						to_or_from_me: "<?= $to_or_from_me ?? '' ?>",
+						status: "<?= $status ?? '' ?>"
+					}
+				},
+				methods: {
+					init: function() {
+
+					}
+				},
+				mounted: function() {
+					this.init();
+				},
+			});
+
+
+		}
+		addMCInitializer('mcp-client-messages-filters', init, '#mcp-client-messages-filters');
+	})();
+</script>

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

@@ -0,0 +1,70 @@
+<table v-if="events.length > 0"
+       class="mb-0 table table-sm table-bordered appointments">
+    <tr v-for="event in events" class="">
+        <td>
+            <a :href="'/patients/view/' + event.clientUid" class="font-weight-bold">@{{
+                event.clientName }}</a>
+        </td>
+        <td>
+            {{-- <span class="small d-inline-block text-secondary font-weight-normal"> (@{{ event.clientAge }} y.o. @{{event.clientSex}})</span>--}}
+            @{{ event.friendlyStartTime }} - @{{ event.friendlyEndTime }} <span
+                class="text-secondary">@{{ formatTimeZone(event.timezone) }}</span>
+            <span v-if="event.title"
+                  class="d-inline-block ml- 2 text-secondary font-weight-bold">
+                                                      &nbsp;/&nbsp;
+                                                  @{{ event.title }}
+                                                  </span>
+            <a :href="'/patients/view/' + event.clientUid + '/calendar/' + event.uid">
+                <i class="fa fa-edit"></i>
+            </a>
+        </td>
+        <td>
+            <div class="d-flex align-items-baseline">
+                <!-- <div v-if="event.status === 'CREATED'"
+                     class="text-warning-mellow font-weight-bold">
+                    <i class="fa fa-exclamation-triangle"></i>
+                    Confirmation pending
+                </div>
+                <div v-else-if="event.status === 'CONFIRMED'"
+                     class="text-success font-weight-bold">
+                    <i class="fa fa-check"></i>
+                    Confirmed by the patient
+                </div>
+                <div v-else-if="event.status === 'REJECTED'"
+                     class="text-danger font-weight-bold">
+                    <i class="fa fa-stop"></i>
+                    Rejected by the patient
+                </div> -->
+                <select v-model="event.newStatus"
+                        class="form-control input-sm bg-light"
+                        v-on:change="updateStatus(event)">
+                    <option value="PENDING">PENDING</option>
+                    <option value="CONFIRMED">CONFIRMED</option>
+                    <option value="CANCELLED">CANCELLED</option>
+                    <option value="COMPLETED">COMPLETED</option>
+                </select>
+                <div v-if="selectedDate === '{{ date('Y-m-d') }}'"
+                     class="pt-1 text-right"
+                     :class="event.started ? 'text-danger': 'text-secondary'">
+                    @{{ event.inHowManyHours }}
+                </div>
+            </div>
+        </td>
+        <td>
+            <div>
+                <b v-if="event.coverage == 'YES'" class="text-success">Covered</b>
+                <b v-else-if="event.coverage == 'NO'" class="text-danger">Not
+                    Covered</b>
+                <b v-else class="text-warning-mellow">Pending</b>
+            </div>
+        </td>
+    </tr>
+</table>
+<div v-if="numEventsForDate === 0 && selectedDate"
+     class="bg-light p-3 text-secondary border bounded">
+    <span v-if="filterStatus === ''">You have no appointments on <b>@{{ formatSelectedDate(selectedDate) }}</b></span>
+    <span v-if="filterStatus !== ''">You have no appointments on <b>@{{ formatSelectedDate(selectedDate) }}</b> with status <b>@{{ filterStatus }}</b></span>
+</div>
+<div v-show="!selectedDate" class="bg-light p-3 text-secondary border bounded">
+    Please select a date from the calendar on the left
+</div>

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

@@ -0,0 +1 @@
+<h1>Phone Calls & Memos</h1>

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

@@ -0,0 +1 @@
+<h1>ERX & Orders</h1>

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

@@ -0,0 +1 @@
+<div id="measurements-tab">Loading...</div>

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

@@ -0,0 +1 @@
+<h1>Messages</h1>

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

@@ -0,0 +1,67 @@
+<?php
+    $apptsPending = [
+        'status' => $pro->getAppointmentsPendingStatusChangeAck(),
+        'decision' => $pro->getAppointmentsPendingDecisionAck(),
+        // 'time' => $pro->getAppointmentsPendingTimeChangeAck()
+    ];
+?>
+@if(!count($apptsPending['status']) && !count($apptsPending['decision'])/* && !count($apptsPending['time'])*/)
+    No appointment changes
+@endif
+@if(count($apptsPending['status']))
+    <b class="text-secondary my-2 d-block">Appointment Status Changes</b>
+    @foreach($apptsPending['status'] as $appt)
+        <div class="d-flex mb-1">
+            <div>
+                <b>{{$appt->client->displayName()}}</b>
+                <span class="ml-2">{{friendlier_date_time($appt->start_time)}}</span>
+                <span class="ml-2">{{$appt->status}}</span>
+                @if($appt->status_memo)
+                    <div class="text-secondary text-sm">{{$appt->status_memo}} This is a status memo</div>
+                @endif
+            </div>
+            <div moe relative class="ml-auto">
+                <form show url="/api/appointment/acknowledgeStatusAsAppointmentPro">
+                    <input type="hidden" name="uid" value="{{$appt->uid}}">
+                    <input type="hidden" name="currentStatus" value="{{$appt->status}}">
+                    @if($appt->status_memo !== null)
+                    <input type="hidden" name="currentStatusMemo" value="{{$appt->status_memo}}">
+                    @endif
+                    <input type="hidden" name="currentRawDate" value="{{$appt->raw_date}}">
+                    <input type="hidden" name="currentRawStartTime" value="{{$appt->raw_start_time}}">
+                    <input type="hidden" name="currentRawEndTime" value="{{$appt->raw_end_time}}">
+                    <input type="hidden" name="currentTimezone" value="{{$appt->timezone}}">
+                    <button submit class="bg-transparent border-0 p-0 text-primary">Acknowledge</button>
+                </form>
+            </div>
+        </div>
+    @endforeach
+@endif
+@if(count($apptsPending['decision']))
+    <b class="text-secondary my-2 d-block">Appointment Confirmation Changes</b>
+    @foreach($apptsPending['decision'] as $appt)
+        <div class="d-flex mb-1">
+            <b>{{$appt->client->displayName()}}</b>
+            <span class="ml-2">{{friendlier_date_time($appt->start_time)}}</span>
+            <span class="ml-2">{{$appt->latestConfirmationDecision->decision_enum}}</span>
+            <div moe relative class="ml-auto">
+                <form show url="/api/appointment/acknowledgeDecisionAsAppointmentPro">
+                    <input type="hidden" name="uid" value="{{$appt->uid}}">
+                    <button submit class="bg-transparent border-0 p-0 text-primary">Acknowledge</button>
+                </form>
+            </div>
+        </div>
+    @endforeach
+@endif
+{{--@if(count($apptsPending['time']))
+    <b class="text-secondary my-2 d-block">Appointment Timing Changes</b>
+    @foreach($apptsPending['time'] as $appt)
+        <div class="d-flex mb-1">
+            <b>{{$appt->client->displayName()}}</b>
+            <span class="ml-2">{{friendlier_date_time($appt->start_time)}}</span>
+            <a class="ml-auto">
+                Acknowledge
+            </a>
+        </div>
+    @endforeach
+@endif--}}

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

@@ -0,0 +1 @@
+<h1>Reports</h1>

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

@@ -0,0 +1 @@
+<h1>Supply Orders</h1>

+ 51 - 0
resources/views/app/mcp/erx_and_orders.blade.php

@@ -0,0 +1,51 @@
+@extends ('layouts/template')
+
+@section('content')
+<div class="p-3 mcp-theme-1" id="patients-list">
+    <div class="card">
+
+        <div class="card-header px-3 py-2 d-flex align-items-center">
+            <strong class="mr-4">
+                <i class="fas fa-file-prescription"></i>
+                ERx & Orders
+            </strong>
+        </div>
+
+        <div class="card-body p-0">
+            <div class="p-3">
+                @include('app.mcp.erx_and_orders_filters')
+            </div>
+            <table class="table table-condensed p-0 m-0">
+                <thead class="bg-light">
+                    <tr>
+                        <th class="px-3 border-0">Date</th>
+                        <th class="px-3 border-0">Patient</th>
+                        <th class="px-3 border-0">Content</th>
+                        <th class="px-3 border-0">Status</th>
+                    </tr>
+                </thead>
+                <tbody>
+                    @foreach($erxAndOrders as $erxAndOrder)
+                    <tr>
+                        <td>{{-- date --}} -</td>
+                        <td>{{-- patient --}} -</td>
+                        <td>{{-- content --}} - </td>
+                        <td>{{-- status --}} - </td>
+                    </tr>
+                    @endforeach
+
+                    @if(count($erxAndOrders) === 0)
+                    <tr>
+                        <td colspan="4">No records found!</td>
+                    </tr>
+                    @endif
+                </tbody>
+
+            </table>
+            <div class="ml-2 mt-2">
+                {{ $erxAndOrders->appends(request()->input())->links() }}
+            </div>
+        </div>
+    </div>
+</div>
+@endsection

+ 87 - 0
resources/views/app/mcp/erx_and_orders_filters.blade.php

@@ -0,0 +1,87 @@
+<style>
+	#mcp-erx-and-orders-filters label {
+		font-weight: bold;
+	}
+
+	#mcp-erx-and-orders-filters .mw-100px {
+		min-width: 100px;
+	}
+</style>
+<form id="mcp-erx-and-orders-filters" method="GET" action="{{ route('mcp.notes') }}" class="row align-items-end" v-cloak>
+	<!-- DATE	 -->
+	<div class="col-md-2">
+		<div class="form-group">
+			<label>Date:</label>
+			<select name="date_category" class="form-control input-sm" v-model="filters.date_category">
+				<option value="">All</option>
+				<option value="EXACTLY">Exactly</option>
+				<option value="LESS_THAN">Less Than</option>
+				<option value="GREATER_THAN">Greater Than</option>
+				<option value="BETWEEN">Between</option>
+				<option value="NOT_BETWEEN">Not Between</option>
+			</select>
+		</div>
+	</div>
+	<div v-if="filters.date_category" class="col-md-2">
+		<div class="form-group">
+			<label>&nbsp;</label>
+			<input name="date_value_1" value="{{ $date_value_1 ?? '' }}" type="date" class="form-control input-sm" :placeholder="(filters.date_category === 'BETWEEN' || filters.date_category === 'NOT_BETWEEN') ? 'From' : 'Date'" />
+		</div>
+	</div>
+	<div v-if="filters.date_category && (filters.date_category === 'BETWEEN' || filters.date_category === 'NOT_BETWEEN')" class="col-md-2">
+		<div class="form-group">
+			<label>&nbsp;</label>
+			<input name="date_value_2" value="{{ $date_value_2 ?? '' }}" type="date" class="form-control input-sm" placeholder="To" />
+		</div>
+	</div>
+	<!-- STATUS -->
+	<div class="col-md-2">
+		<div class="form-group">
+			<label>Status:</label>
+			<select name="status" class="form-control input-sm" v-model="filters.status">
+				<option value="ALL">All</option>
+				<option value="NEW">New</option>
+				<option value="SIGNED">Signed</option>
+				<option value="VERIFIED">Verified</option>
+				<option value="PROCESSED">Processed</option>
+				<option value="CANCELLED">Cancelled</option>
+			</select>
+		</div>
+	</div>
+
+	<div class="col-md-2">
+		<div class="form-group d-flex">
+			<label>&nbsp;</label>
+			<button type="submit" class="btn btn-primary btn-sm mr-2 mw-100px">Apply Filters</button>
+			<a href="{{ route('mcp.patients') }}" class="btn btn-danger btn-sm text-white mw-100px">Clear Filters</a>
+		</div>
+	</div>
+</form>
+
+<script>
+	(function() {
+		function init() {
+			window.apapp = new Vue({
+				el: '#mcp-erx-and-orders-filters',
+				delimiters: ['@{{', '}}'],
+				data: {
+					filters: {
+						date_category: "<?= $date_category ?? '' ?>",
+						status: "<?= $status ?? '' ?>"
+					}
+				},
+				methods: {
+					init: function() {
+
+					}
+				},
+				mounted: function() {
+					this.init();
+				},
+			});
+
+
+		}
+		addMCInitializer('mcp-erx-and-orders-filters', init, '#mcp-erx-and-orders-filters');
+	})();
+</script>

+ 76 - 0
resources/views/app/mcp/erx_and_orders_pending_signature.blade.php

@@ -0,0 +1,76 @@
+<div class="p-3 mcp-theme-1">
+    <div class="card">
+
+        <div class="card-header px-3 py-2 d-flex align-items-center border-bottom-0">
+            <strong class="mr-4">
+                <i class="fas fa-user-injured"></i>
+                ERx & Orders Pending Signature
+            </strong>
+        </div>
+
+        <div class="card-body p-0 border-top-0 pb-0">
+
+
+            <table class="table table-sm table-striped mb-0">
+                <thead>
+                <tr>
+                    <th class="border-bottom-0">Date</th>
+                    <th class="border-bottom-0">Patient</th>
+                    <th class="border-bottom-0">Category</th>
+                    <th class="border-bottom-0">Content</th>
+                    <th class="border-bottom-0">Status</th>
+                </tr>
+                </thead>
+                <tbody>
+                @foreach($records as $row)
+                    <tr>
+                        <td>{{ friendly_date_time($row->created_at, false) }}</td>
+                        <td>
+                            <a target="_blank" native href="{{route('patients.view.dashboard', $row->client)}}">
+                                {{$row->client->displayName()}}
+                            </a>
+                        </td>
+                        <td>{{ ucwords($row->erx_category) }}</td>
+                        <td>
+                            <?php $parsed = @$row->clinical_detail_json ? json_decode($row->clinical_detail_json) : false; ?>
+                            @if($row->erx_category === 'DRUG')
+                                <?php
+                                $drugs = ($parsed && @$parsed->items) ? $parsed->items : [];
+                                ?>
+                                @foreach($drugs as $drug)
+                                    <div class="d-flex align-items-baseline mb-1">
+                                        <b class="mr-2">{{$drug->medication ?? '-'}}</b>
+                                        <span class="text-secondary mr-1">{{$drug->frequency ?? ''}}</span>
+                                    </div>
+                                @endforeach
+                            @elseif($row->erx_category === 'LAB' || $row->erx_category === 'IMAGING')
+                                <?php
+                                $tests = ($parsed && @$parsed->tests) ? $parsed->tests : [];
+                                ?>
+                                @foreach($tests as $test)
+                                    <div class="d-flex align-items-baseline mb-1">
+                                        <b class="mr-2">{{$test ?? '-'}}</b>
+                                    </div>
+                                @endforeach
+                            @elseif($row->erx_category === 'REFERRAL')
+                                <b class="mr-2">{{@$parsed->to ?? '-'}}</b>
+                                <span class="text-secondary mr-1">{{@$parsed->memo ?? '-'}}</span>
+                            @elseif($row->erx_category === 'SUPPLY')
+                                <b class="mr-2">{{@$parsed->item ?? '-'}}</b>
+                                <span class="text-secondary mr-1">{{@$parsed->quantity ?? '-'}}</span>
+                            @elseif($row->erx_category === 'OTHER')
+                                <b class="mr-2">{{@$parsed->title ?? '-'}}</b>
+                                <span class="text-secondary mr-1">{{@$parsed->memo ?? '-'}}</span>
+                            @endif
+                        </td>
+                        <td>{{ $row->pro_declared_status ?: '-' }}</td>
+                    </tr>
+                @endforeach
+                </tbody>
+            </table>
+        </div>
+    </div>
+</div>
+
+
+

+ 79 - 0
resources/views/app/mcp/new_patients_awaiting_visit.blade.php

@@ -0,0 +1,79 @@
+    <div class="p-3 mcp-theme-1">
+        <div class="card">
+
+            <div class="card-header px-3 py-2 d-flex align-items-center border-bottom-0">
+                <strong class="mr-4">
+                    <i class="fas fa-user-injured"></i>
+                    New Patients Awaiting Visit
+                </strong>
+            </div>
+
+            <div class="card-body p-0 border-top-0 pb-0">
+                <table class="table table-sm table-striped mb-0">
+                    <thead>
+                    <tr>
+                        <th class="border-bottom-0">Chart #</th>
+                        <th class="border-bottom-0">Name (F.I. LAST)</th>
+                        <th class="border-bottom-0">DOB</th>
+                        <th class="border-bottom-0">Gender</th>
+                        <th class="border-bottom-0">BMI</th>
+                        <th class="border-bottom-0">Insurance</th>
+                        <th class="border-bottom-0">Last Visit</th>
+                        <th class="border-bottom-0">Next Appt.</th>
+                        <th class="border-bottom-0">Status</th>
+                        <th class="border-bottom-0">CCM</th>
+                        <th class="border-bottom-0">RPM</th>
+                        <th class="border-bottom-0">Last Weight-In</th>
+                        <th class="border-bottom-0">Last BP</th>
+                        <th class="border-bottom-0">Assigned On</th>
+                    </tr>
+                    </thead>
+                    <tbody>
+                    @foreach($records as $row)
+                        <tr>
+                            <td class="border-bottom-0">
+                                <a target="_blank" native href="{{route('patients.view.dashboard', $row)}}">
+                                    {{$row->chart_number}}
+                                </a>
+                            </td>
+                            <td class="border-bottom-0">{{implode(' ', [$row->name_first, $row->name_last])}}</td>
+                            <td class="border-bottom-0">{{$row->dob}}</td>
+                            <td class="border-bottom-0">{{$row->sex}}</td>
+                            <td class="border-bottom-0">{{$row->usual_bmi}}</td>
+                            <td class="border-bottom-0">
+                                <?php $coverageStatus = $row->getPrimaryCoverageStatus(); ?>
+                                @if($coverageStatus === 'YES')
+                                    <div class="text-nowrap">Covered <i class="fa fa-check-circle text-success"></i>
+                                    </div>
+                                @elseif($coverageStatus === 'NO')
+                                    <div class="text-nowrap">Not Covered <i class="fa fa-times text-danger"></i></div>
+                                @else
+                                    <div class="text-nowrap">Unknown <i
+                                                class="fa fa-exclamation-triangle text-warning-mellow"></i></div>
+                                @endif
+                                <?php $coverage = $row->getPrimaryCoverage(); ?>
+                                @if($coverage)
+                                    {{$coverage->toString()}}
+                                @endif
+                            </td>
+                            <td class="border-bottom-0">{{$row->lastMcpAppointment() ? $row->lastMcpAppointment()->start_date : '-'}}</td>
+                            <td class="border-bottom-0">{{$row->nextMcpAppointment() ? $row->nextMcpAppointment()->start_date : '-'}}</td>
+                            <td class="border-bottom-0">{{$row->nextMcpAppointment() ? $row->nextMcpAppointment()->status : '-'}}</td>
+                            <td class="border-bottom-0">{{$row->is_enrolled_in_cm ? 'Yes' : 'No'}}</td>
+                            <td class="border-bottom-0">{{$row->is_enrolled_in_rm ? 'Yes' : 'No'}}</td>
+                            <td class="border-bottom-0">
+                                <?php $m = $row->lastMeasurementOfType('Wt. (lbs.)'); ?>
+                                {{$m && $m->value ? round($m->value, 2) : '-'}}
+                            </td>
+                            <td class="border-bottom-0">
+                                <?php $m = $row->lastMeasurementOfType('BP'); ?>
+                                {{$m && $m->value ? $m->value : '-'}}
+                            </td>
+                            <td class="border-bottom-0">{{$row->getMcpAssignedOn()}}</td>
+                        </tr>
+                    @endforeach
+                    </tbody>
+                </table>
+            </div>
+        </div>
+    </div>

+ 51 - 0
resources/views/app/mcp/notes.blade.php

@@ -0,0 +1,51 @@
+@extends ('layouts/template')
+
+@section('content')
+<div class="p-3 mcp-theme-1" id="patients-list">
+    <div class="card">
+
+        <div class="card-header px-3 py-2 d-flex align-items-center">
+            <strong class="mr-4">
+                <i class="fas fa-notes-medical"></i>
+                Notes
+            </strong>
+        </div>
+
+        <div class="card-body p-0">
+            <div class="p-3">
+                @include('app.mcp.notes_filters')
+            </div>
+            <table class="table table-condensed p-0 m-0">
+                <thead class="bg-light">
+                    <tr>
+                        <th class="px-3 border-0">Date</th>
+                        <th class="px-3 border-0">Patient</th>
+                        <th class="px-3 border-0">ICD</th>
+                        <th class="px-3 border-0">Status</th>
+                    </tr>
+                </thead>
+                <tbody>
+                    @foreach($notes as $note)
+                    <tr>
+                        <td>{{-- date --}} -</td>
+                        <td>{{-- patient --}} - </td>
+                        <td>{{-- ICD --}} - </td>
+                        <td>{{-- Status --}} - </td>
+                    </tr>
+                    @endforeach
+
+                    @if(count($notes) === 0)
+                    <tr>
+                        <td colspan="5">No records found!</td>
+                    </tr>
+                    @endif
+                </tbody>
+
+            </table>
+            <div class="ml-2 mt-2">
+                {{ $notes->appends(request()->input())->links() }}
+            </div>
+        </div>
+    </div>
+</div>
+@endsection

+ 87 - 0
resources/views/app/mcp/notes_filters.blade.php

@@ -0,0 +1,87 @@
+<style>
+	#mcp-notes-filters label {
+		font-weight: bold;
+	}
+
+	#mcp-notes-filters .mw-100px {
+		min-width: 100px;
+	}
+</style>
+<form id="mcp-notes-filters" method="GET" action="{{ route('mcp.notes') }}" class="row align-items-end" v-cloak>
+	<!-- DATE	 -->
+	<div class="col-md-2">
+		<div class="form-group">
+			<label>Date:</label>
+			<select name="date_category" class="form-control input-sm" v-model="filters.date_category">
+				<option value="">All</option>
+				<option value="EXACTLY">Exactly</option>
+				<option value="LESS_THAN">Less Than</option>
+				<option value="GREATER_THAN">Greater Than</option>
+				<option value="BETWEEN">Between</option>
+				<option value="NOT_BETWEEN">Not Between</option>
+			</select>
+		</div>
+	</div>
+	<div v-if="filters.date_category" class="col-md-2">
+		<div class="form-group">
+			<label>&nbsp;</label>
+			<input name="date_value_1" value="{{ $date_value_1 ?? '' }}" type="date" class="form-control input-sm" :placeholder="(filters.date_category === 'BETWEEN' || filters.date_category === 'NOT_BETWEEN') ? 'From' : 'Date'" />
+		</div>
+	</div>
+	<div v-if="filters.date_category && (filters.date_category === 'BETWEEN' || filters.date_category === 'NOT_BETWEEN')" class="col-md-2">
+		<div class="form-group">
+			<label>&nbsp;</label>
+			<input name="date_value_2" value="{{ $date_value_2 ?? '' }}" type="date" class="form-control input-sm" placeholder="To" />
+		</div>
+	</div>
+	<!-- STATUS -->
+	<div class="col-md-2">
+		<div class="form-group">
+			<label>Status:</label>
+			<select name="status" class="form-control input-sm" v-model="filters.status">
+				<option value="ALL">All</option>
+				<option value="NEW">New</option>
+				<option value="SIGNED">Signed</option>
+				<option value="VERIFIED">Verified</option>
+				<option value="PROCESSED">Processed</option>
+				<option value="CANCELLED">Cancelled</option>
+			</select>
+		</div>
+	</div>	
+
+	<div class="col-md-2">
+		<div class="form-group d-flex">
+			<label>&nbsp;</label>
+			<button type="submit" class="btn btn-primary btn-sm mr-2 mw-100px">Apply Filters</button>
+			<a href="{{ route('mcp.patients') }}" class="btn btn-danger btn-sm text-white mw-100px">Clear Filters</a>
+		</div>
+	</div>
+</form>
+
+<script>
+	(function() {
+		function init() {
+			window.apapp = new Vue({
+				el: '#mcp-notes-filters',
+				delimiters: ['@{{', '}}'],
+				data: {
+					filters: {
+						date_category: "<?= $date_category ?? '' ?>",						
+						status: "<?= $status ?? '' ?>"
+					}
+				},
+				methods: {
+					init: function() {
+						
+					}
+				},
+				mounted: function() {
+					this.init();
+				},
+			});
+
+
+		}
+		addMCInitializer('mcp-notes-filters', init, '#mcp-notes-filters');
+	})();
+</script>

+ 48 - 0
resources/views/app/mcp/notes_pending_billing.blade.php

@@ -0,0 +1,48 @@
+<div class="p-3 mcp-theme-1">
+    <div class="card">
+
+        <div class="card-header px-3 py-2 d-flex align-items-center border-bottom-0">
+            <strong class="mr-4">
+                <i class="fas fa-user-injured"></i>
+                Notes Pending Billing
+            </strong>
+        </div>
+
+        <div class="card-body p-0 border-top-0 pb-0">
+            <table class="table table-sm table-striped mb-0">
+                <thead>
+                <tr>
+                    <th class="border-bottom-0">Date</th>
+                    <th class="border-bottom-0">Patient</th>
+                    <th class="border-bottom-0">ICD</th>
+                    <th class="border-bottom-0">Status</th>
+                </tr>
+                </thead>
+                <tbody>
+                @foreach($records as $row)
+                    <tr>
+                        <td class="border-bottom-0">
+                            <a native target="_blank" href="/patients/view/{{ $row->client->uid }}/notes/view/{{ $row->uid }}" class="font-weight-bold">
+                                {{ friendlier_date($row->effective_dateest) }}
+                            </a>
+                        </td>
+                        <td class="border-bottom-0">{{$row->client->displayName()}}</td>
+                        <td class="border-bottom-0">
+                            @foreach($row->reasons as $reason)
+                                <span class="pr-2">{{$reason->code}}</span>
+                            @endforeach
+                            @if(!$row->reasons || !count($row->reasons))
+                                -
+                            @endif
+                        </td>
+                        <td class="border-bottom-0">
+                            {{$row->overallStatus()}}
+                        </td>
+                    </tr>
+                @endforeach
+                </tbody>
+            </table>
+        </div>
+    </div>
+</div>
+

+ 48 - 0
resources/views/app/mcp/notes_pending_signature.blade.php

@@ -0,0 +1,48 @@
+<div class="p-3 mcp-theme-1">
+    <div class="card">
+
+        <div class="card-header px-3 py-2 d-flex align-items-center border-bottom-0">
+            <strong class="mr-4">
+                <i class="fas fa-user-injured"></i>
+                Notes Pending Signature
+            </strong>
+        </div>
+
+        <div class="card-body p-0 border-top-0 pb-0">
+            <table class="table table-sm table-striped mb-0">
+                <thead>
+                <tr>
+                    <th class="border-bottom-0">Date</th>
+                    <th class="border-bottom-0">Patient</th>
+                    <th class="border-bottom-0">ICD</th>
+                    <th class="border-bottom-0">Status</th>
+                </tr>
+                </thead>
+                <tbody>
+                @foreach($records as $row)
+                    <tr>
+                        <td class="border-bottom-0">
+                            <a native target="_blank" href="/patients/view/{{ $row->client->uid }}/notes/view/{{ $row->uid }}" class="font-weight-bold">
+                                {{ friendlier_date($row->effective_dateest) }}
+                            </a>
+                        </td>
+                        <td class="border-bottom-0">{{$row->client->displayName()}}</td>
+                        <td class="border-bottom-0">
+                            @foreach($row->reasons as $reason)
+                                <span class="pr-2">{{$reason->code}}</span>
+                            @endforeach
+                            @if(!$row->reasons || !count($row->reasons))
+                                -
+                            @endif
+                        </td>
+                        <td class="border-bottom-0">
+                            {{$row->overallStatus()}}
+                        </td>
+                    </tr>
+                @endforeach
+                </tbody>
+            </table>
+        </div>
+    </div>
+</div>
+

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

@@ -0,0 +1,74 @@
+<table class="table table-condensed p-0 m-0">
+	<thead class="bg-light">
+		<tr>
+			<th class="px-3 border-0">Chart #</th>
+			<th class="px-3 border-0">Name (F.I. LAST)</th>
+			<th class="px-3 border-0">DOB</th>
+			<th class="px-3 border-0">Gender</th>
+			<th class="px-3 border-0">BMI</th>
+			<th class="px-3 border-0">Insurance</th>
+			<th class="px-3 border-0">Last Visit</th>
+			<th class="px-3 border-0">Next Appt.</th>
+			<th class="px-3 border-0">Status</th>
+			<th class="px-3 border-0">CCM</th>
+			<th class="px-3 border-0">RPM</th>
+			<th class="px-3 border-0">Last Weight-In</th>
+			<th class="px-3 border-0">Last BP</th>
+			<th class="px-3 border-0">Assigned On</th>
+		</tr>
+	</thead>
+	<tbody>
+		@foreach($patients as $patient)
+		<tr>
+			<td class="px-3">
+				<a href="{{route('patients.view.dashboard', $patient)}}">
+					{{$patient->chart_number}}
+				</a>
+			</td>
+			<td>{{$patient->displayName()}}</td>
+			<td>{{ friendly_date_time($patient->dob, false) }} {{ $patient->age_in_years ? '(' . $patient->age_in_years . ' y.o)' : '(-)' }}</td>
+			<td>{{ $patient->sex }}</td>
+			<td>{{ $patient->usual_bmi }}</td>
+			<td>
+				<?php $coverageStatus = $patient->getPrimaryCoverageStatus(); ?>
+				@if($coverageStatus === 'YES')
+				<div class="text-nowrap">Covered <i class="fa fa-check-circle text-success"></i>
+				</div>
+				@elseif($coverageStatus === 'NO')
+				<div class="text-nowrap">Not Covered <i class="fa fa-times text-danger"></i></div>
+				@else
+				<div class="text-nowrap">Unknown <i class="fa fa-exclamation-triangle text-warning-mellow"></i></div>
+				@endif
+				<?php $coverage = $patient->getPrimaryCoverage(); ?>
+				@if($coverage)
+				{{$coverage->toString()}}
+				@endif
+			</td>
+			<td>{{$patient->lastMcpAppointment() ? $patient->lastMcpAppointment()->start_date : '-'}}</td>
+			<td>{{$patient->nextMcpAppointment() ? $patient->nextMcpAppointment()->start_date : '-'}}</td>
+			<td>{{$patient->nextMcpAppointment() ? $patient->nextMcpAppointment()->status : '-'}}</td>
+			<td>{{$patient->is_enrolled_in_cm ? 'Yes' : 'No'}}</td>
+			<td>{{$patient->is_enrolled_in_rm ? 'Yes' : 'No'}}</td>
+			<td>
+				<?php $m = $patient->lastMeasurementOfType('Wt. (lbs.)'); ?>
+				{{$m && $m->value ? round($m->value, 2) : '-'}}
+			</td>
+			<td>
+				<?php $m = $patient->lastMeasurementOfType('BP'); ?>
+				{{$m && $m->value ? $m->value : '-'}}
+			</td>
+			<td>{{$patient->getMcpAssignedOn()}}</td>
+		</tr>
+		@endforeach
+
+		@if(count($patients) === 0)
+		<tr>
+			<td colspan="14">No records found!</td>
+		</tr>
+		@endif
+	</tbody>
+
+</table>
+<div class="p-3">
+	{{$patients->links()}}
+</div>

+ 22 - 0
resources/views/app/mcp/patients.blade.php

@@ -0,0 +1,22 @@
+@extends ('layouts/template')
+
+@section('content')
+<div class="p-3 mcp-theme-1" id="patients-list">
+    <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>
+                Patients
+            </strong>
+        </div>
+
+        <div class="card-body p-0">
+            <div class="p-3">
+                @include('app.mcp.patients_filters')
+            </div>
+            @include('app.mcp.patients-table')
+        </div>
+    </div>
+</div>
+@endsection

+ 261 - 0
resources/views/app/mcp/patients_filters.blade.php

@@ -0,0 +1,261 @@
+<style>
+	#mcp-patients-filters label {
+		font-weight: bold;
+	}
+
+	#mcp-patients-filters .mw-100px {
+		min-width: 100px;
+	}
+</style>
+<form id="mcp-patients-filters" method="GET" action="{{ route('mcp.patients') }}" class="row align-items-end" v-cloak>
+	<!-- AGE	 -->
+	<div class="col-md-2">
+		<div class="form-group">
+			<label>Age:</label>
+			<select name="age_category" class="form-control input-sm" v-model="filters.age_category">
+				<option value="">All</option>
+				<option value="EXACTLY">Exactly</option>
+				<option value="LESS_THAN">Less Than</option>
+				<option value="GREATER_THAN">Greater Than</option>
+				<option value="BETWEEN">Between</option>
+				<option value="NOT_BETWEEN">Not Between</option>
+			</select>
+		</div>
+	</div>
+	<div v-show="filters.age_category" class="col-md-2">
+		<div class="form-group">
+			<label>&nbsp;</label>
+			<input name="age_value_1" v-model="filters.age_value_1" type="number" class="form-control input-sm" :placeholder="(filters.age_category === 'BETWEEN' || filters.age_category === 'NOT_BETWEEN') ? 'From' : 'Age'" />
+		</div>
+	</div>
+	<div v-show="filters.age_category && (filters.age_category === 'BETWEEN' || filters.age_category === 'NOT_BETWEEN')" class="col-md-2">
+		<div class="form-group">
+			<label>&nbsp;</label>
+			<input name="age_value_2" v-model="filters.age_value_2" type="number" class="form-control input-sm" placeholder="To" />
+		</div>
+	</div>
+	<!-- SEX -->
+	<div class="col-md-2">
+		<div class="form-group">
+			<label>Sex:</label>
+			<select name="sex" class="form-control input-sm" v-model="filters.sex">
+				<option value="">All</option>
+				<option value="M">Male</option>
+				<option value="F">Female</option>
+			</select>
+		</div>
+	</div>
+	<!-- BMI -->
+	<div class="col-md-2">
+		<div class="form-group">
+			<label>BMI:</label>
+			<select name="bmi_category" class="form-control input-sm" v-model="filters.bmi_category">
+				<option value="">All</option>
+				<option value="EXACTLY">Exactly</option>
+				<option value="LESS_THAN">Less Than</option>
+				<option value="GREATER_THAN">Greater Than</option>
+				<option value="BETWEEN">Between</option>
+				<option value="NOT_BETWEEN">Not Between</option>
+			</select>
+		</div>
+	</div>
+	<div v-show="filters.bmi_category" class="col-md-2">
+		<div class="form-group">
+			<label>&nbsp;</label>
+			<input name="bmi_value_1" v-model="filters.bmi_value_1" type="number" class="form-control input-sm" :placeholder="(filters.bmi_category === 'BETWEEN' || filters.bmi_category === 'NOT_BETWEEN') ? 'From' : 'BMI'" />
+		</div>
+	</div>
+	<div v-show="filters.bmi_category && (filters.bmi_category === 'BETWEEN' || filters.bmi_category === 'NOT_BETWEEN')" class="col-md-2">
+		<div class="form-group">
+			<label>&nbsp;</label>
+			<input name="bmi_value_2" v-model="filters.bmi_value_2" type="number" class="form-control input-sm" placeholder="To" />
+		</div>
+	</div>
+
+	<!-- LAST VISIT -->
+	<div class="col-md-2">
+		<div class="form-group">
+			<label>Last Visit **:</label>
+			<select name="last_visit_category" class="form-control input-sm" v-model="filters.last_visit_category">
+				<option value="">All</option>
+				<option value="EXACTLY">Exactly</option>
+				<option value="LESS_THAN">Less Than</option>
+				<option value="GREATER_THAN">Greater Than</option>
+				<option value="BETWEEN">Between</option>
+				<option value="NOT_BETWEEN">Not Between</option>
+			</select>
+		</div>
+	</div>
+	<div v-show="filters.last_visit_category" class="col-md-2">
+		<div class="form-group">
+			<label>&nbsp;</label>
+			<input name="last_visit_value_1" v-model="filters.last_visit_value_1" type="date" class="form-control input-sm" :placeholder="(filters.last_visit_category === 'BETWEEN' || filters.last_visit_category === 'NOT_BETWEEN') ? 'From' : 'Last Visit'" />
+		</div>
+	</div>
+	<div v-show="filters.last_visit_category && (filters.last_visit_category === 'BETWEEN' || filters.last_visit_category === 'NOT_BETWEEN')" class="col-md-2">
+		<div class="form-group">
+			<label>&nbsp;</label>
+			<input name="last_visit_value_2" v-model="filters.last_visit_value_2" type="date" class="form-control input-sm" placeholder="To" />
+		</div>
+	</div>
+
+	<!-- NEXT APPOINTMENT -->
+	<div class="col-md-2">
+		<div class="form-group">
+			<label>Next Appointment **:</label>
+			<select name="next_appointment_category" class="form-control input-sm" v-model="filters.next_appointment_category">
+				<option value="">All</option>
+				<option value="EXACTLY">Exactly</option>
+				<option value="LESS_THAN">Less Than</option>
+				<option value="GREATER_THAN">Greater Than</option>
+				<option value="BETWEEN">Between</option>
+				<option value="NOT_BETWEEN">Not Between</option>
+			</select>
+		</div>
+	</div>
+	<div v-if="filters.next_appointment_category" class="col-md-2">
+		<div class="form-group">
+			<label>&nbsp;</label>
+			<input name="next_appointment_value_1" v-model="filters.next_appointment_value_1" type="date" class="form-control input-sm" :placeholder="(filters.next_appointment_category === 'BETWEEN' || filters.next_appointment_category === 'NOT_BETWEEN') ? 'From' : 'Next Appointment'" />
+		</div>
+	</div>
+	<div v-if="filters.next_appointment_category && (filters.next_appointment_category === 'BETWEEN' || filters.next_appointment_category === 'NOT_BETWEEN')" class="col-md-2">
+		<div class="form-group">
+			<label>&nbsp;</label>
+			<input name="next_appointment_value_2" v-model="filters.next_appointment_value_2" type="date" class="form-control input-sm" placeholder="To" />
+		</div>
+	</div>
+
+	<!-- STATUS -->
+	<div class="col-md-2">
+		<div class="form-group">
+			<label>Status:</label>
+			<select name="status" class="form-control input-sm" v-model="filters.status">
+				<option value="">All</option>
+				<option value="ACTIVE">Active</option>
+				<option value="AWAITING_VISIT">Awaiting Visit</option>
+				<option value="INACTIVE">Inactive</option>
+			</select>
+		</div>
+	</div>
+
+	<!-- LAST WEIGHED-IN -->
+	<div class="col-md-2">
+		<div class="form-group">
+			<label>Last Weighed-In:</label>
+			<select name="last_weighed_in_category" class="form-control input-sm" v-model="filters.last_weighed_in_category">
+				<option value="">All</option>
+				<option value="EXACTLY">Exactly</option>
+				<option value="LESS_THAN">Less Than</option>
+				<option value="GREATER_THAN">Greater Than</option>
+				<option value="BETWEEN">Between</option>
+				<option value="NOT_BETWEEN">Not Between</option>
+			</select>
+		</div>
+	</div>
+	<div v-if="filters.last_weighed_in_category" class="col-md-2">
+		<div class="form-group">
+			<label>&nbsp;</label>
+			<input name="last_weighed_in_value_1" v-model="filters.last_weighed_in_value_1" type="date" class="form-control input-sm" :placeholder="(filters.last_weighed_in_category === 'BETWEEN' || filters.last_weighed_in_category === 'NOT_BETWEEN') ? 'From' : 'Enter Date'" />
+		</div>
+	</div>
+	<div v-if="filters.last_weighed_in_category && (filters.last_weighed_in_category === 'BETWEEN' || filters.last_weighed_in_category === 'NOT_BETWEEN')" class="col-md-2">
+		<div class="form-group">
+			<label>&nbsp;</label>
+			<input name="last_weighed_in_value_2" v-model="filters.last_weighed_in_value_2" type="date" class="form-control input-sm" placeholder="To" />
+		</div>
+	</div>
+
+	<!-- LAST BP -->
+	<div class="col-md-2">
+		<div class="form-group">
+			<label>Last BP:</label>
+			<select name="last_bp_category" class="form-control input-sm" v-model="filters.last_bp_category">
+				<option value="">All</option>
+				<option value="EXACTLY">Exactly</option>
+				<option value="LESS_THAN">Less Than</option>
+				<option value="GREATER_THAN">Greater Than</option>
+				<option value="BETWEEN">Between</option>
+				<option value="NOT_BETWEEN">Not Between</option>
+			</select>
+		</div>
+	</div>
+	<div v-if="filters.last_bp_category" class="col-md-2">
+		<div class="form-group">
+			<label>&nbsp;</label>
+			<input name="last_bp_value_1" v-model="filters.last_bp_value_1" type="date" class="form-control input-sm" :placeholder="(filters.last_bp_category === 'BETWEEN' || filters.last_bp_category === 'NOT_BETWEEN') ? 'From' : 'Enter Date'" />
+		</div>
+	</div>
+	<div v-if="filters.last_bp_category && (filters.last_bp_category === 'BETWEEN' || filters.last_bp_category === 'NOT_BETWEEN')" class="col-md-2">
+		<div class="form-group">
+			<label>&nbsp;</label>
+			<input name="last_bp_value_2" v-model="filters.last_bp_value_2" type="date" class="form-control input-sm" placeholder="To" />
+		</div>
+	</div>
+
+	<div class="col-md-2">
+		<div class="form-group d-flex">
+			<label>&nbsp;</label>
+			<button type="button" v-on:click.prevent="doSubmit()" class="btn btn-primary btn-sm mr-2 mw-100px">Apply Filters</button>
+			<a href="{{ route('mcp.patients') }}" class="btn btn-danger btn-sm text-white mw-100px">Clear Filters</a>
+		</div>
+	</div>
+</form>
+
+<?php
+$loadedFilters = $filters;
+$allFilterKeys = [
+	'age_category',
+	'age_value_1',
+	'age_value_2',
+	'bmi_category',
+	'bmi_value_1',
+	'bmi_value_2',
+	'last_bp_category',
+	'last_bp_value_1',
+	'last_bp_value_2',
+	'last_visit_category',
+	'last_visit_value_1',
+	'last_visit_value_2',
+	'last_weighed_in_category',
+	'last_weighed_in_value_1',
+	'next_appointment_category',
+	'next_appointment_value_1',
+	'sex',
+	'status',
+];
+for ($i=0; $i < count($allFilterKeys); $i++) {
+	if (!isset($loadedFilters[$allFilterKeys[$i]]) || !$loadedFilters[$allFilterKeys[$i]]) {
+		$loadedFilters[$allFilterKeys[$i]] = '';
+	}
+}
+?>
+<script>
+	(function() {
+		function init() {
+			new Vue({
+				el: '#mcp-patients-filters',
+				delimiters: ['@{{', '}}'],
+				data: {
+					filters: <?= json_encode($loadedFilters) ?>
+				},
+				methods: {
+					init: function() {
+						
+					},
+					doSubmit: function() {
+						fastLoad('{{ route('mcp.patients') }}?' + $('#mcp-patients-filters').serialize());
+						return false;
+					}
+				},
+				mounted: function() {
+					console.log(this.filters);
+					this.init();
+				},
+			});
+
+
+		}
+		addMCInitializer('mcp-patients-filters', init, '#mcp-patients-filters');
+	})();
+</script>

+ 19 - 0
resources/views/app/mcp/patients_overdue_for_visit.blade.php

@@ -0,0 +1,19 @@
+@extends ('layouts/template')
+
+@section('content')
+    <div class="p-3 mcp-theme-1" id="patients-list">
+        <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>
+                    Patients Overdue for Visit
+                </strong>
+            </div>
+
+            <div class="card-body p-0">
+                @include('app.mcp.patients-table')
+            </div>
+        </div>
+    </div>
+@endsection

+ 19 - 0
resources/views/app/mcp/patients_without_appointments.blade.php

@@ -0,0 +1,19 @@
+@extends ('layouts/template')
+
+@section('content')
+    <div class="p-3 mcp-theme-1" id="patients-list">
+        <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>
+                    Patients w/o Appointments
+                </strong>
+            </div>
+
+            <div class="card-body p-0">
+                @include('app.mcp.patients-table')
+            </div>
+        </div>
+    </div>
+@endsection

+ 5 - 0
resources/views/app/mcp/reports.blade.php

@@ -0,0 +1,5 @@
+@extends ('layouts/template')
+
+@section('content')
+    <h1>Hi</h1>
+@endsection

+ 60 - 0
resources/views/app/mcp/reports_pending_signature.blade.php

@@ -0,0 +1,60 @@
+<div class="p-3 mcp-theme-1">
+    <div class="card">
+
+        <div class="card-header px-3 py-2 d-flex align-items-center border-bottom-0">
+            <strong class="mr-4">
+                <i class="fas fa-user-injured"></i>
+                Reports Pending Signature
+            </strong>
+        </div>
+
+        <div class="card-body p-0 border-top-0 pb-0">
+
+
+            <table class="table table-sm table-striped mb-0">
+                <thead>
+                <tr>
+                    <th class="border-bottom-0">Patient</th>
+                    <th class="border-bottom-0">Title</th>
+                    <th class="border-bottom-0">Category</th>
+                    <th class="border-bottom-0">Report Date</th>
+                    <th class="border-bottom-0">Sign</th>
+                </tr>
+                </thead>
+                <tbody>
+                @foreach($records as $document)
+                    <tr class="{{$document->is_entry_error ? 'entry-error' : ''}} {{@$currentReport->uid === $document->uid ? 'bg-aliceblue' : ''}}">
+                        <td class="border-bottom-0">{{$document->client->displayName()}}</td>
+                        <td>
+                            <a native target="_blank" href="{{route('patients.view.incoming-reports', ['patient' => $document->client, 'currentReport' => $document])}}"
+                               class="{{@$currentReport->uid === $document->uid ? 'font-weight-bold' : ''}}">
+                                {{ $document->title ? $document->title : '(not set)' }}
+                            </a>
+                        </td>
+                        <td>{{ $document->category }}{{ $document->subcategory ? ' / ' . $document->subcategory : '' }}</td>
+                        <td>{{ friendly_date_time($document->report_date, false) }}</td>
+                        <td>
+                            @if(!$document->has_hcp_pro_signed)
+                                -
+                            @else
+                                <div class="text-success mb-1">
+                                    <i class="fa fa-check"></i>
+                                    Signed
+                                </div>
+                                @if($document->hcp)
+                                    <div class="text-secondary">
+                                        <div class="text-sm font-weight-bold">{{$document->hcp->displayName()}}</div>
+                                        <div class="text-sm">{{friendlier_date_time($document->hcp_pro_signed_at)}}</div>
+                                    </div>
+                                @endif
+                            @endif
+                        </td>
+                    </tr>
+                @endforeach
+                </tbody>
+            </table>
+        </div>
+    </div>
+</div>
+
+

+ 53 - 0
resources/views/app/mcp/supply_orders.blade.php

@@ -0,0 +1,53 @@
+@extends ('layouts/template')
+
+@section('content')
+<div class="p-3 mcp-theme-1" id="patients-list">
+    <div class="card">
+
+        <div class="card-header px-3 py-2 d-flex align-items-center">
+            <strong class="mr-4">
+                <i class="fas fa-file-invoice-dollar"></i>
+                Supply Orders
+            </strong>
+        </div>
+
+        <div class="card-body p-0">
+            <div class="p-3">
+                @include('app.mcp.supply_orders_filters')
+            </div>
+            <table class="table table-condensed p-0 m-0">
+                <thead class="bg-light">
+                    <tr>
+                        <th class="px-3 border-0">Date</th>
+                        <th class="px-3 border-0">Patient</th>
+                        <th class="px-3 border-0">Product</th>
+                        <th class="px-3 border-0">Reason</th>
+                        <th class="px-3 border-0">Status</th>
+                    </tr>
+                </thead>
+                <tbody>
+                    @foreach($supplyOrders as $supplyOrder)
+                    <tr>
+                        <td>{{-- date --}} -</td>
+                        <td>{{-- patient --}} -</td>
+                        <td>{{-- service --}} - </td>
+                        <td>{{-- amount --}} - </td>
+                        <td>{{-- status --}} - </td>
+                    </tr>
+                    @endforeach
+
+                    @if(count($supplyOrders) === 0)
+                    <tr>
+                        <td colspan="5">No records found!</td>
+                    </tr>
+                    @endif
+                </tbody>
+
+            </table>
+            <div class="ml-2 mt-2">
+                {{ $supplyOrders->appends(request()->input())->links() }}
+            </div>
+        </div>
+    </div>
+</div>
+@endsection

+ 87 - 0
resources/views/app/mcp/supply_orders_filters.blade.php

@@ -0,0 +1,87 @@
+<style>
+	#mcp-supply-orders-filters label {
+		font-weight: bold;
+	}
+
+	#mcp-supply-orders-filters .mw-100px {
+		min-width: 100px;
+	}
+</style>
+<form id="mcp-supply-orders-filters" method="GET" action="{{ route('mcp.notes') }}" class="row align-items-end" v-cloak>
+	<!-- DATE	 -->
+	<div class="col-md-2">
+		<div class="form-group">
+			<label>Date:</label>
+			<select name="date_category" class="form-control input-sm" v-model="filters.date_category">
+				<option value="">All</option>
+				<option value="EXACTLY">Exactly</option>
+				<option value="LESS_THAN">Less Than</option>
+				<option value="GREATER_THAN">Greater Than</option>
+				<option value="BETWEEN">Between</option>
+				<option value="NOT_BETWEEN">Not Between</option>
+			</select>
+		</div>
+	</div>
+	<div v-if="filters.date_category" class="col-md-2">
+		<div class="form-group">
+			<label>&nbsp;</label>
+			<input name="date_value_1" value="{{ $date_value_1 ?? '' }}" type="date" class="form-control input-sm" :placeholder="(filters.date_category === 'BETWEEN' || filters.date_category === 'NOT_BETWEEN') ? 'From' : 'Date'" />
+		</div>
+	</div>
+	<div v-if="filters.date_category && (filters.date_category === 'BETWEEN' || filters.date_category === 'NOT_BETWEEN')" class="col-md-2">
+		<div class="form-group">
+			<label>&nbsp;</label>
+			<input name="date_value_2" value="{{ $date_value_2 ?? '' }}" type="date" class="form-control input-sm" placeholder="To" />
+		</div>
+	</div>
+	<!-- STATUS -->
+	<div class="col-md-2">
+		<div class="form-group">
+			<label>Status:</label>
+			<select name="status" class="form-control input-sm" v-model="filters.status">
+				<option value="ALL">All</option>
+				<option value="NEW">New</option>
+				<option value="SIGNED">Signed</option>
+				<option value="VERIFIED">Verified</option>
+				<option value="PROCESSED">Processed</option>
+				<option value="CANCELLED">Cancelled</option>
+			</select>
+		</div>
+	</div>
+
+	<div class="col-md-2">
+		<div class="form-group d-flex">
+			<label>&nbsp;</label>
+			<button type="submit" class="btn btn-primary btn-sm mr-2 mw-100px">Apply Filters</button>
+			<a href="{{ route('mcp.patients') }}" class="btn btn-danger btn-sm text-white mw-100px">Clear Filters</a>
+		</div>
+	</div>
+</form>
+
+<script>
+	(function() {
+		function init() {
+			window.apapp = new Vue({
+				el: '#mcp-supply-orders-filters',
+				delimiters: ['@{{', '}}'],
+				data: {
+					filters: {
+						date_category: "<?= $date_category ?? '' ?>",
+						status: "<?= $status ?? '' ?>"
+					}
+				},
+				methods: {
+					init: function() {
+
+					}
+				},
+				mounted: function() {
+					this.init();
+				},
+			});
+
+
+		}
+		addMCInitializer('mcp-supply-orders-filters', init, '#mcp-supply-orders-filters');
+	})();
+</script>

+ 45 - 0
resources/views/app/mcp/supply_orders_pending_signature.blade.php

@@ -0,0 +1,45 @@
+<div class="p-3 mcp-theme-1">
+    <div class="card">
+
+        <div class="card-header px-3 py-2 d-flex align-items-center border-bottom-0">
+            <strong class="mr-4">
+                <i class="fas fa-user-injured"></i>
+                Supply Orders Pending Signature
+            </strong>
+        </div>
+
+        <div class="card-body p-0 border-top-0 pb-0">
+
+
+            <table class="table table-sm table-striped mb-0">
+                <thead>
+                <tr>
+                    <th class="border-bottom-0">Date</th>
+                    <th class="border-bottom-0">Patient</th>
+                    <th class="border-bottom-0">Product</th>
+                    <th class="border-bottom-0">Reason</th>
+                    <th class="border-bottom-0">Status</th>
+                </tr>
+                </thead>
+                <tbody>
+                @foreach($records as $row)
+                    <tr>
+                        <td>{{ friendly_date_time($row->created_at, false) }}</td>
+                        <td>
+                            <a target="_blank" native href="{{route('patients.view.dashboard', $row->client)}}">
+                                {{$row->client->displayName()}}
+                            </a>
+                        </td>
+                        <td>{{ $row->product->title }}</td>
+                        <td>{{ $row->reason ?: '-' }}</td>
+                        <td>**</td>
+                    </tr>
+                @endforeach
+                </tbody>
+            </table>
+        </div>
+    </div>
+</div>
+
+
+

+ 14 - 11
resources/views/app/new-patient.blade.php

@@ -2,7 +2,10 @@
 
 @section('content')
 
-    <?php $patients = [1,2,3,4]; ?>
+    <?php
+    $patients = [1,2,3,4];
+    $medicaidStates = Config::get('constants.medicaid_states');
+    ?>
 
     <div class="p-3 mcp-theme-1" id="newPatientContainer" v-cloak>
         <div class="col-12 col-lg-6 px-0">
@@ -63,28 +66,28 @@
                 				</div>
                         @if($pro->pro_type === 'ADMIN')
                             <div class='form-group mb-3'>
-                                <label class='control-label'>Pro Uid</label>
-                                <select name="mcpProUid" class="form-control" provider-search provider-type="hcp">
+                                <label class='control-label'>HCP Pro</label>
+                                <select name="hcpProUid" class="form-control" provider-search provider-type="hcp">
                                     <option value="">--select--</option>
                                 </select>
                             </div>
                             <div class='form-group mb-3'>
-                                <label class='control-label'>Default NA Pro</label>
-                                <select name="naProUid" class="form-control" provider-search provider-type="default-na">
+                                <label class='control-label'>Care Coordinator</label>
+                                <select name="assistantProUid" class="form-control" provider-search provider-type="default-na">
                                     <option value="">--select--</option>
                                 </select>
                             </div>
                         @elseif($pro->is_hcp === true)
                             <div class='form-group mb-3'>
-                                <label class='control-label'>Pro Uid</label>
+                                <label class='control-label'>HCP Pro</label>
                                 <input type="text" class="form-control" readonly value="{{$pro->displayName()}}">
-                                <input type="hidden" name="mcpProUid" value="{{$pro->uid}}">
+                                <input type="hidden" name="hcpProUid" value="{{$pro->uid}}">
                             </div>
                         @elseif($pro->isDefaultNA())
                             <div class='form-group mb-3'>
-                                <label class='control-label'>Pro Uid</label>
+                                <label class='control-label'>HCP Pro</label>
                                 <?php $teams = $pro->teamsWhereAssistant; ?>
-                                <select name="mcpProUid" class="form-control">
+                                <select name="hcpProUid" class="form-control">
                                     <option value="">--select--</option>
                                     @foreach($teams as $team)
                                         <option value="{{$team->mcp->uid}}">{{$team->mcp->displayName()}}</option>
@@ -92,9 +95,9 @@
                                 </select>
                             </div>
                             <div class='form-group mb-3'>
-                                <label class='control-label'>Default NA Pro</label>
+                                <label class='control-label'>Care Coordinator</label>
                                 <input type="text" class="form-control" readonly value="{{$pro->displayName()}}">
-                                <input type="hidden" name="naProUid" value="{{$pro->uid}}">
+                                <input type="hidden" name="assistantProUid" value="{{$pro->uid}}">
                             </div>
                         @endif
 

+ 469 - 28
resources/views/app/patient/appointment-calendar.blade.php

@@ -225,10 +225,10 @@
             </form>
         </div>
         <div class="stag-popup stag-popup-sm mcp-theme-1" stag-popup-key="client-edit-appointment">
-            <form method="POST" action="/api/appointment/update" id="editApptForm"
+            <form method="POST" action="/api/appointment/updateDateAndTime" id="editApptForm"
                   :class="editAppointment.isTrainingEvent ? 'non-interactive' : ''">
                 <h3 class="stag-popup-title">
-                    <span>Edit Appointment</span>
+                    <span>Edit Date &amp; Time</span>
                     <a native target="_blank" v-if="editAppointment.isTrainingEvent" class="ml-3"
                        :href="'{{config('app.hrm2_url')}}/patients/view/' + editAppointment.clientUid + '/calendar/' + editAppointment.uid">
                         <i class="fa fa-external-link-alt"></i>
@@ -254,17 +254,9 @@
                         Pro
                     </div>
                     <div class="col-9 font-weight-bold">
-                        <select id="editApptPro" name="proUid" provider-search
-                                v-model="editAppointment.proUid"
-                                :data-pro-uid="editAppointment.proUid"
-                                no-auto-pro-suggest-init
-                                class="form-control form-control-sm">
-                            @foreach($pros as $iPro)
-                                <option value="{{$iPro->uid}}">
-                                    {{$iPro->displayName()}}
-                                </option>
-                            @endforeach
-                        </select>
+                        <input type="text"
+                               class="form-control form-control-sm"
+                               :value="editAppointment.proName" readonly>
                     </div>
                 </div>
                 <div class="row mb-2">
@@ -314,14 +306,13 @@
                         Status
                     </div>
                     <div class="col-9 font-weight-bold">
-                        <select id="editApptStatus" name="status" required
+                        <select id="editApptStatus" readonly
                                 v-model="editAppointment.status"
                                 class="form-control form-control-sm font-weight-bold px-1">
-                            <option value="CREATED">CREATED</option>
+                            <option value="PENDING">PENDING</option>
                             <option value="CONFIRMED">CONFIRMED</option>
                             <option value="CANCELLED">CANCELLED</option>
                             <option value="COMPLETED">COMPLETED</option>
-                            <option value="ABANDONED">ABANDONED</option>
                         </select>
                     </div>
                 </div>
@@ -330,7 +321,7 @@
                         Title
                     </div>
                     <div class="col-9 font-weight-bold">
-                        <input type="text" name="title"
+                        <input type="text" readonly
                                class="form-control form-control-sm"
                                v-model="editAppointment.title">
                     </div>
@@ -340,7 +331,7 @@
                         Description
                     </div>
                     <div class="col-9 font-weight-bold">
-                        <textarea name="description"
+                        <textarea readonly
                                   class="form-control form-control-sm"
                                   v-model="editAppointment.description"></textarea>
                     </div>
@@ -348,7 +339,7 @@
                 <div v-if="editAppointment.allowEdit" class="d-flex align-items-center justify-content-center">
                     <button class="btn btn-sm btn-primary mr-2"
                             :disabled="inProgress"
-                            v-on:click.prevent="updateAppointment()">Submit</button>
+                            v-on:click.prevent="updateAppointment_Timing()">Save Date &amp; Time</button>
                     <button class="btn btn-sm btn-default border"
                             onclick="return closeStagPopup()">Cancel</button>
                 </div>
@@ -358,6 +349,261 @@
                 </div>
             </form>
         </div>
+        <div class="stag-popup stag-popup-sm mcp-theme-1" stag-popup-key="client-edit-appointment-status">
+            <form method="POST" action="/api/appointment/updateStatus" id="editApptForm_Status"
+                  :class="editAppointment.isTrainingEvent ? 'non-interactive' : ''">
+                <h3 class="stag-popup-title">
+                    <span>Edit Date &amp; Time</span>
+                    <a native target="_blank" v-if="editAppointment.isTrainingEvent" class="ml-3"
+                       :href="'{{config('app.hrm2_url')}}/patients/view/' + editAppointment.clientUid + '/calendar/' + editAppointment.uid">
+                        <i class="fa fa-external-link-alt"></i>
+                        Open in HRM
+                    </a>
+                    <a href="#" class="ml-auto text-secondary"
+                       onclick="return closeStagPopup()"><i class="fa fa-times-circle"></i></a>
+                </h3>
+                <div class="form-content" :title="editAppointment.isTrainingEvent ? 'Training appointment. Please open in HRM.' : ''">
+                    <input type="hidden" name="uid" :value="editAppointment.uid">
+                    <div class="row mb-2">
+                        <div class="col-3 text-secondary">
+                            Patient
+                        </div>
+                        <div class="col-9 font-weight-bold">
+                            <input type="text"
+                                   class="form-control form-control-sm"
+                                   :value="editAppointment.clientName" readonly>
+                        </div>
+                    </div>
+                    <div class="row mb-2">
+                        <div class="col-3 text-secondary">
+                            Pro
+                        </div>
+                        <div class="col-9 font-weight-bold">
+                            <input type="text"
+                                   class="form-control form-control-sm"
+                                   :value="editAppointment.proName" readonly>
+                        </div>
+                    </div>
+                    <div class="row mb-2">
+                        <div class="col-3 text-secondary">
+                            Date
+                        </div>
+                        <div class="col-9 font-weight-bold">
+                            <input type="date" readonly
+                                   class="form-control form-control-sm"
+                                   v-model="editAppointment.date">
+                        </div>
+                    </div>
+                    <div class="row mb-2">
+                        <div class="col-3 text-secondary">
+                            Start Time
+                        </div>
+                        <div class="col-9 font-weight-bold">
+                            <input type="time" readonly
+                                   class="form-control form-control-sm"
+                                   v-model="editAppointment.startTime">
+                        </div>
+                    </div>
+                    <div class="row mb-2">
+                        <div class="col-3 text-secondary">
+                            End Time
+                        </div>
+                        <div class="col-9 font-weight-bold">
+                            <input type="time" readonly
+                                   class="form-control form-control-sm"
+                                   v-model="editAppointment.endTime">
+                        </div>
+                    </div>
+                    <input type="hidden" :value="timezone">
+                    <div class="row mb-2">
+                        <div class="col-3 text-secondary">
+                            Timezone
+                        </div>
+                        <div class="col-9 font-weight-bold">
+                            <input type="text"
+                                   class="form-control form-control-sm"
+                                   :value="timezone" readonly>
+                            <div class="text-secondary font-weight-normal py-1 text-sm">Timezone as set in the calendar</div>
+                        </div>
+                    </div>
+                    <div class="row mb-2">
+                        <div class="col-3 text-secondary">
+                            Status
+                        </div>
+                        <div class="col-9 font-weight-bold">
+                            <select id="editApptStatus" name="status"
+                                    v-model="editAppointment.status"
+                                    class="form-control form-control-sm font-weight-bold px-1">
+                                <option value="PENDING">PENDING</option>
+                                <option value="CONFIRMED">CONFIRMED</option>
+                                <option value="CANCELLED">CANCELLED</option>
+                                <option value="COMPLETED">COMPLETED</option>
+                            </select>
+                        </div>
+                    </div>
+                    <div class="row mb-2">
+                        <div class="col-3 text-secondary">
+                            Title
+                        </div>
+                        <div class="col-9 font-weight-bold">
+                            <input type="text" readonly
+                                   class="form-control form-control-sm"
+                                   v-model="editAppointment.title">
+                        </div>
+                    </div>
+                    <div class="row mb-2">
+                        <div class="col-3 text-secondary">
+                            Description
+                        </div>
+                        <div class="col-9 font-weight-bold">
+                        <textarea readonly
+                                  class="form-control form-control-sm"
+                                  v-model="editAppointment.description"></textarea>
+                        </div>
+                    </div>
+                    <div v-if="editAppointment.allowEdit" class="d-flex align-items-center justify-content-center">
+                        <button class="btn btn-sm btn-primary mr-2"
+                                :disabled="inProgress"
+                                v-on:click.prevent="updateAppointment_Status()">Save Status</button>
+                        <button class="btn btn-sm btn-default border"
+                                onclick="return closeStagPopup()">Cancel</button>
+                    </div>
+                    <div v-else class="alert alert-secondary mb-0">
+                        You cannot make changes to this appointment.
+                    </div>
+                </div>
+            </form>
+        </div>
+        <div class="stag-popup stag-popup-sm mcp-theme-1" stag-popup-key="client-edit-appointment-basic-details">
+            <form method="POST" action="/api/appointment/updateBasic" id="editApptForm_BasicDetails"
+                  :class="editAppointment.isTrainingEvent ? 'non-interactive' : ''">
+                <h3 class="stag-popup-title">
+                    <span>Edit Basic Details</span>
+                    <a native target="_blank" v-if="editAppointment.isTrainingEvent" class="ml-3"
+                       :href="'{{config('app.hrm2_url')}}/patients/view/' + editAppointment.clientUid + '/calendar/' + editAppointment.uid">
+                        <i class="fa fa-external-link-alt"></i>
+                        Open in HRM
+                    </a>
+                    <a href="#" class="ml-auto text-secondary"
+                       onclick="return closeStagPopup()"><i class="fa fa-times-circle"></i></a>
+                </h3>
+                <div class="form-content" :title="editAppointment.isTrainingEvent ? 'Training appointment. Please open in HRM.' : ''">
+                    <input type="hidden" name="uid" :value="editAppointment.uid">
+                    <div class="row mb-2">
+                        <div class="col-3 text-secondary">
+                            Patient
+                        </div>
+                        <div class="col-9 font-weight-bold">
+                            <input type="text"
+                                   class="form-control form-control-sm"
+                                   :value="editAppointment.clientName" readonly>
+                        </div>
+                    </div>
+                    <div class="row mb-2">
+                        <div class="col-3 text-secondary">
+                            Pro
+                        </div>
+                        <div class="col-9 font-weight-bold">
+                            <input type="text"
+                                   class="form-control form-control-sm"
+                                   :value="editAppointment.proName" readonly>
+                        </div>
+                    </div>
+                    <div class="row mb-2">
+                        <div class="col-3 text-secondary">
+                            Date
+                        </div>
+                        <div class="col-9 font-weight-bold">
+                            <input type="date" readonly
+                                   class="form-control form-control-sm"
+                                   v-model="editAppointment.date">
+                        </div>
+                    </div>
+                    <div class="row mb-2">
+                        <div class="col-3 text-secondary">
+                            Start Time
+                        </div>
+                        <div class="col-9 font-weight-bold">
+                            <input type="time" readonly
+                                   class="form-control form-control-sm"
+                                   v-model="editAppointment.startTime">
+                        </div>
+                    </div>
+                    <div class="row mb-2">
+                        <div class="col-3 text-secondary">
+                            End Time
+                        </div>
+                        <div class="col-9 font-weight-bold">
+                            <input type="time" readonly
+                                   class="form-control form-control-sm"
+                                   v-model="editAppointment.endTime">
+                        </div>
+                    </div>
+                    <input type="hidden" :value="timezone">
+                    <div class="row mb-2">
+                        <div class="col-3 text-secondary">
+                            Timezone
+                        </div>
+                        <div class="col-9 font-weight-bold">
+                            <input type="text"
+                                   class="form-control form-control-sm"
+                                   :value="timezone" readonly>
+                            <div class="text-secondary font-weight-normal py-1 text-sm">Timezone as set in the calendar</div>
+                        </div>
+                    </div>
+                    <div class="row mb-2">
+                        <div class="col-3 text-secondary">
+                            Status
+                        </div>
+                        <div class="col-9 font-weight-bold">
+                            <select id="editApptStatus" readonly
+                                    v-model="editAppointment.status"
+                                    class="form-control form-control-sm font-weight-bold px-1">
+                                <option value="PENDING">PENDING</option>
+                                <option value="CONFIRMED">CONFIRMED</option>
+                                <option value="CANCELLED">CANCELLED</option>
+                                <option value="COMPLETED">COMPLETED</option>
+                            </select>
+                        </div>
+                    </div>
+                    <div class="row mb-2">
+                        <div class="col-3 text-secondary">
+                            Title
+                        </div>
+                        <div class="col-9 font-weight-bold">
+                            <input type="text" name="title"
+                                   class="form-control form-control-sm"
+                                   v-model="editAppointment.title">
+                        </div>
+                    </div>
+                    <div class="row mb-2">
+                        <div class="col-3 text-secondary">
+                            Description
+                        </div>
+                        <div class="col-9 font-weight-bold">
+                        <textarea name="description"
+                                  class="form-control form-control-sm"
+                                  v-model="editAppointment.description"></textarea>
+                        </div>
+                    </div>
+                    <div v-if="editAppointment.allowEdit" class="d-flex align-items-center justify-content-center">
+                        <button class="btn btn-sm btn-primary mr-2"
+                                :disabled="inProgress"
+                                v-on:click.prevent="updateAppointment_BasicDetails()">Save Basic Details</button>
+                        <button class="btn btn-sm btn-default border"
+                                onclick="return closeStagPopup()">Cancel</button>
+                    </div>
+                    <div v-else class="alert alert-secondary mb-0">
+                        You cannot make changes to this appointment.
+                    </div>
+                </div>
+            </form>
+        </div>
+        <div class="stag-menu bg-white border calendar-event-menu pt-1" style="display: none">
+            <a start show href="#" class="px-2 pb-1 d-block text-nowrap" data-action="showEditAppointmentModal_BasicDetails">Edit basic details</a>
+            <a start show href="#" class="px-2 pb-1 d-block text-nowrap" data-action="showEditAppointmentModal">Edit date and time</a>
+            <a start show href="#" class="px-2 pb-1 d-block text-nowrap" data-action="showEditAppointmentModal_Status">Edit status</a>
+        </div>
     </div>
     <script>
         (function() {
@@ -570,7 +816,7 @@
                                                             ev.editable = true;
 
                                                             // active/all
-                                                            if(['CANCELLED', 'COMPLETED', 'ABANDONED'].indexOf(ev.status) !== -1) {
+                                                            if(['CANCELLED', 'COMPLETED'].indexOf(ev.status) !== -1) {
                                                                 if(self.eventTypes === 'APPOINTMENTS_ALL' || self.eventTypes === 'BOTH_ALL') {
                                                                     displayEvents.push(ev);
                                                                 }
@@ -617,7 +863,7 @@
                                     if (arg.event.extendedProps.type === 'availability') {
                                         classes.push('availability');
                                     }
-                                    if (['CANCELLED', 'COMPLETED', 'ABANDONED'].indexOf(arg.event.extendedProps.status) !== -1) {
+                                    if (['CANCELLED', 'COMPLETED'].indexOf(arg.event.extendedProps.status) !== -1) {
                                         classes.push('inactive-appointment');
                                     }
                                     if (arg.event.extendedProps.type === 'appointment') {
@@ -630,7 +876,8 @@
                                 },
                                 eventClick: function(info) {
                                     self.selectedEvent = info.event;
-                                    self.showEditAppointmentModal();
+                                    // self.showEditAppointmentModal();
+                                    self.showEventMenu(info.el);
                                 },
                                 selectAllow: function(info) { // allow only single selections
                                     let seconds = info.end.getTime() - info.start.getTime(),
@@ -794,6 +1041,13 @@
                                 hideMask();
                             }, 'json');
                         },
+                        showEventMenu: function(_el) {
+                            let menu = $(_el).find('.calendar-event-menu').first();
+                            if(!menu.length) {
+                                menu = $('.calendar-event-menu').clone().removeClass('.calendar-event-menu').appendTo(_el);
+                            }
+                            menu.show();
+                        },
                         showEditAppointmentModal: function() {
                             // setup model data
                             this.inProgress = false;
@@ -816,6 +1070,7 @@
                             @endif
 
                             this.editAppointment.proUid = this.selectedEvent.extendedProps.proUid;
+                            this.editAppointment.proName = this.selectedEvent.extendedProps.proName;
                             this.editAppointment.date = this.dateStr(this.selectedEvent.start);
                             this.editAppointment.startTime = this.timeStr(this.selectedEvent.start);
                             this.editAppointment.endTime = this.selectedEvent.end ? this.timeStr(this.selectedEvent.end) : '';
@@ -825,11 +1080,90 @@
                             this.editAppointment.status = this.selectedEvent.extendedProps.status;
                             this.editAppointment.isTrainingEvent = this.selectedEvent.extendedProps.isTrainingEvent;
                             Vue.nextTick(function() {
-                                $('#editApptPro').trigger('change');
                                 showStagPopup('client-edit-appointment', true);
-                                $('#editApptPro').removeAttr('no-auto-pro-suggest-init').removeAttr('pro-suggest-initialized');
-                                initProSuggest();
                             });
+
+                            setTimeout(() => {
+                                $('.stag-menu').hide();
+                            }, 100);
+                        },
+                        showEditAppointmentModal_BasicDetails: function() {
+                            // setup model data
+                            this.inProgress = false;
+                            this.editAppointment.uid = this.selectedEvent.extendedProps.appointmentUid;
+                            this.editAppointment.clientUid = this.selectedEvent.extendedProps.clientUid;
+                            @if($pro->isDefaultNA())
+                                this.editAppointment.allowEdit = false;
+                            this.editAppointment.clientName = this.selectedEvent.extendedProps.clientName.split(/\s+/).map(_x => _x[0]).join('');
+                            $.get('/can-access-patient/' + this.editAppointment.clientUid, _data => {
+                                if(!hasResponseError(_data)) {
+                                    if(_data.data) {
+                                        this.editAppointment.allowEdit = true;
+                                        this.editAppointment.clientName = this.selectedEvent.extendedProps.clientName;
+                                    }
+                                }
+                            }, 'json');
+                            @else
+                                this.editAppointment.allowEdit = true;
+                                this.editAppointment.clientName = this.selectedEvent.extendedProps.clientName;
+                            @endif
+
+                            this.editAppointment.proUid = this.selectedEvent.extendedProps.proUid;
+                            this.editAppointment.proName = this.selectedEvent.extendedProps.proName;
+                            this.editAppointment.date = this.dateStr(this.selectedEvent.start);
+                            this.editAppointment.startTime = this.timeStr(this.selectedEvent.start);
+                            this.editAppointment.endTime = this.selectedEvent.end ? this.timeStr(this.selectedEvent.end) : '';
+                            this.editAppointment.timeZone = this.timezone;
+                            this.editAppointment.title = this.selectedEvent.extendedProps._title;
+                            this.editAppointment.description = this.selectedEvent.extendedProps.description;
+                            this.editAppointment.status = this.selectedEvent.extendedProps.status;
+                            this.editAppointment.isTrainingEvent = this.selectedEvent.extendedProps.isTrainingEvent;
+                            Vue.nextTick(function() {
+                                showStagPopup('client-edit-appointment-basic-details', true);
+                            });
+
+                            setTimeout(() => {
+                                $('.stag-menu').hide();
+                            }, 100);
+                        },
+                        showEditAppointmentModal_Status: function() {
+                            // setup model data
+                            this.inProgress = false;
+                            this.editAppointment.uid = this.selectedEvent.extendedProps.appointmentUid;
+                            this.editAppointment.clientUid = this.selectedEvent.extendedProps.clientUid;
+                            @if($pro->isDefaultNA())
+                                this.editAppointment.allowEdit = false;
+                            this.editAppointment.clientName = this.selectedEvent.extendedProps.clientName.split(/\s+/).map(_x => _x[0]).join('');
+                            $.get('/can-access-patient/' + this.editAppointment.clientUid, _data => {
+                                if(!hasResponseError(_data)) {
+                                    if(_data.data) {
+                                        this.editAppointment.allowEdit = true;
+                                        this.editAppointment.clientName = this.selectedEvent.extendedProps.clientName;
+                                    }
+                                }
+                            }, 'json');
+                            @else
+                                this.editAppointment.allowEdit = true;
+                                this.editAppointment.clientName = this.selectedEvent.extendedProps.clientName;
+                            @endif
+
+                            this.editAppointment.proUid = this.selectedEvent.extendedProps.proUid;
+                            this.editAppointment.proName = this.selectedEvent.extendedProps.proName;
+                            this.editAppointment.date = this.dateStr(this.selectedEvent.start);
+                            this.editAppointment.startTime = this.timeStr(this.selectedEvent.start);
+                            this.editAppointment.endTime = this.selectedEvent.end ? this.timeStr(this.selectedEvent.end) : '';
+                            this.editAppointment.timeZone = this.timezone;
+                            this.editAppointment.title = this.selectedEvent.extendedProps._title;
+                            this.editAppointment.description = this.selectedEvent.extendedProps.description;
+                            this.editAppointment.status = this.selectedEvent.extendedProps.status;
+                            this.editAppointment.isTrainingEvent = this.selectedEvent.extendedProps.isTrainingEvent;
+                            Vue.nextTick(function() {
+                                showStagPopup('client-edit-appointment-status', true);
+                            });
+
+                            setTimeout(() => {
+                                $('.stag-menu').hide();
+                            }, 100);
                         },
                         updateAppointment: function() {
                             let form = $('#editApptForm');
@@ -838,16 +1172,107 @@
                                 return false;
                             }
 
-                            // confirming if changing to cancelled, completed or abandoned
+                            // confirming if changing to cancelled, completed
                             if(this.selectedEvent.extendedProps.status !== this.editAppointment.status &&
-                                ['CANCELLED', 'COMPLETED', 'ABANDONED'].indexOf(this.editAppointment.status) !== -1) {
-                                if(!window.confirm('CANCELLED, COMPLETED and ABANDONED appointments will ' +
+                                ['CANCELLED', 'COMPLETED'].indexOf(this.editAppointment.status) !== -1) {
+                                if(!window.confirm('CANCELLED and COMPLETED appointments will ' +
                                     'not be displayed in the calendar by default.\n\n' +
                                     'Are you sure you want to update the status of this appointment to ' + this.editAppointment.status + '?')) {
                                     return false;
                                 }
                             }
 
+                            this.inProgress = true;
+                            let self = this;
+                            showMask();
+                            $.post(form.attr('action'), form.serialize(), function(_data) {
+                                if(_data) {
+                                    if(_data.success) {
+                                        self.refreshEvents();
+                                        closeStagPopup();
+                                    }
+                                    else {
+                                        toastr.error(_data.message);
+                                    }
+                                }
+                                else {
+                                    toastr.error('Unable to update appointment!');
+                                }
+                                self.inProgress = false;
+                                hideMask();
+                            }, 'json');
+                        },
+                        updateAppointment_Status: function() {
+                            let form = $('#editApptForm_Status');
+                            if(!form[0].checkValidity()) {
+                                form[0].reportValidity();
+                                return false;
+                            }
+
+                            // confirming if changing to cancelled, completed
+                            if(this.selectedEvent.extendedProps.status !== this.editAppointment.status &&
+                                ['CANCELLED', 'COMPLETED'].indexOf(this.editAppointment.status) !== -1) {
+                                if(!window.confirm('CANCELLED and COMPLETED appointments will ' +
+                                    'not be displayed in the calendar by default.\n\n' +
+                                    'Are you sure you want to update the status of this appointment to ' + this.editAppointment.status + '?')) {
+                                    return false;
+                                }
+                            }
+
+                            this.inProgress = true;
+                            let self = this;
+                            showMask();
+                            $.post(form.attr('action'), form.serialize(), function(_data) {
+                                if(_data) {
+                                    if(_data.success) {
+                                        self.refreshEvents();
+                                        closeStagPopup();
+                                    }
+                                    else {
+                                        toastr.error(_data.message);
+                                    }
+                                }
+                                else {
+                                    toastr.error('Unable to update appointment!');
+                                }
+                                self.inProgress = false;
+                                hideMask();
+                            }, 'json');
+                        },
+                        updateAppointment_Timing: function() {
+                            let form = $('#editApptForm');
+                            if(!form[0].checkValidity()) {
+                                form[0].reportValidity();
+                                return false;
+                            }
+
+                            this.inProgress = true;
+                            let self = this;
+                            showMask();
+                            $.post(form.attr('action'), form.serialize(), function(_data) {
+                                if(_data) {
+                                    if(_data.success) {
+                                        self.refreshEvents();
+                                        closeStagPopup();
+                                    }
+                                    else {
+                                        toastr.error(_data.message);
+                                    }
+                                }
+                                else {
+                                    toastr.error('Unable to update appointment!');
+                                }
+                                self.inProgress = false;
+                                hideMask();
+                            }, 'json');
+                        },
+                        updateAppointment_BasicDetails: function() {
+                            let form = $('#editApptForm_BasicDetails');
+                            if(!form[0].checkValidity()) {
+                                form[0].reportValidity();
+                                return false;
+                            }
+
                             this.inProgress = true;
                             let self = this;
                             showMask();
@@ -885,6 +1310,22 @@
                             });
                         }
                         @endif
+
+                        $(document)
+                            .off('mousedown.discard-stag-menu')
+                            .on('mousedown.discard-stag-menu', function (_e) {
+                                if($(_e.target).closest('.stag-menu').length) return;
+                                $('.stag-menu').hide();
+                            });
+
+                        let self = this;
+                        $(document)
+                            .off('click.stag-menu-action', '.stag-menu>a[data-action]')
+                            .on('click.stag-menu-action', '.stag-menu>a[data-action]', function (_e) {
+                                self[$(this).attr('data-action')].call(self);
+                                return false;
+                            });
+
                     }
                 });
             }

+ 1 - 3
resources/views/app/patient/appointments.blade.php

@@ -15,12 +15,10 @@
             <select class="ml-2 max-width-200px form-control form-control-sm"
                     onchange="fastLoad('/patients/view/{{$patient->uid}}/appointments/{{$forPro}}/' + this.value, true, false, false)">
                 <option value="all" {{ $status === 'all' ? 'selected' : '' }}>All Appointments</option>
-                <option value="created" {{ $status === 'created' ? 'selected' : '' }}>New Appointments</option>
+                <option value="pending" {{ $status === 'pending' ? 'selected' : '' }}>Pending Appointments</option>
                 <option value="confirmed" {{ $status === 'confirmed' ? 'selected' : '' }}>Confirmed Appointments</option>
                 <option value="cancelled" {{ $status === 'cancelled' ? 'selected' : '' }}>Cancelled Appointments</option>
                 <option value="completed" {{ $status === 'completed' ? 'selected' : '' }}>Completed Appointments</option>
-                <option value="abandoned" {{ $status === 'abandoned' ? 'selected' : '' }}>Abandoned Appointments</option>
-                <option value="rejected" {{ $status === 'rejected' ? 'selected' : '' }}>Rejected Appointments</option>
             </select>
         </div>
         <table class="table table-striped table-sm table-bordered mb-0">

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

@@ -159,6 +159,7 @@
     </span>
 @endif
 
+
 <script>
     (function() {
         let selectedCodeHourlyRate = 0;

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

@@ -1107,7 +1107,7 @@
                             @include('app/patient/note/_create-bill')
                         @endif
                     </div>
-
+                    
                     @if($pro->pro_type === 'ADMIN')
                                 <table class="table table-sm tabe-striped mb-0 table-bordered">
                         <thead class="bg-light">
@@ -1208,6 +1208,28 @@
                                         @endif
                                     @endif
 
+                                    @if($pro->pro_type === 'ADMIN')                                    
+                                        <b>{{$bill->hcpCompanyPro && $bill->hcpCompanyPro->company ? $bill->hcpCompanyPro->pro->displayName() . ' / ' . $bill->hcpCompanyPro->company->name : '-'}}</b>
+                                        <div moe class="ml-1">
+                                            <a class="text-primary" href="" show start>Swap HCP Company Pro</a>
+                                            <form url="/api/bill/swapHcpCompanyPro">
+                                                <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                <div class="mb-2">
+                                                    <select name="hcpCompanyProUid" class="form-control form-control-sm">
+                                                        <option value="">-- select --</option>
+                                                        @foreach($bill->hcp->companyPros as $companyPro)
+                                                            <option value="{{$companyPro->uid}}">{{$companyPro->pro->displayName() . ' / ' . $companyPro->company->name}}</option>
+                                                        @endforeach
+                                                    </select>
+                                                </div>
+                                                <div class="mb-0">
+                                                    <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                </div>
+                                            </form>
+                                        </div>
+                                    @endif
+
                                 </td>
                                 <td class="pr-3 screen-only">
                                     @if($bill->has_hcp_been_paid)

+ 1 - 1
resources/views/app/patient/partials/appointment-confirmation-history.blade.php

@@ -24,7 +24,7 @@ $cDecisions = $appointment->confirmationDecisions;
     <p class="my-2"><b>Decisions</b></p>
     @foreach($cDecisions as $cDecision)
         <div class="bg-light p-1 my-1 border border">
-            <b class="{{$cDecision->accepted_or_rejected_or_waived === 'ACCEPTED' ? 'text-success' : 'text-warning-mellow'}}">{{$cDecision->accepted_or_rejected_or_waived}}</b> on {{ friendly_date_time($cDecision->created_at) }}
+            <b class="{{$cDecision->decision_enum === 'CONFIRMED' ? 'text-success' : 'text-warning-mellow'}}">{{$cDecision->decision_enum}}</b> on {{ friendly_date_time($cDecision->created_at) }}
             @if($cDecision->memo)
                 <div class="text-sm">
                     <i>{{$cDecision->memo}}</i>

+ 21 - 12
resources/views/app/patient/partials/appointment-confirmation.blade.php

@@ -1,23 +1,20 @@
 <div class="d-flex" id="appointment-confirmation">
     <div class="flex-grow-1">
-        @if($appointment->status === 'CREATED' && !$appointment->latest_confirmation_request_at && !$appointment->latest_confirmation_decision_at)
+        @if($appointment->status === 'PENDING' && !$appointment->latest_confirmation_request_at && !$appointment->latest_confirmation_decision_at)
             <b class="text-warning-mellow">Not requested yet</b>
             <div>
                 @include('app.patient.partials.appointment-request-confirmation', ['label' => 'Request Confirmation'])
             </div>
         @endif
         @if($appointment->latest_confirmation_decision_at)
-            @if($appointment->status === 'CONFIRMED')
+            @if($appointment->latestConfirmationDecision->decision_enum === 'CONFIRMED')
                 <div class="text-nowrap">
-                    <b class="text-success">{{ucwords($appointment->status)}}</b>
+                    <b class="text-success">{{ucwords($appointment->latestConfirmationDecision->decision_enum)}}</b>
                     <span class="text-secondary ml-1">on {{friendlier_date_time(convertToTimezone($appointment->latest_confirmation_decision_at, 'US/Eastern'))}}</span>
                 </div>
-                <div>
-                    @include('app.patient.partials.appointment-request-confirmation', ['label' => 'Re-request Confirmation'])
-                </div>
-            @elseif($appointment->status === 'REJECTED')
+            @elseif($appointment->latestConfirmationDecision->decision_enum === 'CANCELLED')
                 <div class="text-nowrap">
-                    <b class="text-warning-mellow">{{ucwords($appointment->status)}}</b>
+                    <b class="text-warning-mellow">{{ucwords($appointment->latestConfirmationDecision->decision_enum)}}</b>
                     <span class="text-secondary ml-1">on {{friendlier_date_time(convertToTimezone($appointment->latest_confirmation_decision_at, 'US/Eastern'))}}</span>
                 </div>
                 <div>
@@ -25,18 +22,30 @@
                         Re-schedule
                     </a>
                 </div>
+            @elseif($appointment->latestConfirmationDecision->decision_enum === 'WAIVED')
+                <div class="text-nowrap">
+                    <b class="text-warning-mellow">{{ucwords($appointment->latestConfirmationDecision->decision_enum)}}</b>
+                    <span class="text-secondary ml-1">on {{friendlier_date_time(convertToTimezone($appointment->latest_confirmation_decision_at, 'US/Eastern'))}}</span>
+                </div>
             @endif
-            @if($appointment->latestConfirmationDecision)
+            @if($appointment->latestConfirmationDecision && $appointment->latestConfirmationDecision->memo)
                 <div class="my-1 border text-sm px-2 py-1 bg-white max-width-300px">
-                    <b>Client feedback:</b><br>
-                    {{$appointment->latestConfirmationDecision->memo}}
+                    <span>Client feedback:</span>
+                    <span class="pl-2">{{ $appointment->latestConfirmationDecision->memo }}</span>
                 </div>
             @endif
-        @elseif($appointment->latest_confirmation_request_at) {{-- requested but not confirmed yet --}}
+        @endif
+        @if($appointment->latest_confirmation_request_at) {{-- requested but not confirmed yet --}}
             <div class="text-nowrap">
                 <b class="text-primary">Requested</b>
                 <span class="text-secondary ml-1">on {{friendlier_date_time(convertToTimezone($appointment->latest_confirmation_request_at, 'US/Eastern'))}}</span>
             </div>
+            @if($appointment->is_request_pending)
+                <div class="text-sm">
+                    <i class="fa fa-exclamation-triangle text-warning-mellow"></i>
+                    Request Pending
+                </div>
+            @endif
             <div>
                 @include('app.patient.partials.appointment-request-confirmation', ['label' => 'Re-request Confirmation'])
             </div>

+ 2 - 3
resources/views/app/patient/partials/appointments.blade.php

@@ -31,11 +31,10 @@
                                 <div class="mb-2">
                                     <select class="form-control form-control-sm bg-light" name="status" required>
                                         <option value="">-- select --</option>
-                                        <option {{ $appointment->status === 'CREATED' ? 'selected' : '' }} value="CREATED">CREATED</option>
+                                        <option {{ $appointment->status === 'PENDING' ? 'selected' : '' }} value="PENDING">PENDING</option>
                                         <option {{ $appointment->status === 'CONFIRMED' ? 'selected' : '' }} value="CONFIRMED">CONFIRMED</option>
                                         <option {{ $appointment->status === 'CANCELLED' ? 'selected' : '' }} value="CANCELLED">CANCELLED</option>
                                         <option {{ $appointment->status === 'COMPLETED' ? 'selected' : '' }} value="COMPLETED">COMPLETED</option>
-                                        <option {{ $appointment->status === 'ABANDONED' ? 'selected' : '' }} value="ABANDONED">ABANDONED</option>
                                     </select>
                                 </div>
                                 <div>
@@ -44,7 +43,7 @@
                                 </div>
                             </form>
                         </div>
-                        @if($appointment->status === 'CREATED')
+                        @if($appointment->status === 'PENDING')
                             <div moe class="ml-2">
                                 <a href="#" start show class="text-sm font-weight-bold">Req. Conf.</a>
                                 <form url="/api/appointment/sendConfirmationRequestViaSms">

+ 39 - 0
resources/views/app/patient/partials/bulkstamp.http

@@ -0,0 +1,39 @@
+	POST http://localhost:8080/api/measurement/bulkStamp
+	content-type: application/json
+	sessionKey: 172a6fad-56fb-4469-8f0b-cb5ee8e3c992
+
+	{
+		"clientUid": "664ab6e5-99de-4eab-82fc-69745746c20c",
+		"shouldAddEntry": true,
+		"entryDate": "2020-10-10",
+		"entryMemo": "",
+		"entryNumberOfMinutes":null,
+		"toStamp": [
+			{
+				"measurementUid":"ece20657-d584-464c-b387-ebb8b956c7f6",
+				"memo":null
+			},
+			{
+				"measurementUid":"37fd135a-8800-46a8-ab34-930380a717d6",
+				"memo":null
+			},
+			{
+				"measurementUid":"96e584c5-b75b-4831-8ae3-10b6a3438db2",
+				"memo":null
+			},
+			{
+				"measurementUid":"850055fb-a376-4361-965f-23570134a6bc",
+				"memo":null
+			}
+		]
+	}
+
+	
+ 
+ 
+ 
+
+ 
+ 
+ 
+

+ 396 - 7
resources/views/app/patient/settings.blade.php

@@ -136,7 +136,7 @@
                                     <select class="form-control form-control-sm" name="sex">
                                         <option value="">--select--</option>
                                         <option value="M" @if($patient->sex === 'M') selected @endif>Male</option>
-                                        <option value="F" @if($patient->sex === 'F') selected @endif>Female</option>                                       
+                                        <option value="F" @if($patient->sex === 'F') selected @endif>Female</option>
                                     </select>
                                 </div>
                                 <div>
@@ -310,14 +310,14 @@
                     </div>
 
                     <div class="mb-1">
-                        <label>Nurse:</label> <b>{{$patient->defaultNaPro ? $patient->defaultNaPro->displayName() : '-' }}</b>
+                        <label>Care Coordinator:</label> <b>{{$patient->defaultNaPro ? $patient->defaultNaPro->displayName() : '-' }}</b>
                         @if($pro->pro_type == 'ADMIN')
                             <div moe class="ml-2">
                                 <a start show><i class="fa fa-edit"></i></a>
                                 <form url="/api/client/putDefaultNaPro" class="mcp-theme-1">
                                     <input type="hidden" name="uid" value="{{$patient->uid}}">
                                     <div class="mb-2">
-                                        <label class="text-secondary text-sm">Nurse Pro</label>
+                                        <label class="text-secondary text-sm">Care Coordinator</label>
                                         <select provider-search data-pro-uid="{{ @$patient->defaultNaPro->uid }}"
                                                 name="defaultNaProUid"
                                                 class="form-control form-control-sm">
@@ -343,7 +343,7 @@
                                     <form url="/api/client/removeDefaultNaPro" class="mcp-theme-1">
                                         <input type="hidden" name="uid" value="{{$patient->uid}}">
                                         <div class="mb-2">
-                                            <label class="text-secondary text-sm">Remove Nurse Pro</label>
+                                            <label class="text-secondary text-sm">Remove Care Coordinator</label>
 
                                         </div>
                                         <div>
@@ -358,6 +358,12 @@
                             @endif
                         @endif
                     </div>
+                    <div class="mb-1">
+                      MCP Pro: <b>{{ $patient->mcp->name_display ?? ''}}</b>
+                    </div>
+                    <div class="mb-1">
+                      RD Pro: <b>{{ $patient->rd->name_display ?? ''}}</b>
+                    </div>
                 </div>
 
                 <hr class="m-negator-3 my-3">
@@ -411,7 +417,7 @@
                                     <label class="mb-1 text-secondary text-sm">Claim Address Zip</label>
                                     <input type="text" class="form-control form-control-sm" value="{{ $patient->claim_address_zip }}" name="claimAddressZip" />
                                 </div>
-                                
+
                                 <div>
                                     <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
                                     <button cancel class="btn btn-sm btn-default border">Cancel</button>
@@ -435,11 +441,394 @@
                         <div>
                             Claim Address Zip: <b>{{ $patient->claim_address_zip ?? '' }}</b>
                         </div>
-                        
-                        
+
+
                     </div>
                 </div>
+                <hr class="m-negator-3 my-3">
+                <div>
+                    <p>Is Eligible For Cm: {{$patient->is_eligible_for_cm}}</p>
+		            <p>Why Not Eligible For Cm Category: {{$patient->why_not_eligible_for_cm_category}}</p>
+		            <p>Why Not Eligible For Cm Memo: {{$patient->why_not_eligible_for_cm_memo}}</p>
+                </div>
+                <div moe class="ml-2">
+                    <a start show><i class="fa fa-edit"></i>Update CM Eligibility</a>
+                    <form url="/api/client/updateCmEligibility" class="mcp-theme-1">
+                        <input type="hidden" name="uid" value="{{$patient->uid}}">
+                        <div class="form-group">
+                            <label class="control-label">Is Eligible For Cm </label>
+                            <select name="isEligibleForCm" class="form-control">
+                                <option value="">--</option>
+                                <option value="YES">Yes</option>
+                                <option value="NO">No</option>
+                                <option value="UNKNOWN">Unknown</option>
+                            </select>
+                        </div>
+                        <div class="form-group">
+                            <label class="control-label">Why Not Eligible For Cm Category</label>
+                            <input type="text" name="whyNotEligibleForCmCategory" class="form-control">
+                        </div>
+                        <div class="form-group">
+                            <label class="control-label">Why Not Eligible For Cm Memo</label>
+                            <input type="text" name="whyNotEligibleForCmMemo" class="form-control">
+                        </div>
+                        <div>
+                            <button submit class="btn btn-sm btn-primary mr-1">Submit
+                            </button>
+                            <button cancel class="btn btn-sm btn-default border">
+                                Cancel
+                            </button>
+                        </div>
+                    </form>
+                </div>
+
+                <hr class="m-negator-3 my-3">
+                <div>
+                    <p>Is enrolled to CM: {{$patient->is_enrolled_in_cm}}</p>
+                    @if($patient->is_enrolled_in_cm == 'YES')
+                        <p>Cm Enrollment Consent Method Memo: {{$patient->cm_enrollment_consent_method}}</p>
+                        <p>Cm Enrollment Consent Method Memo: {{$patient->cm_enrollment_consent_method_memo}}</p>
+                    @else 
+                        <p>Why Not Enrolled In Cm Category:   {{$patient->why_not_enrolled_in_cm_category}}</p>
+		                <p>Why Not Enrolled In Cm Memo:   {{$patient->why_not_enrolled_in_cm_memo}}</p>
+                    @endif
+                </div>
+                @if($patient->is_enrolled_in_cm == 'YES')
+                <div moe class="ml-2">
+                    <a start show><i class="fa fa-edit"></i>Set is enrolled to CM to false</a>
+                    <form url="/api/client/setIsEnrolledInCmToFalse" class="mcp-theme-1">
+                        <input type="hidden" name="uid" value="{{$patient->uid}}">
+                        <div class="form-group">
+                            <label class="control-label">Why Not Enrolled In Cm Category</label>
+                            <input type="text" name="whyNotEnrolledInCmCategory" class="form-control">
+                        </div>
+                        <div class="form-group">
+                            <label class="control-label">Why Not Enrolled In Cm Memo</label>
+                            <input type="text" name="whyNotEnrolledInCmMemo" class="form-control">
+                        </div>
+                        <div>
+                            <button submit class="btn btn-sm btn-primary mr-1">Submit
+                            </button>
+                            <button cancel class="btn btn-sm btn-default border">
+                                Cancel
+                            </button>
+                        </div>
+                    </form>
+                </div>
+                
+                <div moe class="ml-2">
+                    <a start show><i class="fa fa-edit"></i>Update CM Enrollemnt Consent Info</a>
+                    <form url="/api/client/updateCmEnrollmentConsentInfo" class="mcp-theme-1">
+                        <input type="hidden" name="uid" value="{{$patient->uid}}">
+                        <div class="form-group">
+                            <label class="control-label">Cm Enrollment Consent Method</label>
+                            <input type="text" name="cmEnrollmentConsentMethod" value="{{$patient->cm_enrollment_consent_method}}" class="form-control">
+                        </div>
+                        <div class="form-group">
+                            <label class="control-label">Cm Enrollment Consent Method Memo</label>
+                            <input type="text" name="cmEnrollmentConsentMethodMemo" value="{{$patient->cm_enrollment_consent_method_memo}}" class="form-control">
+                        </div>
+                        <div>
+                            <button submit class="btn btn-sm btn-primary mr-1">Submit
+                            </button>
+                            <button cancel class="btn btn-sm btn-default border">
+                                Cancel
+                            </button>
+                        </div>
+                    </form>
+                </div>
+                
+                @else
+                <div moe class="ml-2">
+                    <a start show><i class="fa fa-edit"></i>Set is enrolled to CM to YES</a>
+                    <form url="/api/client/setIsEnrolledInCmToTrue" class="mcp-theme-1">
+                        <input type="hidden" name="uid" value="{{$patient->uid}}">
+                        <div class="form-group">
+                            <label class="control-label">Cm Enrollment Consent Method</label>
+                            <input type="text" name="cmEnrollmentConsentMethod" class="form-control">
+                        </div>
+                        <div class="form-group">
+                            <label class="control-label">Cm Enrollment Consent Method Memo</label>
+                            <input type="text" name="cmEnrollmentConsentMethodMemo" class="form-control">
+                        </div>
+                        <div>
+                            <button submit class="btn btn-sm btn-primary mr-1">Submit
+                            </button>
+                            <button cancel class="btn btn-sm btn-default border">
+                                Cancel
+                            </button>
+                        </div>
+                    </form>
+                </div>
+
+                <div moe class="ml-2">
+                    <a start show><i class="fa fa-edit"></i>Update Why Not Enrolled In CM</a>
+                    <form url="/api/client/updateWhyNotEnrolledInCm" class="mcp-theme-1">
+                        <input type="hidden" name="uid" value="{{$patient->uid}}">
+                        <div class="form-group">
+                            <label class="control-label">Why Not Enrolled In Cm Category</label>
+                            <input type="text" name="whyNotEnrolledInCmCategory" value="{{$patient->why_not_enrolled_in_cm_category}}" class="form-control">
+                        </div>
+                        <div class="form-group">
+                            <label class="control-label">Why Not Enrolled In Cm Memo</label>
+                            <input type="text" name="whyNotEnrolledInCmMemo" value="{{$patient->why_not_enrolled_in_cm_memo}}" class="form-control">
+                        </div>
+                        <div>
+                            <button submit class="btn btn-sm btn-primary mr-1">Submit
+                            </button>
+                            <button cancel class="btn btn-sm btn-default border">
+                                Cancel
+                            </button>
+                        </div>
+                    </form>
+                </div>
+                @endif
+                <hr class="m-negator-3 my-3">
+                <div>
+                    <p>Is Eligible For RM: {{$patient->is_eligible_for_rm}}</p>
+		            <p>Why Not Eligible For RM Category: {{$patient->why_not_eligible_for_rm_category}}</p>
+		            <p>Why Not Eligible For RM Memo: {{$patient->why_not_eligible_for_rm_memo}}</p>
+                </div>
+                <div moe class="ml-2">
+                    <a start show><i class="fa fa-edit"></i>Update RM Eligiblity</a>
+                    <form url="/api/client/updateRmEligibility" class="mcp-theme-1">
+                        <input type="hidden" name="uid" value="{{$patient->uid}}">
+                        <div class="form-group">
+                            <label class="control-label">Is Eligible For RM </label>
+                            <select name="isEligibleForRm" class="form-control">
+                                <option value="">-- </option>
+                                <option value="YES">Yes</option>
+                                <option value="NO">No</option>
+                                <option value="UNKNOWN">Unknown</option>
+                            </select>
+                        </div>
+                        <div class="form-group">
+                            <label class="control-label">Why Not Eligible For RM Category</label>
+                            <input type="text" name="whyNotEligibleForRmCategory" class="form-control">
+                        </div>
+                        <div class="form-group">
+                            <label class="control-label">Why Not Eligible For RM Memo</label>
+                            <input type="text" name="whyNotEligibleForRmMemo" class="form-control">
+                        </div>
+                        <div>
+                            <button submit class="btn btn-sm btn-primary mr-1">Submit
+                            </button>
+                            <button cancel class="btn btn-sm btn-default border">
+                                Cancel
+                            </button>
+                        </div>
+                    </form>
+                </div>
 
+                <hr class="m-negator-3 my-3">
+                <div>
+                    <p>Is enrolled to RM: {{$patient->is_enrolled_in_rm}}</p>
+                    @if($patient->is_enrolled_in_rm == 'NO')
+                        <p>Why Not Enrolled In RM Category:   {{$patient->why_not_enrolled_in_rm_category}}</p>
+		                <p>Why Not Enrolled In RM Memo:   {{$patient->why_not_enrolled_in_rm_memo}}</p>
+                    @endif
+                </div>
+                @if($patient->is_enrolled_in_rm == 'YES')
+                <div moe class="ml-2">
+                    <a start show><i class="fa fa-edit"></i>Set is enrolled to RM to false</a>
+                    <form url="/api/client/setIsEnrolledInRmToFalse" class="mcp-theme-1">
+                        <input type="hidden" name="uid" value="{{$patient->uid}}">
+                        <div class="form-group">
+                            <label class="control-label">Why Not Enrolled In Rm Category</label>
+                            <input type="text" name="whyNotEnrolledInRmCategory" class="form-control">
+                        </div>
+                        <div class="form-group">
+                            <label class="control-label">Why Not Enrolled In Rm Memo</label>
+                            <input type="text" name="whyNotEnrolledInRmMemo" class="form-control">
+                        </div>
+                        <div>
+                            <button submit class="btn btn-sm btn-primary mr-1">Submit
+                            </button>
+                            <button cancel class="btn btn-sm btn-default border">
+                                Cancel
+                            </button>
+                        </div>
+                    </form>
+                </div>
+                
+                @else
+                <div moe class="ml-2">
+                    <a start show><i class="fa fa-edit"></i>Set is enrolled to RM to YES</a>
+                    <form url="/api/client/setIsEnrolledInRmToTrue" class="mcp-theme-1">
+                        <input type="hidden" name="uid" value="{{$patient->uid}}">
+                        <div class="form-group">
+                            <label class="control-label">Are you sure?</label>
+                        </div>
+                        
+                        <div>
+                            <button submit class="btn btn-sm btn-primary mr-1">Submit
+                            </button>
+                            <button cancel class="btn btn-sm btn-default border">
+                                Cancel
+                            </button>
+                        </div>
+                    </form>
+                </div>
+
+                <div moe class="ml-2">
+                    <a start show><i class="fa fa-edit"></i>Update Why Not Enrolled In RM</a>
+                    <form url="/api/client/updateWhyNotEnrolledInRm" class="mcp-theme-1">
+                        <input type="hidden" name="uid" value="{{$patient->uid}}">
+                        <div class="form-group">
+                            <label class="control-label">Why Not Enrolled In RM Category</label>
+                            <input type="text" name="whyNotEnrolledInRmCategory" value="{{$patient->why_not_enrolled_in_rm_category}}" class="form-control">
+                        </div>
+                        <div class="form-group">
+                            <label class="control-label">Why Not Enrolled In RM Memo</label>
+                            <input type="text" name="whyNotEnrolledInRmMemo" value="{{$patient->why_not_enrolled_in_rm_memo}}" class="form-control">
+                        </div>
+                        <div>
+                            <button submit class="btn btn-sm btn-primary mr-1">Submit
+                            </button>
+                            <button cancel class="btn btn-sm btn-default border">
+                                Cancel
+                            </button>
+                        </div>
+                    </form>
+                </div>
+                @endif
+
+                @if($performer->pro->pro_type === 'ADMIN')
+                <hr class="m-negator-3 my-3">
+                <div>
+                    <h3>Admin Engagement Assessment Status</h3>
+                    <p>Category: {{$patient->adminEngagementAssessmentStatus->status_category ?? ''}}</p>
+		            <p>Memo: {{$patient->adminEngagementAssessmentStatus->status_memo ?? ''}}</p>
+		            <p>Detail: {{$patient->adminEngagementAssessmentStatus->status_detail ?? ''}}</p>
+                </div>
+                <div moe class="ml-2">
+                    <a start show><i class="fa fa-edit"></i>Update Admin Engagement Assessment Status</a>
+                    <form url="/api/client/updateAdminEngagementAssessmentStatus" class="mcp-theme-1">
+                        <input type="hidden" name="uid" value="{{$patient->uid}}">
+                        <div class="form-group">
+                            <label class="control-label">Category </label>
+                            <select name="category" class="form-control">
+                                <option value="NULL">--</option> 
+                                <option value="ACTIVE">ACTIVE</option> 
+                                <option value="INACTIVE">INACTIVE</option> 
+                                <option value="ENTRY_ERROR">ENTRY_ERROR</option> 
+                                <option value="DUMMY">DUMMY</option> 
+                                <option value="DECEASED">DECEASED</option>
+	                            <option value="DUPLICATE">DUPLICATE</option> 
+                                <option value="NO_LONGER_INTERESTED">NO_LONGER_INTERESTED</option> 
+                                <option value="BAD_RECORD">BAD_RECORD</option>
+                            </select>
+                        </div>
+                        <div class="form-group">
+                            <label class="control-label">Memo</label>
+                            <input type="text" name="memo" class="form-control">
+                        </div>
+                        <div class="form-group">
+                            <label class="control-label">Detail</label>
+                            <input type="text" name="detail" class="form-control">
+                        </div>
+                        <div>
+                            <button submit class="btn btn-sm btn-primary mr-1">Submit
+                            </button>
+                            <button cancel class="btn btn-sm btn-default border">
+                                Cancel
+                            </button>
+                        </div>
+                    </form>
+                </div>
+                @endif
+
+                @if($patient->mcp && $performer->pro->id == $patient->mcp->id || true)
+                <hr class="m-negator-3 my-3">
+                <div>
+                    <h3>MCP Engagement Assessment Status</h3>
+                    <p>Category: {{$patient->mcpEngagementAssessmentStatus->status_category ?? ''}}</p>
+		            <p>Memo: {{$patient->mcpEngagementAssessmentStatus->status_memo ?? ''}}</p>
+		            <p>Detail: {{$patient->mcpEngagementAssessmentStatus->status_detail ?? ''}}</p>
+                </div>
+                <div moe class="ml-2">
+                    <a start show><i class="fa fa-edit"></i>Update MCP Engagement Assessment Status</a>
+                    <form url="/api/client/updateMcpEngagementAssessmentStatus" class="mcp-theme-1">
+                        <input type="hidden" name="uid" value="{{$patient->uid}}">
+                        <div class="form-group">
+                            <label class="control-label">Category </label>
+                            <select name="category" class="form-control">
+                                <option value="NULL">--</option> 
+                                <option value="ACTIVE">ACTIVE</option> 
+                                <option value="INACTIVE">INACTIVE</option> 
+                                <option value="ENTRY_ERROR">ENTRY_ERROR</option> 
+                                <option value="DUMMY">DUMMY</option> 
+                                <option value="DECEASED">DECEASED</option>
+	                            <option value="DUPLICATE">DUPLICATE</option> 
+                                <option value="NO_LONGER_INTERESTED">NO_LONGER_INTERESTED</option> 
+                                <option value="BAD_RECORD">BAD_RECORD</option>
+                            </select>
+                        </div>
+                        <div class="form-group">
+                            <label class="control-label">Memo</label>
+                            <input type="text" name="memo" class="form-control">
+                        </div>
+                        <div class="form-group">
+                            <label class="control-label">Detail</label>
+                            <input type="text" name="detail" class="form-control">
+                        </div>
+                        <div>
+                            <button submit class="btn btn-sm btn-primary mr-1">Submit
+                            </button>
+                            <button cancel class="btn btn-sm btn-default border">
+                                Cancel
+                            </button>
+                        </div>
+                    </form>
+                </div>
+                @endif
+                @if($patient->defaultNaPro && $performer->pro->id == $patient->defaultNaPro->id)
+                <hr class="m-negator-3 my-3">
+                <div>
+                    <h3>Default NA Engagement Assessment Status</h3>
+                    <p>Category: {{$patient->defaultNaEngagementAssessmentStatus->status_category ?? ''}}</p>
+		            <p>Memo: {{$patient->defaultNaEngagementAssessmentStatus->status_memo ?? ''}}</p>
+		            <p>Detail: {{$patient->defaultNaEngagementAssessmentStatus->status_detail ?? ''}}</p>
+                </div>
+                <div moe class="ml-2">
+                    <a start show><i class="fa fa-edit"></i>Update Default NA Engagement Assessment Status</a>
+                    <form url="/api/client/updateDefaultNaEngagementAssessmentStatus" class="mcp-theme-1">
+                        <input type="hidden" name="uid" value="{{$patient->uid}}">
+                        <div class="form-group">
+                            <label class="control-label">Category </label>
+                            <select name="category" class="form-control">
+                                <option value="NULL">--</option> 
+                                <option value="ACTIVE">ACTIVE</option> 
+                                <option value="INACTIVE">INACTIVE</option> 
+                                <option value="ENTRY_ERROR">ENTRY_ERROR</option> 
+                                <option value="DUMMY">DUMMY</option> 
+                                <option value="DECEASED">DECEASED</option>
+	                            <option value="DUPLICATE">DUPLICATE</option> 
+                                <option value="NO_LONGER_INTERESTED">NO_LONGER_INTERESTED</option> 
+                                <option value="BAD_RECORD">BAD_RECORD</option>
+                            </select>
+                        </div>
+                        <div class="form-group">
+                            <label class="control-label">Memo</label>
+                            <input type="text" name="memo" class="form-control">
+                        </div>
+                        <div class="form-group">
+                            <label class="control-label">Detail</label>
+                            <input type="text" name="detail" class="form-control">
+                        </div>
+                        <div>
+                            <button submit class="btn btn-sm btn-primary mr-1">Submit
+                            </button>
+                            <button cancel class="btn btn-sm btn-default border">
+                                Cancel
+                            </button>
+                        </div>
+                    </form>
+                </div>
+                @endif
+                <!-- <div>
+                /updateClientEngagementAssessmentStatus
+                </div> -->
             </div>
             <div class="col-6 border-left">
 

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików