@@ -263,6 +518,74 @@
var Appointment_total_missed_to_twentyfive_above = ;
var Appointment_total_missed_uknown_age = ;
+ var Client_consented_male = ;
+ var Client_consented_female = ;
+ var Client_consented_uknown_gender = ;
+ var Client_nonconsented_male = ;
+ var Client_nonconsented_female = ;
+ var Client_nonconsented_uknown_gender = ;
+ var Client_consented_to_nine = ;
+ var Client_consented_to_fourteen = ;
+ var Client_consented_to_nineteen = ;
+ var Client_consented_to_twentyfour = ;
+ var Client_consented_to_twentyfive_above = ;
+ var Client_consented_uknown_age = ;
+ var Client_nonconsented_to_nine = ;
+ var Client_nonconsented_to_fourteen = ;
+ var Client_nonconsented_to_nineteen = ;
+ var Client_nonconsented_to_twentyfour = ;
+ var Client_nonconsented_to_twentyfive_above = ;
+ var Client_nonconsented_uknown_age = ;
+
+
+ var Appointment_honoured_male = ;
+ var Appointment_honoured_female = ;
+ var Appointment_honoured_uknown_gender = ;
+ var Appointment_honored_to_nine = ;
+ var Appointment_honored_to_fourteen = ;
+ var Appointment_honored_to_nineteen = ;
+ var Appointment_honored_to_twentyfour = ;
+ var Appointment_honored_to_twentyfive_above = ;
+ var Appointment_honored_to_uknown_age = ;
+ var Appointment_not_honoured_male = ;
+ var Appointment_not_honoured_female = ;
+ var Appointment_not_honoured_uknown_gender = ;
+ var Appointment_not_honored_to_nine = ;
+ var Appointment_not_honored_to_fourteen = ;
+ var Appointment_not_honored_to_nineteen = ;
+ var Appointment_not_honored_to_twentyfour = ;
+ var Appointment_not_honored_to_twentyfive_above = ;
+ var Appointment_not_honored_to_uknown_age = ;
+
+
+ var Appointment_missed_male = ;
+ var Appointment_missed_female = ;
+ var Appointment_missed_uknown_gender = ;
+ var Appointment_missed_to_nine = ;
+ var Appointment_missed_to_fourteen = ;
+ var Appointment_missed_to_nineteen = ;
+ var Appointment_missed_to_twentyfour = ;
+ var Appointment_missed_to_twentyfive_above = ;
+ var Appointment_missed_to_uknown_age = ;
+ var Appointment_defaulted_female = ;
+ var Appointment_defaulted_male = ;
+ var Appointment_defaulted_uknown_gender = ;
+ var Appointment_defaulted_to_nine = ;
+ var Appointment_defaulted_to_fourteen = ;
+ var Appointment_defaulted_to_nineteen = ;
+ var Appointment_defaulted_to_twentyfour = ;
+ var Appointment_defaulted_to_twentyfive_above = ;
+ var Appointment_defaulted_to_uknown_age = ;
+ var Appointment_ltfu_female = ;
+ var Appointment_ltfu_male = ;
+ var Appointment_ltfu_uknown_gender = ;
+ var Appointment_ltfu_to_nine = ;
+ var Appointment_ltfu_to_fourteen = ;
+ var Appointment_ltfu_to_nineteen = ;
+ var Appointment_ltfu_to_twentyfour = ;
+ var Appointment_ltfu_to_twentyfive_above = ;
+ var Appointment_ltfu_to_uknown_age = ;
+
$(document).ready(function() {
$('select[name="partner"]').on('change', function() {
@@ -638,6 +961,628 @@
});
+ // CONSENTED CLIENTS GENDER
+ var appChart = Highcharts.chart('consented_gender', {
+ chart: {
+ type: 'column'
+ },
+ title: {
+ text: 'Consented Clients By Gender'
+ },
+ xAxis: {
+ categories: ['Male', 'Female', 'UKNOWN Gender']
+ },
+ yAxis: {
+ min: 0,
+ title: {
+ text: 'No of Consented Clients'
+ },
+ stackLabels: {
+ enabled: true,
+ style: {
+ fontWeight: 'bold',
+ color: ( // theme
+ Highcharts.defaultOptions.title.style &&
+ Highcharts.defaultOptions.title.style.color
+ ) || 'gray'
+ }
+ }
+ },
+ tooltip: {
+ formatter: function() {
+ return '
' + this.x + '' +
+ this.series.name + ': ' + this.y;
+ }
+ },
+ plotOptions: {
+ column: {
+ stacking: 'normal',
+ }
+ },
+ series: [{
+ name: 'Gender',
+ data: [Client_consented_male, Client_consented_female, Client_consented_uknown_gender]
+ }],
+
+ });
+ // CONSENTED CLIENTS AGE
+ var appChart = Highcharts.chart('consented_age', {
+ chart: {
+ type: 'column'
+ },
+ title: {
+ text: 'Consented Clients By Age'
+ },
+ xAxis: {
+ categories: ['0-9 YRS', '10-14 YRS', '15-19 YRS', '20-24 YRS', '25+ YRS', 'UKNOWN AGE']
+ },
+ yAxis: {
+ min: 0,
+ title: {
+ text: 'No of Consented Clients'
+ },
+ stackLabels: {
+ enabled: true,
+ style: {
+ fontWeight: 'bold',
+ color: ( // theme
+ Highcharts.defaultOptions.title.style &&
+ Highcharts.defaultOptions.title.style.color
+ ) || 'gray'
+ }
+ }
+ },
+ tooltip: {
+ formatter: function() {
+ return '
' + this.x + '' +
+ this.series.name + ': ' + this.y;
+ }
+ },
+ plotOptions: {
+ column: {
+ stacking: 'normal',
+ }
+ },
+ series: [{
+ name: 'Age',
+ data: [Client_consented_to_nine, Client_consented_to_fourteen, Client_consented_to_nineteen, Client_consented_to_twentyfour, Client_consented_to_twentyfive_above, Client_consented_uknown_age]
+ }],
+
+ });
+
+ //NON CONSENTED CLIENTS GENDER
+ var appChart = Highcharts.chart('nonconsented_gender', {
+ chart: {
+ type: 'column'
+ },
+ title: {
+ text: 'Non Consented Clients By Gender'
+ },
+ xAxis: {
+ categories: ['Male', 'Female', 'UKNOWN Gender']
+ },
+ yAxis: {
+ min: 0,
+ title: {
+ text: 'No of Non Consented Clients'
+ },
+ stackLabels: {
+ enabled: true,
+ style: {
+ fontWeight: 'bold',
+ color: ( // theme
+ Highcharts.defaultOptions.title.style &&
+ Highcharts.defaultOptions.title.style.color
+ ) || 'gray'
+ }
+ }
+ },
+ tooltip: {
+ formatter: function() {
+ return '
' + this.x + '' +
+ this.series.name + ': ' + this.y;
+ }
+ },
+ plotOptions: {
+ column: {
+ stacking: 'normal',
+ }
+ },
+ series: [{
+ name: 'Gender',
+ data: [Client_nonconsented_male, Client_nonconsented_female, Client_nonconsented_uknown_gender]
+ }],
+
+ });
+// NON CONSENTED AGE
+ var appChart = Highcharts.chart('nonconsented_age', {
+ chart: {
+ type: 'column'
+ },
+ title: {
+ text: 'Non Consented Clients By Age'
+ },
+ xAxis: {
+ categories: ['0-9 YRS', '10-14 YRS', '15-19 YRS', '20-24 YRS', '25+ YRS', 'UKNOWN AGE']
+ },
+ yAxis: {
+ min: 0,
+ title: {
+ text: 'No of Non Consented Clients'
+ },
+ stackLabels: {
+ enabled: true,
+ style: {
+ fontWeight: 'bold',
+ color: ( // theme
+ Highcharts.defaultOptions.title.style &&
+ Highcharts.defaultOptions.title.style.color
+ ) || 'gray'
+ }
+ }
+ },
+ tooltip: {
+ formatter: function() {
+ return '
' + this.x + '' +
+ this.series.name + ': ' + this.y;
+ }
+ },
+ plotOptions: {
+ column: {
+ stacking: 'normal',
+ }
+ },
+ series: [{
+ name: 'Age',
+ data: [Client_nonconsented_to_nine, Client_nonconsented_to_fourteen, Client_nonconsented_to_nineteen, Client_nonconsented_to_twentyfour, Client_nonconsented_to_twentyfive_above, Client_nonconsented_uknown_age]
+ }],
+
+ });
+
+ //APPOINTMENT HONOURED GENDER
+ var appChart = Highcharts.chart('appointment_honoured_gender', {
+ chart: {
+ type: 'column'
+ },
+ title: {
+ text: 'Appointment Honoured By Gender'
+ },
+ xAxis: {
+ categories: ['Male', 'Female', 'UKNOWN Gender']
+ },
+ yAxis: {
+ min: 0,
+ title: {
+ text: 'No of Appointment Honoured'
+ },
+ stackLabels: {
+ enabled: true,
+ style: {
+ fontWeight: 'bold',
+ color: ( // theme
+ Highcharts.defaultOptions.title.style &&
+ Highcharts.defaultOptions.title.style.color
+ ) || 'gray'
+ }
+ }
+ },
+ tooltip: {
+ formatter: function() {
+ return '
' + this.x + '' +
+ this.series.name + ': ' + this.y;
+ }
+ },
+ plotOptions: {
+ column: {
+ stacking: 'normal',
+ }
+ },
+ series: [{
+ name: 'Gender',
+ data: [Appointment_honoured_male, Appointment_honoured_female, Appointment_honoured_uknown_gender]
+ }],
+
+ });
+// APPOINTMENT HONOURED AGE
+ var appChart = Highcharts.chart('appointment_honoured_age', {
+ chart: {
+ type: 'column'
+ },
+ title: {
+ text: 'Appointment Honoured By Age'
+ },
+ xAxis: {
+ categories: ['0-9 YRS', '10-14 YRS', '15-19 YRS', '20-24 YRS', '25+ YRS', 'UKNOWN AGE']
+ },
+ yAxis: {
+ min: 0,
+ title: {
+ text: 'No of Appointment Honoured'
+ },
+ stackLabels: {
+ enabled: true,
+ style: {
+ fontWeight: 'bold',
+ color: ( // theme
+ Highcharts.defaultOptions.title.style &&
+ Highcharts.defaultOptions.title.style.color
+ ) || 'gray'
+ }
+ }
+ },
+ tooltip: {
+ formatter: function() {
+ return '
' + this.x + '' +
+ this.series.name + ': ' + this.y;
+ }
+ },
+ plotOptions: {
+ column: {
+ stacking: 'normal',
+ }
+ },
+ series: [{
+ name: 'Age',
+ data: [Appointment_honored_to_nine, Appointment_honored_to_fourteen, Appointment_honored_to_nineteen, Appointment_honored_to_twentyfour, Appointment_honored_to_twentyfive_above, Appointment_honored_to_uknown_age]
+ }],
+
+ });
+
+ //APPOINTMENT NOT HONOURED GENDER
+ var appChart = Highcharts.chart('appointment_not_honoured_gender', {
+ chart: {
+ type: 'column'
+ },
+ title: {
+ text: 'Appointment Not Honoured By Gender'
+ },
+ xAxis: {
+ categories: ['Male', 'Female', 'UKNOWN Gender']
+ },
+ yAxis: {
+ min: 0,
+ title: {
+ text: 'No of Appointment Not Honoured'
+ },
+ stackLabels: {
+ enabled: true,
+ style: {
+ fontWeight: 'bold',
+ color: ( // theme
+ Highcharts.defaultOptions.title.style &&
+ Highcharts.defaultOptions.title.style.color
+ ) || 'gray'
+ }
+ }
+ },
+ tooltip: {
+ formatter: function() {
+ return '
' + this.x + '' +
+ this.series.name + ': ' + this.y;
+ }
+ },
+ plotOptions: {
+ column: {
+ stacking: 'normal',
+ }
+ },
+ series: [{
+ name: 'Gender',
+ data: [Appointment_not_honoured_male, Appointment_not_honoured_female, Appointment_not_honoured_uknown_gender]
+ }],
+
+ });
+// APPOINTMENT NOT HONOURED AGE
+ var appChart = Highcharts.chart('appointment_not_honoured_age', {
+ chart: {
+ type: 'column'
+ },
+ title: {
+ text: 'Appointment Not Honoured By Age'
+ },
+ xAxis: {
+ categories: ['0-9 YRS', '10-14 YRS', '15-19 YRS', '20-24 YRS', '25+ YRS', 'UKNOWN AGE']
+ },
+ yAxis: {
+ min: 0,
+ title: {
+ text: 'No of Appointment Not Honoured'
+ },
+ stackLabels: {
+ enabled: true,
+ style: {
+ fontWeight: 'bold',
+ color: ( // theme
+ Highcharts.defaultOptions.title.style &&
+ Highcharts.defaultOptions.title.style.color
+ ) || 'gray'
+ }
+ }
+ },
+ tooltip: {
+ formatter: function() {
+ return '
' + this.x + '' +
+ this.series.name + ': ' + this.y;
+ }
+ },
+ plotOptions: {
+ column: {
+ stacking: 'normal',
+ }
+ },
+ series: [{
+ name: 'Age',
+ data: [Appointment_not_honored_to_nine, Appointment_not_honored_to_fourteen, Appointment_not_honored_to_nineteen, Appointment_not_honored_to_twentyfour, Appointment_not_honored_to_twentyfive_above, Appointment_not_honored_to_uknown_age]
+ }],
+
+ });
+
+ //MISSED APPOINTMENT BY GENDER
+ var appChart = Highcharts.chart('appointment_missed_gender', {
+ chart: {
+ type: 'column'
+ },
+ title: {
+ text: 'Appointment Missed By Gender'
+ },
+ xAxis: {
+ categories: ['Male', 'Female', 'UKNOWN Gender']
+ },
+ yAxis: {
+ min: 0,
+ title: {
+ text: 'No of Appointment Missed'
+ },
+ stackLabels: {
+ enabled: true,
+ style: {
+ fontWeight: 'bold',
+ color: ( // theme
+ Highcharts.defaultOptions.title.style &&
+ Highcharts.defaultOptions.title.style.color
+ ) || 'gray'
+ }
+ }
+ },
+ tooltip: {
+ formatter: function() {
+ return '
' + this.x + '' +
+ this.series.name + ': ' + this.y;
+ }
+ },
+ plotOptions: {
+ column: {
+ stacking: 'normal',
+ }
+ },
+ series: [{
+ name: 'Gender',
+ data: [Appointment_missed_male, Appointment_missed_female, Appointment_missed_uknown_gender]
+ }],
+
+ });
+// APPOINTMENT MISSED AGE
+ var appChart = Highcharts.chart('appointment_missed_age', {
+ chart: {
+ type: 'column'
+ },
+ title: {
+ text: 'Appointment Missed By Age'
+ },
+ xAxis: {
+ categories: ['0-9 YRS', '10-14 YRS', '15-19 YRS', '20-24 YRS', '25+ YRS', 'UKNOWN AGE']
+ },
+ yAxis: {
+ min: 0,
+ title: {
+ text: 'No of Appointment Missed'
+ },
+ stackLabels: {
+ enabled: true,
+ style: {
+ fontWeight: 'bold',
+ color: ( // theme
+ Highcharts.defaultOptions.title.style &&
+ Highcharts.defaultOptions.title.style.color
+ ) || 'gray'
+ }
+ }
+ },
+ tooltip: {
+ formatter: function() {
+ return '
' + this.x + '' +
+ this.series.name + ': ' + this.y;
+ }
+ },
+ plotOptions: {
+ column: {
+ stacking: 'normal',
+ }
+ },
+ series: [{
+ name: 'Age',
+ data: [Appointment_missed_to_nine, Appointment_missed_to_fourteen, Appointment_missed_to_nineteen, Appointment_missed_to_twentyfour, Appointment_missed_to_twentyfive_above, Appointment_missed_to_uknown_age]
+ }],
+
+ });
+ //DEFAULTED APPOINTMENT BY GENDER
+ var appChart = Highcharts.chart('appointment_defaulted_gender', {
+ chart: {
+ type: 'column'
+ },
+ title: {
+ text: 'Appointment Defaulted By Gender'
+ },
+ xAxis: {
+ categories: ['Male', 'Female', 'UKNOWN Gender']
+ },
+ yAxis: {
+ min: 0,
+ title: {
+ text: 'No of Appointment Defaulted'
+ },
+ stackLabels: {
+ enabled: true,
+ style: {
+ fontWeight: 'bold',
+ color: ( // theme
+ Highcharts.defaultOptions.title.style &&
+ Highcharts.defaultOptions.title.style.color
+ ) || 'gray'
+ }
+ }
+ },
+ tooltip: {
+ formatter: function() {
+ return '
' + this.x + '' +
+ this.series.name + ': ' + this.y;
+ }
+ },
+ plotOptions: {
+ column: {
+ stacking: 'normal',
+ }
+ },
+ series: [{
+ name: 'Gender',
+ data: [Appointment_defaulted_male, Appointment_defaulted_female, Appointment_defaulted_uknown_gender]
+ }],
+
+ });
+// APPOINTMENT DEFAULTED AGE
+ var appChart = Highcharts.chart('appointment_defaulted_age', {
+ chart: {
+ type: 'column'
+ },
+ title: {
+ text: 'Appointment Defaulted By Age'
+ },
+ xAxis: {
+ categories: ['0-9 YRS', '10-14 YRS', '15-19 YRS', '20-24 YRS', '25+ YRS', 'UKNOWN AGE']
+ },
+ yAxis: {
+ min: 0,
+ title: {
+ text: 'No of Appointment Defaulted'
+ },
+ stackLabels: {
+ enabled: true,
+ style: {
+ fontWeight: 'bold',
+ color: ( // theme
+ Highcharts.defaultOptions.title.style &&
+ Highcharts.defaultOptions.title.style.color
+ ) || 'gray'
+ }
+ }
+ },
+ tooltip: {
+ formatter: function() {
+ return '
' + this.x + '' +
+ this.series.name + ': ' + this.y;
+ }
+ },
+ plotOptions: {
+ column: {
+ stacking: 'normal',
+ }
+ },
+ series: [{
+ name: 'Age',
+ data: [Appointment_defaulted_to_nine, Appointment_defaulted_to_fourteen, Appointment_defaulted_to_nineteen, Appointment_defaulted_to_twentyfour, Appointment_defaulted_to_twentyfive_above, Appointment_defaulted_to_uknown_age]
+ }],
+
+ });
+
+ //LTFU APPOINTMENT BY GENDER
+ var appChart = Highcharts.chart('appointment_ltfu_gender', {
+ chart: {
+ type: 'column'
+ },
+ title: {
+ text: 'Appointment LTFU By Gender'
+ },
+ xAxis: {
+ categories: ['Male', 'Female', 'UKNOWN Gender']
+ },
+ yAxis: {
+ min: 0,
+ title: {
+ text: 'No of Appointment LTFU'
+ },
+ stackLabels: {
+ enabled: true,
+ style: {
+ fontWeight: 'bold',
+ color: ( // theme
+ Highcharts.defaultOptions.title.style &&
+ Highcharts.defaultOptions.title.style.color
+ ) || 'gray'
+ }
+ }
+ },
+ tooltip: {
+ formatter: function() {
+ return '
' + this.x + '' +
+ this.series.name + ': ' + this.y;
+ }
+ },
+ plotOptions: {
+ column: {
+ stacking: 'normal',
+ }
+ },
+ series: [{
+ name: 'Gender',
+ data: [Appointment_ltfu_male, Appointment_ltfu_female, Appointment_ltfu_uknown_gender]
+ }],
+
+ });
+// APPOINTMENT LTFU AGE
+ var appChart = Highcharts.chart('appointment_lftu_age', {
+ chart: {
+ type: 'column'
+ },
+ title: {
+ text: 'Appointment LTFU By Age'
+ },
+ xAxis: {
+ categories: ['0-9 YRS', '10-14 YRS', '15-19 YRS', '20-24 YRS', '25+ YRS', 'UKNOWN AGE']
+ },
+ yAxis: {
+ min: 0,
+ title: {
+ text: 'No of Appointment LTFU'
+ },
+ stackLabels: {
+ enabled: true,
+ style: {
+ fontWeight: 'bold',
+ color: ( // theme
+ Highcharts.defaultOptions.title.style &&
+ Highcharts.defaultOptions.title.style.color
+ ) || 'gray'
+ }
+ }
+ },
+ tooltip: {
+ formatter: function() {
+ return '
' + this.x + '' +
+ this.series.name + ': ' + this.y;
+ }
+ },
+ plotOptions: {
+ column: {
+ stacking: 'normal',
+ }
+ },
+ series: [{
+ name: 'Age',
+ data: [Appointment_ltfu_to_nine, Appointment_ltfu_to_fourteen, Appointment_ltfu_to_nineteen, Appointment_ltfu_to_twentyfour, Appointment_ltfu_to_twentyfive_above, Appointment_ltfu_to_uknown_age]
+ }],
+
+ });
+
var colors = Highcharts.getOptions().colors;
diff --git a/routes/web.php b/routes/web.php
index b4fabc1..52fa307 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -200,4 +200,5 @@
// new dashbaord routes
Route::get('/admin/dashboard', ['uses' => 'App\Http\Controllers\NewDashboardController@dashboard', 'as' => 'dashboard']);
+ Route::get('/filter_charts', ['uses' => 'App\Http\Controllers\NewDashboardController@filter_charts', 'as' => 'filter_charts']);
});
diff --git a/storage/debugbar/.gitignore b/storage/debugbar/.gitignore
new file mode 100644
index 0000000..d6b7ef3
--- /dev/null
+++ b/storage/debugbar/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
From e9336b522f11786d44328f44b766c14e3ac309e4 Mon Sep 17 00:00:00 2001
From: Ronald-pro <36841157+Ronald-pro@users.noreply.github.com>
Date: Thu, 28 Apr 2022 08:01:09 +0300
Subject: [PATCH 026/241] added date filters
---
.../Controllers/NewDashboardController.php | 1320 +++++++++++------
app/Http/Controllers/SMSReportController.php | 9 +-
.../appointment_dashboard.blade.php | 928 ++++++++++++
.../facility_dashboard.blade.php | 0
.../new_dashboard/main_dashbaord.blade.php | 653 --------
routes/web.php | 1 +
6 files changed, 1805 insertions(+), 1106 deletions(-)
create mode 100644 resources/views/new_dashboard/appointment_dashboard.blade.php
delete mode 100644 resources/views/new_dashboard/facility_dashboard.blade.php
diff --git a/app/Http/Controllers/NewDashboardController.php b/app/Http/Controllers/NewDashboardController.php
index 7f7c71b..e440dfa 100644
--- a/app/Http/Controllers/NewDashboardController.php
+++ b/app/Http/Controllers/NewDashboardController.php
@@ -29,30 +29,30 @@ public function dashboard()
}
if (Auth::user()->access_level == 'Partner') {
-
- }
- if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
-
$all_partners = Partner::where('status', '=', 'Active')->pluck('name', 'id');
- $client = Client::select('id')->where('status', '=', 'Active')
- ->whereNull('hei_no')
- ->count();
-
- $indicator = Indicator::all();
- $appointment = Appointments::select('id')
- ->count();
-
-
- $missed_appointment = Appointments::select('id')
- ->where('app_status', '=', 'Missed')
- ->orwhere('app_status', '=', 'LTFU')
- ->orwhere('app_status', '=', 'Defaulted')
+ $client = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->count('tbl_client.clinic_number');
+
+ $indicator = Indicator::select(['name', 'description'])->get();
+ $appointment = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_appointment.id')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->count();
+ $missed_appointment = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_appointment.id')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
- // dd($missed_appointment);
$active_facilities = PartnerFacility::join('tbl_client', 'tbl_partner_facility.mfl_code', '=', 'tbl_client.mfl_code')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw('COUNT(tbl_partner_facility.mfl_code) as facilities'))
->where('tbl_appointment.created_at', '>=', Carbon::now()->subMonths(6))
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->orderBy('tbl_appointment.created_at', 'DESC')
->groupBy('tbl_partner_facility.mfl_code')
->get();
@@ -60,81 +60,105 @@ public function dashboard()
// dd($active_facilities);
// active clients by gender
- $clients_male = Client::select('id')->where([['gender', '=', '2'], ['status', '=', 'Active'],])
- ->whereNull('hei_no')
+ $clients_male = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('id')->where([['tbl_client.gender', '=', '2'], ['tbl_client.status', '=', 'Active'],])
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
- $clients_female = Client::where('gender', '=', '1')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
+ $clients_female = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.gender', '=', '1')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
- $unknown_gender = Client::where('gender', '!=', '1')
- ->where('gender', '!=', '2')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
+ $unknown_gender = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
- $client_to_nine = Cache::remember('client-nine', 10, function () {
- return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`dob`)) > 0) and ((year(curdate()) - year(`dob`)) <= 9)) then `dob` end)) AS count"))
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
+ $client_to_nine = Cache::remember('client_to_nine', 10, function () {
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$client_to_fourteen = Cache::remember('client-fourteen', 10, function () {
- return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`dob`)) >= 10) and ((year(curdate()) - year(`dob`)) <= 14)) then `dob` end)) AS count"))
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$client_to_nineteen = Cache::remember('client-nineteen', 10, function () {
- return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`dob`)) >= 15) and ((year(curdate()) - year(`dob`)) <= 19)) then `dob` end)) AS count"))
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$client_to_twentyfour = Cache::remember('client-twentyfour', 10, function () {
- return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`dob`)) >= 20) and ((year(curdate()) - year(`dob`)) <= 24)) then `id` end)) AS count"))
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$client_to_twentyfive_above = Cache::remember('client-twentyfive-above', 10, function () {
- return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`dob`)) >= 25)) then `id` end)) AS count"))
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$client_unknown_age = Cache::remember('client-unknown-age', 10, function () {
- return Client::where('dob', '=', '')
- ->orWhereNull('dob')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.dob', '=', '')
+ ->orWhereNull('tbl_client.dob')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
// appointment by gender
$appointment_male = Cache::remember('appointment-male', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select('tbl_appointment.id')
->where('tbl_client.gender', '=', '2')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
$appointment_female = Cache::remember('appointment-female', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select('tbl_appointment.id')
->where('tbl_client.gender', '=', '1')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
$appointment_uknown_gender = Cache::remember('appointment-uknown-gender', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select('tbl_appointment.id')
->where('tbl_client.gender', '!=', '1')
->where('tbl_client.gender', '!=', '2')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
// appointment by age
@@ -142,30 +166,35 @@ public function dashboard()
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$appointment_to_fourteen = Cache::remember('appointment-to-fourteen', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$appointment_to_nineteen = Cache::remember('appointment-to-nineteen', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$appointment_to_twentyfour = Cache::remember('appointment-to-twentyfour', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$appointment_to_twentyfive_above = Cache::remember('appointment-to-twentyfive-above', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$appointment_uknown_age = Cache::remember('appointment-uknown-age', 10, function () {
@@ -173,590 +202,630 @@ public function dashboard()
->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->where('tbl_client.dob', '=', '')
->orWhereNull('tbl_client.dob')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
// Total missed appointment by gender
$appointment_total_missed_female = Cache::remember('appointment-total-missed-female', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->where('tbl_client.gender', '=', '1')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->orwhere('tbl_appointment.app_status', '=', 'LTFU')
- ->orwhere('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
$appointment_total_missed_male = Cache::remember('appointment-total-missed-male', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->where('tbl_client.gender', '=', '2')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->orwhere('tbl_appointment.app_status', '=', 'LTFU')
- ->orwhere('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
$appointment_total_missed_uknown_gender = Cache::remember('appointment-total-missed-uknown-gender', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->where('tbl_client.gender', '!=', '1')
->where('tbl_client.gender', '!=', '2')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->orwhere('tbl_appointment.app_status', '=', 'LTFU')
- ->orwhere('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
// Total missed appointment by age
$appointment_total_missed_to_nine = Cache::remember('appointment-total-missed-to-nine', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->orwhere('tbl_appointment.app_status', '=', 'LTFU')
- ->orwhere('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$appointment_total_missed_to_fourteen = Cache::remember('appointment-total-missed-to-fourteen', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->orwhere('tbl_appointment.app_status', '=', 'LTFU')
- ->orwhere('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$appointment_total_missed_to_nineteen = Cache::remember('appointment-total-missed-to-nineteen', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.date_attended', '!=', 'tbl_appointment.appntmnt_date')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$appointment_total_missed_to_twentyfour = Cache::remember('appointment-total-missed-to-twentyfour', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.date_attended', '!=', 'tbl_appointment.appntmnt_date')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$appointment_total_missed_to_twentyfive_above = Cache::remember('appointment-total-missed-to-twentyfive_above', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->orwhere('tbl_appointment.app_status', '=', 'LTFU')
- ->orwhere('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$appointment_total_missed_uknown_age = Cache::remember('appointment-total-missed-uknown-age', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->where('tbl_client.dob', '=', '')
- ->orWhereNull('tbl_client.dob')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->orwhere('tbl_appointment.app_status', '=', 'LTFU')
- ->orwhere('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
// client charts
$client_consented = Cache::remember('client-consented', 10, function () {
- return Client::select('smsenable')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
- ->where('smsenable', '=', 'Yes')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_clientsmsenable')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
$client_nonconsented = Cache::remember('client-nonconsented', 10, function () {
- return Client::select('smsenable')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
- ->where('smsenable', '!=', 'Yes')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('smsenable')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
// consented clients by gender
$client_consented_male = Cache::remember('client-consented-male', 10, function () {
- return Client::where('smsenable', '=', 'Yes')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
- ->where('gender', '=', '2')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.gender', '=', '2')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
$client_consented_female = Cache::remember('client-consented-female', 10, function () {
- return Client::where('smsenable', '=', 'Yes')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
- ->where('gender', '=', '1')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.gender', '=', '1')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
$client_consented_uknown_gender = Cache::remember('client-consented-uknown-gender', 10, function () {
- return Client::where('smsenable', '=', 'Yes')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
- ->where('gender', '!=', '1')
- ->where('gender', '!=', '2')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
// non consented clients by gender
$client_nonconsented_male = Cache::remember('client-nonconsented-male', 10, function () {
- return Client::where('smsenable', '!=', 'Yes')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
- ->where('gender', '=', '2')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.gender', '=', '2')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
$client_nonconsented_female = Cache::remember('client-nonconsented-female', 10, function () {
- return Client::where('smsenable', '!=', 'Yes')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
- ->where('gender', '=', '1')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.gender', '=', '1')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
$client_nonconsented_uknown_gender = Cache::remember('client-nonconsented-uknown-gender', 10, function () {
- return Client::where('smsenable', '!=', 'Yes')
- ->where('gender', '!=', '1')
- ->where('gender', '!=', '2')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
// consented clients by age distribution
$client_consented_to_nine = Cache::remember('client-consented-to-nine', 10, function () {
- return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
- ->where('smsenable', '=', 'Yes')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$client_consented_to_fourteen = Cache::remember('tbl-client', 10, function () {
- return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
- ->where('smsenable', '=', 'Yes')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$client_consented_to_nineteen = Cache::remember('client-consented-to-nineteen', 10, function () {
- return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
- ->where('smsenable', '=', 'Yes')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$client_consented_to_twentyfour = Cache::remember('client-consented-to-twentyfour', 10, function () {
- return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
- ->where('smsenable', '=', 'Yes')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$client_consented_to_twentyfive_above = Cache::remember('client-consented-to-twentyfive-above', 10, function () {
- return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
- ->where('smsenable', '=', 'Yes')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$client_consented_uknown_age = Cache::remember('client-consented-uknown-age', 10, function () {
- return Client::select('smsenable')
- ->where('dob', '=', '')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
- ->orWhereNull('dob')
- ->where('smsenable', '=', 'Yes')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.smsenable')
+ ->where('tbl_client.dob', '=', '')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->orWhereNull('tbl_client.dob')
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
// non consented clients by age distribution
$client_nonconsented_to_nine = Cache::remember('client-nonconsented-to-nine', 10, function () {
- return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
- ->where('smsenable', '!=', 'Yes')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$client_nonconsented_to_fourteen = Cache::remember('client-nonconsented-to-fourteen', 10, function () {
- return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
- ->where('smsenable', '!=', 'Yes')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$client_nonconsented_to_nineteen = Cache::remember('client-nonconsented-to-nineteen', 10, function () {
- return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
- ->where('smsenable', '!=', 'Yes')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$client_nonconsented_to_twentyfour = Cache::remember('client-nonconsented-to-twentyfour', 10, function () {
- return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
- ->where('smsenable', '!=', 'Yes')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$client_nonconsented_to_twentyfive_above = Cache::remember('client-nonconsented-to-twentyfive-above', 10, function () {
- return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
- ->where('smsenable', '!=', 'Yes')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$client_nonconsented_uknown_age = Cache::remember('client-nonconsented-uknown-age', 10, function () {
- return Client::select('smsenable')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
- ->where('dob', '=', '')
- ->orWhereNull('dob')
- ->where('smsenable', '!=', 'Yes')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.smsenable')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.dob', '=', '')
+ ->orWhereNull('tbl_client.dob')
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
- // main appointments
- $appointment_honoured = Cache::remember('appointment-honoured', 10, function () {
- return Appointments::select('id')->where('appntmnt_date', '=', 'date_attended')
- ->count();
- });
- // dd($appointment_honoured);
- $appointment_not_honoured = Cache::remember('appointment-not-honoured', 10, function () {
- return Appointments::select('id')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->orwhere('tbl_appointment.app_status', '=', 'LTFU')
- ->orwhere('tbl_appointment.app_status', '=', 'Defaulted')
+ }
+ if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+
+ $all_partners = Partner::where('status', '=', 'Active')->pluck('name', 'id');
+ $client = Client::where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->count('clinic_number');
+
+ $indicator = Indicator::select(['name', 'description'])->get();
+ $appointment = Appointments::select('id')
->count();
- });
+ $missed_appointment = Appointments::select('id')
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->count();
+ // dd($missed_appointment);
+ $active_facilities = PartnerFacility::join('tbl_client', 'tbl_partner_facility.mfl_code', '=', 'tbl_client.mfl_code')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw('COUNT(tbl_partner_facility.mfl_code) as facilities'))
+ ->where('tbl_appointment.created_at', '>=', Carbon::now()->subMonths(6))
+ ->orderBy('tbl_appointment.created_at', 'DESC')
+ ->groupBy('tbl_partner_facility.mfl_code')
+ ->get();
- // appointment honored by gender
- $appointment_honoured_male = Cache::remember('appointment-honoured-male', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->where('tbl_client.gender', '=', '2')
- ->where('tbl_appointment.date_attended', '=', 'tbl_appointment.appntmnt_date')
+
+ // dd($active_facilities);
+ // active clients by gender
+ $clients_male = Client::select('id')->where([['gender', '=', '2'], ['status', '=', 'Active'],])
+ ->whereNull('hei_no')
->count();
- });
- $appointment_honoured_female = Cache::remember('appointment-honoured-female', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->where('tbl_client.gender', '=', '1')
- ->where('tbl_appointment.date_attended', '=', 'tbl_appointment.appntmnt_date')
+
+ $clients_female = Client::where('gender', '=', '1')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
->count();
- });
- $appointment_honoured_uknown_gender = Cache::remember('appointment-honoured-uknown-gender', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->where('tbl_client.gender', '!=', '1')
- ->where('tbl_client.gender', '!=', '2')
- ->where('tbl_appointment.date_attended', '=', 'tbl_appointment.appntmnt_date')
+ $unknown_gender = Client::where('gender', '!=', '1')
+ ->where('gender', '!=', '2')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
->count();
- });
- // appointment honored by age
- $appointment_honored_to_nine = Cache::remember('appointment-honored-to-nine', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.date_attended', '=', 'tbl_appointment.appntmnt_date')
+
+ $client_to_nine = Cache::remember('client_to_nine', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`dob`)) > 0) and ((year(curdate()) - year(`dob`)) <= 9)) then `dob` end)) AS count"))
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
->pluck('count');
});
- $appointment_honored_to_fourteen = Cache::remember('appointment-honored-to-fourteen', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.date_attended', '=', 'tbl_appointment.appntmnt_date')
+
+ $client_to_fourteen = Cache::remember('client-fourteen', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`dob`)) >= 10) and ((year(curdate()) - year(`dob`)) <= 14)) then `dob` end)) AS count"))
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
->pluck('count');
});
- $appointment_honored_to_nineteen = Cache::remember('appointment-honored-to-nineteen', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.date_attended', '=', 'tbl_appointment.appntmnt_date')
+
+ $client_to_nineteen = Cache::remember('client-nineteen', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`dob`)) >= 15) and ((year(curdate()) - year(`dob`)) <= 19)) then `dob` end)) AS count"))
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
->pluck('count');
});
- $appointment_honored_to_twentyfour = Cache::remember('appointment-honored-to-twentyfour', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.date_attended', '=', 'tbl_appointment.appntmnt_date')
+
+ $client_to_twentyfour = Cache::remember('client-twentyfour', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`dob`)) >= 20) and ((year(curdate()) - year(`dob`)) <= 24)) then `id` end)) AS count"))
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
->pluck('count');
});
- $appointment_honored_to_twentyfive_above = Cache::remember('appointment-honored-to-twentyfive_above', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.date_attended', '=', 'tbl_appointment.appntmnt_date')
+
+ $client_to_twentyfive_above = Cache::remember('client-twentyfive-above', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`dob`)) >= 25)) then `id` end)) AS count"))
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
->pluck('count');
});
- $appointment_honored_to_uknown_age = Cache::remember('appointment_honored-to-uknown-age', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select('tbl_client.dob')
- ->where('tbl_client.dob', '=', '')
- ->orWhereNull('tbl_client.dob')
- ->where('tbl_appointment.date_attended', '=', 'tbl_appointment.appntmnt_date')
+
+ $client_unknown_age = Cache::remember('client-unknown-age', 10, function () {
+ return Client::where('dob', '=', '')
+ ->orWhereNull('dob')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
->count();
});
- // appointment not honored by gender
- $appointment_not_honoured_male = Cache::remember('appointment-not-honoured-male', 10, function () {
+ // appointment by gender
+ $appointment_male = Cache::remember('appointment-male', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_appointment.id')
->where('tbl_client.gender', '=', '2')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->orwhere('tbl_appointment.app_status', '=', 'LTFU')
- ->orwhere('tbl_appointment.app_status', '=', 'Defaulted')
->count();
});
- $appointment_not_honoured_female = Cache::remember('appointment-not-honoured-female', 10, function () {
+ $appointment_female = Cache::remember('appointment-female', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_appointment.id')
->where('tbl_client.gender', '=', '1')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->orwhere('tbl_appointment.app_status', '=', 'LTFU')
- ->orwhere('tbl_appointment.app_status', '=', 'Defaulted')
->count();
});
- $appointment_not_honoured_uknown_gender = Cache::remember('appointment-not-honoured-uknown-gender', 10, function () {
+ $appointment_uknown_gender = Cache::remember('appointment-uknown-gender', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_appointment.id')
->where('tbl_client.gender', '!=', '1')
->where('tbl_client.gender', '!=', '2')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->orwhere('tbl_appointment.app_status', '=', 'LTFU')
- ->orwhere('tbl_appointment.app_status', '=', 'Defaulted')
->count();
});
- // appointment not honored by age
- $appointment_not_honored_to_nine = Cache::remember('appointment-not-honored-to-nine', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ // appointment by age
+ $appointment_to_nine = Cache::remember('appointment-to-nine', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->orwhere('tbl_appointment.app_status', '=', 'LTFU')
- ->orwhere('tbl_appointment.app_status', '=', 'Defaulted')
->pluck('count');
});
- $appointment_not_honored_to_fourteen = Cache::remember('appointment-not-honored-to-fourteen', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ $appointment_to_fourteen = Cache::remember('appointment-to-fourteen', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->orwhere('tbl_appointment.app_status', '=', 'LTFU')
- ->orwhere('tbl_appointment.app_status', '=', 'Defaulted')
->pluck('count');
});
- $appointment_not_honored_to_nineteen = Cache::remember('appointment_not_honored_to_nineteen', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ $appointment_to_nineteen = Cache::remember('appointment-to-nineteen', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->orwhere('tbl_appointment.app_status', '=', 'LTFU')
- ->orwhere('tbl_appointment.app_status', '=', 'Defaulted')
->pluck('count');
});
- $appointment_not_honored_to_twentyfour = Cache::remember('appointment_not_honored_to_twentyfour', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ $appointment_to_twentyfour = Cache::remember('appointment-to-twentyfour', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->orwhere('tbl_appointment.app_status', '=', 'LTFU')
- ->orwhere('tbl_appointment.app_status', '=', 'Defaulted')
->pluck('count');
});
- $appointment_not_honored_to_twentyfive_above = Cache::remember('appointment_not_honored_to_twentyfive_above', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ $appointment_to_twentyfive_above = Cache::remember('appointment-to-twentyfive-above', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->orwhere('tbl_appointment.app_status', '=', 'LTFU')
- ->orwhere('tbl_appointment.app_status', '=', 'Defaulted')
->pluck('count');
});
- $appointment_not_honored_to_uknown_age = Cache::remember('appointment_not_honored_to_uknown_age', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select('tbl_client.dob')
+ $appointment_uknown_age = Cache::remember('appointment-uknown-age', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->where('tbl_client.dob', '=', '')
->orWhereNull('tbl_client.dob')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->orwhere('tbl_appointment.app_status', '=', 'LTFU')
- ->orwhere('tbl_appointment.app_status', '=', 'Defaulted')
- ->count();
- });
-
- // missed appointments
-
- $appointment_missed = Cache::remember('appointment_missed', 10, function () {
- return Appointments::where('app_status', '=', 'Missed')
- ->count();
- });
- $appointment_defaulted = Cache::remember('appointment_defaulted', 10, function () {
- return Appointments::where('app_status', '=', 'Defaulted')
- ->count();
- });
- $appointment_lftu = Cache::remember('appointment_lftu', 10, function () {
- return Appointments::where('app_status', '=', 'LTFU')
->count();
});
- // missed appointment by gender
- $appointment_missed_female = Cache::remember('appointment_missed_female', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->where('tbl_appointment.app_status', '=', 'Missed')
+ // Total missed appointment by gender
+ $appointment_total_missed_female = Cache::remember('appointment-total-missed-female', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
->where('tbl_client.gender', '=', '1')
->count();
});
- $appointment_missed_male = Cache::remember('appointment_missed_male', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->where('tbl_appointment.app_status', '=', 'Missed')
+ $appointment_total_missed_male = Cache::remember('appointment-total-missed-male', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
->where('tbl_client.gender', '=', '2')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
->count();
});
- $appointment_missed_uknown_gender = Cache::remember('appointment_missed_uknown_gender', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->where('tbl_appointment.app_status', '=', 'Missed')
+ $appointment_total_missed_uknown_gender = Cache::remember('appointment-total-missed-uknown-gender', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
->where('tbl_client.gender', '!=', '1')
->where('tbl_client.gender', '!=', '2')
->count();
});
- // missed appointment by age
- $appointment_missed_to_nine = Cache::remember('appointment_missed_to_nine', 10, function () {
+
+ // Total missed appointment by age
+ $appointment_total_missed_to_nine = Cache::remember('appointment-total-missed-to-nine', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
->pluck('count');
});
- $appointment_missed_to_fourteen = Cache::remember('appointment_missed_to_fourteen', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
+ $appointment_total_missed_to_fourteen = Cache::remember('appointment-total-missed-to-fourteen', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
->pluck('count');
});
- $appointment_missed_to_nineteen = Cache::remember('appointment_missed_to_nineteen', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
+ $appointment_total_missed_to_nineteen = Cache::remember('appointment-total-missed-to-nineteen', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
->pluck('count');
});
- $appointment_missed_to_twentyfour = Cache::remember('appointment_missed_to_twentyfour', 10, function () {
+ $appointment_total_missed_to_twentyfour = Cache::remember('appointment-total-missed-to-twentyfour', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
->pluck('count');
});
- $appointment_missed_to_twentyfive_above = Cache::remember('appointment_missed_to_twentyfive_above', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
+ $appointment_total_missed_to_twentyfive_above = Cache::remember('appointment-total-missed-to-twentyfive_above', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
->pluck('count');
});
- $appointment_missed_to_uknown_age = Cache::remember('appointment_missed_to_uknown_age', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select('tbl_client.dob')
+ $appointment_total_missed_uknown_age = Cache::remember('appointment-total-missed-uknown-age', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
->where('tbl_client.dob', '=', '')
->orWhereNull('tbl_client.dob')
- ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->count();
+ });
+ // client charts
+ $client_consented = Cache::remember('client-consented', 10, function () {
+ return Client::select('smsenable')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('smsenable', '=', 'Yes')
->count();
});
+ $client_nonconsented = Cache::remember('client-nonconsented', 10, function () {
+ return Client::select('smsenable')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('smsenable', '!=', 'Yes')
+ ->count();
+ });
+ // consented clients by gender
- // defaulted appointment by gender
- $appointment_defaulted_female = Cache::remember('appointment_defaulted_female', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->where('tbl_client.gender', '=', '1')
+ $client_consented_male = Cache::remember('client-consented-male', 10, function () {
+ return Client::where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('gender', '=', '2')
->count();
});
- $appointment_defaulted_male = Cache::remember('appointment_defaulted_male', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->where('tbl_client.gender', '=', '2')
+ $client_consented_female = Cache::remember('client-consented-female', 10, function () {
+ return Client::where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('gender', '=', '1')
->count();
});
- $appointment_defaulted_uknown_gender = Cache::remember('appointment_defaulted_uknown_gender', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->where('tbl_client.gender', '!=', '1')
- ->where('tbl_client.gender', '!=', '2')
+ $client_consented_uknown_gender = Cache::remember('client-consented-uknown-gender', 10, function () {
+ return Client::where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('gender', '!=', '1')
+ ->where('gender', '!=', '2')
->count();
});
-
- // defaulted appointment by age
- $appointment_defaulted_to_nine = Cache::remember('appointment_defaulted_to_nine', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->pluck('count');
+ // non consented clients by gender
+ $client_nonconsented_male = Cache::remember('client-nonconsented-male', 10, function () {
+ return Client::where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('gender', '=', '2')
+ ->count();
});
- $appointment_defaulted_to_fourteen = Cache::remember('appointment_defaulted_to_fourteen', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->pluck('count');
+ $client_nonconsented_female = Cache::remember('client-nonconsented-female', 10, function () {
+ return Client::where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('gender', '=', '1')
+ ->count();
});
- $appointment_defaulted_to_nineteen = Cache::remember('appointment_defaulted_to_nineteen', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->pluck('count');
+ $client_nonconsented_uknown_gender = Cache::remember('client-nonconsented-uknown-gender', 10, function () {
+ return Client::where('smsenable', '!=', 'Yes')
+ ->where('gender', '!=', '1')
+ ->where('gender', '!=', '2')
+ ->count();
});
- $appointment_defaulted_to_twentyfour = Cache::remember('appointment_defaulted_to_twentyfour', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ // consented clients by age distribution
+ $client_consented_to_nine = Cache::remember('client-consented-to-nine', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
->pluck('count');
});
- $appointment_defaulted_to_twentyfive_above = Cache::remember('appointment_defaulted_to_twentyfive_above', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ $client_consented_to_fourteen = Cache::remember('tbl-client', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
->pluck('count');
});
- $appointment_defaulted_to_uknown_age = Cache::remember('appointment_defaulted_to_uknown_age', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select('tbl_client.dob')
- ->where('tbl_client.dob', '=', '')
- ->orWhereNull('tbl_client.dob')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->count();
+ $client_consented_to_nineteen = Cache::remember('client-consented-to-nineteen', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->pluck('count');
});
- // ltfu appointment by gender
- $appointment_ltfu_female = Cache::remember('appointment_ltfu_female', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->where('tbl_client.gender', '=', '1')
- ->count();
+ $client_consented_to_twentyfour = Cache::remember('client-consented-to-twentyfour', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->pluck('count');
});
- $appointment_ltfu_male = Cache::remember('appointment_ltfu_male', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->where('tbl_client.gender', '=', '2')
- ->count();
+ $client_consented_to_twentyfive_above = Cache::remember('client-consented-to-twentyfive-above', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->pluck('count');
});
- $appointment_ltfu_uknown_gender = Cache::remember('appointment_ltfu_uknown_gender', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->where('tbl_client.gender', '!=', '1')
- ->where('tbl_client.gender', '!=', '2')
+ $client_consented_uknown_age = Cache::remember('client-consented-uknown-age', 10, function () {
+ return Client::select('smsenable')
+ ->where('dob', '=', '')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->orWhereNull('dob')
+ ->where('smsenable', '=', 'Yes')
->count();
});
-
- // ltfu appointment by age
- $appointment_ltfu_to_nine = Cache::remember('appointment_ltfu_to_nine', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
+ // non consented clients by age distribution
+ $client_nonconsented_to_nine = Cache::remember('client-nonconsented-to-nine', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
->pluck('count');
});
- $appointment_ltfu_to_fourteen = Cache::remember('appointment_ltfu_to_fourteen', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
+ $client_nonconsented_to_fourteen = Cache::remember('client-nonconsented-to-fourteen', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
->pluck('count');
});
- $appointment_ltfu_to_nineteen = Cache::remember('appointment_ltfu_to_nineteen', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
+ $client_nonconsented_to_nineteen = Cache::remember('client-nonconsented-to-nineteen', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
->pluck('count');
});
- $appointment_ltfu_to_twentyfour = Cache::remember('appointment_ltfu_to_twentyfour', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
+ $client_nonconsented_to_twentyfour = Cache::remember('client-nonconsented-to-twentyfour', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
->pluck('count');
});
- $appointment_ltfu_to_twentyfive_above = Cache::remember('appointment_ltfu_to_twentyfive_above', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
+ $client_nonconsented_to_twentyfive_above = Cache::remember('client-nonconsented-to-twentyfive-above', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
->pluck('count');
});
- $appointment_ltfu_to_uknown_age = Cache::remember('appointment_ltfu_to_uknown_age', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select('tbl_client.dob')
- ->where('tbl_client.dob', '=', '')
- ->orWhereNull('tbl_client.dob')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
+ $client_nonconsented_uknown_age = Cache::remember('client-nonconsented-uknown-age', 10, function () {
+ return Client::select('smsenable')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('dob', '=', '')
+ ->orWhereNull('dob')
+ ->where('smsenable', '!=', 'Yes')
->count();
});
+
+
}
@@ -815,61 +884,412 @@ public function dashboard()
'client_nonconsented_to_nineteen',
'client_nonconsented_to_twentyfour',
'client_nonconsented_to_twentyfive_above',
- 'client_nonconsented_uknown_age',
- 'appointment_honoured',
- 'appointment_not_honoured',
- 'appointment_honoured_male',
- 'appointment_honoured_female',
- 'appointment_honoured_uknown_gender',
- 'appointment_honored_to_nine',
- 'appointment_honored_to_fourteen',
- 'appointment_honored_to_nineteen',
- 'appointment_honored_to_twentyfour',
- 'appointment_honored_to_twentyfive_above',
- 'appointment_honored_to_uknown_age',
- 'appointment_not_honoured_male',
- 'appointment_not_honoured_female',
- 'appointment_not_honoured_uknown_gender',
- 'appointment_not_honored_to_nine',
- 'appointment_not_honored_to_fourteen',
- 'appointment_not_honored_to_nineteen',
- 'appointment_not_honored_to_twentyfour',
- 'appointment_not_honored_to_twentyfive_above',
- 'appointment_not_honored_to_uknown_age',
- 'appointment_missed',
- 'appointment_defaulted',
- 'appointment_lftu',
- 'appointment_missed_female',
- 'appointment_missed_male',
- 'appointment_missed_uknown_gender',
- 'appointment_missed_to_nine',
- 'appointment_missed_to_fourteen',
- 'appointment_missed_to_nineteen',
- 'appointment_missed_to_twentyfour',
- 'appointment_missed_to_twentyfive_above',
- 'appointment_missed_to_uknown_age',
- 'appointment_defaulted_female',
- 'appointment_defaulted_male',
- 'appointment_defaulted_uknown_gender',
- 'appointment_defaulted_to_nine',
- 'appointment_defaulted_to_fourteen',
- 'appointment_defaulted_to_nineteen',
- 'appointment_defaulted_to_twentyfour',
- 'appointment_defaulted_to_twentyfive_above',
- 'appointment_defaulted_to_uknown_age',
- 'appointment_ltfu_female',
- 'appointment_ltfu_male',
- 'appointment_ltfu_uknown_gender',
- 'appointment_ltfu_to_nine',
- 'appointment_ltfu_to_fourteen',
- 'appointment_ltfu_to_nineteen',
- 'appointment_ltfu_to_twentyfour',
- 'appointment_ltfu_to_twentyfive_above',
- 'appointment_ltfu_to_uknown_age'
+ 'client_nonconsented_uknown_age'
));
}
+ public function appointment_charts()
+ {
+ if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+ $all_partners = Partner::where('status', '=', 'Active')->pluck('name', 'id');
+ // main appointments
+ $appointment = Appointments::select('id')
+ ->count();
+ $appointment_honoured = Cache::remember('appointment-honoured', 10, function () {
+ return Appointments::select(\DB::raw("COUNT(id) as count"))
+ ->where('date_attended', '=', DB::raw('appntmnt_date'))
+ ->pluck('count');
+ });
+ // dd($appointment_honoured);
+ $appointment_not_honoured = Cache::remember('appointment-not-honoured', 10, function () {
+ return Appointments::select(\DB::raw("COUNT(id) as count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->pluck('count');
+ });
+
+ // appointment honored by gender
+ $appointment_honoured_male = Cache::remember('appointment-honoured-male', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("COUNT(tbl_appointment.id) as count"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_client.gender', '=', '2')
+ ->pluck('count');
+ });
+ $appointment_honoured_female = Cache::remember('appointment-honoured-female', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_client.gender', '=', '1')
+ ->count();
+ });
+ $appointment_honoured_uknown_gender = Cache::remember('appointment-honoured-uknown-gender', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->count();
+ });
+ // appointment honored by age
+ $appointment_honored_to_nine = Cache::remember('appointment-honored-to-nine', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->pluck('count');
+ });
+ $appointment_honored_to_fourteen = Cache::remember('appointment-honored-to-fourteen', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->pluck('count');
+ });
+ $appointment_honored_to_nineteen = Cache::remember('appointment-honored-to-nineteen', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->pluck('count');
+ });
+ $appointment_honored_to_twentyfour = Cache::remember('appointment-honored-to-twentyfour', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->pluck('count');
+ });
+ $appointment_honored_to_twentyfive_above = Cache::remember('appointment-honored-to-twentyfive_above', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->pluck('count');
+ });
+ $appointment_honored_to_uknown_age = Cache::remember('appointment_honored-to-uknown-age', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_client.dob')
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_client.dob', '=', '')
+ ->orWhereNull('tbl_client.dob')
+ ->count();
+ });
+
+ // appointment not honored by gender
+ $appointment_not_honoured_male = Cache::remember('appointment-not-honoured-male', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_client.gender', '=', '2')
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->count();
+ });
+ $appointment_not_honoured_female = Cache::remember('appointment-not-honoured-female', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_client.gender', '=', '1')
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->count();
+ });
+ $appointment_not_honoured_uknown_gender = Cache::remember('appointment-not-honoured-uknown-gender', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->count();
+ });
+ // appointment not honored by age
+ $appointment_not_honored_to_nine = Cache::remember('appointment-not-honored-to-nine', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->pluck('count');
+ });
+ $appointment_not_honored_to_fourteen = Cache::remember('appointment-not-honored-to-fourteen', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->pluck('count');
+ });
+ $appointment_not_honored_to_nineteen = Cache::remember('appointment_not_honored_to_nineteen', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->pluck('count');
+ });
+ $appointment_not_honored_to_twentyfour = Cache::remember('appointment_not_honored_to_twentyfour', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->pluck('count');
+ });
+ $appointment_not_honored_to_twentyfive_above = Cache::remember('appointment_not_honored_to_twentyfive_above', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->pluck('count');
+ });
+ $appointment_not_honored_to_uknown_age = Cache::remember('appointment_not_honored_to_uknown_age', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_client.dob')
+ ->where('tbl_client.dob', '=', '')
+ ->orWhereNull('tbl_client.dob')
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->count();
+ });
+
+ // missed appointments
+
+ $appointment_missed = Cache::remember('appointment_missed', 10, function () {
+ return Appointments::where('app_status', '=', 'Missed')
+ ->count();
+ });
+ $appointment_defaulted = Cache::remember('appointment_defaulted', 10, function () {
+ return Appointments::where('app_status', '=', 'Defaulted')
+ ->count();
+ });
+ $appointment_lftu = Cache::remember('appointment_lftu', 10, function () {
+ return Appointments::where('app_status', '=', 'LTFU')
+ ->count();
+ });
+
+ // missed appointment by gender
+ $appointment_missed_female = Cache::remember('appointment_missed_female', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.gender', '=', '1')
+ ->count();
+ });
+ $appointment_missed_male = Cache::remember('appointment_missed_male', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.gender', '=', '2')
+ ->count();
+ });
+ $appointment_missed_uknown_gender = Cache::remember('appointment_missed_uknown_gender', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->count();
+ });
+ // missed appointment by age
+ $appointment_missed_to_nine = Cache::remember('appointment_missed_to_nine', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->pluck('count');
+ });
+ $appointment_missed_to_fourteen = Cache::remember('appointment_missed_to_fourteen', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->pluck('count');
+ });
+ $appointment_missed_to_nineteen = Cache::remember('appointment_missed_to_nineteen', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->pluck('count');
+ });
+ $appointment_missed_to_twentyfour = Cache::remember('appointment_missed_to_twentyfour', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->pluck('count');
+ });
+ $appointment_missed_to_twentyfive_above = Cache::remember('appointment_missed_to_twentyfive_above', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->pluck('count');
+ });
+ $appointment_missed_to_uknown_age = Cache::remember('appointment_missed_to_uknown_age', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_client.dob')
+ ->where('tbl_client.dob', '=', '')
+ ->orWhereNull('tbl_client.dob')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->count();
+ });
+
+ // defaulted appointment by gender
+ $appointment_defaulted_female = Cache::remember('appointment_defaulted_female', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.gender', '=', '1')
+ ->count();
+ });
+ $appointment_defaulted_male = Cache::remember('appointment_defaulted_male', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.gender', '=', '2')
+ ->count();
+ });
+ $appointment_defaulted_uknown_gender = Cache::remember('appointment_defaulted_uknown_gender', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->count();
+ });
+
+ // defaulted appointment by age
+ $appointment_defaulted_to_nine = Cache::remember('appointment_defaulted_to_nine', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->pluck('count');
+ });
+ $appointment_defaulted_to_fourteen = Cache::remember('appointment_defaulted_to_fourteen', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->pluck('count');
+ });
+ $appointment_defaulted_to_nineteen = Cache::remember('appointment_defaulted_to_nineteen', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->pluck('count');
+ });
+ $appointment_defaulted_to_twentyfour = Cache::remember('appointment_defaulted_to_twentyfour', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->pluck('count');
+ });
+ $appointment_defaulted_to_twentyfive_above = Cache::remember('appointment_defaulted_to_twentyfive_above', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->pluck('count');
+ });
+ $appointment_defaulted_to_uknown_age = Cache::remember('appointment_defaulted_to_uknown_age', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_client.dob')
+ ->where('tbl_client.dob', '=', '')
+ ->orWhereNull('tbl_client.dob')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->count();
+ });
+ // ltfu appointment by gender
+ $appointment_ltfu_female = Cache::remember('appointment_ltfu_female', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.gender', '=', '1')
+ ->count();
+ });
+ $appointment_ltfu_male = Cache::remember('appointment_ltfu_male', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.gender', '=', '2')
+ ->count();
+ });
+ $appointment_ltfu_uknown_gender = Cache::remember('appointment_ltfu_uknown_gender', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->count();
+ });
+
+ // ltfu appointment by age
+ $appointment_ltfu_to_nine = Cache::remember('appointment_ltfu_to_nine', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->pluck('count');
+ });
+ $appointment_ltfu_to_fourteen = Cache::remember('appointment_ltfu_to_fourteen', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->pluck('count');
+ });
+ $appointment_ltfu_to_nineteen = Cache::remember('appointment_ltfu_to_nineteen', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->pluck('count');
+ });
+ $appointment_ltfu_to_twentyfour = Cache::remember('appointment_ltfu_to_twentyfour', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->pluck('count');
+ });
+ $appointment_ltfu_to_twentyfive_above = Cache::remember('appointment_ltfu_to_twentyfive_above', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->pluck('count');
+ });
+ $appointment_ltfu_to_uknown_age = Cache::remember('appointment_ltfu_to_uknown_age', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_client.dob')
+ ->where('tbl_client.dob', '=', '')
+ ->orWhereNull('tbl_client.dob')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->count();
+ });
+ }
+
+
+ return view('new_dashboard.appointment_dashboard', compact('all_partners', 'appointment', 'appointment_honoured',
+ 'appointment_not_honoured',
+ 'appointment_honoured_male',
+ 'appointment_honoured_female',
+ 'appointment_honoured_uknown_gender',
+ 'appointment_honored_to_nine',
+ 'appointment_honored_to_fourteen',
+ 'appointment_honored_to_nineteen',
+ 'appointment_honored_to_twentyfour',
+ 'appointment_honored_to_twentyfive_above',
+ 'appointment_honored_to_uknown_age',
+ 'appointment_not_honoured_male',
+ 'appointment_not_honoured_female',
+ 'appointment_not_honoured_uknown_gender',
+ 'appointment_not_honored_to_nine',
+ 'appointment_not_honored_to_fourteen',
+ 'appointment_not_honored_to_nineteen',
+ 'appointment_not_honored_to_twentyfour',
+ 'appointment_not_honored_to_twentyfive_above',
+ 'appointment_not_honored_to_uknown_age',
+ 'appointment_missed',
+ 'appointment_defaulted',
+ 'appointment_lftu',
+ 'appointment_missed_female',
+ 'appointment_missed_male',
+ 'appointment_missed_uknown_gender',
+ 'appointment_missed_to_nine',
+ 'appointment_missed_to_fourteen',
+ 'appointment_missed_to_nineteen',
+ 'appointment_missed_to_twentyfour',
+ 'appointment_missed_to_twentyfive_above',
+ 'appointment_missed_to_uknown_age',
+ 'appointment_defaulted_female',
+ 'appointment_defaulted_male',
+ 'appointment_defaulted_uknown_gender',
+ 'appointment_defaulted_to_nine',
+ 'appointment_defaulted_to_fourteen',
+ 'appointment_defaulted_to_nineteen',
+ 'appointment_defaulted_to_twentyfour',
+ 'appointment_defaulted_to_twentyfive_above',
+ 'appointment_defaulted_to_uknown_age',
+ 'appointment_ltfu_female',
+ 'appointment_ltfu_male',
+ 'appointment_ltfu_uknown_gender',
+ 'appointment_ltfu_to_nine',
+ 'appointment_ltfu_to_fourteen',
+ 'appointment_ltfu_to_nineteen',
+ 'appointment_ltfu_to_twentyfour',
+ 'appointment_ltfu_to_twentyfive_above',
+ 'appointment_ltfu_to_uknown_age'
+ ));
+ }
+
public function filter_charts(Request $request)
{
// $data = [];
diff --git a/app/Http/Controllers/SMSReportController.php b/app/Http/Controllers/SMSReportController.php
index d693dfd..51da299 100644
--- a/app/Http/Controllers/SMSReportController.php
+++ b/app/Http/Controllers/SMSReportController.php
@@ -21,7 +21,8 @@ public function success_sms()
$all_partners = Partner::where('status', '=', 'Active')->pluck('name', 'id');
$delivered_partners = ClientOutgoing::join('tbl_client', 'tbl_clnt_outgoing.clnt_usr_id', '=', 'tbl_client.id')
- ->join('tbl_partner', 'tbl_client.partner_id', '=', 'tbl_partner.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->join('tbl_partner', 'tbl_partner_facility.partner_id', '=', 'tbl_partner.id')
->select('tbl_partner.name', DB::raw('count(tbl_clnt_outgoing.callback_status) as total'))
->where('tbl_clnt_outgoing.callback_status', '=', 'Success')
->groupBy('tbl_partner.name')
@@ -29,14 +30,16 @@ public function success_sms()
->get();
// dd($delivered_partners);
$failed_partners = ClientOutgoing::join('tbl_client', 'tbl_clnt_outgoing.clnt_usr_id', '=', 'tbl_client.id')
- ->join('tbl_partner', 'tbl_client.partner_id', '=', 'tbl_partner.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->join('tbl_partner', 'tbl_partner_facility.partner_id', '=', 'tbl_partner.id')
->select('tbl_partner.name', DB::raw('count(tbl_clnt_outgoing.callback_status) as total'))
->where('tbl_clnt_outgoing.callback_status', '=', 'Failed')
->groupBy('tbl_partner.name')
->get();
$cost_partners = ClientOutgoing::join('tbl_client', 'tbl_clnt_outgoing.clnt_usr_id', '=', 'tbl_client.id')
- ->join('tbl_partner', 'tbl_client.partner_id', '=', 'tbl_partner.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->join('tbl_partner', 'tbl_partner_facility.partner_id', '=', 'tbl_partner.id')
->select('tbl_partner.name', DB::raw("ROUND(SUM(SUBSTRING(tbl_clnt_outgoing.cost, 5)), 0) as total_cost"))
->groupBy('tbl_partner.name')
->get();
diff --git a/resources/views/new_dashboard/appointment_dashboard.blade.php b/resources/views/new_dashboard/appointment_dashboard.blade.php
new file mode 100644
index 0000000..5f89b79
--- /dev/null
+++ b/resources/views/new_dashboard/appointment_dashboard.blade.php
@@ -0,0 +1,928 @@
+@extends('layouts.master')
+@section('page-css')
+
+@endsection
+
+@section('main-content')
+
+@if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Partner' || Auth::user()->access_level == 'Donor')
+
+
+
-
-
-
-
-
-
-
Appointments
-
-
{{$appointment}}
-
-
-
-
-
-
-
-
-
-
Honored
-
-
{{$appointment_honoured}}
-
-
-
-
-
-
-
-
-
-
Not Honored
-
-
{{$appointment_not_honoured}}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Total Missed
-
{{$appointment_not_honoured}}
-
-
-
-
-
-
-
-
-
-
Missed
-
-
{{$appointment_missed}}
-
-
-
-
-
-
-
-
-
-
Defaulted
-
-
{{$appointment_defaulted}}
-
-
-
-
-
-
-
-
-
Lost To Follow Up
-
-
{{$appointment_lftu}}
-
-
-
-
-
-
-
-
-
-
@@ -538,54 +375,6 @@
var Client_nonconsented_uknown_age = ;
- var Appointment_honoured_male = ;
- var Appointment_honoured_female = ;
- var Appointment_honoured_uknown_gender = ;
- var Appointment_honored_to_nine = ;
- var Appointment_honored_to_fourteen = ;
- var Appointment_honored_to_nineteen = ;
- var Appointment_honored_to_twentyfour = ;
- var Appointment_honored_to_twentyfive_above = ;
- var Appointment_honored_to_uknown_age = ;
- var Appointment_not_honoured_male = ;
- var Appointment_not_honoured_female = ;
- var Appointment_not_honoured_uknown_gender = ;
- var Appointment_not_honored_to_nine = ;
- var Appointment_not_honored_to_fourteen = ;
- var Appointment_not_honored_to_nineteen = ;
- var Appointment_not_honored_to_twentyfour = ;
- var Appointment_not_honored_to_twentyfive_above = ;
- var Appointment_not_honored_to_uknown_age = ;
-
-
- var Appointment_missed_male = ;
- var Appointment_missed_female = ;
- var Appointment_missed_uknown_gender = ;
- var Appointment_missed_to_nine = ;
- var Appointment_missed_to_fourteen = ;
- var Appointment_missed_to_nineteen = ;
- var Appointment_missed_to_twentyfour = ;
- var Appointment_missed_to_twentyfive_above = ;
- var Appointment_missed_to_uknown_age = ;
- var Appointment_defaulted_female = ;
- var Appointment_defaulted_male = ;
- var Appointment_defaulted_uknown_gender = ;
- var Appointment_defaulted_to_nine = ;
- var Appointment_defaulted_to_fourteen = ;
- var Appointment_defaulted_to_nineteen = ;
- var Appointment_defaulted_to_twentyfour = ;
- var Appointment_defaulted_to_twentyfive_above = ;
- var Appointment_defaulted_to_uknown_age = ;
- var Appointment_ltfu_female = ;
- var Appointment_ltfu_male = ;
- var Appointment_ltfu_uknown_gender = ;
- var Appointment_ltfu_to_nine = ;
- var Appointment_ltfu_to_fourteen = ;
- var Appointment_ltfu_to_nineteen = ;
- var Appointment_ltfu_to_twentyfour = ;
- var Appointment_ltfu_to_twentyfive_above = ;
- var Appointment_ltfu_to_uknown_age = ;
-
$(document).ready(function() {
$('select[name="partner"]').on('change', function() {
@@ -1139,449 +928,7 @@
});
- //APPOINTMENT HONOURED GENDER
- var appChart = Highcharts.chart('appointment_honoured_gender', {
- chart: {
- type: 'column'
- },
- title: {
- text: 'Appointment Honoured By Gender'
- },
- xAxis: {
- categories: ['Male', 'Female', 'UKNOWN Gender']
- },
- yAxis: {
- min: 0,
- title: {
- text: 'No of Appointment Honoured'
- },
- stackLabels: {
- enabled: true,
- style: {
- fontWeight: 'bold',
- color: ( // theme
- Highcharts.defaultOptions.title.style &&
- Highcharts.defaultOptions.title.style.color
- ) || 'gray'
- }
- }
- },
- tooltip: {
- formatter: function() {
- return '
' + this.x + '' +
- this.series.name + ': ' + this.y;
- }
- },
- plotOptions: {
- column: {
- stacking: 'normal',
- }
- },
- series: [{
- name: 'Gender',
- data: [Appointment_honoured_male, Appointment_honoured_female, Appointment_honoured_uknown_gender]
- }],
-
- });
-// APPOINTMENT HONOURED AGE
- var appChart = Highcharts.chart('appointment_honoured_age', {
- chart: {
- type: 'column'
- },
- title: {
- text: 'Appointment Honoured By Age'
- },
- xAxis: {
- categories: ['0-9 YRS', '10-14 YRS', '15-19 YRS', '20-24 YRS', '25+ YRS', 'UKNOWN AGE']
- },
- yAxis: {
- min: 0,
- title: {
- text: 'No of Appointment Honoured'
- },
- stackLabels: {
- enabled: true,
- style: {
- fontWeight: 'bold',
- color: ( // theme
- Highcharts.defaultOptions.title.style &&
- Highcharts.defaultOptions.title.style.color
- ) || 'gray'
- }
- }
- },
- tooltip: {
- formatter: function() {
- return '
' + this.x + '' +
- this.series.name + ': ' + this.y;
- }
- },
- plotOptions: {
- column: {
- stacking: 'normal',
- }
- },
- series: [{
- name: 'Age',
- data: [Appointment_honored_to_nine, Appointment_honored_to_fourteen, Appointment_honored_to_nineteen, Appointment_honored_to_twentyfour, Appointment_honored_to_twentyfive_above, Appointment_honored_to_uknown_age]
- }],
-
- });
-
- //APPOINTMENT NOT HONOURED GENDER
- var appChart = Highcharts.chart('appointment_not_honoured_gender', {
- chart: {
- type: 'column'
- },
- title: {
- text: 'Appointment Not Honoured By Gender'
- },
- xAxis: {
- categories: ['Male', 'Female', 'UKNOWN Gender']
- },
- yAxis: {
- min: 0,
- title: {
- text: 'No of Appointment Not Honoured'
- },
- stackLabels: {
- enabled: true,
- style: {
- fontWeight: 'bold',
- color: ( // theme
- Highcharts.defaultOptions.title.style &&
- Highcharts.defaultOptions.title.style.color
- ) || 'gray'
- }
- }
- },
- tooltip: {
- formatter: function() {
- return '
' + this.x + '' +
- this.series.name + ': ' + this.y;
- }
- },
- plotOptions: {
- column: {
- stacking: 'normal',
- }
- },
- series: [{
- name: 'Gender',
- data: [Appointment_not_honoured_male, Appointment_not_honoured_female, Appointment_not_honoured_uknown_gender]
- }],
- });
-// APPOINTMENT NOT HONOURED AGE
- var appChart = Highcharts.chart('appointment_not_honoured_age', {
- chart: {
- type: 'column'
- },
- title: {
- text: 'Appointment Not Honoured By Age'
- },
- xAxis: {
- categories: ['0-9 YRS', '10-14 YRS', '15-19 YRS', '20-24 YRS', '25+ YRS', 'UKNOWN AGE']
- },
- yAxis: {
- min: 0,
- title: {
- text: 'No of Appointment Not Honoured'
- },
- stackLabels: {
- enabled: true,
- style: {
- fontWeight: 'bold',
- color: ( // theme
- Highcharts.defaultOptions.title.style &&
- Highcharts.defaultOptions.title.style.color
- ) || 'gray'
- }
- }
- },
- tooltip: {
- formatter: function() {
- return '
' + this.x + '' +
- this.series.name + ': ' + this.y;
- }
- },
- plotOptions: {
- column: {
- stacking: 'normal',
- }
- },
- series: [{
- name: 'Age',
- data: [Appointment_not_honored_to_nine, Appointment_not_honored_to_fourteen, Appointment_not_honored_to_nineteen, Appointment_not_honored_to_twentyfour, Appointment_not_honored_to_twentyfive_above, Appointment_not_honored_to_uknown_age]
- }],
-
- });
-
- //MISSED APPOINTMENT BY GENDER
- var appChart = Highcharts.chart('appointment_missed_gender', {
- chart: {
- type: 'column'
- },
- title: {
- text: 'Appointment Missed By Gender'
- },
- xAxis: {
- categories: ['Male', 'Female', 'UKNOWN Gender']
- },
- yAxis: {
- min: 0,
- title: {
- text: 'No of Appointment Missed'
- },
- stackLabels: {
- enabled: true,
- style: {
- fontWeight: 'bold',
- color: ( // theme
- Highcharts.defaultOptions.title.style &&
- Highcharts.defaultOptions.title.style.color
- ) || 'gray'
- }
- }
- },
- tooltip: {
- formatter: function() {
- return '
' + this.x + '' +
- this.series.name + ': ' + this.y;
- }
- },
- plotOptions: {
- column: {
- stacking: 'normal',
- }
- },
- series: [{
- name: 'Gender',
- data: [Appointment_missed_male, Appointment_missed_female, Appointment_missed_uknown_gender]
- }],
-
- });
-// APPOINTMENT MISSED AGE
- var appChart = Highcharts.chart('appointment_missed_age', {
- chart: {
- type: 'column'
- },
- title: {
- text: 'Appointment Missed By Age'
- },
- xAxis: {
- categories: ['0-9 YRS', '10-14 YRS', '15-19 YRS', '20-24 YRS', '25+ YRS', 'UKNOWN AGE']
- },
- yAxis: {
- min: 0,
- title: {
- text: 'No of Appointment Missed'
- },
- stackLabels: {
- enabled: true,
- style: {
- fontWeight: 'bold',
- color: ( // theme
- Highcharts.defaultOptions.title.style &&
- Highcharts.defaultOptions.title.style.color
- ) || 'gray'
- }
- }
- },
- tooltip: {
- formatter: function() {
- return '
' + this.x + '' +
- this.series.name + ': ' + this.y;
- }
- },
- plotOptions: {
- column: {
- stacking: 'normal',
- }
- },
- series: [{
- name: 'Age',
- data: [Appointment_missed_to_nine, Appointment_missed_to_fourteen, Appointment_missed_to_nineteen, Appointment_missed_to_twentyfour, Appointment_missed_to_twentyfive_above, Appointment_missed_to_uknown_age]
- }],
-
- });
- //DEFAULTED APPOINTMENT BY GENDER
- var appChart = Highcharts.chart('appointment_defaulted_gender', {
- chart: {
- type: 'column'
- },
- title: {
- text: 'Appointment Defaulted By Gender'
- },
- xAxis: {
- categories: ['Male', 'Female', 'UKNOWN Gender']
- },
- yAxis: {
- min: 0,
- title: {
- text: 'No of Appointment Defaulted'
- },
- stackLabels: {
- enabled: true,
- style: {
- fontWeight: 'bold',
- color: ( // theme
- Highcharts.defaultOptions.title.style &&
- Highcharts.defaultOptions.title.style.color
- ) || 'gray'
- }
- }
- },
- tooltip: {
- formatter: function() {
- return '
' + this.x + '' +
- this.series.name + ': ' + this.y;
- }
- },
- plotOptions: {
- column: {
- stacking: 'normal',
- }
- },
- series: [{
- name: 'Gender',
- data: [Appointment_defaulted_male, Appointment_defaulted_female, Appointment_defaulted_uknown_gender]
- }],
-
- });
-// APPOINTMENT DEFAULTED AGE
- var appChart = Highcharts.chart('appointment_defaulted_age', {
- chart: {
- type: 'column'
- },
- title: {
- text: 'Appointment Defaulted By Age'
- },
- xAxis: {
- categories: ['0-9 YRS', '10-14 YRS', '15-19 YRS', '20-24 YRS', '25+ YRS', 'UKNOWN AGE']
- },
- yAxis: {
- min: 0,
- title: {
- text: 'No of Appointment Defaulted'
- },
- stackLabels: {
- enabled: true,
- style: {
- fontWeight: 'bold',
- color: ( // theme
- Highcharts.defaultOptions.title.style &&
- Highcharts.defaultOptions.title.style.color
- ) || 'gray'
- }
- }
- },
- tooltip: {
- formatter: function() {
- return '
' + this.x + '' +
- this.series.name + ': ' + this.y;
- }
- },
- plotOptions: {
- column: {
- stacking: 'normal',
- }
- },
- series: [{
- name: 'Age',
- data: [Appointment_defaulted_to_nine, Appointment_defaulted_to_fourteen, Appointment_defaulted_to_nineteen, Appointment_defaulted_to_twentyfour, Appointment_defaulted_to_twentyfive_above, Appointment_defaulted_to_uknown_age]
- }],
-
- });
-
- //LTFU APPOINTMENT BY GENDER
- var appChart = Highcharts.chart('appointment_ltfu_gender', {
- chart: {
- type: 'column'
- },
- title: {
- text: 'Appointment LTFU By Gender'
- },
- xAxis: {
- categories: ['Male', 'Female', 'UKNOWN Gender']
- },
- yAxis: {
- min: 0,
- title: {
- text: 'No of Appointment LTFU'
- },
- stackLabels: {
- enabled: true,
- style: {
- fontWeight: 'bold',
- color: ( // theme
- Highcharts.defaultOptions.title.style &&
- Highcharts.defaultOptions.title.style.color
- ) || 'gray'
- }
- }
- },
- tooltip: {
- formatter: function() {
- return '
' + this.x + '' +
- this.series.name + ': ' + this.y;
- }
- },
- plotOptions: {
- column: {
- stacking: 'normal',
- }
- },
- series: [{
- name: 'Gender',
- data: [Appointment_ltfu_male, Appointment_ltfu_female, Appointment_ltfu_uknown_gender]
- }],
-
- });
-// APPOINTMENT LTFU AGE
- var appChart = Highcharts.chart('appointment_lftu_age', {
- chart: {
- type: 'column'
- },
- title: {
- text: 'Appointment LTFU By Age'
- },
- xAxis: {
- categories: ['0-9 YRS', '10-14 YRS', '15-19 YRS', '20-24 YRS', '25+ YRS', 'UKNOWN AGE']
- },
- yAxis: {
- min: 0,
- title: {
- text: 'No of Appointment LTFU'
- },
- stackLabels: {
- enabled: true,
- style: {
- fontWeight: 'bold',
- color: ( // theme
- Highcharts.defaultOptions.title.style &&
- Highcharts.defaultOptions.title.style.color
- ) || 'gray'
- }
- }
- },
- tooltip: {
- formatter: function() {
- return '
' + this.x + '' +
- this.series.name + ': ' + this.y;
- }
- },
- plotOptions: {
- column: {
- stacking: 'normal',
- }
- },
- series: [{
- name: 'Age',
- data: [Appointment_ltfu_to_nine, Appointment_ltfu_to_fourteen, Appointment_ltfu_to_nineteen, Appointment_ltfu_to_twentyfour, Appointment_ltfu_to_twentyfive_above, Appointment_ltfu_to_uknown_age]
- }],
-
- });
var colors = Highcharts.getOptions().colors;
diff --git a/routes/web.php b/routes/web.php
index 52fa307..8c669f7 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -200,5 +200,6 @@
// new dashbaord routes
Route::get('/admin/dashboard', ['uses' => 'App\Http\Controllers\NewDashboardController@dashboard', 'as' => 'dashboard']);
+ Route::get('/admin/appointment/dashboard', ['uses' => 'App\Http\Controllers\NewDashboardController@appointment_charts', 'as' => 'appointment_charts']);
Route::get('/filter_charts', ['uses' => 'App\Http\Controllers\NewDashboardController@filter_charts', 'as' => 'filter_charts']);
});
From ace53f3262e76e61b6fc06d1820da6b744fd5047 Mon Sep 17 00:00:00 2001
From: Ronald-pro <36841157+Ronald-pro@users.noreply.github.com>
Date: Thu, 28 Apr 2022 08:24:11 +0300
Subject: [PATCH 027/241] added filters
---
config/app.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/config/app.php b/config/app.php
index b797cff..608bad4 100644
--- a/config/app.php
+++ b/config/app.php
@@ -175,7 +175,7 @@
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
Maatwebsite\Excel\ExcelServiceProvider::class,
- Barryvdh\Debugbar\ServiceProvider::class,
+ // Barryvdh\Debugbar\ServiceProvider::class,
// MaddHatter\LaravelFullcalendar\ServiceProvider::class,
From 299c4a4d37b480701754f4f8e4efb4eb4573b22e Mon Sep 17 00:00:00 2001
From: Ronald-pro <36841157+Ronald-pro@users.noreply.github.com>
Date: Sat, 30 Apr 2022 17:12:52 +0300
Subject: [PATCH 028/241] adjustment on main dashboard and client dashboard
filters
---
.../Controllers/NewDashboardController.php | 3287 ++++++++++++-----
app/Models/Appointments.php | 2 +-
app/Models/Client.php | 4 +
config/app.php | 2 +-
.../appointment_dashboard.blade.php | 16 +-
.../new_dashboard/main_dashbaord.blade.php | 137 +-
6 files changed, 2553 insertions(+), 895 deletions(-)
diff --git a/app/Http/Controllers/NewDashboardController.php b/app/Http/Controllers/NewDashboardController.php
index e440dfa..3e940e3 100644
--- a/app/Http/Controllers/NewDashboardController.php
+++ b/app/Http/Controllers/NewDashboardController.php
@@ -26,33 +26,28 @@ public function dashboard()
// showing all the active clients, all appointments, missed appointments
if (Auth::user()->access_level == 'Facility') {
-
- }
- if (Auth::user()->access_level == 'Partner') {
$all_partners = Partner::where('status', '=', 'Active')->pluck('name', 'id');
- $client = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.status', '=', 'Active')
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
- ->count('tbl_client.clinic_number');
+ $client = Client::where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->count('clinic_number');
$indicator = Indicator::select(['name', 'description'])->get();
$appointment = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select('tbl_appointment.id')
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
- ->count();
- $missed_appointment = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select('tbl_appointment.id')
- ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)
->count();
+ $missed_appointment = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_appointment.id')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)
+ ->count();
$active_facilities = PartnerFacility::join('tbl_client', 'tbl_partner_facility.mfl_code', '=', 'tbl_client.mfl_code')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw('COUNT(tbl_partner_facility.mfl_code) as facilities'))
+ ->select('tbl_partner_facility.mfl_code')
->where('tbl_appointment.created_at', '>=', Carbon::now()->subMonths(6))
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->orderBy('tbl_appointment.created_at', 'DESC')
->groupBy('tbl_partner_facility.mfl_code')
->get();
@@ -60,78 +55,69 @@ public function dashboard()
// dd($active_facilities);
// active clients by gender
- $clients_male = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select('id')->where([['tbl_client.gender', '=', '2'], ['tbl_client.status', '=', 'Active'],])
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ $clients_male = Client::select('id')->where([['gender', '=', '2'], ['status', '=', 'Active'],])
+ ->whereNull('hei_no')
+ ->where('mfl_code', Auth::user()->facility_id)
->count();
- $clients_female = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.gender', '=', '1')
- ->where('tbl_client.status', '=', 'Active')
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ $clients_female = Client::where('gender', '=', '1')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('mfl_code', Auth::user()->facility_id)
->count();
- $unknown_gender = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.gender', '!=', '1')
- ->where('tbl_client.gender', '!=', '2')
- ->where('tbl_client.status', '=', 'Active')
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ $unknown_gender = Client::where('gender', '!=', '1')
+ ->where('gender', '!=', '2')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('mfl_code', Auth::user()->facility_id)
->count();
$client_to_nine = Cache::remember('client_to_nine', 10, function () {
- return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`dob` end)) AS count"))
- ->where('tbl_client.status', '=', 'Active')
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`dob`)) > 0) and ((year(curdate()) - year(`dob`)) <= 9)) then `dob` end)) AS count"))
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('mfl_code', Auth::user()->facility_id)
->pluck('count');
});
$client_to_fourteen = Cache::remember('client-fourteen', 10, function () {
- return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`dob` end)) AS count"))
- ->where('tbl_client.status', '=', 'Active')
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`dob`)) >= 10) and ((year(curdate()) - year(`dob`)) <= 14)) then `dob` end)) AS count"))
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('mfl_code', Auth::user()->facility_id)
->pluck('count');
});
$client_to_nineteen = Cache::remember('client-nineteen', 10, function () {
- return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`dob` end)) AS count"))
- ->where('tbl_client.status', '=', 'Active')
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`dob`)) >= 15) and ((year(curdate()) - year(`dob`)) <= 19)) then `dob` end)) AS count"))
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('mfl_code', Auth::user()->facility_id)
->pluck('count');
});
$client_to_twentyfour = Cache::remember('client-twentyfour', 10, function () {
- return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`dob` end)) AS count"))
- ->where('tbl_client.status', '=', 'Active')
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`dob`)) >= 20) and ((year(curdate()) - year(`dob`)) <= 24)) then `id` end)) AS count"))
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('mfl_code', Auth::user()->facility_id)
->pluck('count');
});
$client_to_twentyfive_above = Cache::remember('client-twentyfive-above', 10, function () {
- return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`dob` end)) AS count"))
- ->where('tbl_client.status', '=', 'Active')
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`dob`)) >= 25)) then `id` end)) AS count"))
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('mfl_code', Auth::user()->facility_id)
->pluck('count');
});
$client_unknown_age = Cache::remember('client-unknown-age', 10, function () {
- return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.dob', '=', '')
- ->orWhereNull('tbl_client.dob')
- ->where('tbl_client.status', '=', 'Active')
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ return Client::where('dob', '=', '')
+ ->orWhereNull('dob')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('mfl_code', Auth::user()->facility_id)
->count();
});
@@ -141,7 +127,7 @@ public function dashboard()
->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select('tbl_appointment.id')
->where('tbl_client.gender', '=', '2')
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)
->count();
});
$appointment_female = Cache::remember('appointment-female', 10, function () {
@@ -149,7 +135,7 @@ public function dashboard()
->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select('tbl_appointment.id')
->where('tbl_client.gender', '=', '1')
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)
->count();
});
$appointment_uknown_gender = Cache::remember('appointment-uknown-gender', 10, function () {
@@ -158,422 +144,434 @@ public function dashboard()
->select('tbl_appointment.id')
->where('tbl_client.gender', '!=', '1')
->where('tbl_client.gender', '!=', '2')
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)
->count();
});
// appointment by age
$appointment_to_nine = Cache::remember('appointment-to-nine', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+ });
+ $appointment_to_fourteen = Cache::remember('appointment-to-fourteen', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+ });
+ $appointment_to_nineteen = Cache::remember('appointment-to-nineteen', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+ });
+ $appointment_to_twentyfour = Cache::remember('appointment-to-twentyfour', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+ });
+ $appointment_to_twentyfive_above = Cache::remember('appointment-to-twentyfive-above', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+ });
+
+ $appointment_uknown_age = Cache::remember('appointment-uknown-age', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.dob', '=', '')
+ ->orWhereNull('tbl_client.dob')
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)
+ ->count();
+ });
+
+ // Total missed appointment by gender
+ $appointment_total_missed_female = Cache::remember('appointment-total-missed-female', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
- ->pluck('count');
- });
- $appointment_to_fourteen = Cache::remember('appointment-to-fourteen', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_client.gender', '=', '1')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)
+ ->count();
+ });
+ $appointment_total_missed_male = Cache::remember('appointment-total-missed-male', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.gender', '=', '2')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)
+ ->count();
+ });
+ $appointment_total_missed_uknown_gender = Cache::remember('appointment-total-missed-uknown-gender', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)
+ ->count();
+ });
+
+ // Total missed appointment by age
+ $appointment_total_missed_to_nine = Cache::remember('appointment-total-missed-to-nine', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+ });
+ $appointment_total_missed_to_fourteen = Cache::remember('appointment-total-missed-to-fourteen', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+ });
+ $appointment_total_missed_to_nineteen = Cache::remember('appointment-total-missed-to-nineteen', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+ });
+ $appointment_total_missed_to_twentyfour = Cache::remember('appointment-total-missed-to-twentyfour', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+ });
+ $appointment_total_missed_to_twentyfive_above = Cache::remember('appointment-total-missed-to-twentyfive_above', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+ });
+ $appointment_total_missed_uknown_age = Cache::remember('appointment-total-missed-uknown-age', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.dob', '=', '')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)
+ ->count();
+ });
+ // client charts
+ $client_consented = Cache::remember('client-consented', 10, function () {
+ return Client::select('smsenable')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('smsenable', '=', 'Yes')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->count();
});
- $appointment_to_nineteen = Cache::remember('appointment-to-nineteen', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $client_nonconsented = Cache::remember('client-nonconsented', 10, function () {
+ return Client::select('smsenable')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('smsenable', '!=', 'Yes')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->count();
});
- $appointment_to_twentyfour = Cache::remember('appointment-to-twentyfour', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ // consented clients by gender
+
+ $client_consented_male = Cache::remember('client-consented-male', 10, function () {
+ return Client::where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('gender', '=', '2')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->count();
});
- $appointment_to_twentyfive_above = Cache::remember('appointment-to-twentyfive-above', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $client_consented_female = Cache::remember('client-consented-female', 10, function () {
+ return Client::where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('gender', '=', '1')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->count();
});
- $appointment_uknown_age = Cache::remember('appointment-uknown-age', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.dob', '=', '')
- ->orWhereNull('tbl_client.dob')
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ $client_consented_uknown_gender = Cache::remember('client-consented-uknown-gender', 10, function () {
+ return Client::where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('gender', '!=', '1')
+ ->where('gender', '!=', '2')
+ ->where('mfl_code', Auth::user()->facility_id)
->count();
});
-
- // Total missed appointment by gender
- $appointment_total_missed_female = Cache::remember('appointment-total-missed-female', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.gender', '=', '1')
- ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ // non consented clients by gender
+ $client_nonconsented_male = Cache::remember('client-nonconsented-male', 10, function () {
+ return Client::where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('gender', '=', '2')
+ ->where('mfl_code', Auth::user()->facility_id)
->count();
});
- $appointment_total_missed_male = Cache::remember('appointment-total-missed-male', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.gender', '=', '2')
- ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ $client_nonconsented_female = Cache::remember('client-nonconsented-female', 10, function () {
+ return Client::where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('gender', '=', '1')
+ ->where('mfl_code', Auth::user()->facility_id)
->count();
});
- $appointment_total_missed_uknown_gender = Cache::remember('appointment-total-missed-uknown-gender', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.gender', '!=', '1')
- ->where('tbl_client.gender', '!=', '2')
- ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ $client_nonconsented_uknown_gender = Cache::remember('client-nonconsented-uknown-gender', 10, function () {
+ return Client::where('smsenable', '!=', 'Yes')
+ ->where('gender', '!=', '1')
+ ->where('gender', '!=', '2')
+ ->where('mfl_code', Auth::user()->facility_id)
->count();
});
-
- // Total missed appointment by age
- $appointment_total_missed_to_nine = Cache::remember('appointment-total-missed-to-nine', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
- ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ // consented clients by age distribution
+ $client_consented_to_nine = Cache::remember('client-consented-to-nine', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('mfl_code', Auth::user()->facility_id)
->pluck('count');
});
- $appointment_total_missed_to_fourteen = Cache::remember('appointment-total-missed-to-fourteen', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
- ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ $client_consented_to_fourteen = Cache::remember('tbl-client', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('mfl_code', Auth::user()->facility_id)
->pluck('count');
});
- $appointment_total_missed_to_nineteen = Cache::remember('appointment-total-missed-to-nineteen', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
- ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ $client_consented_to_nineteen = Cache::remember('client-consented-to-nineteen', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('mfl_code', Auth::user()->facility_id)
->pluck('count');
});
- $appointment_total_missed_to_twentyfour = Cache::remember('appointment-total-missed-to-twentyfour', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
- ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ $client_consented_to_twentyfour = Cache::remember('client-consented-to-twentyfour', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('mfl_code', Auth::user()->facility_id)
->pluck('count');
});
- $appointment_total_missed_to_twentyfive_above = Cache::remember('appointment-total-missed-to-twentyfive_above', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
- ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ $client_consented_to_twentyfive_above = Cache::remember('client-consented-to-twentyfive-above', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('mfl_code', Auth::user()->facility_id)
->pluck('count');
});
- $appointment_total_missed_uknown_age = Cache::remember('appointment-total-missed-uknown-age', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.dob', '=', '')
- ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ $client_consented_uknown_age = Cache::remember('client-consented-uknown-age', 10, function () {
+ return Client::select('smsenable')
+ ->where('dob', '=', '')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->orWhereNull('dob')
+ ->where('smsenable', '=', 'Yes')
+ ->where('mfl_code', Auth::user()->facility_id)
->count();
});
- // client charts
- $client_consented = Cache::remember('client-consented', 10, function () {
- return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select('tbl_clientsmsenable')
- ->where('tbl_client.status', '=', 'Active')
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_client.smsenable', '=', 'Yes')
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
- ->count();
+ // non consented clients by age distribution
+ $client_nonconsented_to_nine = Cache::remember('client-nonconsented-to-nine', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
});
- $client_nonconsented = Cache::remember('client-nonconsented', 10, function () {
- return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select('smsenable')
- ->where('tbl_client.status', '=', 'Active')
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_client.smsenable', '!=', 'Yes')
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ $client_nonconsented_to_fourteen = Cache::remember('client-nonconsented-to-fourteen', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+ });
+ $client_nonconsented_to_nineteen = Cache::remember('client-nonconsented-to-nineteen', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+ });
+ $client_nonconsented_to_twentyfour = Cache::remember('client-nonconsented-to-twentyfour', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+ });
+ $client_nonconsented_to_twentyfive_above = Cache::remember('client-nonconsented-to-twentyfive-above', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+ });
+ $client_nonconsented_uknown_age = Cache::remember('client-nonconsented-uknown-age', 10, function () {
+ return Client::select('smsenable')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('dob', '=', '')
+ ->orWhereNull('dob')
+ ->where('smsenable', '!=', 'Yes')
+ ->where('mfl_code', Auth::user()->facility_id)
->count();
});
- // consented clients by gender
- $client_consented_male = Cache::remember('client-consented-male', 10, function () {
- return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.smsenable', '=', 'Yes')
- ->where('tbl_client.status', '=', 'Active')
+ }
+ if (Auth::user()->access_level == 'Partner') {
+ $all_partners = Partner::where('status', '=', 'Active')->pluck('name', 'id');
+ $client = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.status', '=', 'Active')
->whereNull('tbl_client.hei_no')
- ->where('tbl_client.gender', '=', '2')
->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->count('tbl_client.clinic_number');
+
+ $indicator = Indicator::select(['name', 'description'])->get();
+ $appointment = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_appointment.id')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
- });
- $client_consented_female = Cache::remember('client-consented-female', 10, function () {
- return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.smsenable', '=', 'Yes')
- ->where('tbl_client.status', '=', 'Active')
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_client.gender', '=', '1')
+ $missed_appointment = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_appointment.id')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
- });
- $client_consented_uknown_gender = Cache::remember('client-consented-uknown-gender', 10, function () {
- return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.smsenable', '=', 'Yes')
- ->where('tbl_client.status', '=', 'Active')
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_client.gender', '!=', '1')
- ->where('tbl_client.gender', '!=', '2')
+ $active_facilities = PartnerFacility::join('tbl_client', 'tbl_partner_facility.mfl_code', '=', 'tbl_client.mfl_code')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw('COUNT(tbl_partner_facility.mfl_code) as facilities'))
+ ->where('tbl_appointment.created_at', '>=', Carbon::now()->subMonths(6))
->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
- ->count();
- });
- // non consented clients by gender
- $client_nonconsented_male = Cache::remember('client-nonconsented-male', 10, function () {
- return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.smsenable', '!=', 'Yes')
- ->where('tbl_client.status', '=', 'Active')
+ ->orderBy('tbl_appointment.created_at', 'DESC')
+ ->groupBy('tbl_partner_facility.mfl_code')
+ ->get();
+
+
+ // dd($active_facilities);
+ // active clients by gender
+ $clients_male = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('id')->where([['tbl_client.gender', '=', '2'], ['tbl_client.status', '=', 'Active'],])
->whereNull('tbl_client.hei_no')
- ->where('tbl_client.gender', '=', '2')
->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
- });
- $client_nonconsented_female = Cache::remember('client-nonconsented-female', 10, function () {
- return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.smsenable', '!=', 'Yes')
+
+ $clients_female = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.gender', '=', '1')
->where('tbl_client.status', '=', 'Active')
->whereNull('tbl_client.hei_no')
- ->where('tbl_client.gender', '=', '1')
->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
- });
- $client_nonconsented_uknown_gender = Cache::remember('client-nonconsented-uknown-gender', 10, function () {
- return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.smsenable', '!=', 'Yes')
- ->where('tbl_client.gender', '!=', '1')
+ $unknown_gender = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.gender', '!=', '1')
->where('tbl_client.gender', '!=', '2')
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
- ->count();
- });
- // consented clients by age distribution
- $client_consented_to_nine = Cache::remember('client-consented-to-nine', 10, function () {
- return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_client.smsenable', '=', 'Yes')
->where('tbl_client.status', '=', 'Active')
->whereNull('tbl_client.hei_no')
->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
- ->pluck('count');
- });
- $client_consented_to_fourteen = Cache::remember('tbl-client', 10, function () {
+ ->count();
+
+ $client_to_nine = Cache::remember('client_to_nine', 10, function () {
return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_client.smsenable', '=', 'Yes')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`dob` end)) AS count"))
->where('tbl_client.status', '=', 'Active')
->whereNull('tbl_client.hei_no')
->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
- $client_consented_to_nineteen = Cache::remember('client-consented-to-nineteen', 10, function () {
+
+ $client_to_fourteen = Cache::remember('client-fourteen', 10, function () {
return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_client.smsenable', '=', 'Yes')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`dob` end)) AS count"))
->where('tbl_client.status', '=', 'Active')
->whereNull('tbl_client.hei_no')
->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
- $client_consented_to_twentyfour = Cache::remember('client-consented-to-twentyfour', 10, function () {
+
+ $client_to_nineteen = Cache::remember('client-nineteen', 10, function () {
return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_client.smsenable', '=', 'Yes')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`dob` end)) AS count"))
->where('tbl_client.status', '=', 'Active')
->whereNull('tbl_client.hei_no')
->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
- $client_consented_to_twentyfive_above = Cache::remember('client-consented-to-twentyfive-above', 10, function () {
+
+ $client_to_twentyfour = Cache::remember('client-twentyfour', 10, function () {
return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_client.smsenable', '=', 'Yes')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`dob` end)) AS count"))
->where('tbl_client.status', '=', 'Active')
->whereNull('tbl_client.hei_no')
->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
- $client_consented_uknown_age = Cache::remember('client-consented-uknown-age', 10, function () {
- return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select('tbl_client.smsenable')
- ->where('tbl_client.dob', '=', '')
+
+ $client_to_twentyfive_above = Cache::remember('client-twentyfive-above', 10, function () {
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`dob` end)) AS count"))
->where('tbl_client.status', '=', 'Active')
->whereNull('tbl_client.hei_no')
- ->orWhereNull('tbl_client.dob')
- ->where('tbl_client.smsenable', '=', 'Yes')
->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
- ->count();
+ ->pluck('count');
});
- // non consented clients by age distribution
- $client_nonconsented_to_nine = Cache::remember('client-nonconsented-to-nine', 10, function () {
+
+ $client_unknown_age = Cache::remember('client-unknown-age', 10, function () {
return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.dob', '=', '')
+ ->orWhereNull('tbl_client.dob')
->where('tbl_client.status', '=', 'Active')
->whereNull('tbl_client.hei_no')
->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ ->count();
});
- $client_nonconsented_to_fourteen = Cache::remember('client-nonconsented-to-fourteen', 10, function () {
- return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_client.smsenable', '!=', 'Yes')
- ->where('tbl_client.status', '=', 'Active')
- ->whereNull('tbl_client.hei_no')
+
+ // appointment by gender
+ $appointment_male = Cache::remember('appointment-male', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_appointment.id')
+ ->where('tbl_client.gender', '=', '2')
->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
- ->pluck('count');
- });
- $client_nonconsented_to_nineteen = Cache::remember('client-nonconsented-to-nineteen', 10, function () {
- return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_client.smsenable', '!=', 'Yes')
- ->where('tbl_client.status', '=', 'Active')
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
- ->pluck('count');
- });
- $client_nonconsented_to_twentyfour = Cache::remember('client-nonconsented-to-twentyfour', 10, function () {
- return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_client.smsenable', '!=', 'Yes')
- ->where('tbl_client.status', '=', 'Active')
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
- ->pluck('count');
- });
- $client_nonconsented_to_twentyfive_above = Cache::remember('client-nonconsented-to-twentyfive-above', 10, function () {
- return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_client.smsenable', '!=', 'Yes')
- ->where('tbl_client.status', '=', 'Active')
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
- ->pluck('count');
- });
- $client_nonconsented_uknown_age = Cache::remember('client-nonconsented-uknown-age', 10, function () {
- return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select('tbl_client.smsenable')
- ->where('tbl_client.status', '=', 'Active')
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_client.dob', '=', '')
- ->orWhereNull('tbl_client.dob')
- ->where('tbl_client.smsenable', '!=', 'Yes')
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
- ->count();
- });
-
- }
- if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
-
- $all_partners = Partner::where('status', '=', 'Active')->pluck('name', 'id');
- $client = Client::where('status', '=', 'Active')
- ->whereNull('hei_no')
- ->count('clinic_number');
-
- $indicator = Indicator::select(['name', 'description'])->get();
- $appointment = Appointments::select('id')
- ->count();
- $missed_appointment = Appointments::select('id')
- ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
- ->count();
- // dd($missed_appointment);
- $active_facilities = PartnerFacility::join('tbl_client', 'tbl_partner_facility.mfl_code', '=', 'tbl_client.mfl_code')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw('COUNT(tbl_partner_facility.mfl_code) as facilities'))
- ->where('tbl_appointment.created_at', '>=', Carbon::now()->subMonths(6))
- ->orderBy('tbl_appointment.created_at', 'DESC')
- ->groupBy('tbl_partner_facility.mfl_code')
- ->get();
-
-
- // dd($active_facilities);
- // active clients by gender
- $clients_male = Client::select('id')->where([['gender', '=', '2'], ['status', '=', 'Active'],])
- ->whereNull('hei_no')
- ->count();
-
- $clients_female = Client::where('gender', '=', '1')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
- ->count();
- $unknown_gender = Client::where('gender', '!=', '1')
- ->where('gender', '!=', '2')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
- ->count();
-
- $client_to_nine = Cache::remember('client_to_nine', 10, function () {
- return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`dob`)) > 0) and ((year(curdate()) - year(`dob`)) <= 9)) then `dob` end)) AS count"))
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
- ->pluck('count');
- });
-
- $client_to_fourteen = Cache::remember('client-fourteen', 10, function () {
- return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`dob`)) >= 10) and ((year(curdate()) - year(`dob`)) <= 14)) then `dob` end)) AS count"))
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
- ->pluck('count');
- });
-
- $client_to_nineteen = Cache::remember('client-nineteen', 10, function () {
- return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`dob`)) >= 15) and ((year(curdate()) - year(`dob`)) <= 19)) then `dob` end)) AS count"))
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
- ->pluck('count');
- });
-
- $client_to_twentyfour = Cache::remember('client-twentyfour', 10, function () {
- return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`dob`)) >= 20) and ((year(curdate()) - year(`dob`)) <= 24)) then `id` end)) AS count"))
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
- ->pluck('count');
- });
-
- $client_to_twentyfive_above = Cache::remember('client-twentyfive-above', 10, function () {
- return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`dob`)) >= 25)) then `id` end)) AS count"))
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
- ->pluck('count');
- });
-
- $client_unknown_age = Cache::remember('client-unknown-age', 10, function () {
- return Client::where('dob', '=', '')
- ->orWhereNull('dob')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
- ->count();
- });
-
- // appointment by gender
- $appointment_male = Cache::remember('appointment-male', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select('tbl_appointment.id')
- ->where('tbl_client.gender', '=', '2')
- ->count();
+ ->count();
});
$appointment_female = Cache::remember('appointment-female', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select('tbl_appointment.id')
->where('tbl_client.gender', '=', '1')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
$appointment_uknown_gender = Cache::remember('appointment-uknown-gender', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select('tbl_appointment.id')
->where('tbl_client.gender', '!=', '1')
->where('tbl_client.gender', '!=', '2')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
// appointment by age
@@ -581,30 +579,35 @@ public function dashboard()
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$appointment_to_fourteen = Cache::remember('appointment-to-fourteen', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$appointment_to_nineteen = Cache::remember('appointment-to-nineteen', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$appointment_to_twentyfour = Cache::remember('appointment-to-twentyfour', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$appointment_to_twentyfive_above = Cache::remember('appointment-to-twentyfive-above', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$appointment_uknown_age = Cache::remember('appointment-uknown-age', 10, function () {
@@ -612,333 +615,1420 @@ public function dashboard()
->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->where('tbl_client.dob', '=', '')
->orWhereNull('tbl_client.dob')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
// Total missed appointment by gender
$appointment_total_missed_female = Cache::remember('appointment-total-missed-female', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->where('tbl_client.gender', '=', '1')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
$appointment_total_missed_male = Cache::remember('appointment-total-missed-male', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->where('tbl_client.gender', '=', '2')
->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
$appointment_total_missed_uknown_gender = Cache::remember('appointment-total-missed-uknown-gender', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->where('tbl_client.gender', '!=', '1')
->where('tbl_client.gender', '!=', '2')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
// Total missed appointment by age
$appointment_total_missed_to_nine = Cache::remember('appointment-total-missed-to-nine', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$appointment_total_missed_to_fourteen = Cache::remember('appointment-total-missed-to-fourteen', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$appointment_total_missed_to_nineteen = Cache::remember('appointment-total-missed-to-nineteen', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$appointment_total_missed_to_twentyfour = Cache::remember('appointment-total-missed-to-twentyfour', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$appointment_total_missed_to_twentyfive_above = Cache::remember('appointment-total-missed-to-twentyfive_above', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$appointment_total_missed_uknown_age = Cache::remember('appointment-total-missed-uknown-age', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->where('tbl_client.dob', '=', '')
- ->orWhereNull('tbl_client.dob')
->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
// client charts
$client_consented = Cache::remember('client-consented', 10, function () {
- return Client::select('smsenable')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
- ->where('smsenable', '=', 'Yes')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_clientsmsenable')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
$client_nonconsented = Cache::remember('client-nonconsented', 10, function () {
- return Client::select('smsenable')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
- ->where('smsenable', '!=', 'Yes')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('smsenable')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
// consented clients by gender
$client_consented_male = Cache::remember('client-consented-male', 10, function () {
- return Client::where('smsenable', '=', 'Yes')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
- ->where('gender', '=', '2')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.gender', '=', '2')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
$client_consented_female = Cache::remember('client-consented-female', 10, function () {
- return Client::where('smsenable', '=', 'Yes')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
- ->where('gender', '=', '1')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.gender', '=', '1')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
$client_consented_uknown_gender = Cache::remember('client-consented-uknown-gender', 10, function () {
- return Client::where('smsenable', '=', 'Yes')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
- ->where('gender', '!=', '1')
- ->where('gender', '!=', '2')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
// non consented clients by gender
$client_nonconsented_male = Cache::remember('client-nonconsented-male', 10, function () {
- return Client::where('smsenable', '!=', 'Yes')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
- ->where('gender', '=', '2')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.gender', '=', '2')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
$client_nonconsented_female = Cache::remember('client-nonconsented-female', 10, function () {
- return Client::where('smsenable', '!=', 'Yes')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
- ->where('gender', '=', '1')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.gender', '=', '1')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
$client_nonconsented_uknown_gender = Cache::remember('client-nonconsented-uknown-gender', 10, function () {
- return Client::where('smsenable', '!=', 'Yes')
- ->where('gender', '!=', '1')
- ->where('gender', '!=', '2')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
// consented clients by age distribution
$client_consented_to_nine = Cache::remember('client-consented-to-nine', 10, function () {
- return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
- ->where('smsenable', '=', 'Yes')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$client_consented_to_fourteen = Cache::remember('tbl-client', 10, function () {
- return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
- ->where('smsenable', '=', 'Yes')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
- ->pluck('count');
- });
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
+ });
$client_consented_to_nineteen = Cache::remember('client-consented-to-nineteen', 10, function () {
- return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
- ->where('smsenable', '=', 'Yes')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$client_consented_to_twentyfour = Cache::remember('client-consented-to-twentyfour', 10, function () {
- return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
- ->where('smsenable', '=', 'Yes')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$client_consented_to_twentyfive_above = Cache::remember('client-consented-to-twentyfive-above', 10, function () {
- return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
- ->where('smsenable', '=', 'Yes')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$client_consented_uknown_age = Cache::remember('client-consented-uknown-age', 10, function () {
- return Client::select('smsenable')
- ->where('dob', '=', '')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
- ->orWhereNull('dob')
- ->where('smsenable', '=', 'Yes')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.smsenable')
+ ->where('tbl_client.dob', '=', '')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->orWhereNull('tbl_client.dob')
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
// non consented clients by age distribution
$client_nonconsented_to_nine = Cache::remember('client-nonconsented-to-nine', 10, function () {
- return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
- ->where('smsenable', '!=', 'Yes')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$client_nonconsented_to_fourteen = Cache::remember('client-nonconsented-to-fourteen', 10, function () {
- return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
- ->where('smsenable', '!=', 'Yes')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$client_nonconsented_to_nineteen = Cache::remember('client-nonconsented-to-nineteen', 10, function () {
- return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
- ->where('smsenable', '!=', 'Yes')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$client_nonconsented_to_twentyfour = Cache::remember('client-nonconsented-to-twentyfour', 10, function () {
- return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
- ->where('smsenable', '!=', 'Yes')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$client_nonconsented_to_twentyfive_above = Cache::remember('client-nonconsented-to-twentyfive-above', 10, function () {
- return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
- ->where('smsenable', '!=', 'Yes')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->pluck('count');
});
$client_nonconsented_uknown_age = Cache::remember('client-nonconsented-uknown-age', 10, function () {
- return Client::select('smsenable')
- ->where('status', '=', 'Active')
- ->whereNull('hei_no')
- ->where('dob', '=', '')
- ->orWhereNull('dob')
- ->where('smsenable', '!=', 'Yes')
+ return Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.smsenable')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.dob', '=', '')
+ ->orWhereNull('tbl_client.dob')
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
->count();
});
-
}
+ if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+ $all_partners = Partner::where('status', '=', 'Active')->pluck('name', 'id');
+ $client = Client::where('status', '=', 'Active')->whereNull('hei_no')->count('clinic_number');
- // dd($active_facilities);
- return view('new_dashboard.main_dashbaord', compact(
- 'all_partners',
- 'active_facilities',
- 'indicator',
- 'client',
- 'appointment',
- 'missed_appointment',
- 'clients_male',
- 'clients_female',
- 'unknown_gender',
- 'client_to_nine',
- 'client_to_fourteen',
- 'client_to_nineteen',
- 'client_to_twentyfour',
- 'client_to_twentyfive_above',
- 'client_unknown_age',
- 'appointment_male',
- 'appointment_female',
- 'appointment_uknown_gender',
- 'appointment_to_nine',
- 'appointment_to_fourteen',
- 'appointment_to_nineteen',
- 'appointment_to_twentyfour',
- 'appointment_to_twentyfive_above',
- 'appointment_uknown_age',
- 'appointment_total_missed_female',
- 'appointment_total_missed_male',
- 'appointment_total_missed_uknown_gender',
- 'appointment_total_missed_to_nine',
- 'appointment_total_missed_to_fourteen',
- 'appointment_total_missed_to_nineteen',
- 'appointment_total_missed_to_twentyfour',
- 'appointment_total_missed_to_twentyfive_above',
- 'appointment_total_missed_uknown_age',
- 'client_consented',
- 'client_nonconsented',
- 'client_consented_male',
- 'client_consented_female',
- 'client_consented_uknown_gender',
- 'client_nonconsented_male',
- 'client_nonconsented_female',
- 'client_nonconsented_uknown_gender',
- 'client_consented_to_nine',
- 'client_consented_to_fourteen',
- 'client_consented_to_nineteen',
- 'client_consented_to_twentyfour',
- 'client_consented_to_twentyfive_above',
- 'client_consented_uknown_age',
- 'client_nonconsented_to_nine',
- 'client_nonconsented_to_fourteen',
- 'client_nonconsented_to_nineteen',
- 'client_nonconsented_to_twentyfour',
- 'client_nonconsented_to_twentyfive_above',
- 'client_nonconsented_uknown_age'
+ $indicator = Indicator::select(['name', 'description'])->get();
+ $appointment = Appointments::select('id')
+ ->count();
+ $missed_appointment = Appointments::select('id')
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->count();
+ // dd($missed_appointment);
+ $active_facilities = PartnerFacility::join('tbl_client', 'tbl_partner_facility.mfl_code', '=', 'tbl_client.mfl_code')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select('tbl_partner_facility.mfl_code')
+ ->where('tbl_appointment.created_at', '>=', Carbon::now()->subMonths(6))
+ ->orderBy('tbl_appointment.created_at', 'DESC')
+ ->groupBy('tbl_partner_facility.mfl_code')
+ ->get();
- ));
- }
- public function appointment_charts()
- {
- if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
- $all_partners = Partner::where('status', '=', 'Active')->pluck('name', 'id');
- // main appointments
- $appointment = Appointments::select('id')
+ // dd($active_facilities);
+ // active clients by gender
+ $clients_male = Client::select('id')->where([['gender', '=', '2'], ['status', '=', 'Active'],])
+ ->whereNull('hei_no')
->count();
- $appointment_honoured = Cache::remember('appointment-honoured', 10, function () {
- return Appointments::select(\DB::raw("COUNT(id) as count"))
- ->where('date_attended', '=', DB::raw('appntmnt_date'))
+
+ $clients_female = Client::where('gender', '=', '1')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->count();
+ $unknown_gender = Client::where('gender', '!=', '1')
+ ->where('gender', '!=', '2')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->count();
+
+ $client_to_nine = Cache::remember('client_to_nine', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`dob`)) > 0) and ((year(curdate()) - year(`dob`)) <= 9)) then `dob` end)) AS count"))
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
->pluck('count');
- });
- // dd($appointment_honoured);
- $appointment_not_honoured = Cache::remember('appointment-not-honoured', 10, function () {
- return Appointments::select(\DB::raw("COUNT(id) as count"))
- ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
- ->pluck('count');
- });
+ });
- // appointment honored by gender
- $appointment_honoured_male = Cache::remember('appointment-honoured-male', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select(\DB::raw("COUNT(tbl_appointment.id) as count"))
- ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
- ->where('tbl_client.gender', '=', '2')
- ->pluck('count');
- });
- $appointment_honoured_female = Cache::remember('appointment-honoured-female', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
- ->where('tbl_client.gender', '=', '1')
- ->count();
- });
- $appointment_honoured_uknown_gender = Cache::remember('appointment-honoured-uknown-gender', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
- ->where('tbl_client.gender', '!=', '1')
- ->where('tbl_client.gender', '!=', '2')
- ->count();
- });
- // appointment honored by age
- $appointment_honored_to_nine = Cache::remember('appointment-honored-to-nine', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
- ->pluck('count');
- });
- $appointment_honored_to_fourteen = Cache::remember('appointment-honored-to-fourteen', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ $client_to_fourteen = Cache::remember('client-fourteen', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`dob`)) >= 10) and ((year(curdate()) - year(`dob`)) <= 14)) then `dob` end)) AS count"))
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->pluck('count');
+ });
+
+ $client_to_nineteen = Cache::remember('client-nineteen', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`dob`)) >= 15) and ((year(curdate()) - year(`dob`)) <= 19)) then `dob` end)) AS count"))
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->pluck('count');
+ });
+
+ $client_to_twentyfour = Cache::remember('client-twentyfour', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`dob`)) >= 20) and ((year(curdate()) - year(`dob`)) <= 24)) then `id` end)) AS count"))
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->pluck('count');
+ });
+
+ $client_to_twentyfive_above = Cache::remember('client-twentyfive-above', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`dob`)) >= 25)) then `id` end)) AS count"))
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->pluck('count');
+ });
+
+ $client_unknown_age = Cache::remember('client-unknown-age', 10, function () {
+ return Client::where('dob', '=', '')
+ ->orWhereNull('dob')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->count();
+ });
+
+ // appointment by gender
+ $appointment_male = Cache::remember('appointment-male', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_appointment.id')
+ ->where('tbl_client.gender', '=', '2')
+ ->count();
+ });
+ $appointment_female = Cache::remember('appointment-female', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_appointment.id')
+ ->where('tbl_client.gender', '=', '1')
+ ->count();
+ });
+ $appointment_uknown_gender = Cache::remember('appointment-uknown-gender', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_appointment.id')
+ ->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->count();
+ });
+ // appointment by age
+ $appointment_to_nine = Cache::remember('appointment-to-nine', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->pluck('count');
+ });
+ $appointment_to_fourteen = Cache::remember('appointment-to-fourteen', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->pluck('count');
+ });
+ $appointment_to_nineteen = Cache::remember('appointment-to-nineteen', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->pluck('count');
+ });
+ $appointment_to_twentyfour = Cache::remember('appointment-to-twentyfour', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->pluck('count');
+ });
+ $appointment_to_twentyfive_above = Cache::remember('appointment-to-twentyfive-above', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->pluck('count');
+ });
+ $appointment_uknown_age = Cache::remember('appointment-uknown-age', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.dob', '=', '')
+ ->orWhereNull('tbl_client.dob')
+ ->count();
+ });
+
+ // Total missed appointment by gender
+ $appointment_total_missed_female = Cache::remember('appointment-total-missed-female', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_client.gender', '=', '1')
+ ->count();
+ });
+ $appointment_total_missed_male = Cache::remember('appointment-total-missed-male', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_client.gender', '=', '2')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->count();
+ });
+ $appointment_total_missed_uknown_gender = Cache::remember('appointment-total-missed-uknown-gender', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->count();
+ });
+
+ // Total missed appointment by age
+ $appointment_total_missed_to_nine = Cache::remember('appointment-total-missed-to-nine', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->pluck('count');
+ });
+ $appointment_total_missed_to_fourteen = Cache::remember('appointment-total-missed-to-fourteen', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->pluck('count');
+ });
+ $appointment_total_missed_to_nineteen = Cache::remember('appointment-total-missed-to-nineteen', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->pluck('count');
+ });
+ $appointment_total_missed_to_twentyfour = Cache::remember('appointment-total-missed-to-twentyfour', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->pluck('count');
+ });
+ $appointment_total_missed_to_twentyfive_above = Cache::remember('appointment-total-missed-to-twentyfive_above', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->pluck('count');
+ });
+ $appointment_total_missed_uknown_age = Cache::remember('appointment-total-missed-uknown-age', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_client.dob', '=', '')
+ ->orWhereNull('tbl_client.dob')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->count();
+ });
+ // client charts
+ $client_consented = Cache::remember('client-consented', 10, function () {
+ return Client::select('smsenable')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('smsenable', '=', 'Yes')
+ ->count();
+ });
+ $client_nonconsented = Cache::remember('client-nonconsented', 10, function () {
+ return Client::select('smsenable')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('smsenable', '!=', 'Yes')
+ ->count();
+ });
+ // consented clients by gender
+
+ $client_consented_male = Cache::remember('client-consented-male', 10, function () {
+ return Client::where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('gender', '=', '2')
+ ->count();
+ });
+ $client_consented_female = Cache::remember('client-consented-female', 10, function () {
+ return Client::where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('gender', '=', '1')
+ ->count();
+ });
+ $client_consented_uknown_gender = Cache::remember('client-consented-uknown-gender', 10, function () {
+ return Client::where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('gender', '!=', '1')
+ ->where('gender', '!=', '2')
+ ->count();
+ });
+ // non consented clients by gender
+ $client_nonconsented_male = Cache::remember('client-nonconsented-male', 10, function () {
+ return Client::where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('gender', '=', '2')
+ ->count();
+ });
+ $client_nonconsented_female = Cache::remember('client-nonconsented-female', 10, function () {
+ return Client::where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('gender', '=', '1')
+ ->count();
+ });
+ $client_nonconsented_uknown_gender = Cache::remember('client-nonconsented-uknown-gender', 10, function () {
+ return Client::where('smsenable', '!=', 'Yes')
+ ->where('gender', '!=', '1')
+ ->where('gender', '!=', '2')
+ ->count();
+ });
+ // consented clients by age distribution
+ $client_consented_to_nine = Cache::remember('client-consented-to-nine', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->pluck('count');
+ });
+ $client_consented_to_fourteen = Cache::remember('tbl-client', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->pluck('count');
+ });
+ $client_consented_to_nineteen = Cache::remember('client-consented-to-nineteen', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->pluck('count');
+ });
+ $client_consented_to_twentyfour = Cache::remember('client-consented-to-twentyfour', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->pluck('count');
+ });
+ $client_consented_to_twentyfive_above = Cache::remember('client-consented-to-twentyfive-above', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->pluck('count');
+ });
+ $client_consented_uknown_age = Cache::remember('client-consented-uknown-age', 10, function () {
+ return Client::select('smsenable')
+ ->where('dob', '=', '')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->orWhereNull('dob')
+ ->where('smsenable', '=', 'Yes')
+ ->count();
+ });
+ // non consented clients by age distribution
+ $client_nonconsented_to_nine = Cache::remember('client-nonconsented-to-nine', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->pluck('count');
+ });
+ $client_nonconsented_to_fourteen = Cache::remember('client-nonconsented-to-fourteen', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->pluck('count');
+ });
+ $client_nonconsented_to_nineteen = Cache::remember('client-nonconsented-to-nineteen', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->pluck('count');
+ });
+ $client_nonconsented_to_twentyfour = Cache::remember('client-nonconsented-to-twentyfour', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->pluck('count');
+ });
+ $client_nonconsented_to_twentyfive_above = Cache::remember('client-nonconsented-to-twentyfive-above', 10, function () {
+ return Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->pluck('count');
+ });
+ $client_nonconsented_uknown_age = Cache::remember('client-nonconsented-uknown-age', 10, function () {
+ return Client::select('smsenable')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('dob', '=', '')
+ ->orWhereNull('dob')
+ ->where('smsenable', '!=', 'Yes')
+ ->count();
+ });
+
+
+ }
+
+
+ // dd($active_facilities);
+
+ return view('new_dashboard.main_dashbaord', compact(
+ 'all_partners',
+ 'active_facilities',
+ 'indicator',
+ 'client',
+ 'appointment',
+ 'missed_appointment',
+ 'clients_male',
+ 'clients_female',
+ 'unknown_gender',
+ 'client_to_nine',
+ 'client_to_fourteen',
+ 'client_to_nineteen',
+ 'client_to_twentyfour',
+ 'client_to_twentyfive_above',
+ 'client_unknown_age',
+ 'appointment_male',
+ 'appointment_female',
+ 'appointment_uknown_gender',
+ 'appointment_to_nine',
+ 'appointment_to_fourteen',
+ 'appointment_to_nineteen',
+ 'appointment_to_twentyfour',
+ 'appointment_to_twentyfive_above',
+ 'appointment_uknown_age',
+ 'appointment_total_missed_female',
+ 'appointment_total_missed_male',
+ 'appointment_total_missed_uknown_gender',
+ 'appointment_total_missed_to_nine',
+ 'appointment_total_missed_to_fourteen',
+ 'appointment_total_missed_to_nineteen',
+ 'appointment_total_missed_to_twentyfour',
+ 'appointment_total_missed_to_twentyfive_above',
+ 'appointment_total_missed_uknown_age',
+ 'client_consented',
+ 'client_nonconsented',
+ 'client_consented_male',
+ 'client_consented_female',
+ 'client_consented_uknown_gender',
+ 'client_nonconsented_male',
+ 'client_nonconsented_female',
+ 'client_nonconsented_uknown_gender',
+ 'client_consented_to_nine',
+ 'client_consented_to_fourteen',
+ 'client_consented_to_nineteen',
+ 'client_consented_to_twentyfour',
+ 'client_consented_to_twentyfive_above',
+ 'client_consented_uknown_age',
+ 'client_nonconsented_to_nine',
+ 'client_nonconsented_to_fourteen',
+ 'client_nonconsented_to_nineteen',
+ 'client_nonconsented_to_twentyfour',
+ 'client_nonconsented_to_twentyfive_above',
+ 'client_nonconsented_uknown_age'
+
+ ));
+ }
+
+ public function appointment_charts()
+ {
+ if (Auth::user()->access_level == 'Facility') {
+ $all_partners = Partner::where('status', '=', 'Active')->pluck('name', 'id');
+ // main appointments
+ $appointment = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_appointment.id')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $appointment_honoured = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_appointment.id')
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+
+ // dd($appointment_honoured);
+ $appointment_not_honoured = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_appointment.id')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+
+ // appointment honored by gender
+ $appointment_honoured_male = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("COUNT(tbl_appointment.id) as count"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_client.gender', '=', '2')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+ $appointment_honoured_female = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_client.gender', '=', '1')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $appointment_honoured_uknown_gender = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ // appointment honored by age
+ $appointment_honored_to_nine = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+ $appointment_honored_to_fourteen = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+ $appointment_honored_to_nineteen = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+
+ $appointment_honored_to_twentyfour = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+
+ $appointment_honored_to_twentyfive_above = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+
+ $appointment_honored_to_uknown_age = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_client.dob')
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_client.dob', '=', '')
+ ->orWhereNull('tbl_client.dob')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ // appointment not honored by gender
+ $appointment_not_honoured_male = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_client.gender', '=', '2')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+
+ $appointment_not_honoured_female = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_client.gender', '=', '1')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $appointment_not_honoured_uknown_gender = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ // appointment not honored by age
+ $appointment_not_honored_to_nine = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+
+ $appointment_not_honored_to_fourteen = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+
+ $appointment_not_honored_to_nineteen = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+ $appointment_not_honored_to_twentyfour = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+ $appointment_not_honored_to_twentyfive_above = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+
+ $appointment_not_honored_to_uknown_age = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_client.dob')
+ ->where('tbl_client.dob', '=', '')
+ ->orWhereNull('tbl_client.dob')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+
+ // missed appointments
+
+ $appointment_missed = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $appointment_defaulted = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $appointment_lftu = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+
+ // missed appointment by gender
+ $appointment_missed_female = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.gender', '=', '1')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $appointment_missed_male = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.gender', '=', '2')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+
+ $appointment_missed_uknown_gender = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+
+ // missed appointment by age
+ $appointment_missed_to_nine = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+ $appointment_missed_to_fourteen = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+
+ $appointment_missed_to_nineteen = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+ $appointment_missed_to_twentyfour = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+ $appointment_missed_to_twentyfive_above = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+ $appointment_missed_to_uknown_age = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_client.dob')
+ ->where('tbl_client.dob', '=', '')
+ ->orWhereNull('tbl_client.dob')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+
+ // defaulted appointment by gender
+ $appointment_defaulted_female = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.gender', '=', '1')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $appointment_defaulted_male = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.gender', '=', '2')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+
+ $appointment_defaulted_uknown_gender = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ // defaulted appointment by age
+ $appointment_defaulted_to_nine = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+ $appointment_defaulted_to_fourteen = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+ $appointment_defaulted_to_nineteen = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+ $appointment_defaulted_to_twentyfour = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+
+ $appointment_defaulted_to_twentyfive_above = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+
+ $appointment_defaulted_to_uknown_age = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_client.dob')
+ ->where('tbl_client.dob', '=', '')
+ ->orWhereNull('tbl_client.dob')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ // ltfu appointment by gender
+ $appointment_ltfu_female = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.gender', '=', '1')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+
+ $appointment_ltfu_male = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.gender', '=', '2')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $appointment_ltfu_uknown_gender = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+
+ // ltfu appointment by age
+ $appointment_ltfu_to_nine = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+
+ $appointment_ltfu_to_fourteen = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+
+ $appointment_ltfu_to_nineteen = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+
+ $appointment_ltfu_to_twentyfour = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+ $appointment_ltfu_to_twentyfive_above = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+
+ $appointment_ltfu_to_uknown_age = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_client.dob')
+ ->where('tbl_client.dob', '=', '')
+ ->orWhereNull('tbl_client.dob')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ }
+ if (Auth::user()->access_level == 'Partner') {
+ $all_partners = Partner::where('status', '=', 'Active')->pluck('name', 'id');
+ // main appointments
+ $appointment = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_appointment.id')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->count();
+ $appointment_honoured = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_appointment.id')
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->count();
+
+ // dd($appointment_honoured);
+ $appointment_not_honoured = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_appointment.id')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->count();
+
+ // appointment honored by gender
+ $appointment_honoured_male = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("COUNT(tbl_appointment.id) as count"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_client.gender', '=', '2')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
+ $appointment_honoured_female = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_client.gender', '=', '1')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->count();
+ $appointment_honoured_uknown_gender = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->count();
+ // appointment honored by age
+ $appointment_honored_to_nine = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
+ $appointment_honored_to_fourteen = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
+ $appointment_honored_to_nineteen = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
+
+ $appointment_honored_to_twentyfour = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
+
+ $appointment_honored_to_twentyfive_above = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
+
+ $appointment_honored_to_uknown_age = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.dob')
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_client.dob', '=', '')
+ ->orWhereNull('tbl_client.dob')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->count();
+ // appointment not honored by gender
+ $appointment_not_honoured_male = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.gender', '=', '2')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->count();
+
+ $appointment_not_honoured_female = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.gender', '=', '1')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->count();
+ $appointment_not_honoured_uknown_gender = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->count();
+ // appointment not honored by age
+ $appointment_not_honored_to_nine = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
+
+ $appointment_not_honored_to_fourteen = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
+
+ $appointment_not_honored_to_nineteen = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
+ $appointment_not_honored_to_twentyfour = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
+ $appointment_not_honored_to_twentyfive_above = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
+
+ $appointment_not_honored_to_uknown_age = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.dob')
+ ->where('tbl_client.dob', '=', '')
+ ->orWhereNull('tbl_client.dob')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->count();
+
+ // missed appointments
+
+ $appointment_missed = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->count();
+ $appointment_defaulted = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->count();
+ $appointment_lftu = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->count();
+
+ // missed appointment by gender
+ $appointment_missed_female = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.gender', '=', '1')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->count();
+ $appointment_missed_male = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.gender', '=', '2')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->count();
+
+ $appointment_missed_uknown_gender = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->count();
+
+ // missed appointment by age
+ $appointment_missed_to_nine = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
+ $appointment_missed_to_fourteen = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
+
+ $appointment_missed_to_nineteen = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
+ $appointment_missed_to_twentyfour = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
+ $appointment_missed_to_twentyfive_above = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
+ $appointment_missed_to_uknown_age = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.dob')
+ ->where('tbl_client.dob', '=', '')
+ ->orWhereNull('tbl_client.dob')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->count();
+
+ // defaulted appointment by gender
+ $appointment_defaulted_female = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.gender', '=', '1')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->count();
+ $appointment_defaulted_male = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.gender', '=', '2')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->count();
+
+ $appointment_defaulted_uknown_gender = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->count();
+ // defaulted appointment by age
+ $appointment_defaulted_to_nine = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
+ $appointment_defaulted_to_fourteen = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
+ $appointment_defaulted_to_nineteen = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
+ $appointment_defaulted_to_twentyfour = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
+
+ $appointment_defaulted_to_twentyfive_above = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
+
+ $appointment_defaulted_to_uknown_age = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.dob')
+ ->where('tbl_client.dob', '=', '')
+ ->orWhereNull('tbl_client.dob')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->count();
+ // ltfu appointment by gender
+ $appointment_ltfu_female = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.gender', '=', '1')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->count();
+
+ $appointment_ltfu_male = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.gender', '=', '2')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->count();
+ $appointment_ltfu_uknown_gender = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->count();
+
+ // ltfu appointment by age
+ $appointment_ltfu_to_nine = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
+
+ $appointment_ltfu_to_fourteen = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
+
+ $appointment_ltfu_to_nineteen = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
+
+ $appointment_ltfu_to_twentyfour = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
+ $appointment_ltfu_to_twentyfive_above = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
+
+ $appointment_ltfu_to_uknown_age = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.dob')
+ ->where('tbl_client.dob', '=', '')
+ ->orWhereNull('tbl_client.dob')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->count();
+ }
+
+ if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+ $all_partners = Partner::where('status', '=', 'Active')->pluck('name', 'id');
+ // main appointments
+ $appointment = Appointments::select('id')
+ ->count();
+ $appointment_honoured = Cache::remember('appointment-honoured', 10, function () {
+ return Appointments::select(\DB::raw("COUNT(id) as count"))
+ ->where('date_attended', '=', DB::raw('appntmnt_date'))
+ ->pluck('count');
+ });
+ // dd($appointment_honoured);
+ $appointment_not_honoured = Cache::remember('appointment-not-honoured', 10, function () {
+ return Appointments::select(\DB::raw("COUNT(id) as count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->pluck('count');
+ });
+
+ // appointment honored by gender
+ $appointment_honoured_male = Cache::remember('appointment-honoured-male', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("COUNT(tbl_appointment.id) as count"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_client.gender', '=', '2')
+ ->pluck('count');
+ });
+ $appointment_honoured_female = Cache::remember('appointment-honoured-female', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_client.gender', '=', '1')
+ ->count();
+ });
+ $appointment_honoured_uknown_gender = Cache::remember('appointment-honoured-uknown-gender', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->count();
+ });
+ // appointment honored by age
+ $appointment_honored_to_nine = Cache::remember('appointment-honored-to-nine', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->pluck('count');
+ });
+ $appointment_honored_to_fourteen = Cache::remember('appointment-honored-to-fourteen', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
@@ -1102,202 +2192,774 @@ public function appointment_charts()
$appointment_missed_to_twentyfive_above = Cache::remember('appointment_missed_to_twentyfive_above', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->pluck('count');
+ });
+ $appointment_missed_to_uknown_age = Cache::remember('appointment_missed_to_uknown_age', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_client.dob')
+ ->where('tbl_client.dob', '=', '')
+ ->orWhereNull('tbl_client.dob')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->count();
+ });
+
+ // defaulted appointment by gender
+ $appointment_defaulted_female = Cache::remember('appointment_defaulted_female', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.gender', '=', '1')
+ ->count();
+ });
+ $appointment_defaulted_male = Cache::remember('appointment_defaulted_male', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.gender', '=', '2')
+ ->count();
+ });
+ $appointment_defaulted_uknown_gender = Cache::remember('appointment_defaulted_uknown_gender', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->count();
+ });
+
+ // defaulted appointment by age
+ $appointment_defaulted_to_nine = Cache::remember('appointment_defaulted_to_nine', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->pluck('count');
+ });
+ $appointment_defaulted_to_fourteen = Cache::remember('appointment_defaulted_to_fourteen', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->pluck('count');
+ });
+ $appointment_defaulted_to_nineteen = Cache::remember('appointment_defaulted_to_nineteen', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->pluck('count');
+ });
+ $appointment_defaulted_to_twentyfour = Cache::remember('appointment_defaulted_to_twentyfour', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->pluck('count');
+ });
+ $appointment_defaulted_to_twentyfive_above = Cache::remember('appointment_defaulted_to_twentyfive_above', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->pluck('count');
+ });
+ $appointment_defaulted_to_uknown_age = Cache::remember('appointment_defaulted_to_uknown_age', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_client.dob')
+ ->where('tbl_client.dob', '=', '')
+ ->orWhereNull('tbl_client.dob')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->count();
+ });
+ // ltfu appointment by gender
+ $appointment_ltfu_female = Cache::remember('appointment_ltfu_female', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.gender', '=', '1')
+ ->count();
+ });
+ $appointment_ltfu_male = Cache::remember('appointment_ltfu_male', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.gender', '=', '2')
+ ->count();
+ });
+ $appointment_ltfu_uknown_gender = Cache::remember('appointment_ltfu_uknown_gender', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->count();
+ });
+
+ // ltfu appointment by age
+ $appointment_ltfu_to_nine = Cache::remember('appointment_ltfu_to_nine', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->pluck('count');
+ });
+ $appointment_ltfu_to_fourteen = Cache::remember('appointment_ltfu_to_fourteen', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->pluck('count');
+ });
+ $appointment_ltfu_to_nineteen = Cache::remember('appointment_ltfu_to_nineteen', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->pluck('count');
+ });
+ $appointment_ltfu_to_twentyfour = Cache::remember('appointment_ltfu_to_twentyfour', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->pluck('count');
+ });
+ $appointment_ltfu_to_twentyfive_above = Cache::remember('appointment_ltfu_to_twentyfive_above', 10, function () {
+ return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
->pluck('count');
});
- $appointment_missed_to_uknown_age = Cache::remember('appointment_missed_to_uknown_age', 10, function () {
+ $appointment_ltfu_to_uknown_age = Cache::remember('appointment_ltfu_to_uknown_age', 10, function () {
return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
->select('tbl_client.dob')
->where('tbl_client.dob', '=', '')
->orWhereNull('tbl_client.dob')
- ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
->count();
});
+ }
- // defaulted appointment by gender
- $appointment_defaulted_female = Cache::remember('appointment_defaulted_female', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->where('tbl_client.gender', '=', '1')
- ->count();
- });
- $appointment_defaulted_male = Cache::remember('appointment_defaulted_male', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->where('tbl_client.gender', '=', '2')
- ->count();
- });
- $appointment_defaulted_uknown_gender = Cache::remember('appointment_defaulted_uknown_gender', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->where('tbl_client.gender', '!=', '1')
- ->where('tbl_client.gender', '!=', '2')
- ->count();
- });
- // defaulted appointment by age
- $appointment_defaulted_to_nine = Cache::remember('appointment_defaulted_to_nine', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->pluck('count');
- });
- $appointment_defaulted_to_fourteen = Cache::remember('appointment_defaulted_to_fourteen', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->pluck('count');
- });
- $appointment_defaulted_to_nineteen = Cache::remember('appointment_defaulted_to_nineteen', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->pluck('count');
- });
- $appointment_defaulted_to_twentyfour = Cache::remember('appointment_defaulted_to_twentyfour', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->pluck('count');
- });
- $appointment_defaulted_to_twentyfive_above = Cache::remember('appointment_defaulted_to_twentyfive_above', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->pluck('count');
- });
- $appointment_defaulted_to_uknown_age = Cache::remember('appointment_defaulted_to_uknown_age', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select('tbl_client.dob')
- ->where('tbl_client.dob', '=', '')
- ->orWhereNull('tbl_client.dob')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->count();
- });
- // ltfu appointment by gender
- $appointment_ltfu_female = Cache::remember('appointment_ltfu_female', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->where('tbl_client.gender', '=', '1')
- ->count();
- });
- $appointment_ltfu_male = Cache::remember('appointment_ltfu_male', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->where('tbl_client.gender', '=', '2')
- ->count();
- });
- $appointment_ltfu_uknown_gender = Cache::remember('appointment_ltfu_uknown_gender', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->where('tbl_client.gender', '!=', '1')
- ->where('tbl_client.gender', '!=', '2')
- ->count();
- });
+ return view('new_dashboard.appointment_dashboard', compact('all_partners', 'appointment', 'appointment_honoured',
+ 'appointment_not_honoured',
+ 'appointment_honoured_male',
+ 'appointment_honoured_female',
+ 'appointment_honoured_uknown_gender',
+ 'appointment_honored_to_nine',
+ 'appointment_honored_to_fourteen',
+ 'appointment_honored_to_nineteen',
+ 'appointment_honored_to_twentyfour',
+ 'appointment_honored_to_twentyfive_above',
+ 'appointment_honored_to_uknown_age',
+ 'appointment_not_honoured_male',
+ 'appointment_not_honoured_female',
+ 'appointment_not_honoured_uknown_gender',
+ 'appointment_not_honored_to_nine',
+ 'appointment_not_honored_to_fourteen',
+ 'appointment_not_honored_to_nineteen',
+ 'appointment_not_honored_to_twentyfour',
+ 'appointment_not_honored_to_twentyfive_above',
+ 'appointment_not_honored_to_uknown_age',
+ 'appointment_missed',
+ 'appointment_defaulted',
+ 'appointment_lftu',
+ 'appointment_missed_female',
+ 'appointment_missed_male',
+ 'appointment_missed_uknown_gender',
+ 'appointment_missed_to_nine',
+ 'appointment_missed_to_fourteen',
+ 'appointment_missed_to_nineteen',
+ 'appointment_missed_to_twentyfour',
+ 'appointment_missed_to_twentyfive_above',
+ 'appointment_missed_to_uknown_age',
+ 'appointment_defaulted_female',
+ 'appointment_defaulted_male',
+ 'appointment_defaulted_uknown_gender',
+ 'appointment_defaulted_to_nine',
+ 'appointment_defaulted_to_fourteen',
+ 'appointment_defaulted_to_nineteen',
+ 'appointment_defaulted_to_twentyfour',
+ 'appointment_defaulted_to_twentyfive_above',
+ 'appointment_defaulted_to_uknown_age',
+ 'appointment_ltfu_female',
+ 'appointment_ltfu_male',
+ 'appointment_ltfu_uknown_gender',
+ 'appointment_ltfu_to_nine',
+ 'appointment_ltfu_to_fourteen',
+ 'appointment_ltfu_to_nineteen',
+ 'appointment_ltfu_to_twentyfour',
+ 'appointment_ltfu_to_twentyfive_above',
+ 'appointment_ltfu_to_uknown_age'
+ ));
+ }
+
+ public function filter_charts(Request $request)
+ {
+ // $data = [];
+
+ $selected_partners = $request->partners;
+ $selected_counties = $request->counties;
+ $selected_subcounties = $request->subcounties;
+ $selected_facilites = $request->facilities;
+
+ if (Auth::user()->access_level == 'Facility'){}
+ if (Auth::user()->access_level == 'Partner'){}
+
+ $client = Client::where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
+ $appointment = Appointments::select('id')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
+ $missed_appointment = Appointments::select('id')
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
+ $active_facilities = PartnerFacility::join('tbl_client', 'tbl_partner_facility.mfl_code', '=', 'tbl_client.mfl_code')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select('tbl_partner_facility.mfl_code')
+ ->where('tbl_appointment.created_at', '>=', Carbon::now()->subMonths(6))
+ ->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ ->orderBy('tbl_appointment.created_at', 'DESC')
+ ->groupBy('tbl_partner_facility.mfl_code')
+ ->get();
+ // active clients by gender
+ $clients_male = Client::select('id')
+ ->where([['gender', '=', '2'], ['status', '=', 'Active'],])
+ ->whereNull('hei_no')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
+
+ $clients_female = Client::where('gender', '=', '1')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
+ $unknown_gender = Client::where('gender', '!=', '1')
+ ->where('gender', '!=', '2')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
+
+ $client_to_nine = Client::select(\DB::raw("count((case when (((year(curdate()) - year(`dob`)) > 0) and ((year(curdate()) - year(`dob`)) <= 9)) then `dob` end"))
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
+
+ $client_to_fourteen = Client::select(\DB::raw("case when (((year(curdate()) - year(`dob`)) >= 10) and ((year(curdate()) - year(`dob`)) <= 14)) then `dob` end"))
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
+
+
+ $client_to_nineteen = Client::select(\DB::raw("case when (((year(curdate()) - year(`dob`)) >= 15) and ((year(curdate()) - year(`dob`)) <= 19)) then `dob` end"))
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
+
+
+ $client_to_twentyfour = Client::select(\DB::raw("case when (((year(curdate()) - year(`dob`)) >= 20) and ((year(curdate()) - year(`dob`)) <= 24)) then `id` end"))
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
+
+
+ $client_to_twentyfive_above = Client::select(\DB::raw("case when (((year(curdate()) - year(`dob`)) >= 25)) then `id` end"))
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
+
+
+ $client_unknown_age = Client::where('dob', '=', '')
+ ->orWhereNull('dob')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
+
+
+ // appointment by gender
+ $appointment_male = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_appointment.id')
+ ->where('tbl_client.gender', '=', '2')
+ ->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+
+ $appointment_female = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_appointment.id')
+ ->where('tbl_client.gender', '=', '1')
+ ->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+
+ $appointment_uknown_gender = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_appointment.id')
+ ->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+
+ // appointment by age
+ $appointment_to_nine = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end"))
+ ->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+
+ $appointment_to_fourteen = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end"))
+
+ $appointment_to_nineteen = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end"))
+ ->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+
+
+ $appointment_to_twentyfour = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end"))
+ ->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+
+
+ $appointment_to_twentyfive_above = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end"))
+ ->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+
+
+ $appointment_uknown_age = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.dob', '=', '')
+ ->orWhereNull('tbl_client.dob')
+ ->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+
+
+ // Total missed appointment by gender
+ $appointment_total_missed_female = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_client.gender', '=', '1')
+ ->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+
+ $appointment_total_missed_male = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_client.gender', '=', '2')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+
+
+ $appointment_total_missed_uknown_gender = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+
+
+ // Total missed appointment by age
+ $appointment_total_missed_to_nine = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+
+ $appointment_total_missed_to_fourteen = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+
+ $appointment_total_missed_to_nineteen = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+
+ $appointment_total_missed_to_twentyfour = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+
+ $appointment_total_missed_to_twentyfive_above = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+
+ $appointment_total_missed_uknown_age = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_client.dob', '=', '')
+ ->orWhereNull('tbl_client.dob')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+
+ // client charts
+ $client_consented = Client::select('smsenable')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('smsenable', '=', 'Yes')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
+
+ $client_nonconsented = Client::select('smsenable')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('smsenable', '!=', 'Yes')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
+
+ // consented clients by gender
+
+ $client_consented_male = Client::where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('gender', '=', '2')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
+
+ $client_consented_female = Client::where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('gender', '=', '1')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
+
+ $client_consented_uknown_gender = Client::where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('gender', '!=', '1')
+ ->where('gender', '!=', '2')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
+
+ // non consented clients by gender
+ $client_nonconsented_male = Client::where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('gender', '=', '2')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
+
+
+ $client_nonconsented_female = Client::where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('gender', '=', '1')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
+
+ $client_nonconsented_uknown_gender = Client::where('smsenable', '!=', 'Yes')
+ ->where('gender', '!=', '1')
+ ->where('gender', '!=', '2')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
+
+ // consented clients by age distribution
+ $client_consented_to_nine = Client::select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end"))
+ ->where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
+
+ $client_consented_to_fourteen = Client::select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end"))
+ ->where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
- // ltfu appointment by age
- $appointment_ltfu_to_nine = Cache::remember('appointment_ltfu_to_nine', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->pluck('count');
- });
- $appointment_ltfu_to_fourteen = Cache::remember('appointment_ltfu_to_fourteen', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->pluck('count');
- });
- $appointment_ltfu_to_nineteen = Cache::remember('appointment_ltfu_to_nineteen', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->pluck('count');
- });
- $appointment_ltfu_to_twentyfour = Cache::remember('appointment_ltfu_to_twentyfour', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->pluck('count');
- });
- $appointment_ltfu_to_twentyfive_above = Cache::remember('appointment_ltfu_to_twentyfive_above', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->pluck('count');
- });
- $appointment_ltfu_to_uknown_age = Cache::remember('appointment_ltfu_to_uknown_age', 10, function () {
- return Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
- ->select('tbl_client.dob')
- ->where('tbl_client.dob', '=', '')
- ->orWhereNull('tbl_client.dob')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->count();
- });
- }
+ $client_consented_to_nineteen = Client::select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end"))
+ ->where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
+ $client_consented_to_twentyfour = Client::select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end"))
+ ->where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
- return view('new_dashboard.appointment_dashboard', compact('all_partners', 'appointment', 'appointment_honoured',
- 'appointment_not_honoured',
- 'appointment_honoured_male',
- 'appointment_honoured_female',
- 'appointment_honoured_uknown_gender',
- 'appointment_honored_to_nine',
- 'appointment_honored_to_fourteen',
- 'appointment_honored_to_nineteen',
- 'appointment_honored_to_twentyfour',
- 'appointment_honored_to_twentyfive_above',
- 'appointment_honored_to_uknown_age',
- 'appointment_not_honoured_male',
- 'appointment_not_honoured_female',
- 'appointment_not_honoured_uknown_gender',
- 'appointment_not_honored_to_nine',
- 'appointment_not_honored_to_fourteen',
- 'appointment_not_honored_to_nineteen',
- 'appointment_not_honored_to_twentyfour',
- 'appointment_not_honored_to_twentyfive_above',
- 'appointment_not_honored_to_uknown_age',
- 'appointment_missed',
- 'appointment_defaulted',
- 'appointment_lftu',
- 'appointment_missed_female',
- 'appointment_missed_male',
- 'appointment_missed_uknown_gender',
- 'appointment_missed_to_nine',
- 'appointment_missed_to_fourteen',
- 'appointment_missed_to_nineteen',
- 'appointment_missed_to_twentyfour',
- 'appointment_missed_to_twentyfive_above',
- 'appointment_missed_to_uknown_age',
- 'appointment_defaulted_female',
- 'appointment_defaulted_male',
- 'appointment_defaulted_uknown_gender',
- 'appointment_defaulted_to_nine',
- 'appointment_defaulted_to_fourteen',
- 'appointment_defaulted_to_nineteen',
- 'appointment_defaulted_to_twentyfour',
- 'appointment_defaulted_to_twentyfive_above',
- 'appointment_defaulted_to_uknown_age',
- 'appointment_ltfu_female',
- 'appointment_ltfu_male',
- 'appointment_ltfu_uknown_gender',
- 'appointment_ltfu_to_nine',
- 'appointment_ltfu_to_fourteen',
- 'appointment_ltfu_to_nineteen',
- 'appointment_ltfu_to_twentyfour',
- 'appointment_ltfu_to_twentyfive_above',
- 'appointment_ltfu_to_uknown_age'
- ));
- }
+ $client_consented_to_twentyfive_above = Client::select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end"))
+ ->where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
- public function filter_charts(Request $request)
- {
- // $data = [];
+ $client_consented_uknown_age = Client::select('smsenable')
+ ->where('dob', '=', '')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->orWhereNull('dob')
+ ->where('smsenable', '=', 'Yes')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
+
+ // non consented clients by age distribution
+ $client_nonconsented_to_nine = Client::select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end"))
+ ->where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
+
+ $client_nonconsented_to_fourteen = Client::select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end"))
+ ->where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
+
+ $client_nonconsented_to_nineteen = Client::select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end"))
+ ->where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
+
+ $client_nonconsented_to_twentyfour = Client::select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end"))
+ ->where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
+
+ $client_nonconsented_to_twentyfive_above = Client::select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end"))
+ ->where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
- // $selected_counties = $request->partners;
- // $selected_counties = $request->counties;
- // $selected_subcounties = $request->subcounties;
- // $selected_facilites = $request->facilities;
+ $client_nonconsented_uknown_age = Client::select('smsenable')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('dob', '=', '')
+ ->orWhereNull('dob')
+ ->where('smsenable', '!=', 'Yes')
+ ->where('created_at', '>=', date($request->from))->where('created_at', '<=', date($request->to));
+
+ if (!empty($selected_partners)) {
+ $client = $client->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment = $appointment->where('tbl_partner_facility.partner_id', $selected_partners);
+ $missed_appointment = $missed_appointment->where('tbl_partner_facility.partner_id', $selected_partners);
+ $active_facilities = $active_facilities->where('tbl_partner_facility.partner_id', $selected_partners);
+ $clients_male = $clients_male->where('tbl_partner_facility.partner_id', $selected_partners);
+ $clients_female = $clients_female->where('tbl_partner_facility.partner_id', $selected_partners);
+ $unknown_gender = $unknown_gender->where('tbl_partner_facility.partner_id', $selected_partners);
+ $client_to_nine = $client_to_nine->where('tbl_partner_facility.partner_id', $selected_partners);
+ $client_to_fourteen = $client_to_fourteen->where('tbl_partner_facility.partner_id', $selected_partners);
+ $client_to_nineteen = $client_to_nineteen->where('tbl_partner_facility.partner_id', $selected_partners);
+ $client_to_twentyfour = $client_to_twentyfour->where('tbl_partner_facility.partner_id', $selected_partners);
+ $client_to_twentyfive_above = $client_to_twentyfive_above->where('tbl_partner_facility.partner_id', $selected_partners);
+ $client_unknown_age = $client_unknown_age->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_male = $appointment_male->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_female = $appointment_female->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_uknown_gender = $appointment_uknown_gender->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_to_nine = $appointment_to_nine->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_to_fourteen = $appointment_to_fourteen->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_to_nineteen = $appointment_to_nineteen->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_to_twentyfour = $appointment_to_twentyfour->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_to_twentyfive_above = $appointment_to_twentyfive_above->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_uknown_age = $appointment_uknown_age->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_total_missed_female = $appointment_total_missed_female->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_total_missed_male = $appointment_total_missed_male->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_total_missed_uknown_gender = $appointment_total_missed_uknown_gender->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_total_missed_to_nine = $appointment_total_missed_to_nine->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_total_missed_to_fourteen = $appointment_total_missed_to_fourteen->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_total_missed_to_nineteen = $appointment_total_missed_to_nineteen->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_total_missed_to_twentyfour = $appointment_total_missed_to_twentyfour->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_total_missed_to_twentyfive_above = $appointment_total_missed_to_twentyfive_above->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_total_missed_uknown_age = $appointment_total_missed_uknown_age->where('tbl_partner_facility.partner_id', $selected_partners);
+
+ $client_consented = $client_consented->where('tbl_partner_facility.partner_id', $selected_partners);
+ $client_nonconsented = $client_nonconsented->where('tbl_partner_facility.partner_id', $selected_partners);
+ $client_consented_male = $client_consented_male->where('tbl_partner_facility.partner_id', $selected_partners);
+ $client_consented_female = $client_consented_female->where('tbl_partner_facility.partner_id', $selected_partners);
+ $client_consented_uknown_gender = $client_consented_uknown_gender->where('tbl_partner_facility.partner_id', $selected_partners);
+ $client_nonconsented_male = $client_nonconsented_male->where('tbl_partner_facility.partner_id', $selected_partners);
+ $client_nonconsented_female = $client_nonconsented_female->where('tbl_partner_facility.partner_id', $selected_partners);
+ $client_nonconsented_uknown_gender = $client_nonconsented_uknown_gender->where('tbl_partner_facility.partner_id', $selected_partners);
+ $client_consented_to_nine = $client_consented_to_nine->where('tbl_partner_facility.partner_id', $selected_partners);
+ $client_consented_to_fourteen = $client_consented_to_fourteen->where('tbl_partner_facility.partner_id', $selected_partners);
+ $client_consented_to_nineteen = $client_consented_to_nineteen->where('tbl_partner_facility.partner_id', $selected_partners);
+ $client_consented_to_twentyfour = $client_consented_to_twentyfour->where('tbl_partner_facility.partner_id', $selected_partners);
+ $client_consented_to_twentyfive_above = $client_consented_to_twentyfive_above->where('tbl_partner_facility.partner_id', $selected_partners);
+ $client_consented_uknown_age = $client_consented_uknown_age->where('tbl_partner_facility.partner_id', $selected_partners);
+ $client_nonconsented_to_nine = $client_nonconsented_to_nine->where('tbl_partner_facility.partner_id', $selected_partners);
+ $client_nonconsented_to_fourteen = $client_nonconsented_to_fourteen->where('tbl_partner_facility.partner_id', $selected_partners);
+ $client_nonconsented_to_nineteen = $client_nonconsented_to_nineteen->where('tbl_partner_facility.partner_id', $selected_partners);
+ $client_nonconsented_to_twentyfour = $client_nonconsented_to_twentyfour->where('tbl_partner_facility.partner_id', $selected_partners);
+ $client_nonconsented_to_twentyfive_above = $client_nonconsented_to_twentyfive_above->where('tbl_partner_facility.partner_id', $selected_partners);
+ $client_nonconsented_uknown_age = $client_nonconsented_to_twentyfive_aboclient_nonconsented_uknown_ageve->where('tbl_partner_facility.partner_id', $selected_partners);
+ }
+ if (!empty($selected_counties)) {
+ $client = $client->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment = $appointment->where('tbl_partner_facility.county_id', $selected_counties);
+ $missed_appointment = $missed_appointment->where('tbl_partner_facility.county_id', $selected_counties);
+ $active_facilities = $active_facilities->where('tbl_partner_facility.county_id', $selected_counties);
+ $clients_male = $clients_male->where('tbl_partner_facility.county_id', $selected_counties);
+ $clients_female = $clients_female->where('tbl_partner_facility.county_id', $selected_counties);
+ $unknown_gender = $unknown_gender->where('tbl_partner_facility.county_id', $selected_counties);
+ $client_to_nine = $client_to_nine->where('tbl_partner_facility.county_id', $selected_counties);
+ $client_to_fourteen = $client_to_fourteen->where('tbl_partner_facility.county_id', $selected_counties);
+ $client_to_nineteen = $client_to_nineteen->where('tbl_partner_facility.county_id', $selected_counties);
+ $client_to_twentyfour = $client_to_twentyfour->where('tbl_partner_facility.county_id', $selected_counties);
+ $client_to_twentyfive_above = $client_to_twentyfive_above->where('tbl_partner_facility.county_id', $selected_counties);
+ $client_unknown_age = $client_unknown_age->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_male = $appointment_male->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_female = $appointment_female->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_uknown_gender = $appointment_uknown_gender->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_to_nine = $appointment_to_nine->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_to_fourteen = $appointment_to_fourteen->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_to_nineteen = $appointment_to_nineteen->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_to_twentyfour = $appointment_to_twentyfour->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_to_twentyfive_above = $appointment_to_twentyfive_above->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_uknown_age = $appointment_uknown_age->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_total_missed_female = $appointment_total_missed_female->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_total_missed_male = $appointment_total_missed_male->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_total_missed_uknown_gender = $appointment_total_missed_uknown_gender->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_total_missed_to_nine = $appointment_total_missed_to_nine->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_total_missed_to_fourteen = $appointment_total_missed_to_fourteen->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_total_missed_to_nineteen = $appointment_total_missed_to_nineteen->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_total_missed_to_twentyfour = $appointment_total_missed_to_twentyfour->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_total_missed_to_twentyfive_above = $appointment_total_missed_to_twentyfive_above->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_total_missed_uknown_age = $appointment_total_missed_uknown_age->where('tbl_partner_facility.county_id', $selected_counties);
+
+ $client_consented = $client_consented->where('tbl_partner_facility.county_id', $selected_counties);
+ $client_nonconsented = $client_nonconsented->where('tbl_partner_facility.county_id', $selected_counties);
+ $client_consented_male = $client_consented_male->where('tbl_partner_facility.county_id', $selected_counties);
+ $client_consented_female = $client_consented_female->where('tbl_partner_facility.county_id', $selected_counties);
+ $client_consented_uknown_gender = $client_consented_uknown_gender->where('tbl_partner_facility.county_id', $selected_counties);
+ $client_nonconsented_male = $client_nonconsented_male->where('tbl_partner_facility.county_id', $selected_counties);
+ $client_nonconsented_female = $client_nonconsented_female->where('tbl_partner_facility.county_id', $selected_counties);
+ $client_nonconsented_uknown_gender = $client_nonconsented_uknown_gender->where('tbl_partner_facility.county_id', $selected_counties);
+ $client_consented_to_nine = $client_consented_to_nine->where('tbl_partner_facility.county_id', $selected_counties);
+ $client_consented_to_fourteen = $client_consented_to_fourteen->where('tbl_partner_facility.county_id', $selected_counties);
+ $client_consented_to_nineteen = $client_consented_to_nineteen->where('tbl_partner_facility.county_id', $selected_counties);
+ $client_consented_to_twentyfour = $client_consented_to_twentyfour->where('tbl_partner_facility.county_id', $selected_counties);
+ $client_consented_to_twentyfive_above = $client_consented_to_twentyfive_above->where('tbl_partner_facility.county_id', $selected_counties);
+ $client_consented_uknown_age = $client_consented_uknown_age->where('tbl_partner_facility.county_id', $selected_counties);
+ $client_nonconsented_to_nine = $client_nonconsented_to_nine->where('tbl_partner_facility.county_id', $selected_counties);
+ $client_nonconsented_to_fourteen = $client_nonconsented_to_fourteen->where('tbl_partner_facility.county_id', $selected_counties);
+ $client_nonconsented_to_nineteen = $client_nonconsented_to_nineteen->where('tbl_partner_facility.county_id', $selected_counties);
+ $client_nonconsented_to_twentyfour = $client_nonconsented_to_twentyfour->where('tbl_partner_facility.county_id', $selected_counties);
+ $client_nonconsented_to_twentyfive_above = $client_nonconsented_to_twentyfive_above->where('tbl_partner_facility.county_id', $selected_counties);
+ $client_nonconsented_uknown_age = $client_nonconsented_to_twentyfive_aboclient_nonconsented_uknown_ageve->where('tbl_partner_facility.county_id', $selected_counties);
+ }
+ if (!empty($selected_subcounties)) {
+ $client = $client->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment = $appointment->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $missed_appointment = $missed_appointment->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $active_facilities = $active_facilities->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $clients_male = $clients_male->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $clients_female = $clients_female->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $unknown_gender = $unknown_gender->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $client_to_nine = $client_to_nine->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $client_to_fourteen = $client_to_fourteen->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $client_to_nineteen = $client_to_nineteen->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $client_to_twentyfour = $client_to_twentyfour->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $client_to_twentyfive_above = $client_to_twentyfive_above->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $client_unknown_age = $client_unknown_age->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_male = $appointment_male->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_female = $appointment_female->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_uknown_gender = $appointment_uknown_gender->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_to_nine = $appointment_to_nine->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_to_fourteen = $appointment_to_fourteen->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_to_nineteen = $appointment_to_nineteen->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_to_twentyfour = $appointment_to_twentyfour->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_to_twentyfive_above = $appointment_to_twentyfive_above->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_uknown_age = $appointment_uknown_age->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_total_missed_female = $appointment_total_missed_female->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_total_missed_male = $appointment_total_missed_male->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_total_missed_uknown_gender = $appointment_total_missed_uknown_gender->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_total_missed_to_nine = $appointment_total_missed_to_nine->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_total_missed_to_fourteen = $appointment_total_missed_to_fourteen->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_total_missed_to_nineteen = $appointment_total_missed_to_nineteen->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_total_missed_to_twentyfour = $appointment_total_missed_to_twentyfour->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_total_missed_to_twentyfive_above = $appointment_total_missed_to_twentyfive_above->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_total_missed_uknown_age = $appointment_total_missed_uknown_age->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+
+ $client_consented = $client_consented->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $client_nonconsented = $client_nonconsented->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $client_consented_male = $client_consented_male->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $client_consented_female = $client_consented_female->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $client_consented_uknown_gender = $client_consented_uknown_gender->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $client_nonconsented_male = $client_nonconsented_male->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $client_nonconsented_female = $client_nonconsented_female->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $client_nonconsented_uknown_gender = $client_nonconsented_uknown_gender->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $client_consented_to_nine = $client_consented_to_nine->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $client_consented_to_fourteen = $client_consented_to_fourteen->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $client_consented_to_nineteen = $client_consented_to_nineteen->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $client_consented_to_twentyfour = $client_consented_to_twentyfour->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $client_consented_to_twentyfive_above = $client_consented_to_twentyfive_above->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $client_consented_uknown_age = $client_consented_uknown_age->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $client_nonconsented_to_nine = $client_nonconsented_to_nine->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $client_nonconsented_to_fourteen = $client_nonconsented_to_fourteen->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $client_nonconsented_to_nineteen = $client_nonconsented_to_nineteen->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $client_nonconsented_to_twentyfour = $client_nonconsented_to_twentyfour->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $client_nonconsented_to_twentyfive_above = $client_nonconsented_to_twentyfive_above->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $client_nonconsented_uknown_age = $client_nonconsented_to_twentyfive_aboclient_nonconsented_uknown_ageve->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ }
+ if (!empty($selected_facilites)) {
+ $client = $client->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment = $appointment->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $missed_appointment = $missed_appointment->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $active_facilities = $active_facilities->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $clients_male = $clients_male->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $clients_female = $clients_female->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $unknown_gender = $unknown_gender->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $client_to_nine = $client_to_nine->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $client_to_fourteen = $client_to_fourteen->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $client_to_nineteen = $client_to_nineteen->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $client_to_twentyfour = $client_to_twentyfour->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $client_to_twentyfive_above = $client_to_twentyfive_above->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $client_unknown_age = $client_unknown_age->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_male = $appointment_male->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_female = $appointment_female->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_uknown_gender = $appointment_uknown_gender->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_to_nine = $appointment_to_nine->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_to_fourteen = $appointment_to_fourteen->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_to_nineteen = $appointment_to_nineteen->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_to_twentyfour = $appointment_to_twentyfour->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_to_twentyfive_above = $appointment_to_twentyfive_above->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_uknown_age = $appointment_uknown_age->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_total_missed_female = $appointment_total_missed_female->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_total_missed_male = $appointment_total_missed_male->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_total_missed_uknown_gender = $appointment_total_missed_uknown_gender->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_total_missed_to_nine = $appointment_total_missed_to_nine->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_total_missed_to_fourteen = $appointment_total_missed_to_fourteen->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_total_missed_to_nineteen = $appointment_total_missed_to_nineteen->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_total_missed_to_twentyfour = $appointment_total_missed_to_twentyfour->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_total_missed_to_twentyfive_above = $appointment_total_missed_to_twentyfive_above->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_total_missed_uknown_age = $appointment_total_missed_uknown_age->where('tbl_partner_facility.mfl_code', $selected_facilites);
+
+ $client_consented = $client_consented->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $client_nonconsented = $client_nonconsented->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $client_consented_male = $client_consented_male->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $client_consented_female = $client_consented_female->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $client_consented_uknown_gender = $client_consented_uknown_gender->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $client_nonconsented_male = $client_nonconsented_male->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $client_nonconsented_female = $client_nonconsented_female->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $client_nonconsented_uknown_gender = $client_nonconsented_uknown_gender->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $client_consented_to_nine = $client_consented_to_nine->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $client_consented_to_fourteen = $client_consented_to_fourteen->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $client_consented_to_nineteen = $client_consented_to_nineteen->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $client_consented_to_twentyfour = $client_consented_to_twentyfour->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $client_consented_to_twentyfive_above = $client_consented_to_twentyfive_above->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $client_consented_uknown_age = $client_consented_uknown_age->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $client_nonconsented_to_nine = $client_nonconsented_to_nine->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $client_nonconsented_to_fourteen = $client_nonconsented_to_fourteen->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $client_nonconsented_to_nineteen = $client_nonconsented_to_nineteen->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $client_nonconsented_to_twentyfour = $client_nonconsented_to_twentyfour->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $client_nonconsented_to_twentyfive_above = $client_nonconsented_to_twentyfive_above->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $client_nonconsented_uknown_age = $client_nonconsented_to_twentyfive_aboclient_nonconsented_uknown_ageve->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ }
+ $data["client"] = $client->count();
+ $data["appointment"] = $appointment->count();
+ $data["missed_appointment"] = $missed_appointment->count();
+ $data["clients_male"] = $clients_male->count();
+ $data["clients_female"] = $clients_female->count();
+ $data["unknown_gender"] = $unknown_gender->count();
+ $data["client_to_nine"] = $client_to_nine->count();
+ $data["client_to_fourteen"] = $client_to_fourteen->count();
+ $data["client_to_nineteen"] = $client_to_nineteen->count();
+ $data["client_to_twentyfour"] = $client_to_twentyfour->count();
+ $data["client_to_twentyfive_above"] = $client_to_twentyfive_above->count();
+ $data["client_unknown_age"] = $client_unknown_age->count();
+ $data["appointment_male"] = $appointment_male->count();
+ $data["appointment_female"] = $appointment_female->count();
+ $data["appointment_uknown_gender"] = $appointment_uknown_gender->count();
+ $data["appointment_to_nine"] = $appointment_to_nine->count();
+ $data["appointment_to_fourteen"] = $appointment_to_fourteen->count();
+ $data["appointment_to_nineteen"] = $appointment_to_nineteen->count();
+ $data["appointment_to_twentyfour"] = $appointment_to_twentyfour->count();
+ $data["appointment_to_twentyfive_above"] = $appointment_to_twentyfive_above->count();
+ $data["appointment_uknown_age"] = $appointment_uknown_age->count();
+ $data["appointment_total_missed_female"] = $appointment_total_missed_female->count();
+ $data["appointment_total_missed_male"] = $appointment_total_missed_male->count();
+ $data["appointment_total_missed_uknown_gender"] = $appointment_total_missed_uknown_gender->count();
+ $data["appointment_total_missed_to_nine"] = $appointment_total_missed_to_nine->count();
+ $data["appointment_total_missed_to_fourteen"] = $appointment_total_missed_to_fourteen->count();
+ $data["appointment_total_missed_to_nineteen"] = $appointment_total_missed_to_nineteen->count();
+ $data["appointment_total_missed_to_twentyfour"] = $appointment_total_missed_to_twentyfour->count();
+ $data["appointment_total_missed_to_twentyfive_above"] = $appointment_total_missed_to_twentyfive_above->count();
+ $data["appointment_total_missed_uknown_age"] = $appointment_total_missed_uknown_age->count();
+
+ $data["client_consented"] = $client_consented->count();
+ $data["client_nonconsented"] = $client_nonconsented->count();
+ $data["client_consented_male"] = $client_consented_male->count();
+ $data["client_consented_female"] = $client_consented_female->count();
+ $data["client_consented_uknown_gender"] = $client_consented_uknown_gender->count();
+ $data["client_nonconsented_male"] = $client_nonconsented_male->count();
+ $data["client_nonconsented_female"] = $client_nonconsented_female->count();
+ $data["client_nonconsented_uknown_gender"] = $client_nonconsented_uknown_gender->count();
+ $data["client_consented_to_nine"] = $client_consented_to_nine->count();
+ $data["client_consented_to_fourteen"] = $client_consented_to_fourteen->count();
+ $data["client_consented_to_nineteen"] = $client_consented_to_nineteen->count();
+ $data["client_consented_to_twentyfour"] = $client_consented_to_twentyfour->count();
+ $data["client_consented_to_twentyfive_above"] = $client_consented_to_twentyfive_above->count();
+ $data["client_consented_uknown_age"] = $client_consented_uknown_age->count();
+ $data["client_nonconsented_to_nine"] = $client_nonconsented_to_nine->count();
+ $data["client_nonconsented_to_fourteen"] = $client_nonconsented_to_fourteen->count();
+ $data["client_nonconsented_to_nineteen"] = $client_nonconsented_to_nineteen->count();
+ $data["client_nonconsented_to_twentyfour"] = $client_nonconsented_to_twentyfour->count();
+ $data["client_nonconsented_to_twentyfive_above"] = $client_nonconsented_to_twentyfive_above->count();
+ $data["client_nonconsented_uknown_age"] = $client_nonconsented_uknown_age->count();
if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
@@ -1961,112 +3623,7 @@ public function filter_charts(Request $request)
->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to))
->count();
}
- return view('new_dashboard.main_dashbaord', compact(
- 'all_partners',
- 'active_facilities',
- 'indicator',
- 'client',
- 'appointment',
- 'missed_appointment',
- 'clients_male',
- 'clients_female',
- 'unknown_gender',
- 'client_to_nine',
- 'client_to_fourteen',
- 'client_to_nineteen',
- 'client_to_twentyfour',
- 'client_to_twentyfive_above',
- 'client_unknown_age',
- 'appointment_male',
- 'appointment_female',
- 'appointment_uknown_gender',
- 'appointment_to_nine',
- 'appointment_to_fourteen',
- 'appointment_to_nineteen',
- 'appointment_to_twentyfour',
- 'appointment_to_twentyfive_above',
- 'appointment_uknown_age',
- 'appointment_total_missed_female',
- 'appointment_total_missed_male',
- 'appointment_total_missed_uknown_gender',
- 'appointment_total_missed_to_nine',
- 'appointment_total_missed_to_fourteen',
- 'appointment_total_missed_to_nineteen',
- 'appointment_total_missed_to_twentyfour',
- 'appointment_total_missed_to_twentyfive_above',
- 'appointment_total_missed_uknown_age',
- 'client_consented',
- 'client_nonconsented',
- 'client_consented_male',
- 'client_consented_female',
- 'client_consented_uknown_gender',
- 'client_nonconsented_male',
- 'client_nonconsented_female',
- 'client_nonconsented_uknown_gender',
- 'client_consented_to_nine',
- 'client_consented_to_fourteen',
- 'client_consented_to_nineteen',
- 'client_consented_to_twentyfour',
- 'client_consented_to_twentyfive_above',
- 'client_consented_uknown_age',
- 'client_nonconsented_to_nine',
- 'client_nonconsented_to_fourteen',
- 'client_nonconsented_to_nineteen',
- 'client_nonconsented_to_twentyfour',
- 'client_nonconsented_to_twentyfive_above',
- 'client_nonconsented_uknown_age',
- 'appointment_honoured',
- 'appointment_not_honoured',
- 'appointment_honoured_male',
- 'appointment_honoured_female',
- 'appointment_honoured_uknown_gender',
- 'appointment_honored_to_nine',
- 'appointment_honored_to_fourteen',
- 'appointment_honored_to_nineteen',
- 'appointment_honored_to_twentyfour',
- 'appointment_honored_to_twentyfive_above',
- 'appointment_honored_to_uknown_age',
- 'appointment_not_honoured_male',
- 'appointment_not_honoured_female',
- 'appointment_not_honoured_uknown_gender',
- 'appointment_not_honored_to_nine',
- 'appointment_not_honored_to_fourteen',
- 'appointment_not_honored_to_nineteen',
- 'appointment_not_honored_to_twentyfour',
- 'appointment_not_honored_to_twentyfive_above',
- 'appointment_not_honored_to_uknown_age',
- 'appointment_missed',
- 'appointment_defaulted',
- 'appointment_lftu',
- 'appointment_missed_female',
- 'appointment_missed_male',
- 'appointment_missed_uknown_gender',
- 'appointment_missed_to_nine',
- 'appointment_missed_to_fourteen',
- 'appointment_missed_to_nineteen',
- 'appointment_missed_to_twentyfour',
- 'appointment_missed_to_twentyfive_above',
- 'appointment_missed_to_uknown_age',
- 'appointment_defaulted_female',
- 'appointment_defaulted_male',
- 'appointment_defaulted_uknown_gender',
- 'appointment_defaulted_to_nine',
- 'appointment_defaulted_to_fourteen',
- 'appointment_defaulted_to_nineteen',
- 'appointment_defaulted_to_twentyfour',
- 'appointment_defaulted_to_twentyfive_above',
- 'appointment_defaulted_to_uknown_age',
- 'appointment_ltfu_female',
- 'appointment_ltfu_male',
- 'appointment_ltfu_uknown_gender',
- 'appointment_ltfu_to_nine',
- 'appointment_ltfu_to_fourteen',
- 'appointment_ltfu_to_nineteen',
- 'appointment_ltfu_to_twentyfour',
- 'appointment_ltfu_to_twentyfive_above',
- 'appointment_ltfu_to_uknown_age'
-
- ));
+ return view('new_dashboard.main_dashbaord', compact('data'));
}
diff --git a/app/Models/Appointments.php b/app/Models/Appointments.php
index 2607c10..d688f06 100644
--- a/app/Models/Appointments.php
+++ b/app/Models/Appointments.php
@@ -13,7 +13,7 @@ class Appointments extends Model
public $incrementing = false;
protected $fillable = [
- 'app_type_1', 'reason', 'appntmnt_date', 'date_attended'
+ 'client_id', 'app_type_1', 'reason', 'appntmnt_date', 'date_attended'
];
diff --git a/app/Models/Client.php b/app/Models/Client.php
index b72e7f2..5e3a1d2 100644
--- a/app/Models/Client.php
+++ b/app/Models/Client.php
@@ -22,6 +22,10 @@ class Client extends Model
// {
// return Carbon::parse($this->attributes['dob'])->age;
// }
+ public function appointments()
+ {
+ return $this->hasMany(Appointments::class);
+ }
}
diff --git a/config/app.php b/config/app.php
index 608bad4..b797cff 100644
--- a/config/app.php
+++ b/config/app.php
@@ -175,7 +175,7 @@
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
Maatwebsite\Excel\ExcelServiceProvider::class,
- // Barryvdh\Debugbar\ServiceProvider::class,
+ Barryvdh\Debugbar\ServiceProvider::class,
// MaddHatter\LaravelFullcalendar\ServiceProvider::class,
diff --git a/resources/views/new_dashboard/appointment_dashboard.blade.php b/resources/views/new_dashboard/appointment_dashboard.blade.php
index 5f89b79..b28af7f 100644
--- a/resources/views/new_dashboard/appointment_dashboard.blade.php
+++ b/resources/views/new_dashboard/appointment_dashboard.blade.php
@@ -477,7 +477,7 @@
type: 'column'
},
title: {
- text: 'Appointment Honoured By Gender'
+ text: 'Appointment Honored By Gender'
},
xAxis: {
categories: ['Male', 'Female', 'UKNOWN Gender']
@@ -485,7 +485,7 @@
yAxis: {
min: 0,
title: {
- text: 'No of Appointment Honoured'
+ text: 'No of Appointment Honored'
},
stackLabels: {
enabled: true,
@@ -521,7 +521,7 @@
type: 'column'
},
title: {
- text: 'Appointment Honoured By Age'
+ text: 'Appointment Honored By Age'
},
xAxis: {
categories: ['0-9 YRS', '10-14 YRS', '15-19 YRS', '20-24 YRS', '25+ YRS', 'UKNOWN AGE']
@@ -529,7 +529,7 @@
yAxis: {
min: 0,
title: {
- text: 'No of Appointment Honoured'
+ text: 'No of Appointment Honored'
},
stackLabels: {
enabled: true,
@@ -566,7 +566,7 @@
type: 'column'
},
title: {
- text: 'Appointment Not Honoured By Gender'
+ text: 'Appointment Not Honored By Gender'
},
xAxis: {
categories: ['Male', 'Female', 'UKNOWN Gender']
@@ -574,7 +574,7 @@
yAxis: {
min: 0,
title: {
- text: 'No of Appointment Not Honoured'
+ text: 'No of Appointment Not Honored'
},
stackLabels: {
enabled: true,
@@ -610,7 +610,7 @@
type: 'column'
},
title: {
- text: 'Appointment Not Honoured By Age'
+ text: 'Appointment Not Honored By Age'
},
xAxis: {
categories: ['0-9 YRS', '10-14 YRS', '15-19 YRS', '20-24 YRS', '25+ YRS', 'UKNOWN AGE']
@@ -618,7 +618,7 @@
yAxis: {
min: 0,
title: {
- text: 'No of Appointment Not Honoured'
+ text: 'No of Appointment Not Honored'
},
stackLabels: {
enabled: true,
diff --git a/resources/views/new_dashboard/main_dashbaord.blade.php b/resources/views/new_dashboard/main_dashbaord.blade.php
index 0a2a749..785414a 100644
--- a/resources/views/new_dashboard/main_dashbaord.blade.php
+++ b/resources/views/new_dashboard/main_dashbaord.blade.php
@@ -129,26 +129,25 @@
-
+ @if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Partner' || Auth::user()->access_level == 'Donor')
Facilities
-
{{count($active_facilities)}}
+
{{count($active_facilities)}}
-
Clients
-
{{$client}}
+
{{$client}}
@@ -160,7 +159,7 @@
Appointments
-
{{$appointment}}
+
{{$appointment}}
@@ -172,13 +171,49 @@
Missed Appointments
-
{{$missed_appointment}}
+
{{$missed_appointment}}
+
+