@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
";
// 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