performer(); $performerProID = $performer->pro->id; $keyNumbers = []; $totalPatients = Client::where('mcp_pro_id', $performer->pro->id)->count(); $keyNumbers['totalPatients'] = $totalPatients; $patientNotSeenYet = Client::where('mcp_pro_id', $performer->pro->id) ->where(function ($query) { $query->where('has_mcp_done_onboarding_visit', 'UNKNOWN') ->orWhere('has_mcp_done_onboarding_visit', 'NO'); })->count(); $keyNumbers['patientsNotSeenYet'] = $patientNotSeenYet; $pendingBillsToSign = Bill::where(function ($query) use ($performerProID) { $query->where('hcp_pro_id', $performerProID)->where('is_signed_by_hcp', false)->where('is_cancelled', false); }) ->orWhere(function ($query) use ($performerProID) { $query->where('cm_pro_id', $performerProID)->where('is_signed_by_cm', false)->where('is_cancelled', false);; })->orWhere(function ($query) use ($performerProID) { $query->where('rme_pro_id', $performerProID)->where('is_signed_by_rme', false)->where('is_cancelled', false);; })->orWhere(function ($query) use ($performerProID) { $query->where('rmm_pro_id', $performerProID)->where('is_signed_by_rmm', false)->where('is_cancelled', false);; })->count(); $keyNumbers['pendingBillsToSign'] = $pendingBillsToSign; $pendingNotesToSign = Note::where(function ($query) use ($performerProID) { $query->where('hcp_pro_id', $performerProID)->where('is_signed_by_hcp', false)->where('is_cancelled', false);; }) ->orWhere(function ($query) use ($performerProID) { $query->where('ally_pro_id', $performerProID)->where('is_signed_by_ally', false)->where('is_cancelled', false);; })->count(); $keyNumbers['pendingNotesToSign'] = $pendingNotesToSign; $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"] = '--'; } $clientsWithAppointments = Client::where("mcp_pro_id", $performerProID) ->whereNotNull('next_mcp_appointment')->get(); $appointments = []; foreach ($clientsWithAppointments as $client) { $appointment = [ 'client_uid' => $client->uid, 'title' => $client->name_first . ' ' . $client->name_last, 'start' => $client->next_mcp_appointment ]; $appointments[] = $appointment; } return view('app/dashboard', compact('keyNumbers', 'reimbursement', 'appointments')); } public function patients(Request $request) { $patients = Client::orderBy('name_last', 'asc')->orderBy('name_first', 'asc')->get(); return view('app/patients', ['patients' => $patients]); } public function newPatient(Request $request) { return view('app/new-patient'); } public function mc(Request $request, $fragment = "") { $page = "/"; if ($fragment) { $page = '/' . $fragment; } return view('app/mc', compact('page')); } }