performer(); $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; $performerProID = $performer->pro->id; $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"] = '--'; } return view('app/dashboard', compact('keyNumbers','reimbursement')); } public function patients(Request $request) { $proID = $this->performer()->pro->id; $patients = Client::where(function ($q) use($proID) { $q->where('mcp_pro_id', $proID) ->orWhere('cm_pro_id', $proID) ->orWhere('rmm_pro_id', $proID) ->orWhere('rme_pro_id', $proID) ->orWhereRaw('id IN (SELECT client_id FROM client_pro_access WHERE pro_id = ?)', [$proID]); }) ->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')); } }