unknown 3 years ago
parent
commit
6695e33aaa

+ 27 - 344
app/Http/Controllers/HomeController.php

@@ -32,340 +32,6 @@ use Illuminate\Support\Facades\Http;
 class HomeController extends Controller
 class HomeController extends Controller
 {
 {
 
 
-    public function dashboardMcp(Request $request)
-    {
-
-        //patients where performer is the mcp
-        $performer = $this->performer();
-        $pro = $this->performer()->pro;
-        $performerProID = $pro->id;
-        $keyNumbers  = [];
-
-        $keyNumbers['patients_count'] = $pro->get_patients_count_as_mcp();
-        $keyNumbers['new_patients_awaiting_visit_count'] = $pro->get_new_patients_awaiting_visit_count_as_mcp();
-        $keyNumbers['notes_pending_signature_count'] = $pro->get_notes_pending_signature_count_as_mcp();
-        $keyNumbers['notes_pending_billing_count'] = $pro->get_notes_pending_billing_count_as_mcp();
-        $keyNumbers['measurements_awaiting_review_count'] = $pro->get_measurements_awaiting_review_count_as_mcp();
-        $keyNumbers['incoming_reports_pending_signature_count'] = $pro->get_incoming_reports_pending_signature_count_as_mcp();
-
-        $keyNumbers['patients_without_appointment'] = $pro->get_patients_without_appointment_count_as_mcp();
-        $keyNumbers['patients_not_seen_in_45_days'] = $pro->get_patients_not_seen_in_45_days_count_as_mcp();
-
-        $keyNumbers['patients_without_remote_measurement_in_48_hours'] = $pro->get_patients_without_remote_measurement_in_48_hours_count_as_mcp();
-
-        $keyNumbers['cancelled_appointments_pending_acknowledgement'] = $pro->get_cancelled_appointments_pending_acknowledgement_count_as_mcp();
-        $keyNumbers['cancelled_bills_awaiting_review'] = $pro->get_cancelled_bills_awaiting_review_count_as_mcp();
-        $keyNumbers['cancelled_supply_orders_awaiting_review'] = $pro->get_cancelled_supply_orders_awaiting_review_count_as_mcp();
-
-        $keyNumbers['erx_and_orders_awaiting_signature'] = $pro->get_erx_and_orders_awaiting_signature_count_as_mcp();
-        $keyNumbers['supply_orders_awaiting_signature'] = $pro->get_supply_orders_awaiting_signature_count_as_mcp();
-
-        $reimbursement = [];
-        $reimbursement["currentBalance"] =  $performer->pro->balance;
-        $reimbursement["nextPaymentDate"] = '--';
-        $lastPayment = ProTransaction::where('pro_id', $pro->id)->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();
-
-        $proApptUpdates = AppointmentConfirmationDecision
-            ::select('appointment_confirmation_decision.uid', 'client.name_first', 'client.name_last', 'appointment.start_time')
-            ->rightJoin('appointment', 'appointment.id', '=', 'appointment_confirmation_decision.appointment_id')
-            ->rightJoin('client', 'client.id', '=', 'appointment.client_id')
-            ->where('appointment_confirmation_decision.was_acknowledged_by_appointment_pro', false)
-            ->where('appointment.status', '!=', 'CREATED')
-            ->where('appointment.status', '!=', 'COMPLETED')
-            ->where('appointment.status', '!=', 'ABANDONED')
-            ->where('appointment.pro_id', $performerProID)
-            ->where('client.mcp_pro_id', $performerProID)
-            ->orderBy('appointment.start_time', 'DESC')
-            ->get();
-
-        $naApptUpdates = AppointmentConfirmationDecision
-            ::select('appointment_confirmation_decision.uid', 'client.name_first', 'client.name_last', 'pro.name_first as pro_name_first', 'pro.name_last as pro_name_last', 'appointment.start_time')
-            ->rightJoin('appointment', 'appointment.id', '=', 'appointment_confirmation_decision.appointment_id')
-            ->rightJoin('client', 'client.id', '=', 'appointment.client_id')
-            ->rightJoin('pro', 'pro.id', '=', 'appointment.pro_id')
-            ->where('appointment_confirmation_decision.was_acknowledged_by_client_default_na', false)
-            ->where('appointment.status', '!=', 'CREATED')
-            ->where('appointment.status', '!=', 'COMPLETED')
-            ->where('appointment.status', '!=', 'ABANDONED')
-            ->where('client.default_na_pro_id', $performerProID)
-            ->orderBy('appointment.start_time', 'DESC')
-            ->get();
-
-//        $naApptUpdates = AppointmentConfirmationDecision
-//            ::join('appointment', 'appointment.id', '=', 'appointment_confirmation_decision.appointment_id')
-//            ->join('client', 'client.id', '=', 'appointment.client_id')
-//            ->where('client.default_na_pro_id', $performerProID)
-//            ->where('appointment_confirmation_decision.was_acknowledged_by_client_default_na', false)
-//            ->orderBy('appointment.start_time DESC')
-//            ->get();
-
-        // unstamped client memos
-        // for mcp
-        $mcpClientMemos = DB::select(
-            DB::raw("
-SELECT c.uid as client_uid, c.name_first, c.name_last,
-       cm.uid, cm.content, cm.created_at
-FROM client c join client_memo cm on c.id = cm.client_id
-WHERE
-      c.mcp_pro_id = {$performerProID} AND
-      cm.mcp_stamp_id IS NULL
-ORDER BY cm.created_at DESC
-            ")
-        );
-        // for na
-        $naClientMemos = DB::select(
-            DB::raw("
-SELECT c.uid as client_uid, c.name_first, c.name_last,
-       cm.uid, cm.content, cm.created_at
-FROM client c join client_memo cm on c.id = cm.client_id
-WHERE
-      c.default_na_pro_id = {$performerProID} AND
-      cm.default_na_stamp_id IS NULL
-ORDER BY cm.created_at DESC
-            ")
-        );
-
-        $naBillableSignedNotes = DB::select(DB::raw("
-SELECT count(note.id) as na_billable_notes
-FROM note
-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')
-            ->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;
-
-        // 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', compact('keyNumbers', 'reimbursement', 'milliseconds',
-            'businessNumbers',
-            'incomingReports', 'tickets', 'supplyOrders',
-            'numERx', 'numLabs', 'numImaging', 'numSupplyOrders',
-            'newMCPAssociations', 'newNAAssociations',
-            'mcpClientMemos', 'naClientMemos',
-            'proApptUpdates', 'naApptUpdates'));
-    }
-
     public function confirmSmsAuthToken(Request $request)
     public function confirmSmsAuthToken(Request $request)
     {
     {
         return view('app/confirm_sms_auth_token');
         return view('app/confirm_sms_auth_token');
@@ -522,24 +188,16 @@ WHERE cl.shadow_pro_id IS NULL
         }
         }
     }
     }
 
 
-    public function dashboard(Request $request)
-    {
+    private function dashboard_MCP(Request $request){
 
 
-        //patients where performer is the mcp
         $performer = $this->performer();
         $performer = $this->performer();
         $pro = $performer->pro;
         $pro = $performer->pro;
-        if($pro->is_enrolled_as_mcp){
-//            return $this->dashboardMcp($request);
-        }
         $performerProID = $performer->pro->id;
         $performerProID = $performer->pro->id;
-        $isAdmin = ($performer->pro->pro_type === 'ADMIN');
 
 
         $keyNumbers  = [];
         $keyNumbers  = [];
 
 
         $queryClients = $this->performer()->pro->getAccessibleClientsQuery();
         $queryClients = $this->performer()->pro->getAccessibleClientsQuery();
 
 
-
-
         $pendingNotesToSign = Note
         $pendingNotesToSign = Note
             ::where(function ($query) use ($performerProID) {
             ::where(function ($query) use ($performerProID) {
                 $query->where('hcp_pro_id', $performerProID)->where('is_signed_by_hcp', false)->where('is_cancelled', false);
                 $query->where('hcp_pro_id', $performerProID)->where('is_signed_by_hcp', false)->where('is_cancelled', false);
@@ -877,7 +535,7 @@ WHERE cl.shadow_pro_id IS NULL
 
 
         }
         }
 
 
-        return view('app/dashboard', compact('keyNumbers', 'reimbursement', 'milliseconds',
+        return view('app/dashboard-mcp', compact('keyNumbers', 'reimbursement', 'milliseconds',
             'businessNumbers',
             'businessNumbers',
             'incomingReports', 'tickets', 'supplyOrders',
             'incomingReports', 'tickets', 'supplyOrders',
             'numERx', 'numLabs', 'numImaging', 'numSupplyOrders',
             'numERx', 'numLabs', 'numImaging', 'numSupplyOrders',
@@ -886,6 +544,29 @@ WHERE cl.shadow_pro_id IS NULL
             'proApptUpdates', 'naApptUpdates'));
             'proApptUpdates', 'naApptUpdates'));
     }
     }
 
 
+    private function dashboard_DNA(Request $request){
+        $performer = $this->performer();
+        $pro = $performer->pro;
+    }
+
+    private function dashboard_ADMIN(Request $request){
+        $performer = $this->performer();
+        $pro = $performer->pro;
+    }
+
+    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) {
     public function dashboardMeasurementsTab(Request $request, $page = 1) {
 
 
         $performer = $this->performer();
         $performer = $this->performer();
@@ -1037,6 +718,8 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
                 $appointment->client->age_in_years . ' y.o' .
                 $appointment->client->age_in_years . ' y.o' .
                 ($appointment->client->sex ? ' ' . $appointment->client->sex : '') .
                 ($appointment->client->sex ? ' ' . $appointment->client->sex : '') .
                 ')';
                 ')';
+            $appointment->clientAge = $appointment->client->age_in_years;
+            $appointment->clientSex = $appointment->client->sex;
 
 
             $appointment->started = false;
             $appointment->started = false;
             $appointment->inHowManyHours = date_diff(date_create('now'), date_create($appointment->start_time), false)
             $appointment->inHowManyHours = date_diff(date_create('now'), date_create($appointment->start_time), false)

+ 48 - 1
app/Models/Pro.php

@@ -352,6 +352,7 @@ class Pro extends Model
     }
     }
 
 
     function get_notes_pending_signature_count_as_dna() {
     function get_notes_pending_signature_count_as_dna() {
+        return;
         $naBillableSignedNotes = DB::select(DB::raw("
         $naBillableSignedNotes = DB::select(DB::raw("
 SELECT count(note.id) as na_billable_notes
 SELECT count(note.id) as na_billable_notes
 FROM note
 FROM note
@@ -378,6 +379,7 @@ WHERE
     }
     }
 
 
     function get_notes_pending_billing_count_as_mcp() {
     function get_notes_pending_billing_count_as_mcp() {
+        return;
         return Note::where('hcp_pro_id', $this->id)
         return Note::where('hcp_pro_id', $this->id)
             ->where('is_signed_by_hcp', false)
             ->where('is_signed_by_hcp', false)
             ->where('is_cancelled', false)
             ->where('is_cancelled', false)
@@ -385,6 +387,7 @@ WHERE
     }
     }
 
 
     function get_bills_pending_signature_count_as_mcp(){
     function get_bills_pending_signature_count_as_mcp(){
+        return;
         $pendingBillsToSign = Bill::where('bill_service_type', '<>', 'CARE_MONTH')->where(function ($query) use ($performerProID) {
         $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);
             $query->where('hcp_pro_id', $performerProID)->where('is_signed_by_hcp', false)->where('is_cancelled', false);
         })
         })
@@ -400,10 +403,16 @@ WHERE
     }
     }
 
 
     function get_measurements_awaiting_review_count_as_mcp() {
     function get_measurements_awaiting_review_count_as_mcp() {
-
+        return;
     }
     }
 
 
     function get_incoming_reports_pending_signature_count_as_mcp() {
     function get_incoming_reports_pending_signature_count_as_mcp() {
+        return;
+        $incomingReports = IncomingReport::where('hcp_pro_id', $performerProID)
+            ->where('has_hcp_pro_signed', false)
+            ->where('is_entry_error', false)
+            ->orderBy('created_at', 'ASC')
+            ->get();
     }
     }
 
 
     function get_patients_without_appointment_count_as_mcp() {
     function get_patients_without_appointment_count_as_mcp() {
@@ -419,15 +428,53 @@ WHERE
     }
     }
 
 
     function get_cancelled_bills_awaiting_review_count_as_mcp() {
     function get_cancelled_bills_awaiting_review_count_as_mcp() {
+        return;
+        Bill::where('hcp_pro_id', $performerProID)
+            ->where('is_cancelled', true)
+            ->where('is_cancellation_acknowledged', false)
+            ->count();
     }
     }
 
 
     function get_cancelled_supply_orders_awaiting_review_count_as_mcp() {
     function get_cancelled_supply_orders_awaiting_review_count_as_mcp() {
+        return;
+        $keyNumbers['unacknowledgedCancelledSupplyOrders'] = SupplyOrder::where('signed_by_pro_id', $performerProID)
+            ->where('is_cancelled', true)
+            ->where('is_cancellation_acknowledged', false)
+            ->count();
+
     }
     }
 
 
     function get_erx_and_orders_awaiting_signature_count_as_mcp() {
     function get_erx_and_orders_awaiting_signature_count_as_mcp() {
     }
     }
 
 
     function get_supply_orders_awaiting_signature_count_as_mcp() {
     function get_supply_orders_awaiting_signature_count_as_mcp() {
+        return;
+        $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();
+    }
+
+    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 getAccessibleClientsQuery($_search = false) {
     public function getAccessibleClientsQuery($_search = false) {

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


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

@@ -0,0 +1,977 @@
+@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">
+
+                            <!-- 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

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

@@ -0,0 +1,787 @@
+@extends ('layouts.template')
+
+@section('content')
+
+    <style>
+        tr.thin th, tr.thin td, .dashboard-stats-table tr td, .dashboard-stats-table tr th {
+            padding: 0.25em;
+            font-weight: normal;
+        }
+        table.appointments tr td {
+            vertical-align: middle;
+        }
+    </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 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">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 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>
+                                    <th colspan="2">Revenue Cycle Management</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">
+                        <div class="col-6">
+
+                            <!-- Appointment Updates -->
+
+                            @if(count($proApptUpdates))
+                            <div class="card mb-4 ack-container">
+                                <div class="card-header pl-2">
+                                    <strong>
+                                        Appointment Updates
+                                    </strong>
+                                </div>
+                                <div class="card-body p-0">
+                                    <table class="table table-sm mb-0 table-bordered">
+                                        <tbody>
+                                        <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>
+                            </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">
+                                                New Patients
+                                                <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
+                        </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'">
+                                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 & Orders ({{$numERx}})
+                            </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"></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>
+
+                                <table class="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>
+                                            <span class="small d-inline-block text-secondary font-weight-normal"> (@{{ event.clientAge }} y.o. @{{event.clientSex}})</span>
+                                        </td>
+                                        <td>
+                                            @{{ event.friendlyStartTime }} - @{{ event.friendlyEndTime }} <span
+                                                class="text-secondary">@{{ 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>
+                                                Edit
+                                            </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>
+                                                <div v-else class="text-secondary">
+                                                    Status: <b>@{{ event.status }}</b>
+                                                </div>
+                                            </div>
+                                        </td>
+                                        <td>
+                                            <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>
+                                        </td>
+                                        <td>
+                                            <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>
+                                        </td>
+                                    </tr>
+                                </table>
+
+                                <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>
+                </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;
+                    });
+            }
+
+            addMCInitializer('pro-dashboard', init, '#pro-dashboard-container');
+        })();
+    </script>
+@endsection