浏览代码

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

Josh 3 年之前
父节点
当前提交
caddffca84

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

@@ -214,4 +214,66 @@ class DnaController extends Controller
         return view('app.dna.supply_orders_pending_signature', $data);
     }
 
+    //From the new spec 
+    public function myPatients(Request $request){
+        $pro = $this->performer->pro; 
+        $records = $pro->patientsRecordsAsDna();
+        return view('app.dna.dashboard.patients', compact('records'));
+    }
+    
+    public function patientsAwaitingMcpVisit(Request $request){
+        $pro = $this->performer->pro; 
+        $records = $pro->patientsAwaitingMcpVisitRecordsAsDna();
+        return view('app.dna.dashboard.patients_awaiting_mcp_visit', compact('records'));
+    }
+    
+    public function patientsWithoutAppointment(Request $request){
+        $pro = $this->performer->pro; 
+        $records = $pro->patientsWithoutAppointmentRecordsAsDna();
+        return view('app.dna.dashboard.patients_without_appointment', compact('records'));
+    }
+    
+    public function encountersPendingMyReview(Request $request){
+        $pro = $this->performer->pro; 
+        $records = $pro->encountersPendingMyReviewRecordsAsDna();
+        return view('app.dna.dashboard.encounters_pending_my_review', compact('records'));
+    }
+    
+    public function encountersInProgress(Request $request){
+        $pro = $this->performer->pro; 
+        $records = $pro->encountersInProgressRecordsAsDna();
+        return view('app.dna.dashboard.encounters_in_progress', compact('records'));
+    }
+    
+    public function appointmentsPendingConfirmation(Request $request){
+        $pro = $this->performer->pro; 
+        $records = $pro->appointmentsPendingConfirmationRecordsAsDna();
+        return view('app.dna.dashboard.appointments_pending_confirmation', compact('records'));
+    }
+    
+    public function cancelledAppointmentsPendingAck(Request $request){
+        $pro = $this->performer->pro; 
+        $records = $pro->cancelledAppointmentsPendingAckRecordsAsDna();
+        return view('app.dna.dashboard.cancelled_appointments_pending_ack', compact('records'));
+    }
+    
+    public function reportsPendingAck(Request $request){
+        $pro = $this->performer->pro; 
+        $records = $pro->reportsPendingAckRecordsAsDna();
+        return view('app.dna.dashboard.reports_pending_ack', compact('records'));
+    }
+    
+    public function supplyOrdersPendingMyAck(Request $request){
+        $pro = $this->performer->pro; 
+        $records = $pro->supplyOrdersPendingMyAckRecordsAsDna();
+        return view('app.dna.dashboard.supply_orders_pending_my_ack', compact('records'));
+    }
+    
+    public function supplyOrdersPendingHcpApproval(Request $request){
+        $pro = $this->performer->pro; 
+        $records = $pro->supplyOrdersPendingHcpApprovalRecordsAsDna();
+        return view('app.dna.dashboard.supply_orders_pending_hcp_approval', compact('records'));
+    }
+    
+
 }

+ 20 - 334
app/Http/Controllers/HomeController.php

@@ -576,337 +576,8 @@ WHERE cl.shadow_pro_id IS NULL
         $pro = $performer->pro;
         $performerProID = $performer->pro->id;
 
-        $keyNumbers  = [];
-
-        $queryClients = $pro->getAccessibleClientsQuery();
-        $keyNumbers['patients'] = $queryClients->count();
-
-        $pendingNotesToSign = Note::where('ally_pro_id', $performerProID)->where('is_signed_by_ally', false)->where('is_cancelled', false)->where('is_core_note', false)->count();
-        $keyNumbers['pendingNotesToSign'] = $pendingNotesToSign;
-
-        // notes pending mcp sign (applicable to dnas only)
-        $pendingNotesToSignMCP = Note::where('ally_pro_id', $performerProID)->where('is_signed_by_hcp', false)->where('is_cancelled', false)->where('is_core_note', false)->count();
-        $keyNumbers['$pendingNotesToSignMCP'] = $pendingNotesToSignMCP;
-
-        $pendingNotesToSignAlly = Note::where(function ($query) use ($performerProID) {
-            $query->where('ally_pro_id', $performerProID)->where('is_signed_by_ally', false)->where('is_cancelled', false)->where('is_core_note', false);
-        })->count();
-        $keyNumbers['$pendingNotesToSignAlly'] = $pendingNotesToSignAlly;
-
-
-        $signedNotesWithoutBills = Note::where(function ($query) use ($performerProID) {
-            $query->where('hcp_pro_id', $performerProID)->where('is_signed_by_hcp', true)->where('is_cancelled', false);
-        })->whereDoesntHave('bills')->count();
-
-        $keyNumbers['signedNotesWithoutBills'] = $signedNotesWithoutBills;
-
-        // open tickets
-        $keyNumbers['numOpenTickets'] = Ticket::where('is_open', true)
-            ->where(function ($q) use ($performerProID) {
-                $q->where('assigned_pro_id', $performerProID)
-                    ->orWhere('manager_pro_id', $performerProID)
-                    ->orWhere('ordering_pro_id', $performerProID)
-                    ->orWhere('initiating_pro_id', $performerProID);
-            })
-            ->count();
-
-        // unacknowledged cancelled bills for authed pro
-        $keyNumbers['unacknowledgedCancelledBills'] = Bill::where('na_pro_id', $performerProID)
-            ->where('is_cancelled', true)
-            ->where('is_cancellation_acknowledged', false)
-            ->count();
-
-        // unacknowledged cancelled supply orders for authed pro
-        $keyNumbers['unacknowledgedCancelledSupplyOrders'] = SupplyOrder::where('signed_by_pro_id', $performerProID)
-            ->where('is_cancelled', true)
-            ->where('is_cancellation_acknowledged', false)
-            ->count();
-
-        // unsigned supply orders created by authed pro
-        $keyNumbers['unsignedSupplyOrders'] = SupplyOrder
-            ::where('is_cancelled', false)
-            ->where('is_signed_by_pro', false)
-            ->whereRaw('created_by_session_id IN (SELECT id FROM app_session WHERE pro_id = ?)', [$performerProID])
-            ->count();
-
-        // patientsHavingBirthdayToday
-        $queryClients = $this->performer()->pro->getAccessibleClientsQuery();
-        $keyNumbers['patientsHavingBirthdayToday'] = $queryClients
-            ->whereRaw('EXTRACT(DAY from dob) = ?', [date('d')])
-            ->whereRaw('EXTRACT(MONTH from dob) = ?', [date('m')])
-            ->count();
-
-        $reimbursement = [];
-        $reimbursement["currentBalance"] =  $performer->pro->balance;
-        $reimbursement["nextPaymentDate"] = '--';
-        $lastPayment = ProTransaction::where('pro_id', $performerProID)->where('plus_or_minus', 'PLUS')->orderBy('created_at', 'DESC')->first();
-        if ($lastPayment) {
-            $reimbursement["lastPayment"] =  $lastPayment->amount;
-            $reimbursement["lastPaymentDate"] = $lastPayment->created_at;
-        } else {
-            $reimbursement["lastPayment"] = '--';
-            $reimbursement["lastPaymentDate"] = '--';
-        }
-
-        //if today is < 15th, next payment is 15th, else nextPayment is
-        $today = strtotime(date('Y-m-d'));
-        $todayDate = date('j', $today);
-
-        $todayMonth =  date('m', $today);
-        $todayYear = date('Y', $today);
-        if ($todayDate < 15) {
-            $nextPaymentDate = new DateTime();
-            $nextPaymentDate->setDate($todayYear, $todayMonth, 15);
-            $reimbursement['nextPaymentDate'] = $nextPaymentDate->format('m/d/Y');
-        } else {
-            $nextPaymentDate = new \DateTime();
-            $lastDayOfMonth = date('t', $today);
-            $nextPaymentDate->setDate($todayYear, $todayMonth, $lastDayOfMonth);
-            $reimbursement['nextPaymentDate'] = $nextPaymentDate->format('m/d/Y');
-        }
-
-        //expectedPay
-        $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 =  $expectedForCm + $expectedForRme + $expectedForRmm + $expectedForNa;
-        $reimbursement['nextPaymentAmount'] =  $totalExpectedAmount;
-
-        $milliseconds = strtotime(date('Y-m-d')) . '000';
-
-        // bills & claims
-        $businessNumbers = [];
-
-        // Notes with bills to resolve
-        $businessNumbers['notesWithBillsToResolve'] = Note::where('is_cancelled', '!=', true)
-            ->where('is_bill_closed', '!=', true)
-            ->whereRaw('(SELECT count(id) FROM bill WHERE note_id = note.id AND is_cancelled = false AND is_verified = false) > 0')
-            ->count();
-
-        // Notes pending bill closure
-        $businessNumbers['notesPendingBillingClosure'] = Note::where('is_cancelled', '!=', true)
-            ->where('is_bill_closed', '!=', true)
-            ->whereRaw('(SELECT count(id) FROM bill WHERE note_id = note.id AND (is_cancelled = true OR is_verified = true)) = 0')
-            ->count();
-
-        // incoming reports not signed
-        $incomingReports = IncomingReport::where('hcp_pro_id', $performerProID)
-            ->where('has_hcp_pro_signed', false)
-            ->where('is_entry_error', false)
-            ->orderBy('created_at', 'ASC')
-            ->get();
-        // erx, labs & imaging that are not closed
-        $tickets = Ticket::where('ordering_pro_id', $performerProID)
-            ->where('is_entry_error', false)
-            ->where('is_open', true)
-            ->orderBy('created_at', 'ASC')
-            ->get();
-        $supplyOrders = SupplyOrder::where('is_cleared_for_shipment', false)
-            ->where('is_cancelled', false)
-            ->whereRaw('created_by_session_id IN (SELECT id FROM app_session where pro_id = ?)', [$performer->pro->id])
-            ->orderBy('created_at', 'ASC')
-            ->get();
-
-        $numERx = Ticket::where('ordering_pro_id', $performerProID)
-            ->where('category', 'erx')
-            ->where('is_entry_error', false)
-            ->where('is_open', true)
-            ->count();
-        $numLabs = Ticket::where('ordering_pro_id', $performerProID)
-            ->where('category', 'lab')
-            ->where('is_entry_error', false)
-            ->where('is_open', true)
-            ->count();
-        $numImaging = Ticket::where('ordering_pro_id', $performerProID)
-            ->where('category', 'imaging')
-            ->where('is_entry_error', false)
-            ->where('is_open', true)
-            ->count();
-        $numSupplyOrders = SupplyOrder::where('is_cleared_for_shipment', false)
-            ->where('is_cancelled', false)
-            ->whereRaw('created_by_session_id IN (SELECT id FROM app_session where pro_id = ?)', [$performer->pro->id])
-            ->count();
-
-        $newMCPAssociations = ClientProChange
-            ::where('new_pro_id', $performerProID)
-            ->where('responsibility_type', 'MCP')
-            ->whereNull('current_client_pro_change_decision_id')
-            ->get();
-
-        $newNAAssociations = ClientProChange
-            ::where('new_pro_id', $performerProID)
-            ->where('responsibility_type', 'DEFAULT_NA')
-            ->whereNull('current_client_pro_change_decision_id')
-            ->get();
-
-        // unstamped client memos
-        // for mcp
-        $mcpClientMemos = DB::select(
-            DB::raw("
-SELECT c.uid as client_uid, c.name_first, c.name_last,
-       cm.uid, cm.content, cm.created_at
-FROM client c join client_memo cm on c.id = cm.client_id
-WHERE
-      c.mcp_pro_id = {$performerProID} AND
-      cm.mcp_stamp_id IS NULL
-ORDER BY cm.created_at DESC
-            ")
-        );
-        // for na
-        $naClientMemos = DB::select(
-            DB::raw("
-SELECT c.uid as client_uid, c.name_first, c.name_last,
-       cm.uid, cm.content, cm.created_at
-FROM client c join client_memo cm on c.id = cm.client_id
-WHERE
-      c.default_na_pro_id = {$performerProID} AND
-      cm.default_na_stamp_id IS NULL
-ORDER BY cm.created_at DESC
-            ")
-        );
-
-        $keyNumbers['rmBillsToSign'] = Bill
-            ::where('is_cancelled', false)
-            ->where('cm_or_rm', 'RM')
-            ->where(function ($q) use ($performerProID) {
-                $q
-                    ->where(function ($q2) use ($performerProID) {
-                        $q2->where('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.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.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.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.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;
-
-        }
-
-        $incomingSmsMessagesPendingReply = DB::select("
-            SELECT cs.* ,c.uid as client_uid, c.name_first as client_name_first, c.name_last as client_name_last FROM client_sms cs LEFT JOIN client c ON c.id = cs.client_id
-            WHERE cs.is_reply_needed = 'YES' AND c.mcp_pro_id = :mcp_pro_id AND incoming_or_outgoing = 'INCOMING'
-            AND (cs.created_at > c.last_sms_sent_to_client_at OR c.last_sms_sent_to_client_at IS NULL)
-            ORDER BY created_at DESC
-        ", ['mcp_pro_id' => $performer->pro->id]);
-
-        $careMonthsWithMeasurementsPendingStamping = CareMonth::select('id')
-            ->where('mcp_pro_id', $this->performer->pro->id)
-            ->where('rm_num_measurements_not_stamped_by_mcp', '>', 0)
-            ->whereNotNull('rm_num_measurements_not_stamped_by_mcp')
-            ->orderBy('created_at', 'DESC')
-            ->get()
-            ->map(function($_x) {
-                return $_x->id;
-            })
-            ->toArray();
-
-        $measurementsPendingStamping = Measurement::whereIn('care_month_id', $careMonthsWithMeasurementsPendingStamping)
-            ->orderBy('created_at', 'DESC')
-            ->whereNotNull('ts')
-            ->whereNotIn('label', ['SBP', 'DBP'])
-            ->where('is_cellular_zero', '<>', true)
-            ->where('is_removed', false)
-            ->where('has_been_stamped_by_mcp', false)
-            ->whereNotNull('client_bdt_measurement_id')
-            ->whereHas('client', function($clientQuery) use ($performerProID){
-               return $clientQuery->where('default_na_pro_id', $performerProID);
-            })
-            ->paginate(15);
-
-
-        return view('app/dashboard-dna', compact('keyNumbers', 'reimbursement', 'milliseconds',
-            'businessNumbers',
-            'incomingReports', 'tickets', 'supplyOrders',
-            'numERx', 'numLabs', 'numImaging', 'numSupplyOrders',
-            'newMCPAssociations', 'newNAAssociations',
-            'mcpClientMemos', 'naClientMemos', 'measurementsPendingStamping', 'careMonthsWithMeasurementsPendingStamping', 'incomingSmsMessagesPendingReply'));
+        $milliseconds = strtotime(date('Y-m-d')) . '000'; //required by the calendar
+        return view('app/dashboard-dna', compact( 'milliseconds'));
     }
 
     private function dashboard_ADMIN(Request $request){
@@ -1393,7 +1064,12 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
         $results = DB::table('appointment')->select('raw_date')->distinct()->where("start_time", '>=', $from)->where("start_time", '<=', $to.' 23:59:00+00');
 
         if(!$isAdmin) {
-            $results = $results->where("pro_id", $performerProID);
+            $appointments = $appointments->where(function($q) use ($performerProID) {
+                return $q->where("pro_id", $performerProID)
+                    ->orWhereHas('client', function($clientQuery) use ($performerProID){
+                        return $clientQuery->where('default_na_pro_id', $performerProID);
+                    });
+            });
         }
 
         $results = $results->get();
@@ -1421,7 +1097,12 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
         $appointments = Appointment::where("raw_date", '=', $from);
 
         if(!$isAdmin) {
-            $appointments = $appointments->where("pro_id", $performerProID);
+            $appointments = $appointments->where(function($q) use ($performerProID) {
+                return $q->where("pro_id", $performerProID)
+                    ->orWhereHas('client', function($clientQuery) use ($performerProID){
+                        return $clientQuery->where('default_na_pro_id', $performerProID);
+                    });
+            });
         }
 
         $appointments = $appointments
@@ -1482,7 +1163,12 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
         $appointments = Appointment::where("raw_date", '=', $from);
 
         if(!$isAdmin) {
-            $appointments = $appointments->where("pro_id", $performerProID);
+            $appointments = $appointments->where(function($q) use ($performerProID) {
+                return $q->where("pro_id", $performerProID)
+                    ->orWhereHas('client', function($clientQuery) use ($performerProID){
+                        return $clientQuery->where('default_na_pro_id', $performerProID);
+                    });
+            });
         }
 
         $appointments = $appointments

+ 256 - 45
app/Models/Pro.php

@@ -5,6 +5,7 @@ namespace App\Models;
 # use Illuminate\Database\Eloquent\Model;
 
 use App\Helpers\TimeLine;
+use DateTime;
 use Exception;
 use Illuminate\Support\Facades\DB;
 
@@ -337,11 +338,6 @@ class Pro extends Model
         return $query->where('mcp_pro_id', $this->id)->count();
     }
 
-    function get_patients_count_as_dna() {
-        $query = Client::whereNull('shadow_pro_id');
-        return $query->where('default_na_pro_id', $this->id)->count();
-    }
-
     function get_new_patients_awaiting_visit_count_as_mcp() {
         $query = Client::whereNull('shadow_pro_id');
         return $query->where('mcp_pro_id', $this->id)
@@ -349,13 +345,6 @@ class Pro extends Model
             ->count();
     }
 
-    function get_new_patients_awaiting_visit_count_as_dna() {
-        $query = Client::whereNull('shadow_pro_id');
-        return $query->where('default_na_pro_id', $this->id)
-            ->where('has_mcp_done_onboarding_visit', '!=', 'YES')
-            ->count();
-    }
-
     function get_notes_pending_signature_count_as_mcp() {
         return Note::where('hcp_pro_id', $this->id)
             ->where('is_cancelled', '<>', true)
@@ -364,15 +353,6 @@ class Pro extends Model
             ->count();
     }
 
-
-    function get_notes_pending_signature_count_as_dna() {
-        return Note::where('ally_pro_id', $this->id)
-            ->where('is_cancelled', '<>', true)
-            ->where('is_core_note', '<>', true)
-            ->where('is_signed_by_ally', '<>', true)
-            ->count();
-    }
-
     function get_notes_pending_billing_count_as_mcp() {
         return Note::where('hcp_pro_id', $this->id)
             ->where('is_cancelled', '<>', true)
@@ -438,10 +418,6 @@ WHERE mcp_pro_id = :pro_id
         return $this->get_patients_without_appointment_query()->count();
     }
 
-    function get_patients_without_appointment_count_as_dna() {
-        return $this->get_patients_without_appointment_for_dna_query()->count();
-    }
-
     function get_patients_overdue_for_visit_query() {
         return Client::where('mcp_pro_id', $this->id)
                     ->where(function($q){
@@ -462,20 +438,10 @@ WHERE mcp_pro_id = :pro_id
         return $this->get_patients_overdue_for_visit_query()->count();
     }
 
-    function get_patients_overdue_count_as_dna() {
-        return $this->get_patients_overdue_for_visit_for_dna_query()->count();
-    }
-
-    
-
     function get_patients_without_remote_measurement_in_48_hours_count_as_mcp() {
         return DB::select("SELECT COUNT(*) as count FROM client WHERE ((most_recent_cellular_measurement_at+ interval '48 hour')::timestamp < NOW() OR most_recent_cellular_measurement_id IS NULL) AND client.mcp_pro_id = :mcp_pro_id AND is_active IS TRUE", ['mcp_pro_id'=>$this->id])[0]->count; 
     }
 
-    function get_patients_without_remote_measurement_in_48_hours_count_as_dna() {
-        return DB::select("SELECT COUNT(*) as count FROM client WHERE ((most_recent_cellular_measurement_at+ interval '48 hour')::timestamp < NOW() OR most_recent_cellular_measurement_id IS NULL) AND client.default_na_pro_id = :default_na_pro_id AND is_active IS TRUE", ['default_na_pro_id'=>$this->id])[0]->count; 
-    }
-
     function get_cancelled_appointments_pending_acknowledgement_count_as_mcp_query() {
         // SELECT * FROM appointment WHERE hcp_pro_id = :me.id AND status = 'REJECTED' AND wasAcknowledgedByAppointmentPro IS NOT TRUE;
         return Appointment::where('pro_id', $this->id)
@@ -496,16 +462,6 @@ WHERE mcp_pro_id = :pro_id
             ->count();
     }
 
-    //TODO: Generic bills that are cancelled where performer is the pro and not acknowledged
-    function get_cancelled_bills_awaiting_review_count_as_dna() {
-        // SELECT * FROM bill WHERE bill_service_type = 'GENERIC' AND is_cancelled IS TRUE AND isCancellationAcknowledged IS FALSE;
-        return Bill::where('generic_pro_id', $this->id)
-            ->where('bill_service_type', 'GENERIC')
-            ->where('is_cancelled', true)
-            ->where('is_cancellation_acknowledged', '<>', true)
-            ->count();
-    }
-
     function get_cancelled_supply_orders_awaiting_review_count_as_mcp() {
         // SELECT * FROM supply_order WHERE signed_by_pro_id = :me.id AND is_cancelled IS TRUE AND isCancellationAcknowledged IS NOT TRUE;
         return SupplyOrder::where('signed_by_pro_id', $this->id)
@@ -858,4 +814,259 @@ WHERE mcp_pro_id = :pro_id
         return 0;
     }
 
+    //DNA_DASHBOARD
+    
+    //queries
+    private function patientsQueryAsDna(){
+        // WHERE na_pro_id = :me.id
+        return Client::where('default_na_pro_id', $this->id);
+    }
+
+    private function patientsAwaitingMcpVisitQueryAsDna(){
+        // WHERE has_mcp_done_onboarding_visit <> 'YES'
+        return Client::where('default_na_pro_id', $this->id)->where('has_mcp_done_onboarding_visit', '<>', 'YES');
+    }
+
+    private function patientsWithoutAppointmentQueryAsDna(){
+        // WHERE today_mcp_appointment_date IS NULL AND next_mcp_appointment_date IS NULL
+        return Client::where('default_na_pro_id', $this->id)
+                        ->whereNull('today_mcp_appointment_date')
+                        ->whereNull('next_mcp_appointment_date');
+    }
+    
+    private function encountersPendingMyReviewQueryAsDna(){
+        // WHERE ally_pro_id = me.id AND is_cancelled IS NOT TRUE AND is_signed_by_hcp IS TRUE AND is_signed_by_ally IS NOT TRUE;
+        return Note::where('ally_pro_id', $this->id)
+            ->where('is_cancelled', '<>', true)
+            ->where('is_signed_by_hcp', true)
+            ->where('is_signed_by_ally','<>', true);
+    }
+
+    private function encountersInProgressQueryAsDna(){
+        // SELECT * FROM note WHERE ally_pro_id = me.id AND is_cancelled IS NOT TRUE AND is_signed_by_hcp IS NOT TRUE ORDER BY effective_dateest DESC, created_at DESC;
+        return Note::where('ally_pro_id', $this->id)
+                        ->where('is_cancelled', '<>', true)
+                        ->where('is_signed_by_hcp', '<>', true);
+    }
+
+    private function appointmentsPendingConfirmationQueryAsDna(){
+        // WHERE client_id IN (SELECT id FROM client WHERE default_na_pro_id = :me.id) AND status = 'PENDING'
+        $myId = $this->id;
+        return Appointment::whereHas('client', function($clientQuery) use ($myId) {
+            return $clientQuery->where('default_na_pro_id', $myId);
+        })->where('status', 'PENDING');
+    }
+    
+    private function cancelledAppointmentsPendingAckQueryAsDna(){
+        // WHERE client_id IN (SELECT id FROM client WHERE default_na_pro_id = :me.id) AND status = 'CANCELLED' AND is_status_acknowledgement_from_default_na_pending IS TRUE;
+        $myId = $this->id;
+        return Appointment::whereHas('client', function($clientQuery) use ($myId) {
+            return $clientQuery->where('default_na_pro_id', $myId);
+        })->where('status', 'CANCELLED')
+            ->where('is_status_acknowledgement_from_default_na_pending', true);
+    }
+    
+    private function reportsPendingAckQueryAsDna(){
+        // WHERE client_id IN (SELECT id FROM client WHERE default_na_pro_id = :me.id) AND has_na_pro_signed IS FALSE AND is_entry_error
+        $myId = $this->id;
+        return IncomingReport::whereHas('client',function($clientQuery) use ($myId) {
+            return $clientQuery->where('default_na_pro_id', $myId);
+        })->where('has_na_pro_signed', '<>', true)
+            ->where('is_entry_error','<>', true);
+    }
+    
+    private function supplyOrdersPendingMyAckQueryAsDna(){
+        // WHERE client_id IN (SELECT id FROM client WHERE default_na_pro_id = :me.id) AND has_na_pro_signed IS FALSE AND is_signed_by_pro IS TRUE AND is_cancelled IS NOT TRUE;
+        $myId = $this->id;
+        return SupplyOrder::whereHas('client',function($clientQuery) use ($myId) {
+            return $clientQuery->where('default_na_pro_id', $myId);
+        })->where('has_na_pro_signed', '<>', true)
+            ->where('is_signed_by_pro', true)
+            ->where('is_cancelled', '<>', true);
+    }
+
+    private function supplyOrdersPendingHcpApprovalQueryAsDna(){
+        // WHERE client_id IN (SELECT id FROM client WHERE default_na_pro_id = :me.id) AND has_na_pro_signed IS TRUE AND is_signed_by_pro IS NOT TRUE AND is_cancelled IS NOT TRUE;
+        $myId = $this->id;
+        return SupplyOrder::whereHas('client',function($clientQuery) use ($myId) {
+            return $clientQuery->where('default_na_pro_id', $myId);
+        })->where('has_na_pro_signed', true)
+            ->where('is_signed_by_pro','<>', true)
+            ->where('is_cancelled', '<>', true);
+    }
+
+    //counts
+    public function patientsCountAsDna(){
+        return $this->patientsQueryAsDna()->count();
+    }
+    public function patientsAwaitingMcpVisitCountAsDna(){
+        return $this->patientsAwaitingMcpVisitQueryAsDna()->count();
+    }
+    public function patientsWithoutAppointmentCountAsDna(){
+        return $this->patientsWithoutAppointmentQueryAsDna()->count();
+    }
+    public function encountersPendingMyReviewCountAsDna(){
+        return $this->encountersPendingMyReviewQueryAsDna()->count();
+    }
+    public function encountersInProgressCountAsDna(){
+        return $this->encountersInProgressQueryAsDna()->count();
+    }
+    public function appointmentsPendingConfirmationCountAsDna(){
+        return $this->appointmentsPendingConfirmationQueryAsDna()->count();
+    }
+    public function cancelledAppointmentsPendingAckCountAsDna(){
+        return $this->cancelledAppointmentsPendingAckQueryAsDna()->count();
+    }
+    public function reportsPendingAckCountAsDna(){
+        return $this->reportsPendingAckQueryAsDna()->count();
+    }
+    public function supplyOrdersPendingMyAckCountAsDna(){
+        return $this->supplyOrdersPendingMyAckQueryAsDna()->count();
+    }
+    public function supplyOrdersPendingHcpApprovalCountAsDna(){
+        return $this->supplyOrdersPendingHcpApprovalQueryAsDna()->count();
+    }
+
+    //records
+    private $DNA_RESULTS_PAGE_SIZE = 50;
+
+    public function patientsRecordsAsDna(){
+        return $this->patientsQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
+    }
+    public function patientsAwaitingMcpVisitRecordsAsDna(){
+        return $this->patientsAwaitingMcpVisitQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
+    }
+    public function patientsWithoutAppointmentRecordsAsDna(){
+        return $this->patientsWithoutAppointmentQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
+    }
+    public function encountersPendingMyReviewRecordsAsDna(){
+        return $this->encountersPendingMyReviewQueryAsDna()
+                ->orderBy('effective_dateest', 'desc')
+                ->orderBy('created_at', 'desc')
+                ->paginate($this->DNA_RESULTS_PAGE_SIZE);
+    }
+    public function encountersInProgressRecordsAsDna(){
+        return $this->encountersInProgressQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
+    }
+    public function appointmentsPendingConfirmationRecordsAsDna(){
+        return $this->appointmentsPendingConfirmationQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
+    }
+    public function cancelledAppointmentsPendingAckRecordsAsDna(){
+        return $this->cancelledAppointmentsPendingAckQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
+    }
+    public function reportsPendingAckRecordsAsDna(){
+        return $this->reportsPendingAckQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
+    }
+    public function supplyOrdersPendingMyAckRecordsAsDna(){
+        return $this->supplyOrdersPendingMyAckQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
+    }
+    public function supplyOrdersPendingHcpApprovalRecordsAsDna(){
+        return $this->supplyOrdersPendingHcpApprovalQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
+    }
+
+    public function measurementsPendingReviewAsDna(){
+        //Measurements Pending Review 
+        // SELECT * FROM measurement WHERE client_id IN (SELECT id FROM client WHERE rmm_pro_id = :me.id) 
+        // AND has_been_stamped_by_rmm IS FALSE AND is_cellular IS TRUE AND is_cellular_zero IS NOT TRUE AND is_active IS TRUE ORDER BY ts DESC;
+        $myId = $this->id;
+        return Measurement::whereHas('client',function($clientQuery) use ($myId) {
+                return $clientQuery->where('rmm_pro_id', $myId);
+            })
+            ->where('has_been_stamped_by_rmm', '<>', true)
+            ->where('is_cellular', true)
+            ->where('is_cellular_zero', '<>', true)
+            ->where('is_active', true)
+            ->orderBy('ts', 'DESC')
+            ->paginate(15);
+    }
+
+    public function getProcessingAmountAsDna(){
+        $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' => $this->id])[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' => $this->id])[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' => $this->id])[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' => $this->id])[0]->expected_pay;
+        $totalExpectedAmount =  $expectedForCm + $expectedForRme + $expectedForRmm + $expectedForNa;
+
+        return $totalExpectedAmount;
+    }
+
+    public function getNextPaymentDateAsDna(){
+        $nextPaymentDate = '--';
+        //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);
+            $nextPaymentDate = $nextPaymentDate->format('m/d/Y');
+        } else {
+            $nextPaymentDate = new \DateTime();
+            $lastDayOfMonth = date('t', $today);
+            $nextPaymentDate->setDate($todayYear, $todayMonth, $lastDayOfMonth);
+            $nextPaymentDate = $nextPaymentDate->format('m/d/Y');
+        }
+
+        return $nextPaymentDate;
+    }       
+
+
+    public function clientSmsesAsDna(){
+        $myId = $this->id;
+        return ClientSMS::whereHas('client', function($clientQuery) use ($myId){
+            return $clientQuery->where('default_na_pro_id', $myId);
+        })
+        ->orderBy('created_at', 'DESC')
+        ->paginate(15);
+    }
+
+    public function clientMemosAsDna(){
+        $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 = {$this->id}
+ORDER BY cm.created_at DESC
+            ")
+        );
+
+        return $naClientMemos;
+    }
+
+    public function getAppointmentsPendingStatusChangeAckAsDna() {
+        $myId = $this->id;
+        return Appointment::whereHas('client', function($clientQuery) use ($myId){
+            return $clientQuery->where('default_na_pro_id', $myId);
+        })
+            ->where('is_status_acknowledgement_from_appointment_pro_pending', true)
+            ->where('raw_date', '>=', DB::raw('NOW()'))
+            ->orderBy('raw_date', 'asc')
+            ->get();
+    }
+    public function getAppointmentsPendingDecisionAckAsDna() {
+        $myId = $this->id;
+        return Appointment::whereHas('client', function($clientQuery) use ($myId){
+            return $clientQuery->where('default_na_pro_id', $myId);
+        })
+            ->where('is_decision_acknowledgement_from_appointment_pro_pending', true)
+            ->where('raw_date', '>=', DB::raw('NOW()'))
+            ->orderBy('raw_date', 'asc')
+            ->get();
+    }
+    public function getAppointmentsPendingTimeChangeAckAsDna() {
+        $myId = $this->id;
+        return Appointment::whereHas('client', function($clientQuery) use ($myId){
+            return $clientQuery->where('default_na_pro_id', $myId);
+        })
+            ->where('is_time_change_acknowledgement_from_appointment_pro_pending', true)
+            ->where('raw_date', '>=', DB::raw('NOW()'))
+            ->orderBy('raw_date', 'asc')
+            ->get();
+    }
+
+
 }

+ 106 - 121
resources/views/app/dashboard-dna.blade.php

@@ -33,97 +33,71 @@
                         <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_dna()}}</th>
-                                    <th class="pl-2">
-                                        <a href="{{ route('dna.patients') }}">Patients</a>
-                                    </th>
-                                </tr>
-                                <tr>
-                                    <th class="px-2 text-center">{{$pro->get_new_patients_awaiting_visit_count_as_dna()}}</th>
-                                    <th class="pl-2">
-                                        <a href="{{ route('dna.new_patients_awaiting_visit') }}"
-                                           native target="_blank"
-                                           open-in-stag-popup
-                                           popup-style="tall"
-                                           title="New Patients Awaiting Visit">
-                                            New Patients Awaiting Visit
-                                        </a>
-                                    </th>
-                                </tr>
-                                <tr>
-                                    <th class="px-2 text-center">{{$pro->get_notes_pending_signature_count_as_dna()}}</th>
-                                    <th class="pl-2">
-                                        <a href="{{ route('dna.notes_pending_signature') }}"
-                                           native target="_blank"
-                                           open-in-stag-popup
-                                           popup-style="tall"
-                                           title="Notes Pending Signature">
-                                            Notes Pending Signature
-                                        </a>
-                                    </th>
-                                </tr>
-
-                                <tr>
-                                    <th class="px-2 text-center">{{$pro->get_patients_without_appointment_count_as_dna()}}</th>
-                                    <th class="pl-2">
-                                        <a href="{{ route('dna.patients_without_appointments') }}"
-                                           native target="_blank"
-                                           open-in-stag-popup
-                                           popup-style="tall"
-                                           title="Patients w/o Appointments">
-                                            Patients w/o Appointments
-                                        </a>
-                                    </th>
-                                </tr>
-                                <tr>
-                                    <th class="px-2 text-center">{{$pro->get_patients_overdue_count_as_dna()}}</th>
-                                    <th class="pl-2">
-                                        <a href="{{ route('dna.patients_overdue_for_visit') }}"
-                                           native target="_blank"
-                                           open-in-stag-popup
-                                           popup-style="tall"
-                                           title="Patients Overdue for Visit">
-                                            Patients Overdue for Visit
-                                        </a>
-                                    </th>
-                                </tr>
-
-                                <tr>
-                                    <th class="px-2 text-center">{{$pro->get_cancelled_bills_awaiting_review_count_as_dna()}}</th>
-                                    <th class="pl-2">
-                                        <a href="{{ route('dna.cancelled_bills_pending_review') }}"
-                                           native target="_blank"
-                                           open-in-stag-popup
-                                           popup-style="tall"
-                                           title="Cancelled Bills Pending Review">
-                                            Cancelled Bills Pending Review
-                                        </a>
-                                    </th>
-                                </tr>
-
-                                </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_patients_without_remote_measurement_in_48_hours_count_as_dna() ?? '-'}}</th>
-                                    <th class="pl-2">Patients w/o Measurement in 48 hrs.</th>
-                                </tr>
+                                    <tr>
+                                        <th class="px-2 text-center">{{$pro->patientsCountAsDna()}}<th>  
+                                        <th class="pl-2">
+                                            <a href="{{route('dna.my-patients')}}" native target="_blank" open-in-stag-popup popup-style="tall" title="Patients ">Patients </a>
+                                        </th>
+                                    </tr>
+                                    <tr>
+                                        <th class="px-2 text-center">{{$pro->patientsAwaitingMcpVisitCountAsDna()}}<th>
+                                        <th class="pl-2">
+                                            <a href="{{route('dna.patients_awaiting_mcp_visit')}}" native target="_blank" open-in-stag-popup popup-style="tall" title="Patients Awaiting MCP Visit">Patients Awaiting MCP Visit</a>
+                                        </th>
+                                    </tr>
+                                    <tr>
+                                        <th class="px-2 text-center">{{$pro->patientsWithoutAppointmentCountAsDna()}}<th>
+                                        <th class="pl-2">
+                                            <a href="{{route('dna.patients_without_appointment')}}" native target="_blank" open-in-stag-popup popup-style="tall" title="Patients w/o Appointment ">Patients w/o Appointment </a>
+                                        </th>
+                                    </tr>
+                                    <tr>
+                                        <th class="px-2 text-center">{{$pro->encountersPendingMyReviewCountAsDna()}}<th>
+                                        <th class="pl-2">
+                                            <a href="{{route('dna.encounters_pending_my_review')}}" native target="_blank" open-in-stag-popup popup-style="tall" title="Encounters Pending My Review ">Encounters Pending My Review </a>
+                                        </th>
+                                    </tr>
+                                    <tr>
+                                        <th class="px-2 text-center">{{$pro->encountersInProgressCountAsDna()}}<th>
+                                        <th class="pl-2">
+                                            <a href="{{route('dna.encounters_in_progress')}}" native target="_blank" open-in-stag-popup popup-style="tall" title="Encounters In Progress">Encounters In Progress</a>
+                                        </th>
+                                    </tr>
+                                    <tr>
+                                        <th class="px-2 text-center">{{$pro->appointmentsPendingConfirmationCountAsDna()}}<th>
+                                        <th class="pl-2">
+                                            <a href="{{route('dna.appointments_pending_confirmation')}}" native target="_blank" open-in-stag-popup popup-style="tall" title="Appointments Pending Confirmation">Appointments Pending Confirmation</a>
+                                        </th>
+                                    </tr>
+                                    <tr>
+                                        <th class="px-2 text-center">{{$pro->cancelledAppointmentsPendingAckCountAsDna()}}<th>
+                                        <th class="pl-2">
+                                            <a href="{{route('dna.cancelled_appointments_pending_ack')}}" native target="_blank" open-in-stag-popup popup-style="tall" title="Cancelled Appointments Pending Ack.">Cancelled Appointments Pending Ack.</a>
+                                        </th>
+                                    </tr>
+                                    <tr>
+                                        <th class="px-2 text-center">{{$pro->reportsPendingAckCountAsDna()}}<th>
+                                        <th class="pl-2">
+                                            <a href="{{route('dna.reports_pending_ack')}}" native target="_blank" open-in-stag-popup popup-style="tall" title="Reports Pending Ack.">Reports Pending Ack.</a>
+                                        </th>
+                                    </tr>
+                                    <tr>
+                                        <th class="px-2 text-center">{{$pro->supplyOrdersPendingMyAckCountAsDna()}}<th>
+                                        <th class="pl-2">
+                                            <a href="{{route('dna.supply_orders_pending_my_ack')}}" native target="_blank" open-in-stag-popup popup-style="tall" title="Supply Orders Pending My Ack.">Supply Orders Pending My Ack.</a>
+                                        </th>
+                                    </tr>
+                                    <tr>
+                                        <th class="px-2 text-center">{{$pro->supplyOrdersPendingHcpApprovalCountAsDna()}}<th>
+                                        <th class="pl-2">
+                                            <a href="{{route('dna.supply_orders_pending_hcp_approval')}}" native target="_blank" open-in-stag-popup popup-style="tall" title="Supply Orders Pending HCP Approval">Supply Orders Pending HCP Approval</a>
+                                        </th>
+                                    </tr>
                                 </tbody>
                             </table>
                         </div>
                     </div>
+                    
                     <div class="card mb-4">
                         <div class="card-header pl-2">
                             <strong>
@@ -137,52 +111,23 @@
                                     <th colspan="2" class="font-weight-normal px-2 pl-2">Billing & Reimbursement</th>
                                 </tr>
                                 <tr class="thin">
-                                    <th class="font-weight-normal px-2 pl-4">{{friendly_date_time($reimbursement['nextPaymentDate'], false)}}</th>
+                                    <th class="font-weight-normal px-2 pl-4">{{friendly_date_time($performer->pro->getNextPaymentDateAsDna(), 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>
+                                        ${{friendly_money($performer->pro->balance)}}</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>
+                                        ${{friendly_money($performer->pro->getProcessingAmountAsDna())}}</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>
@@ -191,9 +136,12 @@
                 <div class="col-md-9">
                     <div class="row mcp-theme-1">
                         <div class="col-md-6 mcp-theme-1">
+                            <!-- APPOINTMENTS -->
                             <div id="dna-dashboard-appointments" class="mb-4">
 
                             </div>
+
+                            <!-- MEASUREMENTS -->
                             <div class="card mb-4">
                                 <div class="card-header pl-2">
                                     <strong>
@@ -204,6 +152,43 @@
                                     @include('app.dna.dashboard.measurements-pending-stamping')
                                 </div>
                             </div>
+
+                            <!-- ENCOUNTERS PENDING MY REVIEW -->
+                            <div class="card mb-4">
+                                <div class="card-header pl-2">
+                                    <strong>
+                                        Encounters Pending My Review
+                                    </strong>
+                                </div>
+                                <div class="card-body p-0">
+                                    @include('app.dna.dashboard.encounters_pending_my_review')
+                                </div>
+                            </div>
+
+                            <!-- ENCOUNTERS IN PROGRESS -->
+                            <div class="card mb-4">
+                                <div class="card-header pl-2">
+                                    <strong>
+                                        Encounters In Progress
+                                    </strong>
+                                </div>
+                                <div class="card-body p-0">
+                                    @include('app.dna.dashboard.encounters_in_progress')
+                                </div>
+                            </div>
+
+                            <!-- PATIENTS WITHOUT APPOINTMENTS -->
+                            <div class="card mb-4">
+                                <div class="card-header pl-2">
+                                    <strong>
+                                        Patients Without Appointments
+                                    </strong>
+                                </div>
+                                <div class="card-body p-0">
+                                    @include('app.dna.dashboard.patients_without_appointment')
+                                </div>
+                            </div>
+
                         </div>
                         <div class="col-md-6 mcp-theme-1">
                             <div class="card mb-4">

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

@@ -0,0 +1,118 @@
+@php 
+    $appointmentPendingConfirmation = $performer->pro->appointmentsPendingConfirmationRecordsAsDna();
+@endphp 
+<div class="card">
+    <div class="card-body p-0">
+        @if(@$appointmentPendingConfirmation && count($appointmentPendingConfirmation))
+            <table class="mb-0 table table-sm appointments border-top-0">
+                @foreach($appointmentPendingConfirmation as $appointment)
+                    <tr class="{{$appointment->bgColor}}">
+                        <td>
+                            <a href="/patients/view/{{$appointment->clientUid}}" class="font-weight-bold d-block">
+                                {{$appointment->client->name_first }} {{$appointment->client->name_last }}
+                            </a>
+                            <div class="mt-1">
+                                <a href="/patients/view/{{$appointment->clientUid}}/calendar/{{$appointment->uid}}">
+                                    {{ friendly_date_time($appointment->start_time) }} - {{ friendly_date_time($appointment->end_time) }}</a>
+                                <span class="text-secondary">{{ friendly_timezone($appointment->timezone) }}</span>
+                            </div>
+                            @if($appointment->title)
+                                <span class="d-inline-block mt-1 text-secondary text-sm">
+                            {{ $appointment->title }}
+                        </span>
+                            @endif
+                        </td>
+                        <td>
+                            <div class="d-flex flex-column">
+                                <div class="d-flex align-items-baseline flex-nowrap">
+                                    @if($appointment->status === 'PENDING')
+                                        <div class="text-warning-mellow font-weight-bold text-nowrap">
+                                            <i class="fa fa-exclamation-triangle"></i>
+                                            Pending
+                                        </div>
+                                    @elseif($appointment->status === 'CONFIRMED')
+                                        <div class="text-success font-weight-bold text-nowrap">
+                                            <i class="fa fa-check"></i>
+                                            Confirmed
+                                        </div>
+                                    @elseif($appointment->status === 'CANCELLED')
+                                        <div class="text-danger font-weight-bold text-nowrap">
+                                            <i class="fa fa-stop"></i>
+                                            Cancelled
+                                        </div>
+                                    @elseif($appointment->status === 'COMPLETED')
+                                        <div class="text-success font-weight-bold text-nowrap">
+                                            <i class="far fa-calendar-check"></i>
+                                            Completed
+                                        </div>
+                                    @endif
+                                    <div class="ml-2" moe relative center>
+                                        <a href="#" start show><i class="fa fa-edit"></i></a>
+                                        <form url="/api/appointment/updateStatus" hook="refreshDashboardAppointments" center>
+                                            <input type="hidden" name="uid" value="{{$appointment->uid}}">
+                                            <p class="text-nowrap mb-3 font-weight-bold text-secondary">Change appointment status</p>
+                                            <div class="mb-3 border bg-light p-2">
+                                                <div class="d-flex align-items-baseline mb-1">
+                                                    <span class="width-70px">Patient</span>
+                                                    <b>{{$appointment->clientName }}</b>
+                                                </div>
+                                                <div class="d-flex align-items-baseline mb-1">
+                                                    <span class="width-70px">Pro</span>
+                                                    <b>{{$appointment->proName}}</b>
+                                                </div>
+                                                <div class="d-flex align-items-baseline mb-1">
+                                                    <span class="width-70px">Date</span>
+                                                    <b>{{friendly_date($appointment->raw_date)}}</b>
+                                                </div>
+                                                <div class="d-flex align-items-baseline mb-1">
+                                                    <span class="width-70px">Time</span>
+                                                    <span>
+                                                        <b>{{ $appointment->friendlyStartTime }}</b> - <b>{{ $appointment->friendlyEndTime }}</b>
+                                                        <span class="text-secondary">{{ friendly_timezone($appointment->timezone) }}</span>
+                                                    </span>
+                                                </div>
+                                                <div class="d-flex align-items-baseline ">
+                                                    <span class="width-70px">Status</span>
+                                                    <b>{{ucwords(strtolower($appointment->status))}}</b>
+                                                </div>
+                                            </div>
+                                            <label for="" class="mb-2">New Status</label>
+                                            <select name="status" class="form-control form-control-sm input-sm bg-light mb-2">
+                                                <option value="PENDING" {{$appointment->status === 'PENDING' ? 'selected' : ''}}>PENDING</option>
+                                                <option value="CONFIRMED" {{$appointment->status === 'CONFIRMED' ? 'selected' : ''}}>CONFIRMED</option>
+                                                <option value="CANCELLED" {{$appointment->status === 'CANCELLED' ? 'selected' : ''}}>CANCELLED</option>
+                                                <option value="COMPLETED" {{$appointment->status === 'COMPLETED' ? 'selected' : ''}}>COMPLETED</option>
+                                            </select>
+                                            <div class="mb-0">
+                                                <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                            </div>
+                                        </form>
+                                    </div>
+                                </div>
+                                
+                            </div>
+                        </td>
+                        <td>
+                            <div>
+                                @if($appointment->coverage === 'YES')
+                                    <b class="text-success">Covered</b>
+                                @elseif($appointment->coverage === 'NO')
+                                    <b class="text-danger">Not Covered</b>
+                                @else
+                                    <b v-else class="text-warning-mellow">Pending</b>
+                                @endif
+                            </div>
+                        </td>
+                    </tr>
+                @endforeach
+            </table>
+        @else
+            <div class="bg-light p-3 text-secondary">
+                <span>You have no appointments pending confirmation.</span>
+            </div>
+            
+        @endif
+    </div>
+</div>
+

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

@@ -1 +1,39 @@
-<h1>Phone Calls & Memos</h1>
+@php 
+ $clientMemos = $performer->pro->clientMemosAsDna();
+@endphp 
+<div id="mcp-phone-calls-memos">
+@if(!$clientMemos || !count($clientMemos))
+<div class="px-2 py-3">No memos</div>
+@else
+<table class="table table-sm m-0">
+	<tbody>
+		@foreach($clientMemos as $memo)
+		<tr>
+			<td class="px-1">
+				<a href="{{route('patients.view.dashboard', $memo->client_uid)}}">
+					{{$memo->name_first}} {{$memo->name_last}}
+				</a>
+				<a class="text-sm text-nowrap d-block"
+				   href="/memos-thread/{{$memo->client_uid}}"
+				   native target="_blank"
+				   open-in-stag-popup
+				   popup-style="tall"
+				   title="Memos for {{$memo->name_first}} {{$memo->name_last}}">
+					{{friendlier_date_time($memo->created_at)}}
+				</a>
+			</td>
+			<td class="px-1 w-75 text-left">
+				{{$memo->content}}
+			</td>
+		
+		</tr>
+		@endforeach
+	</tbody>
+</table>
+@if(count($clientMemos) > 10)
+	<div class="p-2 border-top bg-light text-center">
+		Showing 1 to 10 of {{count($clientMemos)}} memos
+	</div>
+@endif
+@endif
+</div>

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

@@ -0,0 +1,118 @@
+@php 
+    $cancelledApptsPendingAck = $performer->pro->cancelledAppointmentsPendingAckRecordsAsDna();
+@endphp 
+<div class="card">
+    <div class="card-body p-0">
+        @if(@$cancelledApptsPendingAck && count($cancelledApptsPendingAck))
+            <table class="mb-0 table table-sm appointments border-top-0">
+                @foreach($cancelledApptsPendingAck as $appointment)
+                    <tr class="{{$appointment->bgColor}}">
+                        <td>
+                            <a href="/patients/view/{{$appointment->clientUid}}" class="font-weight-bold d-block">
+                                {{$appointment->client->name_first }} {{$appointment->client->name_last }}
+                            </a>
+                            <div class="mt-1">
+                                <a href="/patients/view/{{$appointment->clientUid}}/calendar/{{$appointment->uid}}">
+                                    {{ friendly_date_time($appointment->start_time) }} - {{ friendly_date_time($appointment->end_time) }}</a>
+                                <span class="text-secondary">{{ friendly_timezone($appointment->timezone) }}</span>
+                            </div>
+                            @if($appointment->title)
+                                <span class="d-inline-block mt-1 text-secondary text-sm">
+                            {{ $appointment->title }}
+                        </span>
+                            @endif
+                        </td>
+                        <td>
+                            <div class="d-flex flex-column">
+                                <div class="d-flex align-items-baseline flex-nowrap">
+                                    @if($appointment->status === 'PENDING')
+                                        <div class="text-warning-mellow font-weight-bold text-nowrap">
+                                            <i class="fa fa-exclamation-triangle"></i>
+                                            Pending
+                                        </div>
+                                    @elseif($appointment->status === 'CONFIRMED')
+                                        <div class="text-success font-weight-bold text-nowrap">
+                                            <i class="fa fa-check"></i>
+                                            Confirmed
+                                        </div>
+                                    @elseif($appointment->status === 'CANCELLED')
+                                        <div class="text-danger font-weight-bold text-nowrap">
+                                            <i class="fa fa-stop"></i>
+                                            Cancelled
+                                        </div>
+                                    @elseif($appointment->status === 'COMPLETED')
+                                        <div class="text-success font-weight-bold text-nowrap">
+                                            <i class="far fa-calendar-check"></i>
+                                            Completed
+                                        </div>
+                                    @endif
+                                    <div class="ml-2" moe relative center>
+                                        <a href="#" start show><i class="fa fa-edit"></i></a>
+                                        <form url="/api/appointment/updateStatus" hook="refreshDashboardAppointments" center>
+                                            <input type="hidden" name="uid" value="{{$appointment->uid}}">
+                                            <p class="text-nowrap mb-3 font-weight-bold text-secondary">Change appointment status</p>
+                                            <div class="mb-3 border bg-light p-2">
+                                                <div class="d-flex align-items-baseline mb-1">
+                                                    <span class="width-70px">Patient</span>
+                                                    <b>{{$appointment->clientName }}</b>
+                                                </div>
+                                                <div class="d-flex align-items-baseline mb-1">
+                                                    <span class="width-70px">Pro</span>
+                                                    <b>{{$appointment->proName}}</b>
+                                                </div>
+                                                <div class="d-flex align-items-baseline mb-1">
+                                                    <span class="width-70px">Date</span>
+                                                    <b>{{friendly_date($appointment->raw_date)}}</b>
+                                                </div>
+                                                <div class="d-flex align-items-baseline mb-1">
+                                                    <span class="width-70px">Time</span>
+                                                    <span>
+                                                        <b>{{ $appointment->friendlyStartTime }}</b> - <b>{{ $appointment->friendlyEndTime }}</b>
+                                                        <span class="text-secondary">{{ friendly_timezone($appointment->timezone) }}</span>
+                                                    </span>
+                                                </div>
+                                                <div class="d-flex align-items-baseline ">
+                                                    <span class="width-70px">Status</span>
+                                                    <b>{{ucwords(strtolower($appointment->status))}}</b>
+                                                </div>
+                                            </div>
+                                            <label for="" class="mb-2">New Status</label>
+                                            <select name="status" class="form-control form-control-sm input-sm bg-light mb-2">
+                                                <option value="PENDING" {{$appointment->status === 'PENDING' ? 'selected' : ''}}>PENDING</option>
+                                                <option value="CONFIRMED" {{$appointment->status === 'CONFIRMED' ? 'selected' : ''}}>CONFIRMED</option>
+                                                <option value="CANCELLED" {{$appointment->status === 'CANCELLED' ? 'selected' : ''}}>CANCELLED</option>
+                                                <option value="COMPLETED" {{$appointment->status === 'COMPLETED' ? 'selected' : ''}}>COMPLETED</option>
+                                            </select>
+                                            <div class="mb-0">
+                                                <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                            </div>
+                                        </form>
+                                    </div>
+                                </div>
+                                
+                            </div>
+                        </td>
+                        <td>
+                            <div>
+                                @if($appointment->coverage === 'YES')
+                                    <b class="text-success">Covered</b>
+                                @elseif($appointment->coverage === 'NO')
+                                    <b class="text-danger">Not Covered</b>
+                                @else
+                                    <b v-else class="text-warning-mellow">Pending</b>
+                                @endif
+                            </div>
+                        </td>
+                    </tr>
+                @endforeach
+            </table>
+        @else
+            <div class="bg-light p-3 text-secondary">
+                <span>You have no cancelled appointments.</span>
+            </div>
+            
+        @endif
+    </div>
+</div>
+

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

@@ -0,0 +1,13 @@
+<?php $coverageStatus = $patient->getPrimaryCoverageStatus(); ?>
+@if($coverageStatus === 'YES')
+    <div class="text-nowrap">Covered <i class="fa fa-check-circle text-success"></i>
+    </div>
+@elseif($coverageStatus === 'NO')
+    <div class="text-nowrap">Not Covered <i class="fa fa-times text-danger"></i></div>
+@else
+    <div class="text-nowrap">Unknown <i class="fa fa-exclamation-triangle text-warning-mellow"></i></div>
+@endif
+<?php $coverage = $patient->getPrimaryCoverage(); ?>
+@if($coverage)
+    {{$coverage->insuranceDisplayName()}}
+@endif

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

@@ -0,0 +1,56 @@
+<div>
+@php 
+    $encountersInProgress = $performer->pro->encountersInProgressRecordsAsDna();
+@endphp 
+@if($encountersInProgress && count($encountersInProgress))
+    <table class="table table-sm table-striped mb-0">
+        <thead>
+        <tr>
+            <th class="border-bottom-0 border-top-0 text-secondary">Chart #</th>
+            <th class="border-bottom-0 border-top-0 text-secondary">Name</th>
+            <th class="border-bottom-0 border-top-0 text-secondary">DOB</th>
+            <th class="border-bottom-0 border-top-0 text-secondary">Gender</th>
+            <th class="border-bottom-0 border-top-0 text-secondary">Insurance</th>
+            <th class="border-bottom-0 border-top-0 text-secondary">HCP</th>
+            <th class="border-bottom-0 border-top-0 text-secondary">Visit Date</th>
+        </tr>
+        </thead>
+        <tbody>
+        @foreach($encountersInProgress as $row)
+            <tr>
+                <td class="text-nowrap">
+                    {{$row->client->chart_number}}
+                </td>
+                <td class="pl-2">
+                    <a href="{{ route('patients.view.dashboard', $row->client) }}">
+                        {{$row->client->displayName()}}
+                    </a>
+                </td>
+                <td class="text-nowrap">
+                    {{friendly_date($row->client->dob)}}
+                </td>
+                <td class="text-nowrap">
+                    {{$row->client->sex}}
+                </td>
+                <td class="text-nowrap">
+                    @include('app.dna.dashboard.coverage_renderer', ['patient'=>$row->client])
+                </td>
+                <td class="text-nowrap">
+                    {{$row->client->mcp->name_display ?? '' }}
+                </td>
+                <td class="text-nowrap">
+                    {{friendly_date($row->effective_dateest)}}
+                </td>
+            </tr>
+        @endforeach
+        </tbody>
+    </table>
+    <div class="m-2">
+        {{ $encountersInProgress->onEachSide(0)->withQueryString()->links() }}
+    </div>
+@else
+    <div class="p-3">
+        No encounters in progress
+    </div>
+@endif
+</div>

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

@@ -0,0 +1,53 @@
+<div>
+@php 
+    $encountersPendingMyReview = $performer->pro->encountersPendingMyReviewRecordsAsDna();
+@endphp 
+@if($encountersPendingMyReview && count($encountersPendingMyReview))
+    <table class="table table-sm table-striped mb-0">
+        <thead>
+        <tr>
+            <th class="border-bottom-0 border-top-0 text-secondary">Patient</th>
+            <th class="border-bottom-0 border-top-0 text-secondary">Type</th>
+            <th class="border-bottom-0 border-top-0 text-secondary">Value</th>
+            <th class="border-bottom-0 border-top-0 text-secondary">Timestamp</th>
+        </tr>
+        </thead>
+        <tbody>
+        @foreach($encountersPendingMyReview as $row)
+        <tr>
+                <td class="text-nowrap">
+                    {{$row->client->chart_number}}
+                </td>
+                <td class="pl-2">
+                    <a href="{{ route('patients.view.dashboard', $row->client) }}">
+                        {{$row->client->displayName()}}
+                    </a>
+                </td>
+                <td class="text-nowrap">
+                    {{friendly_date($row->client->dob)}}
+                </td>
+                <td class="text-nowrap">
+                    {{$row->client->sex}}
+                </td>
+                <td class="text-nowrap">
+                    @include('app.dna.dashboard.coverage_renderer', ['patient'=>$row->client])
+                </td>
+                <td class="text-nowrap">
+                    {{$row->client->mcp->name_display ?? '' }}
+                </td>
+                <td class="text-nowrap">
+                    {{friendly_date($row->effective_dateest)}}
+                </td>
+            </tr>
+        @endforeach
+        </tbody>
+    </table>
+    <div class="m-2">
+        {{ $encountersPendingMyReview->onEachSide(0)->withQueryString()->links() }}
+    </div>
+@else
+    <div class="p-3">
+        No encounters pending review
+    </div>
+@endif
+</div>

+ 7 - 16
resources/views/app/dna/dashboard/measurements-pending-stamping.blade.php

@@ -1,34 +1,25 @@
 <div id="dashboard-measurements-pending-stamping">
-@if($measurementsPendingStamping && count($measurementsPendingStamping))
+@php 
+    $measurementsPendingReviewAsDna = $performer->pro->measurementsPendingReviewAsDna();
+@endphp 
+@if($measurementsPendingReviewAsDna && count($measurementsPendingReviewAsDna))
     <table class="table table-sm table-striped mb-0">
         <thead>
         <tr>
             <th class="border-bottom-0 border-top-0 text-secondary">Patient</th>
-            <th class="border-bottom-0 border-top-0 text-secondary">Care Month</th>
             <th class="border-bottom-0 border-top-0 text-secondary">Type</th>
             <th class="border-bottom-0 border-top-0 text-secondary">Value</th>
             <th class="border-bottom-0 border-top-0 text-secondary">Timestamp</th>
         </tr>
         </thead>
         <tbody>
-        @foreach($measurementsPendingStamping as $row)
+        @foreach($measurementsPendingReviewAsDna as $row)
             <tr>
                 <td class="pl-2">
                     <a href="{{ route('patients.view.dashboard', $row->client) }}">
                         {{$row->client->displayName()}}
                     </a>
                 </td>
-                <td>
-                    <a native target="_blank"
-                       open-in-stag-popup
-                       update-parent
-                       update-target="#dashboard-measurements-pending-stamping"
-                       mc-initer="cm-matrix-{{$row->client->id}}"
-                       title="Care Month Matrix: {{date('M Y', strtotime($row->careMonth->start_date))}}"
-                       href="/patient-care-month-matrix/{{$row->careMonth->uid}}">
-                        {{ friendly_month($row->careMonth->start_date) }}
-                    </a>
-                </td>
                 <td class="text-nowrap">
                     {{$row->label}}
                 </td>
@@ -47,11 +38,11 @@
         </tbody>
     </table>
     <div class="m-2">
-        {{ $measurementsPendingStamping->onEachSide(0)->withQueryString()->links() }}
+        {{ $measurementsPendingReviewAsDna->onEachSide(0)->withQueryString()->links() }}
     </div>
 @else
     <div class="p-3">
-        No measurement pending stamping
+        No measurement pending review
     </div>
 @endif
 </div>

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

@@ -1 +1,36 @@
-<h1>Messages</h1>
+@php 
+$clientSmses = $performer->pro->clientSmsesAsDna();
+@endphp 
+
+@if(!$clientSmses || !count($clientSmses))
+    <div class="px-2 py-3">No messages</div>
+@else
+    <table class="table table-sm m-0">
+        <tbody>
+        @foreach($clientSmses as $msg)
+            <tr>
+                <td class="px-1">
+                    <a href="{{route('patients.view.sms', $msg->client->uid)}}">
+                        {{$msg->client->name_first}} {{$msg->client->name_last}}
+                    </a>
+                    <a class="text-sm text-nowrap d-block"
+                       href="/messages-thread/{{$msg->client->uid}}"
+                       native target="_blank"
+                       open-in-stag-popup
+                       popup-style="tall"
+                       title="Messages for {{$msg->client->name_first}} {{$msg->client->name_last}}">
+                        {{friendlier_date_time($msg->created_at)}}
+                    </a>
+                </td>
+                <td class="px-1 w-75 text-left">
+                    {{$msg->body}}
+                </td>
+               
+            </tr>
+        @endforeach
+        </tbody>
+    </table>
+    <div class="p-2 border-top bg-light text-center">
+        {{$clientSmses->links()}}
+    </div>
+@endif

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

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

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

@@ -0,0 +1,53 @@
+<div>
+@php 
+    $patientsRecordsAsDna = $performer->pro->patientsRecordsAsDna();
+@endphp 
+@if($patientsRecordsAsDna && count($patientsRecordsAsDna))
+    <table class="table table-sm table-striped mb-0">
+        <thead>
+        <tr>
+            <th class="border-bottom-0 border-top-0 text-secondary">Chart #</th>
+            <th class="border-bottom-0 border-top-0 text-secondary">Name</th>
+            <th class="border-bottom-0 border-top-0 text-secondary">DOB</th>
+            <th class="border-bottom-0 border-top-0 text-secondary">Gender</th>
+            <th class="border-bottom-0 border-top-0 text-secondary">Insurance</th>
+            <th class="border-bottom-0 border-top-0 text-secondary">HCP</th>
+        </tr>
+        </thead>
+        <tbody>
+        @foreach($patientsRecordsAsDna as $row)
+            <tr>
+                <td class="text-nowrap">
+                    {{$row->chart_number}}
+                </td>
+                <td class="pl-2">
+                    <a href="{{ route('patients.view.dashboard', $row) }}">
+                        {{$row->displayName()}}
+                    </a>
+                </td>
+                <td class="text-nowrap">
+                    {{friendly_date($row->dob)}}
+                </td>
+                <td class="text-nowrap">
+                    {{$row->sex}}
+                </td>
+                <td class="text-nowrap">
+                    @include('app.dna.dashboard.coverage_renderer', ['patient'=>$row])
+                </td>
+                <td class="text-nowrap">
+                    {{$row->mcp->name_display ?? '' }}
+                </td>
+               
+            </tr>
+        @endforeach
+        </tbody>
+    </table>
+    <div class="m-2">
+        {{ $patientsRecordsAsDna->onEachSide(0)->withQueryString()->links() }}
+    </div>
+@else
+    <div class="p-3">
+        No patients
+    </div>
+@endif
+</div>

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

@@ -0,0 +1,53 @@
+<div>
+@php 
+    $patientsAwaitingMcpVisit = $performer->pro->patientsAwaitingMcpVisitRecordsAsDna();
+@endphp 
+@if($patientsAwaitingMcpVisit && count($patientsAwaitingMcpVisit))
+    <table class="table table-sm table-striped mb-0">
+        <thead>
+        <tr>
+            <th class="border-bottom-0 border-top-0 text-secondary">Chart #</th>
+            <th class="border-bottom-0 border-top-0 text-secondary">Name</th>
+            <th class="border-bottom-0 border-top-0 text-secondary">DOB</th>
+            <th class="border-bottom-0 border-top-0 text-secondary">Gender</th>
+            <th class="border-bottom-0 border-top-0 text-secondary">Insurance</th>
+            <th class="border-bottom-0 border-top-0 text-secondary">HCP</th>
+        </tr>
+        </thead>
+        <tbody>
+        @foreach($patientsAwaitingMcpVisit as $row)
+            <tr>
+                <td class="text-nowrap">
+                    {{$row->chart_number}}
+                </td>
+                <td class="pl-2">
+                    <a href="{{ route('patients.view.dashboard', $row) }}">
+                        {{$row->displayName()}}
+                    </a>
+                </td>
+                <td class="text-nowrap">
+                    {{friendly_date($row->dob)}}
+                </td>
+                <td class="text-nowrap">
+                    {{$row->sex}}
+                </td>
+                <td class="text-nowrap">
+                    @include('app.dna.dashboard.coverage_renderer', ['patient'=>$row])
+                </td>
+                <td class="text-nowrap">
+                    {{$row->mcp->name_display ?? '' }}
+                </td>
+               
+            </tr>
+        @endforeach
+        </tbody>
+    </table>
+    <div class="m-2">
+        {{ $patientsAwaitingMcpVisit->onEachSide(0)->withQueryString()->links() }}
+    </div>
+@else
+    <div class="p-3">
+        No patients awaiting mcp visit
+    </div>
+@endif
+</div>

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

@@ -0,0 +1,53 @@
+<div>
+@php 
+    $patientsWithoutAppointments = $performer->pro->patientsWithoutAppointmentRecordsAsDna();
+@endphp 
+@if($patientsWithoutAppointments && count($patientsWithoutAppointments))
+    <table class="table table-sm table-striped mb-0">
+        <thead>
+        <tr>
+            <th class="border-bottom-0 border-top-0 text-secondary">Patient</th>
+            <th class="border-bottom-0 border-top-0 text-secondary">Type</th>
+            <th class="border-bottom-0 border-top-0 text-secondary">Value</th>
+            <th class="border-bottom-0 border-top-0 text-secondary">Timestamp</th>
+        </tr>
+        </thead>
+        <tbody>
+        @foreach($patientsWithoutAppointments as $row)
+            <tr>
+                <td class="text-nowrap">
+                    {{$row->chart_number}}
+                </td>
+                <td class="pl-2">
+                    <a href="{{ route('patients.view.dashboard', $row) }}">
+                        {{$row->displayName()}}
+                    </a>
+                </td>
+                <td class="text-nowrap">
+                    {{friendly_date($row->dob)}}
+                </td>
+                <td class="text-nowrap">
+                    {{$row->sex}}
+                </td>
+                <td class="text-nowrap">
+                    @include('app.dna.dashboard.coverage_renderer', ['patient'=>$row])
+                </td>
+                <td class="text-nowrap">
+                    {{$row->mcp->name_display ?? '' }}
+                </td>
+                <td class="text-nowrap">
+                    {{friendly_date($row->most_recent_completed_mcp_note_date)}}
+                </td>
+            </tr>
+        @endforeach
+        </tbody>
+    </table>
+    <div class="m-2">
+        {{ $patientsWithoutAppointments->onEachSide(0)->withQueryString()->links() }}
+    </div>
+@else
+    <div class="p-3">
+        No patients without appointments
+    </div>
+@endif
+</div>

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

@@ -0,0 +1,69 @@
+@php 
+    $reportsPendingAck = $performer->pro->reportsPendingAckRecordsAsDna();
+@endphp 
+<div class="p-3 mcp-theme-1" id="patients-list">
+    <div class="card">
+
+        <div class="card-header px-3 py-2 d-flex align-items-center">
+            <strong class="mr-4">
+                <i class="fas fa-file-invoice-dollar"></i>
+                Reports Pending Acknowledgement
+            </strong>
+        </div>
+
+        <div class="card-body p-0">
+            
+            <table class="table table-condensed p-0 m-0">
+                <thead class="bg-light">
+                    <tr>
+                        <th class="px-3 border-0">Patient</th>
+                        <th class="px-3 border-0">Title</th>
+                        <th class="px-3 border-0">Category</th>
+                        <th class="px-3 border-0">Report Date</th>
+                        <th class="px-3 border-0">Sign</th>
+                    </tr>
+                </thead>
+                <tbody>
+                    @foreach($reportsPendingAck as $report)
+                    <tr class="{{$report->is_entry_error ? 'entry-error' : ''}}">
+                        <td class="border-bottom-0">{{$report->client->displayName()}}</td>
+                        <td>
+                            <a native target="_blank" href="{{route('patients.view.incoming-reports', ['patient' => $report->client, 'currentReport' => $report])}}" class="{{@$currentReport->uid === $report->uid ? 'font-weight-bold' : ''}}">
+                                {{ $report->title ? $report->title : '(not set)' }}
+                            </a>
+                        </td>
+                        <td>{{ $report->category }}{{ $report->subcategory ? ' / ' . $report->subcategory : '' }}</td>
+                        <td>{{ friendly_date_time($report->report_date, false) }}</td>
+                        <td>
+                            @if(!$report->has_hcp_pro_signed)
+                            -
+                            @else
+                            <div class="text-success mb-1">
+                                <i class="fa fa-check"></i>
+                                Signed
+                            </div>
+                            @if($report->hcp)
+                            <div class="text-secondary">
+                                <div class="text-sm font-weight-bold">{{$report->hcp->displayName()}}</div>
+                                <div class="text-sm">{{friendlier_date_time($report->hcp_pro_signed_at)}}</div>
+                            </div>
+                            @endif
+                            @endif
+                        </td>
+                    </tr>
+                    @endforeach
+
+                    @if(count($reportsPendingAck) === 0)
+                    <tr>
+                        <td colspan="5">No records found!</td>
+                    </tr>
+                    @endif
+                </tbody>
+
+            </table>
+            <div class="ml-2 mt-2">
+                {{ $reportsPendingAck->appends(request()->input())->links() }}
+            </div>
+        </div>
+    </div>
+</div>

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

@@ -0,0 +1,67 @@
+@php 
+    $supplyOrdersPendingHcpApproval = $performer->pro->supplyOrdersPendingHcpApprovalRecordsAsDna();
+@endphp
+<div class="p-3 mcp-theme-1" id="patients-list">
+    <div class="card">
+
+        <div class="card-header px-3 py-2 d-flex align-items-center">
+            <strong class="mr-4">
+                <i class="fas fa-file-invoice-dollar"></i>
+                Supply Orders
+            </strong>
+        </div>
+
+        <div class="card-body p-0">
+           
+            <table class="table table-condensed p-0 m-0">
+                <thead class="bg-light">
+                    <tr>
+                        <th class="px-3 border-0">Date</th>
+                        <th class="px-3 border-0">Patient</th>
+                        <th class="px-3 border-0">Product</th>
+                        <th class="px-3 border-0">Reason</th>
+                        <th class="px-3 border-0">Is Cancelled</th>
+                        <th class="px-3 border-0">Shipment</th>
+                    </tr>
+                </thead>
+                <tbody>
+                    @foreach($supplyOrdersPendingHcpApproval as $supplyOrder)
+                    <tr>
+                        <td>{{ friendlier_date_time($supplyOrder->created_at)}}</td>
+                        <td>{{ $supplyOrder->client->displayName() }} -</td>
+                        <td>{{ $supplyOrder->product->title }}</td>
+                        <td style="width: 300px;">{{ $supplyOrder->reason }}</td>
+                        <td>{{ $supplyOrder->is_cancelled ? 'Yes' : 'No' }}</td>
+                        <td class="px-2">
+                            @if($supplyOrder->shipment_id)
+                            <i class="fa fa-building"></i>
+                            {{$supplyOrder->shipment->status ? $supplyOrder->shipment->status : 'CREATED'}}
+                            @elseif($supplyOrder->is_cleared_for_shipment)
+                            <span class="text-info">
+                                <i class="fa fa-user-nurse"></i>
+                                Cleared for shipment
+                            </span>
+                            @else
+                            <span class="text-warning-mellow">
+                                <i class="fa fa-user-nurse"></i>
+                                Not cleared for shipment
+                            </span>
+                            @endif
+                        </td>
+                    </tr>
+                    @endforeach
+
+                    @if(count($supplyOrdersPendingHcpApproval) === 0)
+                    <tr>
+                        <td colspan="6">No records found!</td>
+                    </tr>
+                    @endif
+                </tbody>
+
+            </table>
+            <div class="ml-2 mt-2">
+                {{ $supplyOrdersPendingHcpApproval->appends(request()->input())->links() }}
+            </div>
+        </div>
+    </div>
+</div>

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

@@ -0,0 +1,66 @@
+@php 
+    $supplyOrdersPendingMyAck = $performer->pro->supplyOrdersPendingMyAckRecordsAsDna();
+@endphp
+<div class="p-3 mcp-theme-1" id="patients-list">
+    <div class="card">
+
+        <div class="card-header px-3 py-2 d-flex align-items-center">
+            <strong class="mr-4">
+                <i class="fas fa-file-invoice-dollar"></i>
+                Supply Orders
+            </strong>
+        </div>
+
+        <div class="card-body p-0">
+            <table class="table table-condensed p-0 m-0">
+                <thead class="bg-light">
+                    <tr>
+                        <th class="px-3 border-0">Date</th>
+                        <th class="px-3 border-0">Patient</th>
+                        <th class="px-3 border-0">Product</th>
+                        <th class="px-3 border-0">Reason</th>
+                        <th class="px-3 border-0">Is Cancelled</th>
+                        <th class="px-3 border-0">Shipment</th>
+                    </tr>
+                </thead>
+                <tbody>
+                    @foreach($supplyOrdersPendingMyAck as $supplyOrder)
+                    <tr>
+                        <td>{{ friendlier_date_time($supplyOrder->created_at)}}</td>
+                        <td>{{ $supplyOrder->client->displayName() }} -</td>
+                        <td>{{ $supplyOrder->product->title }}</td>
+                        <td style="width: 300px;">{{ $supplyOrder->reason }}</td>
+                        <td>{{ $supplyOrder->is_cancelled ? 'Yes' : 'No' }}</td>
+                        <td class="px-2">
+                            @if($supplyOrder->shipment_id)
+                            <i class="fa fa-building"></i>
+                            {{$supplyOrder->shipment->status ? $supplyOrder->shipment->status : 'CREATED'}}
+                            @elseif($supplyOrder->is_cleared_for_shipment)
+                            <span class="text-info">
+                                <i class="fa fa-user-nurse"></i>
+                                Cleared for shipment
+                            </span>
+                            @else
+                            <span class="text-warning-mellow">
+                                <i class="fa fa-user-nurse"></i>
+                                Not cleared for shipment
+                            </span>
+                            @endif
+                        </td>
+                    </tr>
+                    @endforeach
+
+                    @if(count($supplyOrdersPendingMyAck) === 0)
+                    <tr>
+                        <td colspan="6">No records found!</td>
+                    </tr>
+                    @endif
+                </tbody>
+
+            </table>
+            <div class="ml-2 mt-2">
+                {{ $supplyOrdersPendingMyAck->appends(request()->input())->links() }}
+            </div>
+        </div>
+    </div>
+</div>

+ 12 - 0
routes/web.php

@@ -132,6 +132,18 @@ Route::middleware('pro.auth')->group(function () {
         Route::get('erx_and_orders_pending_signature', 'DnaController@erx_and_orders_pending_signature')->name('erx_and_orders_pending_signature');
         Route::get('supply_orders_pending_signature', 'DnaController@supply_orders_pending_signature')->name('supply_orders_pending_signature');
 
+        //from the new spec
+        Route::get('my-patients', 'DnaController@myPatients')->name('my-patients');
+        Route::get('patients_awaiting_mcp_visit', 'DnaController@patientsAwaitingMcpVisit')->name('patients_awaiting_mcp_visit');
+        Route::get('patients_without_appointment', 'DnaController@patientsWithoutAppointment')->name('patients_without_appointment');
+        Route::get('encounters_pending_my_review', 'DnaController@encountersPendingMyReview')->name('encounters_pending_my_review');
+        Route::get('encounters_in_progress', 'DnaController@encountersInProgress')->name('encounters_in_progress');
+        Route::get('appointments_pending_confirmation', 'DnaController@appointmentsPendingConfirmation')->name('appointments_pending_confirmation');
+        Route::get('cancelled_appointments_pending_ack', 'DnaController@cancelledAppointmentsPendingAck')->name('cancelled_appointments_pending_ack');
+        Route::get('reports_pending_ack', 'DnaController@reportsPendingAck')->name('reports_pending_ack');
+        Route::get('supply_orders_pending_my_ack', 'DnaController@supplyOrdersPendingMyAck')->name('supply_orders_pending_my_ack');
+        Route::get('supply_orders_pending_hcp_approval', 'DnaController@supplyOrdersPendingHcpApproval')->name('supply_orders_pending_hcp_approval');
+
     });
 
     Route::name('admin.')->prefix('a')->group(function () {