@php use App\Models\School; use App\Models\StudentBiodata; use App\Models\SchoolHealthPhysician; use App\Models\NutritionistHistoryEvaluationSection; use App\Models\PsychologistHistoryAssessmentSection; use App\Models\MedicalHistoryEmail; use App\Models\User; use Carbon\Carbon; @endphp @extends('admin.main') @section('content')

Dashboard

Follow Up

Days Since School Creation

Findings

referrals

Emails Sent

Students

@php $schools = School::get()->toArray(); $labels = array_map(function ($school) { return $school['school_name']; // Ensure this matches your field name }, $schools); $labels = array_map(function ($label) { return $label; }, $labels); $followups = []; $studentCount = []; $schools = School::get()->toArray(); if (!empty($schools)) { foreach ($schools as $school) { $schoolId = $school['id']; $schoolIdArr[] = $schoolId; $schoolStudentCount = StudentBiodata::where('School_Name', $schoolId)->count(); $studentCount[] = $schoolStudentCount; // echo $schoolId ; // exit(); $studentIds = StudentBiodata::where('School_Name', $schoolId)->where('deleted', 0)->get()->toArray(); // dd($studentIds); // exit(); $totalFollowUps = 0; $totalUnFollowUps = 0; $totalPendingFollowUps = 0; $TotalPhysicanFollowUps = 0; $TotalnutritionFollowUps1 = 0; $TotalpsychologistFollowUps1 = 0; $TotalInternal_referrals = 0; $TotalExternal_referrals = 0; $Blood_pressure_result_count = 0; if (!empty($studentIds)) { foreach ($studentIds as $key => $value) { $StudentBiodataId = $value['id']; // echo $StudentBiodataId; // exit(); $schoolFollowUps = SchoolHealthPhysician::where('deleted', 0) ->where('Follow_up_Required', 'Yes') ->where('StudentBiodataId', $StudentBiodataId) ->count(); $nutritionFollowUps = NutritionistHistoryEvaluationSection::where('deleted', 0) ->where('Follow_up_Required1', 'Yes') ->where('StudentBiodataId', $StudentBiodataId) ->count(); $psychologistFollowUps = PsychologistHistoryAssessmentSection::where('deleted', 0) ->where('Follow_up_Required2', 'Yes') ->where('StudentBiodataId', $StudentBiodataId) ->count(); $totalFollowUps += $schoolFollowUps + $nutritionFollowUps + $psychologistFollowUps; $schoolUnFollowUps = SchoolHealthPhysician::where('deleted', 0) ->where('Follow_up_Required', 'No') ->where('StudentBiodataId', $StudentBiodataId) ->count(); $nutritionUnFollowUps = NutritionistHistoryEvaluationSection::where('deleted', 0) ->where('Follow_up_Required1', 'No') ->where('StudentBiodataId', $StudentBiodataId) ->count(); $psychologistUnFollowUps = PsychologistHistoryAssessmentSection::where('deleted', 0) ->where('Follow_up_Required2', 'No') ->where('StudentBiodataId', $StudentBiodataId) ->count(); $totalUnFollowUps += $schoolUnFollowUps + $nutritionUnFollowUps + $psychologistUnFollowUps; $schoolPendingFollowUps = SchoolHealthPhysician::where('deleted', 0) ->where('Follow_up_Required', 'Yes') ->where('StudentBiodataId', $StudentBiodataId) ->where('Follow_up_Date', '>=', Carbon::today()) ->count(); $nutritionPendingFollowUps = NutritionistHistoryEvaluationSection::where('deleted', 0) ->where('Follow_up_Required1', 'Yes') ->where('StudentBiodataId', $StudentBiodataId) ->where('Follow_up_Date1', '>=', Carbon::today()) ->count(); $psychologistPendingFollowUps = PsychologistHistoryAssessmentSection::where('deleted', 0) ->where('Follow_up_Required2', 'Yes') ->where('StudentBiodataId', $StudentBiodataId) ->where('Follow_up_Date2', '>=', Carbon::today()) ->count(); $totalPendingFollowUps += $schoolPendingFollowUps + $nutritionPendingFollowUps + $psychologistPendingFollowUps; // echo "totalFollowUps ". $totalFollowUps ."
"; // echo "schoolId ". $schoolId ."
"; $schoolFollowUps1 = SchoolHealthPhysician::where('deleted', 0) // ->where('Follow_up_Required', 'Yes') ->where('StudentBiodataId', $StudentBiodataId) ->count(); $nutritionFollowUps1 = NutritionistHistoryEvaluationSection::where('deleted', 0) // ->where('Follow_up_Required1', 'Yes') ->where('StudentBiodataId', $StudentBiodataId) ->count(); $psychologistFollowUps1 = PsychologistHistoryAssessmentSection::where('deleted', 0) // ->where('Follow_up_Required2', 'Yes') ->where('StudentBiodataId', $StudentBiodataId) ->count(); $TotalPhysicanFollowUps += $schoolFollowUps1; $TotalnutritionFollowUps1 += $nutritionFollowUps1; $TotalpsychologistFollowUps1 += $psychologistFollowUps1; $schoolFollowUpsInternal_referrals = SchoolHealthPhysician::where('deleted', 0) ->where('internal_referrals', '!=', null) ->where('internal_referrals', '!=', '') ->where('StudentBiodataId', $StudentBiodataId) ->count(); $nutritionFollowUpsInternal_referrals = NutritionistHistoryEvaluationSection::where( 'deleted', 0, ) ->where('internal_referrals1', '!=', null) ->where('internal_referrals1', '!=', '') ->where('StudentBiodataId', $StudentBiodataId) ->count(); $psychologistFollowUpsInternal_referrals = PsychologistHistoryAssessmentSection::where( 'deleted', 0, ) ->where('internal_referrals2', '!=', null) ->where('internal_referrals2', '!=', '') ->where('StudentBiodataId', $StudentBiodataId) ->count(); $TotalInternal_referrals += $schoolFollowUpsInternal_referrals + $nutritionFollowUpsInternal_referrals + $psychologistFollowUpsInternal_referrals; // dd($TotalInternal_referrals); // echo $TotalInternal_referrals; // exit(); $schoolFollowUpsExternal_referrals = SchoolHealthPhysician::where('deleted', 0) ->where('external_referrals', '!=', null) ->where('external_referrals', '!=', '') ->where('StudentBiodataId', $StudentBiodataId) ->count(); $nutritionFollowUpsExternal_referrals = NutritionistHistoryEvaluationSection::where( 'deleted', 0, ) ->where('external_referrals1', '!=', null) ->where('external_referrals1', '!=', '') ->where('StudentBiodataId', $StudentBiodataId) ->count(); $psychologistFollowUpsExternal_referrals = PsychologistHistoryAssessmentSection::where( 'deleted', 0, ) ->where('external_referrals2', '!=', null) ->where('external_referrals2', '!=', '') ->where('StudentBiodataId', $StudentBiodataId) ->count(); $TotalExternal_referrals += $schoolFollowUpsExternal_referrals + $nutritionFollowUpsExternal_referrals + $psychologistFollowUpsExternal_referrals; // dd($TotalExternal_referrals); // // echo $TotalInternal_referrals; // exit(); $SchoolHealthPhysician1 = SchoolHealthPhysician::where('deleted', 0) ->where('StudentBiodataId', $StudentBiodataId) ->first(); if (!empty($SchoolHealthPhysician1)) { $Blood_pressure_result = $SchoolHealthPhysician1['Blood_pressure_result']; if ($Blood_pressure_result == 'Low') { $Blood_pressure_result_count += 1; } } } // dd($totalFollowUps); // exit(); } // dd($totalFollowUps); $followups[] = $totalFollowUps; $UnfollowUps[] = $totalUnFollowUps; $PendingfollowUps[] = $totalPendingFollowUps; $TotalPhysicanCount[] = $TotalPhysicanFollowUps; $TotalnutritionFollowUps[] = $TotalnutritionFollowUps1; $TotalPsychologistFollowUps[] = $TotalpsychologistFollowUps1; $Internal_referrals[] = $TotalInternal_referrals; $External_referrals[] = $TotalExternal_referrals; // dd($TotalPsychologistFollowUps); // exit(); // dd($TotalExternal_referrals); // exit(); } } // dd($followups); // exit(); $schools = School::all()->toArray(); // $daysSinceSchoolCreation = 0; // $SchoolName=" "; // $colors = ['lightblue', 'lightgreen', 'pink', 'lightyellow', 'lightcoral']; // $borderColors = ['blue', 'green', 'red', 'yellow', 'darkred']; foreach ($schools as $index => $school) { $School = $school['school_name']; $School_id = $school['id']; $createdAt = $school['created_at']; $daysSince = now()->diffInDays($createdAt); $daysSinceSchoolCreation[] = $daysSince; $SchoolName[] = $School; // echo $daysSince."
"; // echo $School_id."
"; // exit(); } // dd($daysSinceSchoolCreation); // exit(); $findings = DB::table('student_biodata') ->select('School_Name', DB::raw('COUNT(id) as count')) ->groupBy('School_Name') ->having(DB::raw('COUNT(id)'), '>', 1) ->get() ->toArray(); @endphp @endsection