diff --git a/.env.example b/.env.example
index ac74863..b3ed4b9 100644
--- a/.env.example
+++ b/.env.example
@@ -44,3 +44,6 @@ PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
+
+SMS_SERVICE_HOST="https://domain-to-sms-service/api/sender"
+SMS_SERVICE_KEY="sms-service-key"
diff --git a/.github/workflows/Test deployment.yml b/.github/workflows/Test deployment.yml
new file mode 100644
index 0000000..9801683
--- /dev/null
+++ b/.github/workflows/Test deployment.yml
@@ -0,0 +1,39 @@
+name: deploy to test instance
+on:
+ push:
+ branches: [ main ]
+jobs:
+
+ build:
+ name: Deploy
+ runs-on: ubuntu-latest
+ steps:
+ - name: executing remote connection
+ uses: appleboy/ssh-action@master
+ with:
+ host: ${{ secrets.HOST }}
+ username: ${{ secrets.USERNAME }}
+ key: ${{ secrets.CICD_SECRET }}
+ port: ${{ secrets.PORT }}
+ script: |
+ cd /apps/github-workflows/mhealth-apps/
+ sudo rm -rf ushauri_dashboard
+ sudo mkdir ushauri_dashboard
+ sudo chown -R cicd2:cicd2 ushauri_dashboard
+ git config --global --add safe.directory /apps/github-workflows/mhealth-apps/ushauri_dashboard/
+ cd ushauri_dashboard
+ git clone -b main https://github.com/palladiumkenya/ushauri_dashboard.git .
+ git status
+ cp /apps/configs/ushauri-dashboard/.env /apps/github-workflows/mhealth-apps/ushauri_dashboard/
+ cp /apps/configs/ushauri-dashboard/docker-compose.yml /apps/github-workflows/mhealth-apps/ushauri_dashboard/
+ cp /apps/configs/ushauri-dashboard/nginx.dockerfile /apps/github-workflows/mhealth-apps/ushauri_dashboard/
+ cp /apps/configs/ushauri-dashboard/php.dockerfile /apps/github-workflows/mhealth-apps/ushauri_dashboard/
+ cp -r /apps/configs/ushauri-dashboard/nginx /apps/github-workflows/mhealth-apps/ushauri_dashboard/
+ docker-compose down
+ docker-compose rm -f
+ docker-compose --env-file .env up -d --build site
+ # execute normal laravel commands
+ docker-compose exec -T php composer install --ignore-platform-reqs --no-dev
+ docker-compose exec -T php php artisan config:cache
+ docker-compose exec -T php php artisan view:cache
+ docker-compose exec -T php chmod -R 777 storage/
diff --git a/.github/workflows/cicd_process.yml b/.github/workflows/cicd_process.yml
new file mode 100644
index 0000000..af74207
--- /dev/null
+++ b/.github/workflows/cicd_process.yml
@@ -0,0 +1,22 @@
+name: deploy to test instance
+on:
+ push:
+ branches: [ master ]
+jobs:
+
+ build:
+ name: Deploy
+ runs-on: ubuntu-latest
+ steps:
+ - name: executing remote connection
+ uses: appleboy/ssh-action@master
+ with:
+ host: ${{ secrets.PRODUCTION_HOST }}
+ username: ${{ secrets.PRODUCTION_USERNAME }}
+ key: ${{ secrets.PRODUCTION_SECRET }}
+ port: ${{ secrets.PRODUCTION_PORT }}
+ script: |
+
+ cd /var/www/ushauri_dashboard
+ git pull origin
+
diff --git a/README.md b/README.md
index f3decb1..26c8fbd 100644
--- a/README.md
+++ b/README.md
@@ -1,61 +1,61 @@
-
+# Getting started
+ [![deploy to test instance](https://github.com/palladiumkenya/ushauri_dashboard/actions/workflows/cicd_process.yml/badge.svg)](https://github.com/palladiumkenya/ushauri_dashboard/actions/workflows/cicd_process.yml)
+## Installation
+
+Please check the official laravel installation guide for server requirements before you start. [Official Documentation](https://laravel.com/docs/8.x/installation)
-
-
-
-
-
-
+Clone the repository
-## About Laravel
+ git clone https://github.com/palladiumkenya/ushauri_dashboard
-Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
+Switch to the repo folder
+ cd ushauri_dashboard
-- [Simple, fast routing engine](https://laravel.com/docs/routing).
-- [Powerful dependency injection container](https://laravel.com/docs/container).
-- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
-- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
-- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
-- [Robust background job processing](https://laravel.com/docs/queues).
-- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
+Install all the dependencies using composer
-Laravel is accessible, powerful, and provides tools required for large, robust applications.
+ composer install
-## Learning Laravel
+Copy the example env file and make the required configuration changes in the .env file
-Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
+ cp .env.example .env
-If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
+Start the local development server
-## Laravel Sponsors
+ php artisan serve
-We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
+You can now access the server at http://localhost:8000
-### Premium Partners
+**TL;DR command list**
-- **[Vehikl](https://vehikl.com/)**
-- **[Tighten Co.](https://tighten.co)**
-- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
-- **[64 Robots](https://64robots.com)**
-- **[Cubet Techno Labs](https://cubettech.com)**
-- **[Cyber-Duck](https://cyber-duck.co.uk)**
-- **[Many](https://www.many.co.uk)**
-- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
-- **[DevSquad](https://devsquad.com)**
-- **[OP.GG](https://op.gg)**
+ git clone https://github.com/palladiumkenya/ushauri_dashboard
+ cd ushauri_dashboard
+ composer install
+ cp .env.example .env
+ php artisan serve
+
+ ----------
-## Contributing
+# Code overview
-Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
+## Folders
-## Code of Conduct
+- `app/Models` - Contains all the Eloquent models
+- `app/Http/Controllers` - Contain all the data controllers
+- `app/Http/Controllers/Auth` - Contains all the auth controllers
+- `app/Http/Middleware` - Contains the JWT auth middleware
+- `app/Http/Jobs` - Contains all the jobs handlers
+- `config` - Contains all the application configuration files
+- `database/factories` - Contains the model factory for all the models
+- `database/seeds` - Contains the database seeder
+- `resources` - Contains all the application views and styling files
+- `routes` - Contains all the web routes defined in web.php file
+- `tests` - Contains all the application tests
-In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
+## Environment variables
-## Security Vulnerabilities
+- `.env` - Environment variables can be set in this file
-If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
+***Note*** : You can quickly set the database information and other variables in this file and have the application fully working.
-## License
+----------
-The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
diff --git a/app/Console/Commands/ClientReferral.php b/app/Console/Commands/ClientReferral.php
new file mode 100644
index 0000000..95f2a76
--- /dev/null
+++ b/app/Console/Commands/ClientReferral.php
@@ -0,0 +1,167 @@
+httpresponse = Http::withoutVerifying()
+ ->withHeaders(['api-token' => "$key"])
+ ->post("$host", [
+ 'destination' => $destination,
+ 'msg' => $msg,
+ 'sender_id' => $destination,
+ 'gateway' => $source,
+
+ ]);
+
+ return json_decode($this->httpresponse->getBody(), true);
+ }
+
+ public function handle()
+ {
+ $client = Client::join('tbl_master_facility', 'tbl_client.mfl_code', '=', 'tbl_master_facility.code')
+ ->leftJoin('tbl_ward', 'tbl_master_facility.Ward_id', '=', 'tbl_ward.id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(
+ 'tbl_client.clinic_number',
+ 'tbl_client.id as client_id',
+ 'tbl_client.phone_no',
+ 'tbl_client.client_type',
+ 'tbl_client.f_name',
+ 'tbl_client.language_id',
+ 'tbl_master_facility.name as facility',
+ 'tbl_ward.name as location',
+ DB::raw('(CASE WHEN tbl_appointment.appntmnt_date > CURDATE() THEN tbl_appointment.appntmnt_date
+ WHEN tbl_client.language_id = "1" THEN "huna siku ya cliniki"
+ ELSE "no appointment" END) as appointment_date')
+ )
+ ->where('tbl_client.client_type', '=', 'Transfer')
+ ->whereNotNull('tbl_client.phone_no')
+ ->whereDate('tbl_client.updated_at', [now()->subMinutes(30), now()])
+ ->groupBy('tbl_client.id')
+ ->get();
+
+
+
+ foreach ($client as $value) {
+ $phone_no = $value->phone_no;
+ $client_id = $value->client_id;
+ $client_type = $value->client_type;
+ $client_name = $value->f_name;
+ $facility = $value->facility;
+ $location = $value->location;
+ $language = $value->language_id;
+ $appointment_date = $value->appointment_date;
+
+ $check_existence = ClientOutgoing::select('*')->where('message_type_id', '=', '2')
+ ->where('clnt_usr_id', '=', $client_id)
+ ->whereDate('created_at', '=', Carbon::Now())
+ ->limit(1)->count();
+
+ if ($check_existence > 0) {
+ echo 'Message already sent to the client';
+ } else {
+ if (!empty($phone_no)) {
+
+ if ($language !== 2 || $language !== 1) {
+ $get_message = Content::select('*')->where('identifier', '=', '20')->where('language_id', '=', '2')->get();
+ } else {
+ $get_message = Content::select('*')->where('identifier', '=', '20')->where('language_id', '=', $language)->get();
+ }
+
+ foreach ($get_message as $value) {
+ $message = $value->content;
+ $content_id = $value->id;
+ $source = '40149';
+
+ $new_message = str_replace("XXX", $client_name, $message);
+ $facility_name = str_replace('FFF', $facility, $new_message);
+ $location_name = str_replace('LLL', $location, $facility_name);
+ $final_message = str_replace('YYY', $appointment_date, $location_name);
+
+ $save_outgoing = new ClientOutgoing;
+
+ $save_outgoing->destination = $phone_no;
+ $save_outgoing->msg = $final_message;
+ $save_outgoing->source = '40149';
+ $save_outgoing->responded = 'No';
+ $save_outgoing->status = 'Not Sent';
+ $save_outgoing->message_type_id = '2';
+ $save_outgoing->clnt_usr_id = $client_id;
+ $save_outgoing->recepient_type = 'Client';
+ $save_outgoing->content_id = $content_id;
+ // $save_outgoing->created_at = date("Y-m-d H:i:s");
+ $save_outgoing->created_by = '1';
+
+ if ($save_outgoing->save()) {
+ // $sender = new SenderController;
+ $sender = $this->send_message($source, $phone_no, $final_message);
+
+ echo json_encode($sender);
+ } else {
+ echo 'Could not send the message';
+ }
+ }
+ } else {
+ echo 'Can not send to an empty phone number';
+ }
+ }
+ }
+
+ dd("Clients : {$client}");
+
+
+ // return 0;
+ }
+}
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php
index 69914e9..f0b18c4 100644
--- a/app/Console/Kernel.php
+++ b/app/Console/Kernel.php
@@ -13,7 +13,7 @@ class Kernel extends ConsoleKernel
* @var array
*/
protected $commands = [
- //
+ 'App\Console\Commands\ClientReferral',
];
/**
@@ -25,6 +25,7 @@ class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
+ $schedule->command('client:referral')->everyMinutes(30);
}
/**
@@ -34,7 +35,7 @@ protected function schedule(Schedule $schedule)
*/
protected function commands()
{
- $this->load(__DIR__.'/Commands');
+ $this->load(__DIR__ . '/Commands');
require base_path('routes/console.php');
}
diff --git a/app/Http/Controllers/AppointmentController.php b/app/Http/Controllers/AppointmentController.php
index d3448ca..1683988 100644
--- a/app/Http/Controllers/AppointmentController.php
+++ b/app/Http/Controllers/AppointmentController.php
@@ -23,7 +23,7 @@ public function index()
if (Auth::user()->access_level == 'Facility') {
$all_future_apps = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
- ->select('tbl_appointment.id', 'tbl_appointment.client_id', 'tbl_client.clinic_number', 'tbl_appointment.appntmnt_date', 'tbl_appointment_types.name as app_type')
+ ->select('tbl_appointment.id', 'tbl_appointment.client_id', 'tbl_client.clinic_number', 'tbl_client.upi_no', 'tbl_appointment.appntmnt_date', 'tbl_appointment_types.name as app_type')
->where('tbl_appointment.appntmnt_date', '>', Now())
->where('tbl_client.mfl_code', Auth::user()->facility_id)
->get();
@@ -44,6 +44,7 @@ public function editappointment(Request $request)
'expln_app' => "EDITED",
]);
+
if ($appointment) {
Session::flash('statuscode', 'success');
return redirect('report/future/appointments')->with('status', 'Appointment was updated successfully!');
@@ -60,14 +61,14 @@ public function get_future_appointments()
if (Auth::user()->access_level == 'Admin') {
$all_future_appointments = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
- ->selectRaw('tbl_client.clinic_number, tbl_client.file_no, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment_types.name as app_type')
+ ->selectRaw('tbl_client.clinic_number, tbl_client.upi_no, tbl_client.file_no, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment_types.name as app_type')
->where('tbl_appointment.appntmnt_date', '>', Now());
}
if (Auth::user()->access_level == 'Facility') {
$all_future_appointments = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
- ->selectRaw('tbl_client.clinic_number, tbl_client.file_no, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment_types.name as app_type')
+ ->selectRaw('tbl_client.clinic_number, tbl_client.upi_no, tbl_client.file_no, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment_types.name as app_type')
->where('tbl_client.mfl_code', Auth::user()->facility_id)
->where('tbl_appointment.appntmnt_date', '>', Now());
}
@@ -75,7 +76,7 @@ public function get_future_appointments()
if (Auth::user()->access_level == 'Partner') {
$all_future_appointments = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
- ->selectRaw('tbl_client.clinic_number, tbl_client.file_no, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment_types.name as app_type')
+ ->selectRaw('tbl_client.clinic_number, tbl_client.upi_no, tbl_client.file_no, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment_types.name as app_type')
->where('tbl_client.partner_id', Auth::user()->partner_id)
->where('tbl_appointment.appntmnt_date', '>', Now());
}
@@ -83,7 +84,7 @@ public function get_future_appointments()
if (Auth::user()->access_level == 'Donor') {
$all_future_appointments = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
- ->selectRaw('tbl_client.clinic_number, tbl_client.file_no, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment_types.name as app_type')
+ ->selectRaw('tbl_client.clinic_number, tbl_client.upi_no, tbl_client.file_no, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment_types.name as app_type')
->where('donor_id', Auth::user()->donor_id)
->where('tbl_appointment.appntmnt_date', '>', Now());
}
diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php
index 8c5b5ef..83e1e32 100644
--- a/app/Http/Controllers/Auth/LoginController.php
+++ b/app/Http/Controllers/Auth/LoginController.php
@@ -32,13 +32,13 @@ protected function redirectTo() {
}
else if (Auth::user()->access_level == 'Facility') {
Session::flash('statuscode', 'Login Success!, You will be redirected to your Home page in a few.');
- return '/Reports/facility_home';
+ return '/admin/dashboard';
} else if (Auth::user()->access_level == 'Partner') {
Session::flash('statuscode', 'success');
- return '/Reports/dashboard';
+ return '/admin/dashboard';
} else if (Auth::user()->access_level == 'Admin') {
Session::flash('statuscode', 'success');
- return '/Reports/dashboard';
+ return '/admin/dashboard';
}else {
return '/';
}
diff --git a/app/Http/Controllers/BroadcastController.php b/app/Http/Controllers/BroadcastController.php
index 60cb735..f662971 100644
--- a/app/Http/Controllers/BroadcastController.php
+++ b/app/Http/Controllers/BroadcastController.php
@@ -1,9 +1,11 @@
where('partner_id', Auth::user()->partner_id)
->get();
- $groups = Group::all();
+ $groups = Group::all()->where('status', '=', 'Active');
- $genders = Gender::all();
+ $genders = Gender::all()->where('status', '=', 'Active');
+ $time = Time::all();
$data = array(
'facilities' => $facilities,
'groups' => $groups,
- 'genders' => $genders
+ 'genders' => $genders,
+ 'time' => $time
);
$p_data = array(
'facilities' => $p_facilities,
'groups' => $groups,
- 'genders' => $genders
+ 'genders' => $genders,
+ 'time' => $time
);
$u_data = array(
'facilities' => $u_facilities,
'groups' => $groups,
- 'genders' => $genders
+ 'genders' => $genders,
+ 'time' => $time
);
if (Auth::user()->access_level == 'Facility') {
- return view('broadcast.facility_broadcast')->with($u_data);
+ return view('broadcast.facility_broadcast')->with($u_data);
+ } else if (Auth::user()->access_level == 'Partner') {
- } else if(Auth::user()->access_level == 'Partner') {
+ return view('broadcast.partner_broadcast')->with($p_data);
+ } else if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
- return view('broadcast.partner_broadcast')->with($p_data);
+ return view('broadcast.broadcast')->with($data);
+ }
+ }
- } else if(Auth::user()->access_level == 'Admin') {
+ public function broadcast_page()
+ {
+ return view('broadcast.broadcast_page');
+ }
+
+ public function broadcast_user()
+ {
+ $facilities = Facility::join('tbl_users', 'tbl_users.facility_id', '=', 'tbl_master_facility.code')->select('tbl_master_facility.code', 'tbl_master_facility.name')->groupBy('tbl_master_facility.name')->get();
+
+ $p_facilities = Facility::join('tbl_partner_facility', 'tbl_partner_facility.mfl_code', '=', 'tbl_master_facility.code')
+ ->select(
+ 'tbl_partner_facility.mfl_code',
+ 'tbl_partner_facility.partner_id',
+ 'tbl_master_facility.name'
+ )
+ ->where('partner_id', Auth::user()->partner_id)
+ ->get();
+ $data = array(
+ 'facilities' => $facilities
+ );
+ $p_data = array(
+ 'p_facilities' => $p_facilities
+ );
- return view('broadcast.broadcast')->with($data);
+ if (Auth::user()->access_level == 'Partner') {
+ return view('broadcast.broadcast_userpartner')->with($p_data);
+ } else if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+
+ return view('broadcast.broadcast_user')->with($data);
}
+ }
+
+ public function sendSMS_user(Request $request)
+ {
+ if (Auth::user()->access_level == 'Partner') {
+
+ // $request->validate([
+ // 'mfl_code' => 'required',
+ // 'message' => 'required'
+ // ]);
+
+ $users = User::where('status', '=', 'Active')->where('access_level', '=', 'Facility')->where('partner_id', Auth::user()->partner_id)->get();
+
+ // if ($users->count() == 0)
+ // continue;
+
+
+ foreach ($users as $user) {
+
+ $dest = $user->phone_no;
+
+ $msg = $request->message;
+
+ SendSMS::dispatch($dest, $msg);
+ }
+
+ Session::flash('statuscode', 'success');
+ return back()->with('status', 'Message Successfully Sent To The Users.');
+
+ // return back();
+
+ } else if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+
+ // $request->validate([
+ // 'mfl_code' => 'required',
+ // 'message' => 'required'
+ // ]);
+
+ $users = User::where('status', '=', 'Active')->where('access_level', '=', 'Facility')->get();
+
+ // if ($users->count() == 0)
+ // continue;
+
+ foreach ($users as $user) {
+
+ $dest = $user->phone_no;
+ $msg = $request->message;
+
+ SendSMS::dispatch($dest, $msg);
+ }
+
+ Session::flash('statuscode', 'success');
+ return back()->with('status', 'Message Successfully Sent To The Users.');
+ }
}
public function sendSMS(Request $request)
@@ -84,43 +177,43 @@ public function sendSMS(Request $request)
'message' => 'required'
]);
- $facility = Facility::where('code', Auth::user()->facility_id)->get();
-
- foreach($request['groups'] as $group_id) {
-
+ $facility = Facility::where('code', Auth::user()->facility_id)->pluck('code')->first();
+
+ foreach ($request['groups'] as $group_id) {
+
$group = Group::find($group_id);
-
+
if (is_null($group))
continue;
- foreach($request['genders'] as $gender_id) {
+ foreach ($request['genders'] as $gender_id) {
$gender = Gender::find($gender_id);
-
- $clients = Client::where('mfl_code', $facility)->where('group_id', '=', $group->id)->where('gender', $gender->id)->get();
-
+
+ $clients = Client::where('mfl_code', $facility)->where('group_id', '=', $group->id)->where('gender', $gender->id)->get();
+
if ($clients->count() == 0)
continue;
-
+
foreach ($clients as $client) {
-
+
$dest = $client->phone_no;
-
+
$msg = $request->message;
SendSMS::dispatch($dest, $msg);
-
+
// $sender = new SenderController;
-
+
// $sender->send($dest, $msg);
-
- }
-
+
+ }
}
-
}
+ Session::flash('statuscode', 'success');
+ return back()->with('status', 'Message Successfully Sent.');
- return back();
+ // return back();
} else if (Auth::user()->access_level == 'Partner') {
@@ -131,85 +224,79 @@ public function sendSMS(Request $request)
'message' => 'required'
]);
-
- foreach($request['groups'] as $group_id) {
-
- $group = Group::find($groups_id);
-
+
+ foreach ($request['groups'] as $group_id) {
+
+ $group = Group::find($group_id);
+
if (is_null($group))
continue;
- foreach($request['genders'] as $gender_id) {
+ foreach ($request['genders'] as $gender_id) {
$gender = Gender::find($gender_id);
-
- $clients = Client::where('mfl_code', $request->mfl_code)->where('group_id', '=', $group->id)->where('gender', $gender->id)->get();
-
+
+ $clients = Client::where('mfl_code', $request->mfl_code)->where('group_id', '=', $group->id)->where('gender', $gender->id)->get();
+
if ($clients->count() == 0)
continue;
-
+
foreach ($clients as $client) {
-
+
$dest = $client->phone_no;
-
+
$msg = $request->message;
-
+
SendSMS::dispatch($dest, $msg);
-
- }
-
- }
-
- }
+ }
+ }
+ }
+ Session::flash('statuscode', 'success');
+ return back()->with('status', 'Message Successfully Sent.');
+
+ // return back();
- return back();
-
- } else if(Auth::user()->access_level == 'Admin') {
+ } else if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
$request->validate([
'groups' => 'required',
'genders' => 'required',
'message' => 'required'
]);
-
- foreach($request['groups'] as $group_id) {
+
+ foreach ($request['groups'] as $group_id) {
$group = Group::find($group_id);
-
+
if (is_null($group))
continue;
- foreach($request['genders'] as $gender_id) {
+ foreach ($request['genders'] as $gender_id) {
$gender = Gender::find($gender_id);
-
- $clients = Client::where('group_id', '=', $group->id)->where('gender', $gender->id)->get();
-
+
+ $clients = Client::where('group_id', '=', $group->id)->where('gender', $gender->id)->get();
+
if ($clients->count() == 0)
continue;
-
+
foreach ($clients as $client) {
-
+
$dest = $client->phone_no;
-
+
$msg = $request->message;
-
- if(Str::length($dest) >= 10) {
- SendSMS::dispatch($dest, $msg);
+ if (Str::length($dest) >= 10) {
+ SendSMS::dispatch($dest, $msg);
}
-
- }
-
- }
-
+ }
+ }
}
+ Session::flash('statuscode', 'success');
+ return back()->with('status', 'Message Successfully Sent.');
+ //return back();
- return back();
-
- }
-
+ }
}
-
}
diff --git a/app/Http/Controllers/BulkUploadController.php b/app/Http/Controllers/BulkUploadController.php
index 5a882a8..74ccdd8 100644
--- a/app/Http/Controllers/BulkUploadController.php
+++ b/app/Http/Controllers/BulkUploadController.php
@@ -4,6 +4,7 @@
ini_set('max_execution_time', 0);
ini_set('memory_limit', '1024M');
+
use Illuminate\Http\Request;
use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\WithHeadingRow;
@@ -14,12 +15,12 @@
class BulkUploadController extends Controller
{
- public function uploadClientForm(){
+ public function uploadClientForm()
+ {
return view('clients.upload-clients-form');
}
-
-
- public function importClients(Request $request){
+ public function importClients(Request $request)
+ {
$file = request()->file('file');
@@ -28,31 +29,29 @@ public function importClients(Request $request){
for ($i = 0; $i < count($receivedArr); $i++) {
$gender_value = trim(strtolower($receivedArr[$i]['Gender']));
- if($gender_value == 'm'){
+ if ($gender_value == 'm') {
$gender = 2;
- }
- elseif ($gender_value=='f') {
- $gender =1;
- }else {
- $gender= 5;
+ } elseif ($gender_value == 'f') {
+ $gender = 1;
+ } else {
+ $gender = 5;
}
- $marital_value = trim(strtolower($receivedArr[$i]['MaritalStatus']));
+ $marital_value = trim(strtolower($receivedArr[$i]['Marital_Status']));
- if($marital_value == 'divorced'){
+ if ($marital_value == 'Divorced') {
$marital = 3;
- }elseif ($marital_value == 'living with partner') {
+ } elseif ($marital_value == 'Living with partner') {
$marital = 5;
- }elseif ($marital_value == 'married') {
+ } elseif ($marital_value == 'Married') {
$marital = 2;
- }elseif ($marital_value == 'never married') {
+ } elseif ($marital_value == 'Never married') {
$marital = 1;
- }
- elseif ($marital_value == 'polygamous') {
+ } elseif ($marital_value == 'Polygamous') {
$marital = 8;
- }elseif ($marital_value == 'widowed') {
+ } elseif ($marital_value == 'Widowed') {
$marital = 4;
- }else{
+ } else {
$marital = 6;
}
@@ -70,30 +69,34 @@ public function importClients(Request $request){
$age_value = (float)$receivedArr[$i]['ageInYears'];
- if($age_value >=20){
+ if ($age_value >= 20) {
$group_id = 1;
- }elseif ($age_value >=13) {
+ } elseif ($age_value >= 13) {
$group_id = 2;
- }else{
+ } else {
$group_id = 4;
}
- $first_name = trim($receivedArr[$i]['GivenName']);
+ $first_name = trim($receivedArr[$i]['FirstName']);
$middle_name = trim($receivedArr[$i]['MiddleName']);
- $last_name = trim($receivedArr[$i]['FamilyName']);
+ $last_name = trim($receivedArr[$i]['LastName']);
$clinic_number = trim($receivedArr[$i]['CCC_Number']);
- $phone_number = trim($receivedArr[$i]['MobileNumber']);
+ $phone_number = trim($receivedArr[$i]['Phone_Number']);
$facility_id = trim($receivedArr[$i]['MFL']);
$mfl_code = trim($receivedArr[$i]['MFL']);
- $partner_id = trim($receivedArr[$i]['PartnerID']);
+ if (Auth::user()->access_level == 'Partner' || Auth::user()->access_level == 'Facility') {
+ $partner_id = Auth::user()->partner_id;
+ }else{
+ $partner_id = trim($receivedArr[$i]['PartnerID']);
+ }
$status = "Active";
- $client_status = "Art";
+ $client_status = "ART";
$clinic_id = 1;
$text_frequency = 168;
$text_time = 7;
- $wellness = "Yes";
- $motivational = "Yes";
- $smsenable = "Yes";
+ $wellness = "No";
+ $motivational = "No";
+ $smsenable = "No";
$language = 2;
@@ -121,6 +124,7 @@ public function importClients(Request $request){
$client->txt_time = $text_time;
$client->wellness_enable = $wellness;
$client->motivational_enable = $motivational;
+ $client->smsenable = $smsenable;
$client->created_by = Auth::user()->id;
$client->updated_by = Auth::user()->id;
@@ -132,27 +136,25 @@ public function importClients(Request $request){
// return $res;
// }
- if($existing){
+ if ($existing) {
echo ('Client' . $clinic_number . ' already exists in the system ');
-
- }elseif(strlen($clinic_number) < 10 || strlen($clinic_number) > 10){
+ } elseif (strlen($clinic_number) < 10 || strlen($clinic_number) > 10) {
echo ('Client' . $clinic_number . ' has less or more than 10 digit ccc number ');
- }else{
+ } else {
if ($client->save()) {
- echo ('Insert Client Record successfully for client.' . $clinic_number. ' ');
- }else{
- echo ('Could not insert record for client.' . $clinic_number. ' ');
+ echo ('Insert Client Record successfully for client.' . $clinic_number . ' ');
+ } else {
+ echo ('Could not insert record for client.' . $clinic_number . ' ');
}
}
-
-
}
}
echo "Done";
}
- public function importSecondClients(Request $request){
+ public function importSecondClients(Request $request)
+ {
$file = request()->file('file');
@@ -187,11 +189,11 @@ public function importSecondClients(Request $request){
$client_status = trim($receivedArr[$i]['client_status']);
$clinic_id = trim($receivedArr[$i]['clinic_id']);
$text_frequency = 168;
- $text_time = 7;
- $wellness = "Yes";
- $motivational = "Yes";
- $smsenable = "Yes";
- $language = trim($receivedArr[$i]['language_id']);;
+ $text_time = 19;
+ $wellness = "No";
+ $motivational = "No";
+ $smsenable = trim($receivedArr[$i]['smsenable']);
+ $language = trim($receivedArr[$i]['language_id']);
$client = new Client;
@@ -218,6 +220,7 @@ public function importSecondClients(Request $request){
$client->txt_time = $text_time;
$client->wellness_enable = $wellness;
$client->motivational_enable = $motivational;
+ $client->smsenable = $smsenable;
$client->created_by = Auth::user()->id;
$client->updated_by = Auth::user()->id;
@@ -229,28 +232,23 @@ public function importSecondClients(Request $request){
// return $res;
// }
- if($existing){
+ if ($existing) {
echo ('Client' . $clinic_number . ' already exists in the system ');
-
- }elseif(strlen($clinic_number) < 10 || strlen($clinic_number) > 10){
+ } elseif (strlen($clinic_number) < 10 || strlen($clinic_number) > 10) {
echo ('Client' . $clinic_number . ' has less or more than 10 digit ccc number ');
- }else{
+ } else {
if ($client->save()) {
- echo ('Insert Client Record successfully for client.' . $clinic_number. ' ');
- }else{
- echo ('Could not insert record for client.' . $clinic_number. ' ');
+ echo ('Insert Client Record successfully for client.' . $clinic_number . ' ');
+ } else {
+ echo ('Could not insert record for client.' . $clinic_number . ' ');
}
}
-
-
}
}
echo "Done";
}
-
-
function csvToArray($filename = '', $delimiter = ',')
{
if (!file_exists($filename) || !is_readable($filename))
@@ -260,7 +258,7 @@ function csvToArray($filename = '', $delimiter = ',')
$data = array();
if (($handle = fopen($filename, 'r')) !== false) {
- while (($row = fgetcsv($handle, 5000, $delimiter)) !== false) {
+ while (($row = fgetcsv($handle, 13000, $delimiter)) !== false) {
if (!$header) {
// print_r("header not empty");
$header = $row;
@@ -275,4 +273,14 @@ function csvToArray($filename = '', $delimiter = ',')
return $data;
}
+ public function downloadClientTemplate()
+ {
+ $path = public_path('template/UshauriTemplate.xlsx');
+ return response()->download($path);
+ }
+ public function downloadClientScript()
+ {
+ $path = public_path('template/UshauriExtract.sql');
+ return response()->download($path);
+ }
}
diff --git a/app/Http/Controllers/CalendarController.php b/app/Http/Controllers/CalendarController.php
index 54f1df3..1e4aa78 100644
--- a/app/Http/Controllers/CalendarController.php
+++ b/app/Http/Controllers/CalendarController.php
@@ -11,24 +11,25 @@
class CalendarController extends Controller
{
+ private $url_path = "current-appointments";
+
public function index()
{
return view('appointments.appointment_calender');
-
}
public function app_calendar()
{
if (Auth::user()->access_level == 'Facility') {
- $name = 'Total Apps:';
- $app_calendar_data = Appointments::join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
- ->join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select('tbl_client.clinic_number', 'tbl_client.file_no', 'tbl_client.phone_no', 'tbl_appointment_types.name as app_type', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as client_name"), 'tbl_appointment.appntmnt_date as start', DB::raw("CONCAT('Total Apps: ', ' ', COUNT(tbl_appointment_types.id)) as title"), 'tbl_appointment.appntmnt_date as end')
- ->groupBy('tbl_appointment.appntmnt_date')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->get();
-
- return response()->json($app_calendar_data);
+ $name = 'Total:';
+ $app_calendar_data = Appointments::join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
+ ->join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select('tbl_client.clinic_number', 'tbl_client.file_no', 'tbl_client.phone_no', 'tbl_appointment.app_status', 'tbl_appointment_types.name as app_type', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as client_name"), 'tbl_appointment.appntmnt_date as start', DB::raw("CONCAT('$this->url_path','/id_all/', tbl_appointment.id) as url"), DB::raw("CONCAT('Total: ', ' ', COUNT(tbl_appointment_types.id)) as title"), 'tbl_appointment.appntmnt_date as end')
+ ->groupBy('tbl_appointment.appntmnt_date')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->get();
+
+ return response()->json($app_calendar_data);
}
}
public function refill_calendar()
@@ -36,15 +37,14 @@ public function refill_calendar()
if (Auth::user()->access_level == 'Facility') {
$app_calendar_data = Appointments::join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
- ->join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_clinic', 'tbl_clinic.id', '=', 'tbl_client.clinic_id')
- ->select('tbl_client.clinic_number', 'tbl_clinic.name as clinic', 'tbl_client.file_no', 'tbl_client.phone_no', 'tbl_appointment_types.name as app_type', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as client_name"), 'tbl_appointment.appntmnt_date as start', DB::raw("CONCAT('Re-fill: ', ' ', COUNT(tbl_appointment_types.id)) as title"), 'tbl_appointment.appntmnt_date as end')
- ->groupBy('tbl_appointment.appntmnt_date')
- ->where('tbl_appointment_types.name' , '=', 'Re-fill')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->get();
+ ->join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_clinic', 'tbl_clinic.id', '=', 'tbl_client.clinic_id')
+ ->select('tbl_client.clinic_number', 'tbl_clinic.name as clinic', 'tbl_client.file_no', 'tbl_appointment.app_status', 'tbl_client.phone_no', 'tbl_appointment_types.name as app_type', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as client_name"), 'tbl_appointment.appntmnt_date as start', DB::raw("CONCAT('$this->url_path','/id/', tbl_appointment.id) as url"), DB::raw("CONCAT('Refill: ', ' ', COUNT(tbl_appointment_types.id)) as title"), 'tbl_appointment.appntmnt_date as end')
+ ->groupBy('tbl_appointment.appntmnt_date')
+ ->where('tbl_appointment_types.name', '=', 'Re-fill')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->get();
return response()->json($app_calendar_data);
-
}
}
@@ -53,15 +53,14 @@ public function refill_apps()
if (Auth::user()->access_level == 'Facility') {
$app_calendar_data = Appointments::join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
- ->join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_clinic', 'tbl_clinic.id', '=', 'tbl_client.clinic_id')
- ->select('tbl_client.clinic_number', 'tbl_clinic.name as clinic', 'tbl_client.file_no', 'tbl_client.phone_no', 'tbl_appointment_types.name as app_type', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as client_name"), 'tbl_appointment.appntmnt_date as start', DB::raw("CONCAT('Re-fill: ', ' ', COUNT(tbl_appointment_types.id)) as title"), 'tbl_appointment.appntmnt_date as end')
- ->groupBy('tbl_appointment.appntmnt_date')
- ->where('tbl_appointment_types.name' , '=', 'Re-fill')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->get();
+ ->join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_clinic', 'tbl_clinic.id', '=', 'tbl_client.clinic_id')
+ ->select('tbl_client.clinic_number', 'tbl_clinic.name as clinic', 'tbl_client.file_no', 'tbl_appointment.app_status', 'tbl_client.phone_no', 'tbl_appointment_types.name as app_type', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as client_name"), 'tbl_appointment.appntmnt_date as start', DB::raw("CONCAT('$this->url_path','/id/', tbl_appointment.id) as url"), DB::raw("CONCAT('Refill: ', ' ', COUNT(tbl_appointment_types.id)) as title"), 'tbl_appointment.appntmnt_date as end')
+ ->groupBy('tbl_appointment.appntmnt_date')
+ ->where('tbl_appointment_types.name', '=', 'Re-fill')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->get();
return view('calendar.refill', compact('app_calendar_data'));
-
}
}
@@ -69,12 +68,12 @@ public function clinical_calendar()
{
if (Auth::user()->access_level == 'Facility') {
$app_calendar_data = Appointments::join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
- ->join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select('tbl_client.clinic_number', 'tbl_client.file_no', 'tbl_client.phone_no', 'tbl_appointment_types.name as app_type', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as client_name"), 'tbl_appointment.appntmnt_date as start', DB::raw("CONCAT('Clinical Review: ', ' ', COUNT(tbl_appointment_types.id)) as title"), 'tbl_appointment.appntmnt_date as end')
- ->groupBy('tbl_appointment.appntmnt_date')
- ->where('tbl_appointment_types.name' , '=', 'Clinical Review')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->get();
+ ->join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select('tbl_client.clinic_number', 'tbl_client.file_no', 'tbl_client.phone_no', 'tbl_appointment.app_status', 'tbl_appointment_types.name as app_type', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as client_name"), 'tbl_appointment.appntmnt_date as start', DB::raw("CONCAT('$this->url_path','/id/', tbl_appointment.id) as url"), DB::raw("CONCAT('Clinical Review: ', ' ', COUNT(tbl_appointment_types.id)) as title"), 'tbl_appointment.appntmnt_date as end')
+ ->groupBy('tbl_appointment.appntmnt_date')
+ ->where('tbl_appointment_types.name', '=', 'Clinical Review')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->get();
return response()->json($app_calendar_data);
}
}
@@ -83,12 +82,12 @@ public function adherence_calendar()
{
if (Auth::user()->access_level == 'Facility') {
$app_calendar_data = Appointments::join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
- ->join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select('tbl_client.clinic_number', 'tbl_client.file_no', 'tbl_client.phone_no', 'tbl_appointment_types.name as app_type', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as client_name"), 'tbl_appointment.appntmnt_date as start', DB::raw("CONCAT('Adherence: ', ' ', COUNT(tbl_appointment_types.id)) as title"), 'tbl_appointment.appntmnt_date as end')
- ->groupBy('tbl_appointment.appntmnt_date')
- ->where('tbl_appointment_types.name' , '=', 'Enhanced Adherence')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->get();
+ ->join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select('tbl_client.clinic_number', 'tbl_client.file_no', 'tbl_client.phone_no', 'tbl_appointment.app_status', 'tbl_appointment_types.name as app_type', DB::raw("CONCAT('$this->url_path','/id/', tbl_appointment.id) as url"), DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as client_name"), 'tbl_appointment.appntmnt_date as start', DB::raw("CONCAT('Adherence: ', ' ', COUNT(tbl_appointment_types.id)) as title"), 'tbl_appointment.appntmnt_date as end')
+ ->groupBy('tbl_appointment.appntmnt_date')
+ ->where('tbl_appointment_types.name', '=', 'Enhanced Adherence')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->get();
return response()->json($app_calendar_data);
}
}
@@ -97,12 +96,12 @@ public function lab_calendar()
{
if (Auth::user()->access_level == 'Facility') {
$app_calendar_data = Appointments::join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
- ->join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select('tbl_client.clinic_number', 'tbl_client.file_no', 'tbl_client.phone_no', 'tbl_appointment_types.name as app_type', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as client_name"), 'tbl_appointment.appntmnt_date as start', DB::raw("CONCAT('Lab Investigation: ', ' ', COUNT(tbl_appointment_types.id)) as title"), 'tbl_appointment.appntmnt_date as end')
- ->groupBy('tbl_appointment.appntmnt_date')
- ->where('tbl_appointment_types.name' , '=', 'Lab Investigation')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->get();
+ ->join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select('tbl_client.clinic_number', 'tbl_client.file_no', 'tbl_client.phone_no', 'tbl_appointment.app_status', 'tbl_appointment_types.name as app_type', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as client_name"), 'tbl_appointment.appntmnt_date as start', DB::raw("CONCAT('$this->url_path','/id/', tbl_appointment.id) as url"), DB::raw("CONCAT('Lab Investigation: ', ' ', COUNT(tbl_appointment_types.id)) as title"), 'tbl_appointment.appntmnt_date as end')
+ ->groupBy('tbl_appointment.appntmnt_date')
+ ->where('tbl_appointment_types.name', '=', 'Lab Investigation')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->get();
return response()->json($app_calendar_data);
}
}
@@ -111,12 +110,12 @@ public function viral_load()
{
if (Auth::user()->access_level == 'Facility') {
$app_calendar_data = Appointments::join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
- ->join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select('tbl_client.clinic_number', 'tbl_client.file_no', 'tbl_client.phone_no', 'tbl_appointment_types.name as app_type', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as client_name"), 'tbl_appointment.appntmnt_date as start', DB::raw("CONCAT('Viral Load: ', ' ', COUNT(tbl_appointment_types.id)) as title"), 'tbl_appointment.appntmnt_date as end')
- ->groupBy('tbl_appointment.appntmnt_date')
- ->where('tbl_appointment_types.name' , '=', 'Viral Load')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->get();
+ ->join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select('tbl_client.clinic_number', 'tbl_client.file_no', 'tbl_client.phone_no', 'tbl_appointment.app_status', 'tbl_appointment_types.name as app_type', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as client_name"), 'tbl_appointment.appntmnt_date as start', DB::raw("CONCAT('$this->url_path','/id/', tbl_appointment.id) as url"), DB::raw("CONCAT('Viral Load: ', ' ', COUNT(tbl_appointment_types.id)) as title"), 'tbl_appointment.appntmnt_date as end')
+ ->groupBy('tbl_appointment.appntmnt_date')
+ ->where('tbl_appointment_types.name', '=', 'Viral Load')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->get();
return response()->json($app_calendar_data);
}
}
@@ -125,12 +124,12 @@ public function other_calendar()
{
if (Auth::user()->access_level == 'Facility') {
$app_calendar_data = Appointments::join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
- ->join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select('tbl_client.clinic_number', 'tbl_client.file_no', 'tbl_client.phone_no', 'tbl_appointment_types.name as app_type', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as client_name"), 'tbl_appointment.appntmnt_date as start', DB::raw("CONCAT('Other: ', ' ', COUNT(tbl_appointment_types.id)) as title"), 'tbl_appointment.appntmnt_date as end')
- ->groupBy('tbl_appointment.appntmnt_date')
- ->where('tbl_appointment_types.name' , '=', 'Other')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->get();
+ ->join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select('tbl_client.clinic_number', 'tbl_client.file_no', 'tbl_client.phone_no', 'tbl_appointment.app_status', 'tbl_appointment_types.name as app_type', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as client_name"), 'tbl_appointment.appntmnt_date as start', DB::raw("CONCAT('$this->url_path','/id/', tbl_appointment.id) as url"), DB::raw("CONCAT('Other: ', ' ', COUNT(tbl_appointment_types.id)) as title"), 'tbl_appointment.appntmnt_date as end')
+ ->groupBy('tbl_appointment.appntmnt_date')
+ ->where('tbl_appointment_types.name', '=', 'Other')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->get();
return response()->json($app_calendar_data);
}
}
@@ -139,12 +138,12 @@ public function pcr_calendar()
{
if (Auth::user()->access_level == 'Facility') {
$app_calendar_data = Appointments::join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
- ->join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select('tbl_client.clinic_number', 'tbl_client.file_no', 'tbl_client.phone_no', 'tbl_appointment_types.name as app_type', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as client_name"), 'tbl_appointment.appntmnt_date as start', DB::raw("CONCAT('PCR: ', ' ', COUNT(tbl_appointment_types.id)) as title"), 'tbl_appointment.appntmnt_date as end')
- ->groupBy('tbl_appointment.appntmnt_date')
- ->where('tbl_appointment_types.name' , '=', 'PCR')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->get();
+ ->join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select('tbl_client.clinic_number', 'tbl_client.file_no', 'tbl_client.phone_no', 'tbl_appointment.app_status', 'tbl_appointment_types.name as app_type', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as client_name"), 'tbl_appointment.appntmnt_date as start', DB::raw("CONCAT('$this->url_path','/id/', tbl_appointment.id) as url"), DB::raw("CONCAT('PCR: ', ' ', COUNT(tbl_appointment_types.id)) as title"), 'tbl_appointment.appntmnt_date as end')
+ ->groupBy('tbl_appointment.appntmnt_date')
+ ->where('tbl_appointment_types.name', '=', 'PCR')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->get();
return response()->json($app_calendar_data);
}
}
@@ -153,12 +152,12 @@ public function normal_calender()
{
if (Auth::user()->access_level == 'Facility') {
$app_calendar_data = Appointments::join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
- ->join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select('tbl_client.clinic_number', 'tbl_client.file_no', 'tbl_client.phone_no', 'tbl_appointment_types.name as app_type', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as client_name"), 'tbl_appointment.appntmnt_date as start', DB::raw("CONCAT('Normal: ', ' ', COUNT(tbl_appointment_types.id)) as title"), 'tbl_appointment.appntmnt_date as end')
- ->groupBy('tbl_appointment.appntmnt_date')
- ->where('tbl_appointment_types.name' , '=', 'Normal')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->get();
+ ->join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select('tbl_client.clinic_number', 'tbl_client.file_no', 'tbl_client.phone_no', 'tbl_appointment.app_status', 'tbl_appointment_types.name as app_type', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as client_name"), 'tbl_appointment.appntmnt_date as start', DB::raw("CONCAT('$this->url_path','/id/', tbl_appointment.id) as url"), DB::raw("CONCAT('Normal: ', ' ', COUNT(tbl_appointment_types.id)) as title"), 'tbl_appointment.appntmnt_date as end')
+ ->groupBy('tbl_appointment.appntmnt_date')
+ ->where('tbl_appointment_types.name', '=', 'Normal')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->get();
return response()->json($app_calendar_data);
}
}
@@ -167,14 +166,96 @@ public function vl_cd_calendar()
{
if (Auth::user()->access_level == 'Facility') {
$app_calendar_data = Appointments::join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
- ->join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select('tbl_client.clinic_number', 'tbl_client.file_no', 'tbl_client.phone_no', 'tbl_appointment_types.name as app_type', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as client_name"), 'tbl_appointment.appntmnt_date as start', DB::raw("CONCAT('VL/CD4: ', ' ', COUNT(tbl_appointment_types.id)) as title"), 'tbl_appointment.appntmnt_date as end')
- ->groupBy('tbl_appointment.appntmnt_date')
- ->where('tbl_appointment_types.name' , '=', 'VL/CD4')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->get();
+ ->join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select('tbl_client.clinic_number', 'tbl_client.file_no', 'tbl_client.phone_no', 'tbl_appointment.app_status', 'tbl_appointment_types.name as app_type', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as client_name"), 'tbl_appointment.appntmnt_date as start', DB::raw("CONCAT('$this->url_path','/id/', tbl_appointment.id) as url"), DB::raw("CONCAT('VL/CD4: ', ' ', COUNT(tbl_appointment_types.id)) as title"), 'tbl_appointment.appntmnt_date as end')
+ ->groupBy('tbl_appointment.appntmnt_date')
+ ->where('tbl_appointment_types.name', '=', 'VL/CD4')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->get();
+ return response()->json($app_calendar_data);
+ }
+ }
+
+ public function honored_calendar()
+ {
+ if (Auth::user()->access_level == 'Facility') {
+ $app_calendar_data = Appointments::join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
+ ->join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select('tbl_client.clinic_number', 'tbl_client.file_no', 'tbl_client.phone_no', 'tbl_appointment.app_status', 'tbl_appointment_types.name as app_type', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as client_name"), 'tbl_appointment.appntmnt_date as start', DB::raw("CONCAT('$this->url_path','/id/', tbl_appointment.id) as url"), DB::raw("CONCAT('Honored Apps: ', ' ', COUNT(tbl_appointment.id)) as title"), 'tbl_appointment.appntmnt_date as end')
+ ->groupBy('tbl_appointment.appntmnt_date')
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->get();
return response()->json($app_calendar_data);
}
}
+ public function not_honored_calendar()
+ {
+ if (Auth::user()->access_level == 'Facility') {
+ $app_calendar_data = Appointments::join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
+ ->join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select('tbl_client.clinic_number', 'tbl_client.file_no', 'tbl_appointment.app_status', 'tbl_client.phone_no', 'tbl_appointment_types.name as app_type', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as client_name"), 'tbl_appointment.appntmnt_date as start', DB::raw("CONCAT('$this->url_path','/id/', tbl_appointment.id) as url"), DB::raw("CONCAT('Not Honored: ', ' ', COUNT(tbl_appointment.id)) as title"), 'tbl_appointment.appntmnt_date as end')
+ ->groupBy('tbl_appointment.appntmnt_date')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ // ->where('tbl_appointment.date_attended', '!=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->get();
+ return response()->json($app_calendar_data);
+ }
+ }
+
+ public function unscheduled_calendar()
+ {
+ if (Auth::user()->access_level == 'Facility') {
+ $app_calendar_data = Appointments::join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
+ ->join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select('tbl_client.clinic_number', 'tbl_client.file_no', 'tbl_appointment.app_status', 'tbl_client.phone_no', 'tbl_appointment_types.name as app_type', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as client_name"), 'tbl_appointment.appntmnt_date as start', DB::raw("CONCAT('$this->url_path','/id/', tbl_appointment.id) as url"), DB::raw("CONCAT('Un-Scheduled: ', ' ', COUNT(tbl_appointment.visit_type)) as title"), 'tbl_appointment.appntmnt_date as end')
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->groupBy('tbl_appointment.appntmnt_date')
+ ->get();
+ return response()->json($app_calendar_data);
+ }
+ }
+
+ public function current_appointments($slug, $id)
+ {
+ //get the appointment
+ $appointment = DB::table('tbl_appointment')
+ ->where('id', $id)
+ ->get()
+ ->take(1);
+
+ foreach ($appointment as $row) {
+ $app_date = $row->appntmnt_date;
+ $app_type = $row->app_type_1;
+ $unscheduled_app = $row->visit_type;
+ $honored_app = $row->date_attended;
+ $not_honored_app = $row->app_status;
+ }
+
+ $query = DB::table('tbl_client')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_appointment_types', 'tbl_appointment.app_type_1', '=', 'tbl_appointment_types.id')
+ ->join('tbl_clinic', 'tbl_client.clinic_id', '=', 'tbl_clinic.id')
+ ->leftJoin('tbl_clnt_outgoing', 'tbl_appointment.id', '=', 'tbl_clnt_outgoing.appointment_id')
+ ->select('tbl_client.file_no', 'tbl_client.smsenable', 'tbl_appointment.id as appointment_id', 'tbl_appointment.date_attended', 'tbl_appointment.visit_type', 'tbl_client.f_name', 'tbl_client.m_name', 'tbl_client.l_name', 'tbl_client.phone_no', 'tbl_client.status', 'tbl_client.clinic_number', 'tbl_client.id as client_id', 'tbl_appointment.app_status', 'tbl_appointment.appntmnt_date', 'tbl_appointment.app_type_1', 'tbl_appointment_types.id as appointment_types_id', 'tbl_appointment_types.name as appointment_types', 'tbl_clinic.name as clinic',
+ 'tbl_clnt_outgoing.status', 'tbl_clnt_outgoing.callback_status', 'tbl_clnt_outgoing.failure_reason')
+ ->where('tbl_client.status', 'Active')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->where('tbl_appointment.appntmnt_date', $app_date);
+
+ if ($slug == 'id') {
+ $query->where('tbl_appointment.app_type_1', $app_type);
+ $query->where('tbl_appointment.visit_type', $unscheduled_app);
+ $query->where('tbl_appointment.date_attended', $honored_app);
+ $query->where('tbl_appointment.app_status', $not_honored_app);
+ }
+
+
+ $result = $query->get();
+
+ return view('reports.cal_appointments', ['result' => $result]);
+ }
}
diff --git a/app/Http/Controllers/ClientController.php b/app/Http/Controllers/ClientController.php
index 1a6efa9..f49d86f 100644
--- a/app/Http/Controllers/ClientController.php
+++ b/app/Http/Controllers/ClientController.php
@@ -8,6 +8,7 @@
use App\Models\Clinic;
use App\Models\Language;
use App\Models\Condition;
+use App\Models\County;
use App\Models\Gender;
use App\Models\Marital;
use Session;
@@ -22,71 +23,154 @@ public function index()
$treatment = Condition::all();
$grouping = Group::all();
$clinics = Clinic::all();
+ $county = County::where('status', '=', 'Active')->pluck('name', 'id');
$language = Language::all()->where('status', '=', 'Active');
- return view('clients.new_client', compact('gender', 'marital', 'clinics', 'treatment', 'language', 'grouping'));
+ return view('clients.new_client', compact('gender', 'marital', 'clinics', 'treatment', 'language', 'grouping', 'county'));
}
public function add_client(Request $request)
{
- try
- {
- $request->validate([
- 'clinic_number' => 'required|numeric|digits:10',
- 'f_name' => 'required',
- 'l_name' => 'required',
- 'dob' => 'required',
- 'gender' => 'required',
- 'marital' => 'required',
- 'client_status' => 'required',
- 'enrollment_date' => 'required',
- 'art_date' => 'required',
- 'language_id' => 'required',
- 'smsenable' => 'required',
- 'motivational_enable' => 'required',
- 'txt_time' => 'required',
- 'status' => 'required',
- 'group_id' => 'required',
- ]);
- $new_client = new Client;
-
- // $validate_client = Client::where('clinic_number', $request->clinic_number)
- $new_client->clinic_number = $request->clinic_number;
- $new_client->f_name = $request->first_name;
- $new_client->m_name = $request->middle_name;
- $new_client->l_name = $request->last_name;
- $new_client->dob = $request->birth;
- $new_client->gender = $request->gender;
- $new_client->marital = $request->marital;
- $new_client->client_status = $request->treatment;
- $new_client->enrollment_date = date("Y-m-d", strtotime($request->enrollment_date));
- $new_client->art_date = date("Y-m-d", strtotime($request->art_date));
- $new_client->phone_no = $request->phone;
- $new_client->language_id = $request->language;
- $new_client->smsenable = $request->smsenable;
- $new_client->motivational_enable = $request->motivational_enable;
- $new_client->txt_time = date("H", strtotime($request->txt_time));
- $new_client->status = $request->status;
- $new_client->group_id = $request->group;
- $new_client->clinic_id = $request->clinic;
-
- $validate_ccc = Client::where('clinic_number', $request->clinic_number)
- ->first();
-
- if ($validate_ccc) {
- Session::flash('statuscode', 'error');
-
- return redirect('add/client')->with('status', 'Clinic Number already exist in the system!');
+ try {
+ // $request->validate([
+ // 'clinic_number' => 'required|numeric|digits:10',
+ // 'f_name' => 'required',
+ // 'l_name' => 'required',
+ // 'dob' => 'required',
+ // 'gender' => 'required',
+ // 'marital' => 'required',
+ // 'client_status' => 'required',
+ // 'enrollment_date' => 'required',
+ // 'art_date' => 'required',
+ // 'language_id' => 'required',
+ // 'smsenable' => 'required',
+ // 'motivational_enable' => 'required',
+ // 'txt_time' => 'required',
+ // 'status' => 'required',
+ // 'group_id' => 'required',
+ // ]);
+ $new_client = new Client;
+
+ // $validate_client = Client::where('clinic_number', $request->clinic_number)
+ $new_client->clinic_number = $request->clinic_number;
+ $new_client->f_name = $request->first_name;
+ $new_client->m_name = $request->middle_name;
+ $new_client->l_name = $request->last_name;
+ $new_client->dob = $request->birth;
+ $new_client->gender = $request->gender;
+ $new_client->marital = $request->marital;
+ $new_client->client_status = $request->treatment;
+ $new_client->enrollment_date = date("Y-m-d", strtotime($request->enrollment_date));
+ $new_client->art_date = date("Y-m-d", strtotime($request->art_date));
+ $new_client->phone_no = $request->phone;
+ $new_client->language_id = $request->language;
+ $new_client->smsenable = $request->smsenable;
+ $new_client->motivational_enable = $request->motivational_enable;
+ $new_client->txt_time = date("H", strtotime($request->txt_time));
+ $new_client->status = $request->status;
+ $new_client->group_id = $request->group;
+ $new_client->clinic_id = $request->clinic;
+ $new_client->client_type = "New";
+ $new_client->mfl_code = Auth::user()->facility_id;
+ $new_client->facility_id = Auth::user()->facility_id;
+ $new_client->locator_county = $request->county;
+ $new_client->locator_sub_county = $request->subcounty;
+ $new_client->locator_ward = $request->ward;
+ $new_client->locator_location = $request->location;
+ $new_client->locator_village = $request->village;
+
+ $validate_ccc = Client::where('clinic_number', $request->clinic_number)
+ ->first();
+
+ if ($validate_ccc) {
+ Session::flash('statuscode', 'error');
+
+ return redirect('add/clients')->with('status', 'Clinic Number already exist in the system!');
+ }
+ if ($new_client->save()) {
+ Session::flash('statuscode', 'success');
+
+ return redirect('/Reports/facility_home')->with('status', 'Client has been registered successfully!');
+ } else {
+ Session::flash('statuscode', 'error');
+ return back()->with('error', 'An error has occurred please try again later.');
+ }
+ } catch (Exception $e) {
+
+ return back();
}
- if ($new_client->save()) {
+ }
+
+
+ public function check_client_form()
+ {
+ return view('clients.edit_client');
+ }
+
+ public function check_client(Request $request)
+ {
+ $client_search = Client::where('clinic_number', $request->upn_search)->first();
+
+ if ($client_search) {
Session::flash('statuscode', 'success');
- return redirect('Reports/facility_home')->with('status', 'Client has been registered successfully!');
- } else {
- Session::flash('statuscode', 'error');
- return back()->with('error', 'An error has occurred please try again later.');
+ return redirect('edit/client')->with('status', 'Client Found Continue to Edit!');
+ } elseif (!$client_search) {
+ Session::flash('statuscode', 'success');
+
+ return redirect('edit/client')->with('status', 'Client Found Not!');
}
- } catch (Exception $e) {
+ }
+ public function client_search(Request $request)
+ {
- return back();
+ $upn_search = $request->input('upn_search');
+
+ $client_search = Client::join('tbl_gender', 'tbl_client.gender', '=', 'tbl_gender.id')
+ ->leftjoin('tbl_language', 'tbl_client.language_id', '=', 'tbl_language.id')
+ ->leftjoin('tbl_groups', 'tbl_client.group_id', '=', 'tbl_groups.id')
+ ->leftjoin('tbl_marital_status', 'tbl_client.marital', '=', 'tbl_marital_status.id')
+ ->select(
+ 'tbl_client.id',
+ 'tbl_client.clinic_number',
+ 'tbl_client.phone_no',
+ 'tbl_client.f_name',
+ 'tbl_client.m_name',
+ 'tbl_client.l_name',
+ 'tbl_client.art_date',
+ 'tbl_client.enrollment_date',
+ 'tbl_client.file_no',
+ 'tbl_client.dob',
+ 'tbl_client.clinic_number',
+ 'tbl_client.client_status',
+ 'tbl_client.status',
+ 'tbl_client.smsenable',
+ 'tbl_client.consent_date',
+ 'tbl_gender.name as gender',
+ 'tbl_groups.name as group_name',
+ 'tbl_language.name as language',
+ 'tbl_client.marital',
+ 'tbl_client.locator_county',
+ 'tbl_client.locator_sub_county',
+ 'tbl_client.locator_ward',
+ 'tbl_client.locator_location',
+ 'tbl_client.locator_village'
+ )
+ ->where('tbl_client.clinic_number', 'LIKE', '%' . $upn_search . '%')
+ ->whereNull('tbl_client.hei_no')
+ // ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->get();
+
+ // return $client_search;
+ return view('clients.edit_client_form', compact('client_search'));
}
+ public function editForm()
+ {
+ $gender = Gender::all();
+ $marital = Marital::all();
+ $treatment = Condition::all();
+ $grouping = Group::all();
+ $clinics = Clinic::all();
+ $county = County::where('status', '=', 'Active')->pluck('name', 'id');
+ $language = Language::all()->where('status', '=', 'Active');
+ return view('clients.edit_client_form', compact('gender', 'marital', 'clinics', 'treatment', 'language', 'grouping', 'county'));
}
}
diff --git a/app/Http/Controllers/ClientListController.php b/app/Http/Controllers/ClientListController.php
index 907d351..03f5251 100644
--- a/app/Http/Controllers/ClientListController.php
+++ b/app/Http/Controllers/ClientListController.php
@@ -14,6 +14,7 @@
use App\Models\Message;
use App\Models\Facility;
use App\Models\ClientReport;
+use App\Models\Pmtct;
use Auth;
use DB;
@@ -26,6 +27,8 @@ public function get_client_list()
$all_clients = Client::select('tbl_clinic.name', 'tbl_client.file_no', 'tbl_client.file_no', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as client_name"), 'tbl_groups.name AS group_name', 'tbl_client.dob', 'tbl_client.status', 'tbl_client.clinic_number', 'tbl_client.phone_no', 'tbl_client.created_at', 'tbl_client.enrollment_date', 'tbl_client.art_date', 'tbl_client.client_status')
->join('tbl_groups', 'tbl_groups.id', '=', 'tbl_client.group_id')
->join('tbl_clinic', 'tbl_clinic.id', '=', 'tbl_client.clinic_id')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
->whereNotNull('tbl_client.clinic_number');
if (Auth::user()->access_level == 'Facility') {
@@ -71,7 +74,8 @@ public function get_client_profile()
'tbl_gender.name as gender',
'tbl_groups.name as group_name',
'tbl_language.name as language',
- 'tbl_marital_status.marital'
+ 'tbl_marital_status.marital',
+ 'tbl_client.upi_no'
)
// ->where('tbl_client.clinic_number', 'LIKE', "%{$upn_search}%")
->where('tbl_client.mfl_code', Auth::user()->facility_id)
@@ -90,7 +94,7 @@ public function get_client_profile()
->count();
$kept_appointment = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
->select('tbl_appointment.id')
- ->where('tbl_appointment.appointment_kept', '=', 'Yes')
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
->where('tbl_client.mfl_code', Auth::user()->facility_id)
->count();
$missed_app = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
@@ -151,9 +155,40 @@ public function get_client_profile()
->select('tbl_client.clinic_number', 'tbl_client.file_no', 'tbl_appointment.appntmnt_date', 'tbl_appointment_types.name as app_type', 'tbl_clnt_outcome.tracer_name', 'tbl_final_outcome.name as final_outcome', 'tbl_outcome.name as outcome')
->where('tbl_client.mfl_code', Auth::user()->facility_id)
->paginate(1);
+
+ $hei_profile = Pmtct::join('tbl_client', 'tbl_pmtct.client_id', '=', 'tbl_client.id')
+ ->join('tbl_gender', 'tbl_pmtct.hei_gender', '=', 'tbl_gender.id')
+ ->join('tbl_caregiver_not_on_care', 'tbl_pmtct.care_giver_id', '=', 'tbl_caregiver_not_on_care.id')
+ ->select(
+ DB::raw("CONCAT(`tbl_pmtct`.`hei_first_name`, ' ', `tbl_pmtct`.`hei_middle_name`, ' ', `tbl_pmtct`.`hei_last_name`) as hei_name"),
+ 'tbl_pmtct.hei_no',
+ 'tbl_pmtct.hei_dob',
+ 'tbl_gender.name as gender',
+ 'tbl_client.clinic_number',
+ DB::raw("CONCAT(`tbl_caregiver_not_on_care`.`care_giver_fname`, ' ', `tbl_caregiver_not_on_care`.`care_giver_mname`, ' ', `tbl_caregiver_not_on_care`.`care_giver_lname`) as caregiver_name")
+ )
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->paginate(1);
}
//dd($data);
- return view('clients.client_profile', compact('client_profile', 'total_appointments', 'future_appointment', 'kept_appointment', 'missed_app', 'defaulted_app', 'ltfu_app', 'refill_app', 'clinical_app', 'adherence_app', 'lab_app', 'viral_app', 'other_app', 'outgoing_msg', 'appointment_outcome'));
+ return view('clients.client_profile', compact(
+ 'client_profile',
+ 'total_appointments',
+ 'future_appointment',
+ 'kept_appointment',
+ 'missed_app',
+ 'defaulted_app',
+ 'ltfu_app',
+ 'refill_app',
+ 'clinical_app',
+ 'adherence_app',
+ 'lab_app',
+ 'viral_app',
+ 'other_app',
+ 'outgoing_msg',
+ 'appointment_outcome',
+ 'hei_profile'
+ ));
}
public function profile_search(Request $request)
@@ -180,9 +215,11 @@ public function profile_search(Request $request)
'tbl_gender.name as gender',
'tbl_groups.name as group_name',
'tbl_language.name as language',
- 'tbl_marital_status.marital'
+ 'tbl_marital_status.marital',
+ 'tbl_client.upi_no'
)
->where('tbl_client.clinic_number', 'LIKE', '%' . $upn_search . '%')
+ ->whereNull('tbl_client.hei_no')
->where('tbl_client.mfl_code', Auth::user()->facility_id)
->get();
@@ -201,7 +238,7 @@ public function profile_search(Request $request)
->count();
$kept_appointment = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
->select('tbl_appointment.id')
- ->where('tbl_appointment.appointment_kept', '=', 'Yes')
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
->where('tbl_client.clinic_number', 'LIKE', '%' . $upn_search . '%')
->where('tbl_client.mfl_code', Auth::user()->facility_id)
->count();
@@ -263,6 +300,7 @@ public function profile_search(Request $request)
->join('tbl_message_types', 'tbl_clnt_outgoing.message_type_id', '=', 'tbl_message_types.id')
->select('tbl_client.clinic_number', 'tbl_message_types.name as message_type', 'tbl_clnt_outgoing.destination', 'tbl_clnt_outgoing.created_at', 'tbl_clnt_outgoing.msg')
->where('tbl_client.clinic_number', 'LIKE', '%' . $upn_search . '%')
+ ->whereNull('tbl_client.hei_no')
->where('tbl_client.mfl_code', Auth::user()->facility_id)
->get();
$appointment_outcome = Outcome::join('tbl_client', 'tbl_clnt_outcome.client_id', '=', 'tbl_client.id')
@@ -272,14 +310,328 @@ public function profile_search(Request $request)
->join('tbl_outcome', 'tbl_clnt_outcome.outcome', '=', 'tbl_outcome.id')
->select('tbl_client.clinic_number', 'tbl_client.file_no', 'tbl_appointment.appntmnt_date', 'tbl_appointment_types.name as app_type', 'tbl_clnt_outcome.tracer_name', 'tbl_final_outcome.name as final_outcome', 'tbl_outcome.name as outcome')
->where('tbl_client.clinic_number', 'LIKE', '%' . $upn_search . '%')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->get();
+
+ $hei_search = $request->input('hei_search');
+
+ $hei_profile = Pmtct::join('tbl_client', 'tbl_pmtct.client_id', '=', 'tbl_client.id')
+ ->join('tbl_gender', 'tbl_pmtct.hei_gender', '=', 'tbl_gender.id')
+ ->join('tbl_caregiver_not_on_care', 'tbl_pmtct.care_giver_id', '=', 'tbl_caregiver_not_on_care.id')
+ ->select(
+ DB::raw("CONCAT(`tbl_pmtct`.`hei_first_name`, ' ', `tbl_pmtct`.`hei_middle_name`, ' ', `tbl_pmtct`.`hei_last_name`) as hei_name"),
+ 'tbl_pmtct.hei_no',
+ 'tbl_pmtct.hei_dob',
+ 'tbl_gender.name as gender',
+ 'tbl_client.clinic_number',
+ DB::raw("CONCAT(`tbl_caregiver_not_on_care`.`care_giver_fname`, ' ', `tbl_caregiver_not_on_care`.`care_giver_mname`, ' ', `tbl_caregiver_not_on_care`.`care_giver_lname`) as caregiver_name")
+ )
+ ->where('tbl_pmtct.hei_no', $hei_search)
->where('tbl_client.mfl_code', Auth::user()->facility_id)
->get();
}
- //dd($data);
- return view('clients.client_profile', compact('client_profile', 'total_appointments', 'future_appointment', 'kept_appointment', 'missed_app', 'defaulted_app', 'ltfu_app', 'refill_app', 'clinical_app', 'adherence_app', 'lab_app', 'viral_app', 'other_app', 'outgoing_msg', 'appointment_outcome'));
+ //dd($hei_profile);
+ return view('clients.client_profile', compact(
+ 'client_profile',
+ 'total_appointments',
+ 'future_appointment',
+ 'kept_appointment',
+ 'missed_app',
+ 'defaulted_app',
+ 'ltfu_app',
+ 'refill_app',
+ 'clinical_app',
+ 'adherence_app',
+ 'lab_app',
+ 'viral_app',
+ 'other_app',
+ 'outgoing_msg',
+ 'appointment_outcome',
+ 'hei_profile'
+ ));
+ }
+ public function get_hei_profile()
+ {
+ if (Auth::user()->access_level == 'Facility') {
+
+ $total_appointments = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_appointment.id')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $future_appointment = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_appointment.id')
+ ->where('tbl_appointment.appntmnt_date', '>=', Now())
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $kept_appointment = 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'))
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $missed_app = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_appointment.id')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $defaulted_app = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_appointment.id')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $ltfu_app = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_appointment.id')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $refill_app = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_appointment.id')
+ ->where('tbl_appointment.app_type_1', '=', '1')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $clinical_app = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_appointment.id')
+ ->where('tbl_appointment.app_type_1', '=', '2')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $adherence_app = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_appointment.id')
+ ->where('tbl_appointment.app_type_1', '=', '3')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $lab_app = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_appointment.id')
+ ->where('tbl_appointment.app_type_1', '=', '4')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $viral_app = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_appointment.id')
+ ->where('tbl_appointment.app_type_1', '=', '5')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $other_app = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_appointment.id')
+ ->where('tbl_appointment.app_type_1', '=', '6')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $outgoing_msg = Message::join('tbl_client', 'tbl_clnt_outgoing.clnt_usr_id', '=', 'tbl_client.id')
+ ->join('tbl_message_types', 'tbl_clnt_outgoing.message_type_id', '=', 'tbl_message_types.id')
+ ->select('tbl_client.clinic_number', 'tbl_client.hei_no', 'tbl_message_types.name as message_type', 'tbl_clnt_outgoing.destination', 'tbl_clnt_outgoing.created_at', 'tbl_clnt_outgoing.msg')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->paginate(1);
+ $appointment_outcome = Outcome::join('tbl_client', 'tbl_clnt_outcome.client_id', '=', 'tbl_client.id')
+ ->join('tbl_appointment', 'tbl_clnt_outcome.appointment_id', '=', 'tbl_appointment.id')
+ ->join('tbl_appointment_types', 'tbl_appointment.app_type_1', '=', 'tbl_appointment_types.id')
+ ->join('tbl_final_outcome', 'tbl_clnt_outcome.fnl_outcome', '=', 'tbl_final_outcome.id')
+ ->join('tbl_outcome', 'tbl_clnt_outcome.outcome', '=', 'tbl_outcome.id')
+ ->select('tbl_client.clinic_number', 'tbl_client.hei_no', 'tbl_client.file_no', 'tbl_appointment.appntmnt_date', 'tbl_appointment_types.name as app_type', 'tbl_clnt_outcome.tracer_name', 'tbl_final_outcome.name as final_outcome', 'tbl_outcome.name as outcome')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->paginate(1);
+
+ $hei_profile = Pmtct::join('tbl_client', 'tbl_pmtct.client_id', '=', 'tbl_client.id')
+ ->join('tbl_gender', 'tbl_pmtct.hei_gender', '=', 'tbl_gender.id')
+ ->leftJoin('tbl_caregiver_not_on_care', 'tbl_pmtct.care_giver_id', '=', 'tbl_caregiver_not_on_care.id')
+ ->select(
+ DB::raw("CONCAT(`tbl_pmtct`.`hei_first_name`, ' ', `tbl_pmtct`.`hei_middle_name`, ' ', `tbl_pmtct`.`hei_last_name`) as hei_name"),
+ 'tbl_pmtct.hei_no',
+ 'tbl_pmtct.hei_dob',
+ 'tbl_gender.name as gender',
+ 'tbl_client.clinic_number',
+ DB::raw("CONCAT(`tbl_caregiver_not_on_care`.`care_giver_fname`, ' ', `tbl_caregiver_not_on_care`.`care_giver_mname`, ' ', `tbl_caregiver_not_on_care`.`care_giver_lname`) as caregiver_name")
+ )
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->get();
+
+ // dd($appointment_outcome);
+ }
+ return view('clients.hei_profile', compact(
+ 'hei_profile',
+ 'total_appointments',
+ 'future_appointment',
+ 'kept_appointment',
+ 'missed_app',
+ 'defaulted_app',
+ 'ltfu_app',
+ 'refill_app',
+ 'clinical_app',
+ 'adherence_app',
+ 'lab_app',
+ 'viral_app',
+ 'other_app',
+ 'outgoing_msg',
+ 'appointment_outcome'
+ ));
}
+ public function profile_search_hei(Request $request)
+ {
+ if (Auth::user()->access_level == 'Facility') {
+ $hei_search = $request->input('hei_search');
+
+ $hei_profile = Pmtct::join('tbl_client', 'tbl_pmtct.client_id', '=', 'tbl_client.id')
+ ->join('tbl_gender', 'tbl_pmtct.hei_gender', '=', 'tbl_gender.id')
+ ->leftJoin('tbl_caregiver_not_on_care', 'tbl_pmtct.care_giver_id', '=', 'tbl_caregiver_not_on_care.id')
+ ->select(
+ DB::raw("CONCAT(`tbl_pmtct`.`hei_first_name`, ' ', `tbl_pmtct`.`hei_middle_name`, ' ', `tbl_pmtct`.`hei_last_name`) as hei_name"),
+ 'tbl_pmtct.hei_no',
+ 'tbl_pmtct.hei_dob',
+ 'tbl_gender.name as gender',
+ 'tbl_client.clinic_number',
+ DB::raw("CONCAT(`tbl_caregiver_not_on_care`.`care_giver_fname`, ' ', `tbl_caregiver_not_on_care`.`care_giver_mname`, ' ', `tbl_caregiver_not_on_care`.`care_giver_lname`) as caregiver_name")
+ )
+ ->where('tbl_pmtct.hei_no', 'LIKE', '%' . $hei_search . '%')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->get();
+ $total_appointments = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->select('tbl_appointment.id')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_pmtct.hei_no', 'LIKE', '%' . $hei_search . '%')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $future_appointment = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->select('tbl_appointment.id')
+ ->where('tbl_appointment.appntmnt_date', '>=', Now())
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_pmtct.hei_no', 'LIKE', '%' . $hei_search . '%')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $kept_appointment = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->select('tbl_appointment.id')
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_pmtct.hei_no', 'LIKE', '%' . $hei_search . '%')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $missed_app = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->select('tbl_appointment.id')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_pmtct.hei_no', 'LIKE', '%' . $hei_search . '%')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $defaulted_app = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->select('tbl_appointment.id')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_pmtct.hei_no', 'LIKE', '%' . $hei_search . '%')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $ltfu_app = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->select('tbl_appointment.id')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_pmtct.hei_no', 'LIKE', '%' . $hei_search . '%')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $refill_app = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->select('tbl_appointment.id')
+ ->where('tbl_appointment.app_type_1', '=', '1')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_pmtct.hei_no', 'LIKE', '%' . $hei_search . '%')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $clinical_app = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->select('tbl_appointment.id')
+ ->where('tbl_appointment.app_type_1', '=', '2')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_pmtct.hei_no', 'LIKE', '%' . $hei_search . '%')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $adherence_app = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->select('tbl_appointment.id')
+ ->where('tbl_appointment.app_type_1', '=', '3')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_pmtct.hei_no', 'LIKE', '%' . $hei_search . '%')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $lab_app = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->select('tbl_appointment.id')
+ ->where('tbl_appointment.app_type_1', '=', '4')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_pmtct.hei_no', 'LIKE', '%' . $hei_search . '%')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $viral_app = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->select('tbl_appointment.id')
+ ->where('tbl_appointment.app_type_1', '=', '5')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_pmtct.hei_no', 'LIKE', '%' . $hei_search . '%')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $other_app = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->select('tbl_appointment.id')
+ ->where('tbl_appointment.app_type_1', '=', '6')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_pmtct.hei_no', 'LIKE', '%' . $hei_search . '%')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->count();
+ $outgoing_msg = Message::join('tbl_client', 'tbl_clnt_outgoing.clnt_usr_id', '=', 'tbl_client.id')
+ ->join('tbl_message_types', 'tbl_clnt_outgoing.message_type_id', '=', 'tbl_message_types.id')
+ ->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->select('tbl_client.clinic_number', 'tbl_client.hei_no', 'tbl_message_types.name as message_type', 'tbl_clnt_outgoing.destination', 'tbl_clnt_outgoing.created_at', 'tbl_clnt_outgoing.msg')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_pmtct.hei_no', 'LIKE', '%' . $hei_search . '%')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->get();
+ $appointment_outcome = Outcome::join('tbl_client', 'tbl_clnt_outcome.client_id', '=', 'tbl_client.id')
+ ->join('tbl_appointment', 'tbl_clnt_outcome.appointment_id', '=', 'tbl_appointment.id')
+ ->join('tbl_appointment_types', 'tbl_appointment.app_type_1', '=', 'tbl_appointment_types.id')
+ ->join('tbl_final_outcome', 'tbl_clnt_outcome.fnl_outcome', '=', 'tbl_final_outcome.id')
+ ->join('tbl_outcome', 'tbl_clnt_outcome.outcome', '=', 'tbl_outcome.id')
+ ->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->select('tbl_client.clinic_number', 'tbl_client.hei_no', 'tbl_client.file_no', 'tbl_appointment.appntmnt_date', 'tbl_appointment_types.name as app_type', 'tbl_clnt_outcome.tracer_name', 'tbl_final_outcome.name as final_outcome', 'tbl_outcome.name as outcome')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_pmtct.hei_no', 'LIKE', '%' . $hei_search . '%')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->get();
+
+ // dd($hei_profile);
+ }
+ return view('clients.hei_profile', compact(
+ 'hei_profile',
+ 'total_appointments',
+ 'future_appointment',
+ 'kept_appointment',
+ 'missed_app',
+ 'defaulted_app',
+ 'ltfu_app',
+ 'refill_app',
+ 'clinical_app',
+ 'adherence_app',
+ 'lab_app',
+ 'viral_app',
+ 'other_app',
+ 'outgoing_msg',
+ 'appointment_outcome'
+ ));
+ }
public function client_extract()
{
@@ -297,6 +649,7 @@ public function client_extract()
'client_report.created_at',
'client_report.month_year',
'client_report.LANGUAGE',
+ 'client_report.consented',
'client_report.txt_time',
'client_report.partner_name',
'client_report.county',
@@ -304,7 +657,8 @@ public function client_extract()
'client_report.mfl_code',
'client_report.facility_name',
'client_report.consented',
- 'tbl_client.wellness_enable'
+ 'tbl_client.wellness_enable',
+ 'tbl_client.upi_no'
)
->where('client_report.mfl_code', Auth::user()->facility_id)
->get();
@@ -329,7 +683,8 @@ public function client_extract()
'client_report.mfl_code',
'client_report.facility_name',
'client_report.consented',
- 'tbl_client.wellness_enable'
+ 'tbl_client.wellness_enable',
+ 'tbl_client.upi_no'
)
->where('client_report.partner_id', Auth::user()->partner_id)
->get();
@@ -355,7 +710,8 @@ public function client_extract()
'client_report.mfl_code',
'client_report.facility_name',
'client_report.consented',
- 'tbl_client.wellness_enable'
+ 'tbl_client.wellness_enable',
+ 'tbl_client.upi_no'
)
->get();
$client_extract;
@@ -380,7 +736,8 @@ public function client_extract()
'client_report.mfl_code',
'client_report.facility_name',
'client_report.consented',
- 'tbl_client.wellness_enable'
+ 'tbl_client.wellness_enable',
+ 'tbl_client.upi_no'
)
->get();
}
@@ -411,7 +768,8 @@ public function filter_client_extract(Request $request)
'client_report.mfl_code',
'client_report.facility_name',
'client_report.consented',
- 'tbl_client.wellness_enable'
+ 'tbl_client.wellness_enable',
+ 'tbl_client.upi_no'
)
->where('client_report.mfl_code', Auth::user()->facility_id)
->whereDate('client_report.created_at', '>=', date($request->from))
@@ -438,7 +796,8 @@ public function filter_client_extract(Request $request)
'client_report.mfl_code',
'client_report.facility_name',
'client_report.consented',
- 'tbl_client.wellness_enable'
+ 'tbl_client.wellness_enable',
+ 'tbl_client.upi_no'
)
->whereDate('client_report.created_at', '>=', date($request->from))
->whereDate('client_report.created_at', '<=', date($request->to))
@@ -465,7 +824,8 @@ public function filter_client_extract(Request $request)
'client_report.mfl_code',
'client_report.facility_name',
'client_report.consented',
- 'tbl_client.wellness_enable'
+ 'tbl_client.wellness_enable',
+ 'tbl_client.upi_no'
)
->whereDate('client_report.created_at', '>=', date($request->from))
->whereDate('client_report.created_at', '<=', date($request->to))
@@ -491,7 +851,8 @@ public function filter_client_extract(Request $request)
'client_report.mfl_code',
'client_report.facility_name',
'client_report.consented',
- 'tbl_client.wellness_enable'
+ 'tbl_client.wellness_enable',
+ 'tbl_client.upi_no'
)
->whereDate('client_report.created_at', '>=', date($request->from))
->whereDate('client_report.created_at', '<=', date($request->to))
diff --git a/app/Http/Controllers/ConsentController.php b/app/Http/Controllers/ConsentController.php
index 0c921a9..fa69709 100644
--- a/app/Http/Controllers/ConsentController.php
+++ b/app/Http/Controllers/ConsentController.php
@@ -1,6 +1,7 @@
access_level == 'Facility') {
- $consented_clients = Client::join('tbl_groups', 'tbl_groups.id', 'tbl_client.group_id')
- ->select('tbl_client.clinic_number', 'tbl_client.id', 'tbl_client.file_no', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as full_name"),'tbl_client.phone_no', 'tbl_client.dob', 'tbl_client.client_status', 'tbl_groups.name', 'tbl_client.created_at', 'tbl_client.smsenable', 'tbl_client.enrollment_date', 'tbl_client.art_date', 'tbl_client.updated_at', 'tbl_client.status', 'tbl_client.consent_date', 'tbl_client.txt_time')
+ if (Auth::user()->access_level == 'Facility') {
+ $consented_clients = Client::join('tbl_groups', 'tbl_groups.id', 'tbl_client.group_id')
+ ->select('tbl_client.clinic_number', 'tbl_client.id', 'tbl_client.file_no', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as full_name"), 'tbl_client.phone_no', 'tbl_client.dob', 'tbl_client.client_status', 'tbl_groups.name', 'tbl_client.created_at', 'tbl_client.smsenable', 'tbl_client.enrollment_date', 'tbl_client.art_date', 'tbl_client.updated_at', 'tbl_client.status', 'tbl_client.consent_date', 'tbl_client.txt_time')
->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
->where('tbl_client.mfl_code', Auth::user()->facility_id)
->get();
- }
- return view('clients.consent')->with('consented_clients', $consented_clients);
-
+ }
+ return view('clients.consent')->with('consented_clients', $consented_clients);
}
public function addconsentform()
{
@@ -32,58 +34,57 @@ public function client_consent(Request $request)
{
try {
$request->validate([
- 'consent_date' => 'required',
- 'smsenable' => 'required',
- 'language_id' => 'required',
- 'motivational_enable' => 'required',
- 'txt_time' => 'required',
- 'phone_no' => 'required|regex:/(01)[0-9]{9}/'
+ 'consent_date' => 'required',
+ 'smsenable' => 'required',
+ 'language_id' => 'required',
+ 'motivational_enable' => 'required',
+ 'txt_time' => 'required',
+ 'phone_no' => 'required|regex:/(01)[0-9]{9}/'
]);
$client = Client::find($request->input('id'));
- $client->consent_date = strtotime($request->input('consent_date'));
- $client->smsenable = $request->input('smsenable');
- $client->language_id = $request->input('language_id');
- $client->motivational_enable = $request->input('motivational_enable');
- $client->txt_time = date("H", strtotime($request->input('txt_time')));
- $client->phone_no = $request->input('phone_no');
- $client->save();
- // console.log($client->save());
- if ($client) {
- Session::flash('statuscode', 'success');
- return redirect('consent/clients')->with('status', 'Client was successfully consented in the system!');
- } else {
- Session::flash('statuscode', 'error');
- return back()->with('error', 'Could not consent client please try again later.');
- }
- } catch (Exception $e) {
- return back();
+ $client->consent_date = strtotime($request->input('consent_date'));
+ $client->smsenable = $request->input('smsenable');
+ $client->language_id = $request->input('language_id');
+ $client->motivational_enable = $request->input('motivational_enable');
+ $client->txt_time = date("H", strtotime($request->input('txt_time')));
+ $client->phone_no = $request->input('phone_no');
+ $client->save();
+ // console.log($client->save());
+ if ($client) {
+ Session::flash('statuscode', 'success');
+ return redirect('consent/clients')->with('status', 'Client was successfully consented in the system!');
+ } else {
+ Session::flash('statuscode', 'error');
+ return back()->with('error', 'Could not consent client please try again later.');
}
+ } catch (Exception $e) {
+ return back();
+ }
}
public function consent_test(Request $request)
{
try {
- $client = Client::where('clinic_number', $request->clinic_number)
- ->update([
- 'consent_date' => date("Y-m-d", strtotime($request->consent_date)),
- 'smsenable' => $request->smsenable,
- 'language_id' => $request->language_id,
- 'motivational_enable' => $request->motivational_enable,
- 'txt_time' => date("H", strtotime($request->txt_time)),
- 'phone_no' => $request->phone_no,
+ $client = Client::where('clinic_number', $request->clinic_number)
+ ->update([
+ 'consent_date' => date("Y-m-d", strtotime($request->consent_date)),
+ 'smsenable' => $request->smsenable,
+ 'language_id' => $request->language_id,
+ 'motivational_enable' => $request->motivational_enable,
+ 'txt_time' => date("H", strtotime($request->txt_time)),
+ 'phone_no' => $request->phone_no,
- ]);
- if ($client) {
- Session::flash('statuscode', 'success');
- return redirect('consent/clients')->with('status', 'Client was successfully consented in the system!');
- } else {
- Session::flash('statuscode', 'error');
- return back()->with('error', 'Could not consent client please try again later.');
- }
- } catch (Exception $e) {
- return back();
+ ]);
+ if ($client) {
+ Session::flash('statuscode', 'success');
+ return redirect('consent/clients')->with('status', 'Client was successfully consented in the system!');
+ } else {
+ Session::flash('statuscode', 'error');
+ return back()->with('error', 'Could not consent client please try again later.');
}
-
+ } catch (Exception $e) {
+ return back();
+ }
}
}
diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php
index 130af29..3cf05ab 100644
--- a/app/Http/Controllers/DashboardController.php
+++ b/app/Http/Controllers/DashboardController.php
@@ -14,6 +14,7 @@
use App\Models\TodayAppointment;
use App\Models\Message;
use App\Models\County;
+use App\Models\Ward;
use App\Models\SubCounty;
use App\Models\MainDashboardBar;
use App\Models\ClientRegistration;
@@ -40,13 +41,11 @@ public function user_level()
{
$facility_all = Facility::all()->where('code', Auth::user()->facility_id);
- if (Auth::user()->access_level == 'Partner')
- {
- $partner_all = Partner::all()->where('id', Auth::user()->partner_id);
+ if (Auth::user()->access_level == 'Partner') {
+ $partner_all = Partner::all()->where('id', Auth::user()->partner_id);
}
- if (Auth::user()->access_level == 'Donor')
- {
- $donor_all = Donor::all()->where('id', Auth::user()->donor_id);
+ if (Auth::user()->access_level == 'Donor') {
+ $donor_all = Donor::all()->where('id', Auth::user()->donor_id);
}
return view('layouts.large-vertical-sidebar.header', compact('facility_all', 'partner_all', 'donor_all'));
@@ -154,67 +153,70 @@ public function main_graph_dashboard()
if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
- $all_partners = Partner::where('status', '=', 'Active')
- ->pluck('name', 'id');
-
- //$all_counties = County::select('id', 'name')->distinct('id')->whereIn('id', $counties_with_data)->get();
-
-
- $all_clients_number = ClientPerformance::whereNotNull('actual_clients')->sum('actual_clients');
- $pec_client_sum = ClientRegistration::select('total_percentage')->sum('total_percentage');
- $pec_client_count = ClientRegistration::whereNotNull('total_percentage')->avg('total_percentage');
- $all_target_clients = ClientPerformance::whereNotNull('target_clients')->sum('target_clients');
- $all_consented_clients = ClientRegistration::whereNotNull('consented')->sum('consented');
- $all_future_appointments = FutureApp::join('tbl_partner_facility', 'tbl_future_appointments_query.mfl_code', '=', 'tbl_partner_facility.mfl_code')->count();
- $number_of_facilities = ClientPerformance::whereNotNull('mfl_code')->count();
-
- $bar_appointments_data = BarAppointment::all();
- $bar_clients_data = BarClient::all();
-
-
- $registered_clients_count = ClientRegistration::select('clients')->sum('clients');
- $consented_clients_count = ClientRegistration::select('consented')->sum('consented');
+ $all_partners = Partner::where('status', '=', 'Active')
+ ->pluck('name', 'id');
+
+ $all_clients_number = Client::whereNotNull('clinic_number')->count();
+ $pec_client_sum = Client::whereNotNull('id')->count();
+ $pec_client = Client::where('status', '=', 'Active')->count();
+ $pec_client_count = round(($pec_client / $pec_client_sum * 100), 1);
+ $all_target_clients = PartnerFacility::select('avg_clients')->where('is_approved', '=', 'Yes')->sum('avg_clients');
+ $all_consented_clients = Client::where('smsenable', '=', 'Yes')->count();
+ $all_future_appointments = FutureApp::join('tbl_partner_facility', 'tbl_future_appointments_query.mfl_code', '=', 'tbl_partner_facility.mfl_code')->count();
+ $number_of_facilities = PartnerFacility::select('mfl_code')->where('is_approved', '=', 'Yes')->count();
+ $registered_clients_count = Client::whereNotNull('clinic_number')->count();
+ $consented_clients_count = Client::where('smsenable', '=', 'Yes')->count();
}
- if (Auth::user()->access_level == 'Partner'){
+ if (Auth::user()->access_level == 'Partner') {
$all_partners = Partner::where('status', '=', 'Active')
- ->where('id', Auth::user()->partner_id)
- ->pluck('name', 'id');
-
- //$all_counties = County::select('id', 'name')->distinct('id')->whereIn('id', $counties_with_data)->get();
-
-
- $all_clients_number = ClientPerformance::whereNotNull('actual_clients')
- ->where('partner_id', Auth::user()->partner_id)
- ->sum('actual_clients');
- $pec_client_sum = ClientRegistration::select('total_percentage')
- ->where('partner_id', Auth::user()->partner_id)
- ->sum('total_percentage');
- $pec_client_count = ClientRegistration::whereNotNull('total_percentage')
- ->where('partner_id', Auth::user()->partner_id)
- ->avg('total_percentage');
- $all_target_clients = ClientPerformance::whereNotNull('target_clients')
- ->where('partner_id', Auth::user()->partner_id)
- ->sum('target_clients');
- $all_consented_clients = ClientRegistration::whereNotNull('consented')
- ->where('partner_id', Auth::user()->partner_id)
- ->sum('consented');
+ ->where('id', Auth::user()->partner_id)
+ ->pluck('name', 'id');
+
+ $all_clients_number = Client::whereNotNull('clinic_number')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->count();
+ $pec_client_sum = Client::whereNotNull('id')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->count();
+ $pec_client = Client::where('status', '=', 'Active')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->count();
+ $pec_client_count = round(($pec_client / $pec_client_sum * 100), 1);
+ $all_target_clients = PartnerFacility::select('avg_clients')->where('is_approved', '=', 'Yes')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->sum('avg_clients');
+
+ // dd($all_target_clients);
+ $all_consented_clients = Client::where('smsenable', '=', 'Yes')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->count();
$all_future_appointments = FutureApp::join('tbl_partner_facility', 'tbl_future_appointments_query.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
- ->count();
- $number_of_facilities = ClientPerformance::whereNotNull('mfl_code')
- ->where('partner_id', Auth::user()->partner_id)
- ->count();
-
-
- $registered_clients_count = ClientRegistration::select('clients')
- ->where('partner_id', Auth::user()->partner_id)->sum('clients');
- $consented_clients_count = ClientRegistration::select('consented')
- ->where('partner_id', Auth::user()->partner_id)->sum('consented');
- $bar_appointments_data = BarAppointment::all()->where('partner_id', Auth::user()->partner_id);
- $bar_clients_data = BarClient::all()->where('partner_id', Auth::user()->partner_id);
- }
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->count();
+ $number_of_facilities = PartnerFacility::select('mfl_code')->where('is_approved', '=', 'Yes')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->count();
+ $registered_clients_count = Client::whereNotNull('clinic_number')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->count();
+ $consented_clients_count = Client::where('smsenable', '=', 'Yes')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->count();
+
+
+ // $all_clients_number = cache()->remember('all_clients_number', now()->addMinutes(5), function () {
+ // return ClientPerformance::whereNotNull('actual_clients')
+ // ->where('partner_id', Auth::user()->partner_id)
+ // ->sum('actual_clients');
+ // });
+ // $pec_client_sum = cache()->remember('pec_client_sum', now()->addMinutes(5), function () {
+ // return ClientRegistration::select('total_percentage')
+ // ->where('partner_id', Auth::user()->partner_id)
+ // ->sum('total_percentage');
+ // });
+ }
$data["all_clients_number"] = $all_clients_number;
@@ -224,14 +226,10 @@ public function main_graph_dashboard()
$data["all_future_appointments"] = $all_future_appointments;
$data["number_of_facilities"] = $number_of_facilities;
$data["all_partners"] = $all_partners;
- $data["bar_appointments_data"] = $bar_appointments_data;
- $data["bar_clients_data"] = $bar_clients_data;
$data["registered_clients_count"] = $registered_clients_count;
$data["consented_clients_count"] = $consented_clients_count;
-
-
return view('dashboard.dashboardv1', compact(
'all_partners',
'all_clients_number',
@@ -241,8 +239,6 @@ public function main_graph_dashboard()
'number_of_facilities',
'pec_client_count',
'registered_clients_count',
- 'bar_clients_data',
- 'bar_appointments_data',
'consented_clients_count'
));
}
@@ -268,67 +264,74 @@ public function filter_dashboard(Request $request)
}
- $all_clients_number = ClientPerformance::whereNotNull('actual_clients');
- $pec_client_sum = ClientRegistration::select('total_percentage')->sum('total_percentage');
- $pec_client_count = ClientRegistration::whereNotNull('total_percentage');
- $all_target_clients = ClientPerformance::whereNotNull('target_clients');
- $all_consented_clients = ClientRegistration::whereNotNull('consented');
+ $all_clients_number = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->whereNotNull('tbl_client.clinic_number');
+
+ // $pec_client_sum = Client::whereNotNull('id')->count();
+ // $pec_client = Client::where('status', '=', 'Active')->count();
+ $pec_client_count = round((Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')->where('tbl_client.status', '=', 'Active')->count() / Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')->whereNotNull('tbl_client.id')->count() * 100), 1);
+
+ $all_target_clients = PartnerFacility::select('avg_clients')->where('is_approved', '=', 'Yes');
+ $all_consented_clients = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.smsenable', '=', 'Yes');
$all_future_appointments = FutureApp::join('tbl_partner_facility', 'tbl_future_appointments_query.mfl_code', '=', 'tbl_partner_facility.mfl_code');
- $number_of_facilities = ClientPerformance::whereNotNull('mfl_code');
- $registered_clients_count = ClientRegistration::select('clients');
- $consented_clients_count = ClientRegistration::select('consented');
+ $number_of_facilities = PartnerFacility::select('mfl_code')->where('is_approved', '=', 'Yes');
+ $registered_clients_count = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->whereNotNull('tbl_client.clinic_number');
+ $consented_clients_count = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.smsenable', '=', 'Yes');
if (!empty($selected_partners)) {
- $all_clients_number = $all_clients_number->where('partner_id', $selected_partners);
- $pec_client_count = $pec_client_count->where('partner_id', $selected_partners);
+ $all_clients_number = $all_clients_number->where('tbl_partner_facility.partner_id', $selected_partners);
+ // $pec_client_count = $pec_client_count->where('tbl_partner_facility.partner_id', $selected_partners);
$all_target_clients = $all_target_clients->where('partner_id', $selected_partners);
- $all_consented_clients = $all_consented_clients->where('partner_id', $selected_partners);
+ $all_consented_clients = $all_consented_clients->where('tbl_partner_facility.partner_id', $selected_partners);
$number_of_facilities = $number_of_facilities->where('partner_id', $selected_partners);
- $registered_clients_count = $registered_clients_count->where('partner_id', $selected_partners);
- $consented_clients_count = $consented_clients_count->where('partner_id', $selected_partners);
+ $registered_clients_count = $registered_clients_count->where('tbl_partner_facility.partner_id', $selected_partners);
+ $consented_clients_count = $consented_clients_count->where('tbl_partner_facility.partner_id', $selected_partners);
$all_future_appointments = $all_future_appointments->where('tbl_partner_facility.partner_id', $selected_partners);
}
if (!empty($selected_counties)) {
- $all_clients_number = $all_clients_number->where('county_id', $selected_counties);
- $pec_client_count = $pec_client_count->where('county_id', $selected_counties);
+ $all_clients_number = $all_clients_number->where('tbl_partner_facility.county_id', $selected_counties);
+ // $pec_client_count = $pec_client_count->where('tbl_partner_facility.county_id', $selected_counties);
$all_target_clients = $all_target_clients->where('county_id', $selected_counties);
- $all_consented_clients = $all_consented_clients->where('county_id', $selected_counties);
+ $all_consented_clients = $all_consented_clients->where('tbl_partner_facility.county_id', $selected_counties);
$number_of_facilities = $number_of_facilities->where('county_id', $selected_counties);
- $registered_clients_count = $registered_clients_count->where('county_id', $selected_counties);
- $consented_clients_count = $consented_clients_count->where('county_id', $selected_counties);
+ $registered_clients_count = $registered_clients_count->where('tbl_partner_facility.county_id', $selected_counties);
+ $consented_clients_count = $consented_clients_count->where('tbl_partner_facility.county_id', $selected_counties);
$all_future_appointments = $all_future_appointments->where('tbl_partner_facility.county_id', $selected_counties);
}
if (!empty($selected_subcounties)) {
- $all_clients_number = $all_clients_number->where('sub_county_id', $selected_subcounties);
- $pec_client_count = $pec_client_count->where('sub_county_id', $selected_subcounties);
+ $all_clients_number = $all_clients_number->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ // $pec_client_count = $pec_client_count->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
$all_target_clients = $all_target_clients->where('sub_county_id', $selected_subcounties);
- $all_consented_clients = $all_consented_clients->where('sub_county_id', $selected_subcounties);
+ $all_consented_clients = $all_consented_clients->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
$number_of_facilities = $number_of_facilities->where('sub_county_id', $selected_subcounties);
- $registered_clients_count = $registered_clients_count->where('sub_county_id', $selected_subcounties);
- $consented_clients_count = $consented_clients_count->where('sub_county_id', $selected_subcounties);
+ $registered_clients_count = $registered_clients_count->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $consented_clients_count = $consented_clients_count->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
$all_future_appointments = $all_future_appointments->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
}
if (!empty($selected_facilites)) {
- $all_clients_number = $all_clients_number->where('mfl_code', $selected_facilites);
- $pec_client_count = $pec_client_count->where('mfl_code', $selected_facilites);
+ $all_clients_number = $all_clients_number->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ // $pec_client_count = $pec_client_count->where('tbl_partner_facility.mfl_code', $selected_facilites);
$all_target_clients = $all_target_clients->where('mfl_code', $selected_facilites);
- $all_consented_clients = $all_consented_clients->where('mfl_code', $selected_facilites);
+ $all_consented_clients = $all_consented_clients->where('tbl_partner_facility.mfl_code', $selected_facilites);
$number_of_facilities = $number_of_facilities->where('mfl_code', $selected_facilites);
- $registered_clients_count = $registered_clients_count->where('mfl_code', $selected_facilites);
- $consented_clients_count = $consented_clients_count->where('mfl_code', $selected_facilites);
+ $registered_clients_count = $registered_clients_count->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $consented_clients_count = $consented_clients_count->where('tbl_partner_facility.mfl_code', $selected_facilites);
$all_future_appointments = $all_future_appointments->where('tbl_partner_facility.mfl_code', $selected_facilites);
}
- $data["all_clients_number"] = $all_clients_number->sum('actual_clients');
- $data["pec_client_count"] = $pec_client_count->avg('total_percentage');
- $data["all_target_clients"] = $all_target_clients->sum('target_clients');
- $data["all_consented_clients"] = $all_consented_clients->sum('consented');
+ $data["all_clients_number"] = $all_clients_number->count();
+ $data["pec_client_count"] = $pec_client_count;
+ $data["all_target_clients"] = $all_target_clients->sum('avg_clients');
+ $data["all_consented_clients"] = $all_consented_clients->count();
$data["all_future_appointments"] = $all_future_appointments->count();
$data["number_of_facilities"] = $number_of_facilities->count();
- $data["registered_clients_count"] = $registered_clients_count->sum('clients');
- $data["consented_clients_count"] = $consented_clients_count->sum('consented');
+ $data["registered_clients_count"] = $registered_clients_count->count();
+ $data["consented_clients_count"] = $consented_clients_count->count();
return $data;
}
@@ -371,7 +374,23 @@ public function get_counties($id)
$counties = PartnerFacility::join('tbl_county', 'tbl_partner_facility.county_id', '=', 'tbl_county.id')
->where("tbl_partner_facility.partner_id", $id)
+ ->orderBy('tbl_county.name', 'ASC')
+ ->pluck("tbl_county.name", "tbl_county.id");
+
+ if (Auth::user()->access_level == 'County') {
+ $counties = PartnerFacility::join('tbl_county', 'tbl_partner_facility.county_id', '=', 'tbl_county.id')
+ ->where("tbl_partner_facility.partner_id", $id)
+ ->where("tbl_partner_facility.county_id", '=', Auth::user()->county_id)
+ ->orderBy('tbl_county.name', 'ASC')
+ ->pluck("tbl_county.name", "tbl_county.id");
+ }
+ if (Auth::user()->access_level == 'Sub County') {
+ $counties = PartnerFacility::join('tbl_county', 'tbl_partner_facility.county_id', '=', 'tbl_county.id')
+ ->where("tbl_partner_facility.partner_id", $id)
+ ->where("tbl_partner_facility.sub_county_id", '=', Auth::user()->subcounty_id)
+ ->orderBy('tbl_county.name', 'ASC')
->pluck("tbl_county.name", "tbl_county.id");
+ }
return json_encode($counties);
}
@@ -379,33 +398,77 @@ public function get_dashboard_sub_counties($id)
{
$subcounties = PartnerFacility::join('tbl_sub_county', 'tbl_partner_facility.sub_county_id', '=', 'tbl_sub_county.id')
->where("tbl_partner_facility.county_id", $id)
+ ->orderBy('tbl_sub_county.name', 'ASC')
->pluck("tbl_sub_county.name", "tbl_sub_county.id");
- if (Auth::user()->access_level == 'Partner'){
- $subcounties = PartnerFacility::join('tbl_sub_county', 'tbl_partner_facility.sub_county_id', '=', 'tbl_sub_county.id')
- ->where("tbl_partner_facility.county_id", $id)
- ->where("tbl_partner_facility.partner_id", '=', Auth::user()->partner_id)
- ->pluck("tbl_sub_county.name", "tbl_sub_county.id");
- }
+ if (Auth::user()->access_level == 'Partner') {
+ $subcounties = PartnerFacility::join('tbl_sub_county', 'tbl_partner_facility.sub_county_id', '=', 'tbl_sub_county.id')
+ ->where("tbl_partner_facility.county_id", $id)
+ ->where("tbl_partner_facility.partner_id", '=', Auth::user()->partner_id)
+ ->orderBy('tbl_sub_county.name', 'ASC')
+ ->pluck("tbl_sub_county.name", "tbl_sub_county.id");
+ }
+ if (Auth::user()->access_level == 'Sub County') {
+ $subcounties = PartnerFacility::join('tbl_sub_county', 'tbl_partner_facility.sub_county_id', '=', 'tbl_sub_county.id')
+ ->where("tbl_partner_facility.county_id", $id)
+ ->where("tbl_partner_facility.sub_county_id", '=', Auth::user()->subcounty_id)
+ ->orderBy('tbl_sub_county.name', 'ASC')
+ ->pluck("tbl_sub_county.name", "tbl_sub_county.id");
+ }
return json_encode($subcounties);
}
- public function get_dashboard_facilities($id)
+ public function get_dashboard_facilities(Request $request, $id)
{
+ $partner_ids = array();
+ $strings_array = $request->partners;
+ if (!empty($strings_array)) {
+ foreach ($strings_array as $each_id) {
+ $partner_ids[] = (int) $each_id;
+ }
+ }
+ $partners_with_ids = PartnerFacility::select('partner_id')->distinct('partner_id')->groupBy('partner_id')->get();
$facilities = PartnerFacility::join('tbl_master_facility', 'tbl_partner_facility.mfl_code', '=', 'tbl_master_facility.code')
->where("tbl_partner_facility.sub_county_id", $id)
- // ->where("tbl_partner_facility.partner_id", $id)
+ // ->where("tbl_partner_facility.partner_id", $id)
+ ->orderBy('tbl_master_facility.name', 'ASC')
->pluck("tbl_master_facility.name", "tbl_master_facility.code");
- if (Auth::user()->access_level == 'Partner'){
- $facilities = PartnerFacility::join('tbl_master_facility', 'tbl_partner_facility.mfl_code', '=', 'tbl_master_facility.code')
- ->where("tbl_partner_facility.sub_county_id", $id)
- ->where("tbl_partner_facility.partner_id", '=', Auth::user()->partner_id)
- ->pluck("tbl_master_facility.name", "tbl_master_facility.code");
- }
+ if (Auth::user()->access_level == 'Partner') {
+ $facilities = PartnerFacility::join('tbl_master_facility', 'tbl_partner_facility.mfl_code', '=', 'tbl_master_facility.code')
+ ->where("tbl_partner_facility.sub_county_id", $id)
+ ->where("tbl_partner_facility.partner_id", '=', Auth::user()->partner_id)
+ ->orderBy('tbl_master_facility.name', 'ASC')
+ ->pluck("tbl_master_facility.name", "tbl_master_facility.code");
+ }
+ if (Auth::user()->access_level == 'County') {
+ $facilities = PartnerFacility::join('tbl_master_facility', 'tbl_partner_facility.mfl_code', '=', 'tbl_master_facility.code')
+ ->where("tbl_partner_facility.sub_county_id", $id)
+ ->where("tbl_partner_facility.county_id", '=', Auth::user()->county_id)
+ ->orderBy('tbl_master_facility.name', 'ASC')
+ ->pluck("tbl_master_facility.name", "tbl_master_facility.code");
+ }
+ if (Auth::user()->access_level == 'Sub County') {
+ $facilities = PartnerFacility::join('tbl_master_facility', 'tbl_partner_facility.mfl_code', '=', 'tbl_master_facility.code')
+ ->where("tbl_partner_facility.sub_county_id", $id)
+ ->whereIn('tbl_partner_facility.partner_id', $partners_with_ids)
+ ->where("tbl_partner_facility.sub_county_id", '=', Auth::user()->subcounty_id)
+ ->orderBy('tbl_master_facility.name', 'ASC')
+ ->pluck("tbl_master_facility.name", "tbl_master_facility.code");
+ }
return json_encode($facilities);
}
+ public function get_wards($id)
+ {
+ $wards = Ward::join('tbl_master_facility', 'tbl_master_facility.Ward_id', '=', 'tbl_ward.id')
+ ->join('tbl_partner_facility', 'tbl_partner_facility.mfl_code', '=', 'tbl_master_facility.code')
+ ->where('tbl_partner_facility.sub_county_id', $id)
+ ->orderBy('tbl_ward.name', 'ASC')
+ ->pluck('tbl_ward.name', 'tbl_ward.id');
+
+ return json_encode($wards);
+ }
public function facility_dashboard()
@@ -643,331 +706,328 @@ public function client_dashboard()
if (Auth::user()->access_level == 'Admin') {
$all_partners = Partner::where('status', '=', 'Active')
- ->pluck('name', 'id');
- // registration by age group
- $consented_nine = 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')
- ->pluck('count');
+ ->pluck('name', 'id');
+ // registration by age group
+ $consented_nine = 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')
+ ->pluck('count');
- $consented_forteen = 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')
- ->pluck('count');
+ $consented_forteen = 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')
+ ->pluck('count');
- $consented_nineteen = 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')
- ->pluck('count');
+ $consented_nineteen = 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')
+ ->pluck('count');
- $consented_twenty_four = 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')
- ->pluck('count');
+ $consented_twenty_four = 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')
+ ->pluck('count');
- $consented_over_twenty_five = Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
- ->where('smsenable', '=', 'Yes')
- ->pluck('count');
+ $consented_over_twenty_five = Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '=', 'Yes')
+ ->pluck('count');
- $registered_nine = 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"))
- ->pluck('count');
+ $registered_nine = 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"))
+ ->pluck('count');
- $registered_forteen = 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"))
- ->pluck('count');
+ $registered_forteen = 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"))
+ ->pluck('count');
- $registered_nineteen = 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"))
- ->pluck('count');
+ $registered_nineteen = 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"))
+ ->pluck('count');
- $registered_twenty_four = 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"))
- ->pluck('count');
+ $registered_twenty_four = 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"))
+ ->pluck('count');
- $registered_over_twenty_five = Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
- ->pluck('count');
+ $registered_over_twenty_five = Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->pluck('count');
- //registration by marital status
- $single_consented = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '1')
- ->where('smsenable', '=', 'Yes')
- ->pluck('count');
- $monogamous_consented = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '2')
- ->where('smsenable', '=', 'Yes')
- ->pluck('count');
- $divorced_consented = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '3')
- ->where('smsenable', '=', 'Yes')
- ->pluck('count');
- $widowed_consented = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '4')
- ->where('smsenable', '=', 'Yes')
- ->pluck('count');
- $cohabating_consented = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '5')
- ->where('smsenable', '=', 'Yes')
- ->pluck('count');
- $unavailable_consented = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '6')
- ->where('smsenable', '=', 'Yes')
- ->pluck('count');
- $notapplicable_consented = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '7')
- ->where('smsenable', '=', 'Yes')
- ->pluck('count');
- $polygamous_consented = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '8')
- ->where('smsenable', '=', 'Yes')
- ->pluck('count');
-
- $single_registered = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '1')
- ->pluck('count');
- $monogamous_registered = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '2')
- ->pluck('count');
- $divorced_registered = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '3')
- ->pluck('count');
- $widowed_registered = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '4')
- ->pluck('count');
- $cohabating_registered = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '5')
- ->pluck('count');
- $unavailable_registered = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '6')
- ->pluck('count');
- $notapplicable_registered = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '7')
- ->pluck('count');
- $polygamous_registered = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '8')
- ->pluck('count');
+ //registration by marital status
+ $single_consented = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '1')
+ ->where('smsenable', '=', 'Yes')
+ ->pluck('count');
+ $monogamous_consented = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '2')
+ ->where('smsenable', '=', 'Yes')
+ ->pluck('count');
+ $divorced_consented = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '3')
+ ->where('smsenable', '=', 'Yes')
+ ->pluck('count');
+ $widowed_consented = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '4')
+ ->where('smsenable', '=', 'Yes')
+ ->pluck('count');
+ $cohabating_consented = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '5')
+ ->where('smsenable', '=', 'Yes')
+ ->pluck('count');
+ $unavailable_consented = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '6')
+ ->where('smsenable', '=', 'Yes')
+ ->pluck('count');
+ $notapplicable_consented = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '7')
+ ->where('smsenable', '=', 'Yes')
+ ->pluck('count');
+ $polygamous_consented = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '8')
+ ->where('smsenable', '=', 'Yes')
+ ->pluck('count');
+ $single_registered = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '1')
+ ->pluck('count');
+ $monogamous_registered = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '2')
+ ->pluck('count');
+ $divorced_registered = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '3')
+ ->pluck('count');
+ $widowed_registered = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '4')
+ ->pluck('count');
+ $cohabating_registered = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '5')
+ ->pluck('count');
+ $unavailable_registered = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '6')
+ ->pluck('count');
+ $notapplicable_registered = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '7')
+ ->pluck('count');
+ $polygamous_registered = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '8')
+ ->pluck('count');
}
if (Auth::user()->access_level == 'Donor') {
$all_partners = Partner::where('status', '=', 'Active')
- ->pluck('name', 'id');
- // registration by age group
- $consented_nine = 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')
- ->pluck('count');
+ ->pluck('name', 'id');
+ // registration by age group
+ $consented_nine = 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')
+ ->pluck('count');
- $consented_forteen = 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')
- ->pluck('count');
+ $consented_forteen = 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')
+ ->pluck('count');
- $consented_nineteen = 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')
- ->pluck('count');
+ $consented_nineteen = 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')
+ ->pluck('count');
- $consented_twenty_four = 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')
- ->pluck('count');
+ $consented_twenty_four = 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')
+ ->pluck('count');
- $consented_over_twenty_five = Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
- ->where('smsenable', '=', 'Yes')
- ->pluck('count');
+ $consented_over_twenty_five = Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('smsenable', '=', 'Yes')
+ ->pluck('count');
- $registered_nine = 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"))
- ->pluck('count');
+ $registered_nine = 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"))
+ ->pluck('count');
- $registered_forteen = 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"))
- ->pluck('count');
+ $registered_forteen = 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"))
+ ->pluck('count');
- $registered_nineteen = 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"))
- ->pluck('count');
+ $registered_nineteen = 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"))
+ ->pluck('count');
- $registered_twenty_four = 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"))
- ->pluck('count');
+ $registered_twenty_four = 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"))
+ ->pluck('count');
- $registered_over_twenty_five = Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
- ->pluck('count');
+ $registered_over_twenty_five = Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->pluck('count');
- //registration by marital status
- $single_consented = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '1')
- ->where('smsenable', '=', 'Yes')
- ->pluck('count');
- $monogamous_consented = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '2')
- ->where('smsenable', '=', 'Yes')
- ->pluck('count');
- $divorced_consented = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '3')
- ->where('smsenable', '=', 'Yes')
- ->pluck('count');
- $widowed_consented = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '4')
- ->where('smsenable', '=', 'Yes')
- ->pluck('count');
- $cohabating_consented = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '5')
- ->where('smsenable', '=', 'Yes')
- ->pluck('count');
- $unavailable_consented = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '6')
- ->where('smsenable', '=', 'Yes')
- ->pluck('count');
- $notapplicable_consented = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '7')
- ->where('smsenable', '=', 'Yes')
- ->pluck('count');
- $polygamous_consented = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '8')
- ->where('smsenable', '=', 'Yes')
- ->pluck('count');
-
- $single_registered = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '1')
- ->pluck('count');
- $monogamous_registered = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '2')
- ->pluck('count');
- $divorced_registered = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '3')
- ->pluck('count');
- $widowed_registered = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '4')
- ->pluck('count');
- $cohabating_registered = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '5')
- ->pluck('count');
- $unavailable_registered = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '6')
- ->pluck('count');
- $notapplicable_registered = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '7')
- ->pluck('count');
- $polygamous_registered = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '8')
- ->pluck('count');
+ //registration by marital status
+ $single_consented = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '1')
+ ->where('smsenable', '=', 'Yes')
+ ->pluck('count');
+ $monogamous_consented = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '2')
+ ->where('smsenable', '=', 'Yes')
+ ->pluck('count');
+ $divorced_consented = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '3')
+ ->where('smsenable', '=', 'Yes')
+ ->pluck('count');
+ $widowed_consented = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '4')
+ ->where('smsenable', '=', 'Yes')
+ ->pluck('count');
+ $cohabating_consented = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '5')
+ ->where('smsenable', '=', 'Yes')
+ ->pluck('count');
+ $unavailable_consented = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '6')
+ ->where('smsenable', '=', 'Yes')
+ ->pluck('count');
+ $notapplicable_consented = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '7')
+ ->where('smsenable', '=', 'Yes')
+ ->pluck('count');
+ $polygamous_consented = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '8')
+ ->where('smsenable', '=', 'Yes')
+ ->pluck('count');
+ $single_registered = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '1')
+ ->pluck('count');
+ $monogamous_registered = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '2')
+ ->pluck('count');
+ $divorced_registered = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '3')
+ ->pluck('count');
+ $widowed_registered = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '4')
+ ->pluck('count');
+ $cohabating_registered = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '5')
+ ->pluck('count');
+ $unavailable_registered = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '6')
+ ->pluck('count');
+ $notapplicable_registered = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '7')
+ ->pluck('count');
+ $polygamous_registered = Client::select(\DB::raw("COUNT(marital) as count"))
+ ->where('marital', '=', '8')
+ ->pluck('count');
}
if (Auth::user()->access_level == 'Partner') {
$all_partners = Partner::where('status', '=', 'Active')
- ->where('id', Auth::user()->partner_id)
- ->pluck('name', 'id');
+ ->where('id', Auth::user()->partner_id)
+ ->pluck('name', 'id');
// registration by age group
$consented_nine = 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('partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ ->where('smsenable', '=', 'Yes')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->pluck('count');
$consented_forteen = 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('partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ ->where('smsenable', '=', 'Yes')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->pluck('count');
$consented_nineteen = 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('partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ ->where('smsenable', '=', 'Yes')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->pluck('count');
$consented_twenty_four = 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('partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ ->where('smsenable', '=', 'Yes')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->pluck('count');
$consented_over_twenty_five = 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('partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ ->where('smsenable', '=', 'Yes')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->pluck('count');
$registered_nine = 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('partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ ->where('partner_id', Auth::user()->partner_id)
+ ->pluck('count');
$registered_forteen = 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('partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ ->where('partner_id', Auth::user()->partner_id)
+ ->pluck('count');
$registered_nineteen = 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('partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ ->where('partner_id', Auth::user()->partner_id)
+ ->pluck('count');
$registered_twenty_four = 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('partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ ->where('partner_id', Auth::user()->partner_id)
+ ->pluck('count');
$registered_over_twenty_five = Client::select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end)) AS count"))
- ->where('partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ ->where('partner_id', Auth::user()->partner_id)
+ ->pluck('count');
//registration by marital status
$single_consented = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '1')
- ->where('smsenable', '=', 'Yes')
- ->where('partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ ->where('marital', '=', '1')
+ ->where('smsenable', '=', 'Yes')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->pluck('count');
$monogamous_consented = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '2')
- ->where('smsenable', '=', 'Yes')
- ->where('partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ ->where('marital', '=', '2')
+ ->where('smsenable', '=', 'Yes')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->pluck('count');
$divorced_consented = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '3')
- ->where('smsenable', '=', 'Yes')
- ->where('partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ ->where('marital', '=', '3')
+ ->where('smsenable', '=', 'Yes')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->pluck('count');
$widowed_consented = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '4')
- ->where('smsenable', '=', 'Yes')
- ->where('partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ ->where('marital', '=', '4')
+ ->where('smsenable', '=', 'Yes')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->pluck('count');
$cohabating_consented = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '5')
- ->where('smsenable', '=', 'Yes')
- ->where('partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ ->where('marital', '=', '5')
+ ->where('smsenable', '=', 'Yes')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->pluck('count');
$unavailable_consented = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '6')
- ->where('smsenable', '=', 'Yes')
- ->where('partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ ->where('marital', '=', '6')
+ ->where('smsenable', '=', 'Yes')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->pluck('count');
$notapplicable_consented = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '7')
- ->where('smsenable', '=', 'Yes')
- ->where('partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ ->where('marital', '=', '7')
+ ->where('smsenable', '=', 'Yes')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->pluck('count');
$polygamous_consented = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '8')
- ->where('smsenable', '=', 'Yes')
- ->where('partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ ->where('marital', '=', '8')
+ ->where('smsenable', '=', 'Yes')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->pluck('count');
$single_registered = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '1')
- ->where('partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ ->where('marital', '=', '1')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->pluck('count');
$monogamous_registered = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '2')
- ->where('partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ ->where('marital', '=', '2')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->pluck('count');
$divorced_registered = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '3')
- ->where('partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ ->where('marital', '=', '3')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->pluck('count');
$widowed_registered = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '4')
- ->where('partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ ->where('marital', '=', '4')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->pluck('count');
$cohabating_registered = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '5')
- ->where('partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ ->where('marital', '=', '5')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->pluck('count');
$unavailable_registered = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '6')
- ->where('partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ ->where('marital', '=', '6')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->pluck('count');
$notapplicable_registered = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '7')
- ->where('partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ ->where('marital', '=', '7')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->pluck('count');
$polygamous_registered = Client::select(\DB::raw("COUNT(marital) as count"))
- ->where('marital', '=', '8')
- ->where('partner_id', Auth::user()->partner_id)
- ->pluck('count');
-
- }
+ ->where('marital', '=', '8')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->pluck('count');
+ }
return view('dashboard.clients_dashboard', compact(
@@ -1010,98 +1070,98 @@ public function filter_client_dashboard(Request $request)
// registration by age group
$consented_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"))
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.smsenable', '=', 'Yes');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.smsenable', '=', 'Yes');
$consented_forteen = 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"))
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.smsenable', '=', 'Yes');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.smsenable', '=', 'Yes');
$consented_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"))
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.smsenable', '=', 'Yes');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.smsenable', '=', 'Yes');
$consented_twenty_four = 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"))
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.smsenable', '=', 'Yes');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.smsenable', '=', 'Yes');
$consented_over_twenty_five = Client::select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end"))
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.smsenable', '=', 'Yes');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.smsenable', '=', 'Yes');
$registered_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"))
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code');
$registered_forteen = 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"))
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code');
$registered_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"))
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code');
$registered_twenty_four = 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"))
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code');
$registered_over_twenty_five = Client::select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end"))
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code');
//registration by marital status
$single_consented = Client::select(\DB::raw("tbl_client.marital"))
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.marital', '=', '1')
- ->where('tbl_client.smsenable', '=', 'Yes');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.marital', '=', '1')
+ ->where('tbl_client.smsenable', '=', 'Yes');
$monogamous_consented = Client::select(\DB::raw("tbl_client.marital"))
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.marital', '=', '2')
- ->where('tbl_client.smsenable', '=', 'Yes');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.marital', '=', '2')
+ ->where('tbl_client.smsenable', '=', 'Yes');
$divorced_consented = Client::select(\DB::raw("tbl_client.marital"))
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.marital', '=', '3')
- ->where('smsenable', '=', 'Yes');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.marital', '=', '3')
+ ->where('smsenable', '=', 'Yes');
$widowed_consented = Client::select(\DB::raw("tbl_client.marital"))
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.marital', '=', '4')
- ->where('tbl_client.smsenable', '=', 'Yes');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.marital', '=', '4')
+ ->where('tbl_client.smsenable', '=', 'Yes');
$cohabating_consented = Client::select(\DB::raw("tbl_client.marital"))
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('marital', '=', '5')
- ->where('tbl_client.smsenable', '=', 'Yes');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('marital', '=', '5')
+ ->where('tbl_client.smsenable', '=', 'Yes');
$unavailable_consented = Client::select(\DB::raw("tbl_client.marital"))
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.marital', '=', '6')
- ->where('tbl_client.smsenable', '=', 'Yes');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.marital', '=', '6')
+ ->where('tbl_client.smsenable', '=', 'Yes');
$notapplicable_consented = Client::select(\DB::raw("tbl_client.marital"))
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.marital', '=', '7')
- ->where('tbl_client.smsenable', '=', 'Yes');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.marital', '=', '7')
+ ->where('tbl_client.smsenable', '=', 'Yes');
$polygamous_consented = Client::select(\DB::raw("tbl_client.marital"))
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.marital', '=', '8')
- ->where('tbl_client.smsenable', '=', 'Yes');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.marital', '=', '8')
+ ->where('tbl_client.smsenable', '=', 'Yes');
$single_registered = Client::select(\DB::raw("tbl_client.marital"))
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.marital', '=', '1');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.marital', '=', '1');
$monogamous_registered = Client::select(\DB::raw("tbl_client.marital"))
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.marital', '=', '2');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.marital', '=', '2');
$divorced_registered = Client::select(\DB::raw("tbl_client.marital"))
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('marital', '=', '3');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('marital', '=', '3');
$widowed_registered = Client::select(\DB::raw("tbl_client.marital"))
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.marital', '=', '4');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.marital', '=', '4');
$cohabating_registered = Client::select(\DB::raw("tbl_client.marital"))
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.marital', '=', '5');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.marital', '=', '5');
$unavailable_registered = Client::select(\DB::raw("tbl_client.marital"))
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.marital', '=', '6');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.marital', '=', '6');
$notapplicable_registered = Client::select(\DB::raw("tbl_client.marital"))
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.marital', '=', '7');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.marital', '=', '7');
$polygamous_registered = Client::select(\DB::raw("tbl_client.marital"))
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->where('tbl_client.marital', '=', '8');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_client.marital', '=', '8');
if (!empty($selected_partners)) {
$consented_nine = $consented_nine->where('tbl_partner_facility.partner_id', $selected_partners);
@@ -1247,6 +1307,5 @@ public function filter_client_dashboard(Request $request)
$data["polygamous_registered"] = $polygamous_registered->count();
return $data;
-
}
}
diff --git a/app/Http/Controllers/DcmReportController.php b/app/Http/Controllers/DcmReportController.php
index 4df8549..7d5656e 100644
--- a/app/Http/Controllers/DcmReportController.php
+++ b/app/Http/Controllers/DcmReportController.php
@@ -15,89 +15,80 @@
class DcmReportController extends Controller
{
//
-public function dcm_report()
-{
-
- if (Auth::user()->access_level == 'Facility') {
- $all_clients_duration_less_well = DcmUnstable::join('tbl_client', 'tbl_client.id', '=', 'tbl_dfc_module.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_dfc_module.duration_less, tbl_appointment.appntmnt_date')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->where('duration_less', '=', 'Well')->get();
-
- $all_clients_duration_less_advanced = DcmUnstable::join('tbl_client', 'tbl_client.id', '=', 'tbl_dfc_module.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_dfc_module.duration_less, tbl_appointment.appntmnt_date')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->where('duration_less', '=', 'Advanced')->get();
-
- $all_clients_duration_more_stable = Dcm::select('*')
- ->where('duration_more', '=', 'Stable')->get()
- ->where('mfl_code', Auth::user()->facility_id);
-
-
-
- $all_clients_duration_more_unstable = DcmUnstable::join('tbl_client', 'tbl_client.id', '=', 'tbl_dfc_module.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_dfc_module.duration_more, tbl_appointment.appntmnt_date')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->where('tbl_dfc_module.duration_more', '=', 'Unstable')
- ->where('tbl_appointment.active_app', '=', 1)->get();
-
- }
-
- if (Auth::user()->access_level == 'Partner') {
- $all_clients_duration_less_well = DcmUnstable::join('tbl_client', 'tbl_client.id', '=', 'tbl_dfc_module.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_dfc_module.duration_less, tbl_appointment.appntmnt_date')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->where('duration_less', '=', 'Well')->get();
-
- $all_clients_duration_less_advanced = DcmUnstable::join('tbl_client', 'tbl_client.id', '=', 'tbl_dfc_module.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_dfc_module.duration_less, tbl_appointment.appntmnt_date')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->where('duration_less', '=', 'Advanced')->get();
-
- $all_clients_duration_more_stable = Dcm::select('*')
- ->where('duration_more', '=', 'Stable')->get()
- ->where('tbl_client.partner_id', Auth::user()->partner_id);
-
-
-
- $all_clients_duration_more_unstable = DcmUnstable::join('tbl_client', 'tbl_client.id', '=', 'tbl_dfc_module.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_dfc_module.duration_more, tbl_appointment.appntmnt_date')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->where('tbl_dfc_module.duration_more', '=', 'Unstable')
- ->where('tbl_appointment.active_app', '=', 1)->get();
-
- }
-
- if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
- $all_clients_duration_less_well = DcmUnstable::join('tbl_client', 'tbl_client.id', '=', 'tbl_dfc_module.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_dfc_module.duration_less, tbl_appointment.appntmnt_date')
- ->where('duration_less', '=', 'Well')->get();
-
- $all_clients_duration_less_advanced = DcmUnstable::join('tbl_client', 'tbl_client.id', '=', 'tbl_dfc_module.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_dfc_module.duration_less, tbl_appointment.appntmnt_date')
- ->where('duration_less', '=', 'Advanced')->get();
-
- $all_clients_duration_more_stable = Dcm::select('*')
- ->where('duration_more', '=', 'Stable')->get();
-
-
-
- $all_clients_duration_more_unstable = DcmUnstable::join('tbl_client', 'tbl_client.id', '=', 'tbl_dfc_module.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_dfc_module.duration_more, tbl_appointment.appntmnt_date')
- ->where('tbl_dfc_module.duration_more', '=', 'Unstable')
- ->where('tbl_appointment.active_app', '=', 1)->get();
-
- }
-
- return view('reports.dcm_reports', compact('all_clients_duration_less_well', 'all_clients_duration_less_advanced', 'all_clients_duration_more_stable', 'all_clients_duration_more_unstable'));
+ // public function dcm_report()
+ // {
+
+ // if (Auth::user()->access_level == 'Facility') {
+ // $all_clients_duration_less_well = DcmUnstable::join('tbl_client', 'tbl_client.id', '=', 'tbl_dfc_module.client_id')
+ // ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ // ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_dfc_module.duration_less, tbl_appointment.appntmnt_date')
+ // ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ // ->where('duration_less', '=', 'Well')->paginate(1000);
+
+ // $all_clients_duration_less_advanced = DcmUnstable::join('tbl_client', 'tbl_client.id', '=', 'tbl_dfc_module.client_id')
+ // ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ // ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_dfc_module.duration_less, tbl_appointment.appntmnt_date')
+ // ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ // ->where('duration_less', '=', 'Advanced')->paginate(1000);
+
+ // $all_clients_duration_more_stable = Dcm::select('*')
+ // ->where('duration_more', '=', 'Stable')
+ // ->where('mfl_code', Auth::user()->facility_id)->paginate(1000);
+
+
+
+ // $all_clients_duration_more_unstable = DcmUnstable::join('tbl_client', 'tbl_client.id', '=', 'tbl_dfc_module.client_id')
+ // ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ // ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_dfc_module.duration_more, tbl_appointment.appntmnt_date')
+ // ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ // ->where('tbl_dfc_module.duration_more', '=', 'Unstable')->paginate(1000);
+ // }
+
+ // if (Auth::user()->access_level == 'Partner') {
+ // $all_clients_duration_less_well = DcmUnstable::join('tbl_client', 'tbl_client.id', '=', 'tbl_dfc_module.client_id')
+ // ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ // ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ // ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_dfc_module.duration_less, tbl_appointment.appntmnt_date')
+ // ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ // ->where('duration_less', '=', 'Well')->paginate(1000);
+
+ // $all_clients_duration_less_advanced = DcmUnstable::join('tbl_client', 'tbl_client.id', '=', 'tbl_dfc_module.client_id')
+ // ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ // ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ // ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_dfc_module.duration_less, tbl_appointment.appntmnt_date')
+ // ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ // ->where('duration_less', '=', 'Advanced')->paginate(1000);
+
+ // $all_clients_duration_more_stable = Dcm::select('*')
+ // ->where('duration_more', '=', 'Stable')
+ // ->where('partner_id', Auth::user()->partner_id)->paginate(1000);
+
+ // $all_clients_duration_more_unstable = DcmUnstable::join('tbl_client', 'tbl_client.id', '=', 'tbl_dfc_module.client_id')
+ // ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ // ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ // ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_dfc_module.duration_more, tbl_appointment.appntmnt_date')
+ // ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ // ->where('tbl_dfc_module.duration_more', '=', 'Unstable')->paginate(1000);
+ // }
+
+ // if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+ // $all_clients_duration_less_well = DcmUnstable::join('tbl_client', 'tbl_client.id', '=', 'tbl_dfc_module.client_id')
+ // ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ // ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_dfc_module.duration_less, tbl_appointment.appntmnt_date')
+ // ->where('duration_less', '=', 'Well')->paginate(1000);
+
+ // $all_clients_duration_less_advanced = DcmUnstable::join('tbl_client', 'tbl_client.id', '=', 'tbl_dfc_module.client_id')
+ // ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ // ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_dfc_module.duration_less, tbl_appointment.appntmnt_date')
+ // ->where('duration_less', '=', 'Advanced')->paginate(1000);
+
+ // $all_clients_duration_more_stable = Dcm::select('*')
+ // ->where('duration_more', '=', 'Stable')->paginate(1000);
+
+ // $all_clients_duration_more_unstable = Dcm::select('*')
+ // ->where('duration_more', '=', 'Unstable')->paginate(1000);
+ // }
+
+ // return view('reports.dcm_reports', compact('all_clients_duration_less_well', 'all_clients_duration_less_advanced', 'all_clients_duration_more_stable', 'all_clients_duration_more_unstable'));
+ // }
}
-}
\ No newline at end of file
diff --git a/app/Http/Controllers/FacilityController.php b/app/Http/Controllers/FacilityController.php
index 8c031dc..4ab56d0 100644
--- a/app/Http/Controllers/FacilityController.php
+++ b/app/Http/Controllers/FacilityController.php
@@ -72,32 +72,32 @@ public function add_facility(Request $request)
public function my_facility()
{
if (Auth::user()->access_level == 'Admin') {
- $facilities = Facility::join('tbl_county', 'tbl_master_facility.county_id', '=', 'tbl_county.id')
- ->join('tbl_sub_county', 'tbl_master_facility.Sub_County_ID', '=', 'tbl_sub_county.id')
- // ->join('tbl_partner', 'tbl_partner_facility.partner_id', '=', 'tbl_partner.id')
- ->join('tbl_partner_facility', 'tbl_master_facility.code', '=', 'tbl_partner_facility.mfl_code')
- ->join('tbl_consituency', 'tbl_master_facility.consituency_id', '=', 'tbl_consituency.id')
- ->select(
- 'tbl_master_facility.name as facility_name',
- 'tbl_partner_facility.avg_clients as average_clients',
- 'tbl_master_facility.code',
- 'tbl_master_facility.owner',
- 'tbl_county.name as county_name',
- 'tbl_sub_county.name as sub_county_name',
- 'tbl_consituency.name as consituency_name',
- 'tbl_master_facility.facility_type',
- 'tbl_master_facility.keph_level as level',
- 'tbl_partner_facility.is_approved',
- 'tbl_partner_facility.id',
- 'tbl_partner_facility.partner_id'
- //'tbl_partner.name as partner_name'
- )
- ->get();
+ $facilities = Facility::join('tbl_county', 'tbl_master_facility.county_id', '=', 'tbl_county.id')
+ ->join('tbl_sub_county', 'tbl_master_facility.Sub_County_ID', '=', 'tbl_sub_county.id')
+ // ->join('tbl_partner', 'tbl_partner_facility.partner_id', '=', 'tbl_partner.id')
+ ->join('tbl_partner_facility', 'tbl_master_facility.code', '=', 'tbl_partner_facility.mfl_code')
+ ->join('tbl_consituency', 'tbl_master_facility.consituency_id', '=', 'tbl_consituency.id')
+ ->select(
+ 'tbl_master_facility.name as facility_name',
+ 'tbl_partner_facility.avg_clients as average_clients',
+ 'tbl_master_facility.code',
+ 'tbl_master_facility.owner',
+ 'tbl_county.name as county_name',
+ 'tbl_sub_county.name as sub_county_name',
+ 'tbl_consituency.name as consituency_name',
+ 'tbl_master_facility.facility_type',
+ 'tbl_master_facility.keph_level as level',
+ 'tbl_partner_facility.is_approved',
+ 'tbl_partner_facility.id',
+ 'tbl_partner_facility.partner_id'
+ //'tbl_partner.name as partner_name'
+ )
+ ->get();
}
if (Auth::user()->access_level == 'Donor') {
$facilities = Facility::join('tbl_county', 'tbl_master_facility.county_id', '=', 'tbl_county.id')
->join('tbl_sub_county', 'tbl_master_facility.Sub_County_ID', '=', 'tbl_sub_county.id')
- // ->join('tbl_partner', 'tbl_partner_facility.partner_id', '=', 'tbl_partner.id')
+ // ->join('tbl_partner', 'tbl_partner_facility.partner_id', '=', 'tbl_partner.id')
->join('tbl_partner_facility', 'tbl_master_facility.code', '=', 'tbl_partner_facility.mfl_code')
->join('tbl_consituency', 'tbl_master_facility.consituency_id', '=', 'tbl_consituency.id')
->select(
@@ -115,11 +115,11 @@ public function my_facility()
//'tbl_partner.name as partner_name'
)
->get();
- }
+ }
if (Auth::user()->access_level == 'Facility') {
$facilities = Facility::join('tbl_county', 'tbl_master_facility.county_id', '=', 'tbl_county.id')
->join('tbl_sub_county', 'tbl_master_facility.Sub_County_ID', '=', 'tbl_sub_county.id')
- // ->join('tbl_partner', 'tbl_partner_facility.partner_id', '=', 'tbl_partner.id')
+ // ->join('tbl_partner', 'tbl_partner_facility.partner_id', '=', 'tbl_partner.id')
->join('tbl_partner_facility', 'tbl_master_facility.code', '=', 'tbl_partner_facility.mfl_code')
->join('tbl_consituency', 'tbl_master_facility.consituency_id', '=', 'tbl_consituency.id')
->select(
@@ -134,38 +134,90 @@ public function my_facility()
'tbl_master_facility.keph_level as level',
'tbl_partner_facility.is_approved',
'tbl_partner_facility.id'
- // 'tbl_partner.name as partner_name'
+ // 'tbl_partner.name as partner_name'
)
->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)
->get();
- }
- if (Auth::user()->access_level == 'Partner') {
- $all_partners = Partner::all()->where('status', '=', 'Active')
+ }
+ if (Auth::user()->access_level == 'Partner') {
+ $all_partners = Partner::all()->where('status', '=', 'Active')
->where('id', Auth::user()->partner_id);
- $facilities = Facility::join('tbl_county', 'tbl_master_facility.county_id', '=', 'tbl_county.id')
- ->join('tbl_sub_county', 'tbl_master_facility.Sub_County_ID', '=', 'tbl_sub_county.id')
- // ->join('tbl_partner', 'tbl_partner_facility.partner_id', '=', 'tbl_partner.id')
- ->join('tbl_partner_facility', 'tbl_master_facility.code', '=', 'tbl_partner_facility.mfl_code')
- ->join('tbl_consituency', 'tbl_master_facility.consituency_id', '=', 'tbl_consituency.id')
- ->select(
- 'tbl_master_facility.name as facility_name',
- 'tbl_master_facility.code',
- 'tbl_master_facility.owner',
- 'tbl_county.name as county_name',
- 'tbl_partner_facility.avg_clients as average_clients',
- 'tbl_sub_county.name as sub_county_name',
- 'tbl_consituency.name as consituency_name',
- 'tbl_master_facility.facility_type',
- 'tbl_master_facility.keph_level as level',
- 'tbl_partner_facility.is_approved',
- 'tbl_partner_facility.id'
- // 'tbl_partner.name as partner_name'
- )
- ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
- ->get();
- }
- $all_partners = Partner::all()->where('status', '=', 'Active');
+ $facilities = Facility::join('tbl_county', 'tbl_master_facility.county_id', '=', 'tbl_county.id')
+ ->join('tbl_sub_county', 'tbl_master_facility.Sub_County_ID', '=', 'tbl_sub_county.id')
+ // ->join('tbl_partner', 'tbl_partner_facility.partner_id', '=', 'tbl_partner.id')
+ ->join('tbl_partner_facility', 'tbl_master_facility.code', '=', 'tbl_partner_facility.mfl_code')
+ ->join('tbl_consituency', 'tbl_master_facility.consituency_id', '=', 'tbl_consituency.id')
+ ->select(
+ 'tbl_master_facility.name as facility_name',
+ 'tbl_master_facility.code',
+ 'tbl_master_facility.owner',
+ 'tbl_county.name as county_name',
+ 'tbl_partner_facility.avg_clients as average_clients',
+ 'tbl_sub_county.name as sub_county_name',
+ 'tbl_consituency.name as consituency_name',
+ 'tbl_master_facility.facility_type',
+ 'tbl_master_facility.keph_level as level',
+ 'tbl_partner_facility.is_approved',
+ 'tbl_partner_facility.id'
+ // 'tbl_partner.name as partner_name'
+ )
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->get();
+ }
+ if (Auth::user()->access_level == 'Sub County') {
+ $all_partners = Partner::all()->where('status', '=', 'Active')
+ ->where('id', Auth::user()->partner_id);
+
+ $facilities = Facility::join('tbl_county', 'tbl_master_facility.county_id', '=', 'tbl_county.id')
+ ->join('tbl_sub_county', 'tbl_master_facility.Sub_County_ID', '=', 'tbl_sub_county.id')
+ // ->join('tbl_partner', 'tbl_partner_facility.partner_id', '=', 'tbl_partner.id')
+ ->join('tbl_partner_facility', 'tbl_master_facility.code', '=', 'tbl_partner_facility.mfl_code')
+ ->join('tbl_consituency', 'tbl_master_facility.consituency_id', '=', 'tbl_consituency.id')
+ ->select(
+ 'tbl_master_facility.name as facility_name',
+ 'tbl_master_facility.code',
+ 'tbl_master_facility.owner',
+ 'tbl_county.name as county_name',
+ 'tbl_partner_facility.avg_clients as average_clients',
+ 'tbl_sub_county.name as sub_county_name',
+ 'tbl_consituency.name as consituency_name',
+ 'tbl_master_facility.facility_type',
+ 'tbl_master_facility.keph_level as level',
+ 'tbl_partner_facility.is_approved',
+ 'tbl_partner_facility.id'
+ // 'tbl_partner.name as partner_name'
+ )
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->get();
+ }
+ if (Auth::user()->access_level == 'County') {
+ $all_partners = Partner::all()->where('status', '=', 'Active')
+ ->where('id', Auth::user()->partner_id);
+
+ $facilities = Facility::join('tbl_county', 'tbl_master_facility.county_id', '=', 'tbl_county.id')
+ ->join('tbl_sub_county', 'tbl_master_facility.Sub_County_ID', '=', 'tbl_sub_county.id')
+ // ->join('tbl_partner', 'tbl_partner_facility.partner_id', '=', 'tbl_partner.id')
+ ->join('tbl_partner_facility', 'tbl_master_facility.code', '=', 'tbl_partner_facility.mfl_code')
+ ->join('tbl_consituency', 'tbl_master_facility.consituency_id', '=', 'tbl_consituency.id')
+ ->select(
+ 'tbl_master_facility.name as facility_name',
+ 'tbl_master_facility.code',
+ 'tbl_master_facility.owner',
+ 'tbl_county.name as county_name',
+ 'tbl_partner_facility.avg_clients as average_clients',
+ 'tbl_sub_county.name as sub_county_name',
+ 'tbl_consituency.name as consituency_name',
+ 'tbl_master_facility.facility_type',
+ 'tbl_master_facility.keph_level as level',
+ 'tbl_partner_facility.is_approved',
+ 'tbl_partner_facility.id'
+ // 'tbl_partner.name as partner_name'
+ )
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->get();
+ }
+ $all_partners = Partner::all()->where('status', '=', 'Active');
return view('facilities.my_facilities', compact('facilities', 'all_partners'));
}
public function approve_facility(Request $request)
@@ -194,22 +246,22 @@ public function approve_facility(Request $request)
public function edit_facility(Request $request)
{
try {
- $facility = PartnerFacility::where('id', $request->id)
- ->update([
- 'avg_clients' =>$request->average_clients,
- 'partner_id' =>$request->partnername,
- ]);
- if ($facility) {
- Session::flash('statuscode', 'success');
-
- return redirect('admin/my_facilities')->with('status', 'Facility updated successfully!');
- } else {
-
- Session::flash('statuscode', 'error');
- return back()->with('error', 'An error has occurred please try again later.');
+ $facility = PartnerFacility::where('id', $request->id)
+ ->update([
+ 'avg_clients' => $request->average_clients,
+ 'partner_id' => $request->partnername,
+ ]);
+ if ($facility) {
+ Session::flash('statuscode', 'success');
+
+ return redirect('admin/my_facilities')->with('status', 'Facility updated successfully!');
+ } else {
+
+ Session::flash('statuscode', 'error');
+ return back()->with('error', 'An error has occurred please try again later.');
+ }
+ } catch (Exception $e) {
+ return back();
}
- } catch (Exception $e) {
- return back();
- }
}
}
diff --git a/app/Http/Controllers/FinalDashboardController.php b/app/Http/Controllers/FinalDashboardController.php
new file mode 100644
index 0000000..e22ac61
--- /dev/null
+++ b/app/Http/Controllers/FinalDashboardController.php
@@ -0,0 +1,3535 @@
+remember_period = env('REMEMBER_PERIOD', '60 * 60');
+ }
+
+ public function index()
+ {
+ // dd(Auth::user()->access_level);
+
+ $indicator_k = Indicator::where('name', 'Kept&Not Kept')
+ ->select('description')
+ ->remember($this->remember_period)
+ ->get();
+
+ $indicator_m = Indicator::where('name', 'Missed Appointments')
+ ->select('description')
+ ->remember($this->remember_period)
+ ->get();
+
+ $clinics = Clinic::select('id', 'name')
+ ->where('status', '=', 'Active')
+ ->remember($this->remember_period)
+ ->get();
+
+ if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+ $partners = Partner::where("status", "=", "Active")
+ ->remember($this->remember_period)
+ ->get();
+
+ $counties = County::where("status", "=", "Active")
+ ->remember($this->remember_period)
+ ->get(['id', 'name']);
+
+ $sub_counties = SubCounty::where("status", "=", "Active")
+ ->remember($this->remember_period)
+ ->get(['id', 'name']);
+
+ $facilities = Facility::join('tbl_partner_facility', 'tbl_master_facility.code', '=', 'tbl_partner_facility.mfl_code')
+ ->remember($this->remember_period)
+ ->get(['tbl_master_facility.code', 'tbl_master_facility.name']);
+
+ return view('dashboard.appointment', compact('partners', 'counties', 'sub_counties', 'facilities', 'clinics', 'indicator_k', 'indicator_m'));
+ }
+ if (Auth::user()->access_level == 'Facility') {
+
+ $client_list = ETLClient::join('etl_appointment_detail', 'etl_client_detail.client_id', '=', 'etl_appointment_detail.client_id')
+ ->where('etl_client_detail.mfl_code', Auth::user()->facility_id)
+ ->groupBy('etl_appointment_detail.client_id')
+ ->remember($this->remember_period)
+ ->get(['etl_client_detail.upi_no',
+ 'etl_client_detail.ccc_number',
+ 'etl_client_detail.dob',
+ 'etl_client_detail.consented',
+ 'etl_client_detail.client_status',
+ 'etl_client_detail.client_name',
+ 'etl_client_detail.dsd_status',
+ 'etl_client_detail.phone_no',
+ DB::raw('COUNT(etl_appointment_detail.app_kept) AS kept_app '),
+ DB::raw('SUM(etl_appointment_detail.app_not_kept) AS not_kept_app ')]);
+
+ $client_app_list = ETLClient::join('etl_appointment_detail', 'etl_client_detail.client_id', '=', 'etl_appointment_detail.client_id')
+ ->where('etl_client_detail.mfl_code', Auth::user()->facility_id)
+ ->whereNotNull('etl_appointment_detail.final_outcome')
+ ->groupBy('etl_appointment_detail.client_id')
+ ->remember($this->remember_period)
+ ->get(['etl_client_detail.upi_no',
+ 'etl_client_detail.ccc_number',
+ 'etl_client_detail.dob',
+ 'etl_client_detail.consented',
+ 'etl_client_detail.client_status',
+ 'etl_client_detail.client_name',
+ 'etl_client_detail.phone_no',
+ 'etl_client_detail.dsd_status',
+ 'etl_appointment_detail.days_defaulted',
+ 'etl_appointment_detail.final_outcome']);
+
+ return view('dashboard.appointment', compact('clinics', 'client_list', 'client_app_list', 'indicator_k', 'indicator_m'));
+ }
+ if (Auth::user()->access_level == 'County') {
+
+ $partners = Partner::select('tbl_partner.id', 'tbl_partner.name')
+ ->join('tbl_partner_facility', 'tbl_partner.id', '=', 'tbl_partner_facility.partner_id')
+ ->where('tbl_partner.status', '=', 'Active')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->groupBy('tbl_partner.name')
+ ->remember($this->remember_period)
+ ->get();
+
+ $counties = County::where("status", "=", "Active")
+ ->remember($this->remember_period)
+ ->get(['id', 'name']);
+
+ $sub_counties = SubCounty::select('tbl_sub_county.id', 'tbl_sub_county.name')
+ ->join('tbl_partner_facility', 'tbl_sub_county.id', '=', 'tbl_partner_facility.sub_county_id')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->groupBy('tbl_sub_county.name')
+ ->remember($this->remember_period)
+ ->get();
+
+
+ $facilities = Facility::select('tbl_master_facility.code', 'tbl_master_facility.name')
+ ->join('tbl_partner_facility', 'tbl_master_facility.code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->get();
+
+ return view('dashboard.appointment', compact('partners','counties', 'sub_counties', 'facilities', 'clinics', 'indicator_k', 'indicator_m'));
+ }
+ if (Auth::user()->access_level == 'Sub County') {
+
+ $facilities = Facility::select('tbl_master_facility.code', 'tbl_master_facility.name')
+ ->join('tbl_partner_facility', 'tbl_master_facility.code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->get();
+
+ return view('dashboard.appointment', compact('facilities', 'clinics', 'indicator_k', 'indicator_m'));
+ }
+ if (Auth::user()->access_level == 'Partner') {
+
+ $facilities = Facility::select('tbl_master_facility.code', 'tbl_master_facility.name')
+ ->join('tbl_partner_facility', 'tbl_master_facility.code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period)
+ ->get();
+
+ $counties = County::select('tbl_county.id', 'tbl_county.name')
+ ->join('tbl_partner_facility', 'tbl_county.id', '=', 'tbl_partner_facility.county_id')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->groupBy('tbl_county.name')
+ ->remember($this->remember_period)
+ ->get();
+
+ $sub_counties = SubCounty::select('tbl_sub_county.id', 'tbl_sub_county.name')
+ ->join('tbl_partner_facility', 'tbl_sub_county.id', '=', 'tbl_partner_facility.sub_county_id')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->groupBy('tbl_sub_county.name')
+ ->remember($this->remember_period)
+ ->get();
+
+ return view('dashboard.appointment', compact('facilities', 'clinics', 'counties', 'sub_counties', 'indicator_k', 'indicator_m'));
+ }
+ }
+ public function appointment()
+ {
+ if (Auth::user()->access_level == 'Facility') {
+
+ $data = [];
+ $all_appoinments = ETLAppointment::select(
+ DB::raw('(SUM(app_kept)+SUM(app_not_kept)+SUM(future)) as total_app'),
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(future) AS future '),
+ DB::raw('SUM(received_sms) AS messages '),
+ DB::raw('AVG(percent_kept) AS percent_kept '),
+ DB::raw('AVG(percent_not_kept) AS percent_not_kept '),
+ DB::raw('AVG(percent_future) AS percent_future ')
+ )
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $consented_clients = ETLClient::select(
+ DB::raw('SUM(CASE WHEN consented = "Yes" THEN 1 ELSE 0 END) AS consented '),
+ DB::raw('AVG(percent_consented) AS percent_consented ')
+ )
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $all_tx_curr = Txcurr::select(DB::raw('SUM(tbl_tx_cur.tx_cur) as tx_cur'))
+ ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_tx_cur.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $appointment_gender = ETLAppointment::select(
+ 'gender',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('gender')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->orderBy('percent_kept', 'DESC')
+ ->groupBy('gender')
+ ->remember($this->remember_period);
+
+ $appointment_age = ETLAppointment::select(
+ 'age_group',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('age_group')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->groupBy('age_group')
+ ->remember($this->remember_period);
+
+ $appointment_marital = ETLAppointment::select(
+ 'marital',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('marital')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->orderBy('percent_kept', 'DESC')
+ ->groupBy('marital')
+ ->remember($this->remember_period);
+
+ $client_list = ETLClient::select(
+ 'etl_client_detail.upi_no',
+ 'etl_client_detail.ccc_number',
+ 'etl_client_detail.dob',
+ 'etl_client_detail.consented',
+ 'etl_client_detail.client_status',
+ 'etl_client_detail.client_name',
+ 'etl_client_detail.dsd_status',
+ 'etl_client_detail.phone_no',
+ DB::raw('COUNT(etl_appointment_detail.app_kept) AS kept_app '),
+ DB::raw('SUM(etl_appointment_detail.app_not_kept) AS not_kept_app ')
+ )
+ ->join('etl_appointment_detail', 'etl_client_detail.client_id', '=', 'etl_appointment_detail.client_id')
+ ->where('etl_client_detail.mfl_code', Auth::user()->facility_id)
+ ->groupBy('etl_appointment_detail.client_id')
+ ->remember($this->remember_period);
+
+ $appointment_county = ETLAppointment::select(
+ 'county',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('AVG(percent_kept) AS percent_kept '),
+ DB::raw('AVG(percent_not_kept) AS percent_not_kept ')
+ )
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->groupBy('county')
+ ->remember($this->remember_period);
+
+ $appointment_partner = ETLAppointment::select(
+ 'partner',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('AVG(percent_kept) AS percent_kept '),
+ DB::raw('AVG(percent_not_kept) AS percent_not_kept ')
+ )
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->groupBy('partner')
+ ->remember($this->remember_period);
+
+ $appointment_facility = ETLAppointment::select(
+ 'facility',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('AVG(percent_kept) AS percent_kept '),
+ DB::raw('AVG(percent_not_kept) AS percent_not_kept ')
+ )
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->groupBy('facility')
+ ->remember($this->remember_period);
+
+ // missed appointment
+ $client_missed = ETLAppointment::selectRaw('
+ SUM(CASE WHEN app_not_kept = 1 THEN 1 ELSE 0 END) AS not_kept_app,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN received_sms END) AS messages,
+ SUM(CASE WHEN received_sms = 1 AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_messages,
+ SUM(CASE WHEN received_sms = 1 AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_messages,
+ SUM(CASE WHEN received_sms = 1 AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_messages,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN called END) AS called,
+ SUM(CASE WHEN called = 1 AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_called,
+ SUM(CASE WHEN called = 1 AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_called,
+ SUM(CASE WHEN called = 1 AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_called,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN physically_traced END) AS physically_traced,
+ SUM(CASE WHEN physically_traced = 1 AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_traced,
+ SUM(CASE WHEN physically_traced = 1 AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_traced,
+ SUM(CASE WHEN physically_traced = 1 AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_traced,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN rtc_no END) AS final_outcome,
+ SUM(CASE WHEN final_outcome = "Client returned to care" AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_outcome,
+ SUM(CASE WHEN final_outcome = "Client returned to care" AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_outcome,
+ SUM(CASE WHEN final_outcome = "Client returned to care" AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_outcome,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN consent_no END) AS consent,
+ SUM(CASE WHEN consent = "Yes" AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_consent,
+ SUM(CASE WHEN consent = "Yes" AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_consent,
+ SUM(CASE WHEN consent = "Yes" AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_consent '
+ )
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->groupBy('client_id')
+ ->remember($this->remember_period);
+
+ $missed_age = ETLAppointment::select(
+ 'age_group',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('age_group')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->groupBy('age_group')
+ ->remember($this->remember_period);
+
+ $missed_gender = ETLAppointment::select(
+ 'gender',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('gender')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->orderBy('percent_rtc', 'DESC')
+ ->groupBy('gender')
+ ->remember($this->remember_period);
+
+ $missed_marital = ETLAppointment::select(
+ 'marital',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('marital')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->orderBy('percent_rtc', 'DESC')
+ ->groupBy('marital')
+ ->remember($this->remember_period);
+
+ $missed_county = ETLAppointment::select(
+ 'county',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome')
+ )
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->groupBy('county')
+ ->remember($this->remember_period);
+
+ $missed_partner = ETLAppointment::select(
+ 'partner',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome')
+ )
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->groupBy('partner')
+ ->remember($this->remember_period);
+
+ $missed_facility = ETLAppointment::select(
+ 'facility',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->whereNotNull('facility')
+ ->groupBy('facility')
+ ->remember($this->remember_period);
+
+ $client_app_list = ETLClient::select(
+ 'etl_client_detail.upi_no',
+ 'etl_client_detail.ccc_number',
+ 'etl_client_detail.dob',
+ 'etl_client_detail.consented',
+ 'etl_client_detail.client_status',
+ 'etl_appointment_detail.days_defaulted',
+ 'etl_appointment_detail.final_outcome',
+ 'etl_client_detail.client_name',
+ 'etl_client_detail.phone_no'
+ )
+ ->join('etl_appointment_detail', 'etl_client_detail.client_id', '=', 'etl_appointment_detail.client_id')
+ ->where('etl_client_detail.mfl_code', Auth::user()->facility_id)
+ ->whereNotNull('etl_appointment_detail.final_outcome')
+ ->groupBy('etl_appointment_detail.client_id')
+ ->remember($this->remember_period);
+
+ $app_period = ETLAppointment::select(
+ DB::raw('DATE_FORMAT(appointment_date, "%Y-%M") AS new_date'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('(SUM(app_kept)+SUM(app_not_kept)+SUM(future)) as total_app'),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('appointment_date')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->where('appointment_date', '<=', Carbon::now()->format('Y-m-d'))
+ ->where(DB::raw('DATE_FORMAT(appointment_date, "%Y-%M")'), '>=', "2017-January")
+ ->where(DB::raw('DATE_FORMAT(appointment_date, "%Y-%M")'), '<=', date('Y-M'))
+ ->orderBy('appointment_date', 'ASC')
+ ->groupBy('new_date')
+ ->remember($this->remember_period);
+
+ $data["all_appoinments"] = $all_appoinments->get();
+ $data["consented_clients"] = $consented_clients->get();
+ $data["all_tx_curr"] = $all_tx_curr->get();
+ $data["appointment_gender"] = $appointment_gender->get();
+ $data["appointment_age"] = $appointment_age->get();
+ $data["appointment_marital"] = $appointment_marital->get();
+ $data["appointment_county"] = $appointment_county->get();
+ $data["appointment_partner"] = $appointment_partner->get();
+ $data["appointment_facility"] = $appointment_facility->get();
+ $data["client_list"] = $client_list->get();
+ $data["client_missed"] = $client_missed->get();
+ $data["missed_age"] = $missed_age->get();
+ $data["missed_gender"] = $missed_gender->get();
+ $data["missed_marital"] = $missed_marital->get();
+ $data["missed_county"] = $missed_county->get();
+ $data["missed_partner"] = $missed_partner->get();
+ $data["missed_facility"] = $missed_facility->get();
+ $data["client_app_list"] = $client_app_list->get();
+ $data["app_period"] = $app_period->get();
+
+ return $data;
+ }
+ if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+
+ $data = [];
+
+ $all_appoinments = ETLAppointment::selectRaw('
+ (SUM(app_kept)+SUM(app_not_kept)+SUM(future)) as total_app,
+ SUM(app_kept) AS kept_app,
+ SUM(app_not_kept) AS not_kept_app,
+ SUM(future) AS future,
+ SUM(received_sms) AS messages,
+ AVG(percent_kept) AS percent_kept,
+ AVG(percent_not_kept) AS percent_not_kept,
+ AVG(percent_future) AS percent_future '
+ )
+ ->remember($this->remember_period);
+
+ $consented_clients = ETLClient::selectRaw(
+ 'SUM(CASE WHEN consented = "Yes" THEN 1 ELSE 0 END) AS consented,
+ AVG(percent_consented) AS percent_consented '
+ )
+ ->remember($this->remember_period);
+
+ $all_tx_curr = Txcurr::select(DB::raw('SUM(tbl_tx_cur.tx_cur) as tx_cur'))
+ ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->remember($this->remember_period);
+
+ $appointment_gender = ETLAppointment::selectRaw(
+ 'gender,
+ SUM(app_kept) AS kept_app,
+ SUM(app_not_kept) AS not_kept_app,
+ ROUND(AVG(percent_kept),1) AS percent_kept,
+ ROUND(AVG(percent_not_kept),1) AS percent_not_kept '
+ )
+ ->whereNotNull('gender')
+ ->orderBy('percent_kept', 'DESC')
+ ->groupBy('gender')
+ ->remember($this->remember_period);
+
+ $appointment_age = ETLAppointment::selectRaw(
+ 'age_group,
+ SUM(app_kept) AS kept_app,
+ SUM(app_not_kept) AS not_kept_app,
+ ROUND(AVG(percent_kept),1) AS percent_kept,
+ ROUND(AVG(percent_not_kept),1) AS percent_not_kept '
+ )
+ ->whereNotNull('age_group')
+ ->groupBy('age_group')
+ ->remember($this->remember_period);
+
+ $appointment_marital = ETLAppointment::selectRaw(
+ 'marital,
+ SUM(app_kept) AS kept_app,
+ SUM(app_not_kept) AS not_kept_app,
+ ROUND(AVG(percent_kept),1) AS percent_kept,
+ ROUND(AVG(percent_not_kept),1) AS percent_not_kept '
+ )
+ ->whereNotNull('marital')
+ ->orderBy('percent_kept', 'DESC')
+ ->groupBy('marital')
+ ->remember($this->remember_period);
+
+ $appointment_county = ETLAppointment::selectRaw(
+ 'county,
+ SUM(app_kept) AS kept_app,
+ SUM(app_not_kept) AS not_kept_app,
+ ROUND(AVG(percent_kept),1) AS percent_kept,
+ ROUND(AVG(percent_not_kept),1) AS percent_not_kept '
+ )
+ ->whereNotNull('county')
+ ->orderBy('percent_kept', 'DESC')
+ ->groupBy('county')
+ ->remember($this->remember_period);
+
+ $appointment_partner = ETLAppointment::selectRaw(
+ 'partner,
+ SUM(app_kept) AS kept_app,
+ SUM(app_not_kept) AS not_kept_app,
+ ROUND(AVG(percent_kept),1) AS percent_kept,
+ ROUND(AVG(percent_not_kept),1) AS percent_not_kept '
+ )
+ ->whereNotNull('partner')
+ ->orderBy('percent_kept', 'DESC')
+ ->groupBy('partner')
+ ->remember($this->remember_period);
+
+
+ // missed appointment
+ $client_missed = ETLAppointment::selectRaw('
+ SUM(CASE WHEN app_not_kept = 1 THEN 1 ELSE 0 END) AS not_kept_app,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN received_sms END) AS messages,
+ SUM(CASE WHEN received_sms = 1 AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_messages,
+ SUM(CASE WHEN received_sms = 1 AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_messages,
+ SUM(CASE WHEN received_sms = 1 AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_messages,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN called END) AS called,
+ SUM(CASE WHEN called = 1 AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_called,
+ SUM(CASE WHEN called = 1 AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_called,
+ SUM(CASE WHEN called = 1 AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_called,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN physically_traced END) AS physically_traced,
+ SUM(CASE WHEN physically_traced = 1 AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_traced,
+ SUM(CASE WHEN physically_traced = 1 AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_traced,
+ SUM(CASE WHEN physically_traced = 1 AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_traced,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN rtc_no END) AS final_outcome,
+ SUM(CASE WHEN final_outcome = "Client returned to care" AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_outcome,
+ SUM(CASE WHEN final_outcome = "Client returned to care" AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_outcome,
+ SUM(CASE WHEN final_outcome = "Client returned to care" AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_outcome,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN consent_no END) AS consent,
+ SUM(CASE WHEN consent = "Yes" AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_consent,
+ SUM(CASE WHEN consent = "Yes" AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_consent,
+ SUM(CASE WHEN consent = "Yes" AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_consent '
+ )
+ ->groupBy('client_id')
+ ->remember($this->remember_period);
+
+ $missed_age = ETLAppointment::selectRaw(
+ 'age_group,
+ SUM(app_not_kept) AS not_kept_app,
+ SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome,
+ ROUND(AVG(percent_rtc),1) AS percent_rtc,
+ ROUND(AVG(percent_not_kept),1) AS percent_not_kept '
+ )
+ ->whereNotNull('age_group')
+ ->groupBy('age_group')
+ ->remember($this->remember_period);
+
+ $missed_gender = ETLAppointment::selectRaw(
+ 'gender,
+ SUM(app_not_kept) AS not_kept_app,
+ SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome,
+ ROUND(AVG(percent_rtc),1) AS percent_rtc,
+ ROUND(AVG(percent_not_kept),1) AS percent_not_kept '
+ )
+ ->whereNotNull('gender')
+ ->orderBy('percent_rtc', 'DESC')
+ ->groupBy('gender')
+ ->remember($this->remember_period);
+
+ $missed_marital = ETLAppointment::selectRaw(
+ 'marital,
+ SUM(app_not_kept) AS not_kept_app,
+ SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome,
+ ROUND(AVG(percent_rtc),1) AS percent_rtc,
+ ROUND(AVG(percent_not_kept),1) AS percent_not_kept '
+ )
+ ->whereNotNull('marital')
+ ->orderBy('percent_rtc', 'DESC')
+ ->groupBy('marital')
+ ->remember($this->remember_period);
+
+ $missed_county = ETLAppointment::selectRaw(
+ 'county,
+ SUM(app_not_kept) AS not_kept_app,
+ SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome,
+ ROUND(AVG(percent_rtc),1) AS percent_rtc,
+ ROUND(AVG(percent_not_kept),1) AS percent_not_kept '
+ )
+ ->whereNotNull('county')
+ ->orderBy('percent_rtc', 'DESC')
+ ->groupBy('county')
+ ->remember($this->remember_period);
+
+ $missed_partner = ETLAppointment::selectRaw(
+ 'partner,
+ SUM(app_not_kept) AS not_kept_app,
+ SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome,
+ ROUND(AVG(percent_rtc),1) AS percent_rtc,
+ ROUND(AVG(percent_not_kept),1) AS percent_not_kept '
+ )
+ ->whereNotNull('partner')
+ ->orderBy('percent_rtc', 'DESC')
+ ->groupBy('partner')
+ ->remember($this->remember_period);
+
+ $app_period = ETLAppointment::selectRaw(
+ 'DATE_FORMAT(appointment_date, "%Y-%M") AS new_date,
+ ROUND(AVG(percent_rtc),1) AS percent_rtc ,
+ (SUM(app_kept)+SUM(app_not_kept)+SUM(future)) as total_app,
+ ROUND(AVG(percent_not_kept),1) AS percent_not_kept '
+ )->whereNotNull('appointment_date')
+ ->where('appointment_date', '<=', Carbon::now()->format('Y-m-d'))
+ ->where(DB::raw('DATE_FORMAT(appointment_date, "%Y-%M")'), '>=', "2017-January")
+ ->where(DB::raw('DATE_FORMAT(appointment_date, "%Y-%M")'), '<=', date('Y-M'))
+ ->orderBy('appointment_date', 'ASC')
+ ->groupBy('new_date')
+ ->remember($this->remember_period);
+
+ $data["all_appoinments"] = $all_appoinments->get();
+ $data["consented_clients"] = $consented_clients->get();
+ $data["all_tx_curr"] = $all_tx_curr->get();
+ $data["appointment_gender"] = $appointment_gender->get();
+ $data["appointment_age"] = $appointment_age->get();
+ $data["appointment_marital"] = $appointment_marital->get();
+ $data["appointment_county"] = $appointment_county->get();
+ $data["appointment_partner"] = $appointment_partner->get();
+ $data["client_missed"] = $client_missed->get();
+ $data["missed_age"] = $missed_age->get();
+ $data["missed_gender"] = $missed_gender->get();
+ $data["missed_marital"] = $missed_marital->get();
+ $data["missed_county"] = $missed_county->get();
+ $data["missed_partner"] = $missed_partner->get();
+ $data["app_period"] = $app_period->get();
+
+ return $data;
+ }
+ if (Auth::user()->access_level == 'Partner') {
+
+ $data = [];
+
+ $all_appoinments = ETLAppointment::select(
+ DB::raw('(SUM(app_kept)+SUM(app_not_kept)+SUM(future)) as total_app'),
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(future) AS future '),
+ DB::raw('SUM(received_sms) AS messages '),
+ DB::raw('AVG(percent_kept) AS percent_kept '),
+ DB::raw('AVG(percent_not_kept) AS percent_not_kept '),
+ DB::raw('AVG(percent_future) AS percent_future ')
+ )
+ ->where('partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ $consented_clients = ETLClient::select(
+ DB::raw('SUM(CASE WHEN consented = "Yes" THEN 1 ELSE 0 END) AS consented '),
+ DB::raw('AVG(percent_consented) AS percent_consented ')
+ )
+ ->where('partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ $all_tx_curr = Txcurr::select(DB::raw('SUM(tbl_tx_cur.tx_cur) as tx_cur'))
+ ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ $appointment_gender = ETLAppointment::select(
+ 'gender',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('gender')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->orderBy('percent_kept', 'DESC')
+ ->groupBy('gender')
+ ->remember($this->remember_period);
+
+ $appointment_age = ETLAppointment::select(
+ 'age_group',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('age_group')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->groupBy('age_group')
+ ->remember($this->remember_period);
+
+ $appointment_marital = ETLAppointment::select(
+ 'marital',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('marital')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->orderBy('percent_kept', 'DESC')
+ ->groupBy('marital')
+ ->remember($this->remember_period);
+
+ $appointment_county = ETLAppointment::select(
+ 'county',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+
+ )
+ ->where('partner_id', Auth::user()->partner_id)
+ ->groupBy('county')
+ ->remember($this->remember_period);
+
+ $appointment_partner = ETLAppointment::select(
+ 'partner',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app ')
+ )
+ ->where('partner_id', Auth::user()->partner_id)
+ ->orderBy('percent_kept', 'DESC')
+ ->groupBy('partner')
+ ->remember($this->remember_period);
+
+ $appointment_facility = ETLAppointment::select(
+ 'facility',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->where('partner_id', Auth::user()->partner_id)
+ ->orderBy('percent_kept', 'DESC')
+ ->groupBy('facility')
+ ->remember($this->remember_period);
+
+ $client_list = ETLClient::select(
+ DB::raw('COUNT(ccc_number) AS ccc_number ')
+ )
+ ->where('partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ // missed appointment
+ $client_missed = ETLAppointment::selectRaw('
+ SUM(CASE WHEN app_not_kept = 1 THEN 1 ELSE 0 END) AS not_kept_app,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN received_sms END) AS messages,
+ SUM(CASE WHEN received_sms = 1 AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_messages,
+ SUM(CASE WHEN received_sms = 1 AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_messages,
+ SUM(CASE WHEN received_sms = 1 AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_messages,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN called END) AS called,
+ SUM(CASE WHEN called = 1 AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_called,
+ SUM(CASE WHEN called = 1 AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_called,
+ SUM(CASE WHEN called = 1 AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_called,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN physically_traced END) AS physically_traced,
+ SUM(CASE WHEN physically_traced = 1 AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_traced,
+ SUM(CASE WHEN physically_traced = 1 AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_traced,
+ SUM(CASE WHEN physically_traced = 1 AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_traced,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN rtc_no END) AS final_outcome,
+ SUM(CASE WHEN final_outcome = "Client returned to care" AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_outcome,
+ SUM(CASE WHEN final_outcome = "Client returned to care" AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_outcome,
+ SUM(CASE WHEN final_outcome = "Client returned to care" AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_outcome,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN consent_no END) AS consent,
+ SUM(CASE WHEN consent = "Yes" AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_consent,
+ SUM(CASE WHEN consent = "Yes" AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_consent,
+ SUM(CASE WHEN consent = "Yes" AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_consent '
+ )
+ ->where('partner_id', Auth::user()->partner_id)
+ ->groupBy('client_id')
+ ->remember($this->remember_period);
+
+ $missed_age = ETLAppointment::select(
+ 'age_group',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('age_group')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->groupBy('age_group')
+ ->remember($this->remember_period);
+
+ $missed_gender = ETLAppointment::select(
+ 'gender',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('gender')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->orderBy('percent_rtc', 'DESC')
+ ->groupBy('gender')
+ ->remember($this->remember_period);
+
+ $missed_marital = ETLAppointment::select(
+ 'marital',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('marital')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->orderBy('percent_rtc', 'DESC')
+ ->groupBy('marital')
+ ->remember($this->remember_period);
+
+ $missed_county = ETLAppointment::select(
+ 'county',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome')
+ )
+ ->where('partner_id', Auth::user()->partner_id)
+ ->groupBy('county')
+ ->remember($this->remember_period);
+
+ $missed_partner = ETLAppointment::select(
+ 'partner',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome')
+ )
+ ->where('partner_id', Auth::user()->partner_id)
+ ->groupBy('partner')
+ ->remember($this->remember_period);
+
+ $missed_facility = ETLAppointment::select(
+ 'facility',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->where('partner_id', Auth::user()->partner_id)
+ ->whereNotNull('facility')
+ ->orderBy('percent_rtc', 'DESC')
+ ->groupBy('facility')
+ ->remember($this->remember_period);
+
+ $client_app_list = ETLClient::select(
+ DB::raw('COUNT(ccc_number) AS ccc_number ')
+ )->remember($this->remember_period);
+
+ $app_period = ETLAppointment::select(
+ DB::raw('DATE_FORMAT(appointment_date, "%Y-%M") AS new_date'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('(SUM(app_kept)+SUM(app_not_kept)+SUM(future)) as total_app'),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )->whereNotNull('appointment_date')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->where('appointment_date', '<=', Carbon::now()->format('Y-m-d'))
+ ->where(DB::raw('DATE_FORMAT(appointment_date, "%Y-%M")'), '>=', "2017-January")
+ ->where(DB::raw('DATE_FORMAT(appointment_date, "%Y-%M")'), '<=', date('Y-M'))
+ ->orderBy('appointment_date', 'ASC')
+ ->groupBy('new_date')
+ ->remember($this->remember_period);
+
+ $data["all_appoinments"] = $all_appoinments->get();
+ $data["consented_clients"] = $consented_clients->get();
+ $data["all_tx_curr"] = $all_tx_curr->get();
+ $data["appointment_gender"] = $appointment_gender->get();
+ $data["appointment_age"] = $appointment_age->get();
+ $data["appointment_marital"] = $appointment_marital->get();
+ $data["appointment_county"] = $appointment_county->get();
+ $data["appointment_partner"] = $appointment_partner->get();
+ $data["appointment_facility"] = $appointment_facility->get();
+ $data["client_list"] = $client_list->get();
+ $data["client_missed"] = $client_missed->get();
+ $data["missed_age"] = $missed_age->get();
+ $data["missed_gender"] = $missed_gender->get();
+ $data["missed_marital"] = $missed_marital->get();
+ $data["missed_county"] = $missed_county->get();
+ $data["missed_partner"] = $missed_partner->get();
+ $data["missed_facility"] = $missed_facility->get();
+ $data["client_app_list"] = $client_app_list->get();
+ $data["app_period"] = $app_period->get();
+
+ return $data;
+ }
+ if (Auth::user()->access_level == 'Sub County') {
+
+ $data = [];
+
+ $all_appoinments = ETLAppointment::select(
+ DB::raw('(SUM(app_kept)+SUM(app_not_kept)+SUM(future)) as total_app'),
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(future) AS future '),
+ DB::raw('SUM(received_sms) AS messages '),
+ DB::raw('AVG(percent_kept) AS percent_kept '),
+ DB::raw('AVG(percent_not_kept) AS percent_not_kept '),
+ DB::raw('AVG(percent_future) AS percent_future ')
+ )
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $consented_clients = ETLClient::select(
+ DB::raw('SUM(CASE WHEN consented = "Yes" THEN 1 ELSE 0 END) AS consented '),
+ DB::raw('AVG(percent_consented) AS percent_consented ')
+ )
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $all_tx_curr = Txcurr::select(DB::raw('SUM(tbl_tx_cur.tx_cur) as tx_cur'))
+ ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $appointment_gender = ETLAppointment::select(
+ 'gender',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('gender')
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->orderBy('percent_kept', 'DESC')
+ ->groupBy('gender')
+ ->remember($this->remember_period);
+
+ $appointment_age = ETLAppointment::select(
+ 'age_group',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('age_group')
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->groupBy('age_group')
+ ->remember($this->remember_period);
+
+ $appointment_marital = ETLAppointment::select(
+ 'marital',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('marital')
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->orderBy('percent_kept', 'DESC')
+ ->groupBy('marital')
+ ->remember($this->remember_period);
+
+ $appointment_county = ETLAppointment::select(
+ 'county',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app ')
+ )
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->groupBy('county')
+ ->remember($this->remember_period);
+
+ $appointment_partner = ETLAppointment::select(
+ 'partner',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->groupBy('partner')
+ ->remember($this->remember_period);
+
+ $appointment_facility = ETLAppointment::select(
+ 'facility',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('facility')
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->orderBy('percent_kept', 'DESC')
+ ->groupBy('facility')
+ ->remember($this->remember_period);
+ $client_list = ETLClient::select(
+ DB::raw('COUNT(ccc_number) AS ccc_number ')
+ )
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ // missed appointment
+ $client_missed = ETLAppointment::selectRaw('
+ SUM(CASE WHEN app_not_kept = 1 THEN 1 ELSE 0 END) AS not_kept_app,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN received_sms END) AS messages,
+ SUM(CASE WHEN received_sms = 1 AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_messages,
+ SUM(CASE WHEN received_sms = 1 AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_messages,
+ SUM(CASE WHEN received_sms = 1 AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_messages,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN called END) AS called,
+ SUM(CASE WHEN called = 1 AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_called,
+ SUM(CASE WHEN called = 1 AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_called,
+ SUM(CASE WHEN called = 1 AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_called,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN physically_traced END) AS physically_traced,
+ SUM(CASE WHEN physically_traced = 1 AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_traced,
+ SUM(CASE WHEN physically_traced = 1 AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_traced,
+ SUM(CASE WHEN physically_traced = 1 AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_traced,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN rtc_no END) AS final_outcome,
+ SUM(CASE WHEN final_outcome = "Client returned to care" AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_outcome,
+ SUM(CASE WHEN final_outcome = "Client returned to care" AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_outcome,
+ SUM(CASE WHEN final_outcome = "Client returned to care" AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_outcome,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN consent_no END) AS consent,
+ SUM(CASE WHEN consent = "Yes" AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_consent,
+ SUM(CASE WHEN consent = "Yes" AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_consent,
+ SUM(CASE WHEN consent = "Yes" AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_consent '
+ )
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->groupBy('client_id')
+ ->remember($this->remember_period);
+
+ $missed_age = ETLAppointment::select(
+ 'age_group',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('age_group')
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->groupBy('age_group')
+ ->remember($this->remember_period);
+
+ $missed_gender = ETLAppointment::select(
+ 'gender',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('gender')
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->orderBy('percent_rtc', 'DESC')
+ ->groupBy('gender')
+ ->remember($this->remember_period);
+
+ $missed_marital = ETLAppointment::select(
+ 'marital',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('marital')
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->orderBy('percent_rtc', 'DESC')
+ ->groupBy('marital')
+ ->remember($this->remember_period);
+
+ $missed_county = ETLAppointment::select(
+ 'county',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome')
+ )
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->orderBy('percent_rtc', 'DESC')
+ ->groupBy('county')
+ ->remember($this->remember_period);
+
+ $missed_partner = ETLAppointment::select(
+ 'partner',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('AVG(percent_rtc) AS percent_rtc '),
+ DB::raw('AVG(percent_not_kept) AS percent_not_kept ')
+ )
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->groupBy('partner')
+ ->remember($this->remember_period);
+
+ $missed_facility = ETLAppointment::select(
+ 'facility',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->whereNotNull('facility')
+ ->orderBy('percent_rtc', 'DESC')
+ ->groupBy('facility')
+ ->remember($this->remember_period);
+
+ $client_app_list = ETLClient::select(
+ DB::raw('COUNT(ccc_number) AS ccc_number ')
+ )->remember($this->remember_period);
+
+ $app_period = ETLAppointment::select(
+ DB::raw('DATE_FORMAT(appointment_date, "%Y-%M") AS new_date'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('(SUM(app_kept)+SUM(app_not_kept)+SUM(future)) as total_app'),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )->whereNotNull('appointment_date')
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->where('appointment_date', '<=', Carbon::now()->format('Y-m-d'))
+ ->where(DB::raw('DATE_FORMAT(appointment_date, "%Y-%M")'), '>=', "2017-January")
+ ->where(DB::raw('DATE_FORMAT(appointment_date, "%Y-%M")'), '<=', date('Y-M'))
+ ->orderBy('appointment_date', 'ASC')
+ ->groupBy('new_date')
+ ->remember($this->remember_period);
+
+ $data["all_appoinments"] = $all_appoinments->get();
+ $data["consented_clients"] = $consented_clients->get();
+ $data["all_tx_curr"] = $all_tx_curr->get();
+ $data["appointment_gender"] = $appointment_gender->get();
+ $data["appointment_age"] = $appointment_age->get();
+ $data["appointment_marital"] = $appointment_marital->get();
+ $data["appointment_county"] = $appointment_county->get();
+ $data["appointment_partner"] = $appointment_partner->get();
+ $data["appointment_facility"] = $appointment_facility->get();
+ $data["client_list"] = $client_list->get();
+ $data["client_missed"] = $client_missed->get();
+ $data["missed_age"] = $missed_age->get();
+ $data["missed_gender"] = $missed_gender->get();
+ $data["missed_marital"] = $missed_marital->get();
+ $data["missed_county"] = $missed_county->get();
+ $data["missed_partner"] = $missed_partner->get();
+ $data["missed_facility"] = $missed_facility->get();
+ $data["client_app_list"] = $client_app_list->get();
+ $data["app_period"] = $app_period->get();
+
+ return $data;
+ }
+ if (Auth::user()->access_level == 'County') {
+
+ $data = [];
+
+ $all_appoinments = ETLAppointment::select(
+ DB::raw('(SUM(app_kept)+SUM(app_not_kept)+SUM(future)) as total_app'),
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(future) AS future '),
+ DB::raw('SUM(received_sms) AS messages '),
+ DB::raw('AVG(percent_kept) AS percent_kept '),
+ DB::raw('AVG(percent_not_kept) AS percent_not_kept '),
+ DB::raw('AVG(percent_future) AS percent_future ')
+ )
+ ->where('county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+ $consented_clients = ETLClient::select(
+ DB::raw('SUM(CASE WHEN consented = "Yes" THEN 1 ELSE 0 END) AS consented '),
+ DB::raw('AVG(percent_consented) AS percent_consented ')
+ )
+ ->where('county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $all_tx_curr = Txcurr::select(DB::raw('SUM(tbl_tx_cur.tx_cur) as tx_cur'))
+ ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $appointment_gender = ETLAppointment::select(
+ 'gender',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('gender')
+ ->where('county_id', Auth::user()->county_id)
+ ->orderBy('percent_kept', 'DESC')
+ ->groupBy('gender')
+ ->remember($this->remember_period);
+
+ $appointment_age = ETLAppointment::select(
+ 'age_group',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('age_group')
+ ->where('county_id', Auth::user()->county_id)
+ ->groupBy('age_group')
+ ->remember($this->remember_period);
+
+ $appointment_marital = ETLAppointment::select(
+ 'marital',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('marital')
+ ->where('county_id', Auth::user()->county_id)
+ ->orderBy('percent_kept', 'DESC')
+ ->groupBy('marital')
+ ->remember($this->remember_period);
+
+ $appointment_county = ETLAppointment::select(
+ 'county',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app ')
+ )
+ ->where('county_id', Auth::user()->county_id)
+ ->groupBy('county')
+ ->remember($this->remember_period);
+
+ $appointment_partner = ETLAppointment::select(
+ 'partner',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('partner')
+ ->where('county_id', Auth::user()->county_id)
+ ->orderBy('percent_kept', 'DESC')
+ ->groupBy('partner')
+ ->remember($this->remember_period);
+
+ $appointment_facility = ETLAppointment::select(
+ 'facility',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('facility')
+ ->where('county_id', Auth::user()->county_id)
+ ->orderBy('percent_kept', 'DESC')
+ ->groupBy('facility')
+ ->remember($this->remember_period);
+
+ $client_list = ETLClient::select(
+ DB::raw('COUNT(ccc_number) AS ccc_number ')
+ )
+ ->where('county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ // missed appointment
+ $client_missed = ETLAppointment::selectRaw('
+ SUM(CASE WHEN app_not_kept = 1 THEN 1 ELSE 0 END) AS not_kept_app,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN received_sms END) AS messages,
+ SUM(CASE WHEN received_sms = 1 AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_messages,
+ SUM(CASE WHEN received_sms = 1 AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_messages,
+ SUM(CASE WHEN received_sms = 1 AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_messages,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN called END) AS called,
+ SUM(CASE WHEN called = 1 AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_called,
+ SUM(CASE WHEN called = 1 AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_called,
+ SUM(CASE WHEN called = 1 AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_called,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN physically_traced END) AS physically_traced,
+ SUM(CASE WHEN physically_traced = 1 AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_traced,
+ SUM(CASE WHEN physically_traced = 1 AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_traced,
+ SUM(CASE WHEN physically_traced = 1 AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_traced,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN rtc_no END) AS final_outcome,
+ SUM(CASE WHEN final_outcome = "Client returned to care" AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_outcome,
+ SUM(CASE WHEN final_outcome = "Client returned to care" AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_outcome,
+ SUM(CASE WHEN final_outcome = "Client returned to care" AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_outcome,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN consent_no END) AS consent,
+ SUM(CASE WHEN consent = "Yes" AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_consent,
+ SUM(CASE WHEN consent = "Yes" AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_consent,
+ SUM(CASE WHEN consent = "Yes" AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_consent '
+
+ )
+ ->where('county_id', Auth::user()->county_id)
+ ->groupBy('client_id')
+ ->remember($this->remember_period);
+
+ $missed_age = ETLAppointment::select(
+ 'age_group',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('age_group')
+ ->where('county_id', Auth::user()->county_id)
+ ->groupBy('age_group')
+ ->remember($this->remember_period);
+
+ $missed_gender = ETLAppointment::select(
+ 'gender',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('gender')
+ ->where('county_id', Auth::user()->county_id)
+ ->orderBy('percent_rtc', 'DESC')
+ ->groupBy('gender')
+ ->remember($this->remember_period);
+
+ $missed_marital = ETLAppointment::select(
+ 'marital',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('marital')
+ ->where('county_id', Auth::user()->county_id)
+ ->orderBy('percent_rtc', 'DESC')
+ ->groupBy('marital')
+ ->remember($this->remember_period);
+
+ $missed_county = ETLAppointment::select(
+ 'county',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome')
+ )
+ ->where('county_id', Auth::user()->county_id)
+ ->groupBy('county')
+ ->remember($this->remember_period);
+
+ $missed_partner = ETLAppointment::select(
+ 'partner',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('partner')
+ ->where('county_id', Auth::user()->county_id)
+ ->orderBy('percent_rtc', 'DESC')
+ ->groupBy('partner')
+ ->remember($this->remember_period);
+
+ $missed_facility = ETLAppointment::select(
+ 'facility',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->where('county_id', Auth::user()->county_id)
+ ->whereNotNull('facility')
+ ->orderBy('percent_rtc', 'DESC')
+ ->groupBy('facility')
+ ->remember($this->remember_period);
+
+ $client_app_list = ETLClient::select(
+ DB::raw('COUNT(ccc_number) AS ccc_number ')
+ )->remember($this->remember_period);
+
+ $app_period = ETLAppointment::select(
+ DB::raw('DATE_FORMAT(appointment_date, "%Y-%M") AS new_date'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('(SUM(app_kept)+SUM(app_not_kept)+SUM(future)) as total_app'),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )->whereNotNull('appointment_date')
+ ->where('county_id', Auth::user()->county_id)
+ ->where('appointment_date', '<=', Carbon::now()->format('Y-m-d'))
+ ->where(DB::raw('DATE_FORMAT(appointment_date, "%Y-%M")'), '>=', "2017-January")
+ ->where(DB::raw('DATE_FORMAT(appointment_date, "%Y-%M")'), '<=', date('Y-M'))
+ ->orderBy('appointment_date', 'ASC')
+ ->groupBy('new_date')
+ ->remember($this->remember_period);
+
+ $data["all_appoinments"] = $all_appoinments->get();
+ $data["consented_clients"] = $consented_clients->get();
+ $data["all_tx_curr"] = $all_tx_curr->get();
+ $data["appointment_gender"] = $appointment_gender->get();
+ $data["appointment_age"] = $appointment_age->get();
+ $data["appointment_marital"] = $appointment_marital->get();
+ $data["appointment_county"] = $appointment_county->get();
+ $data["appointment_partner"] = $appointment_partner->get();
+ $data["appointment_facility"] = $appointment_facility->get();
+ $data["client_list"] = $client_list->get();
+ $data["client_missed"] = $client_missed->get();
+ $data["missed_age"] = $missed_age->get();
+ $data["missed_gender"] = $missed_gender->get();
+ $data["missed_marital"] = $missed_marital->get();
+ $data["missed_county"] = $missed_county->get();
+ $data["missed_partner"] = $missed_partner->get();
+ $data["missed_facility"] = $missed_facility->get();
+ $data["client_app_list"] = $client_app_list->get();
+ $data["app_period"] = $app_period->get();
+
+ return $data;
+ }
+ }
+
+ public function filter_data(Request $request)
+ {
+ if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+ $data = [];
+ $selected_partners = $request->partners;
+ $selected_counties = $request->counties;
+ $selected_subcounties = $request->subcounties;
+ $selected_facilites = $request->facilities;
+ $selected_clinics = $request->clinics;
+ $selected_appointments = $request->appointments;
+ $selected_from = $request->from;
+ $selected_to = $request->to;
+ $selected_site = $request->sites;
+
+ $all_appoinments = ETLAppointment::select(
+ DB::raw('(SUM(app_kept)+SUM(app_not_kept)+SUM(future)) as total_app'),
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(future) AS future '),
+ DB::raw('SUM(received_sms) AS messages '),
+ DB::raw('AVG(percent_kept) AS percent_kept '),
+ DB::raw('AVG(percent_not_kept) AS percent_not_kept '),
+ DB::raw('AVG(percent_future) AS percent_future ')
+ )->remember($this->remember_period);
+
+ $consented_clients = ETLClient::select(
+ DB::raw('SUM(CASE WHEN consented = "Yes" THEN 1 ELSE 0 END) AS consented '),
+ DB::raw('AVG(percent_consented) AS percent_consented ')
+ )->remember($this->remember_period);
+
+ $all_tx_curr = Txcurr::select(DB::raw('SUM(tbl_tx_cur.tx_cur) as tx_cur'))
+ ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')->remember($this->remember_period);
+
+ $appointment_gender = ETLAppointment::select(
+ 'gender',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('gender')
+ ->groupBy('gender')
+ ->remember($this->remember_period);
+
+ $appointment_age = ETLAppointment::select(
+ 'age_group',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('age_group')
+ ->groupBy('age_group')
+ ->remember($this->remember_period);
+
+ $appointment_marital = ETLAppointment::select(
+ 'marital',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('marital')
+ ->groupBy('marital')
+ ->remember($this->remember_period);
+
+ $appointment_county = ETLAppointment::select(
+ 'county',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('county')
+ ->groupBy('county')
+ ->remember($this->remember_period);
+
+ $appointment_partner = ETLAppointment::select(
+ 'partner',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('partner')
+ ->groupBy('partner')
+ ->remember($this->remember_period);
+
+ // missed appointment
+ $client_missed = ETLAppointment::selectRaw('
+ SUM(CASE WHEN app_not_kept = 1 THEN 1 ELSE 0 END) AS not_kept_app,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN received_sms END) AS messages,
+ SUM(CASE WHEN received_sms = 1 AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_messages,
+ SUM(CASE WHEN received_sms = 1 AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_messages,
+ SUM(CASE WHEN received_sms = 1 AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_messages,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN called END) AS called,
+ SUM(CASE WHEN called = 1 AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_called,
+ SUM(CASE WHEN called = 1 AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_called,
+ SUM(CASE WHEN called = 1 AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_called,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN physically_traced END) AS physically_traced,
+ SUM(CASE WHEN physically_traced = 1 AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_traced,
+ SUM(CASE WHEN physically_traced = 1 AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_traced,
+ SUM(CASE WHEN physically_traced = 1 AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_traced,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN rtc_no END) AS final_outcome,
+ SUM(CASE WHEN final_outcome = "Client returned to care" AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_outcome,
+ SUM(CASE WHEN final_outcome = "Client returned to care" AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_outcome,
+ SUM(CASE WHEN final_outcome = "Client returned to care" AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_outcome,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN consent_no END) AS consent,
+ SUM(CASE WHEN consent = "Yes" AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_consent,
+ SUM(CASE WHEN consent = "Yes" AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_consent,
+ SUM(CASE WHEN consent = "Yes" AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_consent '
+ )->groupBy('client_id')
+ ->remember($this->remember_period);
+
+ $missed_age = ETLAppointment::select(
+ 'age_group',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('age_group')
+ ->groupBy('age_group')
+ ->remember($this->remember_period);
+
+ $missed_gender = ETLAppointment::select(
+ 'gender',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('gender')
+ ->groupBy('gender')
+ ->remember($this->remember_period);
+
+ $missed_marital = ETLAppointment::select(
+ 'marital',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('marital')
+ ->groupBy('marital')
+ ->remember($this->remember_period);
+
+ $missed_county = ETLAppointment::select(
+ 'county',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('county')
+ ->groupBy('county')
+ ->remember($this->remember_period);
+
+ $missed_partner = ETLAppointment::select(
+ 'partner',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('partner')
+ ->groupBy('partner')
+ ->remember($this->remember_period);
+
+ $app_period = ETLAppointment::select(
+ DB::raw('DATE_FORMAT(appointment_date, "%Y-%M") AS new_date'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('(SUM(app_kept)+SUM(app_not_kept)+SUM(future)) as total_app'),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )->whereNotNull('appointment_date')
+ ->where('appointment_date', '<=', Carbon::now()->format('Y-m-d'))
+ ->where(DB::raw('DATE_FORMAT(appointment_date, "%Y-%M")'), '>=', "2017-January")
+ ->orderBy('appointment_date', 'ASC')
+ ->groupBy('new_date')
+ ->remember($this->remember_period);
+
+ if (!empty($selected_partners)) {
+ $all_appoinments = $all_appoinments->where('partner_id', $selected_partners);
+ $consented_clients = $consented_clients->where('partner_id', $selected_partners);
+ $all_tx_curr = $all_tx_curr->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_gender = $appointment_gender->where('partner_id', $selected_partners);
+ $appointment_age = $appointment_age->where('partner_id', $selected_partners);
+ $appointment_marital = $appointment_marital->where('partner_id', $selected_partners);
+ $appointment_county = $appointment_county->where('partner_id', $selected_partners);
+ $appointment_partner = $appointment_partner->where('partner_id', $selected_partners);
+ $client_missed = $client_missed->where('partner_id', $selected_partners);
+ $missed_age = $missed_age->where('partner_id', $selected_partners);
+ $missed_gender = $missed_gender->where('partner_id', $selected_partners);
+ $missed_marital = $missed_marital->where('partner_id', $selected_partners);
+ $missed_county = $missed_county->where('partner_id', $selected_partners);
+ $missed_partner = $missed_partner->where('partner_id', $selected_partners);
+ $app_period = $app_period->where('partner_id', $selected_partners);
+ }
+ if (!empty($selected_counties)) {
+ $all_appoinments = $all_appoinments->where('county_id', $selected_counties);
+ $consented_clients = $consented_clients->where('county_id', $selected_counties);
+ $all_tx_curr = $all_tx_curr->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_gender = $appointment_gender->where('county_id', $selected_counties);
+ $appointment_age = $appointment_age->where('county_id', $selected_counties);
+ $appointment_marital = $appointment_marital->where('county_id', $selected_counties);
+ $appointment_county = $appointment_county->where('county_id', $selected_counties);
+ $appointment_partner = $appointment_partner->where('county_id', $selected_counties);
+ $client_missed = $client_missed->where('county_id', $selected_counties);
+ $missed_age = $missed_age->where('county_id', $selected_counties);
+ $missed_gender = $missed_gender->where('county_id', $selected_counties);
+ $missed_marital = $missed_marital->where('county_id', $selected_counties);
+ $missed_county = $missed_county->where('county_id', $selected_counties);
+ $missed_partner = $missed_partner->where('county_id', $selected_counties);
+ $app_period = $app_period->where('county_id', $selected_counties);
+ }
+ if (!empty($selected_subcounties)) {
+ $all_appoinments = $all_appoinments->where('subcounty_id', $selected_subcounties);
+ $consented_clients = $consented_clients->where('subcounty_id', $selected_subcounties);
+ $all_tx_curr = $all_tx_curr->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_gender = $appointment_gender->where('subcounty_id', $selected_subcounties);
+ $appointment_age = $appointment_age->where('subcounty_id', $selected_subcounties);
+ $appointment_marital = $appointment_marital->where('subcounty_id', $selected_subcounties);
+ $appointment_county = $appointment_county->where('subcounty_id', $selected_subcounties);
+ $appointment_partner = $appointment_partner->where('subcounty_id', $selected_subcounties);
+ $client_missed = $client_missed->where('subcounty_id', $selected_subcounties);
+ $missed_age = $missed_age->where('subcounty_id', $selected_subcounties);
+ $missed_gender = $missed_gender->where('subcounty_id', $selected_subcounties);
+ $missed_marital = $missed_marital->where('subcounty_id', $selected_subcounties);
+ $missed_county = $missed_county->where('subcounty_id', $selected_subcounties);
+ $missed_partner = $missed_partner->where('subcounty_id', $selected_subcounties);
+ $app_period = $app_period->where('subcounty_id', $selected_subcounties);
+ }
+ if (!empty($selected_facilites)) {
+ $all_appoinments = $all_appoinments->where('mfl_code', $selected_facilites);
+ $consented_clients = $consented_clients->where('mfl_code', $selected_facilites);
+ $all_tx_curr = $all_tx_curr->where('tbl_partner_facility.mfl_code', $selected_facilites)->groupBy('tbl_partner_facility.mfl_code');
+ $appointment_gender = $appointment_gender->where('mfl_code', $selected_facilites);
+ $appointment_age = $appointment_age->where('mfl_code', $selected_facilites);
+ $appointment_marital = $appointment_marital->where('mfl_code', $selected_facilites);
+ $appointment_county = $appointment_county->where('mfl_code', $selected_facilites);
+ $appointment_partner = $appointment_partner->where('mfl_code', $selected_facilites);
+ $client_missed = $client_missed->where('mfl_code', $selected_facilites);
+ $missed_age = $missed_age->where('mfl_code', $selected_facilites);
+ $missed_gender = $missed_gender->where('mfl_code', $selected_facilites);
+ $missed_marital = $missed_marital->where('mfl_code', $selected_facilites);
+ $missed_county = $missed_county->where('mfl_code', $selected_facilites);
+ $missed_partner = $missed_partner->where('mfl_code', $selected_facilites);
+ $app_period = $app_period->where('mfl_code', $selected_facilites);
+ }
+
+ if (!empty($selected_clinics)) {
+ $all_appoinments = $all_appoinments->where('clinic_type', $selected_clinics);
+ $consented_clients = $consented_clients->where('clinic_type', $selected_clinics);
+ $all_tx_curr = $all_tx_curr;
+ $appointment_gender = $appointment_gender->where('clinic_type', $selected_clinics);
+ $appointment_age = $appointment_age->where('clinic_type', $selected_clinics);
+ $appointment_marital = $appointment_marital->where('clinic_type', $selected_clinics);
+ $appointment_county = $appointment_county->where('clinic_type', $selected_clinics);
+ $appointment_partner = $appointment_partner->where('clinic_type', $selected_clinics);
+ $client_missed = $client_missed->where('clinic_type', $selected_clinics);
+ $missed_age = $missed_age->where('clinic_type', $selected_clinics);
+ $missed_gender = $missed_gender->where('clinic_type', $selected_clinics);
+ $missed_marital = $missed_marital->where('clinic_type', $selected_clinics);
+ $missed_county = $missed_county->where('clinic_type', $selected_clinics);
+ $missed_partner = $missed_partner->where('clinic_type', $selected_clinics);
+ $app_period = $app_period->where('clinic_type', $selected_clinics);
+ }
+ if (!empty($selected_appointments)) {
+ $all_appoinments = $all_appoinments;
+ $consented_clients = $consented_clients;
+ $all_tx_curr = $all_tx_curr;
+ $appointment_gender = $appointment_gender;
+ $appointment_age = $appointment_age;
+ $appointment_marital = $appointment_marital;
+ $appointment_county = $appointment_county;
+ $appointment_partner = $appointment_partner;
+ $client_missed = $client_missed->where('appointment_status', $selected_appointments);
+ $missed_age = $missed_age->where('appointment_status', $selected_appointments);
+ $missed_gender = $missed_gender->where('appointment_status', $selected_appointments);
+ $missed_marital = $missed_marital->where('appointment_status', $selected_appointments);
+ $missed_county = $missed_county->where('appointment_status', $selected_appointments);
+ $missed_partner = $missed_partner->where('appointment_status', $selected_appointments);
+ $app_period = $app_period->where('appointment_status', $selected_appointments);
+ }
+ if (!empty($selected_from || $selected_to)) {
+ $all_appoinments = $all_appoinments->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $consented_clients = $consented_clients->where('consented_date', '>=', date($request->from))->where('consented_date', '<=', date($request->to));
+ $all_tx_curr = $all_tx_curr;
+ $appointment_gender = $appointment_gender->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $appointment_age = $appointment_age->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $appointment_marital = $appointment_marital->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $appointment_county = $appointment_county->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $appointment_partner = $appointment_partner->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $client_missed = $client_missed->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $missed_age = $missed_age->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $missed_gender = $missed_gender->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $missed_marital = $missed_marital->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $missed_county = $missed_county->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $missed_partner = $missed_partner->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $app_period = $app_period->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ }
+
+ if (!empty($selected_site)) {
+ $all_appoinments = $all_appoinments->where('facility_type', $selected_site);
+ $consented_clients = $consented_clients->where('facility_type', $selected_site);
+ $all_tx_curr = $all_tx_curr;
+ $appointment_gender = $appointment_gender->where('facility_type', $selected_site);
+ $appointment_age = $appointment_age->where('facility_type', $selected_site);
+ $appointment_marital = $appointment_marital->where('facility_type', $selected_site);
+ $appointment_county = $appointment_county->where('facility_type', $selected_site);
+ $appointment_partner = $appointment_partner->where('facility_type', $selected_site);
+ $client_missed = $client_missed->where('facility_type', $selected_site);
+ $missed_age = $missed_age->where('facility_type', $selected_site);
+ $missed_gender = $missed_gender->where('facility_type', $selected_site);
+ $missed_marital = $missed_marital->where('facility_type', $selected_site);
+ $missed_county = $missed_county->where('facility_type', $selected_site);
+ $missed_partner = $missed_partner->where('facility_type', $selected_site);
+ $app_period = $app_period->where('facility_type', $selected_site);
+ }
+
+ $data["all_appoinments"] = $all_appoinments->get();
+ $data["consented_clients"] = $consented_clients->get();
+ $data["all_tx_curr"] = $all_tx_curr->get();
+ $data["appointment_gender"] = $appointment_gender->get();
+ $data["appointment_age"] = $appointment_age->get();
+ $data["appointment_marital"] = $appointment_marital->get();
+ $data["appointment_county"] = $appointment_county->get();
+ $data["appointment_partner"] = $appointment_partner->get();
+ $data["client_missed"] = $client_missed->get();
+ $data["missed_age"] = $missed_age->get();
+ $data["missed_gender"] = $missed_gender->get();
+ $data["missed_marital"] = $missed_marital->get();
+ $data["missed_county"] = $missed_county->get();
+ $data["missed_partner"] = $missed_partner->get();
+ $data["app_period"] = $app_period->get();
+
+ return $data;
+ }
+ if (Auth::user()->access_level == 'Facility') {
+
+ $selected_partners = $request->partners;
+ $selected_counties = $request->counties;
+ $selected_subcounties = $request->subcounties;
+ $selected_facilites = $request->facilities;
+ $selected_clinics = $request->clinics;
+ $selected_appointments = $request->appointments;
+ $selected_from = $request->from;
+ $selected_to = $request->to;
+ $selected_site = $request->site;
+ $data = [];
+ $all_appoinments = ETLAppointment::select(
+ DB::raw('(SUM(app_kept)+SUM(app_not_kept)+SUM(future)) as total_app'),
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(future) AS future '),
+ DB::raw('SUM(received_sms) AS messages '),
+ DB::raw('AVG(percent_kept) AS percent_kept '),
+ DB::raw('AVG(percent_not_kept) AS percent_not_kept '),
+ DB::raw('AVG(percent_future) AS percent_future ')
+ )
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $consented_clients = ETLClient::select(
+ DB::raw('SUM(CASE WHEN consented = "Yes" THEN 1 ELSE 0 END) AS consented '),
+ DB::raw('AVG(percent_consented) AS percent_consented ')
+ )
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $all_tx_curr = Txcurr::select(DB::raw('SUM(tbl_tx_cur.tx_cur) as tx_cur'))
+ ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_tx_cur.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $appointment_gender = ETLAppointment::select(
+ 'gender',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('gender')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->groupBy('gender')
+ ->remember($this->remember_period);
+
+ $appointment_age = ETLAppointment::select(
+ 'age_group',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('age_group')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->groupBy('age_group')
+ ->remember($this->remember_period);
+
+ $appointment_marital = ETLAppointment::select(
+ 'marital',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('marital')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->groupBy('marital')
+ ->remember($this->remember_period);
+
+ $client_list = ETLClient::select(
+ 'etl_client_detail.upi_no',
+ 'etl_client_detail.ccc_number',
+ 'etl_client_detail.dob',
+ 'etl_client_detail.consented',
+ 'etl_client_detail.client_status',
+ 'etl_client_detail.client_name',
+ 'etl_client_detail.dsd_status',
+ 'etl_client_detail.phone_no',
+ DB::raw('COUNT(etl_appointment_detail.app_kept) AS kept_app '),
+ DB::raw('SUM(etl_appointment_detail.app_not_kept) AS not_kept_app ')
+ )
+ ->join('etl_appointment_detail', 'etl_client_detail.client_id', '=', 'etl_appointment_detail.client_id')
+ ->where('etl_client_detail.mfl_code', Auth::user()->facility_id)
+ ->groupBy('etl_appointment_detail.client_id')
+ ->remember($this->remember_period);
+
+ $appointment_county = ETLAppointment::select(
+ 'county',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('AVG(percent_kept) AS percent_kept '),
+ DB::raw('AVG(percent_not_kept) AS percent_not_kept ')
+ )
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->groupBy('county')
+ ->remember($this->remember_period);
+
+ $appointment_partner = ETLAppointment::select(
+ 'partner',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('AVG(percent_kept) AS percent_kept '),
+ DB::raw('AVG(percent_not_kept) AS percent_not_kept ')
+ )
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->groupBy('partner')
+ ->remember($this->remember_period);
+
+ $appointment_facility = ETLAppointment::select(
+ 'facility',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('AVG(percent_kept) AS percent_kept '),
+ DB::raw('AVG(percent_not_kept) AS percent_not_kept ')
+ )
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->groupBy('facility')
+ ->remember($this->remember_period);
+
+ // missed appointment
+ $client_missed = ETLAppointment::selectRaw('
+ SUM(CASE WHEN app_not_kept = 1 THEN 1 ELSE 0 END) AS not_kept_app,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN received_sms END) AS messages,
+ SUM(CASE WHEN received_sms = 1 AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_messages,
+ SUM(CASE WHEN received_sms = 1 AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_messages,
+ SUM(CASE WHEN received_sms = 1 AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_messages,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN called END) AS called,
+ SUM(CASE WHEN called = 1 AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_called,
+ SUM(CASE WHEN called = 1 AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_called,
+ SUM(CASE WHEN called = 1 AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_called,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN physically_traced END) AS physically_traced,
+ SUM(CASE WHEN physically_traced = 1 AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_traced,
+ SUM(CASE WHEN physically_traced = 1 AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_traced,
+ SUM(CASE WHEN physically_traced = 1 AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_traced,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN rtc_no END) AS final_outcome,
+ SUM(CASE WHEN final_outcome = "Client returned to care" AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_outcome,
+ SUM(CASE WHEN final_outcome = "Client returned to care" AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_outcome,
+ SUM(CASE WHEN final_outcome = "Client returned to care" AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_outcome,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN consent_no END) AS consent,
+ SUM(CASE WHEN consent = "Yes" AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_consent,
+ SUM(CASE WHEN consent = "Yes" AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_consent,
+ SUM(CASE WHEN consent = "Yes" AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_consent '
+ )
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->groupBy('client_id')
+ ->remember($this->remember_period);
+
+ $missed_age = ETLAppointment::select(
+ 'age_group',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('age_group')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->groupBy('age_group')
+ ->remember($this->remember_period);
+
+ $missed_gender = ETLAppointment::select(
+ 'gender',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('gender')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->groupBy('gender')
+ ->remember($this->remember_period);
+
+ $missed_marital = ETLAppointment::select(
+ 'marital',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('marital')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->groupBy('marital')
+ ->remember($this->remember_period);
+
+ $missed_county = ETLAppointment::select(
+ 'county',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome')
+ )
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->groupBy('county')
+ ->remember($this->remember_period);
+
+ $missed_partner = ETLAppointment::select(
+ 'partner',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome')
+ )
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->groupBy('partner')
+ ->remember($this->remember_period);
+
+ $client_app_list = ETLClient::select(
+ 'etl_client_detail.upi_no',
+ 'etl_client_detail.ccc_number',
+ 'etl_client_detail.dob',
+ 'etl_client_detail.consented',
+ 'etl_client_detail.client_status',
+ 'etl_appointment_detail.days_defaulted',
+ 'etl_appointment_detail.final_outcome',
+ 'etl_client_detail.client_name',
+ 'etl_client_detail.phone_no'
+ )
+ ->join('etl_appointment_detail', 'etl_client_detail.client_id', '=', 'etl_appointment_detail.client_id')
+ ->where('etl_client_detail.mfl_code', Auth::user()->facility_id)
+ ->whereNotNull('etl_appointment_detail.final_outcome')
+ ->groupBy('etl_appointment_detail.client_id')
+ ->remember($this->remember_period);
+
+ $app_period = ETLAppointment::select(
+ DB::raw('DATE_FORMAT(appointment_date, "%Y-%M") AS new_date'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('(SUM(app_kept)+SUM(app_not_kept)+SUM(future)) as total_app'),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )->whereNotNull('appointment_date')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->where('appointment_date', '<=', Carbon::now()->format('Y-m-d'))
+ ->where(DB::raw('DATE_FORMAT(appointment_date, "%Y-%M")'), '>=', "2017-January")
+ ->orderBy('appointment_date', 'ASC')
+ ->groupBy('new_date')
+ ->remember($this->remember_period);
+
+ // if ($selected_appointments == 'Missed') {
+ // $app_period = DB::table('etl_appointment_detail')->select(
+ // DB::raw('DATE_FORMAT(appointment_date, "%Y-%M") AS new_date'),
+ // DB::raw('ROUND((( COUNT(CASE WHEN appointment_status = "Missed" THEN app_not_kept END)/(COUNT(appointment_id)) ) * 100 ), 1 ) AS percent_not_kept'),
+ // DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ // // DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ // )->whereNotNull('appointment_date')
+ // ->where('mfl_code', Auth::user()->facility_id)
+ // ->where('appointment_date', '<=', date("Y-M-D"))
+ // ->where(DB::raw('DATE_FORMAT(appointment_date, "%Y-%M")'), '>=', "2017-January")
+ // ->orderBy('appointment_date', 'ASC')
+ // ->groupBy('new_date');
+ // }
+
+ if (!empty($selected_partners)) {
+ $all_appoinments = $all_appoinments->where('partner_id', $selected_partners);
+ $consented_clients = $consented_clients->where('partner_id', $selected_partners);
+ $all_tx_curr = $all_tx_curr->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_gender = $appointment_gender->where('partner_id', $selected_partners);
+ $appointment_age = $appointment_age->where('partner_id', $selected_partners);
+ $appointment_marital = $appointment_marital->where('partner_id', $selected_partners);
+ $appointment_county = $appointment_county->where('partner_id', $selected_partners);
+ $appointment_partner = $appointment_partner->where('partner_id', $selected_partners);
+ $appointment_facility = $appointment_facility->where('partner_id', $selected_partners);
+ $client_list = $client_list->where('partner_id', $selected_partners);
+ $client_missed = $client_missed->where('partner_id', $selected_partners);
+ $missed_age = $missed_age->where('partner_id', $selected_partners);
+ $missed_gender = $missed_gender->where('partner_id', $selected_partners);
+ $missed_marital = $missed_marital->where('partner_id', $selected_partners);
+ $missed_county = $missed_county->where('partner_id', $selected_partners);
+ $missed_partner = $missed_partner->where('partner_id', $selected_partners);
+ $client_app_list = $client_app_list->where('partner_id', $selected_partners);
+ $app_period = $app_period->where('partner_id', $selected_partners);
+ }
+ if (!empty($selected_counties)) {
+ $all_appoinments = $all_appoinments->where('county_id', $selected_counties);
+ $consented_clients = $consented_clients->where('county_id', $selected_counties);
+ $all_tx_curr = $all_tx_curr->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_gender = $appointment_gender->where('county_id', $selected_counties);
+ $appointment_age = $appointment_age->where('county_id', $selected_counties);
+ $appointment_marital = $appointment_marital->where('county_id', $selected_counties);
+ $appointment_county = $appointment_county->where('county_id', $selected_counties);
+ $appointment_partner = $appointment_partner->where('county_id', $selected_counties);
+ $appointment_facility = $appointment_facility->where('county_id', $selected_counties);
+ $client_list = $client_list->where('county_id', $selected_counties);
+ $client_missed = $client_missed->where('county_id', $selected_counties);
+ $missed_age = $missed_age->where('county_id', $selected_counties);
+ $missed_gender = $missed_gender->where('county_id', $selected_counties);
+ $missed_marital = $missed_marital->where('county_id', $selected_counties);
+ $missed_county = $missed_county->where('county_id', $selected_counties);
+ $missed_partner = $missed_partner->where('county_id', $selected_counties);
+ $client_app_list = $client_app_list->where('county_id', $selected_counties);
+ $app_period = $app_period->where('county_id', $selected_counties);
+ }
+ if (!empty($selected_subcounties)) {
+ $all_appoinments = $all_appoinments->where('subcounty_id', $selected_subcounties);
+ $consented_clients = $consented_clients->where('subcounty_id', $selected_subcounties);
+ $all_tx_curr = $all_tx_curr->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_gender = $appointment_gender->where('subcounty_id', $selected_subcounties);
+ $appointment_age = $appointment_age->where('subcounty_id', $selected_subcounties);
+ $appointment_marital = $appointment_marital->where('subcounty_id', $selected_subcounties);
+ $appointment_county = $appointment_county->where('subcounty_id', $selected_subcounties);
+ $appointment_partner = $appointment_partner->where('subcounty_id', $selected_subcounties);
+ $appointment_facility = $appointment_facility->where('subcounty_id', $selected_subcounties);
+ $client_list = $client_list->where('subcounty_id', $selected_subcounties);
+ $client_missed = $client_missed->where('subcounty_id', $selected_subcounties);
+ $missed_age = $missed_age->where('subcounty_id', $selected_subcounties);
+ $missed_gender = $missed_gender->where('subcounty_id', $selected_subcounties);
+ $missed_marital = $missed_marital->where('subcounty_id', $selected_subcounties);
+ $missed_county = $missed_county->where('subcounty_id', $selected_subcounties);
+ $missed_partner = $missed_partner->where('subcounty_id', $selected_subcounties);
+ $client_app_list = $client_app_list->where('subcounty_id', $selected_subcounties);
+ $app_period = $app_period->where('subcounty_id', $selected_subcounties);
+ }
+ if (!empty($selected_facilites)) {
+ $all_appoinments = $all_appoinments->where('mfl_code', $selected_facilites);
+ $consented_clients = $consented_clients->where('mfl_code', $selected_facilites);
+ $all_tx_curr = $all_tx_curr->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_gender = $appointment_gender->where('mfl_code', $selected_facilites);
+ $appointment_age = $appointment_age->where('mfl_code', $selected_facilites);
+ $appointment_marital = $appointment_marital->where('mfl_code', $selected_facilites);
+ $appointment_county = $appointment_county->where('mfl_code', $selected_facilites);
+ $appointment_partner = $appointment_partner->where('mfl_code', $selected_facilites);
+ $appointment_facility = $appointment_facility->where('mfl_code', $selected_facilites);
+ $client_list = $client_list->where('mfl_code', $selected_facilites);
+ $client_missed = $client_missed->where('mfl_code', $selected_facilites);
+ $missed_age = $missed_age->where('mfl_code', $selected_facilites);
+ $missed_gender = $missed_gender->where('mfl_code', $selected_facilites);
+ $missed_marital = $missed_marital->where('mfl_code', $selected_facilites);
+ $missed_county = $missed_county->where('mfl_code', $selected_facilites);
+ $missed_partner = $missed_partner->where('mfl_code', $selected_facilites);
+ $client_app_list = $client_app_list->where('mfl_code', $selected_facilites);
+ $app_period = $app_period->where('mfl_code', $selected_facilites);
+ }
+
+ if (!empty($selected_clinics)) {
+ $all_appoinments = $all_appoinments->where('clinic_type', $selected_clinics);
+ $consented_clients = $consented_clients->where('clinic_type', $selected_clinics);
+ $all_tx_curr = $all_tx_curr;
+ $appointment_gender = $appointment_gender->where('clinic_type', $selected_clinics);
+ $appointment_age = $appointment_age->where('clinic_type', $selected_clinics);
+ $appointment_marital = $appointment_marital->where('clinic_type', $selected_clinics);
+ $appointment_county = $appointment_county->where('clinic_type', $selected_clinics);
+ $appointment_partner = $appointment_partner->where('clinic_type', $selected_clinics);
+ $appointment_facility = $appointment_facility->where('clinic_type', $selected_clinics);
+ $client_list = $client_list->where('etl_client_detail.clinic_type', $selected_clinics);
+ $client_missed = $client_missed->where('clinic_type', $selected_clinics);
+ $missed_age = $missed_age->where('clinic_type', $selected_clinics);
+ $missed_gender = $missed_gender->where('clinic_type', $selected_clinics);
+ $missed_marital = $missed_marital->where('clinic_type', $selected_clinics);
+ $missed_county = $missed_county->where('clinic_type', $selected_clinics);
+ $missed_partner = $missed_partner->where('clinic_type', $selected_clinics);
+ $client_app_list = $client_app_list->where('etl_client_detail.clinic_type', $selected_clinics);
+ $app_period = $app_period->where('clinic_type', $selected_clinics);
+ }
+ if (!empty($selected_appointments)) {
+ $all_appoinments = $all_appoinments;
+ $consented_clients = $consented_clients;
+ $all_tx_curr = $all_tx_curr;
+ $appointment_gender = $appointment_gender;
+ $appointment_age = $appointment_age;
+ $appointment_marital = $appointment_marital;
+ $appointment_county = $appointment_county;
+ $appointment_partner = $appointment_partner;
+ $appointment_facility = $appointment_facility;
+ $client_list = $client_list;
+ $client_missed = $client_missed->where('appointment_status', $selected_appointments);
+ $missed_age = $missed_age->where('appointment_status', $selected_appointments);
+ $missed_gender = $missed_gender->where('appointment_status', $selected_appointments);
+ $missed_marital = $missed_marital->where('appointment_status', $selected_appointments);
+ $missed_county = $missed_county->where('appointment_status', $selected_appointments);
+ $missed_partner = $missed_partner->where('appointment_status', $selected_appointments);
+ $client_app_list = $client_app_list;
+ $app_period = $app_period->where('appointment_status', $selected_appointments);
+ }
+ if (!empty($selected_from || $selected_to)) {
+ $all_appoinments = $all_appoinments->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $consented_clients = $consented_clients->where('consented_date', '>=', date($request->from))->where('consented_date', '<=', date($request->to));
+ $all_tx_curr = $all_tx_curr;
+ $appointment_gender = $appointment_gender->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $appointment_age = $appointment_age->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $appointment_marital = $appointment_marital->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $appointment_county = $appointment_county->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $appointment_partner = $appointment_partner->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $appointment_facility = $appointment_facility->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $client_list = $client_list;
+ $client_missed = $client_missed->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $missed_age = $missed_age->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $missed_gender = $missed_gender->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $missed_marital = $missed_marital->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $missed_county = $missed_county->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $missed_partner = $missed_partner->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $client_app_list = $client_app_list;
+ $app_period = $app_period->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ }
+
+ if (!empty($selected_sites)) {
+ $all_appoinments = $all_appoinments->where('facility_type', $selected_sites);
+ $consented_clients = $consented_clients->where('facility_type', $selected_sites);
+ $all_tx_curr = $all_tx_curr->join('etl_client_detail', 'tbl_tx_cur.mfl_code', '=', 'etl_client_detail.mfl_code')->where('etl_client_detail.facility_type', '=', 'EMR Based')->groupBy('etl_client_detail.mfl_code');
+ $appointment_gender = $appointment_gender->where('facility_type', $selected_sites);
+ $appointment_age = $appointment_age->where('facility_type', $selected_sites);
+ $appointment_marital = $appointment_marital->where('facility_type', $selected_sites);
+ $appointment_county = $appointment_county->where('facility_type', $selected_sites);
+ $appointment_partner = $appointment_partner->where('facility_type', $selected_sites);
+ $appointment_facility = $appointment_facility->where('facility_type', $selected_sites);
+ $client_list = $client_list->where('facility_type', $selected_sites);
+ $client_missed = $client_missed->where('facility_type', $selected_sites);
+ $missed_age = $missed_age->where('facility_type', $selected_sites);
+ $missed_gender = $missed_gender->where('facility_type', $selected_sites);
+ $missed_marital = $missed_marital->where('facility_type', $selected_sites);
+ $missed_county = $missed_county->where('facility_type', $selected_sites);
+ $missed_partner = $missed_partner->where('facility_type', $selected_sites);
+ $client_app_list = $client_app_list->where('facility_type', $selected_sites);
+ $app_period = $app_period->where('facility_type', $selected_sites);
+ }
+
+ $data["all_appoinments"] = $all_appoinments->get();
+ $data["consented_clients"] = $consented_clients->get();
+ $data["all_tx_curr"] = $all_tx_curr->get();
+ $data["appointment_gender"] = $appointment_gender->get();
+ $data["appointment_age"] = $appointment_age->get();
+ $data["appointment_marital"] = $appointment_marital->get();
+ $data["appointment_county"] = $appointment_county->get();
+ $data["appointment_partner"] = $appointment_partner->get();
+ $data["appointment_facility"] = $appointment_facility->get();
+ $data["client_list"] = $client_list->get();
+ $data["client_missed"] = $client_missed->get();
+ $data["missed_age"] = $missed_age->get();
+ $data["missed_gender"] = $missed_gender->get();
+ $data["missed_marital"] = $missed_marital->get();
+ $data["missed_county"] = $missed_county->get();
+ $data["missed_partner"] = $missed_partner->get();
+ $data["client_app_list"] = $client_app_list->get();
+ $data["app_period"] = $app_period->get();
+
+ return $data;
+ }
+ if (Auth::user()->access_level == 'Partner') {
+
+ $selected_partners = $request->partners;
+ $selected_counties = $request->counties;
+ $selected_subcounties = $request->subcounties;
+ $selected_facilites = $request->facilities;
+ $selected_clinics = $request->clinics;
+ $selected_appointments = $request->appointments;
+ $selected_from = $request->from;
+ $selected_to = $request->to;
+ $selected_site = $request->sites;
+ $data = [];
+
+ $all_appoinments = ETLAppointment::select(
+ DB::raw('(SUM(app_kept)+SUM(app_not_kept)+SUM(future)) as total_app'),
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(future) AS future '),
+ DB::raw('SUM(received_sms) AS messages '),
+ DB::raw('AVG(percent_kept) AS percent_kept '),
+ DB::raw('AVG(percent_not_kept) AS percent_not_kept '),
+ DB::raw('AVG(percent_future) AS percent_future ')
+ )
+ ->where('partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ $consented_clients = ETLClient::select(
+ DB::raw('SUM(CASE WHEN consented = "Yes" THEN 1 ELSE 0 END) AS consented '),
+ DB::raw('AVG(percent_consented) AS percent_consented ')
+ )
+ ->where('partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ $all_tx_curr = Txcurr::select(DB::raw('SUM(tbl_tx_cur.tx_cur) as tx_cur'))
+ ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ $appointment_gender = ETLAppointment::select(
+ 'gender',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('gender')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->groupBy('gender')
+ ->remember($this->remember_period);
+
+ $appointment_age = ETLAppointment::select(
+ 'age_group',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('age_group')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->groupBy('age_group')
+ ->remember($this->remember_period);
+
+ $appointment_marital = ETLAppointment::select(
+ 'marital',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('marital')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->groupBy('marital')
+ ->remember($this->remember_period);
+
+ $appointment_county = ETLAppointment::select(
+ 'county',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+
+ )
+ ->where('partner_id', Auth::user()->partner_id)
+ ->groupBy('county')
+ ->remember($this->remember_period);
+
+ $appointment_partner = ETLAppointment::select(
+ 'partner',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app ')
+ )
+ ->where('partner_id', Auth::user()->partner_id)
+ ->groupBy('partner')
+ ->remember($this->remember_period);
+
+ $appointment_facility = ETLAppointment::select(
+ 'facility',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->where('partner_id', Auth::user()->partner_id)
+ ->groupBy('facility')
+ ->remember($this->remember_period);
+
+ $client_list = ETLClient::select(
+ DB::raw('COUNT(ccc_number) AS ccc_number ')
+ )
+ ->where('partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ // missed appointment
+ $client_missed = ETLAppointment::selectRaw('
+ SUM(CASE WHEN app_not_kept = 1 THEN 1 ELSE 0 END) AS not_kept_app,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN received_sms END) AS messages,
+ SUM(CASE WHEN received_sms = 1 AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_messages,
+ SUM(CASE WHEN received_sms = 1 AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_messages,
+ SUM(CASE WHEN received_sms = 1 AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_messages,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN called END) AS called,
+ SUM(CASE WHEN called = 1 AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_called,
+ SUM(CASE WHEN called = 1 AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_called,
+ SUM(CASE WHEN called = 1 AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_called,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN physically_traced END) AS physically_traced,
+ SUM(CASE WHEN physically_traced = 1 AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_traced,
+ SUM(CASE WHEN physically_traced = 1 AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_traced,
+ SUM(CASE WHEN physically_traced = 1 AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_traced,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN rtc_no END) AS final_outcome,
+ SUM(CASE WHEN final_outcome = "Client returned to care" AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_outcome,
+ SUM(CASE WHEN final_outcome = "Client returned to care" AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_outcome,
+ SUM(CASE WHEN final_outcome = "Client returned to care" AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_outcome,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN consent_no END) AS consent,
+ SUM(CASE WHEN consent = "Yes" AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_consent,
+ SUM(CASE WHEN consent = "Yes" AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_consent,
+ SUM(CASE WHEN consent = "Yes" AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_consent '
+ )
+ ->where('partner_id', Auth::user()->partner_id)
+ ->groupBy('client_id')
+ ->remember($this->remember_period);
+
+ $missed_age = ETLAppointment::select(
+ 'age_group',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('age_group')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->groupBy('age_group')
+ ->remember($this->remember_period);
+
+ $missed_gender = ETLAppointment::select(
+ 'gender',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('gender')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->groupBy('gender')
+ ->remember($this->remember_period);
+
+ $missed_marital = ETLAppointment::select(
+ 'marital',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('marital')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->groupBy('marital')
+ ->remember($this->remember_period);
+
+ $missed_county = ETLAppointment::select(
+ 'county',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome')
+ )
+ ->where('partner_id', Auth::user()->partner_id)
+ ->groupBy('county')
+ ->remember($this->remember_period);
+
+ $missed_partner = ETLAppointment::select(
+ 'partner',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome')
+ )
+ ->where('partner_id', Auth::user()->partner_id)
+ ->groupBy('partner')
+ ->remember($this->remember_period);
+
+ $missed_facility = ETLAppointment::select(
+ 'facility',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->where('partner_id', Auth::user()->partner_id)
+ ->whereNotNull('facility')
+ ->groupBy('facility')
+ ->remember($this->remember_period);
+
+ $client_app_list = ETLClient::select(
+ DB::raw('COUNT(ccc_number) AS ccc_number ')
+ )->remember($this->remember_period);
+
+ $app_period = ETLAppointment::select(
+ DB::raw('DATE_FORMAT(appointment_date, "%Y-%M") AS new_date'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('(SUM(app_kept)+SUM(app_not_kept)+SUM(future)) as total_app'),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )->whereNotNull('appointment_date')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->where('appointment_date', '<=', Carbon::now()->format('Y-m-d'))
+ ->where(DB::raw('DATE_FORMAT(appointment_date, "%Y-%M")'), '>=', "2017-January")
+ ->orderBy('appointment_date', 'ASC')
+ ->groupBy('new_date')
+ ->remember($this->remember_period);
+
+ if (!empty($selected_partners)) {
+ $all_appoinments = $all_appoinments->where('partner_id', $selected_partners);
+ $consented_clients = $consented_clients->where('partner_id', $selected_partners);
+ $all_tx_curr = $all_tx_curr->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_gender = $appointment_gender->where('partner_id', $selected_partners);
+ $appointment_age = $appointment_age->where('partner_id', $selected_partners);
+ $appointment_marital = $appointment_marital->where('partner_id', $selected_partners);
+ $appointment_county = $appointment_county->where('partner_id', $selected_partners);
+ $appointment_partner = $appointment_partner->where('partner_id', $selected_partners);
+ $appointment_facility = $appointment_facility->where('partner_id', $selected_partners);
+ $client_list = $client_list->where('partner_id', $selected_partners);
+ $client_missed = $client_missed->where('partner_id', $selected_partners);
+ $missed_age = $missed_age->where('partner_id', $selected_partners);
+ $missed_gender = $missed_gender->where('partner_id', $selected_partners);
+ $missed_marital = $missed_marital->where('partner_id', $selected_partners);
+ $missed_county = $missed_county->where('partner_id', $selected_partners);
+ $missed_partner = $missed_partner->where('partner_id', $selected_partners);
+ $missed_facility = $missed_facility->where('partner_id', $selected_partners);
+ $client_app_list = $client_app_list->where('partner_id', $selected_partners);
+ $app_period = $app_period->where('partner_id', $selected_partners);
+ }
+ if (!empty($selected_counties)) {
+ $all_appoinments = $all_appoinments->where('county_id', $selected_counties);
+ $consented_clients = $consented_clients->where('county_id', $selected_counties);
+ $all_tx_curr = $all_tx_curr->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_gender = $appointment_gender->where('county_id', $selected_counties);
+ $appointment_age = $appointment_age->where('county_id', $selected_counties);
+ $appointment_marital = $appointment_marital->where('county_id', $selected_counties);
+ $appointment_county = $appointment_county->where('county_id', $selected_counties);
+ $appointment_partner = $appointment_partner->where('county_id', $selected_counties);
+ $appointment_facility = $appointment_facility->where('county_id', $selected_counties);
+ $client_list = $client_list->where('county_id', $selected_counties);
+ $client_missed = $client_missed->where('county_id', $selected_counties);
+ $missed_age = $missed_age->where('county_id', $selected_counties);
+ $missed_gender = $missed_gender->where('county_id', $selected_counties);
+ $missed_marital = $missed_marital->where('county_id', $selected_counties);
+ $missed_county = $missed_county->where('county_id', $selected_counties);
+ $missed_partner = $missed_partner->where('county_id', $selected_counties);
+ $missed_facility = $missed_facility->where('county_id', $selected_counties);
+ $client_app_list = $client_app_list->where('county_id', $selected_counties);
+ $app_period = $app_period->where('county_id', $selected_counties);
+ }
+ if (!empty($selected_subcounties)) {
+ $all_appoinments = $all_appoinments->where('subcounty_id', $selected_subcounties);
+ $consented_clients = $consented_clients->where('subcounty_id', $selected_subcounties);
+ $all_tx_curr = $all_tx_curr->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_gender = $appointment_gender->where('subcounty_id', $selected_subcounties);
+ $appointment_age = $appointment_age->where('subcounty_id', $selected_subcounties);
+ $appointment_marital = $appointment_marital->where('subcounty_id', $selected_subcounties);
+ $appointment_county = $appointment_county->where('subcounty_id', $selected_subcounties);
+ $appointment_partner = $appointment_partner->where('subcounty_id', $selected_subcounties);
+ $appointment_facility = $appointment_facility->where('subcounty_id', $selected_subcounties);
+ $client_list = $client_list->where('subcounty_id', $selected_subcounties);
+ $client_missed = $client_missed->where('subcounty_id', $selected_subcounties);
+ $missed_age = $missed_age->where('subcounty_id', $selected_subcounties);
+ $missed_gender = $missed_gender->where('subcounty_id', $selected_subcounties);
+ $missed_marital = $missed_marital->where('subcounty_id', $selected_subcounties);
+ $missed_county = $missed_county->where('subcounty_id', $selected_subcounties);
+ $missed_partner = $missed_partner->where('subcounty_id', $selected_subcounties);
+ $missed_facility = $missed_facility->where('subcounty_id', $selected_subcounties);
+ $client_app_list = $client_app_list->where('subcounty_id', $selected_subcounties);
+ $app_period = $app_period->where('subcounty_id', $selected_subcounties);
+ }
+ if (!empty($selected_facilites)) {
+ $all_appoinments = $all_appoinments->where('mfl_code', $selected_facilites);
+ $consented_clients = $consented_clients->where('mfl_code', $selected_facilites);
+ $all_tx_curr = $all_tx_curr->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_gender = $appointment_gender->where('mfl_code', $selected_facilites);
+ $appointment_age = $appointment_age->where('mfl_code', $selected_facilites);
+ $appointment_marital = $appointment_marital->where('mfl_code', $selected_facilites);
+ $appointment_county = $appointment_county->where('mfl_code', $selected_facilites);
+ $appointment_partner = $appointment_partner->where('mfl_code', $selected_facilites);
+ $appointment_facility = $appointment_facility->where('mfl_code', $selected_facilites);
+ $client_list = $client_list->where('mfl_code', $selected_facilites);
+ $client_missed = $client_missed->where('mfl_code', $selected_facilites);
+ $missed_age = $missed_age->where('mfl_code', $selected_facilites);
+ $missed_gender = $missed_gender->where('mfl_code', $selected_facilites);
+ $missed_marital = $missed_marital->where('mfl_code', $selected_facilites);
+ $missed_county = $missed_county->where('mfl_code', $selected_facilites);
+ $missed_partner = $missed_partner->where('mfl_code', $selected_facilites);
+ $missed_facility = $missed_facility->where('mfl_code', $selected_facilites);
+ $client_app_list = $client_app_list->where('mfl_code', $selected_facilites);
+ $app_period = $app_period->where('mfl_code', $selected_facilites);
+ }
+
+ if (!empty($selected_clinics)) {
+ $all_appoinments = $all_appoinments->where('clinic_type', $selected_clinics);
+ $consented_clients = $consented_clients->where('clinic_type', $selected_clinics);
+ $all_tx_curr = $all_tx_curr;
+ $appointment_gender = $appointment_gender->where('clinic_type', $selected_clinics);
+ $appointment_age = $appointment_age->where('clinic_type', $selected_clinics);
+ $appointment_marital = $appointment_marital->where('clinic_type', $selected_clinics);
+ $appointment_county = $appointment_county->where('clinic_type', $selected_clinics);
+ $appointment_partner = $appointment_partner->where('clinic_type', $selected_clinics);
+ $appointment_facility = $appointment_facility->where('clinic_type', $selected_clinics);
+ $client_list = $client_list->where('etl_client_detail.clinic_type', $selected_clinics);
+ $client_missed = $client_missed->where('clinic_type', $selected_clinics);
+ $missed_age = $missed_age->where('clinic_type', $selected_clinics);
+ $missed_gender = $missed_gender->where('clinic_type', $selected_clinics);
+ $missed_marital = $missed_marital->where('clinic_type', $selected_clinics);
+ $missed_county = $missed_county->where('clinic_type', $selected_clinics);
+ $missed_partner = $missed_partner->where('clinic_type', $selected_clinics);
+ $missed_facility = $missed_facility->where('clinic_type', $selected_clinics);
+ $client_app_list = $client_app_list->where('etl_client_detail.clinic_type', $selected_clinics);
+ $app_period = $app_period->where('clinic_type', $selected_clinics);
+ }
+ if (!empty($selected_appointments)) {
+ $all_appoinments = $all_appoinments;
+ $consented_clients = $consented_clients;
+ $all_tx_curr = $all_tx_curr;
+ $appointment_gender = $appointment_gender;
+ $appointment_age = $appointment_age;
+ $appointment_marital = $appointment_marital;
+ $appointment_county = $appointment_county;
+ $appointment_partner = $appointment_partner;
+ $appointment_facility = $appointment_facility;
+ $client_list = $client_list;
+ $client_missed = $client_missed->where('appointment_status', $selected_appointments);
+ $missed_age = $missed_age->where('appointment_status', $selected_appointments);
+ $missed_gender = $missed_gender->where('appointment_status', $selected_appointments);
+ $missed_marital = $missed_marital->where('appointment_status', $selected_appointments);
+ $missed_county = $missed_county->where('appointment_status', $selected_appointments);
+ $missed_partner = $missed_partner->where('appointment_status', $selected_appointments);
+ $missed_facility = $missed_facility->where('appointment_status', $selected_appointments);
+ $client_app_list = $client_app_list;
+ $app_period = $app_period->where('appointment_status', $selected_appointments);
+ }
+ if (!empty($selected_from || $selected_to)) {
+ $all_appoinments = $all_appoinments->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $consented_clients = $consented_clients->where('consented_date', '>=', date($request->from))->where('consented_date', '<=', date($request->to));
+ $all_tx_curr = $all_tx_curr;
+ $appointment_gender = $appointment_gender->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $appointment_age = $appointment_age->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $appointment_marital = $appointment_marital->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $appointment_county = $appointment_county->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $appointment_partner = $appointment_partner->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $appointment_facility = $appointment_facility->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $client_list = $client_list;
+ $client_missed = $client_missed->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $missed_age = $missed_age->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $missed_gender = $missed_gender->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $missed_marital = $missed_marital->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $missed_county = $missed_county->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $missed_partner = $missed_partner->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $missed_facility = $missed_facility->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $client_app_list = $client_app_list;
+ $app_period = $app_period->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ }
+
+ if (!empty($selected_site)) {
+ $all_appoinments = $all_appoinments->where('facility_type', $selected_site);
+ $consented_clients = $consented_clients->where('facility_type', $selected_site);
+ $all_tx_curr = $all_tx_curr->join('etl_client_detail', 'tbl_tx_cur.mfl_code', '=', 'etl_client_detail.mfl_code')->where('etl_client_detail.facility_type', $selected_site)->groupBy('etl_client_detail.mfl_code');
+ $appointment_gender = $appointment_gender->where('facility_type', $selected_site);
+ $appointment_age = $appointment_age->where('facility_type', $selected_site);
+ $appointment_marital = $appointment_marital->where('facility_type', $selected_site);
+ $appointment_county = $appointment_county->where('facility_type', $selected_site);
+ $appointment_partner = $appointment_partner->where('facility_type', $selected_site);
+ $appointment_facility = $appointment_facility->where('facility_type', $selected_site);
+ $client_list = $client_list->where('facility_type', $selected_site);
+ $client_missed = $client_missed->where('facility_type', $selected_site);
+ $missed_age = $missed_age->where('facility_type', $selected_site);
+ $missed_gender = $missed_gender->where('facility_type', $selected_site);
+ $missed_marital = $missed_marital->where('facility_type', $selected_site);
+ $missed_county = $missed_county->where('facility_type', $selected_site);
+ $missed_partner = $missed_partner->where('facility_type', $selected_site);
+ $missed_facility = $missed_facility->where('facility_type', $selected_site);
+ $client_app_list = $client_app_list->where('facility_type', $selected_site);
+ $app_period = $app_period->where('facility_type', $selected_site);
+ }
+
+ $data["all_appoinments"] = $all_appoinments->get();
+ $data["consented_clients"] = $consented_clients->get();
+ $data["all_tx_curr"] = $all_tx_curr->get();
+ $data["appointment_gender"] = $appointment_gender->get();
+ $data["appointment_age"] = $appointment_age->get();
+ $data["appointment_marital"] = $appointment_marital->get();
+ $data["appointment_county"] = $appointment_county->get();
+ $data["appointment_partner"] = $appointment_partner->get();
+ $data["appointment_facility"] = $appointment_facility->get();
+ $data["client_list"] = $client_list->get();
+ $data["client_missed"] = $client_missed->get();
+ $data["missed_age"] = $missed_age->get();
+ $data["missed_gender"] = $missed_gender->get();
+ $data["missed_marital"] = $missed_marital->get();
+ $data["missed_county"] = $missed_county->get();
+ $data["missed_partner"] = $missed_partner->get();
+ $data["missed_facility"] = $missed_facility->get();
+ $data["client_app_list"] = $client_app_list->get();
+ $data["app_period"] = $app_period->get();
+
+ return $data;
+ }
+ if (Auth::user()->access_level == 'Sub County') {
+
+ $data = [];
+ $selected_partners = $request->partners;
+ $selected_counties = $request->counties;
+ $selected_subcounties = $request->subcounties;
+ $selected_facilites = $request->facilities;
+ $selected_clinics = $request->clinics;
+ $selected_appointments = $request->appointments;
+ $selected_from = $request->from;
+ $selected_to = $request->to;
+ $selected_sites = $request->sites;
+
+ $all_appoinments = ETLAppointment::select(
+ DB::raw('(SUM(app_kept)+SUM(app_not_kept)+SUM(future)) as total_app'),
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(future) AS future '),
+ DB::raw('SUM(received_sms) AS messages '),
+ DB::raw('AVG(percent_kept) AS percent_kept '),
+ DB::raw('AVG(percent_not_kept) AS percent_not_kept '),
+ DB::raw('AVG(percent_future) AS percent_future ')
+ )
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $consented_clients = ETLClient::select(
+ DB::raw('SUM(CASE WHEN consented = "Yes" THEN 1 ELSE 0 END) AS consented '),
+ DB::raw('AVG(percent_consented) AS percent_consented ')
+ )
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $all_tx_curr = Txcurr::select(DB::raw('SUM(tbl_tx_cur.tx_cur) as tx_cur'))
+ ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $appointment_gender = ETLAppointment::select(
+ 'gender',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('gender')
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->groupBy('gender')
+ ->remember($this->remember_period);
+
+ $appointment_age = ETLAppointment::select(
+ 'age_group',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('age_group')
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->groupBy('age_group')
+ ->remember($this->remember_period);
+
+ $appointment_marital = ETLAppointment::select(
+ 'marital',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('marital')
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->groupBy('marital')
+ ->remember($this->remember_period);
+
+ $appointment_county = ETLAppointment::select(
+ 'county',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app ')
+ )
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->groupBy('county')
+ ->remember($this->remember_period);
+
+ $appointment_partner = ETLAppointment::select(
+ 'partner',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->groupBy('partner')
+ ->remember($this->remember_period);
+
+ $appointment_facility = ETLAppointment::select(
+ 'facility',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->groupBy('facility')
+ ->remember($this->remember_period);
+
+ $client_list = ETLClient::select(
+ DB::raw('COUNT(ccc_number) AS ccc_number ')
+ )
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ // missed appointment
+ $client_missed = ETLAppointment::selectRaw('
+ SUM(CASE WHEN app_not_kept = 1 THEN 1 ELSE 0 END) AS not_kept_app,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN received_sms END) AS messages,
+ SUM(CASE WHEN received_sms = 1 AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_messages,
+ SUM(CASE WHEN received_sms = 1 AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_messages,
+ SUM(CASE WHEN received_sms = 1 AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_messages,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN called END) AS called,
+ SUM(CASE WHEN called = 1 AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_called,
+ SUM(CASE WHEN called = 1 AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_called,
+ SUM(CASE WHEN called = 1 AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_called,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN physically_traced END) AS physically_traced,
+ SUM(CASE WHEN physically_traced = 1 AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_traced,
+ SUM(CASE WHEN physically_traced = 1 AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_traced,
+ SUM(CASE WHEN physically_traced = 1 AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_traced,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN rtc_no END) AS final_outcome,
+ SUM(CASE WHEN final_outcome = "Client returned to care" AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_outcome,
+ SUM(CASE WHEN final_outcome = "Client returned to care" AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_outcome,
+ SUM(CASE WHEN final_outcome = "Client returned to care" AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_outcome,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN consent_no END) AS consent,
+ SUM(CASE WHEN consent = "Yes" AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_consent,
+ SUM(CASE WHEN consent = "Yes" AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_consent,
+ SUM(CASE WHEN consent = "Yes" AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_consent '
+ )
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->groupBy('client_id')
+ ->remember($this->remember_period);
+
+ $missed_age = ETLAppointment::select(
+ 'age_group',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('age_group')
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->groupBy('age_group')
+ ->remember($this->remember_period);
+
+ $missed_gender = ETLAppointment::select(
+ 'gender',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('gender')
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->groupBy('gender')
+ ->remember($this->remember_period);
+
+ $missed_marital = ETLAppointment::select(
+ 'marital',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('marital')
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->groupBy('marital')
+ ->remember($this->remember_period);
+
+ $missed_county = ETLAppointment::select(
+ 'county',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome')
+ )
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->groupBy('county')
+ ->remember($this->remember_period);
+
+ $missed_partner = ETLAppointment::select(
+ 'partner',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('AVG(percent_rtc) AS percent_rtc '),
+ DB::raw('AVG(percent_not_kept) AS percent_not_kept ')
+ )
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->groupBy('partner')
+ ->remember($this->remember_period);
+
+ $missed_facility = ETLAppointment::select(
+ 'facility',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->whereNotNull('facility')
+ ->groupBy('facility')
+ ->remember($this->remember_period);
+
+ $client_app_list = ETLClient::select(
+ DB::raw('COUNT(ccc_number) AS ccc_number ')
+ )->remember($this->remember_period);
+
+ $app_period = ETLAppointment::select(
+ DB::raw('DATE_FORMAT(appointment_date, "%Y-%M") AS new_date'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('(SUM(app_kept)+SUM(app_not_kept)+SUM(future)) as total_app'),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )->whereNotNull('appointment_date')
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->where('appointment_date', '<=', Carbon::now()->format('Y-m-d'))
+ ->where(DB::raw('DATE_FORMAT(appointment_date, "%Y-%M")'), '>=', "2017-January")
+ ->orderBy('appointment_date', 'ASC')
+ ->groupBy('new_date')
+ ->remember($this->remember_period);
+
+ if (!empty($selected_partners)) {
+ $all_appoinments = $all_appoinments->where('partner_id', $selected_partners);
+ $consented_clients = $consented_clients->where('partner_id', $selected_partners);
+ $all_tx_curr = $all_tx_curr->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_gender = $appointment_gender->where('partner_id', $selected_partners);
+ $appointment_age = $appointment_age->where('partner_id', $selected_partners);
+ $appointment_marital = $appointment_marital->where('partner_id', $selected_partners);
+ $appointment_county = $appointment_county->where('partner_id', $selected_partners);
+ $appointment_partner = $appointment_partner->where('partner_id', $selected_partners);
+ $appointment_facility = $appointment_facility->where('partner_id', $selected_partners);
+ $client_list = $client_list->where('partner_id', $selected_partners);
+ $client_missed = $client_missed->where('partner_id', $selected_partners);
+ $missed_age = $missed_age->where('partner_id', $selected_partners);
+ $missed_gender = $missed_gender->where('partner_id', $selected_partners);
+ $missed_marital = $missed_marital->where('partner_id', $selected_partners);
+ $missed_county = $missed_county->where('partner_id', $selected_partners);
+ $missed_partner = $missed_partner->where('partner_id', $selected_partners);
+ $missed_facility = $missed_facility->where('partner_id', $selected_partners);
+ $client_app_list = $client_app_list->where('partner_id', $selected_partners);
+ $app_period = $app_period->where('partner_id', $selected_partners);
+ }
+ if (!empty($selected_counties)) {
+ $all_appoinments = $all_appoinments->where('county_id', $selected_counties);
+ $consented_clients = $consented_clients->where('county_id', $selected_counties);
+ $all_tx_curr = $all_tx_curr->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_gender = $appointment_gender->where('county_id', $selected_counties);
+ $appointment_age = $appointment_age->where('county_id', $selected_counties);
+ $appointment_marital = $appointment_marital->where('county_id', $selected_counties);
+ $appointment_county = $appointment_county->where('county_id', $selected_counties);
+ $appointment_partner = $appointment_partner->where('county_id', $selected_counties);
+ $appointment_facility = $appointment_facility->where('county_id', $selected_counties);
+ $client_list = $client_list->where('county_id', $selected_counties);
+ $client_missed = $client_missed->where('county_id', $selected_counties);
+ $missed_age = $missed_age->where('county_id', $selected_counties);
+ $missed_gender = $missed_gender->where('county_id', $selected_counties);
+ $missed_marital = $missed_marital->where('county_id', $selected_counties);
+ $missed_county = $missed_county->where('county_id', $selected_counties);
+ $missed_partner = $missed_partner->where('county_id', $selected_counties);
+ $missed_facility = $missed_facility->where('county_id', $selected_counties);
+ $client_app_list = $client_app_list->where('county_id', $selected_counties);
+ $app_period = $app_period->where('county_id', $selected_counties);
+ }
+ if (!empty($selected_subcounties)) {
+ $all_appoinments = $all_appoinments->where('subcounty_id', $selected_subcounties);
+ $consented_clients = $consented_clients->where('subcounty_id', $selected_subcounties);
+ $all_tx_curr = $all_tx_curr->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_gender = $appointment_gender->where('subcounty_id', $selected_subcounties);
+ $appointment_age = $appointment_age->where('subcounty_id', $selected_subcounties);
+ $appointment_marital = $appointment_marital->where('subcounty_id', $selected_subcounties);
+ $appointment_county = $appointment_county->where('subcounty_id', $selected_subcounties);
+ $appointment_partner = $appointment_partner->where('subcounty_id', $selected_subcounties);
+ $appointment_facility = $appointment_facility->where('subcounty_id', $selected_subcounties);
+ $client_list = $client_list->where('subcounty_id', $selected_subcounties);
+ $client_missed = $client_missed->where('subcounty_id', $selected_subcounties);
+ $missed_age = $missed_age->where('subcounty_id', $selected_subcounties);
+ $missed_gender = $missed_gender->where('subcounty_id', $selected_subcounties);
+ $missed_marital = $missed_marital->where('subcounty_id', $selected_subcounties);
+ $missed_county = $missed_county->where('subcounty_id', $selected_subcounties);
+ $missed_partner = $missed_partner->where('subcounty_id', $selected_subcounties);
+ $missed_facility = $missed_facility->where('subcounty_id', $selected_subcounties);
+ $client_app_list = $client_app_list->where('subcounty_id', $selected_subcounties);
+ $app_period = $app_period->where('subcounty_id', $selected_subcounties);
+ }
+ if (!empty($selected_facilites)) {
+ $all_appoinments = $all_appoinments->where('mfl_code', $selected_facilites);
+ $consented_clients = $consented_clients->where('mfl_code', $selected_facilites);
+ $all_tx_curr = $all_tx_curr->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_gender = $appointment_gender->where('mfl_code', $selected_facilites);
+ $appointment_age = $appointment_age->where('mfl_code', $selected_facilites);
+ $appointment_marital = $appointment_marital->where('mfl_code', $selected_facilites);
+ $appointment_county = $appointment_county->where('mfl_code', $selected_facilites);
+ $appointment_partner = $appointment_partner->where('mfl_code', $selected_facilites);
+ $appointment_facility = $appointment_facility->where('mfl_code', $selected_facilites);
+ $client_list = $client_list->where('mfl_code', $selected_facilites);
+ $client_missed = $client_missed->where('mfl_code', $selected_facilites);
+ $missed_age = $missed_age->where('mfl_code', $selected_facilites);
+ $missed_gender = $missed_gender->where('mfl_code', $selected_facilites);
+ $missed_marital = $missed_marital->where('mfl_code', $selected_facilites);
+ $missed_county = $missed_county->where('mfl_code', $selected_facilites);
+ $missed_partner = $missed_partner->where('mfl_code', $selected_facilites);
+ $missed_facility = $missed_facility->where('mfl_code', $selected_facilites);
+ $client_app_list = $client_app_list->where('mfl_code', $selected_facilites);
+ $app_period = $app_period->where('mfl_code', $selected_facilites);
+ }
+
+ if (!empty($selected_clinics)) {
+ $all_appoinments = $all_appoinments->where('clinic_type', $selected_clinics);
+ $consented_clients = $consented_clients->where('clinic_type', $selected_clinics);
+ $all_tx_curr = $all_tx_curr;
+ $appointment_gender = $appointment_gender->where('clinic_type', $selected_clinics);
+ $appointment_age = $appointment_age->where('clinic_type', $selected_clinics);
+ $appointment_marital = $appointment_marital->where('clinic_type', $selected_clinics);
+ $appointment_county = $appointment_county->where('clinic_type', $selected_clinics);
+ $appointment_partner = $appointment_partner->where('clinic_type', $selected_clinics);
+ $appointment_facility = $appointment_facility->where('clinic_type', $selected_clinics);
+ $client_list = $client_list->where('etl_client_detail.clinic_type', $selected_clinics);
+ $client_missed = $client_missed->where('clinic_type', $selected_clinics);
+ $missed_age = $missed_age->where('clinic_type', $selected_clinics);
+ $missed_gender = $missed_gender->where('clinic_type', $selected_clinics);
+ $missed_marital = $missed_marital->where('clinic_type', $selected_clinics);
+ $missed_county = $missed_county->where('clinic_type', $selected_clinics);
+ $missed_partner = $missed_partner->where('clinic_type', $selected_clinics);
+ $missed_facility = $missed_facility->where('clinic_type', $selected_clinics);
+ $client_app_list = $client_app_list->where('etl_client_detail.clinic_type', $selected_clinics);
+ $app_period = $app_period->where('clinic_type', $selected_clinics);
+ }
+ if (!empty($selected_appointments)) {
+ $all_appoinments = $all_appoinments;
+ $consented_clients = $consented_clients;
+ $all_tx_curr = $all_tx_curr;
+ $appointment_gender = $appointment_gender;
+ $appointment_age = $appointment_age;
+ $appointment_marital = $appointment_marital;
+ $appointment_county = $appointment_county;
+ $appointment_partner = $appointment_partner;
+ $appointment_facility = $appointment_facility;
+ $client_list = $client_list;
+ $client_missed = $client_missed->where('appointment_status', $selected_appointments);
+ $missed_age = $missed_age->where('appointment_status', $selected_appointments);
+ $missed_gender = $missed_gender->where('appointment_status', $selected_appointments);
+ $missed_marital = $missed_marital->where('appointment_status', $selected_appointments);
+ $missed_county = $missed_county->where('appointment_status', $selected_appointments);
+ $missed_partner = $missed_partner->where('appointment_status', $selected_appointments);
+ $missed_facility = $missed_facility->where('appointment_status', $selected_appointments);
+ $client_app_list = $client_app_list;
+ $app_period = $app_period->where('appointment_status', $selected_appointments);
+ }
+ if (!empty($selected_from || $selected_to)) {
+ $all_appoinments = $all_appoinments->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $consented_clients = $consented_clients->where('consented_date', '>=', date($request->from))->where('consented_date', '<=', date($request->to));
+ $all_tx_curr = $all_tx_curr;
+ $appointment_gender = $appointment_gender->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $appointment_age = $appointment_age->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $appointment_marital = $appointment_marital->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $appointment_county = $appointment_county->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $appointment_partner = $appointment_partner->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $appointment_facility = $appointment_facility->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $client_list = $client_list;
+ $client_missed = $client_missed->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $missed_age = $missed_age->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $missed_gender = $missed_gender->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $missed_marital = $missed_marital->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $missed_county = $missed_county->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $missed_partner = $missed_partner->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $missed_facility = $missed_facility->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $client_app_list = $client_app_list;
+ $app_period = $app_period->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ }
+
+ if (!empty($selected_sites)) {
+ $all_appoinments = $all_appoinments->where('facility_type', $selected_sites);
+ $consented_clients = $consented_clients->where('facility_type', $selected_sites);
+ $all_tx_curr = $all_tx_curr->join('etl_client_detail', 'tbl_tx_cur.mfl_code', '=', 'etl_client_detail.mfl_code')->where('etl_client_detail.facility_type', $selected_sites)->groupBy('etl_client_detail.mfl_code');
+ $appointment_gender = $appointment_gender->where('facility_type', $selected_sites);
+ $appointment_age = $appointment_age->where('facility_type', $selected_sites);
+ $appointment_marital = $appointment_marital->where('facility_type', $selected_sites);
+ $appointment_county = $appointment_county->where('facility_type', $selected_sites);
+ $appointment_partner = $appointment_partner->where('facility_type', $selected_sites);
+ $appointment_facility = $appointment_facility->where('facility_type', $selected_sites);
+ $client_list = $client_list->where('facility_type', $selected_sites);
+ $client_missed = $client_missed->where('facility_type', $selected_sites);
+ $missed_age = $missed_age->where('facility_type', $selected_sites);
+ $missed_gender = $missed_gender->where('facility_type', $selected_sites);
+ $missed_marital = $missed_marital->where('facility_type', $selected_sites);
+ $missed_county = $missed_county->where('facility_type', $selected_sites);
+ $missed_partner = $missed_partner->where('facility_type', $selected_sites);
+ $missed_facility = $missed_facility->where('facility_type', $selected_sites);
+ $client_app_list = $client_app_list->where('facility_type', $selected_sites);
+ $app_period = $app_period->where('facility_type', $selected_sites);
+ }
+
+ $data["all_appoinments"] = $all_appoinments->get();
+ $data["consented_clients"] = $consented_clients->get();
+ $data["all_tx_curr"] = $all_tx_curr->get();
+ $data["appointment_gender"] = $appointment_gender->get();
+ $data["appointment_age"] = $appointment_age->get();
+ $data["appointment_marital"] = $appointment_marital->get();
+ $data["appointment_county"] = $appointment_county->get();
+ $data["appointment_partner"] = $appointment_partner->get();
+ $data["appointment_facility"] = $appointment_facility->get();
+ $data["client_list"] = $client_list->get();
+ $data["client_missed"] = $client_missed->get();
+ $data["missed_age"] = $missed_age->get();
+ $data["missed_gender"] = $missed_gender->get();
+ $data["missed_marital"] = $missed_marital->get();
+ $data["missed_county"] = $missed_county->get();
+ $data["missed_partner"] = $missed_partner->get();
+ $data["missed_facility"] = $missed_facility->get();
+ $data["client_app_list"] = $client_app_list->get();
+ $data["app_period"] = $app_period->get();
+
+ return $data;
+ }
+ if (Auth::user()->access_level == 'County') {
+
+ $data = [];
+ $selected_partners = $request->partners;
+ $selected_counties = $request->counties;
+ $selected_subcounties = $request->subcounties;
+ $selected_facilites = $request->facilities;
+ $selected_clinics = $request->clinics;
+ $selected_appointments = $request->appointments;
+ $selected_from = $request->from;
+ $selected_to = $request->to;
+ $selected_sites = $request->sites;
+
+ $all_appoinments = ETLAppointment::select(
+ DB::raw('(SUM(app_kept)+SUM(app_not_kept)+SUM(future)) as total_app'),
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(future) AS future '),
+ DB::raw('SUM(received_sms) AS messages '),
+ DB::raw('AVG(percent_kept) AS percent_kept '),
+ DB::raw('AVG(percent_not_kept) AS percent_not_kept '),
+ DB::raw('AVG(percent_future) AS percent_future ')
+ )
+ ->where('county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $consented_clients = ETLClient::select(
+ DB::raw('SUM(CASE WHEN consented = "Yes" THEN 1 ELSE 0 END) AS consented '),
+ DB::raw('AVG(percent_consented) AS percent_consented ')
+ )
+ ->where('county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $all_tx_curr = Txcurr::select(DB::raw('SUM(tbl_tx_cur.tx_cur) as tx_cur'))
+ ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $appointment_gender = ETLAppointment::select(
+ 'gender',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('gender')
+ ->where('county_id', Auth::user()->county_id)
+ ->groupBy('gender')
+ ->remember($this->remember_period);
+
+ $appointment_age = ETLAppointment::select(
+ 'age_group',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('age_group')
+ ->where('county_id', Auth::user()->county_id)
+ ->groupBy('age_group')
+ ->remember($this->remember_period);
+
+ $appointment_marital = ETLAppointment::select(
+ 'marital',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('marital')
+ ->where('county_id', Auth::user()->county_id)
+ ->groupBy('marital')
+ ->remember($this->remember_period);
+
+ $appointment_county = ETLAppointment::select(
+ 'county',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app ')
+ )
+ ->where('county_id', Auth::user()->county_id)
+ ->groupBy('county')
+ ->remember($this->remember_period);
+
+ $appointment_partner = ETLAppointment::select(
+ 'partner',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('partner')
+ ->where('county_id', Auth::user()->county_id)
+ ->groupBy('partner')
+ ->remember($this->remember_period);
+
+ $appointment_facility = ETLAppointment::select(
+ 'facility',
+ DB::raw('SUM(app_kept) AS kept_app '),
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('ROUND(AVG(percent_kept),1) AS percent_kept '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('facility')
+ ->where('county_id', Auth::user()->county_id)
+ ->groupBy('facility')
+ ->remember($this->remember_period);
+
+ $client_list = ETLClient::select(
+ DB::raw('COUNT(ccc_number) AS ccc_number ')
+ )
+ ->where('county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ // missed appointment
+ $client_missed = ETLAppointment::selectRaw('
+ SUM(CASE WHEN app_not_kept = 1 THEN 1 ELSE 0 END) AS not_kept_app,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN received_sms END) AS messages,
+ SUM(CASE WHEN received_sms = 1 AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_messages,
+ SUM(CASE WHEN received_sms = 1 AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_messages,
+ SUM(CASE WHEN received_sms = 1 AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_messages,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN called END) AS called,
+ SUM(CASE WHEN called = 1 AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_called,
+ SUM(CASE WHEN called = 1 AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_called,
+ SUM(CASE WHEN called = 1 AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_called,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN physically_traced END) AS physically_traced,
+ SUM(CASE WHEN physically_traced = 1 AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_traced,
+ SUM(CASE WHEN physically_traced = 1 AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_traced,
+ SUM(CASE WHEN physically_traced = 1 AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_traced,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN rtc_no END) AS final_outcome,
+ SUM(CASE WHEN final_outcome = "Client returned to care" AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_outcome,
+ SUM(CASE WHEN final_outcome = "Client returned to care" AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_outcome,
+ SUM(CASE WHEN final_outcome = "Client returned to care" AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_outcome,
+ SUM(CASE WHEN appointment_status = "Missed" OR appointment_status = "Defaulted" OR appointment_status = "IIT" THEN consent_no END) AS consent,
+ SUM(CASE WHEN consent = "Yes" AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_consent,
+ SUM(CASE WHEN consent = "Yes" AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_consent,
+ SUM(CASE WHEN consent = "Yes" AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_consent '
+
+ )
+ ->where('county_id', Auth::user()->county_id)
+ ->groupBy('client_id')
+ ->remember($this->remember_period);
+
+ $missed_age = ETLAppointment::select(
+ 'age_group',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('age_group')
+ ->where('county_id', Auth::user()->county_id)
+ ->groupBy('age_group')
+ ->remember($this->remember_period);
+
+ $missed_gender = ETLAppointment::select(
+ 'gender',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('gender')
+ ->where('county_id', Auth::user()->county_id)
+ ->groupBy('gender')
+ ->remember($this->remember_period);
+
+ $missed_marital = ETLAppointment::select(
+ 'marital',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->whereNotNull('marital')
+ ->where('county_id', Auth::user()->county_id)
+ ->groupBy('marital')
+ ->remember($this->remember_period);
+
+ $missed_county = ETLAppointment::select(
+ 'county',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome')
+ )
+ ->where('county_id', Auth::user()->county_id)
+ ->groupBy('county')
+ ->remember($this->remember_period);
+
+ $missed_partner = ETLAppointment::select(
+ 'partner',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->where('county_id', Auth::user()->county_id)
+ ->groupBy('partner')
+ ->remember($this->remember_period);
+
+ $missed_facility = ETLAppointment::select(
+ 'facility',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN 1 ELSE 0 END) AS final_outcome'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->whereNotNull('facility')
+ ->groupBy('facility')
+ ->remember($this->remember_period);
+
+ $client_app_list = ETLClient::select(
+ DB::raw('COUNT(ccc_number) AS ccc_number ')
+ )->remember($this->remember_period);
+
+ $app_period = ETLAppointment::select(
+ DB::raw('DATE_FORMAT(appointment_date, "%Y-%M") AS new_date'),
+ DB::raw('ROUND(AVG(percent_rtc),1) AS percent_rtc '),
+ DB::raw('(SUM(app_kept)+SUM(app_not_kept)+SUM(future)) as total_app'),
+ DB::raw('ROUND(AVG(percent_not_kept),1) AS percent_not_kept ')
+ )->whereNotNull('appointment_date')
+ ->where('county_id', Auth::user()->county_id)
+ ->where('appointment_date', '<=', Carbon::now()->format('Y-m-d'))
+ ->where(DB::raw('DATE_FORMAT(appointment_date, "%Y-%M")'), '>=', "2017-January")
+ ->orderBy('appointment_date', 'ASC')
+ ->groupBy('new_date')
+ ->remember($this->remember_period);
+
+ if (!empty($selected_partners)) {
+ $all_appoinments = $all_appoinments->where('partner_id', $selected_partners);
+ $consented_clients = $consented_clients->where('partner_id', $selected_partners);
+ $all_tx_curr = $all_tx_curr->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_gender = $appointment_gender->where('partner_id', $selected_partners);
+ $appointment_age = $appointment_age->where('partner_id', $selected_partners);
+ $appointment_marital = $appointment_marital->where('partner_id', $selected_partners);
+ $appointment_county = $appointment_county->where('partner_id', $selected_partners);
+ $appointment_partner = $appointment_partner->where('partner_id', $selected_partners);
+ $appointment_facility = $appointment_facility->where('partner_id', $selected_partners);
+ $client_list = $client_list->where('partner_id', $selected_partners);
+ $client_missed = $client_missed->where('partner_id', $selected_partners);
+ $missed_age = $missed_age->where('partner_id', $selected_partners);
+ $missed_gender = $missed_gender->where('partner_id', $selected_partners);
+ $missed_marital = $missed_marital->where('partner_id', $selected_partners);
+ $missed_county = $missed_county->where('partner_id', $selected_partners);
+ $missed_partner = $missed_partner->where('partner_id', $selected_partners);
+ $missed_facility = $missed_facility->where('partner_id', $selected_partners);
+ $client_app_list = $client_app_list->where('partner_id', $selected_partners);
+ $app_period = $app_period->where('partner_id', $selected_partners);
+ }
+ if (!empty($selected_counties)) {
+ $all_appoinments = $all_appoinments->where('county_id', $selected_counties);
+ $consented_clients = $consented_clients->where('county_id', $selected_counties);
+ $all_tx_curr = $all_tx_curr->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_gender = $appointment_gender->where('county_id', $selected_counties);
+ $appointment_age = $appointment_age->where('county_id', $selected_counties);
+ $appointment_marital = $appointment_marital->where('county_id', $selected_counties);
+ $appointment_county = $appointment_county->where('county_id', $selected_counties);
+ $appointment_partner = $appointment_partner->where('county_id', $selected_counties);
+ $appointment_facility = $appointment_facility->where('county_id', $selected_counties);
+ $client_list = $client_list->where('county_id', $selected_counties);
+ $client_missed = $client_missed->where('county_id', $selected_counties);
+ $missed_age = $missed_age->where('county_id', $selected_counties);
+ $missed_gender = $missed_gender->where('county_id', $selected_counties);
+ $missed_marital = $missed_marital->where('county_id', $selected_counties);
+ $missed_county = $missed_county->where('county_id', $selected_counties);
+ $missed_partner = $missed_partner->where('county_id', $selected_counties);
+ $missed_facility = $missed_facility->where('county_id', $selected_counties);
+ $client_app_list = $client_app_list->where('county_id', $selected_counties);
+ $app_period = $app_period->where('county_id', $selected_counties);
+ }
+ if (!empty($selected_subcounties)) {
+ $all_appoinments = $all_appoinments->where('subcounty_id', $selected_subcounties);
+ $consented_clients = $consented_clients->where('subcounty_id', $selected_subcounties);
+ $all_tx_curr = $all_tx_curr->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_gender = $appointment_gender->where('subcounty_id', $selected_subcounties);
+ $appointment_age = $appointment_age->where('subcounty_id', $selected_subcounties);
+ $appointment_marital = $appointment_marital->where('subcounty_id', $selected_subcounties);
+ $appointment_county = $appointment_county->where('subcounty_id', $selected_subcounties);
+ $appointment_partner = $appointment_partner->where('subcounty_id', $selected_subcounties);
+ $appointment_facility = $appointment_facility->where('subcounty_id', $selected_subcounties);
+ $client_list = $client_list->where('subcounty_id', $selected_subcounties);
+ $client_missed = $client_missed->where('subcounty_id', $selected_subcounties);
+ $missed_age = $missed_age->where('subcounty_id', $selected_subcounties);
+ $missed_gender = $missed_gender->where('subcounty_id', $selected_subcounties);
+ $missed_marital = $missed_marital->where('subcounty_id', $selected_subcounties);
+ $missed_county = $missed_county->where('subcounty_id', $selected_subcounties);
+ $missed_partner = $missed_partner->where('subcounty_id', $selected_subcounties);
+ $missed_facility = $missed_facility->where('subcounty_id', $selected_subcounties);
+ $client_app_list = $client_app_list->where('subcounty_id', $selected_subcounties);
+ $app_period = $app_period->where('subcounty_id', $selected_subcounties);
+ }
+ if (!empty($selected_facilites)) {
+ $all_appoinments = $all_appoinments->where('mfl_code', $selected_facilites);
+ $consented_clients = $consented_clients->where('mfl_code', $selected_facilites);
+ $all_tx_curr = $all_tx_curr->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_gender = $appointment_gender->where('mfl_code', $selected_facilites);
+ $appointment_age = $appointment_age->where('mfl_code', $selected_facilites);
+ $appointment_marital = $appointment_marital->where('mfl_code', $selected_facilites);
+ $appointment_county = $appointment_county->where('mfl_code', $selected_facilites);
+ $appointment_partner = $appointment_partner->where('mfl_code', $selected_facilites);
+ $appointment_facility = $appointment_facility->where('mfl_code', $selected_facilites);
+ $client_list = $client_list->where('mfl_code', $selected_facilites);
+ $client_missed = $client_missed->where('mfl_code', $selected_facilites);
+ $missed_age = $missed_age->where('mfl_code', $selected_facilites);
+ $missed_gender = $missed_gender->where('mfl_code', $selected_facilites);
+ $missed_marital = $missed_marital->where('mfl_code', $selected_facilites);
+ $missed_county = $missed_county->where('mfl_code', $selected_facilites);
+ $missed_partner = $missed_partner->where('mfl_code', $selected_facilites);
+ $missed_facility = $missed_facility->where('mfl_code', $selected_facilites);
+ $client_app_list = $client_app_list->where('mfl_code', $selected_facilites);
+ $app_period = $app_period->where('mfl_code', $selected_facilites);
+ }
+
+ if (!empty($selected_clinics)) {
+ $all_appoinments = $all_appoinments->where('clinic_type', $selected_clinics);
+ $consented_clients = $consented_clients->where('clinic_type', $selected_clinics);
+ $all_tx_curr = $all_tx_curr;
+ $appointment_gender = $appointment_gender->where('clinic_type', $selected_clinics);
+ $appointment_age = $appointment_age->where('clinic_type', $selected_clinics);
+ $appointment_marital = $appointment_marital->where('clinic_type', $selected_clinics);
+ $appointment_county = $appointment_county->where('clinic_type', $selected_clinics);
+ $appointment_partner = $appointment_partner->where('clinic_type', $selected_clinics);
+ $appointment_facility = $appointment_facility->where('clinic_type', $selected_clinics);
+ $client_list = $client_list->where('etl_client_detail.clinic_type', $selected_clinics);
+ $client_missed = $client_missed->where('clinic_type', $selected_clinics);
+ $missed_age = $missed_age->where('clinic_type', $selected_clinics);
+ $missed_gender = $missed_gender->where('clinic_type', $selected_clinics);
+ $missed_marital = $missed_marital->where('clinic_type', $selected_clinics);
+ $missed_county = $missed_county->where('clinic_type', $selected_clinics);
+ $missed_partner = $missed_partner->where('clinic_type', $selected_clinics);
+ $missed_facility = $missed_facility->where('clinic_type', $selected_clinics);
+ $client_app_list = $client_app_list->where('etl_client_detail.clinic_type', $selected_clinics);
+ $app_period = $app_period->where('clinic_type', $selected_clinics);
+ }
+ if (!empty($selected_appointments)) {
+ $all_appoinments = $all_appoinments;
+ $consented_clients = $consented_clients;
+ $all_tx_curr = $all_tx_curr;
+ $appointment_gender = $appointment_gender;
+ $appointment_age = $appointment_age;
+ $appointment_marital = $appointment_marital;
+ $appointment_county = $appointment_county;
+ $appointment_partner = $appointment_partner;
+ $appointment_facility = $appointment_facility;
+ $client_list = $client_list;
+ $client_missed = $client_missed->where('appointment_status', $selected_appointments);
+ $missed_age = $missed_age->where('appointment_status', $selected_appointments);
+ $missed_gender = $missed_gender->where('appointment_status', $selected_appointments);
+ $missed_marital = $missed_marital->where('appointment_status', $selected_appointments);
+ $missed_county = $missed_county->where('appointment_status', $selected_appointments);
+ $missed_partner = $missed_partner->where('appointment_status', $selected_appointments);
+ $missed_facility = $missed_facility->where('appointment_status', $selected_appointments);
+ $client_app_list = $client_app_list;
+ $app_period = $app_period->where('appointment_status', $selected_appointments);
+ }
+ if (!empty($selected_from || $selected_to)) {
+ $all_appoinments = $all_appoinments->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $consented_clients = $consented_clients->where('consented_date', '>=', date($request->from))->where('consented_date', '<=', date($request->to));
+ $all_tx_curr = $all_tx_curr;
+ $appointment_gender = $appointment_gender->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $appointment_age = $appointment_age->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $appointment_marital = $appointment_marital->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $appointment_county = $appointment_county->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $appointment_partner = $appointment_partner->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $appointment_facility = $appointment_facility->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $client_list = $client_list;
+ $client_missed = $client_missed->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $missed_age = $missed_age->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $missed_gender = $missed_gender->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $missed_marital = $missed_marital->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $missed_county = $missed_county->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $missed_partner = $missed_partner->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $missed_facility = $missed_facility->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $client_app_list = $client_app_list;
+ $app_period = $app_period->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ }
+
+ if (!empty($selected_sites)) {
+ $all_appoinments = $all_appoinments->where('facility_type', $selected_sites);
+ $consented_clients = $consented_clients->where('facility_type', $selected_sites);
+ $all_tx_curr = $all_tx_curr->join('etl_client_detail', 'tbl_tx_cur.mfl_code', '=', 'etl_client_detail.mfl_code')->where('etl_client_detail.facility_type', $selected_sites)->groupBy('etl_client_detail.mfl_code');
+ $appointment_gender = $appointment_gender->where('facility_type', $selected_sites);
+ $appointment_age = $appointment_age->where('facility_type', $selected_sites);
+ $appointment_marital = $appointment_marital->where('facility_type', $selected_sites);
+ $appointment_county = $appointment_county->where('facility_type', $selected_sites);
+ $appointment_partner = $appointment_partner->where('facility_type', $selected_sites);
+ $appointment_facility = $appointment_facility->where('facility_type', $selected_sites);
+ $client_list = $client_list->where('facility_type', $selected_sites);
+ $client_missed = $client_missed->where('facility_type', $selected_sites);
+ $missed_age = $missed_age->where('facility_type', $selected_sites);
+ $missed_gender = $missed_gender->where('facility_type', $selected_sites);
+ $missed_marital = $missed_marital->where('facility_type', $selected_sites);
+ $missed_county = $missed_county->where('facility_type', $selected_sites);
+ $missed_partner = $missed_partner->where('facility_type', $selected_sites);
+ $missed_facility = $missed_facility->where('facility_type', $selected_sites);
+ $client_app_list = $client_app_list->where('facility_type', $selected_sites);
+ $app_period = $app_period->where('facility_type', $selected_sites);
+ }
+
+ $data["all_appoinments"] = $all_appoinments->get();
+ $data["consented_clients"] = $consented_clients->get();
+ $data["all_tx_curr"] = $all_tx_curr->get();
+ $data["appointment_gender"] = $appointment_gender->get();
+ $data["appointment_age"] = $appointment_age->get();
+ $data["appointment_marital"] = $appointment_marital->get();
+ $data["appointment_county"] = $appointment_county->get();
+ $data["appointment_partner"] = $appointment_partner->get();
+ $data["appointment_facility"] = $appointment_facility->get();
+ $data["client_list"] = $client_list->get();
+ $data["client_missed"] = $client_missed->get();
+ $data["missed_age"] = $missed_age->get();
+ $data["missed_gender"] = $missed_gender->get();
+ $data["missed_marital"] = $missed_marital->get();
+ $data["missed_county"] = $missed_county->get();
+ $data["missed_partner"] = $missed_partner->get();
+ $data["missed_facility"] = $missed_facility->get();
+ $data["client_app_list"] = $client_app_list->get();
+ $data["app_period"] = $app_period->get();
+
+ return $data;
+ }
+ }
+ public function get_county_facilities(Request $request, $id)
+ {
+ $partner_ids = array();
+ $strings_array = $request->partners;
+ if (!empty($strings_array)) {
+ foreach ($strings_array as $each_id) {
+ $partner_ids[] = (int) $each_id;
+ }
+ }
+ $partners_with_ids = PartnerFacility::select('partner_id')->distinct('partner_id')->groupBy('partner_id')->remember($this->remember_period)->get();
+
+ $facilities = PartnerFacility::join('tbl_master_facility', 'tbl_partner_facility.mfl_code', '=', 'tbl_master_facility.code')
+ ->where("tbl_partner_facility.county_id", $id)
+ ->orderBy('tbl_master_facility.name', 'ASC')
+ ->remember($this->remember_period)
+ ->pluck("tbl_master_facility.name", "tbl_master_facility.code");
+
+ return json_encode($facilities);
+ }
+ public function get_partner_sub_counties($id)
+ {
+ $subcounties = PartnerFacility::join('tbl_sub_county', 'tbl_partner_facility.sub_county_id', '=', 'tbl_sub_county.id')
+ ->where("tbl_partner_facility.partner_id", $id)
+ ->orderBy('tbl_sub_county.name', 'ASC')
+ ->remember($this->remember_period)
+ ->pluck("tbl_sub_county.name", "tbl_sub_county.id");
+
+ if (Auth::user()->access_level == 'Partner') {
+ $subcounties = PartnerFacility::join('tbl_sub_county', 'tbl_partner_facility.sub_county_id', '=', 'tbl_sub_county.id')
+ ->where("tbl_partner_facility.partner_id", $id)
+ ->where("tbl_partner_facility.partner_id", '=', Auth::user()->partner_id)
+ ->orderBy('tbl_sub_county.name', 'ASC')
+ ->remember($this->remember_period)
+ ->pluck("tbl_sub_county.name", "tbl_sub_county.id");
+ }
+ if (Auth::user()->access_level == 'Sub County') {
+ $subcounties = PartnerFacility::join('tbl_sub_county', 'tbl_partner_facility.sub_county_id', '=', 'tbl_sub_county.id')
+ ->where("tbl_partner_facility.partner_id", $id)
+ ->where("tbl_partner_facility.sub_county_id", '=', Auth::user()->subcounty_id)
+ ->orderBy('tbl_sub_county.name', 'ASC')
+ ->remember($this->remember_period)
+ ->pluck("tbl_sub_county.name", "tbl_sub_county.id");
+ }
+ return json_encode($subcounties);
+ }
+ public function get_partner_facilities(Request $request, $id)
+ {
+ $partner_ids = array();
+ $strings_array = $request->partners;
+ if (!empty($strings_array)) {
+ foreach ($strings_array as $each_id) {
+ $partner_ids[] = (int) $each_id;
+ }
+ }
+ $partners_with_ids = PartnerFacility::select('partner_id')->distinct('partner_id')->groupBy('partner_id')->remember($this->remember_period)->get();
+
+ $facilities = PartnerFacility::join('tbl_master_facility', 'tbl_partner_facility.mfl_code', '=', 'tbl_master_facility.code')
+ ->where("tbl_partner_facility.partner_id", $id)
+ // ->where("tbl_partner_facility.partner_id", $id)
+ ->orderBy('tbl_master_facility.name', 'ASC')
+ ->remember($this->remember_period)
+ ->pluck("tbl_master_facility.name", "tbl_master_facility.code");
+
+ if (Auth::user()->access_level == 'Partner') {
+ $facilities = PartnerFacility::join('tbl_master_facility', 'tbl_partner_facility.mfl_code', '=', 'tbl_master_facility.code')
+ ->where("tbl_partner_facility.partner_id", $id)
+ ->where("tbl_partner_facility.partner_id", '=', Auth::user()->partner_id)
+ ->orderBy('tbl_master_facility.name', 'ASC')
+ ->remember($this->remember_period)
+ ->pluck("tbl_master_facility.name", "tbl_master_facility.code");
+ }
+ if (Auth::user()->access_level == 'County') {
+ $facilities = PartnerFacility::join('tbl_master_facility', 'tbl_partner_facility.mfl_code', '=', 'tbl_master_facility.code')
+ ->where("tbl_partner_facility.partner_id", $id)
+ ->where("tbl_partner_facility.county_id", '=', Auth::user()->county_id)
+ ->orderBy('tbl_master_facility.name', 'ASC')
+ ->remember($this->remember_period)
+ ->pluck("tbl_master_facility.name", "tbl_master_facility.code");
+ }
+ if (Auth::user()->access_level == 'Sub County') {
+ $facilities = PartnerFacility::join('tbl_master_facility', 'tbl_partner_facility.mfl_code', '=', 'tbl_master_facility.code')
+ ->where("tbl_partner_facility.partner_id", $id)
+ ->whereIn('tbl_partner_facility.partner_id', $partners_with_ids)
+ ->where("tbl_partner_facility.sub_county_id", '=', Auth::user()->subcounty_id)
+ ->orderBy('tbl_master_facility.name', 'ASC')
+ ->remember($this->remember_period)
+ ->pluck("tbl_master_facility.name", "tbl_master_facility.code");
+ }
+
+ return json_encode($facilities);
+ }
+ public function get_sitetype_facilities(Request $request, $id)
+ {
+ $partner_ids = array();
+ if (!empty($id == 'EMR Based' || $id == 'Paper Based')) {
+ $facilities = PartnerFacility::join('tbl_master_facility', 'tbl_partner_facility.mfl_code', '=', 'tbl_master_facility.code')
+ ->where("tbl_master_facility.site_type", $id)
+ ->orderBy('tbl_master_facility.name', 'ASC')
+ ->remember($this->remember_period)
+ ->pluck("tbl_master_facility.name", "tbl_master_facility.code");
+ }
+
+ if (Auth::user()->access_level == 'Partner') {
+ $facilities = PartnerFacility::join('tbl_master_facility', 'tbl_partner_facility.mfl_code', '=', 'tbl_master_facility.code')
+ ->where("tbl_master_facility.site_type", $id)
+ ->where("tbl_partner_facility.partner_id", '=', Auth::user()->partner_id)
+ ->orderBy('tbl_master_facility.name', 'ASC')
+ ->remember($this->remember_period)
+ ->pluck("tbl_master_facility.name", "tbl_master_facility.code");
+ }
+ if (Auth::user()->access_level == 'County') {
+ $facilities = PartnerFacility::join('tbl_master_facility', 'tbl_partner_facility.mfl_code', '=', 'tbl_master_facility.code')
+ ->where("tbl_master_facility.site_type", $id)
+ ->where("tbl_partner_facility.county_id", '=', Auth::user()->county_id)
+ ->orderBy('tbl_master_facility.name', 'ASC')
+ ->remember($this->remember_period)
+ ->pluck("tbl_master_facility.name", "tbl_master_facility.code");
+ }
+ if (Auth::user()->access_level == 'Sub County') {
+ $facilities = PartnerFacility::join('tbl_master_facility', 'tbl_partner_facility.mfl_code', '=', 'tbl_master_facility.code')
+ ->where("tbl_master_facility.site_type", $id)
+ ->where("tbl_partner_facility.sub_county_id", '=', Auth::user()->subcounty_id)
+ ->orderBy('tbl_master_facility.name', 'ASC')
+ ->remember($this->remember_period)
+ ->pluck("tbl_master_facility.name", "tbl_master_facility.code");
+ }
+
+ return json_encode($facilities);
+ }
+}
diff --git a/app/Http/Controllers/GroupController.php b/app/Http/Controllers/GroupController.php
index 472ce98..015b3ec 100644
--- a/app/Http/Controllers/GroupController.php
+++ b/app/Http/Controllers/GroupController.php
@@ -46,7 +46,8 @@ public function get_pmtct_clients()
{
$all_pmtct_clients = Client::join('tbl_groups', 'tbl_groups.id', '=', 'tbl_client.group_id')
->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.client_status, tbl_client.phone_no, tbl_client.enrollment_date, tbl_groups.name')
- ->where('tbl_client.clinic_id', '=', '2');
+ ->where('tbl_client.clinic_id', '=', '2')
+ ->whereNull('tbl_client.hei_no');
if (Auth::user()->access_level == 'Facility') {
$all_pmtct_clients->where('facility_id', Auth::user()->facility_id);
diff --git a/app/Http/Controllers/MigrationController.php b/app/Http/Controllers/MigrationController.php
new file mode 100644
index 0000000..4aef2e5
--- /dev/null
+++ b/app/Http/Controllers/MigrationController.php
@@ -0,0 +1,47 @@
+select('Outcome_ID AS Outcome_ID')->max('Outcome_ID');
+ // dd($latest_ids);
+
+ // foreach($latest_ids as $latest)
+ // {
+ // // $new_clients = DB::statement('SELECT * FROM partner_outcome_report WHERE Outcome_ID > '$latest->Outcome_ID' ');
+ // $new_clients = DB::table('partner_outcome_report')->select('*')->where('Outcome_ID', '>', $latest->Outcome_ID);
+ // foreach($new_clients as $new_client)
+ // {
+ // // DB::insert('INSERT INTO tbl_outcome_report_raw, $new_client');
+ // DB::table('tbl_outcome_report_raw')->insert($new_client);
+ // }
+ // }
+
+ // $latest_ids = DB::table('partner_outcome_report')->select('*')->get();
+ // DB::table('tbl_outcome_report_raw')->insert($latest_ids);
+
+ $basket_data = DB::table('partner_outcome_report')->distinct('Outcome_ID')->get();
+ foreach ($basket_data as $records) {
+ DB::table('tbl_outcome_report_raw')->insert(get_object_vars($records));
+ }
+ // dd($latest_ids);
+ }
+}
diff --git a/app/Http/Controllers/NewDashboardController.php b/app/Http/Controllers/NewDashboardController.php
new file mode 100644
index 0000000..f50d2c6
--- /dev/null
+++ b/app/Http/Controllers/NewDashboardController.php
@@ -0,0 +1,10434 @@
+remember_period = env('REMEMBER_PERIOD', '60 * 60');
+ }
+
+ public function dashboard()
+ {
+
+ // showing all the active clients, all appointments, missed appointments
+ if (Auth::user()->access_level == 'Facility') {
+ $all_partners = Partner::where('status', '=', 'Active')
+ ->remember($this->remember_period)
+ ->pluck('name', 'id');
+
+ $client = Client::where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->count('clinic_number');
+
+ $client_ever_enrolled = Client::whereNull('hei_no')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->count('clinic_number');
+
+ $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_partner_facility.mfl_code', Auth::user()->facility_id)
+ ->orderBy('tbl_appointment.created_at', 'DESC')
+ ->groupBy('tbl_partner_facility.mfl_code')
+ ->remember($this->remember_period)
+ ->get();
+ $facilities_ever_enrolled = PartnerFacility::remember($this->remember_period)->count('mfl_code');
+
+
+ // dd($active_facilities);
+ // active clients by gender
+ $clients_male = Client::select('id')->where([['gender', '=', '2'], ['status', '=', 'Active'],])
+ ->whereNull('hei_no')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ $clients_female = Client::where('gender', '=', '1')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ $unknown_gender = Client::where('gender', '!=', '1')
+ ->where('gender', '!=', '2')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ $client_to_nine = Client::select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+
+ $client_to_fourteen = Client::select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_to_nineteen = Client::select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+
+ $client_to_twentyfour = Client::select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+
+ $client_to_twentyfive_above = Client::select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `id` end)) AS count"))
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_unknown_age = Client::where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->count();
+ }
+ if (Auth::user()->access_level == 'Partner') {
+ $all_partners = Partner::where('status', '=', 'Active')->where('id', Auth::user()->partner_id)->remember($this->remember_period)->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)
+ ->remember($this->remember_period)
+ ->count('tbl_client.clinic_number');
+
+ $client_ever_enrolled = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period)
+ ->count('tbl_client.clinic_number');
+
+ $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(DB::raw('(SELECT MAX(DATE(tbl_appointment.created_at)) from tbl_appointment)'), '>=', 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')
+ ->remember($this->remember_period)
+ ->get();
+
+ $facilities_ever_enrolled = PartnerFacility::where('partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period)
+ ->count('mfl_code');
+
+ // 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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->count();
+
+ $client_to_nine = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_to_fourteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_to_nineteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_to_twentyfour = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_to_twentyfive_above = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_unknown_age = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period)
+ ->count();
+ }
+ if (Auth::user()->access_level == 'County') {
+ $all_partners = Partner::join('tbl_partner_facility', 'tbl_partner.id', '=', 'tbl_partner_facility.partner_id')->where('tbl_partner.status', '=', 'Active')->where('tbl_partner_facility.county_id', Auth::user()->county_id)->remember($this->remember_period)->pluck('tbl_partner.name', 'tbl_partner.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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->count('tbl_client.clinic_number');
+
+ $client_ever_enrolled = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->count('tbl_client.clinic_number');
+
+ $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(DB::raw('(SELECT MAX(DATE(tbl_appointment.created_at)) from tbl_appointment)'), '>=', Carbon::now()->subMonths(6))
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->orderBy('tbl_appointment.created_at', 'DESC')
+ ->groupBy('tbl_partner_facility.mfl_code')
+ ->remember($this->remember_period)
+ ->get();
+
+ $facilities_ever_enrolled = PartnerFacility::where('county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->count('mfl_code');
+
+ // 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ $client_to_nine = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_to_fourteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_to_nineteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_to_twentyfour = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_to_twentyfive_above = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_unknown_age = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->count();
+ }
+ if (Auth::user()->access_level == 'Sub County') {
+ $all_partners = Partner::join('tbl_partner_facility', 'tbl_partner.id', '=', 'tbl_partner_facility.partner_id')->where('tbl_partner.status', '=', 'Active')->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)->pluck('tbl_partner.name', 'tbl_partner.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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->count('tbl_client.clinic_number');
+
+ $client_ever_enrolled = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->count('tbl_client.clinic_number');
+
+ $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(DB::raw('(SELECT MAX(DATE(tbl_appointment.created_at)) from tbl_appointment)'), '>=', Carbon::now()->subMonths(6))
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->orderBy('tbl_appointment.created_at', 'DESC')
+ ->groupBy('tbl_partner_facility.mfl_code')
+ ->remember($this->remember_period)
+ ->get();
+
+ $facilities_ever_enrolled = PartnerFacility::where('sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->count('mfl_code');
+
+ // 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ $client_to_nine = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_to_fourteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_to_nineteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_to_twentyfour = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_to_twentyfive_above = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_unknown_age = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->count();
+ }
+ if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+
+ $all_partners = Partner::where('status', '=', 'Active')
+ ->orderBy('name', 'ASC')
+ ->remember("$this->remember_period")
+ ->pluck('name', 'id');
+
+ $client = Client::where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->remember("$this->remember_period")
+ ->count('id');
+
+ $client_ever_enrolled = Client::whereNull('hei_no')
+ ->remember("$this->remember_period")
+ ->count('id');
+
+ // $missed_appointment = Appointments::select('id')->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])->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')
+ ->selectRaw('tbl_partner_facility.mfl_code, MAX(DATE(tbl_appointment.created_at)) as max_date')
+ ->where(DB::raw('(SELECT MAX(DATE(tbl_appointment.created_at)) from tbl_appointment)'), '>=', Carbon::now()->subMonths(6))
+ ->orderBy('tbl_appointment.created_at', 'DESC')
+ ->groupBy('tbl_partner_facility.mfl_code')
+ ->remember($this->remember_period)
+ ->get();
+ $facilities_ever_enrolled = PartnerFacility::remember($this->remember_period)->count('mfl_code');
+
+ $clients_male = Client::where([['gender', '=', '2'], ['status', '=', 'Active'],])
+ ->whereNull('hei_no')
+ ->remember($this->remember_period)
+ ->count('id');
+
+ $clients_female = Client::where([['gender', '=', '1'], ['status', '=', 'Active'],])
+ ->whereNull('hei_no')
+ ->remember($this->remember_period)
+ ->count('id');
+
+ $unknown_gender = Client::where([['gender', '!=', '1'], ['gender', '!=', '2'], ['status', '=', 'Active'],])
+ ->whereNull('hei_no')
+ ->remember($this->remember_period)
+ ->count('id');
+
+ $client_to_nine = Client::select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `dob` ) > 0 ) THEN
+ date_format( str_to_date( `dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `dob` ) > 0 ) THEN
+ date_format( str_to_date( `dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 0) and ((year(curdate()) - year(`dob`)) <= 9)) then `dob` end)) AS count"))
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_to_fourteen = Client::select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `dob` ) > 0 ) THEN
+ date_format( str_to_date( `dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `dob` ) > 0 ) THEN
+ date_format( str_to_date( `dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 10) and ((year(curdate()) - year(`dob`)) <= 14)) then `dob` end)) AS count"))
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_to_nineteen = Client::select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `dob` ) > 0 ) THEN
+ date_format( str_to_date( `dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `dob` ) > 0 ) THEN
+ date_format( str_to_date( `dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 15) and ((year(curdate()) - year(`dob`)) <= 19)) then `dob` end)) AS count"))
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_to_twentyfour = Client::select(\DB::raw("count((case when (((year(curdate()) - year(`dob`)) >= 20) and ((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `dob` ) > 0 ) THEN
+ date_format( str_to_date( `dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `dob` ) > 0 ) THEN
+ date_format( str_to_date( `dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END )) <= 24)) then `id` end)) AS count"))
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_to_twentyfive_above = Client::select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `dob` ) > 0 ) THEN
+ date_format( str_to_date( `dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `dob` ) > 0 ) THEN
+ date_format( str_to_date( `dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `id` end)) AS count"))
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_unknown_age = Client::select('id')
+ ->where('dob', '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->remember($this->remember_period)
+ ->count('id');
+ }
+ // dd($active_facilities);
+
+ return view('new_dashboard.main_dashbaord', compact(
+ 'all_partners',
+ 'active_facilities',
+ 'facilities_ever_enrolled',
+ 'client',
+ 'client_ever_enrolled',
+ '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'
+
+ ));
+ }
+
+ public function client_dashboard()
+ {
+
+ // showing all the active clients, all appointments, missed appointments
+ if (Auth::user()->access_level == 'Facility') {
+ $all_partners = Partner::where('status', '=', 'Active')->remember($this->remember_period)->pluck('name', 'id');
+
+ $client = Client::where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->count('clinic_number');
+
+ // client charts
+ $client_consented = Client::select('smsenable')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('smsenable', '=', 'Yes')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ $client_nonconsented = Client::select('smsenable')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('smsenable', '!=', 'Yes')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ // consented clients by gender
+
+ $client_consented_male = Client::where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('gender', '=', '2')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ $client_consented_female = Client::where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('gender', '=', '1')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ $client_consented_uknown_gender = Client::where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('gender', '!=', '1')
+ ->where('gender', '!=', '2')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ // non consented clients by gender
+ $client_nonconsented_male = Client::where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('gender', '=', '2')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ $client_nonconsented_female = Client::where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('gender', '=', '1')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ $client_nonconsented_uknown_gender = Client::where('smsenable', '!=', 'Yes')
+ ->where('gender', '!=', '1')
+ ->where('gender', '!=', '2')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ // consented clients by age distribution
+ $client_consented_to_nine = 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_consented_to_fourteen = 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_consented_to_nineteen = 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_consented_to_twentyfour = 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_consented_to_twentyfive_above = 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_consented_uknown_age = Client::select('smsenable')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('smsenable', '=', 'Yes')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ // non consented clients by age distribution
+ $client_nonconsented_to_nine = 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_nonconsented_to_fourteen = 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_nonconsented_to_nineteen = 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_nonconsented_to_twentyfour = 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_nonconsented_to_twentyfive_above = 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_nonconsented_uknown_age = Client::select('smsenable')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('smsenable', '!=', 'Yes')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ }
+ if (Auth::user()->access_level == 'Partner') {
+
+ $all_partners = Partner::where('status', '=', 'Active')->where('id', Auth::user()->partner_id)->remember($this->remember_period)->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)
+ ->remember($this->remember_period)
+ ->count('tbl_client.clinic_number');
+
+ // client charts
+ $client_consented = 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)
+ ->remember($this->remember_period)
+ ->count();
+
+ $client_nonconsented = 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)
+ ->remember($this->remember_period)
+ ->count();
+
+ // consented clients by gender
+
+ $client_consented_male = 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)
+ ->remember($this->remember_period)
+ ->count();
+
+ $client_consented_female = 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)
+ ->remember($this->remember_period)
+ ->count();
+
+ $client_consented_uknown_gender = 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)
+ ->remember($this->remember_period)
+ ->count();
+
+ // non consented clients by gender
+ $client_nonconsented_male = 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)
+ ->remember($this->remember_period)
+ ->count();
+
+ $client_nonconsented_female = 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)
+ ->remember($this->remember_period)
+ ->count();
+
+ $client_nonconsented_uknown_gender = 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)
+ ->remember($this->remember_period)
+ ->count();
+
+ // consented clients by age distribution
+ $client_consented_to_nine = 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_consented_to_fourteen = 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_consented_to_nineteen = 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_consented_to_twentyfour = 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_consented_to_twentyfive_above = 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_consented_uknown_age = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.smsenable')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->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)
+ ->remember($this->remember_period)
+ ->count();
+
+ // non consented clients by age distribution
+ $client_nonconsented_to_nine = 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_nonconsented_to_fourteen = 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_nonconsented_to_nineteen = 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_nonconsented_to_twentyfour = 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_nonconsented_to_twentyfive_above = 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_nonconsented_uknown_age = 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(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ }
+ if (Auth::user()->access_level == 'County') {
+ $all_partners = Partner::join('tbl_partner_facility', 'tbl_partner.id', '=', 'tbl_partner_facility.partner_id')->where('tbl_partner.status', '=', 'Active')->where('tbl_partner_facility.county_id', Auth::user()->county_id)->remember($this->remember_period)->pluck('tbl_partner.name', 'tbl_partner.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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->count('tbl_client.clinic_number');
+
+ // client charts
+ $client_consented = 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ $client_nonconsented = 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ // consented clients by gender
+
+ $client_consented_male = 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ $client_consented_female = 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ $client_consented_uknown_gender = 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ // non consented clients by gender
+ $client_nonconsented_male = 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ $client_nonconsented_female = 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ $client_nonconsented_uknown_gender = 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ // consented clients by age distribution
+ $client_consented_to_nine = 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_consented_to_fourteen = 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_consented_to_nineteen = 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_consented_to_twentyfour = 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_consented_to_twentyfive_above = 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_consented_uknown_age = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.smsenable')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ // non consented clients by age distribution
+ $client_nonconsented_to_nine = 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_nonconsented_to_fourteen = 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_nonconsented_to_nineteen = 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_nonconsented_to_twentyfour = 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_nonconsented_to_twentyfive_above = 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_nonconsented_uknown_age = 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(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ }
+ if (Auth::user()->access_level == 'Sub County') {
+ $all_partners = Partner::join('tbl_partner_facility', 'tbl_partner.id', '=', 'tbl_partner_facility.partner_id')->where('tbl_partner.status', '=', 'Active')->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)->remember($this->remember_period)->pluck('tbl_partner.name', 'tbl_partner.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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->count('tbl_client.clinic_number');
+
+ // client charts
+ $client_consented = 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ $client_nonconsented = 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ // consented clients by gender
+
+ $client_consented_male = 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ $client_consented_female = 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ $client_consented_uknown_gender = 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ // non consented clients by gender
+ $client_nonconsented_male = 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ $client_nonconsented_female = 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ $client_nonconsented_uknown_gender = 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ // consented clients by age distribution
+ $client_consented_to_nine = 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_consented_to_fourteen = 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_consented_to_nineteen = 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_consented_to_twentyfour = 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_consented_to_twentyfive_above = 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_consented_uknown_age = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.smsenable')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ // non consented clients by age distribution
+ $client_nonconsented_to_nine = 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_nonconsented_to_fourteen = 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_nonconsented_to_nineteen = 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_nonconsented_to_twentyfour = 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_nonconsented_to_twentyfive_above = 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_nonconsented_uknown_age = 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(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ }
+ if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+
+ $all_partners = Partner::where('status', '=', 'Active')->orderBy('name', 'ASC')->remember($this->remember_period)->pluck('name', 'id');
+
+ $client = Client::where('status', '=', 'Active')->whereNull('hei_no')->remember($this->remember_period)->count('clinic_number');
+
+ // client charts
+ $client_consented = Client::select('smsenable')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('smsenable', '=', 'Yes')
+ ->remember($this->remember_period)
+ ->count();
+
+ $client_nonconsented = Client::select('smsenable')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('smsenable', '!=', 'Yes')
+ ->remember($this->remember_period)
+ ->count();
+
+ // consented clients by gender
+
+ $client_consented_male = Client::where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('gender', '=', '2')
+ ->remember($this->remember_period)
+ ->count();
+
+ $client_consented_female = Client::where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('gender', '=', '1')
+ ->remember($this->remember_period)
+ ->count();
+
+ $client_consented_uknown_gender = Client::where('smsenable', '=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('gender', '!=', '1')
+ ->where('gender', '!=', '2')
+ ->remember($this->remember_period)
+ ->count();
+
+ // non consented clients by gender
+ $client_nonconsented_male = Client::where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('gender', '=', '2')
+ ->remember($this->remember_period)
+ ->count();
+
+ $client_nonconsented_female = Client::where('smsenable', '!=', 'Yes')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('gender', '=', '1')
+ ->remember($this->remember_period)
+ ->count();
+
+ $client_nonconsented_uknown_gender = Client::where('smsenable', '!=', 'Yes')
+ ->where('gender', '!=', '1')
+ ->where('gender', '!=', '2')
+ ->remember($this->remember_period)
+ ->count();
+
+ // consented clients by age distribution
+ $client_consented_to_nine = 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')
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_consented_to_fourteen = 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')
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_consented_to_nineteen = 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')
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_consented_to_twentyfour = 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')
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_consented_to_twentyfive_above = 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')
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_consented_uknown_age = Client::select('smsenable')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where('smsenable', '=', 'Yes')
+ ->remember($this->remember_period)
+ ->count();
+
+ // non consented clients by age distribution
+ $client_nonconsented_to_nine = 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')
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_nonconsented_to_fourteen = 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')
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_nonconsented_to_nineteen = 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')
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_nonconsented_to_twentyfour = 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')
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_nonconsented_to_twentyfive_above = 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')
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_nonconsented_uknown_age = Client::select('smsenable')
+ ->where('status', '=', 'Active')
+ ->whereNull('hei_no')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('smsenable', '!=', 'Yes')
+ ->remember($this->remember_period)
+ ->count();
+ }
+
+
+ // dd($active_facilities);
+
+ return view('new_dashboard.client_dashboard', compact(
+ 'all_partners',
+ 'client',
+ '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')->remember($this->remember_period)->pluck('name', 'id');
+
+ $indicator = Indicator::select(['name', 'description'])->remember($this->remember_period)->get();
+
+ // 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)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ $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)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ $all_future_apps = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select('tbl_appointment.id')
+ ->where('tbl_appointment.appntmnt_date', '=', date('Y-m-d'))
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ // 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)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ // 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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ $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)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $appointment_honored_to_uknown_age = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ // 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)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ $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)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ $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)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $appointment_not_honored_to_uknown_age = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+ }
+ if (Auth::user()->access_level == 'Partner') {
+ $all_partners = Partner::where('status', '=', 'Active')->where('id', Auth::user()->partner_id)->remember($this->remember_period)->pluck('name', 'id');
+
+ $indicator = Indicator::select(['name', 'description'])->remember($this->remember_period)->get();
+
+ // 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)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+ $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)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ $all_future_apps = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_appointment.id', 'tbl_appointment.client_id', 'tbl_client.clinic_number')
+ ->where('tbl_appointment.appntmnt_date', '>', Now())
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ // 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)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ // 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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ $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)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ // 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)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ $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)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ $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)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+ }
+ if (Auth::user()->access_level == 'County') {
+ $all_partners = Partner::join('tbl_partner_facility', 'tbl_partner.id', '=', 'tbl_partner_facility.partner_id')->where('tbl_partner.status', '=', 'Active')->where('tbl_partner_facility.county_id', Auth::user()->county_id)->remember($this->remember_period)->pluck('tbl_partner.name', 'tbl_partner.id');
+
+ $indicator = Indicator::select(['name', 'description'])->remember($this->remember_period)->get();
+
+ // 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ $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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ $all_future_apps = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_appointment.id', 'tbl_appointment.client_id', 'tbl_client.clinic_number')
+ ->where('tbl_appointment.appntmnt_date', '>', Now())
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ // 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ // 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ $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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ // 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ $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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ $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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+ }
+ if (Auth::user()->access_level == 'Sub County') {
+ $all_partners = Partner::join('tbl_partner_facility', 'tbl_partner.id', '=', 'tbl_partner_facility.partner_id')->where('tbl_partner.status', '=', 'Active')->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)->pluck('tbl_partner.name', 'tbl_partner.id');
+ $indicator = Indicator::select(['name', 'description'])->get();
+ // 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ $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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ $all_future_apps = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_appointment.id', 'tbl_appointment.client_id', 'tbl_client.clinic_number')
+ ->where('tbl_appointment.appntmnt_date', '>', Now())
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ // 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ // 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ $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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ // 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ $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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ $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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+ }
+
+ if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+ $all_partners = Partner::where('status', '=', 'Active')->orderBy('name', 'ASC')->remember($this->remember_period)->pluck('name', 'id');
+
+ $indicator = Indicator::select(['name', 'description'])->remember($this->remember_period)->get();
+
+ // main appointments
+ $appointment = Appointments::select('id')
+ ->remember($this->remember_period)
+ ->count('id');
+
+ $appointment_honoured = Appointments::select('id')
+ ->where('date_attended', '=', DB::raw('appntmnt_date'))
+ ->remember($this->remember_period)
+ ->count('id');
+ // dd($appointment_honoured);
+ $appointment_not_honoured = Appointments::select('id')
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->remember($this->remember_period)
+ ->count('id');
+
+ $all_future_apps = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
+ ->select('tbl_appointment.id', 'tbl_appointment.client_id', 'tbl_client.clinic_number', 'tbl_appointment.appntmnt_date', 'tbl_appointment_types.name as app_type')
+ ->where('tbl_appointment.appntmnt_date', '>', Now())
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ // appointment honored by gender
+ $appointment_honoured_male = 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.gender', '=', '2')
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ $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')
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ $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')
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ // appointment honored by age
+ $appointment_honored_to_nine = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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'))
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $appointment_honored_to_fourteen = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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'))
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $appointment_honored_to_nineteen = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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'))
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $appointment_honored_to_twentyfour = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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'))
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $appointment_honored_to_twentyfive_above = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $appointment_honored_to_uknown_age = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->remember($this->remember_period)
+ ->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('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ $appointment_not_honoured_female = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where('tbl_client.gender', '=', '1')
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ $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('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ // appointment not honored by age
+ $appointment_not_honored_to_nine = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $appointment_not_honored_to_fourteen = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $appointment_not_honored_to_nineteen = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $appointment_not_honored_to_twentyfour = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $appointment_not_honored_to_twentyfive_above = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END )) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $appointment_not_honored_to_uknown_age = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+ }
+
+
+ return view('new_dashboard.appointment_dashboard', compact(
+ 'all_partners',
+ 'indicator',
+ 'appointment',
+ 'appointment_honoured',
+ 'all_future_apps',
+ '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',
+ ));
+ }
+ public function missed_appointment_charts()
+ {
+ if (Auth::user()->access_level == 'Facility') {
+ $all_partners = Partner::where('status', '=', 'Active')->remember($this->remember_period)->pluck('name', 'id');
+
+ $indicator = Indicator::select(['name', 'description'])->remember($this->remember_period)->get();
+
+ // 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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $appointment_missed_to_uknown_age = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_client.dob')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $appointment_defaulted_to_uknown_age = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $appointment_ltfu_to_uknown_age = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->count();
+ }
+ if (Auth::user()->access_level == 'Partner') {
+ $all_partners = Partner::where('status', '=', 'Active')->where('id', Auth::user()->partner_id)->remember($this->remember_period)->pluck('name', 'id');
+
+ $indicator = Indicator::select(['name', 'description'])->remember($this->remember_period)->get();
+
+ // 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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period)
+ ->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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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)
+ ->remember($this->remember_period)
+ ->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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period)
+ ->count();
+ }
+ if (Auth::user()->access_level == 'Sub County') {
+ $all_partners = Partner::join('tbl_partner_facility', 'tbl_partner.id', '=', 'tbl_partner_facility.partner_id')->where('tbl_partner.status', '=', 'Active')->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)->pluck('tbl_partner.name', 'tbl_partner.id');
+ $indicator = Indicator::select(['name', 'description'])->remember($this->remember_period)->get();
+
+ // 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->count();
+ }
+ if (Auth::user()->access_level == 'County') {
+ $all_partners = Partner::join('tbl_partner_facility', 'tbl_partner.id', '=', 'tbl_partner_facility.partner_id')->where('tbl_partner.status', '=', 'Active')->where('tbl_partner_facility.county_id', Auth::user()->county_id)->remember($this->remember_period)->pluck('tbl_partner.name', 'tbl_partner.id');
+
+ $indicator = Indicator::select(['name', 'description'])->remember($this->remember_period)->get();
+
+ // 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->count();
+ }
+
+ if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+ $all_partners = Partner::where('status', '=', 'Active')->orderBy('name', 'ASC')->remember($this->remember_period)->pluck('name', 'id');
+ $indicator = Indicator::select(['name', 'description'])->remember($this->remember_period)->get();
+ // main appointments
+ // dd($appointment_honoured);
+ $appointment_not_honoured = Appointments::whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->remember($this->remember_period)
+ ->count('id');
+
+ // missed appointments
+
+ $appointment_missed = Appointments::where('app_status', '=', 'Missed')
+ ->remember($this->remember_period)
+ ->count('id');
+ $appointment_defaulted = Appointments::where('app_status', '=', 'Defaulted')
+ ->remember($this->remember_period)
+ ->count('id');
+ $appointment_lftu = Appointments::where('app_status', '=', 'LTFU')
+ ->remember($this->remember_period)
+ ->count('id');
+
+ // 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')
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ $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')
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ $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')
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $appointment_missed_to_uknown_age = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ // 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')
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ $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')
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ $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')
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $appointment_defaulted_to_uknown_age = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ // 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')
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ $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')
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ $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')
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->remember($this->remember_period)
+ ->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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $appointment_ltfu_to_uknown_age = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->remember($this->remember_period)
+ ->count('tbl_appointment.id');
+ }
+
+ return view('new_dashboard.missed_dashboard', compact(
+ 'all_partners',
+ 'indicator',
+ 'appointment_not_honoured',
+ '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') {
+ }
+ $all_partners = Partner::where('status', '=', 'Active')->remember($this->remember_period)->pluck('name', 'id');
+
+ $indicator = Indicator::select(['name', 'description'])->remember($this->remember_period)->get();
+
+ $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.created_at', '>=', date($request->from))
+ ->where('tbl_client.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+ $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_appointment.created_at', '>=', date($request->from))
+ ->where('tbl_appointment.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+ $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_appointment.created_at', '>=', date($request->from))
+ ->where('tbl_appointment.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+ $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))
+ ->remember($this->remember_period)
+ ->orderBy('tbl_appointment.created_at', 'DESC')
+ ->groupBy('tbl_partner_facility.mfl_code')
+ ->get();
+
+ // active clients by gender
+ $clients_male = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.id')
+ ->where([['tbl_client.gender', '=', '2'], ['tbl_client.status', '=', 'Active'],])
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.created_at', '>=', date($request->from))
+ ->where('tbl_client.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+ $clients_female = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where([['tbl_client.gender', '=', '2'], ['tbl_client.status', '=', 'Active'],])
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.created_at', '>=', date($request->from))
+ ->where('tbl_client.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+ $unknown_gender = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where([['tbl_client.gender', '!=', '1'], ['tbl_client.gender', '!=', '2'], ['tbl_client.status', '=', 'Active'],])
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.created_at', '>=', date($request->from))
+ ->where('tbl_client.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+ $client_to_nine = Client::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`.`dob` end"))
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.created_at', '>=', date($request->from))
+ ->where('tbl_client.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+ $client_to_fourteen = Client::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`.`dob` end"))
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.created_at', '>=', date($request->from))
+ ->where('tbl_client.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+
+ $client_to_nineteen = Client::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`.`dob` end"))
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.created_at', '>=', date($request->from))
+ ->where('tbl_client.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+
+ $client_to_twentyfour = Client::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 `id` end"))
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.created_at', '>=', date($request->from))
+ ->where('tbl_client.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+
+ $client_to_twentyfive_above = Client::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 `id` end"))
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.created_at', '>=', date($request->from))
+ ->where('tbl_client.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+
+ $client_unknown_age = 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_client.created_at', '>=', date($request->from))
+ ->where('tbl_client.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+
+ // appointment by gender
+ $appointment_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('tbl_appointment.id')
+ ->where('tbl_client.gender', '=', '2')
+ ->where('tbl_appointment.created_at', '>=', date($request->from))
+ ->where('tbl_appointment.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+ $appointment_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')
+ ->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))
+ ->remember($this->remember_period);
+
+ $appointment_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')
+ ->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))
+ ->remember($this->remember_period);
+
+ // 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`.`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`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))
+ ->remember($this->remember_period);
+
+ $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`.`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end"))
+ ->where('tbl_appointment.created_at', '>=', date($request->from))
+ ->where('tbl_appointment.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+ $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`.`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`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))
+ ->remember($this->remember_period);
+
+
+ $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`.`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`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))
+ ->remember($this->remember_period);
+
+
+ $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`.`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))
+ ->remember($this->remember_period);
+
+
+ $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))
+ ->remember($this->remember_period);
+
+
+ // Total missed appointment by gender
+ $appointment_total_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')
+ ->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))
+ ->remember($this->remember_period);
+
+ $appointment_total_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_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))
+ ->remember($this->remember_period);
+
+
+ $appointment_total_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')
+ ->whereIn('tbl_appointment.app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->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))
+ ->remember($this->remember_period);
+
+
+ // Total missed appointment by age
+ $appointment_total_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("case when (((year(curdate()) - year(`tbl_client`.`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`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))
+ ->remember($this->remember_period);
+
+ $appointment_total_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("case when (((year(curdate()) - year(`tbl_client`.`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`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))
+ ->remember($this->remember_period);
+
+ $appointment_total_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("case when (((year(curdate()) - year(`tbl_client`.`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`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))
+ ->remember($this->remember_period);
+
+ $appointment_total_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("case when (((year(curdate()) - year(`tbl_client`.`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`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))
+ ->remember($this->remember_period);
+
+ $appointment_total_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("case when (((year(curdate()) - year(`tbl_client`.`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))
+ ->remember($this->remember_period);
+
+ $appointment_total_missed_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')
+ ->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))
+ ->remember($this->remember_period);
+
+ // client charts
+ $client_consented = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.id')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.created_at', '>=', date($request->from))
+ ->where('tbl_client.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+ $client_nonconsented = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.id')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.created_at', '>=', date($request->from))
+ ->where('tbl_client.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+ // consented clients by gender
+
+ $client_consented_male = 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_client.created_at', '>=', date($request->from))
+ ->where('tbl_client.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+ $client_consented_female = 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.created_at', '>=', date($request->from))
+ ->where('tbl_client.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+ $client_consented_uknown_gender = 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_client.created_at', '>=', date($request->from))
+ ->where('tbl_client.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+ // non consented clients by gender
+ $client_nonconsented_male = 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_client.created_at', '>=', date($request->from))
+ ->where('tbl_client.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+
+ $client_nonconsented_female = 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.created_at', '>=', date($request->from))
+ ->where('tbl_client.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+ $client_nonconsented_uknown_gender = 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_client.created_at', '>=', date($request->from))
+ ->where('tbl_client.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+ // consented clients by age distribution
+ $client_consented_to_nine = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.created_at', '>=', date($request->from))
+ ->where('tbl_client.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+ $client_consented_to_fourteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.created_at', '>=', date($request->from))
+ ->where('tbl_client.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+ $client_consented_to_nineteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.created_at', '>=', date($request->from))
+ ->where('tbl_client.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+ $client_consented_to_twentyfour = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.created_at', '>=', date($request->from))
+ ->where('tbl_client.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+ $client_consented_to_twentyfive_above = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.created_at', '>=', date($request->from))
+ ->where('tbl_client.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+ $client_consented_uknown_age = 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_client.created_at', '>=', date($request->from))
+ ->where('tbl_client.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+ // non consented clients by age distribution
+ $client_nonconsented_to_nine = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.created_at', '>=', date($request->from))
+ ->where('tbl_client.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_fourteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`tbl_client`.`dob`)) >= 10) and ((year(curdate()) - year(`tbl_client`.`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.created_at', '>=', date($request->from))
+ ->where('tbl_client.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_nineteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`tbl_client`.`dob`)) >= 15) and ((year(curdate()) - year(`tbl_client`.`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.created_at', '>=', date($request->from))
+ ->where('tbl_client.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_twentyfour = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`tbl_client`.`dob`)) >= 20) and ((year(curdate()) - year(`tbl_client`.`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.created_at', '>=', date($request->from))
+ ->where('tbl_client.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_twentyfive_above = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_client`.`tbl_client`.`dob`)) >= 25)) then `tbl_client`.`id` end"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.created_at', '>=', date($request->from))
+ ->where('tbl_client.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+ $client_nonconsented_uknown_age = 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_client.created_at', '>=', date($request->from))
+ ->where('tbl_client.created_at', '<=', date($request->to))
+ ->remember($this->remember_period);
+
+ 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_uknown_age->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_uknown_age->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_uknown_age->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_uknown_age->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();
+
+
+ //return view('new_dashboard.main_dashbaord', compact('data'));
+ 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 filter_dashboard_charts(Request $request)
+ {
+ $data = [];
+
+ $selected_partners = $request->partners;
+ $selected_counties = $request->counties;
+ $selected_subcounties = $request->subcounties;
+ $selected_facilites = $request->facilities;
+ $selected_from = $request->from;
+ $selected_to = $request->to;
+ $selected_module = $request->module;
+
+ if (Auth::user()->access_level == 'Facility') {
+ $facilities_ever_enrolled = PartnerFacility::join('tbl_client', 'tbl_partner_facility.mfl_code', '=', 'tbl_client.mfl_code')
+ ->select('tbl_partner_facility.mfl_code')->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)->remember($this->remember_period);
+
+ $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')
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $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.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $client_ever_enrolled = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ // active clients by gender
+ $clients_male = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.id')
+ ->where([['tbl_client.gender', '=', '2'], ['tbl_client.status', '=', 'Active'],])
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+
+ $clients_female = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where([['tbl_client.gender', '=', '1'], ['tbl_client.status', '=', 'Active'],])
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $unknown_gender = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where([['tbl_client.gender', '!=', '1'], ['tbl_client.gender', '!=', '2'], ['tbl_client.status', '=', 'Active'],])
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+
+ $client_to_nine = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+
+ $client_to_fourteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+
+ $client_to_nineteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $client_to_twentyfour = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $client_to_twentyfive_above = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+
+ $client_unknown_age = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+ }
+ if (Auth::user()->access_level == 'Partner') {
+
+ $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)
+ ->remember($this->remember_period);
+
+ $client_ever_enrolled = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ $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')
+ ->selectRaw('tbl_partner_facility.mfl_code, MAX(DATE(tbl_appointment.created_at)) as max_date')
+ ->where(DB::raw('(SELECT MAX(DATE(tbl_appointment.created_at)) from tbl_appointment)'), '>=', Carbon::now()->subMonths(6))
+ ->orderBy('tbl_appointment.created_at', 'DESC')
+ ->groupBy('tbl_partner_facility.mfl_code')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ $facilities_ever_enrolled = PartnerFacility::select('tbl_partner_facility.mfl_code')->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)->remember($this->remember_period);
+
+ // active clients by gender
+ $clients_male = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.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)
+ ->remember($this->remember_period);
+
+ $clients_female = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where([['tbl_client.gender', '=', '1'], ['tbl_client.status', '=', 'Active'],])
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ $unknown_gender = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where([['tbl_client.gender', '!=', '1'], ['tbl_client.gender', '!=', '2'], ['tbl_client.status', '=', 'Active'],])
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+
+ $client_to_nine = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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)
+ ->remember($this->remember_period);
+
+
+ $client_to_fourteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period);
+
+
+ $client_to_nineteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period);
+
+ $client_to_twentyfour = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period);
+
+ $client_to_twentyfive_above = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period);
+
+
+ $client_unknown_age = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+ }
+ if (Auth::user()->access_level == 'Sub County') {
+
+ $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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $client_ever_enrolled = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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')
+ ->selectRaw('tbl_partner_facility.mfl_code, MAX(DATE(tbl_appointment.created_at)) as max_date')
+ ->where(DB::raw('(SELECT MAX(DATE(tbl_appointment.created_at)) from tbl_appointment)'), '>=', Carbon::now()->subMonths(6))
+ ->orderBy('tbl_appointment.created_at', 'DESC')
+ ->groupBy('tbl_partner_facility.mfl_code')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $facilities_ever_enrolled = PartnerFacility::select('tbl_partner_facility.mfl_code')->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)->remember($this->remember_period);
+
+ // active clients by gender
+ $clients_male = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.id')
+ ->where([['tbl_client.gender', '=', '2'], ['tbl_client.status', '=', 'Active'],])
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $clients_female = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where([['tbl_client.gender', '=', '1'], ['tbl_client.status', '=', 'Active'],])
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $unknown_gender = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where([['tbl_client.gender', '!=', '1'], ['tbl_client.gender', '!=', '2'], ['tbl_client.status', '=', 'Active'],])
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+
+ $client_to_nine = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+
+ $client_to_fourteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+
+ $client_to_nineteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $client_to_twentyfour = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $client_to_twentyfive_above = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+
+ $client_unknown_age = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+ }
+ if (Auth::user()->access_level == 'County') {
+
+ $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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $client_ever_enrolled = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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')
+ ->selectRaw('tbl_partner_facility.mfl_code, MAX(DATE(tbl_appointment.created_at)) as max_date')
+ ->where(DB::raw('(SELECT MAX(DATE(tbl_appointment.created_at)) from tbl_appointment)'), '>=', Carbon::now()->subMonths(6))
+ ->orderBy('tbl_appointment.created_at', 'DESC')
+ ->groupBy('tbl_partner_facility.mfl_code')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $facilities_ever_enrolled = PartnerFacility::select('tbl_partner_facility.mfl_code')->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)->remember($this->remember_period);
+
+ // active clients by gender
+ $clients_male = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.id')
+ ->where([['tbl_client.gender', '=', '2'], ['tbl_client.status', '=', 'Active'],])
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $clients_female = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where([['tbl_client.gender', '=', '1'], ['tbl_client.status', '=', 'Active'],])
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $unknown_gender = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where([['tbl_client.gender', '!=', '1'], ['tbl_client.gender', '!=', '2'], ['tbl_client.status', '=', 'Active'],])
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+
+ $client_to_nine = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+
+ $client_to_fourteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+
+ $client_to_nineteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $client_to_twentyfour = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $client_to_twentyfive_above = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+
+ $client_unknown_age = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+ }
+
+ if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+
+
+ $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')
+ ->remember($this->remember_period);
+
+ $client_ever_enrolled = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->whereNull('tbl_client.hei_no')
+ ->remember($this->remember_period);
+
+ $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')
+ ->selectRaw('tbl_partner_facility.mfl_code, MAX(DATE(tbl_appointment.created_at)) as max_date')
+ ->where(DB::raw('(SELECT MAX(DATE(tbl_appointment.created_at)) from tbl_appointment)'), '>=', Carbon::now()->subMonths(6))
+ ->orderBy('tbl_appointment.id', 'DESC')
+ ->groupBy('tbl_partner_facility.mfl_code')
+ ->remember($this->remember_period);
+
+ $facilities_ever_enrolled = PartnerFacility::select('tbl_partner_facility.mfl_code')->remember($this->remember_period);
+
+ // active clients by gender
+ $clients_male = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.id')
+ ->where([['tbl_client.gender', '=', '2'], ['tbl_client.status', '=', 'Active'],])
+ ->whereNull('tbl_client.hei_no')
+ ->remember($this->remember_period);
+
+ $clients_female = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where([['tbl_client.gender', '=', '1'], ['tbl_client.status', '=', 'Active'],])
+ ->whereNull('tbl_client.hei_no')
+ ->remember($this->remember_period);
+
+ $unknown_gender = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where([['tbl_client.gender', '!=', '1'], ['tbl_client.gender', '!=', '2'], ['tbl_client.status', '=', 'Active'],])
+ ->whereNull('tbl_client.hei_no')
+ ->remember($this->remember_period);
+
+ $client_to_nine = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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')
+ ->remember($this->remember_period);
+
+ $client_to_fourteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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')
+ ->remember($this->remember_period);
+
+
+ $client_to_nineteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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')
+ ->remember($this->remember_period);
+
+ $client_to_twentyfour = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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')
+ ->remember($this->remember_period);
+
+ $client_to_twentyfive_above = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->remember($this->remember_period);
+
+
+ $client_unknown_age = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->remember($this->remember_period);
+ }
+
+ if (!empty($selected_partners)) {
+ $client = $client->where('tbl_partner_facility.partner_id', $selected_partners);
+ $client_ever_enrolled = $client_ever_enrolled->where('tbl_partner_facility.partner_id', $selected_partners);
+ $active_facilities = $active_facilities->where('tbl_partner_facility.partner_id', $selected_partners);
+ $facilities_ever_enrolled = $facilities_ever_enrolled->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);
+ }
+ if (!empty($selected_counties)) {
+ $client = $client->where('tbl_partner_facility.county_id', $selected_counties);
+ $client_ever_enrolled = $client_ever_enrolled->where('tbl_partner_facility.county_id', $selected_counties);
+ $active_facilities = $active_facilities->where('tbl_partner_facility.county_id', $selected_counties);
+ $facilities_ever_enrolled = $facilities_ever_enrolled->where('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);
+ }
+ if (!empty($selected_subcounties)) {
+ $client = $client->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $client_ever_enrolled = $client_ever_enrolled->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $active_facilities = $active_facilities->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $facilities_ever_enrolled = $facilities_ever_enrolled->where('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);
+ }
+ if (!empty($selected_facilites)) {
+ $client = $client->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $client_ever_enrolled = $client_ever_enrolled->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $active_facilities = $active_facilities->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $facilities_ever_enrolled = $facilities_ever_enrolled->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);
+ }
+ if (!empty($selected_from || $selected_to)) {
+ $client = $client->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ $client_ever_enrolled = $client_ever_enrolled->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ // $active_facilities = $active_facilities->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.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')
+ ->selectRaw('tbl_partner_facility.mfl_code, MAX(DATE(tbl_appointment.created_at)) as max_date')
+ ->where(DB::raw('(SELECT MAX(DATE(tbl_appointment.created_at)) from tbl_appointment)'), '>=', Carbon::now()->subMonths(6))
+ ->where(DB::raw('(SELECT MAX(DATE(tbl_appointment.created_at)) from tbl_appointment)'), '>=', date($request->from))
+ ->where(DB::raw('(SELECT MAX(DATE(tbl_appointment.created_at)) from tbl_appointment)'), '>=', date($request->to))
+ // ->whereRaw('tbl_appointment.created_at', '>=', date($request->from))->whereDate('tbl_appointment.created_at', '>=', date($request->to))
+ ->orderBy('tbl_appointment.created_at', 'DESC')
+ ->groupBy('tbl_partner_facility.mfl_code')
+ ->remember($this->remember_period);
+
+ $facilities_ever_enrolled = $facilities_ever_enrolled->where('tbl_partner_facility.created_at', '>=', date($request->from))->where('tbl_partner_facility.created_at', '<=', date($request->to));
+ $clients_male = $clients_male->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ $clients_female = $clients_female->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ $unknown_gender = $unknown_gender->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ $client_to_nine = $client_to_nine->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ $client_to_fourteen = $client_to_fourteen->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ $client_to_nineteen = $client_to_nineteen->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ $client_to_twentyfour = $client_to_twentyfour->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ $client_to_twentyfive_above = $client_to_twentyfive_above->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ $client_unknown_age = $client_unknown_age->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ }
+ if (!empty($selected_module == 'DSD')) {
+ $client = $client->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $client_ever_enrolled = $client_ever_enrolled->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $active_facilities = $active_facilities->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $facilities_ever_enrolled = $facilities_ever_enrolled->join('tbl_client', 'tbl_partner_facility.mfl_code', '=', 'tbl_client.mfl_code')->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id')->groupBy('tbl_partner_facility.mfl_code')->having(DB::raw('count(tbl_client.mfl_code)'), '>', 0);
+ $clients_male = $clients_male->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $clients_female = $clients_female->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $unknown_gender = $unknown_gender->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $client_to_nine = $client_to_nine->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $client_to_fourteen = $client_to_fourteen->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $client_to_nineteen = $client_to_nineteen->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $client_to_twentyfour = $client_to_twentyfour->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $client_to_twentyfive_above = $client_to_twentyfive_above->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $client_unknown_age = $client_unknown_age->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ }
+ if (!empty($selected_module == 'PMTCT')) {
+ $client = $client->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $client_ever_enrolled = $client_ever_enrolled->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $active_facilities = $active_facilities->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $facilities_ever_enrolled = $facilities_ever_enrolled->join('tbl_client', 'tbl_partner_facility.mfl_code', '=', 'tbl_client.mfl_code')->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id')->groupBy('tbl_partner_facility.mfl_code')->having(DB::raw('count(tbl_client.mfl_code)'), '>', 0);
+ $clients_male = $clients_male->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $clients_female = $clients_female->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $unknown_gender = $unknown_gender->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $client_to_nine = $client_to_nine->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $client_to_fourteen = $client_to_fourteen->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $client_to_nineteen = $client_to_nineteen->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $client_to_twentyfour = $client_to_twentyfour->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $client_to_twentyfive_above = $client_to_twentyfive_above->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $client_unknown_age = $client_unknown_age->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ }
+ $data["client"] = $client->count();
+ $data["facilities_ever_enrolled"] = $facilities_ever_enrolled->count();
+ $data["client_ever_enrolled"] = $client_ever_enrolled->count();
+ $data["active_facilities"] = $active_facilities->get()->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->pluck('count');
+ $data["client_to_fourteen"] = $client_to_fourteen->pluck('count');
+ $data["client_to_nineteen"] = $client_to_nineteen->pluck('count');
+ $data["client_to_twentyfour"] = $client_to_twentyfour->pluck('count');
+ $data["client_to_twentyfive_above"] = $client_to_twentyfive_above->pluck('count');
+ $data["client_unknown_age"] = $client_unknown_age->count();
+
+
+ return $data;
+ }
+ public function filter_client_charts(Request $request)
+ {
+ $data = [];
+ // client charts
+ $selected_partners = $request->partners;
+ $selected_counties = $request->counties;
+ $selected_subcounties = $request->subcounties;
+ $selected_facilites = $request->facilities;
+ $selected_from = $request->from;
+ $selected_to = $request->to;
+ $selected_module = $request->module;
+
+ if (Auth::user()->access_level == 'Facility') {
+
+ $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.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $client_consented = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.id')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $client_nonconsented = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.id')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ // consented clients by gender
+
+ $client_consented_male = 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_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $client_consented_female = 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.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $client_consented_uknown_gender = 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_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ // non consented clients by gender
+ $client_nonconsented_male = 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_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+
+ $client_nonconsented_female = 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.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $client_nonconsented_uknown_gender = 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_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ // consented clients by age distribution
+ $client_consented_to_nine = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $client_consented_to_fourteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $client_consented_to_nineteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $client_consented_to_twentyfour = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $client_consented_to_twentyfive_above = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $client_consented_uknown_age = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.smsenable')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ // non consented clients by age distribution
+ $client_nonconsented_to_nine = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_fourteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_nineteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_twentyfour = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_twentyfive_above = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $client_nonconsented_uknown_age = 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(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+ }
+
+ if (Auth::user()->access_level == 'Partner') {
+ $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)
+ ->remember($this->remember_period);
+
+ $client_consented = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.id')
+ ->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)
+ ->remember($this->remember_period);
+
+ $client_nonconsented = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.id')
+ ->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)
+ ->remember($this->remember_period);
+
+ // consented clients by gender
+
+ $client_consented_male = 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)
+ ->remember($this->remember_period);
+
+ $client_consented_female = 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)
+ ->remember($this->remember_period);
+
+ $client_consented_uknown_gender = 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)
+ ->remember($this->remember_period);
+
+ // non consented clients by gender
+ $client_nonconsented_male = 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)
+ ->remember($this->remember_period);
+
+
+ $client_nonconsented_female = 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)
+ ->remember($this->remember_period);
+
+ $client_nonconsented_uknown_gender = 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)
+ ->remember($this->remember_period);
+
+ // consented clients by age distribution
+ $client_consented_to_nine = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`dob` 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)
+ ->remember($this->remember_period);
+
+ $client_consented_to_fourteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`dob` 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)
+ ->remember($this->remember_period);
+
+ $client_consented_to_nineteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`dob` 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)
+ ->remember($this->remember_period);
+
+ $client_consented_to_twentyfour = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`dob` 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)
+ ->remember($this->remember_period);
+
+ $client_consented_to_twentyfive_above = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`dob` 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)
+ ->remember($this->remember_period);
+
+ $client_consented_uknown_age = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.smsenable')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->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)
+ ->remember($this->remember_period);
+
+ // non consented clients by age distribution
+ $client_nonconsented_to_nine = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`dob` 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)
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_fourteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`dob` 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)
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_nineteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`dob` 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)
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_twentyfour = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`dob` 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)
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_twentyfive_above = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`dob` 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)
+ ->remember($this->remember_period);
+
+ $client_nonconsented_uknown_age = 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(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+ }
+ if (Auth::user()->access_level == 'Sub County') {
+ $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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $client_consented = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.id')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $client_nonconsented = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.id')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ // consented clients by gender
+
+ $client_consented_male = 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $client_consented_female = 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $client_consented_uknown_gender = 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ // non consented clients by gender
+ $client_nonconsented_male = 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+
+ $client_nonconsented_female = 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $client_nonconsented_uknown_gender = 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ // consented clients by age distribution
+ $client_consented_to_nine = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $client_consented_to_fourteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $client_consented_to_nineteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $client_consented_to_twentyfour = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $client_consented_to_twentyfive_above = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $client_consented_uknown_age = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.smsenable')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ // non consented clients by age distribution
+ $client_nonconsented_to_nine = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_fourteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_nineteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_twentyfour = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_twentyfive_above = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $client_nonconsented_uknown_age = 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(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+ }
+ if (Auth::user()->access_level == 'County') {
+ $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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $client_consented = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.id')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $client_nonconsented = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.id')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ // consented clients by gender
+
+ $client_consented_male = 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $client_consented_female = 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $client_consented_uknown_gender = 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ // non consented clients by gender
+ $client_nonconsented_male = 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+
+ $client_nonconsented_female = 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $client_nonconsented_uknown_gender = 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ // consented clients by age distribution
+ $client_consented_to_nine = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $client_consented_to_fourteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $client_consented_to_nineteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $client_consented_to_twentyfour = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $client_consented_to_twentyfive_above = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $client_consented_uknown_age = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.smsenable')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ // non consented clients by age distribution
+ $client_nonconsented_to_nine = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_fourteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_nineteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_twentyfour = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_twentyfive_above = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $client_nonconsented_uknown_age = 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(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+ }
+ if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+
+ $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')
+ ->remember($this->remember_period);
+
+ $client_consented = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.id')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->remember($this->remember_period);
+
+ $client_nonconsented = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_client.id')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->remember($this->remember_period);
+
+ // consented clients by gender
+
+ $client_consented_male = 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')
+ ->remember($this->remember_period);
+
+ $client_consented_female = 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')
+ ->remember($this->remember_period);
+
+ $client_consented_uknown_gender = 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')
+ ->remember($this->remember_period);
+
+ // non consented clients by gender
+ $client_nonconsented_male = 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')
+ ->remember($this->remember_period);
+
+
+ $client_nonconsented_female = 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')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_uknown_gender = 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')
+ ->remember($this->remember_period);
+
+ // consented clients by age distribution
+ $client_consented_to_nine = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->remember($this->remember_period);
+
+ $client_consented_to_fourteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->remember($this->remember_period);
+
+ $client_consented_to_nineteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->remember($this->remember_period);
+
+ $client_consented_to_twentyfour = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->remember($this->remember_period);
+
+ $client_consented_to_twentyfive_above = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->remember($this->remember_period);
+
+ $client_consented_uknown_age = 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(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_client.smsenable', '=', 'Yes')
+ ->remember($this->remember_period);
+
+ // non consented clients by age distribution
+ $client_nonconsented_to_nine = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_fourteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_nineteen = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_twentyfour = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_twentyfive_above = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`dob` end)) AS count"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_uknown_age = 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(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_client.smsenable', '!=', 'Yes')
+ ->remember($this->remember_period);
+ }
+
+ if (!empty($selected_partners)) {
+ $client = $client->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_uknown_age->where('tbl_partner_facility.partner_id', $selected_partners);
+ }
+ if (!empty($selected_counties)) {
+ $client = $client->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_uknown_age->where('tbl_partner_facility.county_id', $selected_counties);
+ }
+ if (!empty($selected_subcounties)) {
+ $client = $client->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_uknown_age->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ }
+ if (!empty($selected_facilites)) {
+ $client = $client->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_uknown_age->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ }
+ if (!empty($selected_from || $selected_to)) {
+ $client = $client->where('tbl_client.created_at', '>=', date($selected_from))->where('tbl_client.created_at', '<=', date($selected_to));
+ $client_consented = $client_consented->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ $client_nonconsented = $client_nonconsented->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ $client_consented_male = $client_consented_male->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ $client_consented_female = $client_consented_female->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ $client_consented_uknown_gender = $client_consented_uknown_gender->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ $client_nonconsented_male = $client_nonconsented_male->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ $client_nonconsented_female = $client_nonconsented_female->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ $client_nonconsented_uknown_gender = $client_nonconsented_uknown_gender->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ $client_consented_to_nine = $client_consented_to_nine->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ $client_consented_to_fourteen = $client_consented_to_fourteen->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ $client_consented_to_nineteen = $client_consented_to_nineteen->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ $client_consented_to_twentyfour = $client_consented_to_twentyfour->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ $client_consented_to_twentyfive_above = $client_consented_to_twentyfive_above->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ $client_consented_uknown_age = $client_consented_uknown_age->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ $client_nonconsented_to_nine = $client_nonconsented_to_nine->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ $client_nonconsented_to_fourteen = $client_nonconsented_to_fourteen->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ $client_nonconsented_to_nineteen = $client_nonconsented_to_nineteen->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ $client_nonconsented_to_twentyfour = $client_nonconsented_to_twentyfour->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ $client_nonconsented_to_twentyfive_above = $client_nonconsented_to_twentyfive_above->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ $client_nonconsented_uknown_age = $client_nonconsented_uknown_age->where('tbl_client.created_at', '>=', date($request->from))->where('tbl_client.created_at', '<=', date($request->to));
+ }
+ if (!empty($selected_module == 'DSD')) {
+ $client = $client->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $client_consented = $client_consented->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $client_nonconsented = $client_nonconsented->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $client_consented_male = $client_consented_male->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $client_consented_female = $client_consented_female->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $client_consented_uknown_gender = $client_consented_uknown_gender->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $client_nonconsented_male = $client_nonconsented_male->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $client_nonconsented_female = $client_nonconsented_female->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $client_nonconsented_uknown_gender = $client_nonconsented_uknown_gender->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $client_consented_to_nine = $client_consented_to_nine->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $client_consented_to_fourteen = $client_consented_to_fourteen->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $client_consented_to_nineteen = $client_consented_to_nineteen->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $client_consented_to_twentyfour = $client_consented_to_twentyfour->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $client_consented_to_twentyfive_above = $client_consented_to_twentyfive_above->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $client_consented_uknown_age = $client_consented_uknown_age->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $client_nonconsented_to_nine = $client_nonconsented_to_nine->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $client_nonconsented_to_fourteen = $client_nonconsented_to_fourteen->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $client_nonconsented_to_nineteen = $client_nonconsented_to_nineteen->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $client_nonconsented_to_twentyfour = $client_nonconsented_to_twentyfour->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $client_nonconsented_to_twentyfive_above = $client_nonconsented_to_twentyfive_above->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $client_nonconsented_uknown_age = $client_nonconsented_uknown_age->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ }
+ if (!empty($selected_module == 'PMTCT')) {
+ $client = $client->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $client_consented = $client_consented->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $client_nonconsented = $client_nonconsented->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $client_consented_male = $client_consented_male->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $client_consented_female = $client_consented_female->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $client_consented_uknown_gender = $client_consented_uknown_gender->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $client_nonconsented_male = $client_nonconsented_male->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $client_nonconsented_female = $client_nonconsented_female->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $client_nonconsented_uknown_gender = $client_nonconsented_uknown_gender->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $client_consented_to_nine = $client_consented_to_nine->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $client_consented_to_fourteen = $client_consented_to_fourteen->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $client_consented_to_nineteen = $client_consented_to_nineteen->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $client_consented_to_twentyfour = $client_consented_to_twentyfour->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $client_consented_to_twentyfive_above = $client_consented_to_twentyfive_above->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $client_consented_uknown_age = $client_consented_uknown_age->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $client_nonconsented_to_nine = $client_nonconsented_to_nine->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $client_nonconsented_to_fourteen = $client_nonconsented_to_fourteen->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $client_nonconsented_to_nineteen = $client_nonconsented_to_nineteen->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $client_nonconsented_to_twentyfour = $client_nonconsented_to_twentyfour->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $client_nonconsented_to_twentyfive_above = $client_nonconsented_to_twentyfive_above->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $client_nonconsented_uknown_age = $client_nonconsented_uknown_age->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ }
+
+
+ $data["client"] = $client->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->pluck('count');
+ $data["client_consented_to_fourteen"] = $client_consented_to_fourteen->pluck('count');
+ $data["client_consented_to_nineteen"] = $client_consented_to_nineteen->pluck('count');
+ $data["client_consented_to_twentyfour"] = $client_consented_to_twentyfour->pluck('count');
+ $data["client_consented_to_twentyfive_above"] = $client_consented_to_twentyfive_above->pluck('count');
+ $data["client_consented_uknown_age"] = $client_consented_uknown_age->count();
+ $data["client_nonconsented_to_nine"] = $client_nonconsented_to_nine->pluck('count');
+ $data["client_nonconsented_to_fourteen"] = $client_nonconsented_to_fourteen->pluck('count');
+ $data["client_nonconsented_to_nineteen"] = $client_nonconsented_to_nineteen->pluck('count');
+ $data["client_nonconsented_to_twentyfour"] = $client_nonconsented_to_twentyfour->pluck('count');
+ $data["client_nonconsented_to_twentyfive_above"] = $client_nonconsented_to_twentyfive_above->pluck('count');
+ $data["client_nonconsented_uknown_age"] = $client_nonconsented_uknown_age->count();
+
+ return $data;
+ }
+ public function filter_appointment_charts(Request $request)
+ {
+ $data = [];
+ // client charts
+ $selected_partners = $request->partners;
+ $selected_counties = $request->counties;
+ $selected_subcounties = $request->subcounties;
+ $selected_facilites = $request->facilities;
+ $selected_from = $request->from;
+ $selected_to = $request->to;
+ $selected_module = $request->module;
+
+ if (Auth::user()->access_level == 'Facility') {
+ $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_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $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_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $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_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ // 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('tbl_appointment.id')
+ ->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)
+ ->remember($this->remember_period);
+
+ $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_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $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_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period);
+
+ $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(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ // 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('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $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('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $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('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+ }
+ if (Auth::user()->access_level == 'Partner') {
+ $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)
+ ->remember($this->remember_period);
+
+ $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)
+ ->remember($this->remember_period);
+
+ $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)
+ ->remember($this->remember_period);
+
+ // 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('tbl_appointment.id')
+ ->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)
+ ->remember($this->remember_period);
+
+ $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)
+ ->remember($this->remember_period);
+
+ $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)
+ ->remember($this->remember_period);
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period);
+
+ $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(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ // 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('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ $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('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ $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('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ $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(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+ }
+ if (Auth::user()->access_level == 'Sub County') {
+ $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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ // 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('tbl_appointment.id')
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_client.gender', '=', '2')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ // 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('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+ }
+ if (Auth::user()->access_level == 'County') {
+ $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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ // 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('tbl_appointment.id')
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_client.gender', '=', '2')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ // 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('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+ }
+ if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+ $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')
+ ->remember($this->remember_period);
+
+ $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'))
+ ->remember($this->remember_period);
+
+ $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'])
+ ->remember($this->remember_period);
+
+ // 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('tbl_appointment.id')
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->where('tbl_client.gender', '=', '2')
+ ->remember($this->remember_period);
+
+ $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')
+ ->remember($this->remember_period);
+
+ $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')
+ ->remember($this->remember_period);
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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'))
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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'))
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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'))
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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'))
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.date_attended', '=', DB::raw('tbl_appointment.appntmnt_date'))
+ ->remember($this->remember_period);
+
+ $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(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->remember($this->remember_period);
+
+ // 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('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->remember($this->remember_period);
+
+ $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('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->remember($this->remember_period);
+
+ $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('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->remember($this->remember_period);
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->remember($this->remember_period);
+
+ $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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->remember($this->remember_period);
+ }
+
+ if (!empty($selected_partners)) {
+ $appointment = $appointment->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_honoured = $appointment_honoured->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_not_honoured = $appointment_not_honoured->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_honoured_male = $appointment_honoured_male->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_honoured_female = $appointment_honoured_female->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_honoured_uknown_gender = $appointment_honoured_uknown_gender->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_honored_to_nine = $appointment_honored_to_nine->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_honored_to_fourteen = $appointment_honored_to_fourteen->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_honored_to_nineteen = $appointment_honored_to_nineteen->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_honored_to_twentyfour = $appointment_honored_to_twentyfour->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_honored_to_twentyfive_above = $appointment_honored_to_twentyfive_above->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_honored_to_uknown_age = $appointment_honored_to_uknown_age->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_not_honoured_male = $appointment_not_honoured_male->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_not_honoured_female = $appointment_not_honoured_female->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_not_honoured_uknown_gender = $appointment_not_honoured_uknown_gender->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_not_honored_to_nine = $appointment_not_honored_to_nine->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_not_honored_to_fourteen = $appointment_not_honored_to_fourteen->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_not_honored_to_nineteen = $appointment_not_honored_to_nineteen->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_not_honored_to_twentyfour = $appointment_not_honored_to_twentyfour->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_not_honored_to_twentyfive_above = $appointment_not_honored_to_twentyfive_above->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_not_honored_to_uknown_age = $appointment_not_honored_to_uknown_age->where('tbl_partner_facility.partner_id', $selected_partners);
+ }
+ if (!empty($selected_counties)) {
+ $appointment = $appointment->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_honoured = $appointment_honoured->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_not_honoured = $appointment_not_honoured->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_honoured_male = $appointment_honoured_male->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_honoured_female = $appointment_honoured_female->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_honoured_uknown_gender = $appointment_honoured_uknown_gender->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_honored_to_nine = $appointment_honored_to_nine->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_honored_to_fourteen = $appointment_honored_to_fourteen->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_honored_to_nineteen = $appointment_honored_to_nineteen->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_honored_to_twentyfour = $appointment_honored_to_twentyfour->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_honored_to_twentyfive_above = $appointment_honored_to_twentyfive_above->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_honored_to_uknown_age = $appointment_honored_to_uknown_age->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_not_honoured_male = $appointment_not_honoured_male->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_not_honoured_female = $appointment_not_honoured_female->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_not_honoured_uknown_gender = $appointment_not_honoured_uknown_gender->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_not_honored_to_nine = $appointment_not_honored_to_nine->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_not_honored_to_fourteen = $appointment_not_honored_to_fourteen->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_not_honored_to_nineteen = $appointment_not_honored_to_nineteen->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_not_honored_to_twentyfour = $appointment_not_honored_to_twentyfour->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_not_honored_to_twentyfive_above = $appointment_not_honored_to_twentyfive_above->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_not_honored_to_uknown_age = $appointment_not_honored_to_uknown_age->where('tbl_partner_facility.county_id', $selected_counties);
+ }
+ if (!empty($selected_subcounties)) {
+ $appointment = $appointment->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_honoured = $appointment_honoured->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_not_honoured = $appointment_not_honoured->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_honoured_male = $appointment_honoured_male->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_honoured_female = $appointment_honoured_female->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_honoured_uknown_gender = $appointment_honoured_uknown_gender->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_honored_to_nine = $appointment_honored_to_nine->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_honored_to_fourteen = $appointment_honored_to_fourteen->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_honored_to_nineteen = $appointment_honored_to_nineteen->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_honored_to_twentyfour = $appointment_honored_to_twentyfour->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_honored_to_twentyfive_above = $appointment_honored_to_twentyfive_above->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_honored_to_uknown_age = $appointment_honored_to_uknown_age->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_not_honoured_male = $appointment_not_honoured_male->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_not_honoured_female = $appointment_not_honoured_female->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_not_honoured_uknown_gender = $appointment_not_honoured_uknown_gender->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_not_honored_to_nine = $appointment_not_honored_to_nine->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_not_honored_to_fourteen = $appointment_not_honored_to_fourteen->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_not_honored_to_nineteen = $appointment_not_honored_to_nineteen->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_not_honored_to_twentyfour = $appointment_not_honored_to_twentyfour->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_not_honored_to_twentyfive_above = $appointment_not_honored_to_twentyfive_above->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_not_honored_to_uknown_age = $appointment_not_honored_to_uknown_age->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ }
+ if (!empty($selected_facilites)) {
+ $appointment = $appointment->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_honoured = $appointment_honoured->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_not_honoured = $appointment_not_honoured->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_honoured_male = $appointment_honoured_male->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_honoured_female = $appointment_honoured_female->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_honoured_uknown_gender = $appointment_honoured_uknown_gender->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_honored_to_nine = $appointment_honored_to_nine->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_honored_to_fourteen = $appointment_honored_to_fourteen->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_honored_to_nineteen = $appointment_honored_to_nineteen->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_honored_to_twentyfour = $appointment_honored_to_twentyfour->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_honored_to_twentyfive_above = $appointment_honored_to_twentyfive_above->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_honored_to_uknown_age = $appointment_honored_to_uknown_age->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_not_honoured_male = $appointment_not_honoured_male->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_not_honoured_female = $appointment_not_honoured_female->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_not_honoured_uknown_gender = $appointment_not_honoured_uknown_gender->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_not_honored_to_nine = $appointment_not_honored_to_nine->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_not_honored_to_fourteen = $appointment_not_honored_to_fourteen->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_not_honored_to_nineteen = $appointment_not_honored_to_nineteen->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_not_honored_to_twentyfour = $appointment_not_honored_to_twentyfour->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_not_honored_to_twentyfive_above = $appointment_not_honored_to_twentyfive_above->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_not_honored_to_uknown_age = $appointment_not_honored_to_uknown_age->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ }
+ if (!empty($selected_from || $selected_to)) {
+ $appointment = $appointment->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_honoured = $appointment_honoured->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_not_honoured = $appointment_not_honoured->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_honoured_male = $appointment_honoured_male->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_honoured_female = $appointment_honoured_female->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_honoured_uknown_gender = $appointment_honoured_uknown_gender->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_honored_to_nine = $appointment_honored_to_nine->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_honored_to_fourteen = $appointment_honored_to_fourteen->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_honored_to_nineteen = $appointment_honored_to_nineteen->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_honored_to_twentyfour = $appointment_honored_to_twentyfour->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_honored_to_twentyfive_above = $appointment_honored_to_twentyfive_above->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_honored_to_uknown_age = $appointment_honored_to_uknown_age->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_not_honoured_male = $appointment_not_honoured_male->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_not_honoured_female = $appointment_not_honoured_female->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_not_honoured_uknown_gender = $appointment_not_honoured_uknown_gender->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_not_honored_to_nine = $appointment_not_honored_to_nine->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_not_honored_to_fourteen = $appointment_not_honored_to_fourteen->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_not_honored_to_nineteen = $appointment_not_honored_to_nineteen->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_not_honored_to_twentyfour = $appointment_not_honored_to_twentyfour->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_not_honored_to_twentyfive_above = $appointment_not_honored_to_twentyfive_above->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_not_honored_to_uknown_age = $appointment_not_honored_to_uknown_age->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ }
+ if (!empty($selected_module == 'DSD')) {
+ $appointment = $appointment->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_honoured = $appointment_honoured->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_not_honoured = $appointment_not_honoured->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_honoured_male = $appointment_honoured_male->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_honoured_female = $appointment_honoured_female->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_honoured_uknown_gender = $appointment_honoured_uknown_gender->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_honored_to_nine = $appointment_honored_to_nine->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_honored_to_fourteen = $appointment_honored_to_fourteen->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_honored_to_nineteen = $appointment_honored_to_nineteen->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_honored_to_twentyfour = $appointment_honored_to_twentyfour->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_honored_to_twentyfive_above = $appointment_honored_to_twentyfive_above->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_honored_to_uknown_age = $appointment_honored_to_uknown_age->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_not_honoured_male = $appointment_not_honoured_male->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_not_honoured_female = $appointment_not_honoured_female->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_not_honoured_uknown_gender = $appointment_not_honoured_uknown_gender->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_not_honored_to_nine = $appointment_not_honored_to_nine->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_not_honored_to_fourteen = $appointment_not_honored_to_fourteen->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_not_honored_to_nineteen = $appointment_not_honored_to_nineteen->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_not_honored_to_twentyfour = $appointment_not_honored_to_twentyfour->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_not_honored_to_twentyfive_above = $appointment_not_honored_to_twentyfive_above->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_not_honored_to_uknown_age = $appointment_not_honored_to_uknown_age->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ }
+ if (!empty($selected_module == 'PMTCT')) {
+ $appointment = $appointment->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_honoured = $appointment_honoured->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_not_honoured = $appointment_not_honoured->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_honoured_male = $appointment_honoured_male->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_honoured_female = $appointment_honoured_female->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_honoured_uknown_gender = $appointment_honoured_uknown_gender->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_honored_to_nine = $appointment_honored_to_nine->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_honored_to_fourteen = $appointment_honored_to_fourteen->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_honored_to_nineteen = $appointment_honored_to_nineteen->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_honored_to_twentyfour = $appointment_honored_to_twentyfour->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_honored_to_twentyfive_above = $appointment_honored_to_twentyfive_above->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_honored_to_uknown_age = $appointment_honored_to_uknown_age->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_not_honoured_male = $appointment_not_honoured_male->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_not_honoured_female = $appointment_not_honoured_female->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_not_honoured_uknown_gender = $appointment_not_honoured_uknown_gender->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_not_honored_to_nine = $appointment_not_honored_to_nine->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_not_honored_to_fourteen = $appointment_not_honored_to_fourteen->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_not_honored_to_nineteen = $appointment_not_honored_to_nineteen->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_not_honored_to_twentyfour = $appointment_not_honored_to_twentyfour->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_not_honored_to_twentyfive_above = $appointment_not_honored_to_twentyfive_above->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_not_honored_to_uknown_age = $appointment_not_honored_to_uknown_age->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ }
+
+ $data["appointment"] = $appointment->count();
+ $data["appointment_honoured"] = $appointment_honoured->count();
+ $data["appointment_not_honoured"] = $appointment_not_honoured->count();
+ $data["appointment_honoured_male"] = $appointment_honoured_male->count();
+ $data["appointment_honoured_female"] = $appointment_honoured_female->count();
+ $data["appointment_honoured_uknown_gender"] = $appointment_honoured_uknown_gender->count();
+ $data["appointment_honored_to_nine"] = $appointment_honored_to_nine->pluck('count');
+ $data["appointment_honored_to_fourteen"] = $appointment_honored_to_fourteen->pluck('count');
+ $data["appointment_honored_to_nineteen"] = $appointment_honored_to_nineteen->pluck('count');
+ $data["appointment_honored_to_twentyfour"] = $appointment_honored_to_twentyfour->pluck('count');
+ $data["appointment_honored_to_twentyfive_above"] = $appointment_honored_to_twentyfive_above->pluck('count');
+ $data["appointment_honored_to_uknown_age"] = $appointment_honored_to_uknown_age->count();
+ $data["appointment_not_honoured_male"] = $appointment_not_honoured_male->count();
+ $data["appointment_not_honoured_female"] = $appointment_not_honoured_female->count();
+ $data["appointment_not_honoured_uknown_gender"] = $appointment_not_honoured_uknown_gender->count();
+ $data["appointment_not_honored_to_nine"] = $appointment_not_honored_to_nine->pluck('count');
+ $data["appointment_not_honored_to_fourteen"] = $appointment_not_honored_to_fourteen->pluck('count');
+ $data["appointment_not_honored_to_nineteen"] = $appointment_not_honored_to_nineteen->pluck('count');
+ $data["appointment_not_honored_to_twentyfour"] = $appointment_not_honored_to_twentyfour->pluck('count');
+ $data["appointment_not_honored_to_twentyfive_above"] = $appointment_not_honored_to_twentyfive_above->pluck('count');
+ $data["appointment_not_honored_to_uknown_age"] = $appointment_not_honored_to_uknown_age->count();
+
+ return $data;
+ }
+ public function filter_missed_appointment_charts(Request $request)
+ {
+ $data = [];
+ // client charts
+ $selected_partners = $request->partners;
+ $selected_counties = $request->counties;
+ $selected_subcounties = $request->subcounties;
+ $selected_facilites = $request->facilities;
+ $selected_from = $request->from;
+ $selected_to = $request->to;
+ $selected_module = $request->module;
+
+ if (Auth::user()->access_level == 'Facility') {
+ $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(\DB::raw("COUNT(id) as count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+ // 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('app_status', '=', 'Missed')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $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('app_status', '=', 'Defaulted')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $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('app_status', '=', 'LTFU')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+ // 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_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $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_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $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_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ // 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_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $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_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $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_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ // 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_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $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_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $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_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+ }
+ if (Auth::user()->access_level == 'Partner') {
+ $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(\DB::raw("COUNT(id) as count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+ // 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('app_status', '=', 'Missed')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ $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('app_status', '=', 'Defaulted')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ $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('app_status', '=', 'LTFU')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ // 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)
+ ->remember($this->remember_period);
+
+ $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)
+ ->remember($this->remember_period);
+
+ $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)
+ ->remember($this->remember_period);
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ $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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ // 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)
+ ->remember($this->remember_period);
+
+ $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)
+ ->remember($this->remember_period);
+
+ $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)
+ ->remember($this->remember_period);
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ $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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ // 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)
+ ->remember($this->remember_period);
+
+ $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)
+ ->remember($this->remember_period);
+
+ $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)
+ ->remember($this->remember_period);
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ $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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+ }
+ if (Auth::user()->access_level == 'Sub County') {
+ $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(\DB::raw("COUNT(id) as count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+ // 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('app_status', '=', 'Missed')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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('app_status', '=', 'Defaulted')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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('app_status', '=', 'LTFU')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+ // 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ // 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ // 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+ }
+ if (Auth::user()->access_level == 'County') {
+ $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(\DB::raw("COUNT(id) as count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+ // 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('app_status', '=', 'Missed')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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('app_status', '=', 'Defaulted')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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('app_status', '=', 'LTFU')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ // 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ // 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ // 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 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.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+ }
+ if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+ $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(\DB::raw("COUNT(id) as count"))
+ ->whereIn('app_status', ['Defaulted', 'LTFU', 'Missed'])
+ ->remember($this->remember_period);
+ // 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('app_status', '=', 'Missed')
+ ->remember($this->remember_period);
+
+ $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('app_status', '=', 'Defaulted')
+ ->remember($this->remember_period);
+
+ $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('app_status', '=', 'LTFU')
+ ->remember($this->remember_period);
+
+ // 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')
+ ->remember($this->remember_period);
+
+ $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')
+ ->remember($this->remember_period);
+
+ $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')
+ ->remember($this->remember_period);
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->remember($this->remember_period);
+
+ $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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->remember($this->remember_period);
+
+ // 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')
+ ->remember($this->remember_period);
+
+ $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')
+ ->remember($this->remember_period);
+
+ $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')
+ ->remember($this->remember_period);
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->remember($this->remember_period);
+
+ $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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->remember($this->remember_period);
+
+ // 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')
+ ->remember($this->remember_period);
+
+ $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')
+ ->remember($this->remember_period);
+
+ $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')
+ ->remember($this->remember_period);
+
+ // 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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 9)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 10) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 14)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 15) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 19)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 20) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 24)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->remember($this->remember_period);
+
+ $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(CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END)) >= 25)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->remember($this->remember_period);
+
+ $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')
+ ->where(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"), '=', '')
+ ->orWhereNull(\DB::raw("CASE
+ WHEN ( locate( '/', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%m/%d/%Y' ), '%Y-%m-%d' )
+ WHEN ( locate( '-', `tbl_client`.`dob` ) > 0 ) THEN
+ date_format( str_to_date( `tbl_client`.`dob`, '%Y-%m-%d' ), '%Y-%m-%d' ) END"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->remember($this->remember_period);
+ }
+
+ if (!empty($selected_partners)) {
+ $appointment_not_honoured = $appointment_not_honoured->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_missed = $appointment_missed->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_defaulted = $appointment_defaulted->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_lftu = $appointment_lftu->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_missed_female = $appointment_missed_female->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_missed_male = $appointment_missed_male->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_missed_uknown_gender = $appointment_missed_uknown_gender->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_missed_to_nine = $appointment_missed_to_nine->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_missed_to_fourteen = $appointment_missed_to_fourteen->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_missed_to_nineteen = $appointment_missed_to_nineteen->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_missed_to_twentyfour = $appointment_missed_to_twentyfour->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_missed_to_twentyfive_above = $appointment_missed_to_twentyfive_above->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_missed_to_uknown_age = $appointment_missed_to_uknown_age->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_defaulted_female = $appointment_defaulted_female->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_defaulted_male = $appointment_defaulted_male->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_defaulted_uknown_gender = $appointment_defaulted_uknown_gender->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_defaulted_to_nine = $appointment_defaulted_to_nine->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_defaulted_to_fourteen = $appointment_defaulted_to_fourteen->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_defaulted_to_nineteen = $appointment_defaulted_to_nineteen->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_defaulted_to_twentyfour = $appointment_defaulted_to_twentyfour->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_defaulted_to_twentyfive_above = $appointment_defaulted_to_twentyfive_above->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_defaulted_to_uknown_age = $appointment_defaulted_to_uknown_age->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_ltfu_female = $appointment_ltfu_female->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_ltfu_male = $appointment_ltfu_male->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_ltfu_uknown_gender = $appointment_ltfu_uknown_gender->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_ltfu_to_nine = $appointment_ltfu_to_nine->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_ltfu_to_fourteen = $appointment_ltfu_to_fourteen->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_ltfu_to_nineteen = $appointment_ltfu_to_nineteen->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_ltfu_to_twentyfour = $appointment_ltfu_to_twentyfour->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_ltfu_to_twentyfive_above = $appointment_ltfu_to_twentyfive_above->where('tbl_partner_facility.partner_id', $selected_partners);
+ $appointment_ltfu_to_uknown_age = $appointment_ltfu_to_uknown_age->where('tbl_partner_facility.partner_id', $selected_partners);
+ }
+ if (!empty($selected_counties)) {
+ $appointment_not_honoured = $appointment_not_honoured->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_missed = $appointment_missed->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_defaulted = $appointment_defaulted->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_lftu = $appointment_lftu->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_missed_female = $appointment_missed_female->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_missed_male = $appointment_missed_male->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_missed_uknown_gender = $appointment_missed_uknown_gender->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_missed_to_nine = $appointment_missed_to_nine->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_missed_to_fourteen = $appointment_missed_to_fourteen->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_missed_to_nineteen = $appointment_missed_to_nineteen->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_missed_to_twentyfour = $appointment_missed_to_twentyfour->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_missed_to_twentyfive_above = $appointment_missed_to_twentyfive_above->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_missed_to_uknown_age = $appointment_missed_to_uknown_age->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_defaulted_female = $appointment_defaulted_female->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_defaulted_male = $appointment_defaulted_male->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_defaulted_uknown_gender = $appointment_defaulted_uknown_gender->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_defaulted_to_nine = $appointment_defaulted_to_nine->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_defaulted_to_fourteen = $appointment_defaulted_to_fourteen->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_defaulted_to_nineteen = $appointment_defaulted_to_nineteen->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_defaulted_to_twentyfour = $appointment_defaulted_to_twentyfour->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_defaulted_to_twentyfive_above = $appointment_defaulted_to_twentyfive_above->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_defaulted_to_uknown_age = $appointment_defaulted_to_uknown_age->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_ltfu_female = $appointment_ltfu_female->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_ltfu_male = $appointment_ltfu_male->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_ltfu_uknown_gender = $appointment_ltfu_uknown_gender->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_ltfu_to_nine = $appointment_ltfu_to_nine->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_ltfu_to_fourteen = $appointment_ltfu_to_fourteen->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_ltfu_to_nineteen = $appointment_ltfu_to_nineteen->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_ltfu_to_twentyfour = $appointment_ltfu_to_twentyfour->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_ltfu_to_twentyfive_above = $appointment_ltfu_to_twentyfive_above->where('tbl_partner_facility.county_id', $selected_counties);
+ $appointment_ltfu_to_uknown_age = $appointment_ltfu_to_uknown_age->where('tbl_partner_facility.county_id', $selected_counties);
+ }
+ if (!empty($selected_subcounties)) {
+ $appointment_not_honoured = $appointment_not_honoured->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_missed = $appointment_missed->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_defaulted = $appointment_defaulted->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_lftu = $appointment_lftu->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_missed_female = $appointment_missed_female->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_missed_male = $appointment_missed_male->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_missed_uknown_gender = $appointment_missed_uknown_gender->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_missed_to_nine = $appointment_missed_to_nine->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_missed_to_fourteen = $appointment_missed_to_fourteen->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_missed_to_nineteen = $appointment_missed_to_nineteen->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_missed_to_twentyfour = $appointment_missed_to_twentyfour->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_missed_to_twentyfive_above = $appointment_missed_to_twentyfive_above->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_missed_to_uknown_age = $appointment_missed_to_uknown_age->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_defaulted_female = $appointment_defaulted_female->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_defaulted_male = $appointment_defaulted_male->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_defaulted_uknown_gender = $appointment_defaulted_uknown_gender->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_defaulted_to_nine = $appointment_defaulted_to_nine->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_defaulted_to_fourteen = $appointment_defaulted_to_fourteen->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_defaulted_to_nineteen = $appointment_defaulted_to_nineteen->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_defaulted_to_twentyfour = $appointment_defaulted_to_twentyfour->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_defaulted_to_twentyfive_above = $appointment_defaulted_to_twentyfive_above->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_defaulted_to_uknown_age = $appointment_defaulted_to_uknown_age->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_ltfu_female = $appointment_ltfu_female->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_ltfu_male = $appointment_ltfu_male->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_ltfu_uknown_gender = $appointment_ltfu_uknown_gender->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_ltfu_to_nine = $appointment_ltfu_to_nine->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_ltfu_to_fourteen = $appointment_ltfu_to_fourteen->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_ltfu_to_nineteen = $appointment_ltfu_to_nineteen->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_ltfu_to_twentyfour = $appointment_ltfu_to_twentyfour->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_ltfu_to_twentyfive_above = $appointment_ltfu_to_twentyfive_above->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $appointment_ltfu_to_uknown_age = $appointment_ltfu_to_uknown_age->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ }
+ if (!empty($selected_facilites)) {
+ $appointment_not_honoured = $appointment_not_honoured->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_missed = $appointment_missed->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_defaulted = $appointment_defaulted->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_lftu = $appointment_lftu->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_missed_female = $appointment_missed_female->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_missed_male = $appointment_missed_male->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_missed_uknown_gender = $appointment_missed_uknown_gender->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_missed_to_nine = $appointment_missed_to_nine->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_missed_to_fourteen = $appointment_missed_to_fourteen->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_missed_to_nineteen = $appointment_missed_to_nineteen->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_missed_to_twentyfour = $appointment_missed_to_twentyfour->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_missed_to_twentyfive_above = $appointment_missed_to_twentyfive_above->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_missed_to_uknown_age = $appointment_missed_to_uknown_age->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_defaulted_female = $appointment_defaulted_female->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_defaulted_male = $appointment_defaulted_male->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_defaulted_uknown_gender = $appointment_defaulted_uknown_gender->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_defaulted_to_nine = $appointment_defaulted_to_nine->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_defaulted_to_fourteen = $appointment_defaulted_to_fourteen->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_defaulted_to_nineteen = $appointment_defaulted_to_nineteen->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_defaulted_to_twentyfour = $appointment_defaulted_to_twentyfour->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_defaulted_to_twentyfive_above = $appointment_defaulted_to_twentyfive_above->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_defaulted_to_uknown_age = $appointment_defaulted_to_uknown_age->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_ltfu_female = $appointment_ltfu_female->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_ltfu_male = $appointment_ltfu_male->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_ltfu_uknown_gender = $appointment_ltfu_uknown_gender->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_ltfu_to_nine = $appointment_ltfu_to_nine->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_ltfu_to_fourteen = $appointment_ltfu_to_fourteen->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_ltfu_to_nineteen = $appointment_ltfu_to_nineteen->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_ltfu_to_twentyfour = $appointment_ltfu_to_twentyfour->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_ltfu_to_twentyfive_above = $appointment_ltfu_to_twentyfive_above->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $appointment_ltfu_to_uknown_age = $appointment_ltfu_to_uknown_age->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ }
+ if (!empty($selected_from || $selected_to)) {
+ $appointment_not_honoured = $appointment_not_honoured->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_missed = $appointment_missed->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_defaulted = $appointment_defaulted->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_lftu = $appointment_lftu->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_missed_female = $appointment_missed_female->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_missed_male = $appointment_missed_male->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_missed_uknown_gender = $appointment_missed_uknown_gender->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_missed_to_nine = $appointment_missed_to_nine->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_missed_to_fourteen = $appointment_missed_to_fourteen->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_missed_to_nineteen = $appointment_missed_to_nineteen->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_missed_to_twentyfour = $appointment_missed_to_twentyfour->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_missed_to_twentyfive_above = $appointment_missed_to_twentyfive_above->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_missed_to_uknown_age = $appointment_missed_to_uknown_age->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_defaulted_female = $appointment_defaulted_female->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_defaulted_male = $appointment_defaulted_male->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_defaulted_uknown_gender = $appointment_defaulted_uknown_gender->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_defaulted_to_nine = $appointment_defaulted_to_nine->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_defaulted_to_fourteen = $appointment_defaulted_to_fourteen->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_defaulted_to_nineteen = $appointment_defaulted_to_nineteen->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_defaulted_to_twentyfour = $appointment_defaulted_to_twentyfour->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_defaulted_to_twentyfive_above = $appointment_defaulted_to_twentyfive_above->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_defaulted_to_uknown_age = $appointment_defaulted_to_uknown_age->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_ltfu_female = $appointment_ltfu_female->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_ltfu_male = $appointment_ltfu_male->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_ltfu_uknown_gender = $appointment_ltfu_uknown_gender->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_ltfu_to_nine = $appointment_ltfu_to_nine->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_ltfu_to_fourteen = $appointment_ltfu_to_fourteen->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_ltfu_to_nineteen = $appointment_ltfu_to_nineteen->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_ltfu_to_twentyfour = $appointment_ltfu_to_twentyfour->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_ltfu_to_twentyfive_above = $appointment_ltfu_to_twentyfive_above->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ $appointment_ltfu_to_uknown_age = $appointment_ltfu_to_uknown_age->where('tbl_appointment.created_at', '>=', date($request->from))->where('tbl_appointment.created_at', '<=', date($request->to));
+ }
+ if (!empty($selected_module == 'DSD')) {
+ $appointment_not_honoured = $appointment_not_honoured->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_missed = $appointment_missed->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_defaulted = $appointment_defaulted->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_lftu = $appointment_lftu->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_missed_female = $appointment_missed_female->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_missed_male = $appointment_missed_male->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_missed_uknown_gender = $appointment_missed_uknown_gender->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_missed_to_nine = $appointment_missed_to_nine->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_missed_to_fourteen = $appointment_missed_to_fourteen->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_missed_to_nineteen = $appointment_missed_to_nineteen->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_missed_to_twentyfour = $appointment_missed_to_twentyfour->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_missed_to_twentyfive_above = $appointment_missed_to_twentyfive_above->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_missed_to_uknown_age = $appointment_missed_to_uknown_age->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_defaulted_female = $appointment_defaulted_female->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_defaulted_male = $appointment_defaulted_male->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_defaulted_uknown_gender = $appointment_defaulted_uknown_gender->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_defaulted_to_nine = $appointment_defaulted_to_nine->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_defaulted_to_fourteen = $appointment_defaulted_to_fourteen->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_defaulted_to_nineteen = $appointment_defaulted_to_nineteen->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_defaulted_to_twentyfour = $appointment_defaulted_to_twentyfour->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_defaulted_to_twentyfive_above = $appointment_defaulted_to_twentyfive_above->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_defaulted_to_uknown_age = $appointment_defaulted_to_uknown_age->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_ltfu_female = $appointment_ltfu_female->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_ltfu_male = $appointment_ltfu_male->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_ltfu_uknown_gender = $appointment_ltfu_uknown_gender->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_ltfu_to_nine = $appointment_ltfu_to_nine->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_ltfu_to_fourteen = $appointment_ltfu_to_fourteen->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_ltfu_to_nineteen = $appointment_ltfu_to_nineteen->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_ltfu_to_twentyfour = $appointment_ltfu_to_twentyfour->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_ltfu_to_twentyfive_above = $appointment_ltfu_to_twentyfive_above->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ $appointment_ltfu_to_uknown_age = $appointment_ltfu_to_uknown_age->join('tbl_dfc_module', 'tbl_client.id', '=', 'tbl_dfc_module.client_id');
+ }
+ if (!empty($selected_module == 'PMTCT')) {
+ $appointment_not_honoured = $appointment_not_honoured->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_missed = $appointment_missed->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_defaulted = $appointment_defaulted->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_lftu = $appointment_lftu->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_missed_female = $appointment_missed_female->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_missed_male = $appointment_missed_male->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_missed_uknown_gender = $appointment_missed_uknown_gender->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_missed_to_nine = $appointment_missed_to_nine->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_missed_to_fourteen = $appointment_missed_to_fourteen->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_missed_to_nineteen = $appointment_missed_to_nineteen->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_missed_to_twentyfour = $appointment_missed_to_twentyfour->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_missed_to_twentyfive_above = $appointment_missed_to_twentyfive_above->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_missed_to_uknown_age = $appointment_missed_to_uknown_age->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_defaulted_female = $appointment_defaulted_female->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_defaulted_male = $appointment_defaulted_male->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_defaulted_uknown_gender = $appointment_defaulted_uknown_gender->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_defaulted_to_nine = $appointment_defaulted_to_nine->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_defaulted_to_fourteen = $appointment_defaulted_to_fourteen->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_defaulted_to_nineteen = $appointment_defaulted_to_nineteen->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_defaulted_to_twentyfour = $appointment_defaulted_to_twentyfour->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_defaulted_to_twentyfive_above = $appointment_defaulted_to_twentyfive_above->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_defaulted_to_uknown_age = $appointment_defaulted_to_uknown_age->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_ltfu_female = $appointment_ltfu_female->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_ltfu_male = $appointment_ltfu_male->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_ltfu_uknown_gender = $appointment_ltfu_uknown_gender->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_ltfu_to_nine = $appointment_ltfu_to_nine->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_ltfu_to_fourteen = $appointment_ltfu_to_fourteen->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_ltfu_to_nineteen = $appointment_ltfu_to_nineteen->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_ltfu_to_twentyfour = $appointment_ltfu_to_twentyfour->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_ltfu_to_twentyfive_above = $appointment_ltfu_to_twentyfive_above->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ $appointment_ltfu_to_uknown_age = $appointment_ltfu_to_uknown_age->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id');
+ }
+
+ $data["appointment_not_honoured"] = $appointment_not_honoured->count();
+ $data["appointment_missed"] = $appointment_missed->count();
+ $data["appointment_defaulted"] = $appointment_defaulted->count();
+ $data["appointment_lftu"] = $appointment_lftu->count();
+ $data["appointment_missed_female"] = $appointment_missed_female->count();
+ $data["appointment_missed_male"] = $appointment_missed_male->count();
+ $data["appointment_missed_uknown_gender"] = $appointment_missed_uknown_gender->count();
+ $data["appointment_missed_to_nine"] = $appointment_missed_to_nine->pluck('count');
+ $data["appointment_missed_to_fourteen"] = $appointment_missed_to_fourteen->pluck('count');
+ $data["appointment_missed_to_nineteen"] = $appointment_missed_to_nineteen->pluck('count');
+ $data["appointment_missed_to_twentyfour"] = $appointment_missed_to_twentyfour->pluck('count');
+ $data["appointment_missed_to_twentyfive_above"] = $appointment_missed_to_twentyfive_above->pluck('count');
+ $data["appointment_missed_to_uknown_age"] = $appointment_missed_to_uknown_age->count();
+ $data["appointment_defaulted_female"] = $appointment_defaulted_female->count();
+ $data["appointment_defaulted_male"] = $appointment_defaulted_male->count();
+ $data["appointment_defaulted_uknown_gender"] = $appointment_defaulted_uknown_gender->count();
+ $data["appointment_defaulted_to_nine"] = $appointment_defaulted_to_nine->pluck('count');
+ $data["appointment_defaulted_to_fourteen"] = $appointment_defaulted_to_fourteen->pluck('count');
+ $data["appointment_defaulted_to_nineteen"] = $appointment_defaulted_to_nineteen->pluck('count');
+ $data["appointment_defaulted_to_twentyfour"] = $appointment_defaulted_to_twentyfour->pluck('count');
+ $data["appointment_defaulted_to_twentyfive_above"] = $appointment_defaulted_to_twentyfive_above->pluck('count');
+ $data["appointment_defaulted_to_uknown_age"] = $appointment_defaulted_to_uknown_age->count();
+ $data["appointment_ltfu_female"] = $appointment_ltfu_female->count();
+ $data["appointment_ltfu_male"] = $appointment_ltfu_male->count();
+ $data["appointment_ltfu_uknown_gender"] = $appointment_ltfu_uknown_gender->count();
+ $data["appointment_ltfu_to_nine"] = $appointment_ltfu_to_nine->pluck('count');
+ $data["appointment_ltfu_to_fourteen"] = $appointment_ltfu_to_fourteen->pluck('count');
+ $data["appointment_ltfu_to_nineteen"] = $appointment_ltfu_to_nineteen->pluck('count');
+ $data["appointment_ltfu_to_twentyfour"] = $appointment_ltfu_to_twentyfour->pluck('count');
+ $data["appointment_ltfu_to_twentyfive_above"] = $appointment_ltfu_to_twentyfive_above->pluck('count');
+ $data["appointment_ltfu_to_uknown_age"] = $appointment_ltfu_to_uknown_age->count();
+
+ return $data;
+ }
+}
diff --git a/app/Http/Controllers/NewReportController.php b/app/Http/Controllers/NewReportController.php
new file mode 100644
index 0000000..8d2b035
--- /dev/null
+++ b/app/Http/Controllers/NewReportController.php
@@ -0,0 +1,508 @@
+access_level == 'Facility') {
+ $gender = Gender::all();
+ $marital = Marital::all();
+ $treatment = Condition::all();
+ $grouping = Group::all()->where('status', '=', 'Active');
+ $clinics = Clinic::all();
+ $time = Time::all();
+ $county = County::where('status', '=', 'Active')->pluck('name', 'id');
+ $language = Language::all()->where('status', '=', 'Active');
+
+ $clients = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->join('tbl_master_facility', 'tbl_client.mfl_code', '=', 'tbl_master_facility.code')
+ ->join('tbl_partner', 'tbl_partner_facility.partner_id', '=', 'tbl_partner.id')
+ ->join('tbl_gender', 'tbl_client.gender', '=', 'tbl_gender.id')
+ ->join('tbl_groups', 'tbl_client.group_id', '=', 'tbl_groups.id')
+ ->join('tbl_language', 'tbl_client.language_id', '=', 'tbl_language.id')
+ ->join('tbl_condition', 'tbl_client.client_status', '=', 'tbl_condition.name')
+ ->join('tbl_marital_status', 'tbl_client.marital', '=', 'tbl_marital_status.id')
+ ->join('tbl_county', 'tbl_partner_facility.county_id', '=', 'tbl_county.id')
+ ->select(
+ 'tbl_client.id',
+ 'tbl_client.clinic_number',
+ 'tbl_client.f_name',
+ 'tbl_client.m_name',
+ 'tbl_client.l_name',
+ 'tbl_client.dob',
+ 'tbl_client.created_at',
+ 'tbl_client.smsenable',
+ DB::raw('DATE(tbl_client.enrollment_date) AS enrollment_date'),
+ DB::raw('DATE(tbl_client.art_date) AS art_date'),
+ 'tbl_client.motivational_enable',
+ 'tbl_client.phone_no',
+ 'tbl_client.clinic_id',
+ 'tbl_client.client_status',
+ 'tbl_client.status',
+ 'tbl_client.language_id',
+ 'tbl_client.group_id',
+ 'tbl_client.txt_time',
+ 'tbl_condition.id as client_treatment',
+ 'tbl_gender.id as gender',
+ 'tbl_gender.name as gender_name',
+ 'tbl_marital_status.id as marital',
+ 'tbl_master_facility.code',
+ 'tbl_master_facility.name as facility',
+ 'tbl_partner.name as partner',
+ 'tbl_county.name as county',
+ 'tbl_client.locator_county',
+ 'tbl_client.locator_sub_county',
+ 'tbl_client.locator_ward',
+ 'tbl_client.locator_village',
+ 'tbl_client.locator_location',
+ 'tbl_client.upi_no'
+ )
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->paginate(20000);
+ }
+ if (Auth::user()->access_level == 'Partner') {
+ $gender = Gender::all();
+ $marital = Marital::all();
+ $treatment = Condition::all();
+ $grouping = Group::all()->where('status', '=', 'Active');
+ $clinics = Clinic::all();
+ $time = Time::all();
+ $county = County::where('status', '=', 'Active')->pluck('name', 'id');
+ $language = Language::all()->where('status', '=', 'Active');
+
+ $clients = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->join('tbl_master_facility', 'tbl_client.mfl_code', '=', 'tbl_master_facility.code')
+ ->join('tbl_partner', 'tbl_partner_facility.partner_id', '=', 'tbl_partner.id')
+ ->join('tbl_gender', 'tbl_client.gender', '=', 'tbl_gender.id')
+ ->join('tbl_groups', 'tbl_client.group_id', '=', 'tbl_groups.id')
+ ->join('tbl_language', 'tbl_client.language_id', '=', 'tbl_language.id')
+ ->join('tbl_condition', 'tbl_client.client_status', '=', 'tbl_condition.name')
+ ->join('tbl_marital_status', 'tbl_client.marital', '=', 'tbl_marital_status.id')
+ ->join('tbl_county', 'tbl_partner_facility.county_id', '=', 'tbl_county.id')
+ ->select(
+ 'tbl_client.id',
+ 'tbl_client.clinic_number',
+ 'tbl_client.f_name',
+ 'tbl_client.m_name',
+ 'tbl_client.l_name',
+ 'tbl_client.dob',
+ 'tbl_client.created_at',
+ 'tbl_client.smsenable',
+ DB::raw('DATE(tbl_client.enrollment_date) AS enrollment_date'),
+ DB::raw('DATE(tbl_client.art_date) AS art_date'),
+ 'tbl_client.motivational_enable',
+ 'tbl_client.phone_no',
+ 'tbl_client.clinic_id',
+ 'tbl_client.client_status',
+ 'tbl_client.status',
+ 'tbl_client.language_id',
+ 'tbl_client.group_id',
+ 'tbl_client.txt_time',
+ 'tbl_condition.id as client_treatment',
+ 'tbl_gender.id as gender',
+ 'tbl_gender.name as gender_name',
+ 'tbl_marital_status.id as marital',
+ 'tbl_master_facility.code',
+ 'tbl_master_facility.name as facility',
+ 'tbl_partner.name as partner',
+ 'tbl_county.name as county',
+ 'tbl_client.locator_county',
+ 'tbl_client.locator_sub_county',
+ 'tbl_client.locator_ward',
+ 'tbl_client.locator_village',
+ 'tbl_client.locator_location',
+ 'tbl_client.upi_no'
+ )
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->paginate(1000);
+ }
+ if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+ $gender = Gender::all();
+ $marital = Marital::all();
+ $treatment = Condition::all();
+ $grouping = Group::all()->where('status', '=', 'Active');
+ $clinics = Clinic::all();
+ $time = Time::all();
+ $county = County::where('status', '=', 'Active')->pluck('name', 'id');
+ $language = Language::all()->where('status', '=', 'Active');
+
+ $clients = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->join('tbl_master_facility', 'tbl_client.mfl_code', '=', 'tbl_master_facility.code')
+ ->join('tbl_partner', 'tbl_partner_facility.partner_id', '=', 'tbl_partner.id')
+ ->join('tbl_gender', 'tbl_client.gender', '=', 'tbl_gender.id')
+ ->join('tbl_groups', 'tbl_client.group_id', '=', 'tbl_groups.id')
+ ->join('tbl_language', 'tbl_client.language_id', '=', 'tbl_language.id')
+ ->join('tbl_condition', 'tbl_client.client_status', '=', 'tbl_condition.name')
+ ->join('tbl_marital_status', 'tbl_client.marital', '=', 'tbl_marital_status.id')
+ ->join('tbl_county', 'tbl_partner_facility.county_id', '=', 'tbl_county.id')
+ ->select(
+ 'tbl_client.id',
+ 'tbl_client.clinic_number',
+ 'tbl_client.f_name',
+ 'tbl_client.m_name',
+ 'tbl_client.l_name',
+ 'tbl_client.dob',
+ 'tbl_client.created_at',
+ 'tbl_client.smsenable',
+ DB::raw('DATE(tbl_client.enrollment_date) AS enrollment_date'),
+ DB::raw('DATE(tbl_client.art_date) AS art_date'),
+ 'tbl_client.motivational_enable',
+ 'tbl_client.phone_no',
+ 'tbl_client.clinic_id',
+ 'tbl_client.client_status',
+ 'tbl_client.status',
+ 'tbl_client.language_id',
+ 'tbl_client.group_id',
+ 'tbl_client.txt_time',
+ 'tbl_condition.id as client_treatment',
+ 'tbl_gender.id as gender',
+ 'tbl_gender.name as gender_name',
+ 'tbl_marital_status.id as marital',
+ 'tbl_master_facility.code',
+ 'tbl_master_facility.name as facility',
+ 'tbl_partner.name as partner',
+ 'tbl_county.name as county',
+ 'tbl_client.locator_county',
+ 'tbl_client.locator_sub_county',
+ 'tbl_client.locator_ward',
+ 'tbl_client.locator_village',
+ 'tbl_client.locator_location',
+ 'tbl_client.upi_no'
+ )
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->paginate(1000);
+ }
+
+ return view('new_reports.clients', compact('clients', 'gender', 'marital', 'clinics', 'time', 'treatment', 'language', 'grouping', 'county'));
+ }
+ public function edit_client(Request $request)
+ {
+
+ try {
+ $client = Client::where('id', $request->id)
+ ->update([
+ 'clinic_number' => $request->clinic_number,
+ 'f_name' => $request->first_name,
+ 'm_name' => $request->middle_name,
+ 'l_name' => $request->last_name,
+ 'dob' => $request->birth,
+ 'gender' => $request->gender,
+ 'marital' => $request->marital,
+ 'client_status' => $request->treatment,
+ 'enrollment_date' => date("Y-m-d", strtotime($request->enrollment_date)),
+ 'art_date' => date("Y-m-d", strtotime($request->art_date)),
+ 'phone_no' => $request->phone,
+ 'language_id' => $request->language,
+ 'smsenable' => $request->smsenable,
+ 'motivational_enable' => $request->motivational_enable,
+ 'txt_time' => $request->txt_time,
+ 'status' => $request->status,
+ 'group_id' => $request->group,
+ 'clinic_id' => $request->clinic,
+ 'locator_county' => $request->county,
+ 'locator_sub_county' => $request->subcounty,
+ 'locator_ward' => $request->ward,
+ 'locator_location' => $request->location,
+ 'locator_village' => $request->village,
+ ]);
+
+ if ($client) {
+ Session::flash('statuscode', 'success');
+ return redirect('new/clients/list')->with('status', 'Client' . ' ' . $request->clinic_number . ' ' . 'details was successfully updated!');
+ } else {
+ Session::flash('statuscode', 'error');
+ return back()->with('error', 'Could not update client details please try again later.');
+ }
+ } catch (Exception $e) {
+ $code = $e->getCode();
+
+ if ((string)$code === (string)"23000") {
+
+ Session::flash('statuscode', 'success');
+ return back()->with('status', 'Clinic Number' . ' ' . $request->clinic_number . ' ' . 'belongs to another client! ');
+ } else {
+ return back();
+ }
+ }
+ }
+
+ public function appointment_list()
+ {
+ if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+ $appointments = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->join('tbl_master_facility', 'tbl_client.mfl_code', '=', 'tbl_master_facility.code')
+ ->join('tbl_partner', 'tbl_partner_facility.partner_id', '=', 'tbl_partner.id')
+ ->join('tbl_gender', 'tbl_client.gender', '=', 'tbl_gender.id')
+ ->join('tbl_county', 'tbl_partner_facility.county_id', '=', 'tbl_county.id')
+ ->join('tbl_appointment_types', 'tbl_appointment.app_type_1', '=', 'tbl_appointment_types.id')
+ ->select('tbl_client.clinic_number', 'tbl_client.f_name', 'tbl_client.m_name', 'tbl_client.l_name', 'tbl_client.dob', 'tbl_client.smsenable', 'tbl_client.phone_no', 'tbl_gender.name as gender', 'tbl_appointment_types.name as app_type', 'tbl_appointment.appntmnt_date', 'tbl_appointment.app_status', 'tbl_appointment.created_at', 'tbl_master_facility.code', 'tbl_master_facility.name as facility', 'tbl_partner.name as partner', 'tbl_county.name as county')
+ ->where('tbl_client.status', '=', 'Active')
+ ->paginate(1000);
+ }
+ if (Auth::user()->access_level == 'Facility') {
+ $appointments = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->join('tbl_master_facility', 'tbl_client.mfl_code', '=', 'tbl_master_facility.code')
+ ->join('tbl_partner', 'tbl_partner_facility.partner_id', '=', 'tbl_partner.id')
+ ->join('tbl_gender', 'tbl_client.gender', '=', 'tbl_gender.id')
+ ->join('tbl_county', 'tbl_partner_facility.county_id', '=', 'tbl_county.id')
+ ->join('tbl_appointment_types', 'tbl_appointment.app_type_1', '=', 'tbl_appointment_types.id')
+ ->select('tbl_client.clinic_number', 'tbl_client.f_name', 'tbl_client.m_name', 'tbl_client.l_name', 'tbl_client.dob', 'tbl_client.smsenable', 'tbl_client.phone_no', 'tbl_gender.name as gender', 'tbl_appointment_types.name as app_type', 'tbl_appointment.appntmnt_date', 'tbl_appointment.app_status', 'tbl_appointment.created_at', 'tbl_master_facility.code', 'tbl_master_facility.name as facility', 'tbl_partner.name as partner', 'tbl_county.name as county')
+ ->where('tbl_client.status', '=', 'Active')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->paginate(1000);
+ }
+ if (Auth::user()->access_level == 'Partner') {
+ $appointments = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->join('tbl_master_facility', 'tbl_client.mfl_code', '=', 'tbl_master_facility.code')
+ ->join('tbl_partner', 'tbl_partner_facility.partner_id', '=', 'tbl_partner.id')
+ ->join('tbl_gender', 'tbl_client.gender', '=', 'tbl_gender.id')
+ ->join('tbl_county', 'tbl_partner_facility.county_id', '=', 'tbl_county.id')
+ ->join('tbl_appointment_types', 'tbl_appointment.app_type_1', '=', 'tbl_appointment_types.id')
+ ->select('tbl_client.clinic_number', 'tbl_client.f_name', 'tbl_client.m_name', 'tbl_client.l_name', 'tbl_client.dob', 'tbl_client.smsenable', 'tbl_client.phone_no', 'tbl_gender.name as gender', 'tbl_appointment_types.name as app_type', 'tbl_appointment.appntmnt_date', 'tbl_appointment.app_status', 'tbl_appointment.created_at', 'tbl_master_facility.code', 'tbl_master_facility.name as facility', 'tbl_partner.name as partner', 'tbl_county.name as county')
+ ->where('tbl_client.status', '=', 'Active')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->paginate(1000);
+ }
+
+ return view('new_reports.appointments', compact('appointments'));
+ }
+ public function active_facility()
+ {
+ if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+ $active_facilities = PartnerFacility::join('tbl_client', 'tbl_partner_facility.mfl_code', '=', 'tbl_client.mfl_code')
+ ->join('tbl_master_facility', 'tbl_partner_facility.mfl_code', '=', 'tbl_master_facility.code')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner', 'tbl_partner_facility.partner_id', '=', 'tbl_partner.id')
+ ->join('tbl_county', 'tbl_partner_facility.county_id', '=', 'tbl_county.id')
+ ->join('tbl_sub_county', 'tbl_partner_facility.sub_county_id', '=', 'tbl_sub_county.id')
+ ->select('tbl_master_facility.code', 'tbl_master_facility.name as facility', 'tbl_partner.name as partner', 'tbl_county.name as county', 'tbl_sub_county.name as subcounty')
+ ->where('tbl_appointment.created_at', '>=', Carbon::now()->subMonths(6))
+ ->orderBy('tbl_appointment.created_at', 'DESC')
+ ->groupBy('tbl_partner_facility.mfl_code')
+ ->get();
+ }
+ if (Auth::user()->access_level == 'Partner') {
+ $active_facilities = PartnerFacility::join('tbl_client', 'tbl_partner_facility.mfl_code', '=', 'tbl_client.mfl_code')
+ ->join('tbl_master_facility', 'tbl_partner_facility.mfl_code', '=', 'tbl_master_facility.code')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner', 'tbl_partner_facility.partner_id', '=', 'tbl_partner.id')
+ ->join('tbl_county', 'tbl_partner_facility.county_id', '=', 'tbl_county.id')
+ ->join('tbl_sub_county', 'tbl_partner_facility.sub_county_id', '=', 'tbl_sub_county.id')
+ ->select('tbl_master_facility.code', 'tbl_master_facility.name as facility', 'tbl_partner.name as partner', 'tbl_county.name as county', 'tbl_sub_county.name as subcounty')
+ ->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();
+ }
+ if (Auth::user()->access_level == 'Sub County') {
+ $active_facilities = PartnerFacility::join('tbl_client', 'tbl_partner_facility.mfl_code', '=', 'tbl_client.mfl_code')
+ ->join('tbl_master_facility', 'tbl_partner_facility.mfl_code', '=', 'tbl_master_facility.code')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner', 'tbl_partner_facility.partner_id', '=', 'tbl_partner.id')
+ ->join('tbl_county', 'tbl_partner_facility.county_id', '=', 'tbl_county.id')
+ ->join('tbl_sub_county', 'tbl_partner_facility.sub_county_id', '=', 'tbl_sub_county.id')
+ ->select('tbl_master_facility.code', 'tbl_master_facility.name as facility', 'tbl_partner.name as partner', 'tbl_county.name as county', 'tbl_sub_county.name as subcounty')
+ ->where('tbl_appointment.created_at', '>=', Carbon::now()->subMonths(6))
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->orderBy('tbl_appointment.created_at', 'DESC')
+ ->groupBy('tbl_partner_facility.mfl_code')
+ ->get();
+ }
+ if (Auth::user()->access_level == 'County') {
+ $active_facilities = PartnerFacility::join('tbl_client', 'tbl_partner_facility.mfl_code', '=', 'tbl_client.mfl_code')
+ ->join('tbl_master_facility', 'tbl_partner_facility.mfl_code', '=', 'tbl_master_facility.code')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner', 'tbl_partner_facility.partner_id', '=', 'tbl_partner.id')
+ ->join('tbl_county', 'tbl_partner_facility.county_id', '=', 'tbl_county.id')
+ ->join('tbl_sub_county', 'tbl_partner_facility.sub_county_id', '=', 'tbl_sub_county.id')
+ ->select('tbl_master_facility.code', 'tbl_master_facility.name as facility', 'tbl_partner.name as partner', 'tbl_county.name as county', 'tbl_sub_county.name as subcounty')
+ ->where('tbl_appointment.created_at', '>=', Carbon::now()->subMonths(6))
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->orderBy('tbl_appointment.created_at', 'DESC')
+ ->groupBy('tbl_partner_facility.mfl_code')
+ ->get();
+ }
+ if (Auth::user()->access_level == 'Facility') {
+ $active_facilities = PartnerFacility::join('tbl_client', 'tbl_partner_facility.mfl_code', '=', 'tbl_client.mfl_code')
+ ->join('tbl_master_facility', 'tbl_partner_facility.mfl_code', '=', 'tbl_master_facility.code')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner', 'tbl_partner_facility.partner_id', '=', 'tbl_partner.id')
+ ->join('tbl_county', 'tbl_partner_facility.county_id', '=', 'tbl_county.id')
+ ->join('tbl_sub_county', 'tbl_partner_facility.sub_county_id', '=', 'tbl_sub_county.id')
+ ->select('tbl_master_facility.code', 'tbl_master_facility.name as facility', 'tbl_partner.name as partner', 'tbl_county.name as county', 'tbl_sub_county.name as subcounty')
+ ->where('tbl_appointment.created_at', '>=', Carbon::now()->subMonths(6))
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)
+ ->orderBy('tbl_appointment.created_at', 'DESC')
+ ->groupBy('tbl_partner_facility.mfl_code')
+ ->get();
+ }
+
+ return view('new_reports.active_facilities', compact('active_facilities'));
+ }
+
+ public function indicators()
+ {
+ $indicators = Indicator::all();
+
+ return view('new_reports.indicators', compact('indicators'));
+ }
+ public function message_form()
+ {
+ return view('new_reports.message_form');
+ }
+
+ public function client_message(Request $request)
+ {
+ $selected_from = $request->date_from;
+ $selected_to = $request->date_to;
+ if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+ $client_messages = Appointments::join('tbl_client', 'tbl_appointment.client_id', 'tbl_client.id')
+ ->join('tbl_clnt_outgoing', 'tbl_appointment.id', 'tbl_clnt_outgoing.appointment_id')
+ ->join('tbl_gender', 'tbl_client.gender', 'tbl_gender.id')
+ ->join('tbl_language', 'tbl_client.language_id', 'tbl_language.id')
+ ->join('tbl_appointment_types', 'tbl_appointment.app_type_1', 'tbl_appointment_types.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', 'tbl_partner_facility.mfl_code')
+ ->join('tbl_master_facility', 'tbl_partner_facility.mfl_code', 'tbl_master_facility.code')
+ ->join('tbl_partner', 'tbl_partner_facility.partner_id', 'tbl_partner.id')
+ ->join('tbl_county', 'tbl_partner_facility.county_id', 'tbl_county.id')
+ ->join('tbl_sub_county', 'tbl_partner_facility.sub_county_id', 'tbl_sub_county.id')
+ ->select(
+ 'tbl_client.clinic_number',
+ 'tbl_client.f_name',
+ 'tbl_client.m_name',
+ 'tbl_client.l_name',
+ 'tbl_gender.name as gender',
+ 'tbl_language.name as language',
+ 'tbl_client.phone_no',
+ 'tbl_clnt_outgoing.msg',
+ 'tbl_clnt_outgoing.callback_status',
+ 'tbl_clnt_outgoing.failure_reason',
+ 'tbl_clnt_outgoing.updated_at',
+ 'tbl_appointment.appntmnt_date as appointment_date',
+ 'tbl_appointment_types.name as app_type',
+ 'tbl_appointment.app_status',
+ 'tbl_master_facility.code',
+ 'tbl_master_facility.name as facility',
+ 'tbl_partner.name as partner',
+ 'tbl_county.name as county',
+ 'tbl_sub_county.name as subcounty'
+ )
+ ->where('tbl_client.status', '=', 'Active')
+ ->where('tbl_appointment.appntmnt_date', '>=', date($request->date_from))
+ ->where('tbl_appointment.appntmnt_date', '<=', date($request->date_to))
+ ->get();
+ }
+ if (Auth::user()->access_level == 'Partner') {
+ $client_messages = Appointments::join('tbl_client', 'tbl_appointment.client_id', 'tbl_client.id')
+ ->join('tbl_clnt_outgoing', 'tbl_appointment.id', 'tbl_clnt_outgoing.appointment_id')
+ ->join('tbl_gender', 'tbl_client.gender', 'tbl_gender.id')
+ ->join('tbl_language', 'tbl_client.language_id', 'tbl_language.id')
+ ->join('tbl_appointment_types', 'tbl_appointment.app_type_1', 'tbl_appointment_types.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', 'tbl_partner_facility.mfl_code')
+ ->join('tbl_master_facility', 'tbl_partner_facility.mfl_code', 'tbl_master_facility.code')
+ ->join('tbl_partner', 'tbl_partner_facility.partner_id', 'tbl_partner.id')
+ ->join('tbl_county', 'tbl_partner_facility.county_id', 'tbl_county.id')
+ ->join('tbl_sub_county', 'tbl_partner_facility.sub_county_id', 'tbl_sub_county.id')
+ ->select(
+ 'tbl_client.clinic_number',
+ 'tbl_client.f_name',
+ 'tbl_client.m_name',
+ 'tbl_client.l_name',
+ 'tbl_gender.name as gender',
+ 'tbl_language.name as language',
+ 'tbl_client.phone_no',
+ 'tbl_clnt_outgoing.msg',
+ 'tbl_clnt_outgoing.callback_status',
+ 'tbl_clnt_outgoing.failure_reason',
+ 'tbl_clnt_outgoing.updated_at',
+ 'tbl_appointment.appntmnt_date as appointment_date',
+ 'tbl_appointment_types.name as app_type',
+ 'tbl_appointment.app_status',
+ 'tbl_master_facility.code',
+ 'tbl_master_facility.name as facility',
+ 'tbl_partner.name as partner',
+ 'tbl_county.name as county',
+ 'tbl_sub_county.name as subcounty'
+ )
+ ->where('tbl_client.status', '=', 'Active')
+ ->where('tbl_appointment.appntmnt_date', '>=', date($request->date_from))
+ ->where('tbl_appointment.appntmnt_date', '<=', date($request->date_to))
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->get();
+ }
+ if (Auth::user()->access_level == 'Facility') {
+ $client_messages = Appointments::join('tbl_client', 'tbl_appointment.client_id', 'tbl_client.id')
+ ->join('tbl_clnt_outgoing', 'tbl_appointment.id', 'tbl_clnt_outgoing.appointment_id')
+ ->join('tbl_gender', 'tbl_client.gender', 'tbl_gender.id')
+ ->join('tbl_language', 'tbl_client.language_id', 'tbl_language.id')
+ ->join('tbl_appointment_types', 'tbl_appointment.app_type_1', 'tbl_appointment_types.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', 'tbl_partner_facility.mfl_code')
+ ->join('tbl_master_facility', 'tbl_partner_facility.mfl_code', 'tbl_master_facility.code')
+ ->join('tbl_partner', 'tbl_partner_facility.partner_id', 'tbl_partner.id')
+ ->join('tbl_county', 'tbl_partner_facility.county_id', 'tbl_county.id')
+ ->join('tbl_sub_county', 'tbl_partner_facility.sub_county_id', 'tbl_sub_county.id')
+ ->select(
+ 'tbl_client.clinic_number',
+ 'tbl_client.f_name',
+ 'tbl_client.m_name',
+ 'tbl_client.l_name',
+ 'tbl_gender.name as gender',
+ 'tbl_language.name as language',
+ 'tbl_client.phone_no',
+ 'tbl_clnt_outgoing.msg',
+ 'tbl_clnt_outgoing.callback_status',
+ 'tbl_clnt_outgoing.failure_reason',
+ 'tbl_clnt_outgoing.updated_at',
+ 'tbl_appointment.appntmnt_date as appointment_date',
+ 'tbl_appointment_types.name as app_type',
+ 'tbl_appointment.app_status',
+ 'tbl_master_facility.code',
+ 'tbl_master_facility.name as facility',
+ 'tbl_partner.name as partner',
+ 'tbl_county.name as county',
+ 'tbl_sub_county.name as subcounty'
+ )
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereDate('tbl_appointment.appntmnt_date', '>=', date($request->date_from))
+ ->whereDate('tbl_appointment.appntmnt_date', '<=', date($request->date_to))
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)
+ ->get();
+ }
+
+
+ return view('new_reports.client_messages', compact('client_messages', 'selected_from', 'selected_to'));
+ }
+}
diff --git a/app/Http/Controllers/PartnerController.php b/app/Http/Controllers/PartnerController.php
index 11d8e30..3093cc4 100644
--- a/app/Http/Controllers/PartnerController.php
+++ b/app/Http/Controllers/PartnerController.php
@@ -7,35 +7,57 @@
use App\Models\PartnerType;
use Session;
use Exception;
+use Auth;
class PartnerController extends Controller
{
public function index()
{
+
$all_partners = Partner::join('tbl_partner_type', 'tbl_partner.partner_type_id', '=', 'tbl_partner_type.id')
->select('tbl_partner.id', 'tbl_partner.name as partner_name', 'tbl_partner.phone_no', 'tbl_partner.description', 'tbl_partner.e_mail', 'tbl_partner.location', 'tbl_partner.status', 'tbl_partner.created_at', 'tbl_partner.updated_at', 'tbl_partner_type.name as partner_type')
->where('tbl_partner.status', '=', 'Active')
->get();
$partner_type = PartnerType::all();
+ if (Auth::user()->access_level == 'Sub County') {
+ $all_partners = Partner::join('tbl_partner_facility', 'tbl_partner.id', '=', 'tbl_partner_facility.partner_id')
+ ->join('tbl_partner_type', 'tbl_partner.partner_type_id', '=', 'tbl_partner_type.id')
+ ->select('tbl_partner.id', 'tbl_partner.name as partner_name', 'tbl_partner.phone_no', 'tbl_partner.description', 'tbl_partner.e_mail', 'tbl_partner.location', 'tbl_partner.status', 'tbl_partner.created_at', 'tbl_partner.updated_at', 'tbl_partner_type.name as partner_type')
+ ->where('tbl_partner.status', '=', 'Active')
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->groupBy('tbl_partner.name')
+ ->get();
+ }
+ if (Auth::user()->access_level == 'County') {
+ $all_partners = Partner::join('tbl_partner_facility', 'tbl_partner.id', '=', 'tbl_partner_facility.partner_id')
+ ->join('tbl_partner_type', 'tbl_partner.partner_type_id', '=', 'tbl_partner_type.id')
+ ->select('tbl_partner.id', 'tbl_partner.name as partner_name', 'tbl_partner.phone_no', 'tbl_partner.description', 'tbl_partner.e_mail', 'tbl_partner.location', 'tbl_partner.status', 'tbl_partner.created_at', 'tbl_partner.updated_at', 'tbl_partner_type.name as partner_type')
+ ->where('tbl_partner.status', '=', 'Active')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->groupBy('tbl_partner.name')
+ ->get();
+ }
+
return view('partners.new_partner', compact('all_partners', 'partner_type'));
}
public function addpartnerform()
{
$partner_type = PartnerType::all();
return view('partners.addpartner', compact('partner_type'));
+
}
public function addpartner(Request $request)
{
try {
$partner = new Partner;
- $validate = Partner::where('phone_no', $request->phone)->first();
+ // $validate = Partner::where('phone_no', $request->phone)->first();
- if ($validate) {
- Session::flash('statuscode', 'error');
- return redirect('admin/partners/form')->with('status', 'Phone Number is already used in the system!');
- }
+ // if ($validate) {
+ // Session::flash('statuscode', 'error');
+ // return redirect('admin/partners/form')->with('status', 'Phone Number is already used in the system!');
+ // }
$partner->name = $request->name;
$partner->description = $request->description;
diff --git a/app/Http/Controllers/PmtcController.php b/app/Http/Controllers/PmtcController.php
index d7f6797..a99fd08 100644
--- a/app/Http/Controllers/PmtcController.php
+++ b/app/Http/Controllers/PmtcController.php
@@ -3,12 +3,15 @@
namespace App\Http\Controllers;
use Illuminate\Http\Request;
+
use\App\Models\Pmtct;
use\App\Models\Client;
use\App\Models\Partner;
use\App\Models\Appointments;
+
use Carbon\Carbon;
use Auth;
+use DB;
class PmtcController extends Controller
{
@@ -16,85 +19,85 @@ class PmtcController extends Controller
public function get_pmtct_honored_appointment()
{
$all_honored_appointment_clients = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- //->innerJoin('tbl_appointment_types')->ON('tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
- ->where('appointment_kept', '=', 'Yes');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ //->innerJoin('tbl_appointment_types')->ON('tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
+ ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
+ ->where('appointment_kept', '=', 'Yes');
return view('pmtct/kept_appointments')->with('all_honored_appointment_clients', $all_honored_appointment_clients->get());
}
- Public function pmtct_appointment_dairy()
+ public function pmtct_appointment_dairy()
{
if (Auth::user()->access_level == 'Admin') {
- $all_booked_pmtct_clients = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appntmnt_date', '>=', Now())
- ->get();
+ $all_booked_pmtct_clients = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appntmnt_date', '>=', Now())
+ ->get();
+
+ $all_schedule_appointment_clients = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
+ ->selectRaw('tbl_client.clinic_number, tbl_appointment_types.name as app_type, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
+ ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->whereNull('tbl_client.hei_no')
+ ->get();
- $all_schedule_appointment_clients = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
- ->selectRaw('tbl_client.clinic_number, tbl_appointment_types.name as app_type, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
- ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->whereNull('tbl_client.hei_no')
- ->get();
-
- $all_unschedule_appointment_clients = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
- ->selectRaw('tbl_client.clinic_number, tbl_appointment_types.name as app_type, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- // ->whereNull('tbl_client.hei_no')
- ->get();
+ $all_unschedule_appointment_clients = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
+ ->selectRaw('tbl_client.clinic_number, tbl_appointment_types.name as app_type, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ // ->whereNull('tbl_client.hei_no')
+ ->get();
}
if (Auth::user()->access_level == 'Facility') {
$all_booked_pmtct_clients = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
- ->where('tbl_appointment.app_status', '=', 'Booked')
- // ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appntmnt_date', '>=', Now())
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->get();
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ // ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appntmnt_date', '>=', Now())
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->get();
- $all_schedule_appointment_clients = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
- ->selectRaw('tbl_client.clinic_number, tbl_appointment_types.name as app_type, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
- ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- // ->whereNull('tbl_client.hei_no')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->get();
+ $all_schedule_appointment_clients = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
+ ->selectRaw('tbl_client.clinic_number, tbl_appointment_types.name as app_type, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
+ ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ // ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->get();
$all_unschedule_appointment_clients = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
- ->selectRaw('tbl_client.clinic_number, tbl_appointment_types.name as app_type, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- // ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->get();
- }
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
+ ->selectRaw('tbl_client.clinic_number, tbl_appointment_types.name as app_type, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ // ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->get();
+ }
- if (Auth::user()->access_level == 'Partner') {
- $all_booked_pmtct_clients = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ if (Auth::user()->access_level == 'Partner') {
+ $all_booked_pmtct_clients = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.appntmnt_date', '>=', Now())
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->get();
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.appntmnt_date', '>=', Now())
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->get();
- $all_schedule_appointment_clients = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $all_schedule_appointment_clients = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
->selectRaw('tbl_client.clinic_number, tbl_appointment_types.name as app_type, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
@@ -103,7 +106,7 @@ public function get_pmtct_honored_appointment()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->get();
- $all_unschedule_appointment_clients = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $all_unschedule_appointment_clients = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->join('tbl_appointment_types', 'tbl_appointment_types.id', '=', 'tbl_appointment.app_type_1')
->selectRaw('tbl_client.clinic_number, tbl_appointment_types.name as app_type, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
@@ -111,7 +114,7 @@ public function get_pmtct_honored_appointment()
->where('tbl_appointment.appntmnt_date', '<', Now())
->where('tbl_client.partner_id', Auth::user()->partner_id)
->get();
- }
+ }
return view('pmtct/pmtct_appointment_dairy', compact('all_booked_pmtct_clients', 'all_schedule_appointment_clients', 'all_unschedule_appointment_clients'));
}
@@ -119,69 +122,69 @@ public function get_pmtct_honored_appointment()
public function pmtct_defaulter_dairy()
{
if (Auth::user()->access_level == 'Admin') {
- $all_missed_appointment_clients = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
- ->where('app_status', '=', 'Missed')
- ->get();
-
- $all_defaulted_appointment_clients = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
- ->where('app_status', '=', 'Defaulted')
- ->get();
-
- $all_ltfu_pmtct_clients = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
- ->where('app_status', '=', 'LTFU')
- ->get();
+ $all_missed_appointment_clients = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
+ ->where('app_status', '=', 'Missed')
+ ->get();
+
+ $all_defaulted_appointment_clients = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
+ ->where('app_status', '=', 'Defaulted')
+ ->get();
+
+ $all_ltfu_pmtct_clients = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
+ ->where('app_status', '=', 'LTFU')
+ ->get();
}
if (Auth::user()->access_level == 'Facility') {
$all_missed_appointment_clients = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
- ->where('app_status', '=', 'Missed')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->get();
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
+ ->where('app_status', '=', 'Missed')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->get();
$all_defaulted_appointment_clients = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
- ->where('app_status', '=', 'Defaulted')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->get();
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
+ ->where('app_status', '=', 'Defaulted')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->get();
$all_ltfu_pmtct_clients = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
- ->where('app_status', '=', 'LTFU')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->get();
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
+ ->where('app_status', '=', 'LTFU')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->get();
}
if (Auth::user()->access_level == 'Partner') {
$all_missed_appointment_clients = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
- ->where('app_status', '=', 'Missed')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->get();
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
+ ->where('app_status', '=', 'Missed')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->get();
$all_defaulted_appointment_clients = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
- ->where('app_status', '=', 'Defaulted')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->get();
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
+ ->where('app_status', '=', 'Defaulted')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->get();
$all_ltfu_pmtct_clients = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
- ->where('app_status', '=', 'LTFU')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->get();
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_appointment.appntmnt_date')
+ ->where('app_status', '=', 'LTFU')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->get();
}
return view('pmtct/pmtct_defaulter_dairy', compact('all_missed_appointment_clients', 'all_defaulted_appointment_clients', 'all_ltfu_pmtct_clients'));
@@ -189,21 +192,58 @@ public function pmtct_defaulter_dairy()
public function get_all_hei()
{
- if (Auth::user()->access_level == 'Admin') {
- $all_hei = Client::select('clinic_number', 'f_name', 'm_name', 'l_name', 'dob', 'client_status', 'phone_no', 'enrollment_date', 'art_date', 'hei_no')
- ->whereNotNull('hei_no')->get();
+
+
+ if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+ $all_hei = Pmtct::join('tbl_client', 'tbl_client.hei_no', '=', 'tbl_pmtct.hei_no')
+ ->join('tbl_gender', 'tbl_pmtct.hei_gender', '=', 'tbl_gender.id')
+ ->select(
+ 'tbl_client.clinic_number',
+ 'tbl_pmtct.hei_first_name as f_name',
+ 'tbl_pmtct.hei_middle_name as m_name',
+ 'tbl_pmtct.hei_last_name as l_name',
+ 'tbl_pmtct.hei_dob as dob',
+ 'tbl_gender.name as gender',
+ 'tbl_pmtct.hei_no',
+ 'tbl_client.status'
+ )
+ ->whereNotNull('tbl_pmtct.hei_no')->paginate(1000);
}
if (Auth::user()->access_level == 'Facility') {
- $all_hei = Client::select('clinic_number', 'f_name', 'm_name', 'l_name', 'dob', 'client_status', 'phone_no', 'enrollment_date', 'art_date', 'hei_no')
- ->where('mfl_code', Auth::user()->facility_id)
- ->whereNotNull('hei_no')->get();
+ $all_hei = Pmtct::join('tbl_client', 'tbl_client.hei_no', '=', 'tbl_pmtct.hei_no')
+ ->join('tbl_gender', 'tbl_pmtct.hei_gender', '=', 'tbl_gender.id')
+ ->select(
+ 'tbl_client.clinic_number',
+ 'tbl_pmtct.hei_first_name as f_name',
+ 'tbl_pmtct.hei_middle_name as m_name',
+ 'tbl_pmtct.hei_last_name as l_name',
+ 'tbl_pmtct.hei_dob as dob',
+ 'tbl_gender.name as gender',
+ 'tbl_pmtct.hei_no',
+ 'tbl_client.status'
+ )
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->whereNotNull('tbl_pmtct.hei_no')
+ ->paginate(10000);
}
if (Auth::user()->access_level == 'Partner') {
- $all_hei = Client::select('clinic_number', 'f_name', 'm_name', 'l_name', 'dob', 'client_status', 'phone_no', 'enrollment_date', 'art_date', 'hei_no')
- ->where('partner_id', Auth::user()->partner_id)
- ->whereNotNull('hei_no')->get();
+ $all_hei = Pmtct::join('tbl_client', 'tbl_client.hei_no', '=', 'tbl_pmtct.hei_no')
+ ->join('tbl_gender', 'tbl_pmtct.hei_gender', '=', 'tbl_gender.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(
+ 'tbl_client.clinic_number',
+ 'tbl_pmtct.hei_first_name as f_name',
+ 'tbl_pmtct.hei_middle_name as m_name',
+ 'tbl_pmtct.hei_last_name as l_name',
+ 'tbl_pmtct.hei_dob as dob',
+ 'tbl_gender.name as gender',
+ 'tbl_pmtct.hei_no',
+ 'tbl_client.status'
+ )
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->whereNotNull('tbl_pmtct.hei_no')->paginate(10000);
}
return view('pmtct/all_heis', compact('all_hei'));
@@ -212,155 +252,187 @@ public function hei_appointment_dairy()
{
if (Auth::user()->access_level == 'Admin') {
- $all_booked_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1')
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.active_app', '=', 1)
- ->whereNotNull('tbl_client.hei_no')
- ->get();;
+ $hei_appointment = Pmtct::join('tbl_client', 'tbl_pmtct.client_id', '=', 'tbl_client.id')
+ ->join('tbl_gender', 'tbl_pmtct.hei_gender', '=', 'tbl_gender.id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_appointment_types', 'tbl_appointment.app_type_1', '=', 'tbl_appointment_types.id')
+ ->leftJoin('tbl_caregiver_not_on_care', 'tbl_pmtct.care_giver_id', '=', 'tbl_caregiver_not_on_care.id')
+ ->select(
+ DB::raw("CONCAT(`tbl_pmtct`.`hei_first_name`, ' ', `tbl_pmtct`.`hei_middle_name`, ' ', `tbl_pmtct`.`hei_last_name`) as hei_name"),
+ 'tbl_pmtct.hei_no',
+ 'tbl_pmtct.hei_dob',
+ 'tbl_gender.name as gender',
+ 'tbl_client.clinic_number',
+ 'tbl_appointment.appntmnt_date as app_date',
+ 'tbl_appointment.app_status',
+ 'tbl_appointment_types.name as app_type',
+ DB::raw("CONCAT(`tbl_caregiver_not_on_care`.`care_giver_fname`, ' ', `tbl_caregiver_not_on_care`.`care_giver_mname`, ' ', `tbl_caregiver_not_on_care`.`care_giver_lname`) as caregiver_name")
+ )
+ ->paginate(1000);
$all_scheduled_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1, tbl_appointment.visit_type')
- ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->whereNotNull('tbl_client.hei_no')
- ->get();
+ ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1, tbl_appointment.visit_type')
+ ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->whereNotNull('tbl_client.hei_no')
+ ->get();
$all_unscheduled_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1, tbl_appointment.visit_type')
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->whereNotNull('tbl_client.hei_no')
- ->get();
-
- }
+ ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1, tbl_appointment.visit_type')
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->whereNotNull('tbl_client.hei_no')
+ ->get();
+ }
if (Auth::user()->access_level == 'Facility') {
- $all_booked_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1')
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.active_app', '=', 1)
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->whereNotNull('tbl_client.hei_no')
- ->get();;
-
- $all_scheduled_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1, tbl_appointment.visit_type')
- ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->whereNotNull('tbl_client.hei_no')
- ->get();
-
- $all_unscheduled_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1, tbl_appointment.visit_type')
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->whereNotNull('tbl_client.hei_no')
- ->get();
+ $hei_appointment = Pmtct::join('tbl_client', 'tbl_pmtct.client_id', '=', 'tbl_client.id')
+ ->join('tbl_gender', 'tbl_pmtct.hei_gender', '=', 'tbl_gender.id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_appointment_types', 'tbl_appointment.app_type_1', '=', 'tbl_appointment_types.id')
+ ->leftJoin('tbl_caregiver_not_on_care', 'tbl_pmtct.care_giver_id', '=', 'tbl_caregiver_not_on_care.id')
+ ->select(
+ DB::raw("CONCAT(`tbl_pmtct`.`hei_first_name`, ' ', `tbl_pmtct`.`hei_middle_name`, ' ', `tbl_pmtct`.`hei_last_name`) as hei_name"),
+ 'tbl_pmtct.hei_no',
+ 'tbl_pmtct.hei_dob',
+ 'tbl_gender.name as gender',
+ 'tbl_client.clinic_number',
+ 'tbl_appointment.appntmnt_date as app_date',
+ 'tbl_appointment.app_status',
+ 'tbl_appointment_types.name as app_type',
+ DB::raw("CONCAT(`tbl_caregiver_not_on_care`.`care_giver_fname`, ' ', `tbl_caregiver_not_on_care`.`care_giver_mname`, ' ', `tbl_caregiver_not_on_care`.`care_giver_lname`) as caregiver_name")
+ )
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->whereNotNull('tbl_client.hei_no')
+ ->get();
+
+ $all_scheduled_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1, tbl_appointment.visit_type')
+ ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->whereNotNull('tbl_client.hei_no')
+ ->get();
+ $all_unscheduled_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1, tbl_appointment.visit_type')
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->whereNotNull('tbl_client.hei_no')
+ ->get();
}
if (Auth::user()->access_level == 'Partner') {
- $all_booked_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1')
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.active_app', '=', 1)
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->whereNotNull('tbl_client.hei_no')
- ->get();;
+ $hei_appointment = Pmtct::join('tbl_client', 'tbl_pmtct.client_id', '=', 'tbl_client.id')
+ ->join('tbl_gender', 'tbl_pmtct.hei_gender', '=', 'tbl_gender.id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_appointment_types', 'tbl_appointment.app_type_1', '=', 'tbl_appointment_types.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->leftJoin('tbl_caregiver_not_on_care', 'tbl_pmtct.care_giver_id', '=', 'tbl_caregiver_not_on_care.id')
+ ->select(
+ DB::raw("CONCAT(`tbl_pmtct`.`hei_first_name`, ' ', `tbl_pmtct`.`hei_middle_name`, ' ', `tbl_pmtct`.`hei_last_name`) as hei_name"),
+ 'tbl_pmtct.hei_no',
+ 'tbl_pmtct.hei_dob',
+ 'tbl_gender.name as gender',
+ 'tbl_client.clinic_number',
+ 'tbl_appointment.appntmnt_date as app_date',
+ 'tbl_appointment.app_status',
+ 'tbl_appointment_types.name as app_type',
+ DB::raw("CONCAT(`tbl_caregiver_not_on_care`.`care_giver_fname`, ' ', `tbl_caregiver_not_on_care`.`care_giver_mname`, ' ', `tbl_caregiver_not_on_care`.`care_giver_lname`) as caregiver_name")
+ )
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->whereNotNull('tbl_client.hei_no')
+ ->paginate(1000);
$all_scheduled_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1, tbl_appointment.visit_type')
- ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->whereNotNull('tbl_client.hei_no')
- ->get();
+ ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1, tbl_appointment.visit_type')
+ ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->whereNotNull('tbl_client.hei_no')
+ ->get();
$all_unscheduled_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1, tbl_appointment.visit_type')
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->whereNotNull('tbl_client.hei_no')
- ->get();
-
- }
-
- return view('pmtct/hei_appointment_dairy', compact('all_unscheduled_heis', 'all_booked_heis', 'all_scheduled_heis'));
+ ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1, tbl_appointment.visit_type')
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->whereNotNull('tbl_client.hei_no')
+ ->get();
+ }
+ return view('pmtct/hei_appointment_dairy', compact('all_unscheduled_heis', 'hei_appointment', 'all_scheduled_heis'));
}
public function hei_defaulter_dairy()
{
- if (Auth::user()->access_level == 'Admin') {
- $all_missed_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1, tbl_appointment.app_status')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->whereNotNull('tbl_client.hei_no')
- ->get();
-
- $all_defaulted_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1, tbl_appointment.app_status')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->whereNotNull('tbl_client.hei_no')
- ->get();
-
- $all_ltfu_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1, tbl_appointment.app_status')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->whereNotNull('tbl_client.hei_no')
- ->get();
- }
-
- if (Auth::user()->access_level == 'Facility') {
- $all_missed_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1, tbl_appointment.app_status')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->whereNotNull('tbl_client.hei_no')
- ->get();
-
- $all_defaulted_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1, tbl_appointment.app_status')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->whereNotNull('tbl_client.hei_no')
- ->get();
-
- $all_ltfu_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1, tbl_appointment.app_status')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->whereNotNull('tbl_client.hei_no')
- ->get();
- }
-
- if (Auth::user()->access_level == 'Partner') {
- $all_missed_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1, tbl_appointment.app_status')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->whereNotNull('tbl_client.hei_no')
- ->get();
-
- $all_defaulted_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1, tbl_appointment.app_status')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->whereNotNull('tbl_client.hei_no')
- ->get();
-
- $all_ltfu_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1, tbl_appointment.app_status')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->whereNotNull('tbl_client.hei_no')
- ->get();
- }
+ if (Auth::user()->access_level == 'Admin') {
+ $all_missed_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1, tbl_appointment.app_status')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->whereNotNull('tbl_client.hei_no')
+ ->get();
+
+ $all_defaulted_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1, tbl_appointment.app_status')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereNotNull('tbl_client.hei_no')
+ ->get();
+
+ $all_ltfu_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1, tbl_appointment.app_status')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->whereNotNull('tbl_client.hei_no')
+ ->get();
+ }
+
+ if (Auth::user()->access_level == 'Facility') {
+ $all_missed_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1, tbl_appointment.app_status')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->whereNotNull('tbl_client.hei_no')
+ ->get();
+
+ $all_defaulted_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1, tbl_appointment.app_status')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->whereNotNull('tbl_client.hei_no')
+ ->get();
+
+ $all_ltfu_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1, tbl_appointment.app_status')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->whereNotNull('tbl_client.hei_no')
+ ->get();
+ }
+
+ if (Auth::user()->access_level == 'Partner') {
+ $all_missed_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1, tbl_appointment.app_status')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->whereNotNull('tbl_client.hei_no')
+ ->get();
+
+ $all_defaulted_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1, tbl_appointment.app_status')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->whereNotNull('tbl_client.hei_no')
+ ->get();
+
+ $all_ltfu_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->selectRaw('tbl_client.clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no, tbl_appointment.appntmnt_date, tbl_appointment.app_type_1, tbl_appointment.app_status')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->whereNotNull('tbl_client.hei_no')
+ ->get();
+ }
return view('pmtct/hei_defaulter_dairy', compact('all_missed_heis', 'all_defaulted_heis', 'all_ltfu_heis'));
}
@@ -368,63 +440,60 @@ public function hei_defaulter_dairy()
public function hei_final_outcome()
{
if (Auth::user()->access_level == 'Admin') {
- $all_deceased_heis = Client::selectRaw('clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no')
- ->where('status', '=', 'Deceased')
- ->whereNotNull('hei_no')
- ->get();
-
- $all_transfer_heis = Client::selectRaw('clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no')
- ->where('status', '=', 'Transfer Out')
- ->whereNotNull('hei_no')
- ->get();
+ $all_deceased_heis = Client::selectRaw('clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no')
+ ->where('status', '=', 'Deceased')
+ ->whereNotNull('hei_no')
+ ->get();
- $all_discharged_heis = Client::selectRaw('clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no')
- ->where('status', '=', 'Disabled')
- ->whereNotNull('hei_no')
- ->get();
+ $all_transfer_heis = Client::selectRaw('clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no')
+ ->where('status', '=', 'Transfer Out')
+ ->whereNotNull('hei_no')
+ ->get();
+ $all_discharged_heis = Client::selectRaw('clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no')
+ ->where('status', '=', 'Disabled')
+ ->whereNotNull('hei_no')
+ ->get();
}
if (Auth::user()->access_level == 'Facility') {
$all_deceased_heis = Client::selectRaw('clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no')
- ->where('status', '=', 'Deceased')
- ->where('mfl_code', Auth::user()->facility_id)
- ->whereNotNull('hei_no')
- ->get();
+ ->where('status', '=', 'Deceased')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->whereNotNull('hei_no')
+ ->get();
$all_transfer_heis = Client::selectRaw('clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no')
- ->where('status', '=', 'Transfer Out')
- ->where('mfl_code', Auth::user()->facility_id)
- ->whereNotNull('hei_no')
- ->get();
+ ->where('status', '=', 'Transfer Out')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->whereNotNull('hei_no')
+ ->get();
$all_discharged_heis = Client::selectRaw('clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no')
- ->where('status', '=', 'Disabled')
- ->where('mfl_code', Auth::user()->facility_id)
- ->whereNotNull('hei_no')
- ->get();
-
+ ->where('status', '=', 'Disabled')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->whereNotNull('hei_no')
+ ->get();
}
if (Auth::user()->access_level == 'Partner') {
$all_deceased_heis = Client::selectRaw('clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no')
- ->where('status', '=', 'Deceased')
- ->where('partner_id', Auth::user()->partner_id)
- ->whereNotNull('hei_no')
- ->get();
+ ->where('status', '=', 'Deceased')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->whereNotNull('hei_no')
+ ->get();
$all_transfer_heis = Client::selectRaw('clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no')
- ->where('status', '=', 'Transfer Out')
- ->where('partner_id', Auth::user()->partner_id)
- ->whereNotNull('hei_no')
- ->get();
+ ->where('status', '=', 'Transfer Out')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->whereNotNull('hei_no')
+ ->get();
$all_discharged_heis = Client::selectRaw('clinic_number, tbl_client.f_name, tbl_client.m_name, tbl_client.l_name, tbl_client.hei_no, tbl_client.phone_no')
- ->where('status', '=', 'Disabled')
- ->where('partner_id', Auth::user()->partner_id)
- ->whereNotNull('hei_no')
- ->get();
-
+ ->where('status', '=', 'Disabled')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->whereNotNull('hei_no')
+ ->get();
}
return view('pmtct/hei_final_outcome', compact('all_deceased_heis', 'all_transfer_heis', 'all_discharged_heis'));
@@ -435,686 +504,686 @@ public function pmtct_dashboard()
{
if (Auth::user()->access_level == 'Facility') {
- $ranges = [
-
- 'ToNine' => 0,
- 'ToFourteen' => 10,
- 'ToNineteen' => 15,
- 'ToTwentyFour' => 20,
- 'ToTwentyNine' => 25,
- 'ToThirtyFour' => 30,
- 'ToThirtyNine' => 35,
- 'ToFortyFour' => 40,
- 'ToFortyNine' => 45,
- 'FiftyPlus' => 50
- ];
-
- $startdate = Appointments::select('appntmnt_date')->orderBy('appntmnt_date', 'asc')->first();
- $startdate = Carbon::parse($startdate->appntmnt_date)->format('Y-m-d');
- $enddate = Appointments::select('appntmnt_date')->orderBy('appntmnt_date', 'desc')->first();
- $enddate = Carbon::parse($enddate->appntmnt_date)->format('Y-m-d');
+ $ranges = [
+
+ 'ToNine' => 0,
+ 'ToFourteen' => 10,
+ 'ToNineteen' => 15,
+ 'ToTwentyFour' => 20,
+ 'ToTwentyNine' => 25,
+ 'ToThirtyFour' => 30,
+ 'ToThirtyNine' => 35,
+ 'ToFortyFour' => 40,
+ 'ToFortyNine' => 45,
+ 'FiftyPlus' => 50
+ ];
+
+ $startdate = Appointments::select('appntmnt_date')->orderBy('appntmnt_date', 'asc')->first();
+ $startdate = Carbon::parse($startdate->appntmnt_date)->format('Y-m-d');
+ $enddate = Appointments::select('appntmnt_date')->orderBy('appntmnt_date', 'desc')->first();
+ $enddate = Carbon::parse($enddate->appntmnt_date)->format('Y-m-d');
$tonine_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- //->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- // ->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ //->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ // ->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tofourteen_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- // ->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ // ->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tonineteen_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- // ->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ // ->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$totwentyfour_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- // ->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ // ->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$totwentynine_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- // ->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ // ->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tothirtyfour_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- //->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ //->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tothirtynine_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- // ->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ // ->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tofortyfour_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- // ->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ // ->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tofortynine_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- // ->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ // ->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tofiftyplus_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- //->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ //->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tototal_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- // ->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ // ->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
// Un-Scheduled
$tonine_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- // ->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ // ->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tofourteen_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- //->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ //->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tonineteen_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- // ->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ // ->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$totwentyfour_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- //->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ //->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$totwentynine_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- // ->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ // ->whereDate('tbl_appointment.appntmnt_date', '>=', $startdate)->whereDate('tbl_appointment.appntmnt_date', '<=', $enddate)
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tothirtyfour_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tothirtynine_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tofortyfour_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tofortynine_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tofifty_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50) and ((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_pmtct`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50) and ((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tototal_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->whereNull('tbl_client.hei_no')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->whereNull('tbl_client.hei_no')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
//Booked
$tonine_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.appntmnt_date', '>', Now())
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.appntmnt_date', '>', Now())
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tofourteen_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.appntmnt_date', '>', Now())
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.appntmnt_date', '>', Now())
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tonineteen_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.appntmnt_date', '>', Now())
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.appntmnt_date', '>', Now())
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$totwentyfour_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.appntmnt_date', '>', Now())
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.appntmnt_date', '>', Now())
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$totwentynine_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.appntmnt_date', '>', Now())
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.appntmnt_date', '>', Now())
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tothirtyfour_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.appntmnt_date', '>', Now())
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.appntmnt_date', '>', Now())
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tothirtynine_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.appntmnt_date', '>', Now())
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.appntmnt_date', '>', Now())
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tofortyfour_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.appntmnt_date', '>', Now())
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.appntmnt_date', '>', Now())
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tofortynine_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.appntmnt_date', '>', Now())
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.appntmnt_date', '>', Now())
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tofifty_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50) and ((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_pmtct`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.appntmnt_date', '>', Now())
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50) and ((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.appntmnt_date', '>', Now())
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tototal_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->whereNull('tbl_client.hei_no')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.appntmnt_date', '>', Now())
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->whereNull('tbl_client.hei_no')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.appntmnt_date', '>', Now())
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
// Defaulter
$tonine_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tofourteen_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tonineteen_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$totwentyfour_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$totwentynine_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tothirtyfour_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tothirtynine_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tofortyfour_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tofortynine_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tofifty_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50) and ((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_pmtct`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50) and ((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tototal_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->whereNull('tbl_client.hei_no')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->whereNull('tbl_client.hei_no')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
// Missed
$tonine_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tofourteen_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tonineteen_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$totwentyfour_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$totwentynine_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tothirtyfour_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tothirtynine_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tofortyfour_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tofortynine_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tofifty_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50) and ((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_pmtct`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50) and ((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tototal_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->whereNull('tbl_client.hei_no')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->whereNull('tbl_client.hei_no')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
// LTFU
$tonine_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tofourteen_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tonineteen_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$totwentyfour_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$totwentynine_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tothirtyfour_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tothirtynine_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tofortyfour_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tofortynine_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tofifty_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50) and ((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_pmtct`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50) and ((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tototal_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->whereNull('tbl_client.hei_no')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->whereNull('tbl_client.hei_no')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
// honoured appointments
$tonine_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appointment_kept', '=', 'Yes')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appointment_kept', '=', 'Yes')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tofourteen_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appointment_kept', '=', 'Yes')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appointment_kept', '=', 'Yes')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tonineteen_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appointment_kept', '=', 'Yes')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appointment_kept', '=', 'Yes')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$totwentyfour_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appointment_kept', '=', 'Yes')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appointment_kept', '=', 'Yes')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$totwentynine_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appointment_kept', '=', 'Yes')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appointment_kept', '=', 'Yes')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tothirtyfour_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appointment_kept', '=', 'Yes')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appointment_kept', '=', 'Yes')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tothirtynine_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appointment_kept', '=', 'Yes')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appointment_kept', '=', 'Yes')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tofortyfour_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appointment_kept', '=', 'Yes')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appointment_kept', '=', 'Yes')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tofortynine_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appointment_kept', '=', 'Yes')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appointment_kept', '=', 'Yes')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tofifty_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50) and ((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_pmtct`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appointment_kept', '=', 'Yes')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50) and ((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appointment_kept', '=', 'Yes')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
$tototal_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->whereNull('tbl_client.hei_no')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.appointment_kept', '=', 'Yes')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->whereNull('tbl_client.hei_no')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.appointment_kept', '=', 'Yes')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
}
// partner level
@@ -1122,43 +1191,43 @@ public function pmtct_dashboard()
if (Auth::user()->access_level == 'Partner') {
$all_partners = Partner::where('status', '=', 'Active')
- ->where('id', Auth::user()->partner_id)
- ->pluck('name', 'id');
+ ->where('id', Auth::user()->partner_id)
+ ->pluck('name', 'id');
- $tonine_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tonine_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->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"))
->whereNull('tbl_client.hei_no')
- // ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ // ->where('tbl_appointment.visit_type', '=', 'Scheduled')
->where('tbl_appointment.appntmnt_date', '<', Now())
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tofourteen_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tofourteen_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->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"))
->whereNull('tbl_client.hei_no')
->where('tbl_appointment.appntmnt_date', '<', Now())
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tonineteen_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tonineteen_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->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"))
->whereNull('tbl_client.hei_no')
->where('tbl_appointment.appntmnt_date', '<', Now())
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $totwentyfour_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $totwentyfour_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->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"))
->whereNull('tbl_client.hei_no')
->where('tbl_appointment.appntmnt_date', '<', Now())
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $totwentynine_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $totwentynine_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1166,7 +1235,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tothirtyfour_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tothirtyfour_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1174,7 +1243,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tothirtynine_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tothirtynine_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1182,7 +1251,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tofortyfour_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tofortyfour_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1190,7 +1259,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tofortynine_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tofortynine_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1198,7 +1267,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tofiftyplus_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tofiftyplus_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1206,7 +1275,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tototal_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tototal_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1214,44 +1283,44 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- // Un-Scheduled
- $tonine_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ // Un-Scheduled
+ $tonine_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->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"))
->whereNull('tbl_client.hei_no')
->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
->where('tbl_appointment.appntmnt_date', '<', Now())
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tofourteen_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tofourteen_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->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"))
->whereNull('tbl_client.hei_no')
->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
->where('tbl_appointment.appntmnt_date', '<', Now())
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tonineteen_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tonineteen_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->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"))
->whereNull('tbl_client.hei_no')
->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
->where('tbl_appointment.appntmnt_date', '<', Now())
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $totwentyfour_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $totwentyfour_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->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"))
->whereNull('tbl_client.hei_no')
->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
->where('tbl_appointment.appntmnt_date', '<', Now())
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $totwentynine_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $totwentynine_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1260,7 +1329,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tothirtyfour_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tothirtyfour_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1269,7 +1338,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tothirtynine_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tothirtynine_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1278,7 +1347,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tofortyfour_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tofortyfour_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1287,7 +1356,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tofortynine_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tofortynine_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1296,7 +1365,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tofifty_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tofifty_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50) and ((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_pmtct`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1305,7 +1374,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tototal_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tototal_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->whereNull('tbl_client.hei_no')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
@@ -1314,17 +1383,17 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- //Booked
- $tonine_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ //Booked
+ $tonine_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->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"))
->whereNull('tbl_client.hei_no')
->where('tbl_appointment.app_status', '=', 'Booked')
->where('tbl_appointment.appntmnt_date', '>', Now())
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tofourteen_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tofourteen_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
->whereNull('tbl_client.hei_no')
@@ -1333,25 +1402,25 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tonineteen_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tonineteen_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->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"))
->whereNull('tbl_client.hei_no')
->where('tbl_appointment.app_status', '=', 'Booked')
->where('tbl_appointment.appntmnt_date', '>', Now())
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $totwentyfour_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $totwentyfour_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->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"))
->whereNull('tbl_client.hei_no')
->where('tbl_appointment.app_status', '=', 'Booked')
->where('tbl_appointment.appntmnt_date', '>', Now())
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $totwentynine_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $totwentynine_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1360,7 +1429,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tothirtyfour_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tothirtyfour_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1369,7 +1438,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tothirtynine_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tothirtynine_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1378,7 +1447,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tofortyfour_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tofortyfour_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1387,7 +1456,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tofortynine_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tofortynine_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1396,7 +1465,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tofifty_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tofifty_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50) and ((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_pmtct`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1405,7 +1474,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tototal_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tototal_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->whereNull('tbl_client.hei_no')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
@@ -1414,17 +1483,17 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- // Defaulter
+ // Defaulter
- $tonine_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tonine_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->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"))
->whereNull('tbl_client.hei_no')
->where('tbl_appointment.app_status', '=', 'Defaulted')
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tofourteen_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tofourteen_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
->whereNull('tbl_client.hei_no')
@@ -1432,23 +1501,23 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tonineteen_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tonineteen_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->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"))
->whereNull('tbl_client.hei_no')
->where('tbl_appointment.app_status', '=', 'Defaulted')
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $totwentyfour_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $totwentyfour_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->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"))
->whereNull('tbl_client.hei_no')
->where('tbl_appointment.app_status', '=', 'Defaulted')
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $totwentynine_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $totwentynine_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1456,7 +1525,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tothirtyfour_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tothirtyfour_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1464,7 +1533,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tothirtynine_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tothirtynine_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1472,7 +1541,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tofortyfour_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tofortyfour_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1480,7 +1549,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tofortynine_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tofortynine_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1488,7 +1557,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tofifty_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tofifty_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50) and ((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_pmtct`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1496,7 +1565,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tototal_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tototal_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->whereNull('tbl_client.hei_no')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
@@ -1504,16 +1573,16 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- // Missed
- $tonine_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ // Missed
+ $tonine_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->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"))
->whereNull('tbl_client.hei_no')
->where('tbl_appointment.app_status', '=', 'Missed')
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tofourteen_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tofourteen_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
->whereNull('tbl_client.hei_no')
@@ -1521,23 +1590,23 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tonineteen_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tonineteen_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->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"))
->whereNull('tbl_client.hei_no')
->where('tbl_appointment.app_status', '=', 'Missed')
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $totwentyfour_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $totwentyfour_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->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"))
->whereNull('tbl_client.hei_no')
->where('tbl_appointment.app_status', '=', 'Missed')
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $totwentynine_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $totwentynine_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1545,7 +1614,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tothirtyfour_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tothirtyfour_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1553,7 +1622,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tothirtynine_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tothirtynine_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1561,7 +1630,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tofortyfour_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tofortyfour_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1569,7 +1638,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tofortynine_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tofortynine_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1577,7 +1646,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tofifty_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tofifty_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50) and ((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_pmtct`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1585,7 +1654,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tototal_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tototal_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->whereNull('tbl_client.hei_no')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
@@ -1593,16 +1662,16 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- // LTFU
- $tonine_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ // LTFU
+ $tonine_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->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"))
->whereNull('tbl_client.hei_no')
->where('tbl_appointment.app_status', '=', 'LTFU')
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tofourteen_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tofourteen_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
->whereNull('tbl_client.hei_no')
@@ -1610,23 +1679,23 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tonineteen_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tonineteen_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->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"))
->whereNull('tbl_client.hei_no')
->where('tbl_appointment.app_status', '=', 'LTFU')
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $totwentyfour_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $totwentyfour_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->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"))
->whereNull('tbl_client.hei_no')
->where('tbl_appointment.app_status', '=', 'LTFU')
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $totwentynine_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $totwentynine_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1634,7 +1703,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tothirtyfour_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tothirtyfour_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1642,7 +1711,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tothirtynine_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tothirtynine_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1650,7 +1719,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tofortyfour_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tofortyfour_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1658,7 +1727,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tofortynine_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tofortynine_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1666,7 +1735,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tofifty_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tofifty_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50) and ((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_pmtct`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1674,7 +1743,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tototal_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tototal_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->whereNull('tbl_client.hei_no')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
@@ -1682,16 +1751,16 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- // honoured appointments
- $tonine_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ // honoured appointments
+ $tonine_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->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"))
->whereNull('tbl_client.hei_no')
->where('tbl_appointment.appointment_kept', '=', 'Yes')
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tofourteen_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tofourteen_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
->whereNull('tbl_client.hei_no')
@@ -1699,23 +1768,23 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tonineteen_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tonineteen_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->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"))
->whereNull('tbl_client.hei_no')
->where('tbl_appointment.appointment_kept', '=', 'Yes')
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $totwentyfour_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $totwentyfour_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->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"))
->whereNull('tbl_client.hei_no')
->where('tbl_appointment.appointment_kept', '=', 'Yes')
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $totwentynine_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $totwentynine_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1723,7 +1792,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tothirtyfour_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tothirtyfour_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1731,7 +1800,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tothirtynine_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tothirtynine_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1739,7 +1808,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tofortyfour_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tofortyfour_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1747,7 +1816,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tofortynine_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tofortynine_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1755,7 +1824,7 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tofifty_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tofifty_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50) and ((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_pmtct`.`id` end)) AS count"))
->whereNull('tbl_client.hei_no')
@@ -1763,1653 +1832,1753 @@ public function pmtct_dashboard()
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- $tototal_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ $tototal_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->whereNull('tbl_client.hei_no')
->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
->where('tbl_appointment.appointment_kept', '=', 'Yes')
->where('tbl_client.partner_id', Auth::user()->partner_id)
->pluck('count');
- }
+ }
- // Administrator
+ // Administrator
- $all_partners = Partner::where('status', '=', 'Active')
+ $all_partners = Partner::where('status', '=', 'Active')
->pluck('name', 'id');
if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
$tonine_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- // ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ // ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->pluck('count');
$tofourteen_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- // ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ // ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->pluck('count');
$tonineteen_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- //->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ //->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->pluck('count');
$totwentyfour_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- //->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ //->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->pluck('count');
$totwentynine_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- // ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ // ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->pluck('count');
$tothirtyfour_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- // ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ // ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->pluck('count');
$tothirtynine_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- //->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ //->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->pluck('count');
$tofortyfour_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- // ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ // ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->pluck('count');
$tofortynine_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- // ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ // ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->pluck('count');
$tofiftyplus_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- //->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ //->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->pluck('count');
$tototal_scheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- // ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ // ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->pluck('count');
// Un-Scheduled
$tonine_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->pluck('count');
$tofourteen_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->pluck('count');
$tonineteen_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->pluck('count');
$totwentyfour_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->pluck('count');
$totwentynine_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->pluck('count');
$tothirtyfour_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->pluck('count');
$tothirtynine_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->pluck('count');
$tofortyfour_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->pluck('count');
$tofortynine_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->pluck('count');
$tofifty_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50) and ((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_pmtct`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50) and ((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->pluck('count');
$tototal_unscheduled = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->whereNull('tbl_client.hei_no')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->whereNull('tbl_client.hei_no')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->pluck('count');
//Booked
$tonine_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.appntmnt_date', '>', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.appntmnt_date', '>', Now())
+ ->pluck('count');
$tofourteen_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.appntmnt_date', '>', Now())
- ->pluck('count');
-
- $tonineteen_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.appntmnt_date', '>', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.appntmnt_date', '>', Now())
+ ->pluck('count');
+
+ $tonineteen_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.appntmnt_date', '>', Now())
+ ->pluck('count');
$totwentyfour_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.appntmnt_date', '>', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.appntmnt_date', '>', Now())
+ ->pluck('count');
$totwentynine_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.appntmnt_date', '>', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.appntmnt_date', '>', Now())
+ ->pluck('count');
$tothirtyfour_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.appntmnt_date', '>', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.appntmnt_date', '>', Now())
+ ->pluck('count');
$tothirtynine_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.appntmnt_date', '>', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.appntmnt_date', '>', Now())
+ ->pluck('count');
$tofortyfour_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.appntmnt_date', '>', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.appntmnt_date', '>', Now())
+ ->pluck('count');
$tofortynine_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.appntmnt_date', '>', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.appntmnt_date', '>', Now())
+ ->pluck('count');
$tofifty_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50) and ((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_pmtct`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.appntmnt_date', '>', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50) and ((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.appntmnt_date', '>', Now())
+ ->pluck('count');
$tototal_booked = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->whereNull('tbl_client.hei_no')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.appntmnt_date', '>', Now())
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->whereNull('tbl_client.hei_no')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.appntmnt_date', '>', Now())
+ ->pluck('count');
// Defaulter
$tonine_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->pluck('count');
$tofourteen_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->pluck('count');
$tonineteen_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->pluck('count');
$totwentyfour_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->pluck('count');
$totwentynine_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->pluck('count');
$tothirtyfour_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->pluck('count');
$tothirtynine_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->pluck('count');
$tofortyfour_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->pluck('count');
$tofortynine_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->pluck('count');
$tofifty_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50) and ((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_pmtct`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50) and ((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->pluck('count');
$tototal_defaulted = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->whereNull('tbl_client.hei_no')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->whereNull('tbl_client.hei_no')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->pluck('count');
// Missed
$tonine_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->pluck('count');
$tofourteen_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->pluck('count');
$tonineteen_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->pluck('count');
$totwentyfour_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->pluck('count');
$totwentynine_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->pluck('count');
$tothirtyfour_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->pluck('count');
$tothirtynine_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->pluck('count');
$tofortyfour_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->pluck('count');
$tofortynine_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->pluck('count');
$tofifty_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50) and ((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_pmtct`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50) and ((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->pluck('count');
$tototal_missed = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->whereNull('tbl_client.hei_no')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->whereNull('tbl_client.hei_no')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->pluck('count');
// LTFU
$tonine_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->pluck('count');
$tofourteen_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->pluck('count');
$tonineteen_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->pluck('count');
$totwentyfour_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->pluck('count');
$totwentynine_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->pluck('count');
-
- $tothirtyfour_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->pluck('count');
+
+ $tothirtyfour_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->pluck('count');
$tothirtynine_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->pluck('count');
$tofortyfour_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->pluck('count');
$tofortynine_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->pluck('count');
$tofifty_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50) and ((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_pmtct`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50) and ((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->pluck('count');
$tototal_ltfu = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->whereNull('tbl_client.hei_no')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->whereNull('tbl_client.hei_no')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->pluck('count');
// honoured appointments
$tonine_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appointment_kept', '=', 'Yes')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appointment_kept', '=', 'Yes')
+ ->pluck('count');
$tofourteen_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appointment_kept', '=', 'Yes')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appointment_kept', '=', 'Yes')
+ ->pluck('count');
$tonineteen_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appointment_kept', '=', 'Yes')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appointment_kept', '=', 'Yes')
+ ->pluck('count');
$totwentyfour_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appointment_kept', '=', 'Yes')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appointment_kept', '=', 'Yes')
+ ->pluck('count');
$totwentynine_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appointment_kept', '=', 'Yes')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 25) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 29)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appointment_kept', '=', 'Yes')
+ ->pluck('count');
$tothirtyfour_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appointment_kept', '=', 'Yes')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 30) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 34)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appointment_kept', '=', 'Yes')
+ ->pluck('count');
$tothirtynine_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appointment_kept', '=', 'Yes')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 35) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 39)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appointment_kept', '=', 'Yes')
+ ->pluck('count');
$tofortyfour_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appointment_kept', '=', 'Yes')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 40) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 44)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appointment_kept', '=', 'Yes')
+ ->pluck('count');
$tofortynine_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appointment_kept', '=', 'Yes')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 45) and ((year(curdate()) - year(`tbl_client`.`dob`)) <= 49)) then `tbl_client`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appointment_kept', '=', 'Yes')
+ ->pluck('count');
$tofifty_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50) and ((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_pmtct`.`id` end)) AS count"))
- ->whereNull('tbl_client.hei_no')
- ->where('tbl_appointment.appointment_kept', '=', 'Yes')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) >= 50) and ((year(curdate()) - year(`tbl_client`.`dob`)) >= 50)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appointment_kept', '=', 'Yes')
+ ->pluck('count');
$tototal_honoured = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->whereNull('tbl_client.hei_no')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
- ->where('tbl_appointment.appointment_kept', '=', 'Yes')
- ->pluck('count');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->whereNull('tbl_client.hei_no')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_client`.`dob`)) > 0) and ((year(curdate()) - year(`tbl_client`.`dob`)) >=10)) then `tbl_client`.`id` end)) AS count"))
+ ->where('tbl_appointment.appointment_kept', '=', 'Yes')
+ ->pluck('count');
}
- return view('pmtct/pmtct_dashboard', compact('all_partners', 'tonine_scheduled', 'tofourteen_scheduled', 'tonineteen_scheduled', 'totwentyfour_scheduled',
- 'totwentynine_scheduled', 'tothirtyfour_scheduled', 'tothirtynine_scheduled', 'tofortyfour_scheduled', 'tofortynine_scheduled', 'tofiftyplus_scheduled', 'tototal_scheduled',
- 'tonine_unscheduled', 'tofourteen_unscheduled', 'tonineteen_unscheduled', 'totwentyfour_unscheduled', 'totwentynine_unscheduled', 'tothirtyfour_unscheduled', 'tothirtynine_unscheduled',
- 'tofortyfour_unscheduled', 'tofortynine_unscheduled', 'tofifty_unscheduled', 'tototal_unscheduled', 'tonine_booked', 'tofourteen_booked', 'tonineteen_booked', 'totwentyfour_booked',
- 'totwentynine_booked', 'tothirtyfour_booked', 'tothirtynine_booked', 'tofortyfour_booked', 'tofortynine_booked', 'tofifty_booked', 'tototal_booked',
- 'tonine_defaulted', 'tofourteen_defaulted', 'tonineteen_defaulted', 'totwentyfour_defaulted',
- 'totwentynine_defaulted', 'tothirtyfour_defaulted', 'tothirtynine_defaulted', 'tofortyfour_defaulted', 'tofortynine_defaulted', 'tofifty_defaulted', 'tototal_defaulted',
- 'tonine_missed', 'tofourteen_missed', 'tonineteen_missed', 'totwentyfour_missed',
- 'totwentynine_missed', 'tothirtyfour_missed', 'tothirtynine_missed', 'tofortyfour_missed', 'tofortynine_missed', 'tofifty_missed', 'tototal_missed',
- 'tonine_ltfu', 'tofourteen_ltfu', 'tonineteen_ltfu', 'totwentyfour_ltfu',
- 'totwentynine_ltfu', 'tothirtyfour_ltfu', 'tothirtynine_ltfu', 'tofortyfour_ltfu', 'tofortynine_ltfu', 'tofifty_ltfu', 'tototal_ltfu',
- 'tonine_honoured', 'tofourteen_honoured', 'tonineteen_honoured', 'totwentyfour_honoured',
- 'totwentynine_honoured', 'tothirtyfour_honoured', 'tothirtynine_honoured', 'tofortyfour_honoured', 'tofortynine_honoured', 'tofifty_honoured', 'tototal_honoured'));
+ return view('pmtct/pmtct_dashboard', compact(
+ 'all_partners',
+ 'tonine_scheduled',
+ 'tofourteen_scheduled',
+ 'tonineteen_scheduled',
+ 'totwentyfour_scheduled',
+ 'totwentynine_scheduled',
+ 'tothirtyfour_scheduled',
+ 'tothirtynine_scheduled',
+ 'tofortyfour_scheduled',
+ 'tofortynine_scheduled',
+ 'tofiftyplus_scheduled',
+ 'tototal_scheduled',
+ 'tonine_unscheduled',
+ 'tofourteen_unscheduled',
+ 'tonineteen_unscheduled',
+ 'totwentyfour_unscheduled',
+ 'totwentynine_unscheduled',
+ 'tothirtyfour_unscheduled',
+ 'tothirtynine_unscheduled',
+ 'tofortyfour_unscheduled',
+ 'tofortynine_unscheduled',
+ 'tofifty_unscheduled',
+ 'tototal_unscheduled',
+ 'tonine_booked',
+ 'tofourteen_booked',
+ 'tonineteen_booked',
+ 'totwentyfour_booked',
+ 'totwentynine_booked',
+ 'tothirtyfour_booked',
+ 'tothirtynine_booked',
+ 'tofortyfour_booked',
+ 'tofortynine_booked',
+ 'tofifty_booked',
+ 'tototal_booked',
+ 'tonine_defaulted',
+ 'tofourteen_defaulted',
+ 'tonineteen_defaulted',
+ 'totwentyfour_defaulted',
+ 'totwentynine_defaulted',
+ 'tothirtyfour_defaulted',
+ 'tothirtynine_defaulted',
+ 'tofortyfour_defaulted',
+ 'tofortynine_defaulted',
+ 'tofifty_defaulted',
+ 'tototal_defaulted',
+ 'tonine_missed',
+ 'tofourteen_missed',
+ 'tonineteen_missed',
+ 'totwentyfour_missed',
+ 'totwentynine_missed',
+ 'tothirtyfour_missed',
+ 'tothirtynine_missed',
+ 'tofortyfour_missed',
+ 'tofortynine_missed',
+ 'tofifty_missed',
+ 'tototal_missed',
+ 'tonine_ltfu',
+ 'tofourteen_ltfu',
+ 'tonineteen_ltfu',
+ 'totwentyfour_ltfu',
+ 'totwentynine_ltfu',
+ 'tothirtyfour_ltfu',
+ 'tothirtynine_ltfu',
+ 'tofortyfour_ltfu',
+ 'tofortynine_ltfu',
+ 'tofifty_ltfu',
+ 'tototal_ltfu',
+ 'tonine_honoured',
+ 'tofourteen_honoured',
+ 'tonineteen_honoured',
+ 'totwentyfour_honoured',
+ 'totwentynine_honoured',
+ 'tothirtyfour_honoured',
+ 'tothirtynine_honoured',
+ 'tofortyfour_honoured',
+ 'tofortynine_honoured',
+ 'tofifty_honoured',
+ 'tototal_honoured'
+ ));
}
public function hei_dashboard()
-{
- $all_partners = Partner::where('status', '=', 'Active')
- ->pluck('name', 'id');
- if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
- $toone_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.active_app', '=', 1)
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ {
+ $all_partners = Partner::where('status', '=', 'Active')
+ ->pluck('name', 'id');
+ if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+ $toone_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.active_app', '=', 1)
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
- $tofour_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.active_app', '=', 1)
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ $tofour_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.active_app', '=', 1)
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
- $tonine_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.active_app', '=', 1)
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ $tonine_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.active_app', '=', 1)
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
- $tofourteen_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.active_app', '=', 1)
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ $tofourteen_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.active_app', '=', 1)
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
- $tototal_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.active_app', '=', 1)
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ $tototal_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.active_app', '=', 1)
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
- $toone_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
- // ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ $toone_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
+ // ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
- $tofour_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
- // ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ $tofour_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
+ // ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
- $tonine_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
- //->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ $tonine_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
+ //->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
- $tofourteen_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- //->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ $tofourteen_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ //->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
- $tototal_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- // ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ $tototal_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ // ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
- $toone_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ $toone_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
- $tofour_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ $tofour_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
- $tonine_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ $tonine_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
- $tofourteen_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ $tofourteen_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
- $tototal_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ $tototal_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
- $toone_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ $toone_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
- $tofour_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ $tofour_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
- $tonine_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ $tonine_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
- $tofourteen_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ $tofourteen_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
- $tototal_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ $tototal_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
- $toone_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ $toone_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
- $tofour_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ $tofour_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
- $tonine_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ $tonine_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
- $tofourteen_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ $tofourteen_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
- $tototal_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ $tototal_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
- $toone_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ $toone_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
- $tofour_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ $tofour_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
- $tonine_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ $tonine_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
- $tofourteen_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ $tofourteen_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
- $tototal_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ $tototal_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
- // non-positive hei
- $count_booked_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("COUNT(tbl_appointment.id) as count"))
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.active_app', '=', 1)
- ->whereNotNull('tbl_client.hei_no')
- ->pluck('count');
+ // non-positive hei
+ $count_booked_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("COUNT(tbl_appointment.id) as count"))
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.active_app', '=', 1)
+ ->whereNotNull('tbl_client.hei_no')
+ ->pluck('count');
- $count_scheduled_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("COUNT(tbl_appointment.id) as count"))
- ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->pluck('count');
+ $count_scheduled_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("COUNT(tbl_appointment.id) as count"))
+ ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->pluck('count');
- $count_unscheduled_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("COUNT(tbl_appointment.id) as count"))
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->pluck('count');
-
- $count_deceased_heis = Client::select(\DB::raw("COUNT(tbl_client.id) as count"))
- ->where('tbl_client.status', '=', 'Deceased')
- ->whereNotNull('tbl_client.hei_no')
- ->pluck('count');
-
- $count_transfer_heis = Client::select(\DB::raw("COUNT(tbl_client.id) as count"))
- ->where('tbl_client.status', '=', 'Transfer Out')
- ->whereNotNull('tbl_client.hei_no')
- ->pluck('count');
-
- $count_discharged_heis = Client::select(\DB::raw("COUNT(tbl_client.id) as count"))
- ->where('tbl_client.status', '=', 'Disabled')
- ->whereNotNull('tbl_client.hei_no')
- ->pluck('count');
+ $count_unscheduled_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("COUNT(tbl_appointment.id) as count"))
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->pluck('count');
- $count_missed_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("COUNT(tbl_client.id) as count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->whereNotNull('tbl_client.hei_no')
- ->pluck('count');
+ $count_deceased_heis = Client::select(\DB::raw("COUNT(tbl_client.id) as count"))
+ ->where('tbl_client.status', '=', 'Deceased')
+ ->whereNotNull('tbl_client.hei_no')
+ ->pluck('count');
- $count_defaulted_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("COUNT(tbl_client.id) as count"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->whereNotNull('tbl_client.hei_no')
- ->pluck('count');
+ $count_transfer_heis = Client::select(\DB::raw("COUNT(tbl_client.id) as count"))
+ ->where('tbl_client.status', '=', 'Transfer Out')
+ ->whereNotNull('tbl_client.hei_no')
+ ->pluck('count');
- $count_ltfu_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("COUNT(tbl_client.id) as count"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->whereNotNull('tbl_client.hei_no')
- ->pluck('count');
+ $count_discharged_heis = Client::select(\DB::raw("COUNT(tbl_client.id) as count"))
+ ->where('tbl_client.status', '=', 'Disabled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->pluck('count');
- $count_pcr_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->select(\DB::raw("COUNT(tbl_pmtct.hei_no) as count"))
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->pluck('count');
+ $count_missed_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("COUNT(tbl_client.id) as count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->whereNotNull('tbl_client.hei_no')
+ ->pluck('count');
- }
+ $count_defaulted_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("COUNT(tbl_client.id) as count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereNotNull('tbl_client.hei_no')
+ ->pluck('count');
- if (Auth::user()->access_level == 'Facility') {
- $toone_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.active_app', '=', 1)
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $count_ltfu_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("COUNT(tbl_client.id) as count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->whereNotNull('tbl_client.hei_no')
+ ->pluck('count');
- $tofour_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.active_app', '=', 1)
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $count_pcr_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->select(\DB::raw("COUNT(tbl_pmtct.hei_no) as count"))
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->pluck('count');
+ }
- $tonine_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.active_app', '=', 1)
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ if (Auth::user()->access_level == 'Facility') {
+ $toone_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.active_app', '=', 1)
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $tofourteen_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.active_app', '=', 1)
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $tofour_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.active_app', '=', 1)
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $tototal_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.active_app', '=', 1)
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $tonine_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.active_app', '=', 1)
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $toone_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $tofourteen_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.active_app', '=', 1)
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $tofour_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $tototal_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.active_app', '=', 1)
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $tonine_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $toone_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $tofourteen_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $tofour_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $tototal_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $tonine_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+ $tofourteen_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $toone_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $tototal_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $tofour_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
- $tonine_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $toone_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $tofourteen_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $tofour_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $tototal_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $tonine_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $toone_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $tofourteen_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $tofour_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $tototal_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $tonine_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $toone_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $tofourteen_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $tofour_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $tototal_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $tonine_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $toone_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $tofourteen_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $tofour_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $tototal_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $tonine_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $toone_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $tofourteen_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $tofour_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $tototal_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $tonine_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $toone_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $tofourteen_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $tofour_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $tototal_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $tonine_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $toone_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $tofourteen_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $tofour_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $tototal_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $tonine_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- // non-positive hei
- $count_booked_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("COUNT(tbl_appointment.id) as count"))
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.active_app', '=', 1)
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->whereNotNull('tbl_client.hei_no')
- ->pluck('count');
+ $tofourteen_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $count_scheduled_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("COUNT(tbl_appointment.id) as count"))
- ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $tototal_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $count_unscheduled_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("COUNT(tbl_appointment.id) as count"))
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
-
- $count_deceased_heis = Client::select(\DB::raw("COUNT(tbl_client.id) as count"))
- ->where('tbl_client.status', '=', 'Deceased')
- ->whereNotNull('tbl_client.hei_no')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
-
- $count_transfer_heis = Client::select(\DB::raw("COUNT(tbl_client.id) as count"))
- ->where('tbl_client.status', '=', 'Transfer Out')
- ->whereNotNull('tbl_client.hei_no')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
-
- $count_discharged_heis = Client::select(\DB::raw("COUNT(tbl_client.id) as count"))
- ->where('tbl_client.status', '=', 'Disabled')
- ->whereNotNull('tbl_client.hei_no')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ // non-positive hei
+ $count_booked_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("COUNT(tbl_appointment.id) as count"))
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.active_app', '=', 1)
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->whereNotNull('tbl_client.hei_no')
+ ->pluck('count');
- $count_missed_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("COUNT(tbl_client.id) as count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->whereNotNull('tbl_client.hei_no')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $count_scheduled_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("COUNT(tbl_appointment.id) as count"))
+ ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $count_defaulted_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("COUNT(tbl_client.id) as count"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->whereNotNull('tbl_client.hei_no')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $count_unscheduled_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("COUNT(tbl_appointment.id) as count"))
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $count_ltfu_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("COUNT(tbl_client.id) as count"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->whereNotNull('tbl_client.hei_no')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $count_deceased_heis = Client::select(\DB::raw("COUNT(tbl_client.id) as count"))
+ ->where('tbl_client.status', '=', 'Deceased')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- $count_pcr_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->select(\DB::raw("COUNT(tbl_client.id) as count"))
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->pluck('count');
+ $count_transfer_heis = Client::select(\DB::raw("COUNT(tbl_client.id) as count"))
+ ->where('tbl_client.status', '=', 'Transfer Out')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- }
+ $count_discharged_heis = Client::select(\DB::raw("COUNT(tbl_client.id) as count"))
+ ->where('tbl_client.status', '=', 'Disabled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+
+ $count_missed_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("COUNT(tbl_client.id) as count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+
+ $count_defaulted_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("COUNT(tbl_client.id) as count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+
+ $count_ltfu_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("COUNT(tbl_client.id) as count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
- if (Auth::user()->access_level == 'Partner') {
+ $count_pcr_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->select(\DB::raw("COUNT(tbl_client.id) as count"))
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->pluck('count');
+ }
+
+ if (Auth::user()->access_level == 'Partner') {
$all_partners = Partner::where('status', '=', 'Active')
- ->where('id', Auth::user()->partner_id)
- ->pluck('name', 'id');
- $toone_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.active_app', '=', 1)
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ ->where('id', Auth::user()->partner_id)
+ ->pluck('name', 'id');
+ $toone_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.active_app', '=', 1)
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $tofour_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.active_app', '=', 1)
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $tofour_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.active_app', '=', 1)
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $tonine_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.active_app', '=', 1)
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $tonine_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.active_app', '=', 1)
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $tofourteen_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.active_app', '=', 1)
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $tofourteen_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.active_app', '=', 1)
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $tototal_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.active_app', '=', 1)
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $tototal_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.active_app', '=', 1)
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $toone_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $toone_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $tofour_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $tofour_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $tonine_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $tonine_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $tofourteen_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $tofourteen_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
+
+ $tototal_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $tototal_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $toone_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $toone_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $tofour_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $tofour_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $tonine_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $tonine_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $tofourteen_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $tofourteen_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $tototal_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $tototal_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $toone_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $toone_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $tofour_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $tofour_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $tonine_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $tonine_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $tofourteen_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $tofourteen_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $tototal_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $tototal_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $toone_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $toone_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $tofour_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $tofour_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $tonine_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $tonine_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $tofourteen_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $tofourteen_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $tototal_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $tototal_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $toone_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $toone_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $tofour_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $tofour_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $tonine_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $tonine_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $tofourteen_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $tofourteen_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $tototal_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $tototal_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("count((case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end)) AS count"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ // non-positive hei
+ $count_booked_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("COUNT(tbl_appointment.id) as count"))
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.active_app', '=', 1)
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->whereNotNull('tbl_client.hei_no')
+ ->pluck('count');
- // non-positive hei
- $count_booked_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("COUNT(tbl_appointment.id) as count"))
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.active_app', '=', 1)
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->whereNotNull('tbl_client.hei_no')
- ->pluck('count');
+ $count_scheduled_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("COUNT(tbl_appointment.id) as count"))
+ ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $count_scheduled_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("COUNT(tbl_appointment.id) as count"))
- ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $count_unscheduled_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("COUNT(tbl_appointment.id) as count"))
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $count_unscheduled_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("COUNT(tbl_appointment.id) as count"))
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
-
- $count_deceased_heis = Client::select(\DB::raw("COUNT(tbl_client.id) as count"))
- ->where('tbl_client.status', '=', 'Deceased')
- ->whereNotNull('tbl_client.hei_no')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
-
- $count_transfer_heis = Client::select(\DB::raw("COUNT(tbl_client.id) as count"))
- ->where('tbl_client.status', '=', 'Transfer Out')
- ->whereNotNull('tbl_client.hei_no')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
-
- $count_discharged_heis = Client::select(\DB::raw("COUNT(tbl_client.id) as count"))
- ->where('tbl_client.status', '=', 'Disabled')
- ->whereNotNull('tbl_client.hei_no')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $count_deceased_heis = Client::select(\DB::raw("COUNT(tbl_client.id) as count"))
+ ->where('tbl_client.status', '=', 'Deceased')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $count_missed_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("COUNT(tbl_client.id) as count"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->whereNotNull('tbl_client.hei_no')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $count_transfer_heis = Client::select(\DB::raw("COUNT(tbl_client.id) as count"))
+ ->where('tbl_client.status', '=', 'Transfer Out')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $count_defaulted_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("COUNT(tbl_client.id) as count"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->whereNotNull('tbl_client.hei_no')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $count_discharged_heis = Client::select(\DB::raw("COUNT(tbl_client.id) as count"))
+ ->where('tbl_client.status', '=', 'Disabled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $count_ltfu_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->select(\DB::raw("COUNT(tbl_client.id) as count"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->whereNotNull('tbl_client.hei_no')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $count_missed_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("COUNT(tbl_client.id) as count"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- $count_pcr_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->select(\DB::raw("COUNT(tbl_client.id) as count"))
- ->whereNotNull('tbl_pmtct.date_confirmed_positive')
- ->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->pluck('count');
+ $count_defaulted_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("COUNT(tbl_client.id) as count"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- }
+ $count_ltfu_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->select(\DB::raw("COUNT(tbl_client.id) as count"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
- return view('pmtct/hei_dashboard', compact('all_partners', 'toone_booked_heis', 'tofour_booked_heis', 'tonine_booked_heis', 'tofourteen_booked_heis',
- 'toone_scheduled_heis', 'tofour_scheduled_heis', 'tonine_scheduled_heis', 'tofourteen_scheduled_heis', 'toone_unscheduled_heis', 'tofour_unscheduled_heis',
- 'tonine_unscheduled_heis', 'tofourteen_unscheduled_heis', 'toone_missed_heis', 'tofour_missed_heis', 'tonine_missed_heis', 'tofourteen_missed_heis',
- 'toone_defaulted_heis', 'tofour_defaulted_heis', 'tonine_defaulted_heis', 'tofourteen_defaulted_heis', 'toone_ltfu_heis', 'tofour_ltfu_heis', 'tonine_ltfu_heis', 'tofourteen_ltfu_heis',
- 'tototal_booked_heis', 'tototal_scheduled_heis', 'tototal_unscheduled_heis', 'tototal_missed_heis', 'tototal_defaulted_heis', 'tototal_ltfu_heis', 'count_booked_heis', 'count_scheduled_heis',
- 'count_unscheduled_heis', 'count_deceased_heis', 'count_transfer_heis', 'count_discharged_heis', 'count_missed_heis', 'count_defaulted_heis', 'count_ltfu_heis', 'count_pcr_heis'));
+ $count_pcr_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->select(\DB::raw("COUNT(tbl_client.id) as count"))
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive')
+ ->where('tbl_client.partner_id', Auth::user()->partner_id)
+ ->pluck('count');
+ }
-}
+ return view('pmtct/hei_dashboard', compact(
+ 'all_partners',
+ 'toone_booked_heis',
+ 'tofour_booked_heis',
+ 'tonine_booked_heis',
+ 'tofourteen_booked_heis',
+ 'toone_scheduled_heis',
+ 'tofour_scheduled_heis',
+ 'tonine_scheduled_heis',
+ 'tofourteen_scheduled_heis',
+ 'toone_unscheduled_heis',
+ 'tofour_unscheduled_heis',
+ 'tonine_unscheduled_heis',
+ 'tofourteen_unscheduled_heis',
+ 'toone_missed_heis',
+ 'tofour_missed_heis',
+ 'tonine_missed_heis',
+ 'tofourteen_missed_heis',
+ 'toone_defaulted_heis',
+ 'tofour_defaulted_heis',
+ 'tonine_defaulted_heis',
+ 'tofourteen_defaulted_heis',
+ 'toone_ltfu_heis',
+ 'tofour_ltfu_heis',
+ 'tonine_ltfu_heis',
+ 'tofourteen_ltfu_heis',
+ 'tototal_booked_heis',
+ 'tototal_scheduled_heis',
+ 'tototal_unscheduled_heis',
+ 'tototal_missed_heis',
+ 'tototal_defaulted_heis',
+ 'tototal_ltfu_heis',
+ 'count_booked_heis',
+ 'count_scheduled_heis',
+ 'count_unscheduled_heis',
+ 'count_deceased_heis',
+ 'count_transfer_heis',
+ 'count_discharged_heis',
+ 'count_missed_heis',
+ 'count_defaulted_heis',
+ 'count_ltfu_heis',
+ 'count_pcr_heis'
+ ));
+ }
public function filter_hei_dashboard(Request $request)
-{
- $data = [];
+ {
+ $data = [];
$selected_counties = $request->partners;
$selected_counties = $request->counties;
@@ -3417,319 +3586,319 @@ public function filter_hei_dashboard(Request $request)
$selected_facilites = $request->facilities;
$toone_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end"))
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.active_app', '=', 1)
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end"))
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.active_app', '=', 1)
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
$tofour_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end"))
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.active_app', '=', 1)
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end"))
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.active_app', '=', 1)
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
$tonine_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end"))
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.active_app', '=', 1)
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end"))
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.active_app', '=', 1)
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
$tofourteen_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end"))
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.active_app', '=', 1)
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end"))
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.active_app', '=', 1)
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
$tototal_booked_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end"))
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.active_app', '=', 1)
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end"))
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.active_app', '=', 1)
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
$toone_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end"))
- // ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end"))
+ // ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
$tofour_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end"))
- // ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end"))
+ // ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
$tonine_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end"))
- //->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end"))
+ //->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
$tofourteen_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end"))
- //->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end"))
+ //->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
$tototal_scheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end"))
- // ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->whereNotNull('tbl_client.hei_no')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end"))
+ // ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->whereNotNull('tbl_client.hei_no')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
$toone_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end"))
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end"))
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
$tofour_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end"))
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end"))
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
$tonine_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end"))
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end"))
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
$tofourteen_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end"))
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end"))
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
$tototal_unscheduled_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end"))
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->where('tbl_appointment.appntmnt_date', '<', Now())
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end"))
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->where('tbl_appointment.appntmnt_date', '<', Now())
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
$toone_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
$tofour_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
$tonine_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
$tofourteen_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
$tototal_missed_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
$toone_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
$tofour_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
$tonine_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
$tofourteen_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
$tototal_defaulted_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
$toone_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) < 1)) then `tbl_pmtct`.`id` end"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
$tofour_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 1) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 4)) then `tbl_pmtct`.`id` end"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
$tonine_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 5) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 9)) then `tbl_pmtct`.`id` end"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
$tofourteen_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) >= 10) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
$tototal_ltfu_heis = Pmtct::join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->whereNotNull('tbl_client.hei_no')
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("case when (((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) > 0) and ((year(curdate()) - year(`tbl_pmtct`.`hei_dob`)) <= 14)) then `tbl_pmtct`.`id` end"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->whereNotNull('tbl_client.hei_no')
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
// non-positive hei
$count_booked_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("tbl_appointment.id"))
- ->where('tbl_appointment.app_status', '=', 'Booked')
- ->where('tbl_appointment.active_app', '=', 1)
- ->whereNotNull('tbl_client.hei_no');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("tbl_appointment.id"))
+ ->where('tbl_appointment.app_status', '=', 'Booked')
+ ->where('tbl_appointment.active_app', '=', 1)
+ ->whereNotNull('tbl_client.hei_no');
$count_scheduled_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("tbl_appointment.id"))
- ->where('tbl_appointment.visit_type', '=', 'Scheduled')
- ->whereNotNull('tbl_client.hei_no');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("tbl_appointment.id"))
+ ->where('tbl_appointment.visit_type', '=', 'Scheduled')
+ ->whereNotNull('tbl_client.hei_no');
$count_unscheduled_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("tbl_appointment.id"))
- ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
- ->whereNotNull('tbl_client.hei_no');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("tbl_appointment.id"))
+ ->where('tbl_appointment.visit_type', '=', 'Un-Scheduled')
+ ->whereNotNull('tbl_client.hei_no');
$count_deceased_heis = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("tbl_client.id"))
- ->where('tbl_client.status', '=', 'Deceased')
- ->whereNotNull('tbl_client.hei_no');
+ ->select(\DB::raw("tbl_client.id"))
+ ->where('tbl_client.status', '=', 'Deceased')
+ ->whereNotNull('tbl_client.hei_no');
$count_transfer_heis = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("tbl_client.id"))
- ->where('tbl_client.status', '=', 'Transfer Out')
- ->whereNotNull('tbl_client.hei_no');
+ ->select(\DB::raw("tbl_client.id"))
+ ->where('tbl_client.status', '=', 'Transfer Out')
+ ->whereNotNull('tbl_client.hei_no');
$count_discharged_heis = Client::join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("tbl_client.id"))
- ->where('tbl_client.status', '=', 'Disabled')
- ->whereNotNull('tbl_client.hei_no');
+ ->select(\DB::raw("tbl_client.id"))
+ ->where('tbl_client.status', '=', 'Disabled')
+ ->whereNotNull('tbl_client.hei_no');
$count_missed_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("tbl_client.id"))
- ->where('tbl_appointment.app_status', '=', 'Missed')
- ->whereNotNull('tbl_client.hei_no');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("tbl_client.id"))
+ ->where('tbl_appointment.app_status', '=', 'Missed')
+ ->whereNotNull('tbl_client.hei_no');
$count_defaulted_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("tbl_client.id"))
- ->where('tbl_appointment.app_status', '=', 'Defaulted')
- ->whereNotNull('tbl_client.hei_no');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("tbl_client.id"))
+ ->where('tbl_appointment.app_status', '=', 'Defaulted')
+ ->whereNotNull('tbl_client.hei_no');
$count_ltfu_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("tbl_client.id"))
- ->where('tbl_appointment.app_status', '=', 'LTFU')
- ->whereNotNull('tbl_client.hei_no');
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("tbl_client.id"))
+ ->where('tbl_appointment.app_status', '=', 'LTFU')
+ ->whereNotNull('tbl_client.hei_no');
$count_pcr_heis = Appointments::join('tbl_client', 'tbl_client.id', '=', 'tbl_appointment.client_id')
- ->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
- ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
- ->select(\DB::raw("tbl_client.id"))
- ->whereNotNull('tbl_pmtct.date_confirmed_positive');
+ ->join('tbl_pmtct', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("tbl_client.id"))
+ ->whereNotNull('tbl_pmtct.date_confirmed_positive');
if (!empty($selected_partners)) {
$toone_booked_heis = $toone_booked_heis->where('tbl_partner_facility.partner_id', $selected_partners);
@@ -3946,7 +4115,13 @@ public function filter_hei_dashboard(Request $request)
$data["count_pcr_heis"] = $count_pcr_heis->count();
return $data;
+ }
+ public function pmtct_enrollment()
+ {
+ $pmtct_anc = DB::table('tbl_pmtct_anc')->join('tbl_client', 'tbl_pmtct_anc.client_id','=', 'tbl_client.id')
+ ->select('tbl_client.f_name', 'tbl_client.l_name', 'tbl_client.clinic_number', 'tbl_pmtct_anc.visit_number')
+ ->get();
+
+ }
}
-
-}
\ No newline at end of file
diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php
index f36e4a1..bc39486 100644
--- a/app/Http/Controllers/ReportController.php
+++ b/app/Http/Controllers/ReportController.php
@@ -13,8 +13,10 @@
use App\Models\Summary;
use App\Models\MonthlyApp;
use App\Models\Partner;
+use App\Models\Dcm;
use DB;
use Auth;
+use Cache;
class ReportController extends Controller
{
@@ -25,28 +27,28 @@ public function deactivated_clients()
if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
$all_deactivated_clients = Client::join('tbl_groups', 'tbl_groups.id', 'tbl_client.group_id')
- ->select('tbl_client.clinic_number', 'tbl_client.file_no', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as full_name"), 'tbl_client.phone_no', 'tbl_client.dob', 'tbl_client.client_type', 'tbl_groups.name', 'tbl_client.created_at')
- ->where('tbl_client.status', '=', 'Disabled')
- ->get();
+ ->select('tbl_client.clinic_number', 'tbl_client.file_no', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as full_name"), 'tbl_client.phone_no', 'tbl_client.dob', 'tbl_client.status as client_type', 'tbl_groups.name', 'tbl_client.created_at')
+ ->whereIn('tbl_client.status', ['Disabled', 'Deceased'])
+ ->paginate(15000);
}
if (Auth::user()->access_level == 'Facility') {
$all_deactivated_clients = Client::join('tbl_groups', 'tbl_groups.id', 'tbl_client.group_id')
- ->select('tbl_client.clinic_number', 'tbl_client.file_no', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as full_name"), 'tbl_client.phone_no', 'tbl_client.dob', 'tbl_client.client_type', 'tbl_groups.name', 'tbl_client.created_at')
- ->where('tbl_client.status', '=', 'Disabled')
+ ->select('tbl_client.clinic_number', 'tbl_client.file_no', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as full_name"), 'tbl_client.phone_no', 'tbl_client.dob', 'tbl_client.status as client_type', 'tbl_groups.name', 'tbl_client.created_at')
+ ->whereIn('tbl_client.status', ['Disabled', 'Deceased'])
->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->get();
+ ->paginate(10000);
}
if (Auth::user()->access_level == 'Partner') {
$all_partners = Partner::where('status', '=', 'Active')
- ->where('id', Auth::user()->partner_id)
- ->pluck('name', 'id');
+ ->where('id', Auth::user()->partner_id)
+ ->pluck('name', 'id');
$all_deactivated_clients = Client::join('tbl_groups', 'tbl_groups.id', 'tbl_client.group_id')
- ->select('tbl_client.clinic_number', 'tbl_client.file_no', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as full_name"), 'tbl_client.phone_no', 'tbl_client.dob', 'tbl_client.client_type', 'tbl_groups.name', 'tbl_client.created_at')
- ->where('tbl_client.status', '=', 'Disabled')
+ ->select('tbl_client.clinic_number', 'tbl_client.file_no', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as full_name"), 'tbl_client.phone_no', 'tbl_client.dob', 'tbl_client.status as client_type', 'tbl_groups.name', 'tbl_client.created_at')
+ ->whereIn('tbl_client.status', ['Disabled', 'Deceased'])
->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->get();
+ ->paginate(10000);
}
return view('reports.deactivated_clients', compact('all_deactivated_clients', 'all_partners'));
@@ -55,56 +57,56 @@ public function deactivated_clients()
public function transfer_out()
{
$all_partners = Partner::where('status', '=', 'Active')
- ->pluck('name', 'id');
+ ->pluck('name', 'id');
if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
$all_transfer_clients = Client::join('tbl_groups', 'tbl_groups.id', 'tbl_client.group_id')
->join('tbl_master_facility', 'tbl_master_facility.code', '=', 'tbl_client.mfl_code')
->select('tbl_client.clinic_number', 'tbl_client.file_no', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as full_name"), DB::raw("CONCAT(`tbl_client`.`prev_clinic`, ' ', `tbl_master_facility`.`name`) as clinic_previous"), 'tbl_client.phone_no', 'tbl_client.dob', 'tbl_client.client_status', 'tbl_groups.name', 'tbl_client.created_at')
- // ->where('tbl_client.prev_clinic', '=', 'tbl_master_facility.code')
+ // ->where('tbl_client.prev_clinic', '=', 'tbl_master_facility.code')
->where('tbl_client.status', '=', 'Transfer Out')
- ->get();
+ ->paginate(1000);
$all_transfer_in = Client::join('tbl_groups', 'tbl_groups.id', 'tbl_client.group_id')
->join('tbl_master_facility', 'tbl_master_facility.code', '=', 'tbl_client.prev_clinic')
->select('tbl_client.clinic_number', 'tbl_client.file_no', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as full_name"), DB::raw("CONCAT(`tbl_client`.`prev_clinic`, ' ', `tbl_master_facility`.`name`) as clinic_previous"), 'tbl_client.phone_no', 'tbl_client.dob', 'tbl_client.client_status', 'tbl_groups.name', 'tbl_client.created_at')
->where('tbl_client.mfl_code', '!=', 'tbl_client.prev_clinic')
- ->get();
+ ->paginate(1000);
}
if (Auth::user()->access_level == 'Facility') {
$all_transfer_clients = Client::join('tbl_groups', 'tbl_groups.id', 'tbl_client.group_id')
->join('tbl_master_facility', 'tbl_master_facility.code', '=', 'tbl_client.mfl_code')
->select('tbl_client.clinic_number', 'tbl_client.file_no', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as full_name"), DB::raw("CONCAT(`tbl_client`.`prev_clinic`, ' ', `tbl_master_facility`.`name`) as clinic_previous"), 'tbl_client.phone_no', 'tbl_client.dob', 'tbl_client.client_status', 'tbl_groups.name', 'tbl_client.created_at')
- ->where('tbl_client.status', '=', 'Transfer Out')
+ ->where('tbl_client.status', '=', 'Transfer Out')
->where('tbl_client.prev_clinic', Auth::user()->facility_id)
- ->get();
+ ->paginate(1000);
$all_transfer_in = Client::join('tbl_groups', 'tbl_groups.id', 'tbl_client.group_id')
->join('tbl_master_facility', 'tbl_master_facility.code', '=', 'tbl_client.prev_clinic')
->select('tbl_client.clinic_number', 'tbl_client.file_no', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as full_name"), DB::raw("CONCAT(`tbl_client`.`prev_clinic`, ' ', `tbl_master_facility`.`name`) as clinic_previous"), 'tbl_client.phone_no', 'tbl_client.dob', 'tbl_client.client_status', 'tbl_groups.name', 'tbl_client.created_at')
->where('tbl_client.mfl_code', '!=', 'tbl_client.prev_clinic')
->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->get();
+ ->paginate(1000);
}
if (Auth::user()->access_level == 'Partner') {
$all_partners = Partner::where('status', '=', 'Active')
- ->where('id', Auth::user()->partner_id)
- ->pluck('name', 'id');
+ ->where('id', Auth::user()->partner_id)
+ ->pluck('name', 'id');
$all_transfer_clients = Client::join('tbl_groups', 'tbl_groups.id', 'tbl_client.group_id')
->join('tbl_master_facility', 'tbl_master_facility.code', '=', 'tbl_client.mfl_code')
->select('tbl_client.clinic_number', 'tbl_client.file_no', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as full_name"), DB::raw("CONCAT(`tbl_client`.`prev_clinic`, ' ', `tbl_master_facility`.`name`) as clinic_previous"), 'tbl_client.phone_no', 'tbl_client.dob', 'tbl_client.client_status', 'tbl_groups.name', 'tbl_client.created_at')
->where('tbl_client.status', '=', 'Transfer Out')
->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->get();
+ ->paginate(1000);
$all_transfer_in = Client::join('tbl_groups', 'tbl_groups.id', 'tbl_client.group_id')
->join('tbl_master_facility', 'tbl_master_facility.code', '=', 'tbl_client.prev_clinic')
->select('tbl_client.clinic_number', 'tbl_client.file_no', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as full_name"), DB::raw("CONCAT(`tbl_client`.`prev_clinic`, '', `tbl_master_facility`.`name`) as clinic_previous"), 'tbl_client.phone_no', 'tbl_client.dob', 'tbl_client.client_status', 'tbl_groups.name', 'tbl_client.created_at')
->where('tbl_client.mfl_code', '!=', 'tbl_client.prev_clinic')
->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->get();
+ ->paginate(1000);
}
@@ -129,35 +131,41 @@ public function today_appointments()
return view('reports.today_appointment', compact('all_today_appointments', 'all_partners'));
}
-
+
public function consented_report()
{
$all_partners = Partner::where('status', '=', 'Active')
- ->pluck('name', 'id');
+ ->pluck('name', 'id');
if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
$consented_clients = Client::join('tbl_groups', 'tbl_groups.id', 'tbl_client.group_id')
- ->select('tbl_client.clinic_number', 'tbl_client.file_no', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as full_name"), 'tbl_client.phone_no', 'tbl_client.dob', 'tbl_client.client_status', 'tbl_groups.name', 'tbl_client.created_at', 'tbl_client.smsenable', 'tbl_client.enrollment_date', 'tbl_client.art_date', 'tbl_client.updated_at', 'tbl_client.status', 'tbl_client.consent_date')
+ ->select('tbl_client.clinic_number', 'tbl_client.file_no', 'tbl_client.f_name', 'tbl_client.m_name', 'tbl_client.l_name', 'tbl_client.phone_no', 'tbl_client.dob', 'tbl_client.client_status', 'tbl_groups.name', 'tbl_client.created_at', 'tbl_client.smsenable', 'tbl_client.enrollment_date', 'tbl_client.art_date', 'tbl_client.updated_at', 'tbl_client.status', 'tbl_client.consent_date')
->where('tbl_client.smsenable', '=', 'Yes')
- ->get();
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
+ ->paginate(1000);
}
if (Auth::user()->access_level == 'Facility') {
$consented_clients = Client::join('tbl_groups', 'tbl_groups.id', 'tbl_client.group_id')
- ->select('tbl_client.clinic_number', 'tbl_client.file_no', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as full_name"), 'tbl_client.phone_no', 'tbl_client.dob', 'tbl_client.client_status', 'tbl_groups.name', 'tbl_client.created_at', 'tbl_client.smsenable', 'tbl_client.enrollment_date', 'tbl_client.art_date', 'tbl_client.updated_at', 'tbl_client.status', 'tbl_client.consent_date')
+ ->select('tbl_client.clinic_number', 'tbl_client.file_no', 'tbl_client.f_name', 'tbl_client.m_name', 'tbl_client.l_name', 'tbl_client.phone_no', 'tbl_client.dob', 'tbl_client.client_status', 'tbl_groups.name', 'tbl_client.created_at', 'tbl_client.smsenable', 'tbl_client.enrollment_date', 'tbl_client.art_date', 'tbl_client.updated_at', 'tbl_client.status', 'tbl_client.consent_date')
->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->get();
+ ->paginate(1000);
}
if (Auth::user()->access_level == 'Partner') {
$all_partners = Partner::where('status', '=', 'Active')
- ->pluck('name', 'id');
+ ->pluck('name', 'id');
$consented_clients = Client::join('tbl_groups', 'tbl_groups.id', 'tbl_client.group_id')
->select('tbl_client.clinic_number', 'tbl_client.file_no', 'tbl_client.f_name', 'tbl_client.m_name', 'tbl_client.l_name', 'tbl_client.phone_no', 'tbl_client.dob', 'tbl_client.client_status', 'tbl_groups.name', 'tbl_client.created_at', 'tbl_client.smsenable', 'tbl_client.enrollment_date', 'tbl_client.art_date', 'tbl_client.updated_at', 'tbl_client.status', 'tbl_client.consent_date')
->where('tbl_client.smsenable', '=', 'Yes')
+ ->where('tbl_client.status', '=', 'Active')
+ ->whereNull('tbl_client.hei_no')
->where('tbl_client.partner_id', Auth::user()->partner_id)
- ->get();
+ ->paginate(1000);
}
return view('reports.consented', compact('consented_clients', 'all_partners'));
@@ -165,79 +173,130 @@ public function consented_report()
public function tracing_outcome()
{
- $all_partners = Partner::where('status', '=', 'Active')
- ->pluck('name', 'id');
+ if (Auth::user()->access_level == 'Partner') {
+ $all_partners = Partner::where('status', '=', 'Active')->where('id', Auth::user()->partner_id)->pluck('name', 'id');
+ }
+ if (Auth::user()->access_level == 'Sub County') {
+ $all_partners = Partner::join('tbl_partner_facility', 'tbl_partner_facility.partner_id', '=', 'tbl_partner.id')->where('tbl_partner.status', '=', 'Active')->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)->pluck('tbl_partner.name', 'tbl_partner.id');
+ }
+ if (Auth::user()->access_level == 'County') {
+ $all_partners = Partner::join('tbl_partner_facility', 'tbl_partner_facility.partner_id', '=', 'tbl_partner.id')->where('tbl_partner.status', '=', 'Active')->where('tbl_partner_facility.county_id', Auth::user()->county_id)->pluck('tbl_partner.name', 'tbl_partner.id');
+ }
+ if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor' || Auth::user()->access_level == 'Facility') {
+ $all_partners = Partner::where('status', '=', 'Active')->orderBy('name', 'ASC')->pluck('name', 'id');
+ }
+ return view('reports.outcomeform', compact('all_partners'));
+ }
+
+ public function tracing_outcome_filter(Request $request)
+ {
+ // $selected_partners = $request->partners;
+ // $selected_counties = $request->counties;
+ // $selected_subcounties = $request->subcounties;
+ // $selected_facilites = $request->facilities;
+ $selected_from = $request->date_from;
+ $selected_to = $request->date_to;
+ //$outcome_report = OutcomeReport::select('*')->get();
if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
- $outcome_report = OutcomeReport::select(
- 'UPN',
- 'Age',
- 'Facility',
- 'Gender',
- 'Sub_County',
- 'File_Number',
- 'Appointment_Date',
- 'Date_Came',
- 'Tracer',
- 'Days_Defaulted',
- 'Tracing_Date',
- 'Outcome',
- 'Final_Outcome',
- 'Other_Outcome'
- )
+ $outcome_report = OutcomeReport::select('*')
+ ->where('Appointment_Date', '>=', date($request->date_from))
+ ->where('Appointment_Date', '<=', date($request->date_to))
->get();
+ $all_partners = Partner::where('status', '=', 'Active')->orderBy('name', 'ASC')->pluck('name', 'id');
}
- if (Auth::user()->access_level == 'Facility') {
- $outcome_report = OutcomeReport::select(
- 'UPN',
- 'Age',
- 'Facility',
- 'Gender',
- 'Sub_County',
- 'File_Number',
- 'Appointment_Date',
- 'Date_Came',
- 'Tracer',
- 'Days_Defaulted',
- 'Tracing_Date',
- 'Outcome',
- 'Final_Outcome',
- 'Other_Outcome'
- )
- ->where('MFL', Auth::user()->facility_id)
+ if (Auth::user()->access_level == 'Partner') {
+
+ $outcome_report = OutcomeReport::select('*')->where('partner_id', Auth::user()->partner_id)
+ ->where('Appointment_Date', '>=', date($request->date_from))
+ ->where('Appointment_Date', '<=', date($request->date_to))
->get();
+ $all_partners = Partner::where('status', '=', 'Active')->where('id', Auth::user()->partner_id)->pluck('name', 'id');
}
+ if (Auth::user()->access_level == 'Sub County') {
- if (Auth::user()->access_level == 'Partner') {
- $outcome_report = OutcomeReport::select(
- 'UPN',
- 'Age',
- 'Facility',
- 'Gender',
- 'Sub_County',
- 'File_Number',
- 'Appointment_Date',
- 'Date_Came',
- 'Tracer',
- 'Days_Defaulted',
- 'Tracing_Date',
- 'Outcome',
- 'Final_Outcome',
- 'Other_Outcome'
- )
- ->where('partner_id', Auth::user()->partner_id)
+ $outcome_report = OutcomeReport::select('*')->where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('Appointment_Date', '>=', date($request->date_from))
+ ->where('Appointment_Date', '<=', date($request->date_to))
->get();
+ $all_partners = Partner::where('status', '=', 'Active')->where('id', Auth::user()->partner_id)->pluck('name', 'id');
+ }
+ if (Auth::user()->access_level == 'Facility') {
+
+ $outcome_report = OutcomeReport::select('*')->where('mfl_code', Auth::user()->facility_id)
+ ->where('Appointment_Date', '>=', date($request->date_from))
+ ->where('Appointment_Date', '<=', date($request->date_to))
+ ->get();
+ $all_partners = Partner::where('status', '=', 'Active')->orderBy('name', 'ASC')->pluck('name', 'id');
+ }
+ // if (!empty($request->date_from)) {
+ // $outcome_report = $outcome_report->where('Appointment_Date', '>=', date($request->date_from));
+ // }
+ // if (!empty($request->date_to)) {
+ // $outcome_report = $outcome_report->where('Appointment_Date', '<=', date($request->date_to));
+ // }
+ if (!empty($request->partners)) {
+ $outcome_report = $outcome_report->where('partner_id', '=', $request->partners);
+ }
+ if (!empty($request->counties)) {
+ $outcome_report = $outcome_report->where('county_id', $request->counties);
+ }
+ if (!empty($request->subcounties)) {
+ $outcome_report = $outcome_report->where('sub_county_id', $request->subcounties);
+ }
+ if (!empty($request->facilities)) {
+ $outcome_report = $outcome_report->where('MFL', $request->facilities);
}
+ // $outcome_report = $outcome_report->orderBy('created_at', 'DESC');
- return view('reports.outcome', compact('outcome_report', 'all_partners'));
+ // dd($outcome_report);
+ return view('reports.outcome', compact('outcome_report', 'all_partners', 'selected_from', 'selected_to'));
}
public function messages_extract_report()
{
if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
$all_partners = Partner::where('status', '=', 'Active')
- ->pluck('name', 'id');
+ ->pluck('name', 'id');
+
+ // $message_extract = Client::chunk(100, function ($message_extract) {
+ // foreach ($message_extract as $message_extracts) {
+ // $message_extract = Client::JOIN('tbl_groups', 'tbl_groups.id', 'tbl_client.group_id')
+ // ->JOIN('tbl_master_facility', `tbl_master_facility` . `code`, `tbl_partner_facility` . `mfl_code`)
+ // ->JOIN('tbl_gender', `tbl_gender` . `id`, `tbl_client` . `gender`)
+ // ->JOIN('tbl_partner_facility', `tbl_partner_facility` . `mfl_code`, `tbl_client` . `mfl_code`)
+ // ->JOIN('tbl_marital_status', `tbl_marital_status` . `id`, `tbl_client` . `marital`)
+ // ->JOIN('tbl_partner', `tbl_partner` . `id`, `tbl_partner_facility` . `partner_id`)
+ // // ->JOIN('tbl_time`, `tbl_time' . `id`, `tbl_client` . `txt_time`)
+ // ->JOIN('tbl_language', `tbl_language` . `id`, `tbl_client` . `language_id`)
+ // ->JOIN('tbl_clnt_outgoing', `tbl_clnt_outgoing` . `clnt_usr_id`, `tbl_client` . `id`)
+ // ->JOIN('tbl_message_types', `tbl_message_types` . `id`, `tbl_clnt_outgoing` . `message_type_id`)
+ // ->JOIN('tbl_county', `tbl_county` . `id`, `tbl_partner_facility` . `county_id`)
+ // ->JOIN('tbl_sub_county', `tbl_sub_county` . `id`, `tbl_partner_facility` . `sub_county_id`)
+ // ->select(
+ // 'tbl_client.clinic_number as clinic_number',
+ // 'tbl_client.mfl_code as mfl_code',
+ // 'tbl_master_facility.name as facility_name',
+ // 'tbl_gender.name as gender',
+ // 'tbl_groups.name as group_name',
+ // 'tbl_marital_status.marital as marital',
+ // 'tbl_partner_facility.partner_id as partner_id',
+ // 'tbl_partner.name as partner_name',
+ // 'tbl_client.created_at as created_at',
+ // DB::raw("date_format( `tbl_client`.`created_at`, '%M %Y' ) as month_year"),
+ // // '(date_format( `tbl_client`.`created_at`, '%M %Y' ) AS month_year)',
+ // 'tbl_language.name as language',
+ // 'tbl_message_types.name as message_type',
+ // 'tbl_clnt_outgoing.msg as msg',
+ // 'tbl_client.language_id as language_id',
+ // 'tbl_client.txt_time as preferred_time',
+ // 'tbl_county.name as county',
+ // 'tbl_sub_county.name as sub_county',
+ // 'tbl_sub_county.id as sub_county_id'
+ // )->get();
+ // }
+ // });
$message_extract = MessageExtract::select(
'clinic_number',
@@ -254,10 +313,11 @@ public function messages_extract_report()
'sub_county',
'mfl_code',
'facility_name'
- )
- ->get();
+ )->get();
}
if (Auth::user()->access_level == 'Facility') {
+ $all_partners = Partner::where('status', '=', 'Active')
+ ->pluck('name', 'id');
$message_extract = MessageExtract::select(
'clinic_number',
'gender',
@@ -279,8 +339,8 @@ public function messages_extract_report()
}
if (Auth::user()->access_level == 'Partner') {
$all_partners = Partner::where('status', '=', 'Active')
- ->where('id', Auth::user()->partner_id)
- ->pluck('name', 'id');
+ ->where('id', Auth::user()->partner_id)
+ ->pluck('name', 'id');
$message_extract = MessageExtract::select(
'clinic_number',
@@ -329,8 +389,8 @@ public function client_report()
if (Auth::user()->access_level == 'Partner') {
$all_partners = Partner::where('status', '=', 'Active')
- ->where('id', Auth::user()->partner_id)
- ->pluck('name', 'id');
+ ->where('id', Auth::user()->partner_id)
+ ->pluck('name', 'id');
$client_summary = Summary::all()
->where('partner_id', Auth::user()->partner_id);
}
@@ -354,8 +414,8 @@ public function monthly_appointments()
if (Auth::user()->access_level == 'Partner') {
$all_partners = Partner::where('status', '=', 'Active')
- ->where('id', Auth::user()->partner_id)
- ->pluck('name', 'id');
+ ->where('id', Auth::user()->partner_id)
+ ->pluck('name', 'id');
$monthly_app_summary = MonthlyApp::all()
->where('partner_id', Auth::user()->partner_id);
}
@@ -363,4 +423,26 @@ public function monthly_appointments()
return view('reports.monthly_appointment', compact('monthly_app_summary', 'all_partners'));
}
+
+ public function dsd_clients()
+ {
+ if (Auth::user()->access_level == 'Facility') {
+ $all_dsd_clients = Dcm::select('*')->groupBy('clinic_number')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->where('stability_status', '=', 'DCM')
+ ->get();
+ }
+ if (Auth::user()->access_level == 'Partner') {
+ $all_dsd_clients = Dcm::select('*')->groupBy('clinic_number')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->where('stability_status', '=', 'DCM')
+ ->paginate(10000);
+ }
+ if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+ $all_dsd_clients = Dcm::select('*')->groupBy('clinic_number')
+ ->where('stability_status', '=', 'DCM')
+ ->paginate(10000);
+ }
+ return view('reports.dcm_reports', compact('all_dsd_clients'));
+ }
}
diff --git a/app/Http/Controllers/SMSReportController.php b/app/Http/Controllers/SMSReportController.php
new file mode 100644
index 0000000..f901ed4
--- /dev/null
+++ b/app/Http/Controllers/SMSReportController.php
@@ -0,0 +1,537 @@
+pluck('name', 'id');
+ return view('sms.sms_report', compact('all_partners'));
+ }
+
+ 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_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')
+ // ->groupBy(DB::raw("DATE_FORMAT(tbl_clnt_outgoing.created_at, '%m-%Y')"))
+ ->get();
+ // dd($delivered_partners);
+ $failed_partners = ClientOutgoing::join('tbl_client', 'tbl_clnt_outgoing.clnt_usr_id', '=', 'tbl_client.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_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();
+
+ $cost_counties = ClientOutgoing::join('tbl_client', 'tbl_clnt_outgoing.clnt_usr_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->join('tbl_county', 'tbl_partner_facility.county_id', '=', 'tbl_county.id')
+ ->select('tbl_county.name', DB::raw("ROUND(SUM(SUBSTRING(tbl_clnt_outgoing.cost, 5)), 0) as total_cost"))
+ ->groupBy('tbl_county.name')
+ ->get();
+
+ //dd($cost_counties);
+
+ $success = ClientOutgoing::select("callback_status")
+ ->where('callback_status', '=', 'Success')
+ ->count();
+
+
+ $failed_blacklist = ClientOutgoing::select('callback_status')
+ ->where('callback_status', '=', 'Failed')
+ ->where('failure_reason', '=', 'UserInBlacklist')
+ ->count();
+ $failed_absent = ClientOutgoing::select('callback_status')
+ ->where('callback_status', '=', 'Failed')
+ ->where('failure_reason', '=', 'AbsentSubscriber')
+ ->count();
+
+ $failed_inactive = ClientOutgoing::select('callback_status')
+ ->where('callback_status', '=', 'Failed')
+ ->where('failure_reason', '=', 'UserInactive')
+ ->count();
+
+ $failed_deliveryfailure = ClientOutgoing::select('callback_status')
+ ->where('callback_status', '=', 'Failed')
+ ->where('failure_reason', '=', 'DeliveryFailure')
+ ->count();
+
+ // $rejected_blacklist = ClientOutgoing::select('callback_status')
+ // ->where('callback_status', '=', 'Rejected')
+ // ->where('failure_reason', '=', 'UserInBlacklist')
+ // ->count();
+
+ // $rejected_inactive = ClientOutgoing::select('callback_status')
+ // ->where('callback_status', '=', 'Rejected')
+ // ->where('failure_reason', '=', 'UserInactive')
+ // ->count();
+
+ // $rejected_deliveryfailure = ClientOutgoing::select('callback_status')
+ // ->where('callback_status', '=', 'Rejected')
+ // ->where('failure_reason', '=', 'DeliveryFailure')
+ // ->count();
+
+ // cost calculation for all the status
+ $success_cost = ClientOutgoing::select(\DB::raw("ROUND(SUM(SUBSTRING(cost, 5)), 0) as total_cost"))
+ ->where('callback_status', '=', 'Success')
+ ->pluck('total_cost');
+ $failed_blacklist_cost = ClientOutgoing::select(\DB::raw("ROUND(SUM(SUBSTRING(cost, 5)), 0) as total_cost"))
+ ->where('callback_status', '=', 'Failed')
+ ->where('failure_reason', '=', 'UserInBlacklist')
+ ->pluck('total_cost');
+ $failed_absent_cost = ClientOutgoing::select(\DB::raw("ROUND(SUM(SUBSTRING(cost, 5)), 0) as total_cost"))
+ ->where('callback_status', '=', 'Failed')
+ ->where('failure_reason', '=', 'AbsentSubscriber')
+ ->pluck('total_cost');
+ $failed_inactive_cost = ClientOutgoing::select(\DB::raw("ROUND(SUM(SUBSTRING(cost, 5)), 0) as total_cost"))
+ ->where('callback_status', '=', 'Failed')
+ ->where('failure_reason', '=', 'UserInactive')
+ ->pluck('total_cost');
+ $failed_deliveryfailure_cost = ClientOutgoing::select(\DB::raw("ROUND(SUM(SUBSTRING(cost, 5)), 0) as total_cost"))
+ ->where('callback_status', '=', 'Failed')
+ ->where('failure_reason', '=', 'DeliveryFailure')
+ ->pluck('total_cost');
+
+ // $rejected_blacklist_cost = ClientOutgoing::select(\DB::raw("ROUND(SUM(SUBSTRING(cost, 5)), 0) as total_cost"))
+ // ->where('callback_status', '=', 'Rejected')
+ // ->where('failure_reason', '=', 'UserInBlacklist')
+ // ->pluck('total_cost');
+ // $rejected_inactive_cost = ClientOutgoing::select(\DB::raw("ROUND(SUM(SUBSTRING(cost, 5)), 0) as total_cost"))
+ // ->where('callback_status', '=', 'Rejected')
+ // ->where('failure_reason', '=', 'UserInactive')
+ // ->pluck('total_cost');
+ // $rejected_deliveryfailure_cost = ClientOutgoing::select(\DB::raw("ROUND(SUM(SUBSTRING(cost, 5)), 0) as total_cost"))
+ // ->where('callback_status', '=', 'Rejected')
+ // ->where('failure_reason', '=', 'DeliveryFailure')
+ // ->pluck('total_cost');
+
+// $rejected_blacklist_cost = ClientOutgoing::select(\DB::raw("ROUND(SUM(SUBSTRING(cost, 5)), 0) as total_cost"))
+// ->where('callback_status', '=', 'Rejected')
+// ->where('failure_reason', '=', 'UserInBlacklist')
+// ->pluck('total_cost');
+// $rejected_inactive_cost = ClientOutgoing::select(\DB::raw("ROUND(SUM(SUBSTRING(cost, 5)), 0) as total_cost"))
+// ->where('callback_status', '=', 'Rejected')
+// ->where('failure_reason', '=', 'UserInactive')
+// ->pluck('total_cost');
+// $rejected_deliveryfailure_cost = ClientOutgoing::select(\DB::raw("ROUND(SUM(SUBSTRING(cost, 5)), 0) as total_cost"))
+// ->where('callback_status', '=', 'Rejected')
+// ->where('failure_reason', '=', 'DeliveryFailure')
+// ->pluck('total_cost');
+ $total_cost = ClientOutgoing::select(\DB::raw("ROUND(SUM(SUBSTRING(cost, 5)), 0) as total_cost"))
+ ->whereNotNull('callback_status')
+ ->pluck('total_cost');
+
+
+ $all_partners = Partner::where('status', '=', 'Active')
+ ->pluck('name', 'id');
+
+ return view('sms.sms_report', compact(
+ 'success',
+ 'all_partners',
+ 'failed_blacklist',
+ 'failed_absent',
+ 'failed_inactive',
+ 'failed_deliveryfailure',
+ 'success_cost',
+ 'failed_blacklist_cost',
+ 'failed_absent_cost',
+ 'failed_inactive_cost',
+ 'failed_deliveryfailure_cost',
+ 'delivered_partners',
+ 'failed_partners',
+ 'cost_partners',
+ 'cost_counties',
+ 'total_cost'
+ ));
+ }
+
+ public function filter_sms(Request $request)
+ {
+ $data = [];
+
+ $selected_partners = $request->partners;
+ $selected_counties = $request->counties;
+ $selected_subcounties = $request->subcounties;
+ $selected_facilites = $request->facilities;
+
+ $success = ClientOutgoing::join('tbl_client', 'tbl_clnt_outgoing.clnt_usr_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("COUNT(tbl_clnt_outgoing.status)"))
+ ->whereDate('tbl_clnt_outgoing.updated_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.updated_at', '<=', date($request->to))
+ ->where('tbl_clnt_outgoing.callback_status', '=', 'Success');
+
+ $failed_blacklist = ClientOutgoing::join('tbl_client', 'tbl_clnt_outgoing.clnt_usr_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_clnt_outgoing.status')
+ ->where('tbl_clnt_outgoing.callback_status', '=', 'Failed')
+ ->whereDate('tbl_clnt_outgoing.updated_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.updated_at', '<=', date($request->to))
+ ->where('tbl_clnt_outgoing.failure_reason', '=', 'UserInBlacklist');
+
+ $failed_absent = ClientOutgoing::join('tbl_client', 'tbl_clnt_outgoing.clnt_usr_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_clnt_outgoing.status')
+ ->where('tbl_clnt_outgoing.callback_status', '=', 'Failed')
+ ->whereDate('tbl_clnt_outgoing.updated_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.updated_at', '<=', date($request->to))
+ ->where('tbl_clnt_outgoing.failure_reason', '=', 'AbsentSubscriber');
+
+ $failed_inactive = ClientOutgoing::join('tbl_client', 'tbl_clnt_outgoing.clnt_usr_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_clnt_outgoing.status')
+ ->where('tbl_clnt_outgoing.callback_status', '=', 'Failed')
+ ->whereDate('tbl_clnt_outgoing.updated_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.updated_at', '<=', date($request->to))
+ ->where('tbl_clnt_outgoing.failure_reason', '=', 'UserInactive');
+
+ $failed_deliveryfailure = ClientOutgoing::join('tbl_client', 'tbl_clnt_outgoing.clnt_usr_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select('tbl_clnt_outgoing.status')
+ ->where('tbl_clnt_outgoing.callback_status', '=', 'Failed')
+ ->whereDate('tbl_clnt_outgoing.updated_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.updated_at', '<=', date($request->to))
+ ->where('tbl_clnt_outgoing.failure_reason', '=', 'DeliveryFailure');
+
+ // $rejected_blacklist = ClientOutgoing::join('tbl_client', 'tbl_clnt_outgoing.clnt_usr_id', '=', 'tbl_client.id')
+ // ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ // ->select('tbl_clnt_outgoing.status')
+ // ->where('tbl_clnt_outgoing.callback_status', '=', 'Rejected')
+ // ->whereDate('tbl_clnt_outgoing.updated_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.updated_at', '<=', date($request->to))
+ // ->where('tbl_clnt_outgoing.failure_reason', '=', 'UserInBlacklist');
+
+ // $rejected_inactive = ClientOutgoing::join('tbl_client', 'tbl_clnt_outgoing.clnt_usr_id', '=', 'tbl_client.id')
+ // ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ // ->select('tbl_clnt_outgoing.status')
+ // ->where('tbl_clnt_outgoing.callback_status', '=', 'Rejected')
+ // ->whereDate('tbl_clnt_outgoing.updated_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.updated_at', '<=', date($request->to))
+ // ->where('tbl_clnt_outgoing.failure_reason', '=', 'UserInactive');
+
+ // $rejected_deliveryfailure = ClientOutgoing::join('tbl_client', 'tbl_clnt_outgoing.clnt_usr_id', '=', 'tbl_client.id')
+ // ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ // ->select('tbl_clnt_outgoing.status')
+ // ->where('tbl_clnt_outgoing.callback_status', '=', 'Rejected')
+ // ->whereDate('tbl_clnt_outgoing.updated_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.updated_at', '<=', date($request->to))
+ // ->where('tbl_clnt_outgoing.failure_reason', '=', 'DeliveryFailure');
+
+ // cost calculation for all the status
+ $success_cost = ClientOutgoing::join('tbl_client', 'tbl_clnt_outgoing.clnt_usr_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("ROUND(SUM(SUBSTRING(tbl_clnt_outgoing.cost, 5)), 2) as total_cost"))
+ ->where('tbl_clnt_outgoing.callback_status', '=', 'Success')
+ ->whereDate('tbl_clnt_outgoing.updated_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.updated_at', '<=', date($request->to))
+ ->pluck('total_cost');
+ $failed_blacklist_cost = ClientOutgoing::join('tbl_client', 'tbl_clnt_outgoing.clnt_usr_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("ROUND(SUM(SUBSTRING(tbl_clnt_outgoing.cost, 5)), 2) as total_cost"))
+ ->where('tbl_clnt_outgoing.callback_status', '=', 'Failed')
+ ->where('tbl_clnt_outgoing.failure_reason', '=', 'UserInBlacklist')
+ ->whereDate('tbl_clnt_outgoing.updated_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.updated_at', '<=', date($request->to))
+ ->pluck('total_cost');
+ $failed_absent_cost = ClientOutgoing::join('tbl_client', 'tbl_clnt_outgoing.clnt_usr_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("ROUND(SUM(SUBSTRING(tbl_clnt_outgoing.cost, 5)), 2) as total_cost"))
+ ->where('tbl_clnt_outgoing.callback_status', '=', 'Failed')
+ ->where('tbl_clnt_outgoing.failure_reason', '=', 'AbsentSubscriber')
+ ->whereDate('tbl_clnt_outgoing.updated_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.updated_at', '<=', date($request->to))
+ ->pluck('total_cost');
+ $failed_inactive_cost = ClientOutgoing::join('tbl_client', 'tbl_clnt_outgoing.clnt_usr_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("ROUND(SUM(SUBSTRING(tbl_clnt_outgoing.cost, 5)), 2) as total_cost"))
+ ->where('tbl_clnt_outgoing.callback_status', '=', 'Failed')
+ ->where('tbl_clnt_outgoing.failure_reason', '=', 'UserInactive')
+ ->whereDate('tbl_clnt_outgoing.updated_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.updated_at', '<=', date($request->to))
+ ->pluck('total_cost');
+ $failed_deliveryfailure_cost = ClientOutgoing::join('tbl_client', 'tbl_clnt_outgoing.clnt_usr_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(\DB::raw("ROUND(SUM(SUBSTRING(tbl_clnt_outgoing.cost, 5)), 2) as total_cost"))
+ ->where('tbl_clnt_outgoing.callback_status', '=', 'Failed')
+ ->where('tbl_clnt_outgoing.failure_reason', '=', 'DeliveryFailure')
+ ->whereDate('tbl_clnt_outgoing.updated_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.updated_at', '<=', date($request->to))
+ ->pluck('total_cost');
+ // $rejected_blacklist_cost = ClientOutgoing::join('tbl_client', 'tbl_clnt_outgoing.clnt_usr_id', '=', 'tbl_client.id')
+ // ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ // ->select(\DB::raw("ROUND(SUM(SUBSTRING(tbl_clnt_outgoing.cost, 5)), 2) as total_cost"))
+ // ->where('tbl_clnt_outgoing.callback_status', '=', 'Rejected')
+ // ->where('tbl_clnt_outgoing.failure_reason', '=', 'UserInBlacklist')
+ // ->whereDate('tbl_clnt_outgoing.updated_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.updated_at', '<=', date($request->to))
+ // ->pluck('total_cost');
+ // $rejected_inactive_cost = ClientOutgoing::join('tbl_client', 'tbl_clnt_outgoing.clnt_usr_id', '=', 'tbl_client.id')
+ // ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ // ->select(\DB::raw("ROUND(SUM(SUBSTRING(tbl_clnt_outgoing.cost, 5)), 2) as total_cost"))
+ // ->where('tbl_clnt_outgoing.callback_status', '=', 'Rejected')
+ // ->where('tbl_clnt_outgoing.failure_reason', '=', 'UserInactive')
+ // ->whereDate('tbl_clnt_outgoing.updated_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.updated_at', '<=', date($request->to))
+ // ->pluck('total_cost');
+ // $rejected_deliveryfailure_cost = ClientOutgoing::join('tbl_client', 'tbl_clnt_outgoing.clnt_usr_id', '=', 'tbl_client.id')
+ // ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ // ->select(\DB::raw("ROUND(SUM(SUBSTRING(tbl_clnt_outgoing.cost, 5)), 2) as total_cost"))
+ // ->where('tbl_clnt_outgoing.callback_status', '=', 'Rejected')
+ // ->where('tbl_clnt_outgoing.failure_reason', '=', 'DeliveryFailure')
+ // ->whereDate('tbl_clnt_outgoing.updated_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.updated_at', '<=', date($request->to))
+ // ->pluck('total_cost');
+
+ if (!empty($selected_partners)) {
+ $success = $success->where('tbl_partner_facility.partner_id', $selected_partners);
+ $failed_blacklist = $failed_blacklist->where('tbl_partner_facility.partner_id', $selected_partners);
+ $failed_inactive = $failed_inactive->where('tbl_partner_facility.partner_id', $selected_partners);
+ $failed_deliveryfailure = $failed_deliveryfailure->where('tbl_partner_facility.partner_id', $selected_partners);
+ // $rejected_blacklist = $rejected_blacklist->where('tbl_partner_facility.partner_id', $selected_partners);
+ // $rejected_inactive = $rejected_inactive->where('tbl_partner_facility.partner_id', $selected_partners);
+ // $rejected_deliveryfailure = $rejected_deliveryfailure->where('tbl_partner_facility.partner_id', $selected_partners);
+ $success_cost = $success_cost->where('tbl_partner_facility.partner_id', $selected_partners);
+ $failed_blacklist_cost = $failed_blacklist_cost->where('tbl_partner_facility.partner_id', $selected_partners);
+ $failed_inactive_cost = $failed_inactive_cost->where('tbl_partner_facility.partner_id', $selected_partners);
+ $failed_deliveryfailure_cost = $failed_deliveryfailure_cost->where('tbl_partner_facility.partner_id', $selected_partners);
+ // $rejected_blacklist_cost = $rejected_blacklist_cost->where('tbl_partner_facility.partner_id', $selected_partners);
+ // $rejected_inactive_cost = $rejected_inactive_cost->where('tbl_partner_facility.partner_id', $selected_partners);
+ // $rejected_deliveryfailure_cost = $rejected_deliveryfailure_cost->where('tbl_partner_facility.partner_id', $selected_partners);
+ }
+ if (!empty($selected_counties)) {
+ $success = $success->where('tbl_partner_facility.county_id', $selected_counties);
+ $failed_blacklist = $failed_blacklist->where('tbl_partner_facility.county_id', $selected_counties);
+ $failed_inactive = $failed_inactive->where('tbl_partner_facility.county_id', $selected_counties);
+ $failed_deliveryfailure = $failed_deliveryfailure->where('tbl_partner_facility.county_id', $selected_counties);
+ // $rejected_blacklist = $rejected_blacklist->where('tbl_partner_facility.county_id', $selected_counties);
+ // $rejected_inactive = $rejected_inactive->where('tbl_partner_facility.county_id', $selected_counties);
+ // $rejected_deliveryfailure = $rejected_deliveryfailure->where('tbl_partner_facility.county_id', $selected_counties);
+ $success_cost = $success_cost->where('tbl_partner_facility.county_id', $selected_counties);
+ $failed_blacklist_cost = $failed_blacklist_cost->where('tbl_partner_facility.county_id', $selected_counties);
+ $failed_inactive_cost = $failed_inactive_cost->where('tbl_partner_facility.county_id', $selected_counties);
+ $failed_deliveryfailure_cost = $failed_deliveryfailure_cost->where('tbl_partner_facility.county_id', $selected_counties);
+ // $rejected_blacklist_cost = $rejected_blacklist_cost->where('tbl_partner_facility.county_id', $selected_counties);
+ // $rejected_inactive_cost = $rejected_inactive_cost->where('tbl_partner_facility.county_id', $selected_counties);
+ // $rejected_deliveryfailure_cost = $rejected_deliveryfailure_cost->where('tbl_partner_facility.county_id', $selected_counties);
+ }
+ if (!empty($selected_subcounties)) {
+ $success = $success->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $failed_blacklist = $failed_blacklist->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $failed_inactive = $failed_inactive->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $failed_deliveryfailure = $failed_deliveryfailure->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ // $rejected_blacklist = $rejected_blacklist->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ // $rejected_inactive = $rejected_inactive->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ // $rejected_deliveryfailure = $rejected_deliveryfailure->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $success_cost = $success_cost->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $failed_blacklist_cost = $failed_blacklist_cost->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $failed_inactive_cost = $failed_inactive_cost->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ $failed_deliveryfailure_cost = $failed_deliveryfailure_cost->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ // $rejected_blacklist_cost = $rejected_blacklist_cost->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ // $rejected_inactive_cost = $rejected_inactive_cost->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ // $rejected_deliveryfailure_cost = $rejected_deliveryfailure_cost->where('tbl_partner_facility.sub_county_id', $selected_subcounties);
+ }
+ if (!empty($selected_facilites)) {
+ $success = $success->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $failed_blacklist = $failed_blacklist->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $failed_inactive = $failed_inactive->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $failed_deliveryfailure = $failed_deliveryfailure->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ // $rejected_blacklist = $rejected_blacklist->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ // $rejected_inactive = $rejected_inactive->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ // $rejected_deliveryfailure = $rejected_deliveryfailure->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $success_cost = $success_cost->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $failed_blacklist_cost = $failed_blacklist_cost->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $failed_inactive_cost = $failed_inactive_cost->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ $failed_deliveryfailure_cost = $failed_deliveryfailure_cost->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ // $rejected_blacklist_cost = $rejected_blacklist_cost->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ // $rejected_inactive_cost = $rejected_inactive_cost->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ // $rejected_deliveryfailure_cost = $rejected_deliveryfailure_cost->where('tbl_partner_facility.mfl_code', $selected_facilites);
+ }
+
+ $data["success"] = $success->count();
+ $data["failed_blacklist"] = $failed_blacklist->count();
+ $data["failed_inactive"] = $failed_inactive->count();
+ $data["failed_deliveryfailure"] = $failed_deliveryfailure->count();
+ // $data["rejected_blacklist"] = $rejected_blacklist->count();
+ // $data["rejected_inactive"] = $rejected_inactive->count();
+ // $data["rejected_deliveryfailure"] = $rejected_deliveryfailure->count();
+ $data["success_cost"] = $success_cost;
+ $data["failed_blacklist_cost"] = $failed_blacklist_cost;
+ $data["failed_inactive_cost"] = $failed_inactive_cost;
+ $data["failed_deliveryfailure_cost"] = $failed_deliveryfailure_cost;
+ // $data["rejected_blacklist_cost"] = $rejected_blacklist_cost;
+ // $data["rejected_inactive_cost"] = $rejected_inactive_cost;
+ // $data["rejected_deliveryfailure_cost"] = $rejected_deliveryfailure_cost;
+
+ return $data;
+ }
+
+ public function filtering_sms(Request $request)
+ {
+ $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')
+ ->select('tbl_partner.name', DB::raw('count(tbl_clnt_outgoing.callback_status) as total'))
+ ->where('tbl_clnt_outgoing.callback_status', '=', 'Success')
+ ->whereDate('tbl_clnt_outgoing.created_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.created_at', '<=', date($request->to))
+ ->groupBy('tbl_partner.name')
+ // ->groupBy(DB::raw("DATE_FORMAT(tbl_clnt_outgoing.created_at, '%m-%Y')"))
+ ->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')
+ ->select('tbl_partner.name', DB::raw('count(tbl_clnt_outgoing.callback_status) as total'))
+ ->where('tbl_clnt_outgoing.callback_status', '=', 'Failed')
+ ->whereDate('tbl_clnt_outgoing.created_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.created_at', '<=', date($request->to))
+ ->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')
+ ->select('tbl_partner.name', DB::raw("ROUND(SUM(SUBSTRING(tbl_clnt_outgoing.cost, 5)), 0) as total_cost"))
+ ->whereDate('tbl_clnt_outgoing.created_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.created_at', '<=', date($request->to))
+ ->groupBy('tbl_partner.name')
+ ->get();
+
+ $cost_counties = ClientOutgoing::join('tbl_client', 'tbl_clnt_outgoing.clnt_usr_id', '=', 'tbl_client.id')
+ ->join('tbl_partner_facility', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->join('tbl_county', 'tbl_partner_facility.county_id', '=', 'tbl_county.id')
+ ->select('tbl_county.name', DB::raw("ROUND(SUM(SUBSTRING(tbl_clnt_outgoing.cost, 5)), 0) as total_cost"))
+ ->whereDate('tbl_clnt_outgoing.created_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.created_at', '<=', date($request->to))
+ ->groupBy('tbl_county.name')
+ ->get();
+
+ //dd($cost_counties);
+
+ $success = ClientOutgoing::select("callback_status")
+ ->where('callback_status', '=', 'Success')
+ ->whereDate('tbl_clnt_outgoing.created_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.created_at', '<=', date($request->to))
+ ->count();
+
+
+ $failed_blacklist = ClientOutgoing::select('callback_status')
+ ->where('callback_status', '=', 'Failed')
+ ->where('failure_reason', '=', 'UserInBlacklist')
+ ->whereDate('tbl_clnt_outgoing.created_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.created_at', '<=', date($request->to))
+ ->count();
+ $failed_absent = ClientOutgoing::select('callback_status')
+ ->where('callback_status', '=', 'Failed')
+ ->where('failure_reason', '=', 'AbsentSubscriber')
+ ->whereDate('tbl_clnt_outgoing.created_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.created_at', '<=', date($request->to))
+ ->count();
+
+ $failed_inactive = ClientOutgoing::select('callback_status')
+ ->where('callback_status', '=', 'Failed')
+ ->where('failure_reason', '=', 'UserInactive')
+ ->whereDate('tbl_clnt_outgoing.created_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.created_at', '<=', date($request->to))
+ ->count();
+
+ $failed_deliveryfailure = ClientOutgoing::select('callback_status')
+ ->where('callback_status', '=', 'Failed')
+ ->where('failure_reason', '=', 'DeliveryFailure')
+ ->whereDate('tbl_clnt_outgoing.created_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.created_at', '<=', date($request->to))
+ ->count();
+
+ // $rejected_blacklist = ClientOutgoing::select('callback_status')
+ // ->where('callback_status', '=', 'Rejected')
+ // ->where('failure_reason', '=', 'UserInBlacklist')
+ // ->whereDate('tbl_clnt_outgoing.created_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.created_at', '<=', date($request->to))
+ // ->count();
+
+ // $rejected_inactive = ClientOutgoing::select('callback_status')
+ // ->where('callback_status', '=', 'Rejected')
+ // ->where('failure_reason', '=', 'UserInactive')
+ // ->whereDate('tbl_clnt_outgoing.created_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.created_at', '<=', date($request->to))
+ // ->count();
+
+ // $rejected_deliveryfailure = ClientOutgoing::select('callback_status')
+ // ->where('callback_status', '=', 'Rejected')
+ // ->where('failure_reason', '=', 'DeliveryFailure')
+ // ->whereDate('tbl_clnt_outgoing.created_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.created_at', '<=', date($request->to))
+ // ->count();
+
+ // cost calculation for all the status
+ $success_cost = ClientOutgoing::select(\DB::raw("ROUND(SUM(SUBSTRING(cost, 5)), 0) as total_cost"))
+ ->where('callback_status', '=', 'Success')
+ ->whereDate('tbl_clnt_outgoing.created_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.created_at', '<=', date($request->to))
+ ->pluck('total_cost');
+ $failed_blacklist_cost = ClientOutgoing::select(\DB::raw("ROUND(SUM(SUBSTRING(cost, 5)), 0) as total_cost"))
+ ->where('callback_status', '=', 'Failed')
+ ->where('failure_reason', '=', 'UserInBlacklist')
+ ->whereDate('tbl_clnt_outgoing.created_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.created_at', '<=', date($request->to))
+ ->pluck('total_cost');
+ $failed_absent_cost = ClientOutgoing::select(\DB::raw("ROUND(SUM(SUBSTRING(cost, 5)), 0) as total_cost"))
+ ->where('callback_status', '=', 'Failed')
+ ->where('failure_reason', '=', 'AbsentSubscriber')
+ ->whereDate('tbl_clnt_outgoing.created_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.created_at', '<=', date($request->to))
+ ->pluck('total_cost');
+ $failed_inactive_cost = ClientOutgoing::select(\DB::raw("ROUND(SUM(SUBSTRING(cost, 5)), 0) as total_cost"))
+ ->where('callback_status', '=', 'Failed')
+ ->where('failure_reason', '=', 'UserInactive')
+ ->whereDate('tbl_clnt_outgoing.created_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.created_at', '<=', date($request->to))
+ ->pluck('total_cost');
+ $failed_deliveryfailure_cost = ClientOutgoing::select(\DB::raw("ROUND(SUM(SUBSTRING(cost, 5)), 0) as total_cost"))
+ ->where('callback_status', '=', 'Failed')
+ ->where('failure_reason', '=', 'DeliveryFailure')
+ ->whereDate('tbl_clnt_outgoing.created_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.created_at', '<=', date($request->to))
+ ->pluck('total_cost');
+
+ // $rejected_blacklist_cost = ClientOutgoing::select(\DB::raw("ROUND(SUM(SUBSTRING(cost, 5)), 0) as total_cost"))
+ // ->where('callback_status', '=', 'Rejected')
+ // ->where('failure_reason', '=', 'UserInBlacklist')
+ // ->whereDate('tbl_clnt_outgoing.created_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.created_at', '<=', date($request->to))
+ // ->pluck('total_cost');
+ // $rejected_inactive_cost = ClientOutgoing::select(\DB::raw("ROUND(SUM(SUBSTRING(cost, 5)), 0) as total_cost"))
+ // ->where('callback_status', '=', 'Rejected')
+ // ->where('failure_reason', '=', 'UserInactive')
+ // ->whereDate('tbl_clnt_outgoing.created_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.created_at', '<=', date($request->to))
+ // ->pluck('total_cost');
+ // $rejected_deliveryfailure_cost = ClientOutgoing::select(\DB::raw("ROUND(SUM(SUBSTRING(cost, 5)), 0) as total_cost"))
+ // ->where('callback_status', '=', 'Rejected')
+ // ->where('failure_reason', '=', 'DeliveryFailure')
+ // ->whereDate('tbl_clnt_outgoing.created_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.created_at', '<=', date($request->to))
+ // ->pluck('total_cost');
+
+// $rejected_blacklist_cost = ClientOutgoing::select(\DB::raw("ROUND(SUM(SUBSTRING(cost, 5)), 0) as total_cost"))
+// ->where('callback_status', '=', 'Rejected')
+// ->where('failure_reason', '=', 'UserInBlacklist')
+// ->whereDate('tbl_clnt_outgoing.created_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.created_at', '<=', date($request->to))
+// ->pluck('total_cost');
+// $rejected_inactive_cost = ClientOutgoing::select(\DB::raw("ROUND(SUM(SUBSTRING(cost, 5)), 0) as total_cost"))
+// ->where('callback_status', '=', 'Rejected')
+// ->where('failure_reason', '=', 'UserInactive')
+// ->whereDate('tbl_clnt_outgoing.created_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.created_at', '<=', date($request->to))
+// ->pluck('total_cost');
+// $rejected_deliveryfailure_cost = ClientOutgoing::select(\DB::raw("ROUND(SUM(SUBSTRING(cost, 5)), 0) as total_cost"))
+// ->where('callback_status', '=', 'Rejected')
+// ->where('failure_reason', '=', 'DeliveryFailure')
+// ->whereDate('tbl_clnt_outgoing.created_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.created_at', '<=', date($request->to))
+// ->pluck('total_cost');
+ $total_cost = ClientOutgoing::select(\DB::raw("ROUND(SUM(SUBSTRING(cost, 5)), 0) as total_cost"))
+ ->whereNotNull('callback_status')
+ ->whereDate('tbl_clnt_outgoing.created_at', '>=', date($request->from))->whereDate('tbl_clnt_outgoing.created_at', '<=', date($request->to))
+ ->pluck('total_cost');
+
+
+ return view('sms.sms_report', compact(
+ 'success',
+ 'failed_blacklist',
+ 'failed_absent',
+ 'failed_inactive',
+ 'failed_deliveryfailure',
+ 'success_cost',
+ 'failed_blacklist_cost',
+ 'failed_absent_cost',
+ 'failed_inactive_cost',
+ 'failed_deliveryfailure_cost',
+ 'delivered_partners',
+ 'failed_partners',
+ 'cost_partners',
+ 'cost_counties',
+ 'total_cost'
+ ));
+ }
+}
diff --git a/app/Http/Controllers/ScheduleSMSController.php b/app/Http/Controllers/ScheduleSMSController.php
new file mode 100644
index 0000000..bca6297
--- /dev/null
+++ b/app/Http/Controllers/ScheduleSMSController.php
@@ -0,0 +1,643 @@
+current_date = date("Y-m-d");
+ }
+
+ public function wellnessScheduler()
+ {
+ try{
+ //get clients enrolled for the wellness sms as per filter
+ $clients = Wellness::all();
+
+ foreach ($clients as $client) {
+ $cleaned_msg ="";
+ $client_id = $client->client_id;
+ $language = $client->language_name;
+ $group_id = $client->group_id;
+ $language_id = $client->language_id;
+ $registration_date = $client->registration_date;
+ $time = $client->txt_time;
+ $daytime = $client->daytime;
+ $frequency = $client->txt_frequency;
+ $phone_no = $client->phone_no;
+ $wellness_enable = $client->wellness_enable;
+ $motivational_enable = $client->motivational_enable;
+
+ //Check if the phone number has country code appended
+ $mobile = substr($phone_no, -9);
+ $len = strlen($mobile);
+ if ($len < 10) {
+ $phone_no = "254" . $mobile;
+ }
+
+ //check if a wellness message is already sent. If not send it.
+ if (DB::table('tbl_clnt_outgoing')
+ ->where('message_type_id', 4)
+ ->where('clnt_usr_id', $client_id)
+ ->where(function ($query) {
+ $query->whereDate('created_at', $this->current_date)
+ ->orwhereDate('updated_at', $this->current_date);
+ })
+ ->doesntExist())
+ {
+ //get message content
+ $message_type_id = 4;
+ $msg_content = DB::table('tbl_content')
+ ->where('message_type_id', $message_type_id)
+ ->where('language_id', $language_id)
+ ->where('group_id', $group_id)
+ ->get()
+ ->take(1);
+
+ foreach($msg_content as $msg)
+ {
+ $content_id = $msg->id;
+ $cleaned_msg = $msg->message;
+ $today = date("Y-m-d H:i:s");
+ $status = "Not Sent";
+ $responded = "No";
+
+ if ($wellness_enable == 'Yes' && trim($cleaned_msg) != '') {
+ $source = 40149;
+ $clnt_outgoing = array(
+ 'destination' => $phone_no,
+ 'msg' => $cleaned_msg,
+ 'responded' => $responded,
+ 'status' => $status,
+ 'message_type_id' => $message_type_id,
+ 'source' => $source,
+ 'clnt_usr_id' => $client_id,
+ 'appointment_id' => null,
+ 'no_of_days' => null,
+ 'recepient_type' => 'Client',
+ 'content_id' => $content_id,
+ 'created_at' => $today,
+ 'created_by' => '1'
+ );
+
+ $this->sms_outgoing_insert($clnt_outgoing);
+ }
+
+ }
+
+
+ }
+ }
+ }catch (Exception $e) {
+ throw $e;
+ }
+ }
+
+ public function notifiedScheduler()
+ {
+ try{
+ //get one day and seven day appointments for sms notification
+ $notifications = AppointmentNotifications::all();
+
+ foreach($notifications as $notification)
+ {
+ $f_name = $notification->f_name;
+ $m_name = $notification->m_name;
+ $l_name = $notification->l_name;
+ $phone_no = $notification->phone_no;
+ $txt_time = $notification->txt_time;
+ $alt_phone_no = $notification->alt_phone_no;
+ $smsenable = $notification->smsenable;
+
+ $appointment_date = $notification->appntmnt_date;
+ $appointment_msg = $notification->app_msg;
+ $no_of_days = $notification->no_of_days;
+
+ $app_status = $notification->app_status;
+ $appointment_id = $notification->appointment_id;
+ $notified = $notification->notified;
+ $sent_status = $notification->sent_status;
+ $language_id = $notification->language_id;
+ $client_id = $notification->client_id;
+ $client_name = ucwords(strtolower($f_name)) . " ";
+ $client_name = str_replace("'", '', $client_name);
+
+ //check if a notification is already sent. If not send it.
+ if (DB::table('tbl_clnt_outgoing')
+ ->where('message_type_id', 1)
+ ->where('clnt_usr_id', $client_id)
+ ->where(function ($query) {
+ $query->whereDate('created_at', $this->current_date)
+ ->orwhereDate('updated_at', $this->current_date);
+ })
+ ->doesntExist())
+ {
+ //set the logic flow based on the number of days to appointment
+ $logic_flow_id = $no_of_days == 7 ? 2 : 3;
+
+ //get message content
+ $msg_content = DB::table('tbl_messages')
+ ->where('target_group', 'All')
+ ->where('message_type_id', 1)
+ ->where('logic_flow', $logic_flow_id)
+ ->where('language_id', $language_id)
+ ->get()
+ ->take(1);
+
+ foreach($msg_content as $msg)
+ {
+ $content_id = $msg->id;
+ $content = $msg->message;
+ $today = date("Y-m-d H:i:s");
+ $new_msg = str_replace("XXX", $client_name, $content);
+ $appointment_date = date("d-m-Y", strtotime($appointment_date));
+ $cleaned_msg = str_replace("YYY", $appointment_date, $new_msg);
+
+ $status = "Not Sent";
+ $responded = "No";
+ $yes_notified = 'Yes';
+ $app_status = "Notified";
+ $Notified_status = "Notified Sent";
+
+ $update_appointment_array = array(
+ 'appointment_id' => $appointment_id,
+ 'app_status' => $app_status,
+ 'app_msg' => $cleaned_msg,
+ 'notified' => $yes_notified,
+ 'sent_status' => $Notified_status,
+ 'updated_by' => '1'
+ );
+
+
+ // update the appointment details with the sms send status and sms message
+ $this->appointment_update($update_appointment_array);
+
+
+ if ($smsenable == 'Yes') //send the sms
+ {
+ $source = 40149;
+ $message_type_id = 1;
+ $clnt_outgoing = array(
+ 'destination' => $phone_no,
+ 'msg' => $cleaned_msg,
+ 'responded' => $responded,
+ 'status' => $status,
+ 'message_type_id' => $message_type_id,
+ 'source' => $source,
+ 'clnt_usr_id' => $client_id,
+ 'appointment_id' => $appointment_id,
+ 'no_of_days' => $no_of_days,
+ 'recepient_type' => 'Client',
+ 'content_id' => $content_id,
+ 'created_at' => $today,
+ 'created_by' => '1'
+ );
+
+ // if($appointment_id == 2783041){
+ // send the sms
+ $this->sms_outgoing_insert($clnt_outgoing);
+ // }
+ }
+ // dd($clnt_outgoing);
+
+ }
+
+ }
+ }
+ }catch (Exception $e) {
+ throw $e;
+ }
+ }
+
+ public function missedScheduler()
+ {
+ try{
+ //get notification flow info...
+ $update_appointment_array = array();
+ $notification_flow = DB::table('tbl_notification_flow')
+ ->where('status', 'Active')
+ ->where('notification_type', 'Missed')
+ ->get()
+ ->take(1);
+
+ foreach($notification_flow as $row)
+ {
+ $notification_type = $row->notification_type;
+ $notification_value = $row->value;
+ $notification_flow_id = $row->id;
+ $notification_flow_days = $row->days;
+ }
+
+ //get missed appointments
+ $notifications = MissedAppointmentNotifications::all();
+
+ foreach($notifications as $notification)
+ {
+ $cleaned_msg = '';
+ $group_name = $notification->group_name;
+ $group_id = $notification->group_id;
+ $f_name = $notification->f_name;
+ $m_name = $notification->m_name;
+ $l_name = $notification->l_name;
+ $phone_no = $notification->phone_no;
+ $txt_time = $notification->txt_time;
+ $alt_phone_no = $notification->alt_phone_no;
+ $smsenable = $notification->smsenable;
+ $no_of_days = $notification->no_of_days;
+
+ $appointment_date = $notification->appntmnt_date;
+ $appointment_msg = $notification->app_msg;
+ $app_status = $notification->app_status;
+ $appointment_id = $notification->appointment_id;
+ $notified = $notification->notified;
+ $sent_status = $notification->sent_status;
+ $language_id = $notification->language_id;
+ $client_id = $notification->client_id;
+ $client_name = ucwords(strtolower($f_name)) . " ";
+ $client_name = str_replace("'", '', $client_name);
+
+ $target_group = 'All';
+ $message_type_id = 1;
+ $logic_flow_id = 4;
+
+ //get message content
+ $get_content = DB::table('tbl_content')
+ ->where('identifier', $notification_flow_id)
+ ->where('message_type_id', 1)
+ ->where('group_id', $group_id)
+ ->where('language_id', $language_id)
+ ->get()
+ ->take(1);
+
+ if(empty($get_content)){
+
+ $status = "Not Sent";
+ $responded = "No";
+
+ $yes_notified = 'No';
+ $app_status = "Missed";
+ $missed_status = "Missed Updated";
+
+ $update_appointment_array= array(
+ 'appointment_id' => $appointment_id,
+ 'app_status' => $app_status,
+ 'app_msg' => "Message content not Found",
+ 'notified' => $yes_notified,
+ 'sent_status' => $missed_status,
+ 'updated_by' => '1'
+ );
+ }
+ else{
+ foreach ($get_content as $sms)
+ {
+ $missed = "Missed";
+ $content = $sms->content;
+
+ $content_id = $sms->id;
+ $message_type_id = $sms->message_type_id;
+ //Convert encoded character in the message to clients real name and appointment day XXX => Client Name YYY=> Appointment Date
+ $today = date("Y-m-d H:i:s");
+ $new_msg = str_replace("XXX", $client_name, $content);
+ $appointment_date = date("d-m-Y", strtotime($appointment_date));
+ $cleaned_msg = str_replace("YYY", $appointment_date, $new_msg);
+
+ $status = "Not Sent";
+ $responded = "No";
+ $yes_notified = 'Yes';
+ $app_status = "Missed";
+ $Missed_status = "Missed Sent";
+
+ $update_appointment_array= array(
+ 'appointment_id' => $appointment_id,
+ 'app_status' => $app_status,
+ 'app_msg' => $cleaned_msg,
+ 'notified' => $yes_notified,
+ 'sent_status' => $Missed_status,
+ 'updated_by' => '1'
+ );
+ }
+ }
+
+ // update the appointment details with the sms send status and sms message
+ if(!empty($update_appointment_array))
+ {
+ $this->appointment_update($update_appointment_array);
+
+ //check if a notification is already sent. If not send it.
+ if (DB::table('tbl_clnt_outgoing')
+ ->where('message_type_id', 1)
+ ->where('clnt_usr_id', $client_id)
+ ->where('destination', $phone_no)
+ ->whereDate('created_at', $this->current_date)
+ ->doesntExist())
+ {
+ if ($smsenable == 'Yes' && trim($cleaned_msg) != '') {
+ $source = 40149;
+ $outgoing = array(
+ 'destination' => $phone_no,
+ 'msg' => $cleaned_msg,
+ 'responded' => $responded,
+ 'status' => $status,
+ 'message_type_id' => $message_type_id,
+ 'source' => $source,
+ 'clnt_usr_id' => $client_id,
+ 'appointment_id' => $appointment_id,
+ 'no_of_days' => 0,
+ 'recepient_type' => 'Client',
+ 'content_id' => $content_id,
+ 'created_at' => $today,
+ 'created_by' => '1'
+ );
+
+ // if($appointment_id == 3009818){
+ // send the sms
+ $this->sms_outgoing_insert($outgoing);
+ // }
+
+ }
+ }
+ }
+
+ }
+ }catch (Exception $e) {
+ throw $e;
+ }
+
+ }
+
+ public function defaultedScheduler()
+ {
+ try{
+ //get notification flow info...
+ $notification_flow = DB::table('tbl_notification_flow')
+ ->where('status', 'Active')
+ ->where('notification_type', 'Defaulted')
+ ->get()
+ ->take(1);
+
+ foreach($notification_flow as $row)
+ {
+ $notification_type = $row->notification_type;
+ $notification_value = $row->value;
+ $notification_flow_id = $row->id;
+ $notification_flow_days = $row->days;
+ }
+
+ //defaulters for sms notification
+ $notifications = DefaulterNotifications::all();
+
+ foreach($notifications as $notification)
+ {
+ $f_name = $notification->f_name;
+ $m_name = $notification->m_name;
+ $l_name = $notification->l_name;
+ $phone_no = $notification->phone_no;
+ $txt_time = $notification->txt_time;
+ $alt_phone_no = $notification->alt_phone_no;
+ $smsenable = $notification->smsenable;
+
+ $appointment_date = $notification->appntmnt_date;
+ $appointment_msg = $notification->app_msg;
+ $app_status = $notification->app_status;
+ $appointment_id = $notification->appointment_id;
+ $notified = $notification->notified;
+ $sent_status = $notification->sent_status;
+ $language_id = $notification->language_id;
+ $client_id = $notification->client_id;
+ $group_id = $notification->group_id;
+ $client_name = ucwords(strtolower($f_name)) . " ";
+ $client_name = str_replace("'", '', $client_name);
+
+ $target_group = 'All';
+ $message_type_id = 1;
+ $today = date("Y-m-d H:i:s");
+
+ $status = "Not Sent";
+ $responded = "No";
+ $yes_notified = 'Yes';
+ $app_status = "Defaulted";
+ $Default_status = "Default Sent";
+
+ $update_appointment_array = array(
+ 'appointment_id' => $appointment_id,
+ 'app_status' => $app_status,
+ 'app_msg' => '',
+ 'notified' => $yes_notified,
+ 'sent_status' => $Default_status,
+ 'updated_by' => '1'
+ );
+
+ // update the appointment details with the sms send status and sms message
+ $this->appointment_update($update_appointment_array);
+
+
+ }
+ }catch (Exception $e) {
+ throw $e;
+ }
+
+ }
+
+ public function ltfuScheduler()
+ {
+ try{
+ //ltfu records for sms notification
+ $notifications = LTFUNotifications::all();
+
+ foreach($notifications as $notification)
+ {
+ $f_name = $notification->f_name;
+ $m_name = $notification->m_name;
+ $l_name = $notification->l_name;
+ $phone_no = $notification->phone_no;
+ $txt_time = $notification->txt_time;
+ $alt_phone_no = $notification->alt_phone_no;
+ $smsenable = $notification->smsenable;
+
+ $appointment_date = $notification->appntmnt_date;
+ $appointment_msg = $notification->app_msg;
+ $app_status = $notification->app_status;
+ $appointment_id = $notification->appointment_id;
+ $notified = $notification->notified;
+ $sent_status = $notification->sent_status;
+ $language_id = $notification->language_id;
+ $client_id = $notification->client_id;
+ $group_id = $notification->group_id;
+ $client_name = ucwords(strtolower($f_name)) . " ";
+ $client_name = str_replace("'", '', $client_name);
+
+ $update_appointment_array = array(
+ 'appointment_id' => $appointment_id,
+ 'app_status' => "LTFU",
+ 'app_msg' => '',
+ 'notified' => "No",
+ 'sent_status' => '',
+ 'updated_by' => '1'
+ );
+
+ // update the appointment details with the sms send status and sms message
+ $this->appointment_update($update_appointment_array);
+ }
+
+ }catch (Exception $e) {
+ throw $e;
+ }
+
+ }
+
+ public function sender()
+ {
+ try{
+ //get all outgoing smses
+ $messages = OutgoingSms::all();
+
+ foreach($messages as $message)
+ {
+ $clnt_outgoing_id = $message->id;
+ $source = $message->source;
+ $destination = $message->destination;
+ $msg = $message->msg;
+ $status = $message->status;
+ $responded = $message->responded;
+ $content_id = $message->content_id;
+ $message_type_id = $message->message_type_id;
+ $clnt_usr_id = $message->clnt_usr_id;
+ $created_at = $message->created_at;
+ $recepient_type = $message->recepient_type;
+
+ if ($status == "Not Sent")
+ {
+ // DB::connection()->enableQueryLog();
+ //check if a similar message already sent.
+ if (DB::table('tbl_clnt_outgoing')
+ ->where('msg','like', '%'.$msg.'%')
+ ->where('destination', $destination)
+ ->where('status', 'Sent')
+ ->whereRaw('created_at between (CURDATE() - INTERVAL 1 DAY) AND (CURDATE() + INTERVAL 1 DAY) ')
+ ->doesntExist()) //Message has not been sent, send the current message
+ {
+ // $queries = DB::getQueryLog();
+ // dd( $queries);
+
+ //Number process , Append conutry code prefix on the phone no if its not appended e.g 0712345678 => 254712345678
+ $mobile = substr($destination, -9);
+ $len = strlen($mobile);
+ if ($len < 10) {
+ $destination = "254" . $mobile;
+ }
+
+ //call sms service
+ $result = $this->send_message($source,$destination , $msg);
+
+ $status = $result['status'];
+ $messageid = '';
+ $cost = 0;
+
+ foreach($result as $row)
+ {
+ if($status == 'success')
+ {
+ foreach($result['data'] as $data)
+ {
+ foreach($data['Recipients'] as $Recipient)
+ {
+ $messageid = $Recipient['messageId'];
+ $cost = $Recipient['cost'];
+ }
+ }
+ }
+
+ //update the sent message with the sms cost and send status
+ $sms = ClientOutgoing::find($clnt_outgoing_id);
+ $sms->status = $status;
+ $sms->cost = $cost;
+ $sms->message_id = $messageid;
+ $sms->save();
+ //dd($result);
+
+ }
+ }
+ else //delete the current duplicate message
+ {
+ ClientOutgoing::destroy($clnt_outgoing_id);
+ }
+ }
+ }
+ }catch (Exception $e) {
+ throw $e;
+ }
+ }
+
+ private function send_message($source, $destination, $msg)
+ {
+ $key = env('SMS_SERVICE_KEY', '');
+ $host = env('SMS_SERVICE_HOST', '');
+
+ $this->httpresponse = Http::
+ withoutVerifying()
+ ->withHeaders(['api-token'=> "$key"])
+ ->post("$host", [
+ 'destination' => $destination,
+ 'msg' => $msg,
+ 'sender_id' => $destination,
+ 'gateway' => $source,
+ ]);
+
+ return json_decode( $this->httpresponse->getBody(), true);
+ }
+
+ private function sms_outgoing_insert($record)
+ {
+ try{
+ $sms = new ClientOutgoing;
+ $sms->destination = $record['destination'];
+ $sms->msg = $record['msg'];
+ $sms->responded = $record['responded'];
+ $sms->status = $record['status'];
+ $sms->message_type_id = $record['message_type_id'];
+ $sms->source = $record['source'];
+ $sms->clnt_usr_id = $record['clnt_usr_id'];
+ $sms->appointment_id = $record['appointment_id'];
+ $sms->no_of_days = $record['no_of_days'];
+ $sms->recepient_type = $record['recepient_type'];
+ $sms->content_id = $record['content_id'];
+ $sms->created_by = $record['created_by'];
+ $sms->save();
+ } catch (Exception $e) {
+ throw $e;
+ }
+
+ }
+
+ private function appointment_update($record)
+ {
+ try{
+ $appointment = Appointments::find($record['appointment_id']);
+ $appointment->app_status = $record['app_status'];
+ $appointment->app_msg = trim($record['app_msg']) == '' ? $appointment->app_msg : $record['app_msg'];
+ $appointment->notified = $record['notified'];
+ $appointment->sent_status = trim($record['sent_status']) == '' ? $appointment->sent_status : $record['sent_status'];
+ $appointment->updated_by = $record['updated_by'];
+ $appointment->save();
+ } catch (Exception $e) {
+ throw $e;
+ }
+ }
+}
diff --git a/app/Http/Controllers/TracerController.php b/app/Http/Controllers/TracerController.php
index 6d77e08..69a357a 100644
--- a/app/Http/Controllers/TracerController.php
+++ b/app/Http/Controllers/TracerController.php
@@ -8,6 +8,7 @@
use App\Models\Outcome;
use App\Models\Appointments;
use App\Models\FutureApp;
+use App\Models\Clinic;
use Session;
use Auth;
use DB;
@@ -53,12 +54,12 @@ public function tracer_client()
}
public function tracing_cost()
{
- if (Auth::user()->access_level == 'Admin') {
+ if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
$tracing_cost = Outcome::join('tbl_users', 'tbl_clnt_outcome.created_by', '=', 'tbl_users.id')
->join('tbl_client', 'tbl_clnt_outcome.client_id', '=', 'tbl_client.id')
->select('tbl_clnt_outcome.app_status', DB::raw("CONCAT(`tbl_users`.`f_name`, ' ', `tbl_users`.`m_name`, ' ', `tbl_users`.`l_name`) as tracer_name"), 'tbl_client.clinic_number', 'tbl_clnt_outcome.tracing_cost')
->whereNotNull('tbl_clnt_outcome.tracing_cost')
- ->get();
+ ->paginate(1000);
$total_costing = Outcome::join('tbl_users', 'tbl_clnt_outcome.created_by', '=', 'tbl_users.id')
->join('tbl_client', 'tbl_clnt_outcome.client_id', '=', 'tbl_client.id')
@@ -90,8 +91,9 @@ public function booked_clients_tracing()
if (Auth::user()->access_level == 'Facility') {
$all_booked = Appointments::join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
->join('tbl_appointment_types', 'tbl_appointment.app_type_1', '=', 'tbl_appointment_types.id')
+ ->join('tbl_clinic', 'tbl_client.clinic_id', '=', 'tbl_clinic.id')
->leftjoin('tbl_tracer_client', 'tbl_client.id', '=', 'tbl_tracer_client.client_id')
- ->select('tbl_appointment.id as app_id', 'tbl_client.id as client_id', 'tbl_tracer_client.is_assigned', 'tbl_client.clinic_number as clinic_number', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as client_name"), 'tbl_appointment.appntmnt_date', 'tbl_appointment_types.name as app_type')
+ ->select('tbl_appointment.id as app_id', 'tbl_client.id as client_id', 'tbl_tracer_client.is_assigned', 'tbl_clinic.name as clinic_name', 'tbl_client.clinic_number as clinic_number', DB::raw("CONCAT(`tbl_client`.`f_name`, ' ', `tbl_client`.`m_name`, ' ', `tbl_client`.`l_name`) as client_name"), 'tbl_appointment.appntmnt_date', 'tbl_appointment_types.name as app_type')
->where('tbl_appointment.appntmnt_date', '>', Now())
->where('tbl_client.mfl_code', Auth::user()->facility_id)
->get();
diff --git a/app/Http/Controllers/UpiController.php b/app/Http/Controllers/UpiController.php
new file mode 100644
index 0000000..ba889cf
--- /dev/null
+++ b/app/Http/Controllers/UpiController.php
@@ -0,0 +1,62 @@
+access_level == 'Admin') {
+
+ $verification_gender = DB::select('CALL sp_rpt_upi_gender(?,?,?,?)', array("%","%", "%", "%"));
+ $verification_age = DB::select('CALL sp_rpt_upi_age(?,?,?,?)', array("%","%", "%", "%"));
+ $verification_list = DB::select('CALL sp_rpt_upi_verification_list(?,?,?,?,?)', array("National","%","%", "%", "%"));
+ $verification_count = DB::select('CALL sp_rpt_upi_verification_list(?,?,?,?,?)', array("National", "%","%", "%", "%"));
+ $verification_count_total = DB::select('CALL sp_rpt_upi_verification_summary(?,?,?,?,?)', array("National", "%","%", "%", "%"));
+ }
+ if (Auth::user()->access_level == 'Facility') {
+ $facility = Auth::user()->facility_id;
+
+ $verification_gender = DB::select('CALL sp_rpt_upi_gender(?,?,?,?)', array($facility,"%", "%", "%"));
+ $verification_age = DB::select('CALL sp_rpt_upi_age(?,?,?,?)', array($facility,"%", "%", "%"));
+ $verification_list = DB::select('CALL sp_rpt_upi_verification_list(?,?,?,?,?)', array("Facility",$facility,"%", "%", "%"));
+ $verification_count = DB::select('CALL sp_rpt_upi_verification_list(?,?,?,?,?)', array("Partner",$facility,"%", "%", "%"));
+ $verification_count_total = DB::select('CALL sp_rpt_upi_verification_summary(?,?,?,?,?)', array("Facility", $facility,"%", "%", "%"));
+ }
+ if (Auth::user()->access_level == 'Partner') {
+ $partner = Auth::user()->partner_id;
+
+ $verification_gender = DB::select('CALL sp_rpt_upi_gender(?,?,?,?)', array("%", $partner , "%", "%"));
+ $verification_age = DB::select('CALL sp_rpt_upi_age(?,?,?,?)', array("%",$partner, "%", "%"));
+ $verification_list = DB::select('CALL sp_rpt_upi_verification_list(?,?,?,?,?)', array("Partner","%", $partner, "%", "%"));
+ $verification_count = DB::select('CALL sp_rpt_upi_verification_list(?,?,?,?,?)', array("National","%",$partner, "%", "%"));
+ $verification_count_total = DB::select('CALL sp_rpt_upi_verification_summary(?,?,?,?,?)', array("Partner", "%", $partner, "%", "%"));
+ }
+ if (Auth::user()->access_level == 'County') {
+ $county = Auth::user()->county_id;
+
+ $verification_gender = DB::select('CALL sp_rpt_upi_gender(?,?,?,?)', array("%", "%", $county, "%"));
+ $verification_age = DB::select('CALL sp_rpt_upi_age(?,?,?,?)', array("%","%", $county, "%"));
+ $verification_list = DB::select('CALL sp_rpt_upi_verification_list(?,?,?,?,?)', array("Partner","%", "%", $county, "%"));
+ $verification_count = DB::select('CALL sp_rpt_upi_verification_list(?,?,?,?,?)', array("National","%","%", $county, "%"));
+ $verification_count_total = DB::select('CALL sp_rpt_upi_verification_summary(?,?,?,?,?)', array("National", "%", "%", $county, "%"));
+ }
+ if (Auth::user()->access_level == 'Sub County') {
+ $subcounty = Auth::user()->subcounty_id;
+
+ $verification_gender = DB::select('CALL sp_rpt_upi_gender(?,?,?,?)', array("%", "%", "%", $subcounty));
+ $verification_age = DB::select('CALL sp_rpt_upi_age(?,?,?,?)', array("%","%", "%", $subcounty));
+ $verification_list = DB::select('CALL sp_rpt_upi_verification_list(?,?,?,?,?)', array("Partner","%", "%", "%", $subcounty));
+ $verification_count = DB::select('CALL sp_rpt_upi_verification_list(?,?,?,?,?)', array("National","%","%", "%", $subcounty));
+ $verification_count_total = DB::select('CALL sp_rpt_upi_verification_summary(?,?,?,?,?)', array("National", "%", "%", "%", $subcounty));
+ }
+
+ //dd($verification_age);
+ return view('dashboard.upi_dashboard', compact('verification_age', 'verification_count_total', 'verification_gender', 'verification_list', 'verification_count'));
+ }
+}
diff --git a/app/Http/Controllers/UptakeController.php b/app/Http/Controllers/UptakeController.php
new file mode 100644
index 0000000..ca1fb35
--- /dev/null
+++ b/app/Http/Controllers/UptakeController.php
@@ -0,0 +1,251 @@
+access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+ $all_partners = Partner::where('status', '=', 'Active')->orderBy('name', 'ASC')->pluck('name', 'id');
+ $consented = DB::select('CALL sp_rpt_consentedclients(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', "%"));
+ $registered = DB::select('CALL sp_rpt_registeredclients(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', "%"));
+ $txcur = DB::select('CALL sp_rpt_txcur(?,?,?,?)', array("%", "%", "%", "%"));
+
+ $consentedagesex = DB::select('CALL sp_rpt_consentedbyagesex(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', "%"));
+ $scheduledappointment = DB::select('CALL sp_rpt_scheduled_appointments(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', "%"));
+ $honoredappointment = DB::select('CALL sp_rpt_honored_appointments(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', "%"));
+ $honoredappointmentagesex = DB::select('CALL sp_rpt_honored_appointmentsbyagesex(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', "%"));
+ $honoredappointmentfacilities = DB::select('CALL sp_rpt_honoredclients_facilities(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', "%"));
+ $consentedfacilities = DB::select('CALL sp_rpt_consentedclients_facilities(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', "%"));
+
+ $ushauristatistics = DB::select('CALL sp_rpt_quick_stats(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', "%"));
+ $messages_sent = DB::select('CALL sp_rpt_messeges(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', "%"));
+ }
+ if (Auth::user()->access_level == 'Facility') {
+ $facility = Auth::user()->facility_id;
+ $all_partners = Partner::where('status', '=', 'Active')->orderBy('name', 'ASC')->pluck('name', 'id');
+
+ $consented = DB::select('CALL sp_rpt_consentedclients(?,?,?,?,?,?)', array("%", "%", $facility, '1900-01-01', '2900-01-01', "%"));
+ $registered = DB::select('CALL sp_rpt_registeredclients(?,?,?,?,?,?)', array("%", "%", $facility, '1900-01-01', '2900-01-01', "%"));
+ $txcur = DB::select('CALL sp_rpt_txcur(?,?,?,?)', array("%", "%", $facility, "%"));
+
+ $consentedagesex = DB::select('CALL sp_rpt_consentedbyagesex(?,?,?,?,?,?)', array("%", "%", $facility, '1900-01-01', '2900-01-01', "%"));
+ $scheduledappointment = DB::select('CALL sp_rpt_scheduled_appointments(?,?,?,?,?,?)', array("%", "%", $facility, '1900-01-01', '2900-01-01', "%"));
+ $honoredappointment = DB::select('CALL sp_rpt_honored_appointments(?,?,?,?,?,?)', array("%", "%", $facility, '1900-01-01', '2900-01-01', "%"));
+ $honoredappointmentagesex = DB::select('CALL sp_rpt_honored_appointmentsbyagesex(?,?,?,?,?,?)', array("%", "%", $facility, '1900-01-01', '2900-01-01', "%"));
+ $honoredappointmentfacilities = DB::select('CALL sp_rpt_honoredclients_facilities(?,?,?,?,?,?)', array("%", "%", $facility, '1900-01-01', '2900-01-01', "%"));
+ $consentedfacilities = DB::select('CALL sp_rpt_consentedclients_facilities(?,?,?,?,?,?)', array("%", "%", $facility, '1900-01-01', '2900-01-01', "%"));
+
+ $ushauristatistics = DB::select('CALL sp_rpt_quick_stats(?,?,?,?,?,?)', array("%", "%", $facility, '1900-01-01', '2900-01-01', "%"));
+ $messages_sent = DB::select('CALL sp_rpt_messeges(?,?,?,?,?,?)', array("%", "%", $facility, '1900-01-01', '2900-01-01', "%"));
+
+ $data["consentedTest"] = json_encode($consentedagesex);
+ }
+ if (Auth::user()->access_level == 'Partner') {
+ $partner = Auth::user()->partner_id;
+ $all_partners = Partner::where('status', '=', 'Active')->where('id', Auth::user()->partner_id)->pluck('name', 'id');
+
+ $consented = DB::select('CALL sp_rpt_consentedclients(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', $partner));
+ $registered = DB::select('CALL sp_rpt_registeredclients(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', $partner));
+ $txcur = DB::select('CALL sp_rpt_txcur(?,?,?,?)', array("%", "%", "%", $partner));
+
+ $consentedagesex = DB::select('CALL sp_rpt_consentedbyagesex(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', $partner));
+ $scheduledappointment = DB::select('CALL sp_rpt_scheduled_appointments(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', $partner));
+ $honoredappointment = DB::select('CALL sp_rpt_honored_appointments(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', $partner));
+ $honoredappointmentagesex = DB::select('CALL sp_rpt_honored_appointmentsbyagesex(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', $partner));
+ $honoredappointmentfacilities = DB::select('CALL sp_rpt_honoredclients_facilities(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', $partner));
+ $consentedfacilities = DB::select('CALL sp_rpt_consentedclients_facilities(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', $partner));
+
+ $ushauristatistics = DB::select('CALL sp_rpt_quick_stats(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', $partner));
+ $messages_sent = DB::select('CALL sp_rpt_messeges(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', $partner));
+ }
+
+
+ $facilities = Facility::join('tbl_partner_facility', 'tbl_partner_facility.mfl_code', '=', 'tbl_master_facility.code')
+ ->select('tbl_master_facility.name as facility', 'tbl_partner_facility.mfl_code')->get();
+
+ return view('uptake.index', compact(
+ 'registered',
+ 'consented',
+ 'txcur',
+ 'data',
+ 'consentedagesex',
+ 'facilities',
+ 'scheduledappointment',
+ 'honoredappointment',
+ 'honoredappointmentagesex',
+ 'honoredappointmentfacilities',
+ 'consentedfacilities',
+ 'all_partners',
+ 'ushauristatistics',
+ 'messages_sent'
+ ));
+
+ dd($ushauristatistics);
+ }
+
+ public function filter_uptake(Request $request)
+ {
+
+ $data = [];
+ $selected_partners = $request->partners;
+ $selected_counties = $request->counties;
+ $selected_subcounties = $request->subcounties;
+ $selected_facilites = $request->facilities;
+ $selected_from = $request->from;
+ $selected_to = $request->to;
+
+ if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+ $all_partners = Partner::where('status', '=', 'Active')->orderBy('name', 'ASC')->pluck('name', 'id');
+ $consented = DB::select('CALL sp_rpt_consentedclients(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', "%"));
+ $registered = DB::select('CALL sp_rpt_registeredclients(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', "%"));
+ $txcur = DB::select('CALL sp_rpt_txcur(?,?,?,?)', array("%", "%", "%", "%"));
+
+ $consentedagesex = DB::select('CALL sp_rpt_consentedbyagesex(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', "%"));
+ $scheduledappointment = DB::select('CALL sp_rpt_scheduled_appointments(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', "%"));
+ $honoredappointment = DB::select('CALL sp_rpt_honored_appointments(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', "%"));
+ $honoredappointmentagesex = DB::select('CALL sp_rpt_honored_appointmentsbyagesex(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', "%"));
+ $honoredappointmentfacilities = DB::select('CALL sp_rpt_honoredclients_facilities(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', "%"));
+ $consentedfacilities = DB::select('CALL sp_rpt_consentedclients_facilities(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', "%"));
+
+ $ushauristatistics = DB::select('CALL sp_rpt_quick_stats(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', "%"));
+ $messages_sent = DB::select('CALL sp_rpt_messeges(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', "%"));
+ }
+ if (Auth::user()->access_level == 'Facility') {
+ $facility = Auth::user()->facility_id;
+ $all_partners = Partner::where('status', '=', 'Active')->orderBy('name', 'ASC')->pluck('name', 'id');
+
+ $consented = DB::select('CALL sp_rpt_consentedclients(?,?,?,?,?,?)', array("%", "%", $facility, '1900-01-01', '2900-01-01', "%"));
+ $registered = DB::select('CALL sp_rpt_registeredclients(?,?,?,?,?,?)', array("%", "%", $facility, '1900-01-01', '2900-01-01', "%"));
+ $txcur = DB::select('CALL sp_rpt_txcur(?,?,?,?)', array("%", "%", $facility, "%"));
+
+ $consentedagesex = DB::select('CALL sp_rpt_consentedbyagesex(?,?,?,?,?,?)', array("%", "%", $facility, '1900-01-01', '2900-01-01', "%"));
+ $scheduledappointment = DB::select('CALL sp_rpt_scheduled_appointments(?,?,?,?,?,?)', array("%", "%", $facility, '1900-01-01', '2900-01-01', "%"));
+ $honoredappointment = DB::select('CALL sp_rpt_honored_appointments(?,?,?,?,?,?)', array("%", "%", $facility, '1900-01-01', '2900-01-01', "%"));
+ $honoredappointmentagesex = DB::select('CALL sp_rpt_honored_appointmentsbyagesex(?,?,?,?,?,?)', array("%", "%", $facility, '1900-01-01', '2900-01-01', "%"));
+ $honoredappointmentfacilities = DB::select('CALL sp_rpt_honoredclients_facilities(?,?,?,?,?,?)', array("%", "%", $facility, '1900-01-01', '2900-01-01', "%"));
+ $consentedfacilities = DB::select('CALL sp_rpt_consentedclients_facilities(?,?,?,?,?,?)', array("%", "%", $facility, '1900-01-01', '2900-01-01', "%"));
+
+ $ushauristatistics = DB::select('CALL sp_rpt_quick_stats(?,?,?,?,?,?)', array("%", "%", $facility, '1900-01-01', '2900-01-01', "%"));
+ $messages_sent = DB::select('CALL sp_rpt_messeges(?,?,?,?,?,?)', array("%", "%", $facility, '1900-01-01', '2900-01-01', "%"));
+
+ $data["consentedTest"] = json_encode($consentedagesex);
+ }
+ if (Auth::user()->access_level == 'Partner') {
+ $partner = Auth::user()->partner_id;
+ $all_partners = Partner::where('status', '=', 'Active')->where('id', Auth::user()->partner_id)->pluck('name', 'id');
+
+ $consented = DB::select('CALL sp_rpt_consentedclients(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', $partner));
+ $registered = DB::select('CALL sp_rpt_registeredclients(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', $partner));
+ $txcur = DB::select('CALL sp_rpt_txcur(?,?,?,?)', array("%", "%", "%", $partner));
+
+ $consentedagesex = DB::select('CALL sp_rpt_consentedbyagesex(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', $partner));
+ $scheduledappointment = DB::select('CALL sp_rpt_scheduled_appointments(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', $partner));
+ $honoredappointment = DB::select('CALL sp_rpt_honored_appointments(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', $partner));
+ $honoredappointmentagesex = DB::select('CALL sp_rpt_honored_appointmentsbyagesex(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', $partner));
+ $honoredappointmentfacilities = DB::select('CALL sp_rpt_honoredclients_facilities(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', $partner));
+ $consentedfacilities = DB::select('CALL sp_rpt_consentedclients_facilities(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', $partner));
+
+ $ushauristatistics = DB::select('CALL sp_rpt_quick_stats(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', $partner));
+ $messages_sent = DB::select('CALL sp_rpt_messeges(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', $partner));
+ }
+
+ if (!empty($selected_partners)) {
+ $consented = DB::select('CALL sp_rpt_consentedclients(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', $selected_partners));
+ $registered = DB::select('CALL sp_rpt_registeredclients(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', $selected_partners));
+ $txcur = DB::select('CALL sp_rpt_txcur(?,?,?,?)', array("%", "%", "%", $selected_partners));
+
+ $consentedagesex = DB::select('CALL sp_rpt_consentedbyagesex(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', $selected_partners));
+ $scheduledappointment = DB::select('CALL sp_rpt_scheduled_appointments(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', $selected_partners));
+ $honoredappointment = DB::select('CALL sp_rpt_honored_appointments(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', $selected_partners));
+ $honoredappointmentagesex = DB::select('CALL sp_rpt_honored_appointmentsbyagesex(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', $selected_partners));
+ $honoredappointmentfacilities = DB::select('CALL sp_rpt_honoredclients_facilities(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', $selected_partners));
+ $consentedfacilities = DB::select('CALL sp_rpt_consentedclients_facilities(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', $selected_partners));
+ $messages_sent = DB::select('CALL sp_rpt_messeges(?,?,?,?,?,?)', array("%", "%", "%", '1900-01-01', '2900-01-01', $selected_partners));
+ }
+ if (!empty($selected_counties)) {
+ $consented = DB::select('CALL sp_rpt_consentedclients(?,?,?,?,?,?)', array($selected_counties, "%", "%", '1900-01-01', '2900-01-01', "%"));
+ $registered = DB::select('CALL sp_rpt_registeredclients(?,?,?,?,?,?)', array($selected_counties, "%", "%", '1900-01-01', '2900-01-01', "%"));
+ $txcur = DB::select('CALL sp_rpt_txcur(?,?,?,?)', array($selected_counties, "%", "%", "%"));
+
+ $consentedagesex = DB::select('CALL sp_rpt_consentedbyagesex(?,?,?,?,?,?)', array($selected_counties, "%", "%", '1900-01-01', '2900-01-01', "%"));
+ $scheduledappointment = DB::select('CALL sp_rpt_scheduled_appointments(?,?,?,?,?,?)', array($selected_counties, "%", "%", '1900-01-01', '2900-01-01', "%"));
+ $honoredappointment = DB::select('CALL sp_rpt_honored_appointments(?,?,?,?,?,?)', array($selected_counties, "%", "%", '1900-01-01', '2900-01-01', "%"));
+ $honoredappointmentagesex = DB::select('CALL sp_rpt_honored_appointmentsbyagesex(?,?,?,?,?,?)', array($selected_counties, "%", "%", '1900-01-01', '2900-01-01', "%"));
+ $honoredappointmentfacilities = DB::select('CALL sp_rpt_honoredclients_facilities(?,?,?,?,?,?)', array($selected_counties, "%", "%", '1900-01-01', '2900-01-01', "%"));
+ $consentedfacilities = DB::select('CALL sp_rpt_consentedclients_facilities(?,?,?,?,?,?)', array($selected_counties, "%", "%", '1900-01-01', '2900-01-01', "%"));
+ $messages_sent = DB::select('CALL sp_rpt_messeges(?,?,?,?,?,?)', array($selected_counties, "%", "%", '1900-01-01', '2900-01-01', "%"));
+ }
+ if (!empty($selected_subcounties)) {
+ $consented = DB::select('CALL sp_rpt_consentedclients(?,?,?,?,?,?)', array("%", $selected_subcounties, "%", '1900-01-01', '2900-01-01', "%"));
+ $registered = DB::select('CALL sp_rpt_registeredclients(?,?,?,?,?,?)', array("%", $selected_subcounties, "%", '1900-01-01', '2900-01-01', "%"));
+ $txcur = DB::select('CALL sp_rpt_txcur(?,?,?,?)', array("%", $selected_subcounties, "%", "%"));
+
+ $consentedagesex = DB::select('CALL sp_rpt_consentedbyagesex(?,?,?,?,?,?)', array("%", $selected_subcounties, "%", '1900-01-01', '2900-01-01', "%"));
+ $scheduledappointment = DB::select('CALL sp_rpt_scheduled_appointments(?,?,?,?,?,?)', array("%", $selected_subcounties, "%", '1900-01-01', '2900-01-01', "%"));
+ $honoredappointment = DB::select('CALL sp_rpt_honored_appointments(?,?,?,?,?,?)', array("%", $selected_subcounties, "%", '1900-01-01', '2900-01-01', "%"));
+ $honoredappointmentagesex = DB::select('CALL sp_rpt_honored_appointmentsbyagesex(?,?,?,?,?,?)', array("%", $selected_subcounties, "%", '1900-01-01', '2900-01-01', "%"));
+ $honoredappointmentfacilities = DB::select('CALL sp_rpt_honoredclients_facilities(?,?,?,?,?,?)', array("%", $selected_subcounties, "%", '1900-01-01', '2900-01-01', "%"));
+ $consentedfacilities = DB::select('CALL sp_rpt_consentedclients_facilities(?,?,?,?,?,?)', array("%", $selected_subcounties, "%", '1900-01-01', '2900-01-01', "%"));
+ $messages_sent = DB::select('CALL sp_rpt_messeges(?,?,?,?,?,?)', array("%", $selected_subcounties, "%", '1900-01-01', '2900-01-01', "%"));
+
+ }
+ if (!empty($selected_facilites)) {
+ $consented = DB::select('CALL sp_rpt_consentedclients(?,?,?,?,?,?)', array("%", "%", $selected_facilites, '1900-01-01', '2900-01-01', "%"));
+ $registered = DB::select('CALL sp_rpt_registeredclients(?,?,?,?,?,?)', array("%", "%", $selected_facilites, '1900-01-01', '2900-01-01', "%"));
+ $txcur = DB::select('CALL sp_rpt_txcur(?,?,?,?)', array("%", "%", $selected_facilites, "%"));
+
+ $consentedagesex = DB::select('CALL sp_rpt_consentedbyagesex(?,?,?,?,?,?)', array("%", "%", $selected_facilites, '1900-01-01', '2900-01-01', "%"));
+ $scheduledappointment = DB::select('CALL sp_rpt_scheduled_appointments(?,?,?,?,?,?)', array("%", "%", $selected_facilites, '1900-01-01', '2900-01-01', "%"));
+ $honoredappointment = DB::select('CALL sp_rpt_honored_appointments(?,?,?,?,?,?)', array("%", "%", $selected_facilites, '1900-01-01', '2900-01-01', "%"));
+ $honoredappointmentagesex = DB::select('CALL sp_rpt_honored_appointmentsbyagesex(?,?,?,?,?,?)', array("%", "%", $selected_facilites, '1900-01-01', '2900-01-01', "%"));
+ $honoredappointmentfacilities = DB::select('CALL sp_rpt_honoredclients_facilities(?,?,?,?,?,?)', array("%", "%", $selected_facilites, '1900-01-01', '2900-01-01', "%"));
+ $consentedfacilities = DB::select('CALL sp_rpt_consentedclients_facilities(?,?,?,?,?,?)', array("%", "%", $selected_facilites, '1900-01-01', '2900-01-01', "%"));
+ $messages_sent = DB::select('CALL sp_rpt_messeges(?,?,?,?,?,?)', array("%", "%", $selected_facilites, '1900-01-01', '2900-01-01', "%"));
+ }
+ if (!empty($selected_from || $selected_to)) {
+ $consented = DB::select('CALL sp_rpt_consentedclients(?,?,?,?,?,?)', array("%", "%", "%", $selected_from, $selected_to, "%"));
+ $registered = DB::select('CALL sp_rpt_registeredclients(?,?,?,?,?,?)', array("%", "%", "%", $selected_from, $selected_to, "%"));
+ $txcur = DB::select('CALL sp_rpt_txcur(?,?,?,?)', array("%", "%", "%", "%"));
+
+ $consentedagesex = DB::select('CALL sp_rpt_consentedbyagesex(?,?,?,?,?,?)', array("%", "%", "%", $selected_from, $selected_to, "%"));
+ $scheduledappointment = DB::select('CALL sp_rpt_scheduled_appointments(?,?,?,?,?,?)', array("%", "%", "%", $selected_from, $selected_to, "%"));
+ $honoredappointment = DB::select('CALL sp_rpt_honored_appointments(?,?,?,?,?,?)', array("%", "%", "%", $selected_from, $selected_to, "%"));
+ $honoredappointmentagesex = DB::select('CALL sp_rpt_honored_appointmentsbyagesex(?,?,?,?,?,?)', array("%", "%", "%", $selected_from, $selected_to, "%"));
+ $honoredappointmentfacilities = DB::select('CALL sp_rpt_honoredclients_facilities(?,?,?,?,?,?)', array("%", "%", "%", $selected_from, $selected_to, "%"));
+ $consentedfacilities = DB::select('CALL sp_rpt_consentedclients_facilities(?,?,?,?,?,?)', array("%", "%", "%", $selected_from, $selected_to, "%"));
+ $ushauristatistics = DB::select('CALL sp_rpt_quick_stats(?,?,?,?,?,?)', array("%", "%", "%", $selected_from, $selected_to, "%"));
+ $messages_sent = DB::select('CALL sp_rpt_messeges(?,?,?,?,?,?)', array("%", "%", "%", $selected_from, $selected_to, "%"));
+ }
+
+ $data["consented"] = json_decode($consented[0]->consented);
+ $data["registered"] = json_decode($registered[0]->registeredClients);
+ $data["txcur"] = json_decode($txcur[0]->tx_cur);
+ $data["consentedagesex"] = $consentedagesex;
+ $data["scheduledappointment"] = json_decode($scheduledappointment[0]->appointments);
+ $data["honoredappointment"] = json_decode($honoredappointment[0]->honored);
+ $data["honoredappointmentagesex"] = $honoredappointmentagesex;
+ $data["honoredappointmentfacilities"] = $honoredappointmentfacilities;
+ $data["consentedfacilities"] = $consentedfacilities;
+ $data["ushauristatistics"] = $ushauristatistics;
+ $data["messages_sent"] = json_decode($messages_sent[0]->sentmesseges);
+
+ return $data;
+ }
+}
diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php
index d29284c..fddf284 100644
--- a/app/Http/Controllers/UserController.php
+++ b/app/Http/Controllers/UserController.php
@@ -21,30 +21,203 @@
class UserController extends Controller
{
//
+ public function user_info()
+ {
+ if (Auth::user()->access_level == 'Sub County') {
+ $data = [];
+
+ $user_info = DB::table('tbl_users')->select(
+ 'tbl_sub_county.name as sub_county'
+ )->join('tbl_partner_facility', 'tbl_users.subcounty_id', '=', 'tbl_partner_facility.sub_county_id')
+ ->join('tbl_sub_county', 'tbl_partner_facility.sub_county_id', '=', 'tbl_sub_county.id')
+ ->where('tbl_sub_county.id', '=', Auth::user()->subcounty_id)
+ ->groupBy('tbl_sub_county.name');
+ $data["user_info"] = $user_info->get();
+
+ return $data;
+ }
+ if (Auth::user()->access_level == 'County') {
+ $data = [];
+
+ $user_info = DB::table('tbl_users')->select(
+ 'tbl_county.name as county'
+ )->join('tbl_partner_facility', 'tbl_users.county_id', '=', 'tbl_partner_facility.county_id')
+ ->join('tbl_county', 'tbl_partner_facility.county_id', '=', 'tbl_county.id')
+ ->where('tbl_county.id', '=', Auth::user()->county_id)
+ ->groupBy('tbl_county.name');
+ $data["user_info"] = $user_info->get();
+
+ return $data;
+ }
+ if (Auth::user()->access_level == 'Facility') {
+ $data = [];
+
+ $user_info = DB::table('tbl_users')->select(
+ 'tbl_master_facility.name as facility', 'tbl_master_facility.code'
+ )->join('tbl_partner_facility', 'tbl_users.facility_id', '=', 'tbl_partner_facility.mfl_code')
+ ->join('tbl_master_facility', 'tbl_partner_facility.mfl_code', '=', 'tbl_master_facility.code')
+ ->where('tbl_master_facility.code', '=', Auth::user()->facility_id)
+ ->groupBy('tbl_master_facility.name');
+ $data["user_info"] = $user_info->get();
+
+ return $data;
+ }
+ if (Auth::user()->access_level == 'Partner') {
+ $data = [];
+
+ $user_info = DB::table('tbl_users')->select(
+ 'tbl_partner.name as partner'
+ )->join('tbl_partner_facility', 'tbl_users.facility_id', '=', 'tbl_partner_facility.mfl_code')
+ ->join('tbl_partner', 'tbl_partner_facility.partner_id', '=', 'tbl_partner.id')
+ ->where('tbl_partner.id', '=', Auth::user()->partner_id)
+ ->groupBy('tbl_partner.name');
+ $data["user_info"] = $user_info->get();
+
+ return $data;
+ }
+ }
public function showUsers()
{
- if (Auth::user()->access_level == 'Partner'){
- $all_users = User::join('tbl_clinic', 'tbl_clinic.id', '=', 'tbl_users.clinic_id')
- ->join('tbl_role', 'tbl_role.id', '=', 'tbl_users.role_id')
- ->select(DB::raw("CONCAT(`tbl_users`.`f_name`, ' ', `tbl_users`.`m_name`, ' ', `tbl_users`.`l_name`) as user_name"), 'tbl_users.f_name', 'tbl_users.m_name', 'tbl_users.l_name', 'tbl_users.dob', 'tbl_users.phone_no', 'tbl_users.e_mail', 'tbl_users.access_level', 'tbl_users.status',
- 'tbl_users.created_at', 'tbl_users.updated_at', 'tbl_clinic.name AS clinic_name', 'tbl_role.id AS role_id', 'tbl_users.view_client', 'tbl_users.rcv_app_list', 'tbl_users.daily_report', 'tbl_users.monthly_report', 'tbl_users.month3_report', 'tbl_users.month6_report', 'tbl_users.yearly_report', 'tbl_users.status',
- 'tbl_users.id as id', 'tbl_users.facility_id', 'tbl_clinic.id as clinic_id')
- ->where('tbl_users.status', '=', 'Active')
- ->where('tbl_users.partner_id', Auth::user()->partner_id)
- ->get();
- }
-
- if (Auth::user()->access_level == 'Admin'){
- $all_users = User::join('tbl_clinic', 'tbl_clinic.id', '=', 'tbl_users.clinic_id')
- ->join('tbl_role', 'tbl_role.id', '=', 'tbl_users.role_id')
- ->select(DB::raw("CONCAT(`tbl_users`.`f_name`, ' ', `tbl_users`.`m_name`, ' ', `tbl_users`.`l_name`) as user_name"), 'tbl_users.f_name', 'tbl_users.m_name', 'tbl_users.l_name', 'tbl_users.dob', 'tbl_users.phone_no', 'tbl_users.e_mail', 'tbl_users.access_level', 'tbl_users.status',
- 'tbl_users.created_at', 'tbl_users.updated_at', 'tbl_clinic.name AS clinic_name', 'tbl_role.id AS role_id', 'tbl_users.view_client', 'tbl_users.rcv_app_list', 'tbl_users.daily_report', 'tbl_users.monthly_report', 'tbl_users.month3_report', 'tbl_users.month6_report', 'tbl_users.yearly_report', 'tbl_users.status',
- 'tbl_users.id as id', 'tbl_users.facility_id', 'tbl_clinic.id as clinic_id', 'tbl_users.partner_id', 'tbl_users.county_id', 'tbl_users.donor_id')
- ->where('tbl_users.status', '=', 'Active')
- ->get();
- }
+ if (Auth::user()->access_level == 'Partner') {
+ $all_users = User::join('tbl_clinic', 'tbl_clinic.id', '=', 'tbl_users.clinic_id')
+ ->join('tbl_role', 'tbl_role.id', '=', 'tbl_users.role_id')
+ ->select(
+ DB::raw("CONCAT(`tbl_users`.`f_name`, ' ', `tbl_users`.`m_name`, ' ', `tbl_users`.`l_name`) as user_name"),
+ 'tbl_users.f_name',
+ 'tbl_users.m_name',
+ 'tbl_users.l_name',
+ 'tbl_users.dob',
+ 'tbl_users.phone_no',
+ 'tbl_users.e_mail',
+ 'tbl_users.access_level',
+ 'tbl_users.status',
+ 'tbl_users.created_at',
+ 'tbl_users.updated_at',
+ 'tbl_clinic.name AS clinic_name',
+ 'tbl_role.id AS role_id',
+ 'tbl_users.view_client',
+ 'tbl_users.rcv_app_list',
+ 'tbl_users.daily_report',
+ 'tbl_users.monthly_report',
+ 'tbl_users.month3_report',
+ 'tbl_users.month6_report',
+ 'tbl_users.yearly_report',
+ 'tbl_users.status',
+ 'tbl_users.id as id',
+ 'tbl_users.facility_id',
+ 'tbl_clinic.id as clinic_id'
+ )
+ ->where('tbl_users.status', '=', 'Active')
+ ->where('tbl_users.partner_id', '=', Auth::user()->partner_id)
+ ->get();
+ }
+ if (Auth::user()->access_level == 'Sub County') {
+ $all_users = User::join('tbl_clinic', 'tbl_clinic.id', '=', 'tbl_users.clinic_id')
+ ->join('tbl_role', 'tbl_role.id', '=', 'tbl_users.role_id')
+ ->join('tbl_partner_facility', 'tbl_partner_facility.sub_county_id', '=', 'tbl_users.subcounty_id')
+ ->select(
+ DB::raw("CONCAT(`tbl_users`.`f_name`, ' ', `tbl_users`.`m_name`, ' ', `tbl_users`.`l_name`) as user_name"),
+ 'tbl_users.f_name',
+ 'tbl_users.m_name',
+ 'tbl_users.l_name',
+ 'tbl_users.dob',
+ 'tbl_users.phone_no',
+ 'tbl_users.e_mail',
+ 'tbl_users.access_level',
+ 'tbl_users.status',
+ 'tbl_users.created_at',
+ 'tbl_users.updated_at',
+ 'tbl_clinic.name AS clinic_name',
+ 'tbl_role.id AS role_id',
+ 'tbl_users.view_client',
+ 'tbl_users.rcv_app_list',
+ 'tbl_users.daily_report',
+ 'tbl_users.monthly_report',
+ 'tbl_users.month3_report',
+ 'tbl_users.month6_report',
+ 'tbl_users.yearly_report',
+ 'tbl_users.status',
+ 'tbl_users.id as id',
+ 'tbl_users.facility_id',
+ 'tbl_clinic.id as clinic_id'
+ )
+ ->where('tbl_users.status', '=', 'Active')
+ ->where('tbl_partner_facility.sub_county_id', '=', Auth::user()->subcounty_id)
+ ->groupBy('user_name')
+ ->get();
+ }
+ if (Auth::user()->access_level == 'County') {
+ $all_users = User::join('tbl_clinic', 'tbl_clinic.id', '=', 'tbl_users.clinic_id')
+ ->join('tbl_role', 'tbl_role.id', '=', 'tbl_users.role_id')
+ ->join('tbl_partner_facility', 'tbl_partner_facility.county_id', '=', 'tbl_users.county_id')
+ ->select(
+ DB::raw("CONCAT(`tbl_users`.`f_name`, ' ', `tbl_users`.`m_name`, ' ', `tbl_users`.`l_name`) as user_name"),
+ 'tbl_users.f_name',
+ 'tbl_users.m_name',
+ 'tbl_users.l_name',
+ 'tbl_users.dob',
+ 'tbl_users.phone_no',
+ 'tbl_users.e_mail',
+ 'tbl_users.access_level',
+ 'tbl_users.status',
+ 'tbl_users.created_at',
+ 'tbl_users.updated_at',
+ 'tbl_clinic.name AS clinic_name',
+ 'tbl_role.id AS role_id',
+ 'tbl_users.view_client',
+ 'tbl_users.rcv_app_list',
+ 'tbl_users.daily_report',
+ 'tbl_users.monthly_report',
+ 'tbl_users.month3_report',
+ 'tbl_users.month6_report',
+ 'tbl_users.yearly_report',
+ 'tbl_users.status',
+ 'tbl_users.id as id',
+ 'tbl_users.facility_id',
+ 'tbl_clinic.id as clinic_id'
+ )
+ ->where('tbl_users.status', '=', 'Active')
+ ->where('tbl_partner_facility.county_id', '=', Auth::user()->county_id)
+ ->groupBy('user_name')
+ ->get();
+ }
+
+ if (Auth::user()->access_level == 'Admin') {
+ $all_users = User::join('tbl_clinic', 'tbl_clinic.id', '=', 'tbl_users.clinic_id')
+ ->join('tbl_role', 'tbl_role.id', '=', 'tbl_users.role_id')
+ ->select(
+ DB::raw("CONCAT(`tbl_users`.`f_name`, ' ', `tbl_users`.`m_name`, ' ', `tbl_users`.`l_name`) as user_name"),
+ 'tbl_users.f_name',
+ 'tbl_users.m_name',
+ 'tbl_users.l_name',
+ 'tbl_users.dob',
+ 'tbl_users.phone_no',
+ 'tbl_users.e_mail',
+ 'tbl_users.access_level',
+ 'tbl_users.status',
+ 'tbl_users.created_at',
+ 'tbl_users.updated_at',
+ 'tbl_clinic.name AS clinic_name',
+ 'tbl_role.id AS role_id',
+ 'tbl_users.view_client',
+ 'tbl_users.rcv_app_list',
+ 'tbl_users.daily_report',
+ 'tbl_users.monthly_report',
+ 'tbl_users.month3_report',
+ 'tbl_users.month6_report',
+ 'tbl_users.yearly_report',
+ 'tbl_users.status',
+ 'tbl_users.id as id',
+ 'tbl_users.facility_id',
+ 'tbl_clinic.id as clinic_id',
+ 'tbl_users.partner_id',
+ 'tbl_users.county_id',
+ 'tbl_users.donor_id'
+ )
+ ->where('tbl_users.status', '=', 'Active')
+ ->get();
+ }
$access_level = AccessLevel::all()->where('status', '=', 'Active');
- $partners = Partner::all();
$donors = Donor::all();
$facilities = PartnerFacility::join('tbl_master_facility', 'tbl_partner_facility.mfl_code', '=', 'tbl_master_facility.code')
->select('tbl_partner_facility.id', 'tbl_master_facility.name', 'tbl_partner_facility.mfl_code as code')
@@ -52,12 +225,24 @@ public function showUsers()
->get();
$counties = County::all();
$clinics = Clinic::all();
- if (Auth::user()->access_level == 'Partner'){
+ if (Auth::user()->access_level == 'Partner') {
$roles = Role::all()->where('status', '=', 'Active')
- ->where('access_level', '=', 'Facility');
+ ->where('access_level', '=', 'Facility');
+ $partners = Partner::all()->where('status', '=', 'Active')->where('id', Auth::user()->partner_id);
}
- if (Auth::user()->access_level == 'Admin'){
- $roles = Role::all()->where('status', '=', 'Active');
+ if (Auth::user()->access_level == 'Sub County') {
+ $roles = Role::all()->where('status', '=', 'Active')
+ ->where('access_level', '=', 'Facility');
+ $partners = Partner::join('tbl_partner_facility', 'tbl_partner.id', '=', 'tbl_partner_facility.partner_id')->where('tbl_partner.status', '=', 'Active')->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)->get();
+ }
+ if (Auth::user()->access_level == 'County') {
+ $roles = Role::all()->where('status', '=', 'Active')
+ ->where('access_level', '=', 'Facility');
+ $partners = Partner::all()->where('status', '=', 'Active')->where('id', Auth::user()->partner_id);
+ }
+ if (Auth::user()->access_level == 'Admin') {
+ $roles = Role::all()->where('status', '=', 'Active');
+ $partners = Partner::all()->where('status', '=', 'Active');
}
$sub_counties = SubCounty::all();
@@ -73,22 +258,23 @@ public function adduserform(Request $request)
->orderBy('tbl_master_facility.name', 'asc')
// ->where('tbl_partner_facility.mfl_code', '=', 'tbl_master_facility.code')
->get();
- if (Auth::user()->access_level == 'Partner'){
- $facilities = PartnerFacility::join('tbl_master_facility', 'tbl_partner_facility.mfl_code', '=', 'tbl_master_facility.code')
+ if (Auth::user()->access_level == 'Partner') {
+ $facilities = PartnerFacility::join('tbl_master_facility', 'tbl_partner_facility.mfl_code', '=', 'tbl_master_facility.code')
->select('tbl_partner_facility.id', 'tbl_master_facility.name', 'tbl_partner_facility.mfl_code as code')
->orderBy('tbl_master_facility.name', 'asc')
- ->where('tbl_partner_facility.partner_id', '=', Auth::user()->partner_id)
+ ->where('tbl_partner_facility.partner_id', '=', Auth::user()->partner_id)
->get();
- }
+ }
$counties = County::all();
$clinics = Clinic::all();
$roles = Role::all()->where('status', '=', 'Active');
$sub_counties = SubCounty::all();
$access_level = AccessLevel::all()->where('status', '=', 'Active');
- if (Auth::user()->access_level == 'Partner'){
+ if (Auth::user()->access_level == 'Partner') {
+ $partners = Partner::all()->where('status', '=', 'Active')->where('id', Auth::user()->partner_id);
$access_level = AccessLevel::all()->where('status', '=', 'Active')
- // ->where('name', '=', 'Partner')
- ->where('name', '=', 'Facility');
+ // ->where('name', '=', 'Partner')
+ ->where('name', '=', 'Facility');
}
$clients = Client::select('tbl_client.clinic_number', 'tbl_clinic.name')
@@ -209,7 +395,7 @@ public function adduser(Request $request)
$user->role_id = $request->rolename;
$user->facility_id = $request->facilityname;
$user->clinic_id = $request->clinicname;
- $user->partner_id = Auth::user()->partner_id;
+ $user->partner_id = $request->partner;
}
$user->view_client = $request->bio_data;
$user->rcv_app_list = $request->app_receive;
@@ -267,7 +453,8 @@ public function edituser(Request $request)
'month3_report' => $request->month3_report,
'month6_report' => $request->month6_report,
'yearly_report' => $request->yearly_report,
- 'created_by' => Auth::user()->id,
+ 'updated_by' => Auth::user()->id,
+ 'status' => $request->status,
]);
if ($user) {
Session::flash('statuscode', 'success');
@@ -293,7 +480,6 @@ public function resetuser(Request $request)
if ($user->save()) {
Session::flash('statuscode', 'success');
return redirect('admin/users')->with('status', 'User has been reset successfull');
-
} else {
Session::flash('statuscode', 'error');
return redirect('admin/users')->with('status', 'An error has occurred please try again later');
@@ -334,5 +520,4 @@ public function changepass(Request $request)
return back();
}
}
-
}
diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php
index 3238635..b7bd6ea 100644
--- a/app/Http/Middleware/RedirectIfAuthenticated.php
+++ b/app/Http/Middleware/RedirectIfAuthenticated.php
@@ -21,11 +21,11 @@ public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
- if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Partner' || Auth::user()->access_level == 'Donor') {
- return redirect('/Reports/dashboard')->with('success', 'Login Success! You will be redirected to your Home page in a few.');
+ if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Partner' || Auth::user()->access_level == 'Donor' || Auth::user()->access_level == 'County' || Auth::user()->access_level == 'Sub County') {
+ return redirect('/admin/dashboard')->with('success', 'Login Success! You will be redirected to your Home page in a few.');
}
if (Auth::user()->access_level == 'Facility') {
- return redirect('/Reports/facility_home')->with('success', 'Login Success! You will be redirected to your Home page in a few.');
+ return redirect('/admin/dashboard')->with('success', 'Login Success! You will be redirected to your Home page in a few.');
}
}
return $next($request);
diff --git a/app/Models/ActiveFacilities.php b/app/Models/ActiveFacilities.php
new file mode 100644
index 0000000..9637eff
--- /dev/null
+++ b/app/Models/ActiveFacilities.php
@@ -0,0 +1,18 @@
+belongsTo('App\Models\Client','client_id','id');
+ return $this->belongsTo(Client::class,'client_id');
}
}
diff --git a/app/Models/Client.php b/app/Models/Client.php
index 60d083a..f0bc479 100644
--- a/app/Models/Client.php
+++ b/app/Models/Client.php
@@ -5,10 +5,13 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Carbon\Carbon;
+use Watson\Rememberable\Rememberable;
class Client extends Model
{
use HasFactory;
+ use Rememberable;
+
public $table = 'tbl_client';
public $timestamps = false;
@@ -16,9 +19,21 @@ class Client extends Model
'clinic_number', 'consent_date', 'smsenable', 'language_id', 'motivational_enable', 'txt_time', 'phone_no'
];
- public function age() {
- return $this->dob->diffInYears(\Carbon::now());
- }
+// protected $appends = ['age'];
+
+// public function getAgeAttribute()
+// {
+// return Carbon::parse($this->attributes['dob'])->age;
+// }
+ // public function appointment()
+ // {
+ // return $this->hasMany(Appointments::class, 'client_id');
+ // }
+
+ // Public function partner()
+ // {
+ // return $this->hasOne(Partner::class);
+ // }
}
diff --git a/app/Models/ClientOutgoing.php b/app/Models/ClientOutgoing.php
new file mode 100644
index 0000000..40c0d2d
--- /dev/null
+++ b/app/Models/ClientOutgoing.php
@@ -0,0 +1,19 @@
+belongsTo(Client::class, 'mfl_code');
+ }
}
diff --git a/app/Models/Gender.php b/app/Models/Gender.php
index c6ed6c5..c2c2083 100644
--- a/app/Models/Gender.php
+++ b/app/Models/Gender.php
@@ -16,4 +16,9 @@ class Gender extends Model
protected $fillable = [
];
+
+ public function client()
+ {
+ return $this->belongsTo(Client::class,'gender');
+ }
}
\ No newline at end of file
diff --git a/app/Models/GenderAppointment.php b/app/Models/GenderAppointment.php
new file mode 100644
index 0000000..517178a
--- /dev/null
+++ b/app/Models/GenderAppointment.php
@@ -0,0 +1,13 @@
+dob->diffInYears(\Carbon\Carbon::now())->format('Y-m-d');
+ return Carbon::parse($this->attributes['dob'])->age;
+}
/**
* The attributes that should be hidden for arrays.
diff --git a/app/Models/Ward.php b/app/Models/Ward.php
new file mode 100644
index 0000000..a63392a
--- /dev/null
+++ b/app/Models/Ward.php
@@ -0,0 +1,18 @@
+=5.2"
},
- "require-dev": {
- "simpletest/simpletest": "dev-master#72de02a7b80c6bb8864ef9bf66d41d2f58f826bd"
- },
"type": "library",
"autoload": {
- "psr-0": {
- "HTMLPurifier": "library/"
- },
"files": [
"library/HTMLPurifier.composer.php"
],
+ "psr-0": {
+ "HTMLPurifier": "library/"
+ },
"exclude-from-classmap": [
"/library/HTMLPurifier/Language/"
]
@@ -499,7 +645,11 @@
"keywords": [
"html"
],
- "time": "2020-06-29T00:56:53+00:00"
+ "support": {
+ "issues": "https://github.com/ezyang/htmlpurifier/issues",
+ "source": "https://github.com/ezyang/htmlpurifier/tree/v4.14.0"
+ },
+ "time": "2021-12-25T01:21:49+00:00"
},
{
"name": "fideloper/proxy",
@@ -553,32 +703,34 @@
"proxy",
"trusted proxy"
],
+ "support": {
+ "issues": "https://github.com/fideloper/TrustedProxy/issues",
+ "source": "https://github.com/fideloper/TrustedProxy/tree/4.4.1"
+ },
"time": "2020-10-22T13:48:01+00:00"
},
{
"name": "fruitcake/laravel-cors",
- "version": "v2.0.4",
+ "version": "v2.2.0",
"source": {
"type": "git",
"url": "https://github.com/fruitcake/laravel-cors.git",
- "reference": "a8ccedc7ca95189ead0e407c43b530dc17791d6a"
+ "reference": "783a74f5e3431d7b9805be8afb60fd0a8f743534"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/fruitcake/laravel-cors/zipball/a8ccedc7ca95189ead0e407c43b530dc17791d6a",
- "reference": "a8ccedc7ca95189ead0e407c43b530dc17791d6a",
+ "url": "https://api.github.com/repos/fruitcake/laravel-cors/zipball/783a74f5e3431d7b9805be8afb60fd0a8f743534",
+ "reference": "783a74f5e3431d7b9805be8afb60fd0a8f743534",
"shasum": ""
},
"require": {
"asm89/stack-cors": "^2.0.1",
"illuminate/contracts": "^6|^7|^8|^9",
"illuminate/support": "^6|^7|^8|^9",
- "php": ">=7.2",
- "symfony/http-foundation": "^4|^5",
- "symfony/http-kernel": "^4.3.4|^5"
+ "php": ">=7.2"
},
"require-dev": {
- "laravel/framework": "^6|^7|^8",
+ "laravel/framework": "^6|^7.24|^8",
"orchestra/testbench-dusk": "^4|^5|^6|^7",
"phpunit/phpunit": "^6|^7|^8|^9",
"squizlabs/php_codesniffer": "^3.5"
@@ -586,7 +738,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.0-dev"
+ "dev-master": "2.1-dev"
},
"laravel": {
"providers": [
@@ -620,35 +772,44 @@
"crossdomain",
"laravel"
],
- "time": "2021-04-26T11:24:25+00:00"
+ "support": {
+ "issues": "https://github.com/fruitcake/laravel-cors/issues",
+ "source": "https://github.com/fruitcake/laravel-cors/tree/v2.2.0"
+ },
+ "funding": [
+ {
+ "url": "https://fruitcake.nl",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/barryvdh",
+ "type": "github"
+ }
+ ],
+ "time": "2022-02-23T14:25:13+00:00"
},
{
"name": "graham-campbell/result-type",
- "version": "v1.0.1",
+ "version": "v1.0.4",
"source": {
"type": "git",
"url": "https://github.com/GrahamCampbell/Result-Type.git",
- "reference": "7e279d2cd5d7fbb156ce46daada972355cea27bb"
+ "reference": "0690bde05318336c7221785f2a932467f98b64ca"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/7e279d2cd5d7fbb156ce46daada972355cea27bb",
- "reference": "7e279d2cd5d7fbb156ce46daada972355cea27bb",
+ "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/0690bde05318336c7221785f2a932467f98b64ca",
+ "reference": "0690bde05318336c7221785f2a932467f98b64ca",
"shasum": ""
},
"require": {
- "php": "^7.0|^8.0",
- "phpoption/phpoption": "^1.7.3"
+ "php": "^7.0 || ^8.0",
+ "phpoption/phpoption": "^1.8"
},
"require-dev": {
- "phpunit/phpunit": "^6.5|^7.5|^8.5|^9.0"
+ "phpunit/phpunit": "^6.5.14 || ^7.5.20 || ^8.5.19 || ^9.5.8"
},
"type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.0-dev"
- }
- },
"autoload": {
"psr-4": {
"GrahamCampbell\\ResultType\\": "src/"
@@ -661,7 +822,8 @@
"authors": [
{
"name": "Graham Campbell",
- "email": "graham@alt-three.com"
+ "email": "hello@gjcampbell.co.uk",
+ "homepage": "https://github.com/GrahamCampbell"
}
],
"description": "An Implementation Of The Result Type",
@@ -672,28 +834,43 @@
"Result-Type",
"result"
],
- "time": "2020-04-13T13:17:36+00:00"
+ "support": {
+ "issues": "https://github.com/GrahamCampbell/Result-Type/issues",
+ "source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.0.4"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/GrahamCampbell",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/graham-campbell/result-type",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2021-11-21T21:41:47+00:00"
},
{
"name": "guzzlehttp/guzzle",
- "version": "7.3.0",
+ "version": "7.4.5",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
- "reference": "7008573787b430c1c1f650e3722d9bba59967628"
+ "reference": "1dd98b0564cb3f6bd16ce683cb755f94c10fbd82"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/guzzle/guzzle/zipball/7008573787b430c1c1f650e3722d9bba59967628",
- "reference": "7008573787b430c1c1f650e3722d9bba59967628",
+ "url": "https://api.github.com/repos/guzzle/guzzle/zipball/1dd98b0564cb3f6bd16ce683cb755f94c10fbd82",
+ "reference": "1dd98b0564cb3f6bd16ce683cb755f94c10fbd82",
"shasum": ""
},
"require": {
"ext-json": "*",
- "guzzlehttp/promises": "^1.4",
- "guzzlehttp/psr7": "^1.7 || ^2.0",
+ "guzzlehttp/promises": "^1.5",
+ "guzzlehttp/psr7": "^1.9 || ^2.4",
"php": "^7.2.5 || ^8.0",
- "psr/http-client": "^1.0"
+ "psr/http-client": "^1.0",
+ "symfony/deprecation-contracts": "^2.2 || ^3.0"
},
"provide": {
"psr/http-client-implementation": "1.0"
@@ -703,7 +880,7 @@
"ext-curl": "*",
"php-http/client-integration-tests": "^3.0",
"phpunit/phpunit": "^8.5.5 || ^9.3.5",
- "psr/log": "^1.1"
+ "psr/log": "^1.1 || ^2.0 || ^3.0"
},
"suggest": {
"ext-curl": "Required for CURL handler support",
@@ -713,35 +890,59 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "7.3-dev"
+ "dev-master": "7.4-dev"
}
},
"autoload": {
- "psr-4": {
- "GuzzleHttp\\": "src/"
- },
"files": [
"src/functions_include.php"
- ]
+ ],
+ "psr-4": {
+ "GuzzleHttp\\": "src/"
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
+ {
+ "name": "Graham Campbell",
+ "email": "hello@gjcampbell.co.uk",
+ "homepage": "https://github.com/GrahamCampbell"
+ },
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
},
+ {
+ "name": "Jeremy Lindblom",
+ "email": "jeremeamia@gmail.com",
+ "homepage": "https://github.com/jeremeamia"
+ },
+ {
+ "name": "George Mponos",
+ "email": "gmponos@gmail.com",
+ "homepage": "https://github.com/gmponos"
+ },
+ {
+ "name": "Tobias Nyholm",
+ "email": "tobias.nyholm@gmail.com",
+ "homepage": "https://github.com/Nyholm"
+ },
{
"name": "Márk Sági-Kazár",
"email": "mark.sagikazar@gmail.com",
- "homepage": "https://sagikazarmark.hu"
+ "homepage": "https://github.com/sagikazarmark"
+ },
+ {
+ "name": "Tobias Schultze",
+ "email": "webmaster@tubo-world.de",
+ "homepage": "https://github.com/Tobion"
}
],
"description": "Guzzle is a PHP HTTP client library",
- "homepage": "http://guzzlephp.org/",
"keywords": [
"client",
"curl",
@@ -753,20 +954,38 @@
"rest",
"web service"
],
- "time": "2021-03-23T11:33:13+00:00"
+ "support": {
+ "issues": "https://github.com/guzzle/guzzle/issues",
+ "source": "https://github.com/guzzle/guzzle/tree/7.4.5"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/GrahamCampbell",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/Nyholm",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-06-20T22:16:13+00:00"
},
{
"name": "guzzlehttp/promises",
- "version": "1.4.1",
+ "version": "1.5.1",
"source": {
"type": "git",
"url": "https://github.com/guzzle/promises.git",
- "reference": "8e7d04f1f6450fef59366c399cfad4b9383aa30d"
+ "reference": "fe752aedc9fd8fcca3fe7ad05d419d32998a06da"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/guzzle/promises/zipball/8e7d04f1f6450fef59366c399cfad4b9383aa30d",
- "reference": "8e7d04f1f6450fef59366c399cfad4b9383aa30d",
+ "url": "https://api.github.com/repos/guzzle/promises/zipball/fe752aedc9fd8fcca3fe7ad05d419d32998a06da",
+ "reference": "fe752aedc9fd8fcca3fe7ad05d419d32998a06da",
"shasum": ""
},
"require": {
@@ -778,46 +997,79 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "1.4-dev"
+ "dev-master": "1.5-dev"
}
},
"autoload": {
- "psr-4": {
- "GuzzleHttp\\Promise\\": "src/"
- },
"files": [
"src/functions_include.php"
- ]
+ ],
+ "psr-4": {
+ "GuzzleHttp\\Promise\\": "src/"
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
+ {
+ "name": "Graham Campbell",
+ "email": "hello@gjcampbell.co.uk",
+ "homepage": "https://github.com/GrahamCampbell"
+ },
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
+ },
+ {
+ "name": "Tobias Nyholm",
+ "email": "tobias.nyholm@gmail.com",
+ "homepage": "https://github.com/Nyholm"
+ },
+ {
+ "name": "Tobias Schultze",
+ "email": "webmaster@tubo-world.de",
+ "homepage": "https://github.com/Tobion"
}
],
"description": "Guzzle promises library",
"keywords": [
"promise"
],
- "time": "2021-03-07T09:25:29+00:00"
+ "support": {
+ "issues": "https://github.com/guzzle/promises/issues",
+ "source": "https://github.com/guzzle/promises/tree/1.5.1"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/GrahamCampbell",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/Nyholm",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2021-10-22T20:56:57+00:00"
},
{
"name": "guzzlehttp/psr7",
- "version": "2.0.0",
+ "version": "2.4.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
- "reference": "1dc8d9cba3897165e16d12bb13d813afb1eb3fe7"
+ "reference": "13388f00956b1503577598873fffb5ae994b5737"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/guzzle/psr7/zipball/1dc8d9cba3897165e16d12bb13d813afb1eb3fe7",
- "reference": "1dc8d9cba3897165e16d12bb13d813afb1eb3fe7",
+ "url": "https://api.github.com/repos/guzzle/psr7/zipball/13388f00956b1503577598873fffb5ae994b5737",
+ "reference": "13388f00956b1503577598873fffb5ae994b5737",
"shasum": ""
},
"require": {
@@ -841,7 +1093,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.0-dev"
+ "dev-master": "2.4-dev"
}
},
"autoload": {
@@ -854,13 +1106,34 @@
"MIT"
],
"authors": [
+ {
+ "name": "Graham Campbell",
+ "email": "hello@gjcampbell.co.uk",
+ "homepage": "https://github.com/GrahamCampbell"
+ },
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
},
+ {
+ "name": "George Mponos",
+ "email": "gmponos@gmail.com",
+ "homepage": "https://github.com/gmponos"
+ },
+ {
+ "name": "Tobias Nyholm",
+ "email": "tobias.nyholm@gmail.com",
+ "homepage": "https://github.com/Nyholm"
+ },
+ {
+ "name": "Márk Sági-Kazár",
+ "email": "mark.sagikazar@gmail.com",
+ "homepage": "https://github.com/sagikazarmark"
+ },
{
"name": "Tobias Schultze",
+ "email": "webmaster@tubo-world.de",
"homepage": "https://github.com/Tobion"
},
{
@@ -880,20 +1153,38 @@
"uri",
"url"
],
- "time": "2021-06-30T20:03:07+00:00"
+ "support": {
+ "issues": "https://github.com/guzzle/psr7/issues",
+ "source": "https://github.com/guzzle/psr7/tree/2.4.0"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/GrahamCampbell",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/Nyholm",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-06-20T21:43:11+00:00"
},
{
"name": "laravel/framework",
- "version": "v8.49.2",
+ "version": "v8.83.17",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
- "reference": "d9b43ee080b4d51344b2e578aa667f85040471a2"
+ "reference": "2cf142cd5100b02da248acad3988bdaba5635e16"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/laravel/framework/zipball/d9b43ee080b4d51344b2e578aa667f85040471a2",
- "reference": "d9b43ee080b4d51344b2e578aa667f85040471a2",
+ "url": "https://api.github.com/repos/laravel/framework/zipball/2cf142cd5100b02da248acad3988bdaba5635e16",
+ "reference": "2cf142cd5100b02da248acad3988bdaba5635e16",
"shasum": ""
},
"require": {
@@ -903,34 +1194,37 @@
"ext-json": "*",
"ext-mbstring": "*",
"ext-openssl": "*",
- "league/commonmark": "^1.3",
+ "laravel/serializable-closure": "^1.0",
+ "league/commonmark": "^1.3|^2.0.2",
"league/flysystem": "^1.1",
"monolog/monolog": "^2.0",
- "nesbot/carbon": "^2.31",
+ "nesbot/carbon": "^2.53.1",
"opis/closure": "^3.6",
"php": "^7.3|^8.0",
"psr/container": "^1.0",
+ "psr/log": "^1.0|^2.0",
"psr/simple-cache": "^1.0",
- "ramsey/uuid": "^4.0",
- "swiftmailer/swiftmailer": "^6.0",
- "symfony/console": "^5.1.4",
- "symfony/error-handler": "^5.1.4",
- "symfony/finder": "^5.1.4",
- "symfony/http-foundation": "^5.1.4",
- "symfony/http-kernel": "^5.1.4",
- "symfony/mime": "^5.1.4",
- "symfony/process": "^5.1.4",
- "symfony/routing": "^5.1.4",
- "symfony/var-dumper": "^5.1.4",
+ "ramsey/uuid": "^4.2.2",
+ "swiftmailer/swiftmailer": "^6.3",
+ "symfony/console": "^5.4",
+ "symfony/error-handler": "^5.4",
+ "symfony/finder": "^5.4",
+ "symfony/http-foundation": "^5.4",
+ "symfony/http-kernel": "^5.4",
+ "symfony/mime": "^5.4",
+ "symfony/process": "^5.4",
+ "symfony/routing": "^5.4",
+ "symfony/var-dumper": "^5.4",
"tijsverkoyen/css-to-inline-styles": "^2.2.2",
- "vlucas/phpdotenv": "^5.2",
- "voku/portable-ascii": "^1.4.8"
+ "vlucas/phpdotenv": "^5.4.1",
+ "voku/portable-ascii": "^1.6.1"
},
"conflict": {
"tightenco/collect": "<5.5.33"
},
"provide": {
- "psr/container-implementation": "1.0"
+ "psr/container-implementation": "1.0",
+ "psr/simple-cache-implementation": "1.0"
},
"replace": {
"illuminate/auth": "self.version",
@@ -966,22 +1260,24 @@
"illuminate/view": "self.version"
},
"require-dev": {
- "aws/aws-sdk-php": "^3.155",
- "doctrine/dbal": "^2.6|^3.0",
- "filp/whoops": "^2.8",
+ "aws/aws-sdk-php": "^3.198.1",
+ "doctrine/dbal": "^2.13.3|^3.1.4",
+ "filp/whoops": "^2.14.3",
"guzzlehttp/guzzle": "^6.5.5|^7.0.1",
"league/flysystem-cached-adapter": "^1.0",
- "mockery/mockery": "^1.4.2",
- "orchestra/testbench-core": "^6.23",
+ "mockery/mockery": "^1.4.4",
+ "orchestra/testbench-core": "^6.27",
"pda/pheanstalk": "^4.0",
- "phpunit/phpunit": "^8.5.8|^9.3.3",
- "predis/predis": "^1.1.2",
- "symfony/cache": "^5.1.4"
+ "phpunit/phpunit": "^8.5.19|^9.5.8",
+ "predis/predis": "^1.1.9",
+ "symfony/cache": "^5.4"
},
"suggest": {
- "aws/aws-sdk-php": "Required to use the SQS queue driver, DynamoDb failed job storage and SES mail driver (^3.155).",
+ "ably/ably-php": "Required to use the Ably broadcast driver (^1.0).",
+ "aws/aws-sdk-php": "Required to use the SQS queue driver, DynamoDb failed job storage and SES mail driver (^3.198.1).",
"brianium/paratest": "Required to run tests in parallel (^6.0).",
- "doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.6|^3.0).",
+ "doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.13.3|^3.1.4).",
+ "ext-bcmath": "Required to use the multiple_of validation rule.",
"ext-ftp": "Required to use the Flysystem FTP driver.",
"ext-gd": "Required to use Illuminate\\Http\\Testing\\FileFactory::image().",
"ext-memcached": "Required to use the memcache cache driver.",
@@ -989,21 +1285,21 @@
"ext-posix": "Required to use all features of the queue worker.",
"ext-redis": "Required to use the Redis cache and queue drivers (^4.0|^5.0).",
"fakerphp/faker": "Required to use the eloquent factory builder (^1.9.1).",
- "filp/whoops": "Required for friendly error pages in development (^2.8).",
+ "filp/whoops": "Required for friendly error pages in development (^2.14.3).",
"guzzlehttp/guzzle": "Required to use the HTTP Client, Mailgun mail driver and the ping methods on schedules (^6.5.5|^7.0.1).",
"laravel/tinker": "Required to use the tinker console command (^2.0).",
"league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (^1.0).",
"league/flysystem-cached-adapter": "Required to use the Flysystem cache (^1.0).",
"league/flysystem-sftp": "Required to use the Flysystem SFTP driver (^1.0).",
- "mockery/mockery": "Required to use mocking (^1.4.2).",
+ "mockery/mockery": "Required to use mocking (^1.4.4).",
"nyholm/psr7": "Required to use PSR-7 bridging features (^1.2).",
"pda/pheanstalk": "Required to use the beanstalk queue driver (^4.0).",
- "phpunit/phpunit": "Required to use assertions and run tests (^8.5.8|^9.3.3).",
- "predis/predis": "Required to use the predis connector (^1.1.2).",
+ "phpunit/phpunit": "Required to use assertions and run tests (^8.5.19|^9.5.8).",
+ "predis/predis": "Required to use the predis connector (^1.1.9).",
"psr/http-message": "Required to allow Storage::put to accept a StreamInterface (^1.0).",
- "pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^4.0|^5.0|^6.0).",
- "symfony/cache": "Required to PSR-6 cache bridge (^5.1.4).",
- "symfony/filesystem": "Required to enable support for relative symbolic links (^5.1.4).",
+ "pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^4.0|^5.0|^6.0|^7.0).",
+ "symfony/cache": "Required to PSR-6 cache bridge (^5.4).",
+ "symfony/filesystem": "Required to enable support for relative symbolic links (^5.4).",
"symfony/psr-http-message-bridge": "Required to use PSR-7 bridging features (^2.0).",
"wildbit/swiftmailer-postmark": "Required to use Postmark mail driver (^3.0)."
},
@@ -1044,36 +1340,99 @@
"framework",
"laravel"
],
- "time": "2021-07-06T14:06:38+00:00"
+ "support": {
+ "issues": "https://github.com/laravel/framework/issues",
+ "source": "https://github.com/laravel/framework"
+ },
+ "time": "2022-06-21T14:38:31+00:00"
+ },
+ {
+ "name": "laravel/serializable-closure",
+ "version": "v1.2.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/laravel/serializable-closure.git",
+ "reference": "09f0e9fb61829f628205b7c94906c28740ff9540"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/09f0e9fb61829f628205b7c94906c28740ff9540",
+ "reference": "09f0e9fb61829f628205b7c94906c28740ff9540",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.3|^8.0"
+ },
+ "require-dev": {
+ "pestphp/pest": "^1.18",
+ "phpstan/phpstan": "^0.12.98",
+ "symfony/var-dumper": "^5.3"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Laravel\\SerializableClosure\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Taylor Otwell",
+ "email": "taylor@laravel.com"
+ },
+ {
+ "name": "Nuno Maduro",
+ "email": "nuno@laravel.com"
+ }
+ ],
+ "description": "Laravel Serializable Closure provides an easy and secure way to serialize closures in PHP.",
+ "keywords": [
+ "closure",
+ "laravel",
+ "serializable"
+ ],
+ "support": {
+ "issues": "https://github.com/laravel/serializable-closure/issues",
+ "source": "https://github.com/laravel/serializable-closure"
+ },
+ "time": "2022-05-16T17:09:47+00:00"
},
{
"name": "laravel/tinker",
- "version": "v2.6.1",
+ "version": "v2.7.2",
"source": {
"type": "git",
"url": "https://github.com/laravel/tinker.git",
- "reference": "04ad32c1a3328081097a181875733fa51f402083"
+ "reference": "dff39b661e827dae6e092412f976658df82dbac5"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/laravel/tinker/zipball/04ad32c1a3328081097a181875733fa51f402083",
- "reference": "04ad32c1a3328081097a181875733fa51f402083",
+ "url": "https://api.github.com/repos/laravel/tinker/zipball/dff39b661e827dae6e092412f976658df82dbac5",
+ "reference": "dff39b661e827dae6e092412f976658df82dbac5",
"shasum": ""
},
"require": {
- "illuminate/console": "^6.0|^7.0|^8.0",
- "illuminate/contracts": "^6.0|^7.0|^8.0",
- "illuminate/support": "^6.0|^7.0|^8.0",
+ "illuminate/console": "^6.0|^7.0|^8.0|^9.0",
+ "illuminate/contracts": "^6.0|^7.0|^8.0|^9.0",
+ "illuminate/support": "^6.0|^7.0|^8.0|^9.0",
"php": "^7.2.5|^8.0",
- "psy/psysh": "^0.10.4",
- "symfony/var-dumper": "^4.3.4|^5.0"
+ "psy/psysh": "^0.10.4|^0.11.1",
+ "symfony/var-dumper": "^4.3.4|^5.0|^6.0"
},
"require-dev": {
"mockery/mockery": "~1.3.3|^1.4.2",
"phpunit/phpunit": "^8.5.8|^9.3.3"
},
"suggest": {
- "illuminate/database": "The Illuminate Database package (^6.0|^7.0|^8.0)."
+ "illuminate/database": "The Illuminate Database package (^6.0|^7.0|^8.0|^9.0)."
},
"type": "library",
"extra": {
@@ -1108,29 +1467,36 @@
"laravel",
"psysh"
],
- "time": "2021-03-02T16:53:12+00:00"
+ "support": {
+ "issues": "https://github.com/laravel/tinker/issues",
+ "source": "https://github.com/laravel/tinker/tree/v2.7.2"
+ },
+ "time": "2022-03-23T12:38:24+00:00"
},
{
"name": "laravel/ui",
- "version": "v3.3.0",
+ "version": "v3.4.6",
"source": {
"type": "git",
"url": "https://github.com/laravel/ui.git",
- "reference": "07d725813350c695c779382cbd6dac0ab8665537"
+ "reference": "65ec5c03f7fee2c8ecae785795b829a15be48c2c"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/laravel/ui/zipball/07d725813350c695c779382cbd6dac0ab8665537",
- "reference": "07d725813350c695c779382cbd6dac0ab8665537",
+ "url": "https://api.github.com/repos/laravel/ui/zipball/65ec5c03f7fee2c8ecae785795b829a15be48c2c",
+ "reference": "65ec5c03f7fee2c8ecae785795b829a15be48c2c",
"shasum": ""
},
"require": {
- "illuminate/console": "^8.42",
- "illuminate/filesystem": "^8.42",
- "illuminate/support": "^8.42",
- "illuminate/validation": "^8.42",
+ "illuminate/console": "^8.42|^9.0",
+ "illuminate/filesystem": "^8.42|^9.0",
+ "illuminate/support": "^8.82|^9.0",
+ "illuminate/validation": "^8.42|^9.0",
"php": "^7.3|^8.0"
},
+ "require-dev": {
+ "orchestra/testbench": "^6.23|^7.0"
+ },
"type": "library",
"extra": {
"branch-alias": {
@@ -1163,46 +1529,61 @@
"laravel",
"ui"
],
- "time": "2021-05-25T16:45:33+00:00"
+ "support": {
+ "source": "https://github.com/laravel/ui/tree/v3.4.6"
+ },
+ "time": "2022-05-20T13:38:08+00:00"
},
{
"name": "league/commonmark",
- "version": "1.6.5",
+ "version": "2.3.3",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/commonmark.git",
- "reference": "44ffd8d3c4a9133e4bd0548622b09c55af39db5f"
+ "reference": "0da1dca5781dd3cfddbe328224d9a7a62571addc"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/44ffd8d3c4a9133e4bd0548622b09c55af39db5f",
- "reference": "44ffd8d3c4a9133e4bd0548622b09c55af39db5f",
+ "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/0da1dca5781dd3cfddbe328224d9a7a62571addc",
+ "reference": "0da1dca5781dd3cfddbe328224d9a7a62571addc",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
- "php": "^7.1 || ^8.0"
- },
- "conflict": {
- "scrutinizer/ocular": "1.7.*"
+ "league/config": "^1.1.1",
+ "php": "^7.4 || ^8.0",
+ "psr/event-dispatcher": "^1.0",
+ "symfony/deprecation-contracts": "^2.1 || ^3.0",
+ "symfony/polyfill-php80": "^1.16"
},
"require-dev": {
- "cebe/markdown": "~1.0",
- "commonmark/commonmark.js": "0.29.2",
- "erusev/parsedown": "~1.0",
+ "cebe/markdown": "^1.0",
+ "commonmark/cmark": "0.30.0",
+ "commonmark/commonmark.js": "0.30.0",
+ "composer/package-versions-deprecated": "^1.8",
+ "embed/embed": "^4.4",
+ "erusev/parsedown": "^1.0",
"ext-json": "*",
"github/gfm": "0.29.0",
- "michelf/php-markdown": "~1.4",
- "mikehaertl/php-shellcommand": "^1.4",
- "phpstan/phpstan": "^0.12.90",
- "phpunit/phpunit": "^7.5 || ^8.5 || ^9.2",
- "scrutinizer/ocular": "^1.5",
- "symfony/finder": "^4.2"
+ "michelf/php-markdown": "^1.4",
+ "nyholm/psr7": "^1.5",
+ "phpstan/phpstan": "^0.12.88 || ^1.0.0",
+ "phpunit/phpunit": "^9.5.5",
+ "scrutinizer/ocular": "^1.8.1",
+ "symfony/finder": "^5.3",
+ "symfony/yaml": "^2.3 | ^3.0 | ^4.0 | ^5.0 | ^6.0",
+ "unleashedtech/php-coding-standard": "^3.1",
+ "vimeo/psalm": "^4.7.3"
+ },
+ "suggest": {
+ "symfony/yaml": "v2.3+ required if using the Front Matter extension"
},
- "bin": [
- "bin/commonmark"
- ],
"type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "2.4-dev"
+ }
+ },
"autoload": {
"psr-4": {
"League\\CommonMark\\": "src"
@@ -1220,7 +1601,7 @@
"role": "Lead Developer"
}
],
- "description": "Highly-extensible PHP Markdown parser which fully supports the CommonMark spec and Github-Flavored Markdown (GFM)",
+ "description": "Highly-extensible PHP Markdown parser which fully supports the CommonMark spec and GitHub-Flavored Markdown (GFM)",
"homepage": "https://commonmark.thephpleague.com",
"keywords": [
"commonmark",
@@ -1232,20 +1613,127 @@
"md",
"parser"
],
- "time": "2021-06-26T11:57:13+00:00"
+ "support": {
+ "docs": "https://commonmark.thephpleague.com/",
+ "forum": "https://github.com/thephpleague/commonmark/discussions",
+ "issues": "https://github.com/thephpleague/commonmark/issues",
+ "rss": "https://github.com/thephpleague/commonmark/releases.atom",
+ "source": "https://github.com/thephpleague/commonmark"
+ },
+ "funding": [
+ {
+ "url": "https://www.colinodell.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://www.paypal.me/colinpodell/10.00",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/colinodell",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/league/commonmark",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-06-07T21:28:26+00:00"
+ },
+ {
+ "name": "league/config",
+ "version": "v1.1.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/thephpleague/config.git",
+ "reference": "a9d39eeeb6cc49d10a6e6c36f22c4c1f4a767f3e"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/thephpleague/config/zipball/a9d39eeeb6cc49d10a6e6c36f22c4c1f4a767f3e",
+ "reference": "a9d39eeeb6cc49d10a6e6c36f22c4c1f4a767f3e",
+ "shasum": ""
+ },
+ "require": {
+ "dflydev/dot-access-data": "^3.0.1",
+ "nette/schema": "^1.2",
+ "php": "^7.4 || ^8.0"
+ },
+ "require-dev": {
+ "phpstan/phpstan": "^0.12.90",
+ "phpunit/phpunit": "^9.5.5",
+ "scrutinizer/ocular": "^1.8.1",
+ "unleashedtech/php-coding-standard": "^3.1",
+ "vimeo/psalm": "^4.7.3"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "1.2-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "League\\Config\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Colin O'Dell",
+ "email": "colinodell@gmail.com",
+ "homepage": "https://www.colinodell.com",
+ "role": "Lead Developer"
+ }
+ ],
+ "description": "Define configuration arrays with strict schemas and access values with dot notation",
+ "homepage": "https://config.thephpleague.com",
+ "keywords": [
+ "array",
+ "config",
+ "configuration",
+ "dot",
+ "dot-access",
+ "nested",
+ "schema"
+ ],
+ "support": {
+ "docs": "https://config.thephpleague.com/",
+ "issues": "https://github.com/thephpleague/config/issues",
+ "rss": "https://github.com/thephpleague/config/releases.atom",
+ "source": "https://github.com/thephpleague/config"
+ },
+ "funding": [
+ {
+ "url": "https://www.colinodell.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://www.paypal.me/colinpodell/10.00",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/colinodell",
+ "type": "github"
+ }
+ ],
+ "time": "2021-08-14T12:15:32+00:00"
},
{
"name": "league/flysystem",
- "version": "1.1.4",
+ "version": "1.1.9",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem.git",
- "reference": "f3ad69181b8afed2c9edf7be5a2918144ff4ea32"
+ "reference": "094defdb4a7001845300334e7c1ee2335925ef99"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/f3ad69181b8afed2c9edf7be5a2918144ff4ea32",
- "reference": "f3ad69181b8afed2c9edf7be5a2918144ff4ea32",
+ "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/094defdb4a7001845300334e7c1ee2335925ef99",
+ "reference": "094defdb4a7001845300334e7c1ee2335925ef99",
"shasum": ""
},
"require": {
@@ -1316,20 +1804,30 @@
"sftp",
"storage"
],
- "time": "2021-06-23T21:56:05+00:00"
+ "support": {
+ "issues": "https://github.com/thephpleague/flysystem/issues",
+ "source": "https://github.com/thephpleague/flysystem/tree/1.1.9"
+ },
+ "funding": [
+ {
+ "url": "https://offset.earth/frankdejonge",
+ "type": "other"
+ }
+ ],
+ "time": "2021-12-09T09:40:50+00:00"
},
{
"name": "league/mime-type-detection",
- "version": "1.7.0",
+ "version": "1.11.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/mime-type-detection.git",
- "reference": "3b9dff8aaf7323590c1d2e443db701eb1f9aa0d3"
+ "reference": "ff6248ea87a9f116e78edd6002e39e5128a0d4dd"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/3b9dff8aaf7323590c1d2e443db701eb1f9aa0d3",
- "reference": "3b9dff8aaf7323590c1d2e443db701eb1f9aa0d3",
+ "url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/ff6248ea87a9f116e78edd6002e39e5128a0d4dd",
+ "reference": "ff6248ea87a9f116e78edd6002e39e5128a0d4dd",
"shasum": ""
},
"require": {
@@ -1337,7 +1835,7 @@
"php": "^7.2 || ^8.0"
},
"require-dev": {
- "friendsofphp/php-cs-fixer": "^2.18",
+ "friendsofphp/php-cs-fixer": "^3.2",
"phpstan/phpstan": "^0.12.68",
"phpunit/phpunit": "^8.5.8 || ^9.3"
},
@@ -1358,30 +1856,44 @@
}
],
"description": "Mime-type detection for Flysystem",
- "time": "2021-01-18T20:58:21+00:00"
+ "support": {
+ "issues": "https://github.com/thephpleague/mime-type-detection/issues",
+ "source": "https://github.com/thephpleague/mime-type-detection/tree/1.11.0"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/frankdejonge",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/league/flysystem",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-04-17T13:12:02+00:00"
},
{
"name": "maatwebsite/excel",
- "version": "3.1.32",
+ "version": "3.1.40",
"source": {
"type": "git",
- "url": "https://github.com/Maatwebsite/Laravel-Excel.git",
- "reference": "9dc29b63a77fb7f2f514ef754af3a1b57e83cadf"
+ "url": "https://github.com/SpartnerNL/Laravel-Excel.git",
+ "reference": "8a54972e3d616c74687c3cbff15765555761885c"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/Maatwebsite/Laravel-Excel/zipball/9dc29b63a77fb7f2f514ef754af3a1b57e83cadf",
- "reference": "9dc29b63a77fb7f2f514ef754af3a1b57e83cadf",
+ "url": "https://api.github.com/repos/SpartnerNL/Laravel-Excel/zipball/8a54972e3d616c74687c3cbff15765555761885c",
+ "reference": "8a54972e3d616c74687c3cbff15765555761885c",
"shasum": ""
},
"require": {
"ext-json": "*",
- "illuminate/support": "5.8.*|^6.0|^7.0|^8.0",
+ "illuminate/support": "5.8.*|^6.0|^7.0|^8.0|^9.0",
"php": "^7.0|^8.0",
"phpoffice/phpspreadsheet": "^1.18"
},
"require-dev": {
- "orchestra/testbench": "^6.0",
+ "orchestra/testbench": "^6.0|^7.0",
"predis/predis": "^1.1"
},
"type": "library",
@@ -1407,7 +1919,7 @@
"authors": [
{
"name": "Patrick Brouwers",
- "email": "patrick@maatwebsite.nl"
+ "email": "patrick@spartner.nl"
}
],
"description": "Supercharged Excel exports and imports in Laravel",
@@ -1422,33 +1934,49 @@
"php",
"phpspreadsheet"
],
- "time": "2021-07-08T10:11:21+00:00"
+ "support": {
+ "issues": "https://github.com/SpartnerNL/Laravel-Excel/issues",
+ "source": "https://github.com/SpartnerNL/Laravel-Excel/tree/3.1.40"
+ },
+ "funding": [
+ {
+ "url": "https://laravel-excel.com/commercial-support",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/patrickbrouwers",
+ "type": "github"
+ }
+ ],
+ "time": "2022-05-02T13:50:01+00:00"
},
{
"name": "maennchen/zipstream-php",
- "version": "2.1.0",
+ "version": "2.2.1",
"source": {
"type": "git",
"url": "https://github.com/maennchen/ZipStream-PHP.git",
- "reference": "c4c5803cc1f93df3d2448478ef79394a5981cc58"
+ "reference": "211e9ba1530ea5260b45d90c9ea252f56ec52729"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/c4c5803cc1f93df3d2448478ef79394a5981cc58",
- "reference": "c4c5803cc1f93df3d2448478ef79394a5981cc58",
+ "url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/211e9ba1530ea5260b45d90c9ea252f56ec52729",
+ "reference": "211e9ba1530ea5260b45d90c9ea252f56ec52729",
"shasum": ""
},
"require": {
"myclabs/php-enum": "^1.5",
- "php": ">= 7.1",
+ "php": "^7.4 || ^8.0",
"psr/http-message": "^1.0",
"symfony/polyfill-mbstring": "^1.0"
},
"require-dev": {
"ext-zip": "*",
- "guzzlehttp/guzzle": ">= 6.3",
+ "guzzlehttp/guzzle": "^6.5.3 || ^7.2.0",
"mikey179/vfsstream": "^1.6",
- "phpunit/phpunit": ">= 7.5"
+ "php-coveralls/php-coveralls": "^2.4",
+ "phpunit/phpunit": "^8.5.8 || ^9.4.2",
+ "vimeo/psalm": "^4.1"
},
"type": "library",
"autoload": {
@@ -1483,20 +2011,30 @@
"stream",
"zip"
],
- "time": "2020-05-30T13:11:16+00:00"
+ "support": {
+ "issues": "https://github.com/maennchen/ZipStream-PHP/issues",
+ "source": "https://github.com/maennchen/ZipStream-PHP/tree/2.2.1"
+ },
+ "funding": [
+ {
+ "url": "https://opencollective.com/zipstream",
+ "type": "open_collective"
+ }
+ ],
+ "time": "2022-05-18T15:52:06+00:00"
},
{
"name": "markbaker/complex",
- "version": "2.0.3",
+ "version": "3.0.1",
"source": {
"type": "git",
"url": "https://github.com/MarkBaker/PHPComplex.git",
- "reference": "6f724d7e04606fd8adaa4e3bb381c3e9db09c946"
+ "reference": "ab8bc271e404909db09ff2d5ffa1e538085c0f22"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/6f724d7e04606fd8adaa4e3bb381c3e9db09c946",
- "reference": "6f724d7e04606fd8adaa4e3bb381c3e9db09c946",
+ "url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/ab8bc271e404909db09ff2d5ffa1e538085c0f22",
+ "reference": "ab8bc271e404909db09ff2d5ffa1e538085c0f22",
"shasum": ""
},
"require": {
@@ -1512,51 +2050,7 @@
"autoload": {
"psr-4": {
"Complex\\": "classes/src/"
- },
- "files": [
- "classes/src/functions/abs.php",
- "classes/src/functions/acos.php",
- "classes/src/functions/acosh.php",
- "classes/src/functions/acot.php",
- "classes/src/functions/acoth.php",
- "classes/src/functions/acsc.php",
- "classes/src/functions/acsch.php",
- "classes/src/functions/argument.php",
- "classes/src/functions/asec.php",
- "classes/src/functions/asech.php",
- "classes/src/functions/asin.php",
- "classes/src/functions/asinh.php",
- "classes/src/functions/atan.php",
- "classes/src/functions/atanh.php",
- "classes/src/functions/conjugate.php",
- "classes/src/functions/cos.php",
- "classes/src/functions/cosh.php",
- "classes/src/functions/cot.php",
- "classes/src/functions/coth.php",
- "classes/src/functions/csc.php",
- "classes/src/functions/csch.php",
- "classes/src/functions/exp.php",
- "classes/src/functions/inverse.php",
- "classes/src/functions/ln.php",
- "classes/src/functions/log2.php",
- "classes/src/functions/log10.php",
- "classes/src/functions/negative.php",
- "classes/src/functions/pow.php",
- "classes/src/functions/rho.php",
- "classes/src/functions/sec.php",
- "classes/src/functions/sech.php",
- "classes/src/functions/sin.php",
- "classes/src/functions/sinh.php",
- "classes/src/functions/sqrt.php",
- "classes/src/functions/tan.php",
- "classes/src/functions/tanh.php",
- "classes/src/functions/theta.php",
- "classes/src/operations/add.php",
- "classes/src/operations/subtract.php",
- "classes/src/operations/multiply.php",
- "classes/src/operations/divideby.php",
- "classes/src/operations/divideinto.php"
- ]
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -1574,20 +2068,24 @@
"complex",
"mathematics"
],
- "time": "2021-06-02T09:44:11+00:00"
+ "support": {
+ "issues": "https://github.com/MarkBaker/PHPComplex/issues",
+ "source": "https://github.com/MarkBaker/PHPComplex/tree/3.0.1"
+ },
+ "time": "2021-06-29T15:32:53+00:00"
},
{
"name": "markbaker/matrix",
- "version": "2.1.3",
+ "version": "3.0.0",
"source": {
"type": "git",
"url": "https://github.com/MarkBaker/PHPMatrix.git",
- "reference": "174395a901b5ba0925f1d790fa91bab531074b61"
+ "reference": "c66aefcafb4f6c269510e9ac46b82619a904c576"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/174395a901b5ba0925f1d790fa91bab531074b61",
- "reference": "174395a901b5ba0925f1d790fa91bab531074b61",
+ "url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/c66aefcafb4f6c269510e9ac46b82619a904c576",
+ "reference": "c66aefcafb4f6c269510e9ac46b82619a904c576",
"shasum": ""
},
"require": {
@@ -1607,25 +2105,7 @@
"autoload": {
"psr-4": {
"Matrix\\": "classes/src/"
- },
- "files": [
- "classes/src/Functions/adjoint.php",
- "classes/src/Functions/antidiagonal.php",
- "classes/src/Functions/cofactors.php",
- "classes/src/Functions/determinant.php",
- "classes/src/Functions/diagonal.php",
- "classes/src/Functions/identity.php",
- "classes/src/Functions/inverse.php",
- "classes/src/Functions/minors.php",
- "classes/src/Functions/trace.php",
- "classes/src/Functions/transpose.php",
- "classes/src/Operations/add.php",
- "classes/src/Operations/directsum.php",
- "classes/src/Operations/subtract.php",
- "classes/src/Operations/multiply.php",
- "classes/src/Operations/divideby.php",
- "classes/src/Operations/divideinto.php"
- ]
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -1644,52 +2124,64 @@
"matrix",
"vector"
],
- "time": "2021-05-25T15:42:17+00:00"
+ "support": {
+ "issues": "https://github.com/MarkBaker/PHPMatrix/issues",
+ "source": "https://github.com/MarkBaker/PHPMatrix/tree/3.0.0"
+ },
+ "time": "2021-07-01T19:01:15+00:00"
},
{
"name": "monolog/monolog",
- "version": "2.3.0",
+ "version": "2.7.0",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
- "reference": "df991fd88693ab703aa403413d83e15f688dae33"
+ "reference": "5579edf28aee1190a798bfa5be8bc16c563bd524"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/Seldaek/monolog/zipball/df991fd88693ab703aa403413d83e15f688dae33",
- "reference": "df991fd88693ab703aa403413d83e15f688dae33",
+ "url": "https://api.github.com/repos/Seldaek/monolog/zipball/5579edf28aee1190a798bfa5be8bc16c563bd524",
+ "reference": "5579edf28aee1190a798bfa5be8bc16c563bd524",
"shasum": ""
},
"require": {
"php": ">=7.2",
- "psr/log": "^1.0.1"
+ "psr/log": "^1.0.1 || ^2.0 || ^3.0"
},
"provide": {
- "psr/log-implementation": "1.0.0"
+ "psr/log-implementation": "1.0.0 || 2.0.0 || 3.0.0"
},
"require-dev": {
"aws/aws-sdk-php": "^2.4.9 || ^3.0",
"doctrine/couchdb": "~1.0@dev",
- "elasticsearch/elasticsearch": "^7",
+ "elasticsearch/elasticsearch": "^7 || ^8",
+ "ext-json": "*",
"graylog2/gelf-php": "^1.4.2",
+ "guzzlehttp/guzzle": "^7.4",
+ "guzzlehttp/psr7": "^2.2",
"mongodb/mongodb": "^1.8",
- "php-amqplib/php-amqplib": "~2.4",
+ "php-amqplib/php-amqplib": "~2.4 || ^3",
"php-console/php-console": "^3.1.3",
- "phpspec/prophecy": "^1.6.1",
+ "phpspec/prophecy": "^1.15",
"phpstan/phpstan": "^0.12.91",
- "phpunit/phpunit": "^8.5",
+ "phpunit/phpunit": "^8.5.14",
"predis/predis": "^1.1",
- "rollbar/rollbar": "^1.3",
- "ruflin/elastica": ">=0.90 <7.0.1",
- "swiftmailer/swiftmailer": "^5.3|^6.0"
+ "rollbar/rollbar": "^1.3 || ^2 || ^3",
+ "ruflin/elastica": "^7",
+ "swiftmailer/swiftmailer": "^5.3|^6.0",
+ "symfony/mailer": "^5.4 || ^6",
+ "symfony/mime": "^5.4 || ^6"
},
"suggest": {
"aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
"doctrine/couchdb": "Allow sending log messages to a CouchDB server",
"elasticsearch/elasticsearch": "Allow sending log messages to an Elasticsearch server via official client",
"ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
+ "ext-curl": "Required to send log messages using the IFTTTHandler, the LogglyHandler, the SendGridHandler, the SlackWebhookHandler or the TelegramBotHandler",
"ext-mbstring": "Allow to work properly with unicode symbols",
"ext-mongodb": "Allow sending log messages to a MongoDB server (via driver)",
+ "ext-openssl": "Required to send log messages using SSL",
+ "ext-sockets": "Allow sending log messages to a Syslog server (via UDP driver)",
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
"mongodb/mongodb": "Allow sending log messages to a MongoDB server (via library)",
"php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
@@ -1726,7 +2218,21 @@
"logging",
"psr-3"
],
- "time": "2021-07-05T11:34:13+00:00"
+ "support": {
+ "issues": "https://github.com/Seldaek/monolog/issues",
+ "source": "https://github.com/Seldaek/monolog/tree/2.7.0"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/Seldaek",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/monolog/monolog",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-06-09T08:59:12+00:00"
},
{
"name": "myclabs/php-enum",
@@ -1772,36 +2278,53 @@
"keywords": [
"enum"
],
+ "support": {
+ "issues": "https://github.com/myclabs/php-enum/issues",
+ "source": "https://github.com/myclabs/php-enum/tree/1.8.3"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/mnapoli",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/myclabs/php-enum",
+ "type": "tidelift"
+ }
+ ],
"time": "2021-07-05T08:18:36+00:00"
},
{
"name": "nesbot/carbon",
- "version": "2.50.0",
+ "version": "2.58.0",
"source": {
"type": "git",
"url": "https://github.com/briannesbitt/Carbon.git",
- "reference": "f47f17d17602b2243414a44ad53d9f8b9ada5fdb"
+ "reference": "97a34af22bde8d0ac20ab34b29d7bfe360902055"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/f47f17d17602b2243414a44ad53d9f8b9ada5fdb",
- "reference": "f47f17d17602b2243414a44ad53d9f8b9ada5fdb",
+ "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/97a34af22bde8d0ac20ab34b29d7bfe360902055",
+ "reference": "97a34af22bde8d0ac20ab34b29d7bfe360902055",
"shasum": ""
},
"require": {
"ext-json": "*",
"php": "^7.1.8 || ^8.0",
"symfony/polyfill-mbstring": "^1.0",
- "symfony/translation": "^3.4 || ^4.0 || ^5.0"
+ "symfony/polyfill-php80": "^1.16",
+ "symfony/translation": "^3.4 || ^4.0 || ^5.0 || ^6.0"
},
"require-dev": {
+ "doctrine/dbal": "^2.0 || ^3.0",
"doctrine/orm": "^2.7",
- "friendsofphp/php-cs-fixer": "^2.14 || ^3.0",
+ "friendsofphp/php-cs-fixer": "^3.0",
"kylekatarnls/multi-tester": "^2.0",
"phpmd/phpmd": "^2.9",
"phpstan/extension-installer": "^1.0",
- "phpstan/phpstan": "^0.12.54",
- "phpunit/phpunit": "^7.5.20 || ^8.5.14",
+ "phpstan/phpstan": "^0.12.54 || ^1.0",
+ "phpunit/php-file-iterator": "^2.0.5",
+ "phpunit/phpunit": "^7.5.20 || ^8.5.23",
"squizlabs/php_codesniffer": "^3.4"
},
"bin": [
@@ -1810,8 +2333,8 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.x-dev",
- "dev-3.x": "3.x-dev"
+ "dev-3.x": "3.x-dev",
+ "dev-master": "2.x-dev"
},
"laravel": {
"providers": [
@@ -1851,20 +2374,182 @@
"datetime",
"time"
],
- "time": "2021-06-28T22:38:45+00:00"
+ "support": {
+ "docs": "https://carbon.nesbot.com/docs",
+ "issues": "https://github.com/briannesbitt/Carbon/issues",
+ "source": "https://github.com/briannesbitt/Carbon"
+ },
+ "funding": [
+ {
+ "url": "https://opencollective.com/Carbon",
+ "type": "open_collective"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/nesbot/carbon",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-04-25T19:31:17+00:00"
+ },
+ {
+ "name": "nette/schema",
+ "version": "v1.2.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/nette/schema.git",
+ "reference": "9a39cef03a5b34c7de64f551538cbba05c2be5df"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/nette/schema/zipball/9a39cef03a5b34c7de64f551538cbba05c2be5df",
+ "reference": "9a39cef03a5b34c7de64f551538cbba05c2be5df",
+ "shasum": ""
+ },
+ "require": {
+ "nette/utils": "^2.5.7 || ^3.1.5 || ^4.0",
+ "php": ">=7.1 <8.2"
+ },
+ "require-dev": {
+ "nette/tester": "^2.3 || ^2.4",
+ "phpstan/phpstan-nette": "^0.12",
+ "tracy/tracy": "^2.7"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.2-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "src/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause",
+ "GPL-2.0-only",
+ "GPL-3.0-only"
+ ],
+ "authors": [
+ {
+ "name": "David Grudl",
+ "homepage": "https://davidgrudl.com"
+ },
+ {
+ "name": "Nette Community",
+ "homepage": "https://nette.org/contributors"
+ }
+ ],
+ "description": "📐 Nette Schema: validating data structures against a given Schema.",
+ "homepage": "https://nette.org",
+ "keywords": [
+ "config",
+ "nette"
+ ],
+ "support": {
+ "issues": "https://github.com/nette/schema/issues",
+ "source": "https://github.com/nette/schema/tree/v1.2.2"
+ },
+ "time": "2021-10-15T11:40:02+00:00"
+ },
+ {
+ "name": "nette/utils",
+ "version": "v3.2.7",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/nette/utils.git",
+ "reference": "0af4e3de4df9f1543534beab255ccf459e7a2c99"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/nette/utils/zipball/0af4e3de4df9f1543534beab255ccf459e7a2c99",
+ "reference": "0af4e3de4df9f1543534beab255ccf459e7a2c99",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.2 <8.2"
+ },
+ "conflict": {
+ "nette/di": "<3.0.6"
+ },
+ "require-dev": {
+ "nette/tester": "~2.0",
+ "phpstan/phpstan": "^1.0",
+ "tracy/tracy": "^2.3"
+ },
+ "suggest": {
+ "ext-gd": "to use Image",
+ "ext-iconv": "to use Strings::webalize(), toAscii(), chr() and reverse()",
+ "ext-intl": "to use Strings::webalize(), toAscii(), normalize() and compare()",
+ "ext-json": "to use Nette\\Utils\\Json",
+ "ext-mbstring": "to use Strings::lower() etc...",
+ "ext-tokenizer": "to use Nette\\Utils\\Reflection::getUseStatements()",
+ "ext-xml": "to use Strings::length() etc. when mbstring is not available"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.2-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "src/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause",
+ "GPL-2.0-only",
+ "GPL-3.0-only"
+ ],
+ "authors": [
+ {
+ "name": "David Grudl",
+ "homepage": "https://davidgrudl.com"
+ },
+ {
+ "name": "Nette Community",
+ "homepage": "https://nette.org/contributors"
+ }
+ ],
+ "description": "🛠 Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.",
+ "homepage": "https://nette.org",
+ "keywords": [
+ "array",
+ "core",
+ "datetime",
+ "images",
+ "json",
+ "nette",
+ "paginator",
+ "password",
+ "slugify",
+ "string",
+ "unicode",
+ "utf-8",
+ "utility",
+ "validation"
+ ],
+ "support": {
+ "issues": "https://github.com/nette/utils/issues",
+ "source": "https://github.com/nette/utils/tree/v3.2.7"
+ },
+ "time": "2022-01-24T11:29:14+00:00"
},
{
"name": "nikic/php-parser",
- "version": "v4.11.0",
+ "version": "v4.14.0",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
- "reference": "fe14cf3672a149364fb66dfe11bf6549af899f94"
+ "reference": "34bea19b6e03d8153165d8f30bba4c3be86184c1"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/fe14cf3672a149364fb66dfe11bf6549af899f94",
- "reference": "fe14cf3672a149364fb66dfe11bf6549af899f94",
+ "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/34bea19b6e03d8153165d8f30bba4c3be86184c1",
+ "reference": "34bea19b6e03d8153165d8f30bba4c3be86184c1",
"shasum": ""
},
"require": {
@@ -1903,20 +2588,24 @@
"parser",
"php"
],
- "time": "2021-07-03T13:36:55+00:00"
+ "support": {
+ "issues": "https://github.com/nikic/PHP-Parser/issues",
+ "source": "https://github.com/nikic/PHP-Parser/tree/v4.14.0"
+ },
+ "time": "2022-05-31T20:59:12+00:00"
},
{
"name": "opis/closure",
- "version": "3.6.2",
+ "version": "3.6.3",
"source": {
"type": "git",
"url": "https://github.com/opis/closure.git",
- "reference": "06e2ebd25f2869e54a306dda991f7db58066f7f6"
+ "reference": "3d81e4309d2a927abbe66df935f4bb60082805ad"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/opis/closure/zipball/06e2ebd25f2869e54a306dda991f7db58066f7f6",
- "reference": "06e2ebd25f2869e54a306dda991f7db58066f7f6",
+ "url": "https://api.github.com/repos/opis/closure/zipball/3d81e4309d2a927abbe66df935f4bb60082805ad",
+ "reference": "3d81e4309d2a927abbe66df935f4bb60082805ad",
"shasum": ""
},
"require": {
@@ -1933,12 +2622,12 @@
}
},
"autoload": {
- "psr-4": {
- "Opis\\Closure\\": "src/"
- },
"files": [
"functions.php"
- ]
+ ],
+ "psr-4": {
+ "Opis\\Closure\\": "src/"
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -1964,20 +2653,24 @@
"serialization",
"serialize"
],
- "time": "2021-04-09T13:42:10+00:00"
+ "support": {
+ "issues": "https://github.com/opis/closure/issues",
+ "source": "https://github.com/opis/closure/tree/3.6.3"
+ },
+ "time": "2022-01-27T09:35:39+00:00"
},
{
"name": "phpoffice/phpspreadsheet",
- "version": "1.18.0",
+ "version": "1.23.0",
"source": {
"type": "git",
"url": "https://github.com/PHPOffice/PhpSpreadsheet.git",
- "reference": "418cd304e8e6b417ea79c3b29126a25dc4b1170c"
+ "reference": "21e4cf62699eebf007db28775f7d1554e612ed9e"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/418cd304e8e6b417ea79c3b29126a25dc4b1170c",
- "reference": "418cd304e8e6b417ea79c3b29126a25dc4b1170c",
+ "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/21e4cf62699eebf007db28775f7d1554e612ed9e",
+ "reference": "21e4cf62699eebf007db28775f7d1554e612ed9e",
"shasum": ""
},
"require": {
@@ -1996,25 +2689,25 @@
"ext-zlib": "*",
"ezyang/htmlpurifier": "^4.13",
"maennchen/zipstream-php": "^2.1",
- "markbaker/complex": "^2.0",
- "markbaker/matrix": "^2.0",
- "php": "^7.2 || ^8.0",
+ "markbaker/complex": "^3.0",
+ "markbaker/matrix": "^3.0",
+ "php": "^7.3 || ^8.0",
"psr/http-client": "^1.0",
"psr/http-factory": "^1.0",
- "psr/simple-cache": "^1.0"
+ "psr/simple-cache": "^1.0 || ^2.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "dev-master",
"dompdf/dompdf": "^1.0",
- "friendsofphp/php-cs-fixer": "^2.18",
+ "friendsofphp/php-cs-fixer": "^3.2",
"jpgraph/jpgraph": "^4.0",
- "mpdf/mpdf": "^8.0",
+ "mpdf/mpdf": "8.0.17",
"phpcompatibility/php-compatibility": "^9.3",
- "phpstan/phpstan": "^0.12.82",
- "phpstan/phpstan-phpunit": "^0.12.18",
- "phpunit/phpunit": "^8.5",
- "squizlabs/php_codesniffer": "^3.5",
- "tecnickcom/tcpdf": "^6.3"
+ "phpstan/phpstan": "^1.1",
+ "phpstan/phpstan-phpunit": "^1.0",
+ "phpunit/phpunit": "^8.5 || ^9.0",
+ "squizlabs/php_codesniffer": "^3.6",
+ "tecnickcom/tcpdf": "^6.4"
},
"suggest": {
"dompdf/dompdf": "Option for rendering PDF with PDF Writer (doesn't yet support PHP8)",
@@ -2064,33 +2757,37 @@
"xls",
"xlsx"
],
- "time": "2021-05-31T18:21:15+00:00"
+ "support": {
+ "issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues",
+ "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.23.0"
+ },
+ "time": "2022-04-24T13:53:10+00:00"
},
{
"name": "phpoption/phpoption",
- "version": "1.7.5",
+ "version": "1.8.1",
"source": {
"type": "git",
"url": "https://github.com/schmittjoh/php-option.git",
- "reference": "994ecccd8f3283ecf5ac33254543eb0ac946d525"
+ "reference": "eab7a0df01fe2344d172bff4cd6dbd3f8b84ad15"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/994ecccd8f3283ecf5ac33254543eb0ac946d525",
- "reference": "994ecccd8f3283ecf5ac33254543eb0ac946d525",
+ "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/eab7a0df01fe2344d172bff4cd6dbd3f8b84ad15",
+ "reference": "eab7a0df01fe2344d172bff4cd6dbd3f8b84ad15",
"shasum": ""
},
"require": {
- "php": "^5.5.9 || ^7.0 || ^8.0"
+ "php": "^7.0 || ^8.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.4.1",
- "phpunit/phpunit": "^4.8.35 || ^5.7.27 || ^6.5.6 || ^7.0 || ^8.0 || ^9.0"
+ "phpunit/phpunit": "^6.5.14 || ^7.5.20 || ^8.5.19 || ^9.5.8"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "1.7-dev"
+ "dev-master": "1.8-dev"
}
},
"autoload": {
@@ -2105,11 +2802,13 @@
"authors": [
{
"name": "Johannes M. Schmitt",
- "email": "schmittjoh@gmail.com"
+ "email": "schmittjoh@gmail.com",
+ "homepage": "https://github.com/schmittjoh"
},
{
"name": "Graham Campbell",
- "email": "graham@alt-three.com"
+ "email": "hello@gjcampbell.co.uk",
+ "homepage": "https://github.com/GrahamCampbell"
}
],
"description": "Option Type for PHP",
@@ -2119,29 +2818,50 @@
"php",
"type"
],
- "time": "2020-07-20T17:29:33+00:00"
+ "support": {
+ "issues": "https://github.com/schmittjoh/php-option/issues",
+ "source": "https://github.com/schmittjoh/php-option/tree/1.8.1"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/GrahamCampbell",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/phpoption/phpoption",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2021-12-04T23:24:31+00:00"
},
{
- "name": "psr/container",
- "version": "1.1.1",
+ "name": "predis/predis",
+ "version": "v1.1.10",
"source": {
"type": "git",
- "url": "https://github.com/php-fig/container.git",
- "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf"
+ "url": "https://github.com/predis/predis.git",
+ "reference": "a2fb02d738bedadcffdbb07efa3a5e7bd57f8d6e"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf",
- "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf",
+ "url": "https://api.github.com/repos/predis/predis/zipball/a2fb02d738bedadcffdbb07efa3a5e7bd57f8d6e",
+ "reference": "a2fb02d738bedadcffdbb07efa3a5e7bd57f8d6e",
"shasum": ""
},
"require": {
- "php": ">=7.2.0"
+ "php": ">=5.3.9"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "~4.8"
+ },
+ "suggest": {
+ "ext-curl": "Allows access to Webdis when paired with phpiredis",
+ "ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol"
},
"type": "library",
"autoload": {
"psr-4": {
- "Psr\\Container\\": "src/"
+ "Predis\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
@@ -2150,37 +2870,100 @@
],
"authors": [
{
- "name": "PHP-FIG",
- "homepage": "https://www.php-fig.org/"
+ "name": "Daniele Alessandri",
+ "email": "suppakilla@gmail.com",
+ "homepage": "http://clorophilla.net",
+ "role": "Creator & Maintainer"
+ },
+ {
+ "name": "Till Krüss",
+ "homepage": "https://till.im",
+ "role": "Maintainer"
}
],
- "description": "Common Container Interface (PHP FIG PSR-11)",
- "homepage": "https://github.com/php-fig/container",
+ "description": "Flexible and feature-complete Redis client for PHP and HHVM",
+ "homepage": "http://github.com/predis/predis",
"keywords": [
- "PSR-11",
- "container",
- "container-interface",
- "container-interop",
- "psr"
+ "nosql",
+ "predis",
+ "redis"
+ ],
+ "support": {
+ "issues": "https://github.com/predis/predis/issues",
+ "source": "https://github.com/predis/predis/tree/v1.1.10"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/sponsors/tillkruss",
+ "type": "github"
+ }
],
- "time": "2021-03-05T17:36:06+00:00"
+ "time": "2022-01-05T17:46:08+00:00"
},
{
- "name": "psr/event-dispatcher",
- "version": "1.0.0",
+ "name": "psr/container",
+ "version": "1.1.2",
"source": {
"type": "git",
- "url": "https://github.com/php-fig/event-dispatcher.git",
- "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0"
+ "url": "https://github.com/php-fig/container.git",
+ "reference": "513e0666f7216c7459170d56df27dfcefe1689ea"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0",
- "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0",
+ "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea",
+ "reference": "513e0666f7216c7459170d56df27dfcefe1689ea",
"shasum": ""
},
"require": {
- "php": ">=7.2.0"
+ "php": ">=7.4.0"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Psr\\Container\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "https://www.php-fig.org/"
+ }
+ ],
+ "description": "Common Container Interface (PHP FIG PSR-11)",
+ "homepage": "https://github.com/php-fig/container",
+ "keywords": [
+ "PSR-11",
+ "container",
+ "container-interface",
+ "container-interop",
+ "psr"
+ ],
+ "support": {
+ "issues": "https://github.com/php-fig/container/issues",
+ "source": "https://github.com/php-fig/container/tree/1.1.2"
+ },
+ "time": "2021-11-05T16:50:12+00:00"
+ },
+ {
+ "name": "psr/event-dispatcher",
+ "version": "1.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/event-dispatcher.git",
+ "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0",
+ "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.2.0"
},
"type": "library",
"extra": {
@@ -2209,6 +2992,10 @@
"psr",
"psr-14"
],
+ "support": {
+ "issues": "https://github.com/php-fig/event-dispatcher/issues",
+ "source": "https://github.com/php-fig/event-dispatcher/tree/1.0.0"
+ },
"time": "2019-01-08T18:20:26+00:00"
},
{
@@ -2258,6 +3045,9 @@
"psr",
"psr-18"
],
+ "support": {
+ "source": "https://github.com/php-fig/http-client/tree/master"
+ },
"time": "2020-06-29T06:28:15+00:00"
},
{
@@ -2310,6 +3100,9 @@
"request",
"response"
],
+ "support": {
+ "source": "https://github.com/php-fig/http-factory/tree/master"
+ },
"time": "2019-04-30T12:38:16+00:00"
},
{
@@ -2360,6 +3153,9 @@
"request",
"response"
],
+ "support": {
+ "source": "https://github.com/php-fig/http-message/tree/master"
+ },
"time": "2016-08-06T14:39:51+00:00"
},
{
@@ -2407,6 +3203,9 @@
"psr",
"psr-3"
],
+ "support": {
+ "source": "https://github.com/php-fig/log/tree/1.1.4"
+ },
"time": "2021-05-03T11:20:27+00:00"
},
{
@@ -2455,40 +3254,44 @@
"psr-16",
"simple-cache"
],
+ "support": {
+ "source": "https://github.com/php-fig/simple-cache/tree/master"
+ },
"time": "2017-10-23T01:57:42+00:00"
},
{
"name": "psy/psysh",
- "version": "v0.10.8",
+ "version": "v0.11.5",
"source": {
"type": "git",
"url": "https://github.com/bobthecow/psysh.git",
- "reference": "e4573f47750dd6c92dca5aee543fa77513cbd8d3"
+ "reference": "c23686f9c48ca202710dbb967df8385a952a2daf"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/bobthecow/psysh/zipball/e4573f47750dd6c92dca5aee543fa77513cbd8d3",
- "reference": "e4573f47750dd6c92dca5aee543fa77513cbd8d3",
+ "url": "https://api.github.com/repos/bobthecow/psysh/zipball/c23686f9c48ca202710dbb967df8385a952a2daf",
+ "reference": "c23686f9c48ca202710dbb967df8385a952a2daf",
"shasum": ""
},
"require": {
"ext-json": "*",
"ext-tokenizer": "*",
- "nikic/php-parser": "~4.0|~3.0|~2.0|~1.3",
- "php": "^8.0 || ^7.0 || ^5.5.9",
- "symfony/console": "~5.0|~4.0|~3.0|^2.4.2|~2.3.10",
- "symfony/var-dumper": "~5.0|~4.0|~3.0|~2.7"
+ "nikic/php-parser": "^4.0 || ^3.1",
+ "php": "^8.0 || ^7.0.8",
+ "symfony/console": "^6.0 || ^5.0 || ^4.0 || ^3.4",
+ "symfony/var-dumper": "^6.0 || ^5.0 || ^4.0 || ^3.4"
+ },
+ "conflict": {
+ "symfony/console": "4.4.37 || 5.3.14 || 5.3.15 || 5.4.3 || 5.4.4 || 6.0.3 || 6.0.4"
},
"require-dev": {
- "bamarni/composer-bin-plugin": "^1.2",
- "hoa/console": "3.17.*"
+ "bamarni/composer-bin-plugin": "^1.2"
},
"suggest": {
"ext-pcntl": "Enabling the PCNTL extension makes PsySH a lot happier :)",
"ext-pdo-sqlite": "The doc command requires SQLite to work.",
"ext-posix": "If you have PCNTL, you'll want the POSIX extension as well.",
- "ext-readline": "Enables support for arrow-key history navigation, and showing and manipulating command history.",
- "hoa/console": "A pure PHP readline implementation. You'll want this if your PHP install doesn't already support readline or libedit."
+ "ext-readline": "Enables support for arrow-key history navigation, and showing and manipulating command history."
},
"bin": [
"bin/psysh"
@@ -2496,7 +3299,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "0.10.x-dev"
+ "dev-main": "0.11.x-dev"
}
},
"autoload": {
@@ -2526,7 +3329,11 @@
"interactive",
"shell"
],
- "time": "2021-04-10T16:23:39+00:00"
+ "support": {
+ "issues": "https://github.com/bobthecow/psysh/issues",
+ "source": "https://github.com/bobthecow/psysh/tree/v0.11.5"
+ },
+ "time": "2022-05-27T18:03:49+00:00"
},
{
"name": "ralouphie/getallheaders",
@@ -2566,24 +3373,29 @@
}
],
"description": "A polyfill for getallheaders.",
+ "support": {
+ "issues": "https://github.com/ralouphie/getallheaders/issues",
+ "source": "https://github.com/ralouphie/getallheaders/tree/develop"
+ },
"time": "2019-03-08T08:55:37+00:00"
},
{
"name": "ramsey/collection",
- "version": "1.1.3",
+ "version": "1.2.2",
"source": {
"type": "git",
"url": "https://github.com/ramsey/collection.git",
- "reference": "28a5c4ab2f5111db6a60b2b4ec84057e0f43b9c1"
+ "reference": "cccc74ee5e328031b15640b51056ee8d3bb66c0a"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/ramsey/collection/zipball/28a5c4ab2f5111db6a60b2b4ec84057e0f43b9c1",
- "reference": "28a5c4ab2f5111db6a60b2b4ec84057e0f43b9c1",
+ "url": "https://api.github.com/repos/ramsey/collection/zipball/cccc74ee5e328031b15640b51056ee8d3bb66c0a",
+ "reference": "cccc74ee5e328031b15640b51056ee8d3bb66c0a",
"shasum": ""
},
"require": {
- "php": "^7.2 || ^8"
+ "php": "^7.3 || ^8",
+ "symfony/polyfill-php81": "^1.23"
},
"require-dev": {
"captainhook/captainhook": "^5.3",
@@ -2593,6 +3405,7 @@
"hamcrest/hamcrest-php": "^2",
"jangregor/phpstan-prophecy": "^0.8",
"mockery/mockery": "^1.3",
+ "phpspec/prophecy-phpunit": "^2.0",
"phpstan/extension-installer": "^1",
"phpstan/phpstan": "^0.12.32",
"phpstan/phpstan-mockery": "^0.12.5",
@@ -2620,7 +3433,7 @@
"homepage": "https://benramsey.com"
}
],
- "description": "A PHP 7.2+ library for representing and manipulating collections.",
+ "description": "A PHP library for representing and manipulating collections.",
"keywords": [
"array",
"collection",
@@ -2629,53 +3442,68 @@
"queue",
"set"
],
- "time": "2021-01-21T17:40:04+00:00"
+ "support": {
+ "issues": "https://github.com/ramsey/collection/issues",
+ "source": "https://github.com/ramsey/collection/tree/1.2.2"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/ramsey",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/ramsey/collection",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2021-10-10T03:01:02+00:00"
},
{
"name": "ramsey/uuid",
- "version": "4.1.1",
+ "version": "4.2.3",
"source": {
"type": "git",
"url": "https://github.com/ramsey/uuid.git",
- "reference": "cd4032040a750077205918c86049aa0f43d22947"
+ "reference": "fc9bb7fb5388691fd7373cd44dcb4d63bbcf24df"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/ramsey/uuid/zipball/cd4032040a750077205918c86049aa0f43d22947",
- "reference": "cd4032040a750077205918c86049aa0f43d22947",
+ "url": "https://api.github.com/repos/ramsey/uuid/zipball/fc9bb7fb5388691fd7373cd44dcb4d63bbcf24df",
+ "reference": "fc9bb7fb5388691fd7373cd44dcb4d63bbcf24df",
"shasum": ""
},
"require": {
"brick/math": "^0.8 || ^0.9",
"ext-json": "*",
- "php": "^7.2 || ^8",
+ "php": "^7.2 || ^8.0",
"ramsey/collection": "^1.0",
- "symfony/polyfill-ctype": "^1.8"
+ "symfony/polyfill-ctype": "^1.8",
+ "symfony/polyfill-php80": "^1.14"
},
"replace": {
"rhumsaa/uuid": "self.version"
},
"require-dev": {
- "codeception/aspect-mock": "^3",
- "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7.0",
+ "captainhook/captainhook": "^5.10",
+ "captainhook/plugin-composer": "^5.3",
+ "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
"doctrine/annotations": "^1.8",
- "goaop/framework": "^2",
+ "ergebnis/composer-normalize": "^2.15",
"mockery/mockery": "^1.3",
"moontoast/math": "^1.1",
"paragonie/random-lib": "^2",
+ "php-mock/php-mock": "^2.2",
"php-mock/php-mock-mockery": "^1.3",
- "php-mock/php-mock-phpunit": "^2.5",
"php-parallel-lint/php-parallel-lint": "^1.1",
- "phpbench/phpbench": "^0.17.1",
+ "phpbench/phpbench": "^1.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-mockery": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
- "phpunit/phpunit": "^8.5",
- "psy/psysh": "^0.10.0",
- "slevomat/coding-standard": "^6.0",
+ "phpunit/phpunit": "^8.5 || ^9",
+ "slevomat/coding-standard": "^7.0",
"squizlabs/php_codesniffer": "^3.5",
- "vimeo/psalm": "3.9.4"
+ "vimeo/psalm": "^4.9"
},
"suggest": {
"ext-bcmath": "Enables faster math with arbitrary-precision integers using BCMath.",
@@ -2688,42 +3516,58 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "4.x-dev"
+ "dev-main": "4.x-dev"
+ },
+ "captainhook": {
+ "force-install": true
}
},
"autoload": {
- "psr-4": {
- "Ramsey\\Uuid\\": "src/"
- },
"files": [
"src/functions.php"
- ]
+ ],
+ "psr-4": {
+ "Ramsey\\Uuid\\": "src/"
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "A PHP library for generating and working with universally unique identifiers (UUIDs).",
- "homepage": "https://github.com/ramsey/uuid",
"keywords": [
"guid",
"identifier",
"uuid"
],
- "time": "2020-08-18T17:17:46+00:00"
+ "support": {
+ "issues": "https://github.com/ramsey/uuid/issues",
+ "source": "https://github.com/ramsey/uuid/tree/4.2.3"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/ramsey",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/ramsey/uuid",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2021-09-25T23:10:38+00:00"
},
{
"name": "swiftmailer/swiftmailer",
- "version": "v6.2.7",
+ "version": "v6.3.0",
"source": {
"type": "git",
"url": "https://github.com/swiftmailer/swiftmailer.git",
- "reference": "15f7faf8508e04471f666633addacf54c0ab5933"
+ "reference": "8a5d5072dca8f48460fce2f4131fcc495eec654c"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/15f7faf8508e04471f666633addacf54c0ab5933",
- "reference": "15f7faf8508e04471f666633addacf54c0ab5933",
+ "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/8a5d5072dca8f48460fce2f4131fcc495eec654c",
+ "reference": "8a5d5072dca8f48460fce2f4131fcc495eec654c",
"shasum": ""
},
"require": {
@@ -2735,7 +3579,7 @@
},
"require-dev": {
"mockery/mockery": "^1.0",
- "symfony/phpunit-bridge": "^4.4|^5.0"
+ "symfony/phpunit-bridge": "^4.4|^5.4"
},
"suggest": {
"ext-intl": "Needed to support internationalized email addresses"
@@ -2771,32 +3615,48 @@
"mail",
"mailer"
],
- "time": "2021-03-09T12:30:35+00:00"
+ "support": {
+ "issues": "https://github.com/swiftmailer/swiftmailer/issues",
+ "source": "https://github.com/swiftmailer/swiftmailer/tree/v6.3.0"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/swiftmailer/swiftmailer",
+ "type": "tidelift"
+ }
+ ],
+ "abandoned": "symfony/mailer",
+ "time": "2021-10-18T15:26:12+00:00"
},
{
"name": "symfony/console",
- "version": "v5.3.2",
+ "version": "v5.4.10",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
- "reference": "649730483885ff2ca99ca0560ef0e5f6b03f2ac1"
+ "reference": "4d671ab4ddac94ee439ea73649c69d9d200b5000"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/console/zipball/649730483885ff2ca99ca0560ef0e5f6b03f2ac1",
- "reference": "649730483885ff2ca99ca0560ef0e5f6b03f2ac1",
+ "url": "https://api.github.com/repos/symfony/console/zipball/4d671ab4ddac94ee439ea73649c69d9d200b5000",
+ "reference": "4d671ab4ddac94ee439ea73649c69d9d200b5000",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
- "symfony/deprecation-contracts": "^2.1",
+ "symfony/deprecation-contracts": "^2.1|^3",
"symfony/polyfill-mbstring": "~1.0",
- "symfony/polyfill-php73": "^1.8",
- "symfony/polyfill-php80": "^1.15",
- "symfony/service-contracts": "^1.1|^2",
- "symfony/string": "^5.1"
+ "symfony/polyfill-php73": "^1.9",
+ "symfony/polyfill-php80": "^1.16",
+ "symfony/service-contracts": "^1.1|^2|^3",
+ "symfony/string": "^5.1|^6.0"
},
"conflict": {
+ "psr/log": ">=3",
"symfony/dependency-injection": "<4.4",
"symfony/dotenv": "<5.1",
"symfony/event-dispatcher": "<4.4",
@@ -2804,16 +3664,16 @@
"symfony/process": "<4.4"
},
"provide": {
- "psr/log-implementation": "1.0"
+ "psr/log-implementation": "1.0|2.0"
},
"require-dev": {
- "psr/log": "~1.0",
- "symfony/config": "^4.4|^5.0",
- "symfony/dependency-injection": "^4.4|^5.0",
- "symfony/event-dispatcher": "^4.4|^5.0",
- "symfony/lock": "^4.4|^5.0",
- "symfony/process": "^4.4|^5.0",
- "symfony/var-dumper": "^4.4|^5.0"
+ "psr/log": "^1|^2",
+ "symfony/config": "^4.4|^5.0|^6.0",
+ "symfony/dependency-injection": "^4.4|^5.0|^6.0",
+ "symfony/event-dispatcher": "^4.4|^5.0|^6.0",
+ "symfony/lock": "^4.4|^5.0|^6.0",
+ "symfony/process": "^4.4|^5.0|^6.0",
+ "symfony/var-dumper": "^4.4|^5.0|^6.0"
},
"suggest": {
"psr/log": "For using the console logger",
@@ -2852,24 +3712,42 @@
"console",
"terminal"
],
- "time": "2021-06-12T09:42:48+00:00"
+ "support": {
+ "source": "https://github.com/symfony/console/tree/v5.4.10"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-06-26T13:00:04+00:00"
},
{
"name": "symfony/css-selector",
- "version": "v5.3.0",
+ "version": "v5.4.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/css-selector.git",
- "reference": "fcd0b29a7a0b1bb5bfbedc6231583d77fea04814"
+ "reference": "b0a190285cd95cb019237851205b8140ef6e368e"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/css-selector/zipball/fcd0b29a7a0b1bb5bfbedc6231583d77fea04814",
- "reference": "fcd0b29a7a0b1bb5bfbedc6231583d77fea04814",
+ "url": "https://api.github.com/repos/symfony/css-selector/zipball/b0a190285cd95cb019237851205b8140ef6e368e",
+ "reference": "b0a190285cd95cb019237851205b8140ef6e368e",
"shasum": ""
},
"require": {
- "php": ">=7.2.5"
+ "php": ">=7.2.5",
+ "symfony/polyfill-php80": "^1.16"
},
"type": "library",
"autoload": {
@@ -2900,20 +3778,37 @@
],
"description": "Converts CSS selectors to XPath expressions",
"homepage": "https://symfony.com",
- "time": "2021-05-26T17:40:38+00:00"
+ "support": {
+ "source": "https://github.com/symfony/css-selector/tree/v5.4.3"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-01-02T09:53:40+00:00"
},
{
"name": "symfony/deprecation-contracts",
- "version": "v2.4.0",
+ "version": "v2.5.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git",
- "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627"
+ "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5f38c8804a9e97d23e0c8d63341088cd8a22d627",
- "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627",
+ "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e8b495ea28c1d97b5e0c121748d6f9b53d075c66",
+ "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66",
"shasum": ""
},
"require": {
@@ -2922,7 +3817,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "2.4-dev"
+ "dev-main": "2.5-dev"
},
"thanks": {
"name": "symfony/contracts",
@@ -2950,33 +3845,52 @@
],
"description": "A generic function and convention to trigger deprecation notices",
"homepage": "https://symfony.com",
- "time": "2021-03-23T23:28:01+00:00"
+ "support": {
+ "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.1"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-01-02T09:53:40+00:00"
},
{
"name": "symfony/error-handler",
- "version": "v5.3.3",
+ "version": "v5.4.9",
"source": {
"type": "git",
"url": "https://github.com/symfony/error-handler.git",
- "reference": "43323e79c80719e8a4674e33484bca98270d223f"
+ "reference": "c116cda1f51c678782768dce89a45f13c949455d"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/error-handler/zipball/43323e79c80719e8a4674e33484bca98270d223f",
- "reference": "43323e79c80719e8a4674e33484bca98270d223f",
+ "url": "https://api.github.com/repos/symfony/error-handler/zipball/c116cda1f51c678782768dce89a45f13c949455d",
+ "reference": "c116cda1f51c678782768dce89a45f13c949455d",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
- "psr/log": "^1.0",
- "symfony/polyfill-php80": "^1.15",
- "symfony/var-dumper": "^4.4|^5.0"
+ "psr/log": "^1|^2|^3",
+ "symfony/var-dumper": "^4.4|^5.0|^6.0"
},
"require-dev": {
- "symfony/deprecation-contracts": "^2.1",
- "symfony/http-kernel": "^4.4|^5.0",
- "symfony/serializer": "^4.4|^5.0"
+ "symfony/deprecation-contracts": "^2.1|^3",
+ "symfony/http-kernel": "^4.4|^5.0|^6.0",
+ "symfony/serializer": "^4.4|^5.0|^6.0"
},
+ "bin": [
+ "Resources/bin/patch-type-declarations"
+ ],
"type": "library",
"autoload": {
"psr-4": {
@@ -3002,27 +3916,44 @@
],
"description": "Provides tools to manage errors and ease debugging PHP code",
"homepage": "https://symfony.com",
- "time": "2021-06-24T08:13:00+00:00"
+ "support": {
+ "source": "https://github.com/symfony/error-handler/tree/v5.4.9"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-05-21T13:57:48+00:00"
},
{
"name": "symfony/event-dispatcher",
- "version": "v5.3.0",
+ "version": "v5.4.9",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
- "reference": "67a5f354afa8e2f231081b3fa11a5912f933c3ce"
+ "reference": "8e6ce1cc0279e3ff3c8ff0f43813bc88d21ca1bc"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/67a5f354afa8e2f231081b3fa11a5912f933c3ce",
- "reference": "67a5f354afa8e2f231081b3fa11a5912f933c3ce",
+ "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/8e6ce1cc0279e3ff3c8ff0f43813bc88d21ca1bc",
+ "reference": "8e6ce1cc0279e3ff3c8ff0f43813bc88d21ca1bc",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
- "symfony/deprecation-contracts": "^2.1",
- "symfony/event-dispatcher-contracts": "^2",
- "symfony/polyfill-php80": "^1.15"
+ "symfony/deprecation-contracts": "^2.1|^3",
+ "symfony/event-dispatcher-contracts": "^2|^3",
+ "symfony/polyfill-php80": "^1.16"
},
"conflict": {
"symfony/dependency-injection": "<4.4"
@@ -3032,14 +3963,14 @@
"symfony/event-dispatcher-implementation": "2.0"
},
"require-dev": {
- "psr/log": "~1.0",
- "symfony/config": "^4.4|^5.0",
- "symfony/dependency-injection": "^4.4|^5.0",
- "symfony/error-handler": "^4.4|^5.0",
- "symfony/expression-language": "^4.4|^5.0",
- "symfony/http-foundation": "^4.4|^5.0",
- "symfony/service-contracts": "^1.1|^2",
- "symfony/stopwatch": "^4.4|^5.0"
+ "psr/log": "^1|^2|^3",
+ "symfony/config": "^4.4|^5.0|^6.0",
+ "symfony/dependency-injection": "^4.4|^5.0|^6.0",
+ "symfony/error-handler": "^4.4|^5.0|^6.0",
+ "symfony/expression-language": "^4.4|^5.0|^6.0",
+ "symfony/http-foundation": "^4.4|^5.0|^6.0",
+ "symfony/service-contracts": "^1.1|^2|^3",
+ "symfony/stopwatch": "^4.4|^5.0|^6.0"
},
"suggest": {
"symfony/dependency-injection": "",
@@ -3070,20 +4001,37 @@
],
"description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them",
"homepage": "https://symfony.com",
- "time": "2021-05-26T17:43:10+00:00"
+ "support": {
+ "source": "https://github.com/symfony/event-dispatcher/tree/v5.4.9"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-05-05T16:45:39+00:00"
},
{
"name": "symfony/event-dispatcher-contracts",
- "version": "v2.4.0",
+ "version": "v2.5.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher-contracts.git",
- "reference": "69fee1ad2332a7cbab3aca13591953da9cdb7a11"
+ "reference": "f98b54df6ad059855739db6fcbc2d36995283fe1"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/69fee1ad2332a7cbab3aca13591953da9cdb7a11",
- "reference": "69fee1ad2332a7cbab3aca13591953da9cdb7a11",
+ "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/f98b54df6ad059855739db6fcbc2d36995283fe1",
+ "reference": "f98b54df6ad059855739db6fcbc2d36995283fe1",
"shasum": ""
},
"require": {
@@ -3096,7 +4044,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "2.4-dev"
+ "dev-main": "2.5-dev"
},
"thanks": {
"name": "symfony/contracts",
@@ -3132,24 +4080,43 @@
"interoperability",
"standards"
],
- "time": "2021-03-23T23:28:01+00:00"
+ "support": {
+ "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v2.5.1"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-01-02T09:53:40+00:00"
},
{
"name": "symfony/finder",
- "version": "v5.3.0",
+ "version": "v5.4.8",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
- "reference": "0ae3f047bed4edff6fd35b26a9a6bfdc92c953c6"
+ "reference": "9b630f3427f3ebe7cd346c277a1408b00249dad9"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/finder/zipball/0ae3f047bed4edff6fd35b26a9a6bfdc92c953c6",
- "reference": "0ae3f047bed4edff6fd35b26a9a6bfdc92c953c6",
+ "url": "https://api.github.com/repos/symfony/finder/zipball/9b630f3427f3ebe7cd346c277a1408b00249dad9",
+ "reference": "9b630f3427f3ebe7cd346c277a1408b00249dad9",
"shasum": ""
},
"require": {
- "php": ">=7.2.5"
+ "php": ">=7.2.5",
+ "symfony/deprecation-contracts": "^2.1|^3",
+ "symfony/polyfill-php80": "^1.16"
},
"type": "library",
"autoload": {
@@ -3176,94 +4143,50 @@
],
"description": "Finds files and directories via an intuitive fluent interface",
"homepage": "https://symfony.com",
- "time": "2021-05-26T12:52:38+00:00"
- },
- {
- "name": "symfony/http-client-contracts",
- "version": "v2.4.0",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/http-client-contracts.git",
- "reference": "7e82f6084d7cae521a75ef2cb5c9457bbda785f4"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/http-client-contracts/zipball/7e82f6084d7cae521a75ef2cb5c9457bbda785f4",
- "reference": "7e82f6084d7cae521a75ef2cb5c9457bbda785f4",
- "shasum": ""
+ "support": {
+ "source": "https://github.com/symfony/finder/tree/v5.4.8"
},
- "require": {
- "php": ">=7.2.5"
- },
- "suggest": {
- "symfony/http-client-implementation": ""
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-main": "2.4-dev"
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
},
- "thanks": {
- "name": "symfony/contracts",
- "url": "https://github.com/symfony/contracts"
- }
- },
- "autoload": {
- "psr-4": {
- "Symfony\\Contracts\\HttpClient\\": ""
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
{
- "name": "Nicolas Grekas",
- "email": "p@tchwork.com"
+ "url": "https://github.com/fabpot",
+ "type": "github"
},
{
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
}
],
- "description": "Generic abstractions related to HTTP clients",
- "homepage": "https://symfony.com",
- "keywords": [
- "abstractions",
- "contracts",
- "decoupling",
- "interfaces",
- "interoperability",
- "standards"
- ],
- "time": "2021-04-11T23:07:08+00:00"
+ "time": "2022-04-15T08:07:45+00:00"
},
{
"name": "symfony/http-foundation",
- "version": "v5.3.3",
+ "version": "v5.4.10",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-foundation.git",
- "reference": "0e45ab1574caa0460d9190871a8ce47539e40ccf"
+ "reference": "e7793b7906f72a8cc51054fbca9dcff7a8af1c1e"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/http-foundation/zipball/0e45ab1574caa0460d9190871a8ce47539e40ccf",
- "reference": "0e45ab1574caa0460d9190871a8ce47539e40ccf",
+ "url": "https://api.github.com/repos/symfony/http-foundation/zipball/e7793b7906f72a8cc51054fbca9dcff7a8af1c1e",
+ "reference": "e7793b7906f72a8cc51054fbca9dcff7a8af1c1e",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
- "symfony/deprecation-contracts": "^2.1",
+ "symfony/deprecation-contracts": "^2.1|^3",
"symfony/polyfill-mbstring": "~1.1",
- "symfony/polyfill-php80": "^1.15"
+ "symfony/polyfill-php80": "^1.16"
},
"require-dev": {
"predis/predis": "~1.0",
- "symfony/cache": "^4.4|^5.0",
- "symfony/expression-language": "^4.4|^5.0",
- "symfony/mime": "^4.4|^5.0"
+ "symfony/cache": "^4.4|^5.0|^6.0",
+ "symfony/expression-language": "^4.4|^5.0|^6.0",
+ "symfony/mime": "^4.4|^5.0|^6.0"
},
"suggest": {
"symfony/mime": "To use the file extension guesser"
@@ -3293,36 +4216,52 @@
],
"description": "Defines an object-oriented layer for the HTTP specification",
"homepage": "https://symfony.com",
- "time": "2021-06-27T09:19:40+00:00"
+ "support": {
+ "source": "https://github.com/symfony/http-foundation/tree/v5.4.10"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-06-19T13:13:40+00:00"
},
{
"name": "symfony/http-kernel",
- "version": "v5.3.3",
+ "version": "v5.4.10",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-kernel.git",
- "reference": "90ad9f4b21ddcb8ebe9faadfcca54929ad23f9f8"
+ "reference": "255ae3b0a488d78fbb34da23d3e0c059874b5948"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/http-kernel/zipball/90ad9f4b21ddcb8ebe9faadfcca54929ad23f9f8",
- "reference": "90ad9f4b21ddcb8ebe9faadfcca54929ad23f9f8",
+ "url": "https://api.github.com/repos/symfony/http-kernel/zipball/255ae3b0a488d78fbb34da23d3e0c059874b5948",
+ "reference": "255ae3b0a488d78fbb34da23d3e0c059874b5948",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
- "psr/log": "~1.0",
- "symfony/deprecation-contracts": "^2.1",
- "symfony/error-handler": "^4.4|^5.0",
- "symfony/event-dispatcher": "^5.0",
- "symfony/http-client-contracts": "^1.1|^2",
- "symfony/http-foundation": "^5.3",
+ "psr/log": "^1|^2",
+ "symfony/deprecation-contracts": "^2.1|^3",
+ "symfony/error-handler": "^4.4|^5.0|^6.0",
+ "symfony/event-dispatcher": "^5.0|^6.0",
+ "symfony/http-foundation": "^5.3.7|^6.0",
"symfony/polyfill-ctype": "^1.8",
"symfony/polyfill-php73": "^1.9",
- "symfony/polyfill-php80": "^1.15"
+ "symfony/polyfill-php80": "^1.16"
},
"conflict": {
- "symfony/browser-kit": "<4.4",
+ "symfony/browser-kit": "<5.4",
"symfony/cache": "<5.0",
"symfony/config": "<5.0",
"symfony/console": "<4.4",
@@ -3338,23 +4277,24 @@
"twig/twig": "<2.13"
},
"provide": {
- "psr/log-implementation": "1.0"
+ "psr/log-implementation": "1.0|2.0"
},
"require-dev": {
"psr/cache": "^1.0|^2.0|^3.0",
- "symfony/browser-kit": "^4.4|^5.0",
- "symfony/config": "^5.0",
- "symfony/console": "^4.4|^5.0",
- "symfony/css-selector": "^4.4|^5.0",
- "symfony/dependency-injection": "^5.3",
- "symfony/dom-crawler": "^4.4|^5.0",
- "symfony/expression-language": "^4.4|^5.0",
- "symfony/finder": "^4.4|^5.0",
- "symfony/process": "^4.4|^5.0",
- "symfony/routing": "^4.4|^5.0",
- "symfony/stopwatch": "^4.4|^5.0",
- "symfony/translation": "^4.4|^5.0",
- "symfony/translation-contracts": "^1.1|^2",
+ "symfony/browser-kit": "^5.4|^6.0",
+ "symfony/config": "^5.0|^6.0",
+ "symfony/console": "^4.4|^5.0|^6.0",
+ "symfony/css-selector": "^4.4|^5.0|^6.0",
+ "symfony/dependency-injection": "^5.3|^6.0",
+ "symfony/dom-crawler": "^4.4|^5.0|^6.0",
+ "symfony/expression-language": "^4.4|^5.0|^6.0",
+ "symfony/finder": "^4.4|^5.0|^6.0",
+ "symfony/http-client-contracts": "^1.1|^2|^3",
+ "symfony/process": "^4.4|^5.0|^6.0",
+ "symfony/routing": "^4.4|^5.0|^6.0",
+ "symfony/stopwatch": "^4.4|^5.0|^6.0",
+ "symfony/translation": "^4.4|^5.0|^6.0",
+ "symfony/translation-contracts": "^1.1|^2|^3",
"twig/twig": "^2.13|^3.0.4"
},
"suggest": {
@@ -3388,28 +4328,45 @@
],
"description": "Provides a structured process for converting a Request into a Response",
"homepage": "https://symfony.com",
- "time": "2021-06-30T08:27:49+00:00"
+ "support": {
+ "source": "https://github.com/symfony/http-kernel/tree/v5.4.10"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-06-26T16:57:59+00:00"
},
{
"name": "symfony/mime",
- "version": "v5.3.2",
+ "version": "v5.4.10",
"source": {
"type": "git",
"url": "https://github.com/symfony/mime.git",
- "reference": "47dd7912152b82d0d4c8d9040dbc93d6232d472a"
+ "reference": "02265e1e5111c3cd7480387af25e82378b7ab9cc"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/mime/zipball/47dd7912152b82d0d4c8d9040dbc93d6232d472a",
- "reference": "47dd7912152b82d0d4c8d9040dbc93d6232d472a",
+ "url": "https://api.github.com/repos/symfony/mime/zipball/02265e1e5111c3cd7480387af25e82378b7ab9cc",
+ "reference": "02265e1e5111c3cd7480387af25e82378b7ab9cc",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
- "symfony/deprecation-contracts": "^2.1",
+ "symfony/deprecation-contracts": "^2.1|^3",
"symfony/polyfill-intl-idn": "^1.10",
"symfony/polyfill-mbstring": "^1.0",
- "symfony/polyfill-php80": "^1.15"
+ "symfony/polyfill-php80": "^1.16"
},
"conflict": {
"egulias/email-validator": "~3.0.0",
@@ -3420,10 +4377,10 @@
"require-dev": {
"egulias/email-validator": "^2.1.10|^3.1",
"phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0",
- "symfony/dependency-injection": "^4.4|^5.0",
- "symfony/property-access": "^4.4|^5.1",
- "symfony/property-info": "^4.4|^5.1",
- "symfony/serializer": "^5.2"
+ "symfony/dependency-injection": "^4.4|^5.0|^6.0",
+ "symfony/property-access": "^4.4|^5.1|^6.0",
+ "symfony/property-info": "^4.4|^5.1|^6.0",
+ "symfony/serializer": "^5.2|^6.0"
},
"type": "library",
"autoload": {
@@ -3454,32 +4411,52 @@
"mime",
"mime-type"
],
- "time": "2021-06-09T10:58:01+00:00"
+ "support": {
+ "source": "https://github.com/symfony/mime/tree/v5.4.10"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-06-09T12:22:40+00:00"
},
{
"name": "symfony/polyfill-ctype",
- "version": "v1.23.0",
+ "version": "v1.26.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
- "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce"
+ "reference": "6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/46cd95797e9df938fdd2b03693b5fca5e64b01ce",
- "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce",
+ "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4",
+ "reference": "6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
+ "provide": {
+ "ext-ctype": "*"
+ },
"suggest": {
"ext-ctype": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "1.23-dev"
+ "dev-main": "1.26-dev"
},
"thanks": {
"name": "symfony/polyfill",
@@ -3487,12 +4464,12 @@
}
},
"autoload": {
- "psr-4": {
- "Symfony\\Polyfill\\Ctype\\": ""
- },
"files": [
"bootstrap.php"
- ]
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Ctype\\": ""
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -3516,32 +4493,52 @@
"polyfill",
"portable"
],
- "time": "2021-02-19T12:13:01+00:00"
+ "support": {
+ "source": "https://github.com/symfony/polyfill-ctype/tree/v1.26.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-05-24T11:49:31+00:00"
},
{
"name": "symfony/polyfill-iconv",
- "version": "v1.23.0",
+ "version": "v1.26.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-iconv.git",
- "reference": "63b5bb7db83e5673936d6e3b8b3e022ff6474933"
+ "reference": "143f1881e655bebca1312722af8068de235ae5dc"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/63b5bb7db83e5673936d6e3b8b3e022ff6474933",
- "reference": "63b5bb7db83e5673936d6e3b8b3e022ff6474933",
+ "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/143f1881e655bebca1312722af8068de235ae5dc",
+ "reference": "143f1881e655bebca1312722af8068de235ae5dc",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
+ "provide": {
+ "ext-iconv": "*"
+ },
"suggest": {
"ext-iconv": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "1.23-dev"
+ "dev-main": "1.26-dev"
},
"thanks": {
"name": "symfony/polyfill",
@@ -3549,12 +4546,12 @@
}
},
"autoload": {
- "psr-4": {
- "Symfony\\Polyfill\\Iconv\\": ""
- },
"files": [
"bootstrap.php"
- ]
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Iconv\\": ""
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -3579,20 +4576,37 @@
"portable",
"shim"
],
- "time": "2021-05-27T09:27:20+00:00"
+ "support": {
+ "source": "https://github.com/symfony/polyfill-iconv/tree/v1.26.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-05-24T11:49:31+00:00"
},
{
"name": "symfony/polyfill-intl-grapheme",
- "version": "v1.23.0",
+ "version": "v1.26.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-grapheme.git",
- "reference": "24b72c6baa32c746a4d0840147c9715e42bb68ab"
+ "reference": "433d05519ce6990bf3530fba6957499d327395c2"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/24b72c6baa32c746a4d0840147c9715e42bb68ab",
- "reference": "24b72c6baa32c746a4d0840147c9715e42bb68ab",
+ "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/433d05519ce6990bf3530fba6957499d327395c2",
+ "reference": "433d05519ce6990bf3530fba6957499d327395c2",
"shasum": ""
},
"require": {
@@ -3604,7 +4618,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "1.23-dev"
+ "dev-main": "1.26-dev"
},
"thanks": {
"name": "symfony/polyfill",
@@ -3612,12 +4626,12 @@
}
},
"autoload": {
- "psr-4": {
- "Symfony\\Polyfill\\Intl\\Grapheme\\": ""
- },
"files": [
"bootstrap.php"
- ]
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Intl\\Grapheme\\": ""
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -3643,20 +4657,37 @@
"portable",
"shim"
],
- "time": "2021-05-27T09:17:38+00:00"
+ "support": {
+ "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.26.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-05-24T11:49:31+00:00"
},
{
"name": "symfony/polyfill-intl-idn",
- "version": "v1.23.0",
+ "version": "v1.26.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-idn.git",
- "reference": "65bd267525e82759e7d8c4e8ceea44f398838e65"
+ "reference": "59a8d271f00dd0e4c2e518104cc7963f655a1aa8"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/65bd267525e82759e7d8c4e8ceea44f398838e65",
- "reference": "65bd267525e82759e7d8c4e8ceea44f398838e65",
+ "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/59a8d271f00dd0e4c2e518104cc7963f655a1aa8",
+ "reference": "59a8d271f00dd0e4c2e518104cc7963f655a1aa8",
"shasum": ""
},
"require": {
@@ -3670,7 +4701,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "1.23-dev"
+ "dev-main": "1.26-dev"
},
"thanks": {
"name": "symfony/polyfill",
@@ -3678,12 +4709,12 @@
}
},
"autoload": {
- "psr-4": {
- "Symfony\\Polyfill\\Intl\\Idn\\": ""
- },
"files": [
"bootstrap.php"
- ]
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Intl\\Idn\\": ""
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -3713,20 +4744,37 @@
"portable",
"shim"
],
- "time": "2021-05-27T09:27:20+00:00"
+ "support": {
+ "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.26.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-05-24T11:49:31+00:00"
},
{
"name": "symfony/polyfill-intl-normalizer",
- "version": "v1.23.0",
+ "version": "v1.26.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-normalizer.git",
- "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8"
+ "reference": "219aa369ceff116e673852dce47c3a41794c14bd"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8590a5f561694770bdcd3f9b5c69dde6945028e8",
- "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8",
+ "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/219aa369ceff116e673852dce47c3a41794c14bd",
+ "reference": "219aa369ceff116e673852dce47c3a41794c14bd",
"shasum": ""
},
"require": {
@@ -3738,7 +4786,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "1.23-dev"
+ "dev-main": "1.26-dev"
},
"thanks": {
"name": "symfony/polyfill",
@@ -3746,12 +4794,12 @@
}
},
"autoload": {
- "psr-4": {
- "Symfony\\Polyfill\\Intl\\Normalizer\\": ""
- },
"files": [
"bootstrap.php"
],
+ "psr-4": {
+ "Symfony\\Polyfill\\Intl\\Normalizer\\": ""
+ },
"classmap": [
"Resources/stubs"
]
@@ -3780,32 +4828,52 @@
"portable",
"shim"
],
- "time": "2021-02-19T12:13:01+00:00"
+ "support": {
+ "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.26.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-05-24T11:49:31+00:00"
},
{
"name": "symfony/polyfill-mbstring",
- "version": "v1.23.0",
+ "version": "v1.26.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
- "reference": "2df51500adbaebdc4c38dea4c89a2e131c45c8a1"
+ "reference": "9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/2df51500adbaebdc4c38dea4c89a2e131c45c8a1",
- "reference": "2df51500adbaebdc4c38dea4c89a2e131c45c8a1",
+ "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e",
+ "reference": "9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
+ "provide": {
+ "ext-mbstring": "*"
+ },
"suggest": {
"ext-mbstring": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "1.23-dev"
+ "dev-main": "1.26-dev"
},
"thanks": {
"name": "symfony/polyfill",
@@ -3813,12 +4881,12 @@
}
},
"autoload": {
- "psr-4": {
- "Symfony\\Polyfill\\Mbstring\\": ""
- },
"files": [
"bootstrap.php"
- ]
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Mbstring\\": ""
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -3843,20 +4911,37 @@
"portable",
"shim"
],
- "time": "2021-05-27T09:27:20+00:00"
+ "support": {
+ "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.26.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-05-24T11:49:31+00:00"
},
{
"name": "symfony/polyfill-php72",
- "version": "v1.23.0",
+ "version": "v1.26.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php72.git",
- "reference": "9a142215a36a3888e30d0a9eeea9766764e96976"
+ "reference": "bf44a9fd41feaac72b074de600314a93e2ae78e2"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/9a142215a36a3888e30d0a9eeea9766764e96976",
- "reference": "9a142215a36a3888e30d0a9eeea9766764e96976",
+ "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/bf44a9fd41feaac72b074de600314a93e2ae78e2",
+ "reference": "bf44a9fd41feaac72b074de600314a93e2ae78e2",
"shasum": ""
},
"require": {
@@ -3865,7 +4950,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "1.23-dev"
+ "dev-main": "1.26-dev"
},
"thanks": {
"name": "symfony/polyfill",
@@ -3873,12 +4958,12 @@
}
},
"autoload": {
- "psr-4": {
- "Symfony\\Polyfill\\Php72\\": ""
- },
"files": [
"bootstrap.php"
- ]
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Php72\\": ""
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -3902,20 +4987,37 @@
"portable",
"shim"
],
- "time": "2021-05-27T09:17:38+00:00"
+ "support": {
+ "source": "https://github.com/symfony/polyfill-php72/tree/v1.26.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-05-24T11:49:31+00:00"
},
{
"name": "symfony/polyfill-php73",
- "version": "v1.23.0",
+ "version": "v1.26.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php73.git",
- "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010"
+ "reference": "e440d35fa0286f77fb45b79a03fedbeda9307e85"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fba8933c384d6476ab14fb7b8526e5287ca7e010",
- "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010",
+ "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/e440d35fa0286f77fb45b79a03fedbeda9307e85",
+ "reference": "e440d35fa0286f77fb45b79a03fedbeda9307e85",
"shasum": ""
},
"require": {
@@ -3924,7 +5026,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "1.23-dev"
+ "dev-main": "1.26-dev"
},
"thanks": {
"name": "symfony/polyfill",
@@ -3932,12 +5034,12 @@
}
},
"autoload": {
- "psr-4": {
- "Symfony\\Polyfill\\Php73\\": ""
- },
"files": [
"bootstrap.php"
],
+ "psr-4": {
+ "Symfony\\Polyfill\\Php73\\": ""
+ },
"classmap": [
"Resources/stubs"
]
@@ -3964,20 +5066,37 @@
"portable",
"shim"
],
- "time": "2021-02-19T12:13:01+00:00"
+ "support": {
+ "source": "https://github.com/symfony/polyfill-php73/tree/v1.26.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-05-24T11:49:31+00:00"
},
{
"name": "symfony/polyfill-php80",
- "version": "v1.23.0",
+ "version": "v1.26.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php80.git",
- "reference": "eca0bf41ed421bed1b57c4958bab16aa86b757d0"
+ "reference": "cfa0ae98841b9e461207c13ab093d76b0fa7bace"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/eca0bf41ed421bed1b57c4958bab16aa86b757d0",
- "reference": "eca0bf41ed421bed1b57c4958bab16aa86b757d0",
+ "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/cfa0ae98841b9e461207c13ab093d76b0fa7bace",
+ "reference": "cfa0ae98841b9e461207c13ab093d76b0fa7bace",
"shasum": ""
},
"require": {
@@ -3986,7 +5105,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "1.23-dev"
+ "dev-main": "1.26-dev"
},
"thanks": {
"name": "symfony/polyfill",
@@ -3994,12 +5113,12 @@
}
},
"autoload": {
- "psr-4": {
- "Symfony\\Polyfill\\Php80\\": ""
- },
"files": [
"bootstrap.php"
],
+ "psr-4": {
+ "Symfony\\Polyfill\\Php80\\": ""
+ },
"classmap": [
"Resources/stubs"
]
@@ -4030,25 +5149,121 @@
"portable",
"shim"
],
- "time": "2021-02-19T12:13:01+00:00"
+ "support": {
+ "source": "https://github.com/symfony/polyfill-php80/tree/v1.26.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-05-10T07:21:04+00:00"
+ },
+ {
+ "name": "symfony/polyfill-php81",
+ "version": "v1.26.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-php81.git",
+ "reference": "13f6d1271c663dc5ae9fb843a8f16521db7687a1"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/13f6d1271c663dc5ae9fb843a8f16521db7687a1",
+ "reference": "13f6d1271c663dc5ae9fb843a8f16521db7687a1",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.1"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "1.26-dev"
+ },
+ "thanks": {
+ "name": "symfony/polyfill",
+ "url": "https://github.com/symfony/polyfill"
+ }
+ },
+ "autoload": {
+ "files": [
+ "bootstrap.php"
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Php81\\": ""
+ },
+ "classmap": [
+ "Resources/stubs"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "polyfill",
+ "portable",
+ "shim"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/polyfill-php81/tree/v1.26.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-05-24T11:49:31+00:00"
},
{
"name": "symfony/process",
- "version": "v5.3.2",
+ "version": "v5.4.8",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
- "reference": "714b47f9196de61a196d86c4bad5f09201b307df"
+ "reference": "597f3fff8e3e91836bb0bd38f5718b56ddbde2f3"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/process/zipball/714b47f9196de61a196d86c4bad5f09201b307df",
- "reference": "714b47f9196de61a196d86c4bad5f09201b307df",
+ "url": "https://api.github.com/repos/symfony/process/zipball/597f3fff8e3e91836bb0bd38f5718b56ddbde2f3",
+ "reference": "597f3fff8e3e91836bb0bd38f5718b56ddbde2f3",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
- "symfony/polyfill-php80": "^1.15"
+ "symfony/polyfill-php80": "^1.16"
},
"type": "library",
"autoload": {
@@ -4075,26 +5290,43 @@
],
"description": "Executes commands in sub-processes",
"homepage": "https://symfony.com",
- "time": "2021-06-12T10:15:01+00:00"
+ "support": {
+ "source": "https://github.com/symfony/process/tree/v5.4.8"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-04-08T05:07:18+00:00"
},
{
"name": "symfony/routing",
- "version": "v5.3.0",
+ "version": "v5.4.8",
"source": {
"type": "git",
"url": "https://github.com/symfony/routing.git",
- "reference": "368e81376a8e049c37cb80ae87dbfbf411279199"
+ "reference": "e07817bb6244ea33ef5ad31abc4a9288bef3f2f7"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/routing/zipball/368e81376a8e049c37cb80ae87dbfbf411279199",
- "reference": "368e81376a8e049c37cb80ae87dbfbf411279199",
+ "url": "https://api.github.com/repos/symfony/routing/zipball/e07817bb6244ea33ef5ad31abc4a9288bef3f2f7",
+ "reference": "e07817bb6244ea33ef5ad31abc4a9288bef3f2f7",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
- "symfony/deprecation-contracts": "^2.1",
- "symfony/polyfill-php80": "^1.15"
+ "symfony/deprecation-contracts": "^2.1|^3",
+ "symfony/polyfill-php80": "^1.16"
},
"conflict": {
"doctrine/annotations": "<1.12",
@@ -4104,12 +5336,12 @@
},
"require-dev": {
"doctrine/annotations": "^1.12",
- "psr/log": "~1.0",
- "symfony/config": "^5.3",
- "symfony/dependency-injection": "^4.4|^5.0",
- "symfony/expression-language": "^4.4|^5.0",
- "symfony/http-foundation": "^4.4|^5.0",
- "symfony/yaml": "^4.4|^5.0"
+ "psr/log": "^1|^2|^3",
+ "symfony/config": "^5.3|^6.0",
+ "symfony/dependency-injection": "^4.4|^5.0|^6.0",
+ "symfony/expression-language": "^4.4|^5.0|^6.0",
+ "symfony/http-foundation": "^4.4|^5.0|^6.0",
+ "symfony/yaml": "^4.4|^5.0|^6.0"
},
"suggest": {
"symfony/config": "For using the all-in-one router or any loader",
@@ -4148,25 +5380,46 @@
"uri",
"url"
],
- "time": "2021-05-26T17:43:10+00:00"
+ "support": {
+ "source": "https://github.com/symfony/routing/tree/v5.4.8"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-04-18T21:45:37+00:00"
},
{
"name": "symfony/service-contracts",
- "version": "v2.4.0",
+ "version": "v2.5.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/service-contracts.git",
- "reference": "f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb"
+ "reference": "24d9dc654b83e91aa59f9d167b131bc3b5bea24c"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/service-contracts/zipball/f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb",
- "reference": "f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb",
+ "url": "https://api.github.com/repos/symfony/service-contracts/zipball/24d9dc654b83e91aa59f9d167b131bc3b5bea24c",
+ "reference": "24d9dc654b83e91aa59f9d167b131bc3b5bea24c",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
- "psr/container": "^1.1"
+ "psr/container": "^1.1",
+ "symfony/deprecation-contracts": "^2.1|^3"
+ },
+ "conflict": {
+ "ext-psr": "<1.1|>=2"
},
"suggest": {
"symfony/service-implementation": ""
@@ -4174,7 +5427,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "2.4-dev"
+ "dev-main": "2.5-dev"
},
"thanks": {
"name": "symfony/contracts",
@@ -4210,20 +5463,37 @@
"interoperability",
"standards"
],
- "time": "2021-04-01T10:43:52+00:00"
+ "support": {
+ "source": "https://github.com/symfony/service-contracts/tree/v2.5.1"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-03-13T20:07:29+00:00"
},
{
"name": "symfony/string",
- "version": "v5.3.3",
+ "version": "v5.4.10",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
- "reference": "bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1"
+ "reference": "4432bc7df82a554b3e413a8570ce2fea90e94097"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/string/zipball/bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1",
- "reference": "bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1",
+ "url": "https://api.github.com/repos/symfony/string/zipball/4432bc7df82a554b3e413a8570ce2fea90e94097",
+ "reference": "4432bc7df82a554b3e413a8570ce2fea90e94097",
"shasum": ""
},
"require": {
@@ -4234,20 +5504,23 @@
"symfony/polyfill-mbstring": "~1.0",
"symfony/polyfill-php80": "~1.15"
},
+ "conflict": {
+ "symfony/translation-contracts": ">=3.0"
+ },
"require-dev": {
- "symfony/error-handler": "^4.4|^5.0",
- "symfony/http-client": "^4.4|^5.0",
+ "symfony/error-handler": "^4.4|^5.0|^6.0",
+ "symfony/http-client": "^4.4|^5.0|^6.0",
"symfony/translation-contracts": "^1.1|^2",
- "symfony/var-exporter": "^4.4|^5.0"
+ "symfony/var-exporter": "^4.4|^5.0|^6.0"
},
"type": "library",
"autoload": {
- "psr-4": {
- "Symfony\\Component\\String\\": ""
- },
"files": [
"Resources/functions.php"
],
+ "psr-4": {
+ "Symfony\\Component\\String\\": ""
+ },
"exclude-from-classmap": [
"/Tests/"
]
@@ -4276,31 +5549,49 @@
"utf-8",
"utf8"
],
- "time": "2021-06-27T11:44:38+00:00"
+ "support": {
+ "source": "https://github.com/symfony/string/tree/v5.4.10"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-06-26T15:57:47+00:00"
},
{
"name": "symfony/translation",
- "version": "v5.3.3",
+ "version": "v5.4.9",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation.git",
- "reference": "380b8c9e944d0e364b25f28e8e555241eb49c01c"
+ "reference": "1639abc1177d26bcd4320e535e664cef067ab0ca"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/translation/zipball/380b8c9e944d0e364b25f28e8e555241eb49c01c",
- "reference": "380b8c9e944d0e364b25f28e8e555241eb49c01c",
+ "url": "https://api.github.com/repos/symfony/translation/zipball/1639abc1177d26bcd4320e535e664cef067ab0ca",
+ "reference": "1639abc1177d26bcd4320e535e664cef067ab0ca",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
- "symfony/deprecation-contracts": "^2.1",
+ "symfony/deprecation-contracts": "^2.1|^3",
"symfony/polyfill-mbstring": "~1.0",
- "symfony/polyfill-php80": "^1.15",
+ "symfony/polyfill-php80": "^1.16",
"symfony/translation-contracts": "^2.3"
},
"conflict": {
"symfony/config": "<4.4",
+ "symfony/console": "<5.3",
"symfony/dependency-injection": "<5.0",
"symfony/http-kernel": "<5.0",
"symfony/twig-bundle": "<5.0",
@@ -4310,16 +5601,17 @@
"symfony/translation-implementation": "2.3"
},
"require-dev": {
- "psr/log": "~1.0",
- "symfony/config": "^4.4|^5.0",
- "symfony/console": "^4.4|^5.0",
- "symfony/dependency-injection": "^5.0",
- "symfony/finder": "^4.4|^5.0",
- "symfony/http-kernel": "^5.0",
- "symfony/intl": "^4.4|^5.0",
+ "psr/log": "^1|^2|^3",
+ "symfony/config": "^4.4|^5.0|^6.0",
+ "symfony/console": "^5.4|^6.0",
+ "symfony/dependency-injection": "^5.0|^6.0",
+ "symfony/finder": "^4.4|^5.0|^6.0",
+ "symfony/http-client-contracts": "^1.1|^2.0|^3.0",
+ "symfony/http-kernel": "^5.0|^6.0",
+ "symfony/intl": "^4.4|^5.0|^6.0",
"symfony/polyfill-intl-icu": "^1.21",
- "symfony/service-contracts": "^1.1.2|^2",
- "symfony/yaml": "^4.4|^5.0"
+ "symfony/service-contracts": "^1.1.2|^2|^3",
+ "symfony/yaml": "^4.4|^5.0|^6.0"
},
"suggest": {
"psr/log-implementation": "To use logging capability in translator",
@@ -4354,20 +5646,37 @@
],
"description": "Provides tools to internationalize your application",
"homepage": "https://symfony.com",
- "time": "2021-06-27T12:22:47+00:00"
+ "support": {
+ "source": "https://github.com/symfony/translation/tree/v5.4.9"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-05-06T12:33:37+00:00"
},
{
"name": "symfony/translation-contracts",
- "version": "v2.4.0",
+ "version": "v2.5.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation-contracts.git",
- "reference": "95c812666f3e91db75385749fe219c5e494c7f95"
+ "reference": "1211df0afa701e45a04253110e959d4af4ef0f07"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/95c812666f3e91db75385749fe219c5e494c7f95",
- "reference": "95c812666f3e91db75385749fe219c5e494c7f95",
+ "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/1211df0afa701e45a04253110e959d4af4ef0f07",
+ "reference": "1211df0afa701e45a04253110e959d4af4ef0f07",
"shasum": ""
},
"require": {
@@ -4379,7 +5688,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "2.4-dev"
+ "dev-main": "2.5-dev"
},
"thanks": {
"name": "symfony/contracts",
@@ -4415,26 +5724,43 @@
"interoperability",
"standards"
],
- "time": "2021-03-23T23:28:01+00:00"
+ "support": {
+ "source": "https://github.com/symfony/translation-contracts/tree/v2.5.1"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-01-02T09:53:40+00:00"
},
{
"name": "symfony/var-dumper",
- "version": "v5.3.3",
+ "version": "v5.4.9",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-dumper.git",
- "reference": "46aa709affb9ad3355bd7a810f9662d71025c384"
+ "reference": "af52239a330fafd192c773795520dc2dd62b5657"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/var-dumper/zipball/46aa709affb9ad3355bd7a810f9662d71025c384",
- "reference": "46aa709affb9ad3355bd7a810f9662d71025c384",
+ "url": "https://api.github.com/repos/symfony/var-dumper/zipball/af52239a330fafd192c773795520dc2dd62b5657",
+ "reference": "af52239a330fafd192c773795520dc2dd62b5657",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
"symfony/polyfill-mbstring": "~1.0",
- "symfony/polyfill-php80": "^1.15"
+ "symfony/polyfill-php80": "^1.16"
},
"conflict": {
"phpunit/phpunit": "<5.4.3",
@@ -4442,8 +5768,9 @@
},
"require-dev": {
"ext-iconv": "*",
- "symfony/console": "^4.4|^5.0",
- "symfony/process": "^4.4|^5.0",
+ "symfony/console": "^4.4|^5.0|^6.0",
+ "symfony/process": "^4.4|^5.0|^6.0",
+ "symfony/uid": "^5.1|^6.0",
"twig/twig": "^2.13|^3.0.4"
},
"suggest": {
@@ -4486,30 +5813,47 @@
"debug",
"dump"
],
- "time": "2021-06-24T08:13:00+00:00"
+ "support": {
+ "source": "https://github.com/symfony/var-dumper/tree/v5.4.9"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-05-21T10:24:18+00:00"
},
{
"name": "tijsverkoyen/css-to-inline-styles",
- "version": "2.2.3",
+ "version": "2.2.4",
"source": {
"type": "git",
"url": "https://github.com/tijsverkoyen/CssToInlineStyles.git",
- "reference": "b43b05cf43c1b6d849478965062b6ef73e223bb5"
+ "reference": "da444caae6aca7a19c0c140f68c6182e337d5b1c"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/tijsverkoyen/CssToInlineStyles/zipball/b43b05cf43c1b6d849478965062b6ef73e223bb5",
- "reference": "b43b05cf43c1b6d849478965062b6ef73e223bb5",
+ "url": "https://api.github.com/repos/tijsverkoyen/CssToInlineStyles/zipball/da444caae6aca7a19c0c140f68c6182e337d5b1c",
+ "reference": "da444caae6aca7a19c0c140f68c6182e337d5b1c",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-libxml": "*",
"php": "^5.5 || ^7.0 || ^8.0",
- "symfony/css-selector": "^2.7 || ^3.0 || ^4.0 || ^5.0"
+ "symfony/css-selector": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0"
},
"require-dev": {
- "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0 || ^7.5"
+ "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0 || ^7.5 || ^8.5.21 || ^9.5.10"
},
"type": "library",
"extra": {
@@ -4535,35 +5879,39 @@
],
"description": "CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very useful when you're sending emails.",
"homepage": "https://github.com/tijsverkoyen/CssToInlineStyles",
- "time": "2020-07-13T06:12:54+00:00"
+ "support": {
+ "issues": "https://github.com/tijsverkoyen/CssToInlineStyles/issues",
+ "source": "https://github.com/tijsverkoyen/CssToInlineStyles/tree/2.2.4"
+ },
+ "time": "2021-12-08T09:12:39+00:00"
},
{
"name": "vlucas/phpdotenv",
- "version": "v5.3.0",
+ "version": "v5.4.1",
"source": {
"type": "git",
"url": "https://github.com/vlucas/phpdotenv.git",
- "reference": "b3eac5c7ac896e52deab4a99068e3f4ab12d9e56"
+ "reference": "264dce589e7ce37a7ba99cb901eed8249fbec92f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/b3eac5c7ac896e52deab4a99068e3f4ab12d9e56",
- "reference": "b3eac5c7ac896e52deab4a99068e3f4ab12d9e56",
+ "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/264dce589e7ce37a7ba99cb901eed8249fbec92f",
+ "reference": "264dce589e7ce37a7ba99cb901eed8249fbec92f",
"shasum": ""
},
"require": {
"ext-pcre": "*",
- "graham-campbell/result-type": "^1.0.1",
+ "graham-campbell/result-type": "^1.0.2",
"php": "^7.1.3 || ^8.0",
- "phpoption/phpoption": "^1.7.4",
- "symfony/polyfill-ctype": "^1.17",
- "symfony/polyfill-mbstring": "^1.17",
- "symfony/polyfill-php80": "^1.17"
+ "phpoption/phpoption": "^1.8",
+ "symfony/polyfill-ctype": "^1.23",
+ "symfony/polyfill-mbstring": "^1.23.1",
+ "symfony/polyfill-php80": "^1.23.1"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.4.1",
"ext-filter": "*",
- "phpunit/phpunit": "^7.5.20 || ^8.5.14 || ^9.5.1"
+ "phpunit/phpunit": "^7.5.20 || ^8.5.21 || ^9.5.10"
},
"suggest": {
"ext-filter": "Required to use the boolean validator."
@@ -4571,7 +5919,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "5.3-dev"
+ "dev-master": "5.4-dev"
}
},
"autoload": {
@@ -4586,13 +5934,13 @@
"authors": [
{
"name": "Graham Campbell",
- "email": "graham@alt-three.com",
- "homepage": "https://gjcampbell.co.uk/"
+ "email": "hello@gjcampbell.co.uk",
+ "homepage": "https://github.com/GrahamCampbell"
},
{
"name": "Vance Lucas",
"email": "vance@vancelucas.com",
- "homepage": "https://vancelucas.com/"
+ "homepage": "https://github.com/vlucas"
}
],
"description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.",
@@ -4601,20 +5949,34 @@
"env",
"environment"
],
- "time": "2021-01-20T15:23:13+00:00"
+ "support": {
+ "issues": "https://github.com/vlucas/phpdotenv/issues",
+ "source": "https://github.com/vlucas/phpdotenv/tree/v5.4.1"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/GrahamCampbell",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2021-12-12T23:22:04+00:00"
},
{
"name": "voku/portable-ascii",
- "version": "1.5.6",
+ "version": "1.6.1",
"source": {
"type": "git",
"url": "https://github.com/voku/portable-ascii.git",
- "reference": "80953678b19901e5165c56752d087fc11526017c"
+ "reference": "87337c91b9dfacee02452244ee14ab3c43bc485a"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/voku/portable-ascii/zipball/80953678b19901e5165c56752d087fc11526017c",
- "reference": "80953678b19901e5165c56752d087fc11526017c",
+ "url": "https://api.github.com/repos/voku/portable-ascii/zipball/87337c91b9dfacee02452244ee14ab3c43bc485a",
+ "reference": "87337c91b9dfacee02452244ee14ab3c43bc485a",
"shasum": ""
},
"require": {
@@ -4649,25 +6011,99 @@
"clean",
"php"
],
- "time": "2020-11-12T00:07:28+00:00"
+ "support": {
+ "issues": "https://github.com/voku/portable-ascii/issues",
+ "source": "https://github.com/voku/portable-ascii/tree/1.6.1"
+ },
+ "funding": [
+ {
+ "url": "https://www.paypal.me/moelleken",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/voku",
+ "type": "github"
+ },
+ {
+ "url": "https://opencollective.com/portable-ascii",
+ "type": "open_collective"
+ },
+ {
+ "url": "https://www.patreon.com/voku",
+ "type": "patreon"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/voku/portable-ascii",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-01-24T18:55:24+00:00"
+ },
+ {
+ "name": "watson/rememberable",
+ "version": "5.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/dwightwatson/rememberable.git",
+ "reference": "34a52524601e14d5742c7a4cbbda443a73e12cf7"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/dwightwatson/rememberable/zipball/34a52524601e14d5742c7a4cbbda443a73e12cf7",
+ "reference": "34a52524601e14d5742c7a4cbbda443a73e12cf7",
+ "shasum": ""
+ },
+ "require": {
+ "illuminate/database": "^8.0",
+ "illuminate/support": "^8.0",
+ "php": "^7.3|^8.0"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Watson\\Rememberable\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Dwight Watson",
+ "email": "dwight@studiousapp.com"
+ }
+ ],
+ "description": "Query caching for Laravel",
+ "keywords": [
+ "caching",
+ "eloquent",
+ "laravel",
+ "remember"
+ ],
+ "support": {
+ "issues": "https://github.com/dwightwatson/rememberable/issues",
+ "source": "https://github.com/dwightwatson/rememberable/tree/5.0.1"
+ },
+ "time": "2020-11-19T22:25:47+00:00"
},
{
"name": "webmozart/assert",
- "version": "1.10.0",
+ "version": "1.11.0",
"source": {
"type": "git",
"url": "https://github.com/webmozarts/assert.git",
- "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25"
+ "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/webmozarts/assert/zipball/6964c76c7804814a842473e0c8fd15bab0f18e25",
- "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25",
+ "url": "https://api.github.com/repos/webmozarts/assert/zipball/11cb2199493b2f8a3b53e7f19068fc6aac760991",
+ "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991",
"shasum": ""
},
"require": {
- "php": "^7.2 || ^8.0",
- "symfony/polyfill-ctype": "^1.8"
+ "ext-ctype": "*",
+ "php": "^7.2 || ^8.0"
},
"conflict": {
"phpstan/phpstan": "<0.12.20",
@@ -4703,46 +6139,63 @@
"check",
"validate"
],
- "time": "2021-03-09T10:59:23+00:00"
+ "support": {
+ "issues": "https://github.com/webmozarts/assert/issues",
+ "source": "https://github.com/webmozarts/assert/tree/1.11.0"
+ },
+ "time": "2022-06-03T18:03:27+00:00"
}
],
"packages-dev": [
{
- "name": "composer/package-versions-deprecated",
- "version": "1.11.99.2",
+ "name": "barryvdh/laravel-debugbar",
+ "version": "v3.6.7",
"source": {
"type": "git",
- "url": "https://github.com/composer/package-versions-deprecated.git",
- "reference": "c6522afe5540d5fc46675043d3ed5a45a740b27c"
+ "url": "https://github.com/barryvdh/laravel-debugbar.git",
+ "reference": "b96f9820aaf1ff9afe945207883149e1c7afb298"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/c6522afe5540d5fc46675043d3ed5a45a740b27c",
- "reference": "c6522afe5540d5fc46675043d3ed5a45a740b27c",
+ "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/b96f9820aaf1ff9afe945207883149e1c7afb298",
+ "reference": "b96f9820aaf1ff9afe945207883149e1c7afb298",
"shasum": ""
},
"require": {
- "composer-plugin-api": "^1.1.0 || ^2.0",
- "php": "^7 || ^8"
- },
- "replace": {
- "ocramius/package-versions": "1.11.99"
+ "illuminate/routing": "^6|^7|^8|^9",
+ "illuminate/session": "^6|^7|^8|^9",
+ "illuminate/support": "^6|^7|^8|^9",
+ "maximebf/debugbar": "^1.17.2",
+ "php": ">=7.2",
+ "symfony/debug": "^4.3|^5|^6",
+ "symfony/finder": "^4.3|^5|^6"
},
"require-dev": {
- "composer/composer": "^1.9.3 || ^2.0@dev",
- "ext-zip": "^1.13",
- "phpunit/phpunit": "^6.5 || ^7"
+ "mockery/mockery": "^1.3.3",
+ "orchestra/testbench-dusk": "^4|^5|^6|^7",
+ "phpunit/phpunit": "^8.5|^9.0",
+ "squizlabs/php_codesniffer": "^3.5"
},
- "type": "composer-plugin",
+ "type": "library",
"extra": {
- "class": "PackageVersions\\Installer",
"branch-alias": {
- "dev-master": "1.x-dev"
+ "dev-master": "3.6-dev"
+ },
+ "laravel": {
+ "providers": [
+ "Barryvdh\\Debugbar\\ServiceProvider"
+ ],
+ "aliases": {
+ "Debugbar": "Barryvdh\\Debugbar\\Facades\\Debugbar"
+ }
}
},
"autoload": {
+ "files": [
+ "src/helpers.php"
+ ],
"psr-4": {
- "PackageVersions\\": "src/PackageVersions"
+ "Barryvdh\\Debugbar\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
@@ -4751,50 +6204,61 @@
],
"authors": [
{
- "name": "Marco Pivetta",
- "email": "ocramius@gmail.com"
+ "name": "Barry vd. Heuvel",
+ "email": "barryvdh@gmail.com"
+ }
+ ],
+ "description": "PHP Debugbar integration for Laravel",
+ "keywords": [
+ "debug",
+ "debugbar",
+ "laravel",
+ "profiler",
+ "webprofiler"
+ ],
+ "support": {
+ "issues": "https://github.com/barryvdh/laravel-debugbar/issues",
+ "source": "https://github.com/barryvdh/laravel-debugbar/tree/v3.6.7"
+ },
+ "funding": [
+ {
+ "url": "https://fruitcake.nl",
+ "type": "custom"
},
{
- "name": "Jordi Boggiano",
- "email": "j.boggiano@seld.be"
+ "url": "https://github.com/barryvdh",
+ "type": "github"
}
],
- "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)",
- "time": "2021-05-24T07:46:03+00:00"
+ "time": "2022-02-09T07:52:32+00:00"
},
{
"name": "doctrine/cache",
- "version": "2.0.3",
+ "version": "2.2.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/cache.git",
- "reference": "c9622c6820d3ede1e2315a6a377ea1076e421d88"
+ "reference": "1ca8f21980e770095a31456042471a57bc4c68fb"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/doctrine/cache/zipball/c9622c6820d3ede1e2315a6a377ea1076e421d88",
- "reference": "c9622c6820d3ede1e2315a6a377ea1076e421d88",
+ "url": "https://api.github.com/repos/doctrine/cache/zipball/1ca8f21980e770095a31456042471a57bc4c68fb",
+ "reference": "1ca8f21980e770095a31456042471a57bc4c68fb",
"shasum": ""
},
"require": {
"php": "~7.1 || ^8.0"
},
"conflict": {
- "doctrine/common": ">2.2,<2.4",
- "psr/cache": ">=3"
+ "doctrine/common": ">2.2,<2.4"
},
"require-dev": {
- "alcaeus/mongo-php-adapter": "^1.1",
"cache/integration-tests": "dev-master",
- "doctrine/coding-standard": "^8.0",
- "mongodb/mongodb": "^1.1",
- "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
- "predis/predis": "~1.0",
- "psr/cache": "^1.0 || ^2.0",
- "symfony/cache": "^4.4 || ^5.2"
- },
- "suggest": {
- "alcaeus/mongo-php-adapter": "Required to use legacy MongoDB driver"
+ "doctrine/coding-standard": "^9",
+ "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
+ "psr/cache": "^1.0 || ^2.0 || ^3.0",
+ "symfony/cache": "^4.4 || ^5.4 || ^6",
+ "symfony/var-exporter": "^4.4 || ^5.4 || ^6"
},
"type": "library",
"autoload": {
@@ -4841,40 +6305,60 @@
"redis",
"xcache"
],
- "time": "2021-05-25T09:43:04+00:00"
+ "support": {
+ "issues": "https://github.com/doctrine/cache/issues",
+ "source": "https://github.com/doctrine/cache/tree/2.2.0"
+ },
+ "funding": [
+ {
+ "url": "https://www.doctrine-project.org/sponsorship.html",
+ "type": "custom"
+ },
+ {
+ "url": "https://www.patreon.com/phpdoctrine",
+ "type": "patreon"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fcache",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-05-20T20:07:39+00:00"
},
{
"name": "doctrine/dbal",
- "version": "3.1.1",
+ "version": "3.3.7",
"source": {
"type": "git",
"url": "https://github.com/doctrine/dbal.git",
- "reference": "8e0fde2b90e3f61361013d1e928621beeea07bc0"
+ "reference": "9f79d4650430b582f4598fe0954ef4d52fbc0a8a"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/doctrine/dbal/zipball/8e0fde2b90e3f61361013d1e928621beeea07bc0",
- "reference": "8e0fde2b90e3f61361013d1e928621beeea07bc0",
+ "url": "https://api.github.com/repos/doctrine/dbal/zipball/9f79d4650430b582f4598fe0954ef4d52fbc0a8a",
+ "reference": "9f79d4650430b582f4598fe0954ef4d52fbc0a8a",
"shasum": ""
},
"require": {
- "composer/package-versions-deprecated": "^1.11.99",
- "doctrine/cache": "^1.0|^2.0",
- "doctrine/deprecations": "^0.5.3",
+ "composer-runtime-api": "^2",
+ "doctrine/cache": "^1.11|^2.0",
+ "doctrine/deprecations": "^0.5.3|^1",
"doctrine/event-manager": "^1.0",
- "php": "^7.3 || ^8.0"
+ "php": "^7.3 || ^8.0",
+ "psr/cache": "^1|^2|^3",
+ "psr/log": "^1|^2|^3"
},
"require-dev": {
"doctrine/coding-standard": "9.0.0",
- "jetbrains/phpstorm-stubs": "2020.2",
- "phpstan/phpstan": "0.12.81",
- "phpstan/phpstan-strict-rules": "^0.12.2",
- "phpunit/phpunit": "9.5.5",
- "psalm/plugin-phpunit": "0.13.0",
- "squizlabs/php_codesniffer": "3.6.0",
+ "jetbrains/phpstorm-stubs": "2022.1",
+ "phpstan/phpstan": "1.7.13",
+ "phpstan/phpstan-strict-rules": "^1.2",
+ "phpunit/phpunit": "9.5.20",
+ "psalm/plugin-phpunit": "0.16.1",
+ "squizlabs/php_codesniffer": "3.7.0",
"symfony/cache": "^5.2|^6.0",
- "symfony/console": "^2.0.5|^3.0|^4.0|^5.0|^6.0",
- "vimeo/psalm": "4.6.4"
+ "symfony/console": "^2.7|^3.0|^4.0|^5.0|^6.0",
+ "vimeo/psalm": "4.23.0"
},
"suggest": {
"symfony/console": "For helpful console commands such as SQL execution and import of files."
@@ -4932,29 +6416,47 @@
"sqlserver",
"sqlsrv"
],
- "time": "2021-06-19T17:59:55+00:00"
+ "support": {
+ "issues": "https://github.com/doctrine/dbal/issues",
+ "source": "https://github.com/doctrine/dbal/tree/3.3.7"
+ },
+ "funding": [
+ {
+ "url": "https://www.doctrine-project.org/sponsorship.html",
+ "type": "custom"
+ },
+ {
+ "url": "https://www.patreon.com/phpdoctrine",
+ "type": "patreon"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fdbal",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-06-13T21:43:03+00:00"
},
{
"name": "doctrine/deprecations",
- "version": "v0.5.3",
+ "version": "v1.0.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/deprecations.git",
- "reference": "9504165960a1f83cc1480e2be1dd0a0478561314"
+ "reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/doctrine/deprecations/zipball/9504165960a1f83cc1480e2be1dd0a0478561314",
- "reference": "9504165960a1f83cc1480e2be1dd0a0478561314",
+ "url": "https://api.github.com/repos/doctrine/deprecations/zipball/0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de",
+ "reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de",
"shasum": ""
},
"require": {
"php": "^7.1|^8.0"
},
"require-dev": {
- "doctrine/coding-standard": "^6.0|^7.0|^8.0",
- "phpunit/phpunit": "^7.0|^8.0|^9.0",
- "psr/log": "^1.0"
+ "doctrine/coding-standard": "^9",
+ "phpunit/phpunit": "^7.5|^8.5|^9.5",
+ "psr/log": "^1|^2|^3"
},
"suggest": {
"psr/log": "Allows logging deprecations via PSR-3 logger implementation"
@@ -4971,7 +6473,11 @@
],
"description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.",
"homepage": "https://www.doctrine-project.org/",
- "time": "2021-03-21T12:59:47+00:00"
+ "support": {
+ "issues": "https://github.com/doctrine/deprecations/issues",
+ "source": "https://github.com/doctrine/deprecations/tree/v1.0.0"
+ },
+ "time": "2022-05-02T15:47:09+00:00"
},
{
"name": "doctrine/event-manager",
@@ -5047,33 +6553,52 @@
"event system",
"events"
],
+ "support": {
+ "issues": "https://github.com/doctrine/event-manager/issues",
+ "source": "https://github.com/doctrine/event-manager/tree/1.1.x"
+ },
+ "funding": [
+ {
+ "url": "https://www.doctrine-project.org/sponsorship.html",
+ "type": "custom"
+ },
+ {
+ "url": "https://www.patreon.com/phpdoctrine",
+ "type": "patreon"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fevent-manager",
+ "type": "tidelift"
+ }
+ ],
"time": "2020-05-29T18:28:51+00:00"
},
{
"name": "doctrine/instantiator",
- "version": "1.4.0",
+ "version": "1.4.1",
"source": {
"type": "git",
"url": "https://github.com/doctrine/instantiator.git",
- "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b"
+ "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/doctrine/instantiator/zipball/d56bf6102915de5702778fe20f2de3b2fe570b5b",
- "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b",
+ "url": "https://api.github.com/repos/doctrine/instantiator/zipball/10dcfce151b967d20fde1b34ae6640712c3891bc",
+ "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"require-dev": {
- "doctrine/coding-standard": "^8.0",
+ "doctrine/coding-standard": "^9",
"ext-pdo": "*",
"ext-phar": "*",
- "phpbench/phpbench": "^0.13 || 1.0.0-alpha2",
- "phpstan/phpstan": "^0.12",
- "phpstan/phpstan-phpunit": "^0.12",
- "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0"
+ "phpbench/phpbench": "^0.16 || ^1",
+ "phpstan/phpstan": "^1.4",
+ "phpstan/phpstan-phpunit": "^1",
+ "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
+ "vimeo/psalm": "^4.22"
},
"type": "library",
"autoload": {
@@ -5098,20 +6623,38 @@
"constructor",
"instantiate"
],
- "time": "2020-11-10T18:47:58+00:00"
+ "support": {
+ "issues": "https://github.com/doctrine/instantiator/issues",
+ "source": "https://github.com/doctrine/instantiator/tree/1.4.1"
+ },
+ "funding": [
+ {
+ "url": "https://www.doctrine-project.org/sponsorship.html",
+ "type": "custom"
+ },
+ {
+ "url": "https://www.patreon.com/phpdoctrine",
+ "type": "patreon"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-03-03T08:28:38+00:00"
},
{
"name": "facade/flare-client-php",
- "version": "1.8.1",
+ "version": "1.9.1",
"source": {
"type": "git",
"url": "https://github.com/facade/flare-client-php.git",
- "reference": "47b639dc02bcfdfc4ebb83de703856fa01e35f5f"
+ "reference": "b2adf1512755637d0cef4f7d1b54301325ac78ed"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/facade/flare-client-php/zipball/47b639dc02bcfdfc4ebb83de703856fa01e35f5f",
- "reference": "47b639dc02bcfdfc4ebb83de703856fa01e35f5f",
+ "url": "https://api.github.com/repos/facade/flare-client-php/zipball/b2adf1512755637d0cef4f7d1b54301325ac78ed",
+ "reference": "b2adf1512755637d0cef4f7d1b54301325ac78ed",
"shasum": ""
},
"require": {
@@ -5134,12 +6677,12 @@
}
},
"autoload": {
- "psr-4": {
- "Facade\\FlareClient\\": "src"
- },
"files": [
"src/helpers.php"
- ]
+ ],
+ "psr-4": {
+ "Facade\\FlareClient\\": "src"
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -5153,26 +6696,37 @@
"flare",
"reporting"
],
- "time": "2021-05-31T19:23:29+00:00"
+ "support": {
+ "issues": "https://github.com/facade/flare-client-php/issues",
+ "source": "https://github.com/facade/flare-client-php/tree/1.9.1"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/spatie",
+ "type": "github"
+ }
+ ],
+ "time": "2021-09-13T12:16:46+00:00"
},
{
"name": "facade/ignition",
- "version": "2.11.0",
+ "version": "2.17.5",
"source": {
"type": "git",
"url": "https://github.com/facade/ignition.git",
- "reference": "dc6818335f50ccf0b90284784718ea9a82604286"
+ "reference": "1d71996f83c9a5a7807331b8986ac890352b7a0c"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/facade/ignition/zipball/dc6818335f50ccf0b90284784718ea9a82604286",
- "reference": "dc6818335f50ccf0b90284784718ea9a82604286",
+ "url": "https://api.github.com/repos/facade/ignition/zipball/1d71996f83c9a5a7807331b8986ac890352b7a0c",
+ "reference": "1d71996f83c9a5a7807331b8986ac890352b7a0c",
"shasum": ""
},
"require": {
+ "ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
- "facade/flare-client-php": "^1.6",
+ "facade/flare-client-php": "^1.9.1",
"facade/ignition-contracts": "^1.0.2",
"illuminate/support": "^7.0|^8.0",
"monolog/monolog": "^2.0",
@@ -5182,6 +6736,7 @@
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.14",
+ "livewire/livewire": "^2.4",
"mockery/mockery": "^1.3",
"orchestra/testbench": "^5.0|^6.0",
"psalm/plugin-laravel": "^1.2"
@@ -5204,12 +6759,12 @@
}
},
"autoload": {
- "psr-4": {
- "Facade\\Ignition\\": "src"
- },
"files": [
"src/helpers.php"
- ]
+ ],
+ "psr-4": {
+ "Facade\\Ignition\\": "src"
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -5223,7 +6778,13 @@
"laravel",
"page"
],
- "time": "2021-07-12T15:55:51+00:00"
+ "support": {
+ "docs": "https://flareapp.io/docs/ignition-for-laravel/introduction",
+ "forum": "https://twitter.com/flareappio",
+ "issues": "https://github.com/facade/ignition/issues",
+ "source": "https://github.com/facade/ignition"
+ },
+ "time": "2022-02-23T18:31:24+00:00"
},
{
"name": "facade/ignition-contracts",
@@ -5272,25 +6833,29 @@
"flare",
"ignition"
],
+ "support": {
+ "issues": "https://github.com/facade/ignition-contracts/issues",
+ "source": "https://github.com/facade/ignition-contracts/tree/1.0.2"
+ },
"time": "2020-10-16T08:27:54+00:00"
},
{
"name": "filp/whoops",
- "version": "2.13.0",
+ "version": "2.14.5",
"source": {
"type": "git",
"url": "https://github.com/filp/whoops.git",
- "reference": "2edbc73a4687d9085c8f20f398eebade844e8424"
+ "reference": "a63e5e8f26ebbebf8ed3c5c691637325512eb0dc"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/filp/whoops/zipball/2edbc73a4687d9085c8f20f398eebade844e8424",
- "reference": "2edbc73a4687d9085c8f20f398eebade844e8424",
+ "url": "https://api.github.com/repos/filp/whoops/zipball/a63e5e8f26ebbebf8ed3c5c691637325512eb0dc",
+ "reference": "a63e5e8f26ebbebf8ed3c5c691637325512eb0dc",
"shasum": ""
},
"require": {
"php": "^5.5.9 || ^7.0 || ^8.0",
- "psr/log": "^1.0.1"
+ "psr/log": "^1.0.1 || ^2.0 || ^3.0"
},
"require-dev": {
"mockery/mockery": "^0.9 || ^1.0",
@@ -5333,7 +6898,17 @@
"throwable",
"whoops"
],
- "time": "2021-06-04T12:00:00+00:00"
+ "support": {
+ "issues": "https://github.com/filp/whoops/issues",
+ "source": "https://github.com/filp/whoops/tree/2.14.5"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/denis-sokolov",
+ "type": "github"
+ }
+ ],
+ "time": "2022-01-07T12:00:00+00:00"
},
{
"name": "fzaninotto/faker",
@@ -5383,6 +6958,10 @@
"faker",
"fixtures"
],
+ "support": {
+ "issues": "https://github.com/fzaninotto/Faker/issues",
+ "source": "https://github.com/fzaninotto/Faker/tree/v1.9.2"
+ },
"abandoned": true,
"time": "2020-12-11T09:56:16+00:00"
},
@@ -5401,50 +6980,120 @@
"shasum": ""
},
"require": {
- "php": "^5.3|^7.0|^8.0"
- },
- "replace": {
- "cordoval/hamcrest-php": "*",
- "davedevelopment/hamcrest-php": "*",
- "kodova/hamcrest-php": "*"
+ "php": "^5.3|^7.0|^8.0"
+ },
+ "replace": {
+ "cordoval/hamcrest-php": "*",
+ "davedevelopment/hamcrest-php": "*",
+ "kodova/hamcrest-php": "*"
+ },
+ "require-dev": {
+ "phpunit/php-file-iterator": "^1.4 || ^2.0",
+ "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.1-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "hamcrest"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "description": "This is the PHP port of Hamcrest Matchers",
+ "keywords": [
+ "test"
+ ],
+ "support": {
+ "issues": "https://github.com/hamcrest/hamcrest-php/issues",
+ "source": "https://github.com/hamcrest/hamcrest-php/tree/v2.0.1"
+ },
+ "time": "2020-07-09T08:09:16+00:00"
+ },
+ {
+ "name": "maximebf/debugbar",
+ "version": "v1.18.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/maximebf/php-debugbar.git",
+ "reference": "0d44b75f3b5d6d41ae83b79c7a4bceae7fbc78b6"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/0d44b75f3b5d6d41ae83b79c7a4bceae7fbc78b6",
+ "reference": "0d44b75f3b5d6d41ae83b79c7a4bceae7fbc78b6",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.1|^8",
+ "psr/log": "^1|^2|^3",
+ "symfony/var-dumper": "^2.6|^3|^4|^5|^6"
},
"require-dev": {
- "phpunit/php-file-iterator": "^1.4 || ^2.0",
- "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0"
+ "phpunit/phpunit": "^7.5.20 || ^9.4.2",
+ "twig/twig": "^1.38|^2.7|^3.0"
+ },
+ "suggest": {
+ "kriswallsmith/assetic": "The best way to manage assets",
+ "monolog/monolog": "Log using Monolog",
+ "predis/predis": "Redis storage"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.1-dev"
+ "dev-master": "1.17-dev"
}
},
"autoload": {
- "classmap": [
- "hamcrest"
- ]
+ "psr-4": {
+ "DebugBar\\": "src/DebugBar/"
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
- "BSD-3-Clause"
+ "MIT"
],
- "description": "This is the PHP port of Hamcrest Matchers",
+ "authors": [
+ {
+ "name": "Maxime Bouroumeau-Fuseau",
+ "email": "maxime.bouroumeau@gmail.com",
+ "homepage": "http://maximebf.com"
+ },
+ {
+ "name": "Barry vd. Heuvel",
+ "email": "barryvdh@gmail.com"
+ }
+ ],
+ "description": "Debug bar in the browser for php application",
+ "homepage": "https://github.com/maximebf/php-debugbar",
"keywords": [
- "test"
+ "debug",
+ "debugbar"
],
- "time": "2020-07-09T08:09:16+00:00"
+ "support": {
+ "issues": "https://github.com/maximebf/php-debugbar/issues",
+ "source": "https://github.com/maximebf/php-debugbar/tree/v1.18.0"
+ },
+ "time": "2021-12-27T18:49:48+00:00"
},
{
"name": "mockery/mockery",
- "version": "1.4.3",
+ "version": "1.5.0",
"source": {
"type": "git",
"url": "https://github.com/mockery/mockery.git",
- "reference": "d1339f64479af1bee0e82a0413813fe5345a54ea"
+ "reference": "c10a5f6e06fc2470ab1822fa13fa2a7380f8fbac"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/mockery/mockery/zipball/d1339f64479af1bee0e82a0413813fe5345a54ea",
- "reference": "d1339f64479af1bee0e82a0413813fe5345a54ea",
+ "url": "https://api.github.com/repos/mockery/mockery/zipball/c10a5f6e06fc2470ab1822fa13fa2a7380f8fbac",
+ "reference": "c10a5f6e06fc2470ab1822fa13fa2a7380f8fbac",
"shasum": ""
},
"require": {
@@ -5499,41 +7148,46 @@
"test double",
"testing"
],
- "time": "2021-02-24T09:51:49+00:00"
+ "support": {
+ "issues": "https://github.com/mockery/mockery/issues",
+ "source": "https://github.com/mockery/mockery/tree/1.5.0"
+ },
+ "time": "2022-01-20T13:18:17+00:00"
},
{
"name": "myclabs/deep-copy",
- "version": "1.10.2",
+ "version": "1.11.0",
"source": {
"type": "git",
"url": "https://github.com/myclabs/DeepCopy.git",
- "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220"
+ "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/776f831124e9c62e1a2c601ecc52e776d8bb7220",
- "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220",
+ "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/14daed4296fae74d9e3201d2c4925d1acb7aa614",
+ "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
- "replace": {
- "myclabs/deep-copy": "self.version"
+ "conflict": {
+ "doctrine/collections": "<1.6.8",
+ "doctrine/common": "<2.13.3 || >=3,<3.2.2"
},
"require-dev": {
- "doctrine/collections": "^1.0",
- "doctrine/common": "^2.6",
- "phpunit/phpunit": "^7.1"
+ "doctrine/collections": "^1.6.8",
+ "doctrine/common": "^2.13.3 || ^3.2.2",
+ "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13"
},
"type": "library",
"autoload": {
- "psr-4": {
- "DeepCopy\\": "src/DeepCopy/"
- },
"files": [
"src/DeepCopy/deep_copy.php"
- ]
+ ],
+ "psr-4": {
+ "DeepCopy\\": "src/DeepCopy/"
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -5547,37 +7201,46 @@
"object",
"object graph"
],
- "time": "2020-11-13T09:40:50+00:00"
+ "support": {
+ "issues": "https://github.com/myclabs/DeepCopy/issues",
+ "source": "https://github.com/myclabs/DeepCopy/tree/1.11.0"
+ },
+ "funding": [
+ {
+ "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-03-03T13:19:32+00:00"
},
{
"name": "nunomaduro/collision",
- "version": "v5.5.0",
+ "version": "v5.11.0",
"source": {
"type": "git",
"url": "https://github.com/nunomaduro/collision.git",
- "reference": "b5cb36122f1c142c3c3ee20a0ae778439ef0244b"
+ "reference": "8b610eef8582ccdc05d8f2ab23305e2d37049461"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/nunomaduro/collision/zipball/b5cb36122f1c142c3c3ee20a0ae778439ef0244b",
- "reference": "b5cb36122f1c142c3c3ee20a0ae778439ef0244b",
+ "url": "https://api.github.com/repos/nunomaduro/collision/zipball/8b610eef8582ccdc05d8f2ab23305e2d37049461",
+ "reference": "8b610eef8582ccdc05d8f2ab23305e2d37049461",
"shasum": ""
},
"require": {
"facade/ignition-contracts": "^1.0",
- "filp/whoops": "^2.7.2",
+ "filp/whoops": "^2.14.3",
"php": "^7.3 || ^8.0",
"symfony/console": "^5.0"
},
"require-dev": {
"brianium/paratest": "^6.1",
"fideloper/proxy": "^4.4.1",
- "friendsofphp/php-cs-fixer": "^2.17.3",
"fruitcake/laravel-cors": "^2.0.3",
- "laravel/framework": "^9.0",
+ "laravel/framework": "8.x-dev",
"nunomaduro/larastan": "^0.6.2",
"nunomaduro/mock-final-classes": "^1.0",
- "orchestra/testbench": "^7.0",
+ "orchestra/testbench": "^6.0",
"phpstan/phpstan": "^0.12.64",
"phpunit/phpunit": "^9.5.0"
},
@@ -5617,20 +7280,38 @@
"php",
"symfony"
],
- "time": "2021-06-22T20:47:22+00:00"
+ "support": {
+ "issues": "https://github.com/nunomaduro/collision/issues",
+ "source": "https://github.com/nunomaduro/collision"
+ },
+ "funding": [
+ {
+ "url": "https://www.paypal.com/paypalme/enunomaduro",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/nunomaduro",
+ "type": "github"
+ },
+ {
+ "url": "https://www.patreon.com/nunomaduro",
+ "type": "patreon"
+ }
+ ],
+ "time": "2022-01-10T16:22:52+00:00"
},
{
"name": "phar-io/manifest",
- "version": "2.0.1",
+ "version": "2.0.3",
"source": {
"type": "git",
"url": "https://github.com/phar-io/manifest.git",
- "reference": "85265efd3af7ba3ca4b2a2c34dbfc5788dd29133"
+ "reference": "97803eca37d319dfa7826cc2437fc020857acb53"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phar-io/manifest/zipball/85265efd3af7ba3ca4b2a2c34dbfc5788dd29133",
- "reference": "85265efd3af7ba3ca4b2a2c34dbfc5788dd29133",
+ "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53",
+ "reference": "97803eca37d319dfa7826cc2437fc020857acb53",
"shasum": ""
},
"require": {
@@ -5673,20 +7354,24 @@
}
],
"description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)",
- "time": "2020-06-27T14:33:11+00:00"
+ "support": {
+ "issues": "https://github.com/phar-io/manifest/issues",
+ "source": "https://github.com/phar-io/manifest/tree/2.0.3"
+ },
+ "time": "2021-07-20T11:28:43+00:00"
},
{
"name": "phar-io/version",
- "version": "3.1.0",
+ "version": "3.2.1",
"source": {
"type": "git",
"url": "https://github.com/phar-io/version.git",
- "reference": "bae7c545bef187884426f042434e561ab1ddb182"
+ "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phar-io/version/zipball/bae7c545bef187884426f042434e561ab1ddb182",
- "reference": "bae7c545bef187884426f042434e561ab1ddb182",
+ "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74",
+ "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74",
"shasum": ""
},
"require": {
@@ -5720,7 +7405,11 @@
}
],
"description": "Library for handling version information and constraints",
- "time": "2021-02-23T14:00:09+00:00"
+ "support": {
+ "issues": "https://github.com/phar-io/version/issues",
+ "source": "https://github.com/phar-io/version/tree/3.2.1"
+ },
+ "time": "2022-02-21T01:04:05+00:00"
},
{
"name": "phpdocumentor/reflection-common",
@@ -5769,20 +7458,24 @@
"reflection",
"static analysis"
],
+ "support": {
+ "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues",
+ "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x"
+ },
"time": "2020-06-27T09:03:43+00:00"
},
{
"name": "phpdocumentor/reflection-docblock",
- "version": "5.2.2",
+ "version": "5.3.0",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
- "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556"
+ "reference": "622548b623e81ca6d78b721c5e029f4ce664f170"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/069a785b2141f5bcf49f3e353548dc1cce6df556",
- "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556",
+ "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/622548b623e81ca6d78b721c5e029f4ce664f170",
+ "reference": "622548b623e81ca6d78b721c5e029f4ce664f170",
"shasum": ""
},
"require": {
@@ -5793,7 +7486,8 @@
"webmozart/assert": "^1.9.1"
},
"require-dev": {
- "mockery/mockery": "~1.3.2"
+ "mockery/mockery": "~1.3.2",
+ "psalm/phar": "^4.8"
},
"type": "library",
"extra": {
@@ -5821,20 +7515,24 @@
}
],
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
- "time": "2020-09-03T19:13:55+00:00"
+ "support": {
+ "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues",
+ "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0"
+ },
+ "time": "2021-10-19T17:43:47+00:00"
},
{
"name": "phpdocumentor/type-resolver",
- "version": "1.4.0",
+ "version": "1.6.1",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/TypeResolver.git",
- "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0"
+ "reference": "77a32518733312af16a44300404e945338981de3"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0",
- "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0",
+ "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/77a32518733312af16a44300404e945338981de3",
+ "reference": "77a32518733312af16a44300404e945338981de3",
"shasum": ""
},
"require": {
@@ -5842,7 +7540,8 @@
"phpdocumentor/reflection-common": "^2.0"
},
"require-dev": {
- "ext-tokenizer": "*"
+ "ext-tokenizer": "*",
+ "psalm/phar": "^4.8"
},
"type": "library",
"extra": {
@@ -5866,37 +7565,41 @@
}
],
"description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
- "time": "2020-09-17T18:55:26+00:00"
+ "support": {
+ "issues": "https://github.com/phpDocumentor/TypeResolver/issues",
+ "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.1"
+ },
+ "time": "2022-03-15T21:29:03+00:00"
},
{
"name": "phpspec/prophecy",
- "version": "1.13.0",
+ "version": "v1.15.0",
"source": {
"type": "git",
"url": "https://github.com/phpspec/prophecy.git",
- "reference": "be1996ed8adc35c3fd795488a653f4b518be70ea"
+ "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpspec/prophecy/zipball/be1996ed8adc35c3fd795488a653f4b518be70ea",
- "reference": "be1996ed8adc35c3fd795488a653f4b518be70ea",
+ "url": "https://api.github.com/repos/phpspec/prophecy/zipball/bbcd7380b0ebf3961ee21409db7b38bc31d69a13",
+ "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13",
"shasum": ""
},
"require": {
"doctrine/instantiator": "^1.2",
- "php": "^7.2 || ~8.0, <8.1",
+ "php": "^7.2 || ~8.0, <8.2",
"phpdocumentor/reflection-docblock": "^5.2",
"sebastian/comparator": "^3.0 || ^4.0",
"sebastian/recursion-context": "^3.0 || ^4.0"
},
"require-dev": {
- "phpspec/phpspec": "^6.0",
+ "phpspec/phpspec": "^6.0 || ^7.0",
"phpunit/phpunit": "^8.0 || ^9.0"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "1.11.x-dev"
+ "dev-master": "1.x-dev"
}
},
"autoload": {
@@ -5929,27 +7632,31 @@
"spy",
"stub"
],
- "time": "2021-03-17T13:42:18+00:00"
+ "support": {
+ "issues": "https://github.com/phpspec/prophecy/issues",
+ "source": "https://github.com/phpspec/prophecy/tree/v1.15.0"
+ },
+ "time": "2021-12-08T12:19:24+00:00"
},
{
"name": "phpunit/php-code-coverage",
- "version": "9.2.6",
+ "version": "9.2.15",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
- "reference": "f6293e1b30a2354e8428e004689671b83871edde"
+ "reference": "2e9da11878c4202f97915c1cb4bb1ca318a63f5f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f6293e1b30a2354e8428e004689671b83871edde",
- "reference": "f6293e1b30a2354e8428e004689671b83871edde",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2e9da11878c4202f97915c1cb4bb1ca318a63f5f",
+ "reference": "2e9da11878c4202f97915c1cb4bb1ca318a63f5f",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-libxml": "*",
"ext-xmlwriter": "*",
- "nikic/php-parser": "^4.10.2",
+ "nikic/php-parser": "^4.13.0",
"php": ">=7.3",
"phpunit/php-file-iterator": "^3.0.3",
"phpunit/php-text-template": "^2.0.2",
@@ -5996,20 +7703,30 @@
"testing",
"xunit"
],
- "time": "2021-03-28T07:26:59+00:00"
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
+ "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.15"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ }
+ ],
+ "time": "2022-03-07T09:28:20+00:00"
},
{
"name": "phpunit/php-file-iterator",
- "version": "3.0.5",
+ "version": "3.0.6",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
- "reference": "aa4be8575f26070b100fccb67faabb28f21f66f8"
+ "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/aa4be8575f26070b100fccb67faabb28f21f66f8",
- "reference": "aa4be8575f26070b100fccb67faabb28f21f66f8",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf",
+ "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf",
"shasum": ""
},
"require": {
@@ -6046,7 +7763,17 @@
"filesystem",
"iterator"
],
- "time": "2020-09-28T05:57:25+00:00"
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues",
+ "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ }
+ ],
+ "time": "2021-12-02T12:48:52+00:00"
},
{
"name": "phpunit/php-invoker",
@@ -6099,6 +7826,16 @@
"keywords": [
"process"
],
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/php-invoker/issues",
+ "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ }
+ ],
"time": "2020-09-28T05:58:55+00:00"
},
{
@@ -6148,6 +7885,16 @@
"keywords": [
"template"
],
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/php-text-template/issues",
+ "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ }
+ ],
"time": "2020-10-26T05:33:50+00:00"
},
{
@@ -6197,20 +7944,30 @@
"keywords": [
"timer"
],
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/php-timer/issues",
+ "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ }
+ ],
"time": "2020-10-26T13:16:10+00:00"
},
{
"name": "phpunit/phpunit",
- "version": "9.5.6",
+ "version": "9.5.21",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
- "reference": "fb9b8333f14e3dce976a60ef6a7e05c7c7ed8bfb"
+ "reference": "0e32b76be457de00e83213528f6bb37e2a38fcb1"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/fb9b8333f14e3dce976a60ef6a7e05c7c7ed8bfb",
- "reference": "fb9b8333f14e3dce976a60ef6a7e05c7c7ed8bfb",
+ "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/0e32b76be457de00e83213528f6bb37e2a38fcb1",
+ "reference": "0e32b76be457de00e83213528f6bb37e2a38fcb1",
"shasum": ""
},
"require": {
@@ -6222,11 +7979,11 @@
"ext-xml": "*",
"ext-xmlwriter": "*",
"myclabs/deep-copy": "^1.10.1",
- "phar-io/manifest": "^2.0.1",
+ "phar-io/manifest": "^2.0.3",
"phar-io/version": "^3.0.2",
"php": ">=7.3",
"phpspec/prophecy": "^1.12.1",
- "phpunit/php-code-coverage": "^9.2.3",
+ "phpunit/php-code-coverage": "^9.2.13",
"phpunit/php-file-iterator": "^3.0.5",
"phpunit/php-invoker": "^3.1.1",
"phpunit/php-text-template": "^2.0.3",
@@ -6240,11 +7997,10 @@
"sebastian/global-state": "^5.0.1",
"sebastian/object-enumerator": "^4.0.3",
"sebastian/resource-operations": "^3.0.3",
- "sebastian/type": "^2.3.4",
+ "sebastian/type": "^3.0",
"sebastian/version": "^3.0.2"
},
"require-dev": {
- "ext-pdo": "*",
"phpspec/prophecy-phpunit": "^2.0.1"
},
"suggest": {
@@ -6261,11 +8017,11 @@
}
},
"autoload": {
- "classmap": [
- "src/"
- ],
"files": [
"src/Framework/Assert/Functions.php"
+ ],
+ "classmap": [
+ "src/"
]
},
"notification-url": "https://packagist.org/downloads/",
@@ -6286,7 +8042,70 @@
"testing",
"xunit"
],
- "time": "2021-06-23T05:14:38+00:00"
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/phpunit/issues",
+ "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.21"
+ },
+ "funding": [
+ {
+ "url": "https://phpunit.de/sponsors.html",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ }
+ ],
+ "time": "2022-06-19T12:14:25+00:00"
+ },
+ {
+ "name": "psr/cache",
+ "version": "1.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/cache.git",
+ "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8",
+ "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Psr\\Cache\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "http://www.php-fig.org/"
+ }
+ ],
+ "description": "Common interface for caching libraries",
+ "keywords": [
+ "cache",
+ "psr",
+ "psr-6"
+ ],
+ "support": {
+ "source": "https://github.com/php-fig/cache/tree/master"
+ },
+ "time": "2016-08-06T20:24:11+00:00"
},
{
"name": "reliese/laravel",
@@ -6345,6 +8164,10 @@
"laravel",
"reliese"
],
+ "support": {
+ "issues": "https://github.com/reliese/laravel/issues",
+ "source": "https://github.com/reliese/laravel"
+ },
"time": "2020-12-07T02:35:15+00:00"
},
{
@@ -6391,6 +8214,16 @@
],
"description": "Library for parsing CLI options",
"homepage": "https://github.com/sebastianbergmann/cli-parser",
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/cli-parser/issues",
+ "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ }
+ ],
"time": "2020-09-28T06:08:49+00:00"
},
{
@@ -6437,6 +8270,16 @@
],
"description": "Collection of value objects that represent the PHP code units",
"homepage": "https://github.com/sebastianbergmann/code-unit",
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/code-unit/issues",
+ "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ }
+ ],
"time": "2020-10-26T13:08:54+00:00"
},
{
@@ -6482,6 +8325,16 @@
],
"description": "Looks up which function or method a line of code belongs to",
"homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/",
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues",
+ "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ }
+ ],
"time": "2020-09-28T05:30:19+00:00"
},
{
@@ -6546,6 +8399,16 @@
"compare",
"equality"
],
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/comparator/issues",
+ "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.6"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ }
+ ],
"time": "2020-10-26T15:49:45+00:00"
},
{
@@ -6593,6 +8456,16 @@
],
"description": "Library for calculating the complexity of PHP code units",
"homepage": "https://github.com/sebastianbergmann/complexity",
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/complexity/issues",
+ "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ }
+ ],
"time": "2020-10-26T15:52:27+00:00"
},
{
@@ -6649,20 +8522,30 @@
"unidiff",
"unified diff"
],
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/diff/issues",
+ "source": "https://github.com/sebastianbergmann/diff/tree/4.0.4"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ }
+ ],
"time": "2020-10-26T13:10:38+00:00"
},
{
"name": "sebastian/environment",
- "version": "5.1.3",
+ "version": "5.1.4",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/environment.git",
- "reference": "388b6ced16caa751030f6a69e588299fa09200ac"
+ "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/388b6ced16caa751030f6a69e588299fa09200ac",
- "reference": "388b6ced16caa751030f6a69e588299fa09200ac",
+ "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/1b5dff7bb151a4db11d49d90e5408e4e938270f7",
+ "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7",
"shasum": ""
},
"require": {
@@ -6702,20 +8585,30 @@
"environment",
"hhvm"
],
- "time": "2020-09-28T05:52:38+00:00"
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/environment/issues",
+ "source": "https://github.com/sebastianbergmann/environment/tree/5.1.4"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ }
+ ],
+ "time": "2022-04-03T09:37:03+00:00"
},
{
"name": "sebastian/exporter",
- "version": "4.0.3",
+ "version": "4.0.4",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/exporter.git",
- "reference": "d89cc98761b8cb5a1a235a6b703ae50d34080e65"
+ "reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/d89cc98761b8cb5a1a235a6b703ae50d34080e65",
- "reference": "d89cc98761b8cb5a1a235a6b703ae50d34080e65",
+ "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/65e8b7db476c5dd267e65eea9cab77584d3cfff9",
+ "reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9",
"shasum": ""
},
"require": {
@@ -6764,25 +8657,35 @@
}
],
"description": "Provides the functionality to export PHP variables for visualization",
- "homepage": "http://www.github.com/sebastianbergmann/exporter",
+ "homepage": "https://www.github.com/sebastianbergmann/exporter",
"keywords": [
"export",
"exporter"
],
- "time": "2020-09-28T05:24:23+00:00"
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/exporter/issues",
+ "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.4"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ }
+ ],
+ "time": "2021-11-11T14:18:36+00:00"
},
{
"name": "sebastian/global-state",
- "version": "5.0.3",
+ "version": "5.0.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/global-state.git",
- "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49"
+ "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/23bd5951f7ff26f12d4e3242864df3e08dec4e49",
- "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49",
+ "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/0ca8db5a5fc9c8646244e629625ac486fa286bf2",
+ "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2",
"shasum": ""
},
"require": {
@@ -6823,7 +8726,17 @@
"keywords": [
"global state"
],
- "time": "2021-06-11T13:31:12+00:00"
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/global-state/issues",
+ "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.5"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ }
+ ],
+ "time": "2022-02-14T08:28:10+00:00"
},
{
"name": "sebastian/lines-of-code",
@@ -6870,6 +8783,16 @@
],
"description": "Library for counting the lines of code in PHP source code",
"homepage": "https://github.com/sebastianbergmann/lines-of-code",
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/lines-of-code/issues",
+ "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.3"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ }
+ ],
"time": "2020-11-28T06:42:11+00:00"
},
{
@@ -6917,6 +8840,16 @@
],
"description": "Traverses array structures and object graphs to enumerate all referenced objects",
"homepage": "https://github.com/sebastianbergmann/object-enumerator/",
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/object-enumerator/issues",
+ "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ }
+ ],
"time": "2020-10-26T13:12:34+00:00"
},
{
@@ -6962,6 +8895,16 @@
],
"description": "Allows reflection of object attributes, including inherited and non-public ones",
"homepage": "https://github.com/sebastianbergmann/object-reflector/",
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/object-reflector/issues",
+ "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ }
+ ],
"time": "2020-10-26T13:14:26+00:00"
},
{
@@ -7015,6 +8958,16 @@
],
"description": "Provides functionality to recursively process PHP variables",
"homepage": "http://www.github.com/sebastianbergmann/recursion-context",
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/recursion-context/issues",
+ "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ }
+ ],
"time": "2020-10-26T13:17:30+00:00"
},
{
@@ -7060,32 +9013,42 @@
],
"description": "Provides a list of PHP built-in functions that operate on resources",
"homepage": "https://www.github.com/sebastianbergmann/resource-operations",
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/resource-operations/issues",
+ "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ }
+ ],
"time": "2020-09-28T06:45:17+00:00"
},
{
"name": "sebastian/type",
- "version": "2.3.4",
+ "version": "3.0.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/type.git",
- "reference": "b8cd8a1c753c90bc1a0f5372170e3e489136f914"
+ "reference": "b233b84bc4465aff7b57cf1c4bc75c86d00d6dad"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/b8cd8a1c753c90bc1a0f5372170e3e489136f914",
- "reference": "b8cd8a1c753c90bc1a0f5372170e3e489136f914",
+ "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/b233b84bc4465aff7b57cf1c4bc75c86d00d6dad",
+ "reference": "b233b84bc4465aff7b57cf1c4bc75c86d00d6dad",
"shasum": ""
},
"require": {
"php": ">=7.3"
},
"require-dev": {
- "phpunit/phpunit": "^9.3"
+ "phpunit/phpunit": "^9.5"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.3-dev"
+ "dev-master": "3.0-dev"
}
},
"autoload": {
@@ -7106,7 +9069,17 @@
],
"description": "Collection of value objects that represent the types of the PHP type system",
"homepage": "https://github.com/sebastianbergmann/type",
- "time": "2021-06-15T12:49:02+00:00"
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/type/issues",
+ "source": "https://github.com/sebastianbergmann/type/tree/3.0.0"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ }
+ ],
+ "time": "2022-03-15T09:54:48+00:00"
},
{
"name": "sebastian/version",
@@ -7149,20 +9122,99 @@
],
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
"homepage": "https://github.com/sebastianbergmann/version",
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/version/issues",
+ "source": "https://github.com/sebastianbergmann/version/tree/3.0.2"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ }
+ ],
"time": "2020-09-28T06:39:44+00:00"
},
+ {
+ "name": "symfony/debug",
+ "version": "v4.4.41",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/debug.git",
+ "reference": "6637e62480b60817b9a6984154a533e8e64c6bd5"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/debug/zipball/6637e62480b60817b9a6984154a533e8e64c6bd5",
+ "reference": "6637e62480b60817b9a6984154a533e8e64c6bd5",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.1.3",
+ "psr/log": "^1|^2|^3"
+ },
+ "conflict": {
+ "symfony/http-kernel": "<3.4"
+ },
+ "require-dev": {
+ "symfony/http-kernel": "^3.4|^4.0|^5.0"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\Debug\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Provides tools to ease debugging PHP code",
+ "homepage": "https://symfony.com",
+ "support": {
+ "source": "https://github.com/symfony/debug/tree/v4.4.41"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "abandoned": "symfony/error-handler",
+ "time": "2022-04-12T15:19:55+00:00"
+ },
{
"name": "theseer/tokenizer",
- "version": "1.2.0",
+ "version": "1.2.1",
"source": {
"type": "git",
"url": "https://github.com/theseer/tokenizer.git",
- "reference": "75a63c33a8577608444246075ea0af0d052e452a"
+ "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/theseer/tokenizer/zipball/75a63c33a8577608444246075ea0af0d052e452a",
- "reference": "75a63c33a8577608444246075ea0af0d052e452a",
+ "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e",
+ "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e",
"shasum": ""
},
"require": {
@@ -7189,7 +9241,17 @@
}
],
"description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
- "time": "2020-07-12T23:59:07+00:00"
+ "support": {
+ "issues": "https://github.com/theseer/tokenizer/issues",
+ "source": "https://github.com/theseer/tokenizer/tree/1.2.1"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/theseer",
+ "type": "github"
+ }
+ ],
+ "time": "2021-07-28T10:34:58+00:00"
}
],
"aliases": [],
@@ -7200,5 +9262,6 @@
"platform": {
"php": "^7.3"
},
- "platform-dev": []
+ "platform-dev": [],
+ "plugin-api-version": "2.3.0"
}
diff --git a/config/app.php b/config/app.php
index 201f1ce..652374d 100644
--- a/config/app.php
+++ b/config/app.php
@@ -175,6 +175,7 @@
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
Maatwebsite\Excel\ExcelServiceProvider::class,
+ //Barryvdh\Debugbar\ServiceProvider::class,
// MaddHatter\LaravelFullcalendar\ServiceProvider::class,
diff --git a/public/assets/images/MOH_New.png b/public/assets/images/MOH_New.png
new file mode 100644
index 0000000..294a2bf
Binary files /dev/null and b/public/assets/images/MOH_New.png differ
diff --git a/public/assets/images/Ushauri_big.png b/public/assets/images/Ushauri_big.png
new file mode 100644
index 0000000..1e478c4
Binary files /dev/null and b/public/assets/images/Ushauri_big.png differ
diff --git a/public/assets/images/login/CDC.png b/public/assets/images/login/CDC.png
new file mode 100644
index 0000000..2bbea11
Binary files /dev/null and b/public/assets/images/login/CDC.png differ
diff --git a/public/assets/images/login/KeHMIS.png b/public/assets/images/login/KeHMIS.png
new file mode 100644
index 0000000..29182d9
Binary files /dev/null and b/public/assets/images/login/KeHMIS.png differ
diff --git a/public/assets/images/login/moh.png b/public/assets/images/login/moh.png
index 386cd74..af8ed41 100644
Binary files a/public/assets/images/login/moh.png and b/public/assets/images/login/moh.png differ
diff --git a/public/assets/images/ushauriNew_log.jpeg b/public/assets/images/ushauriNew_log.jpeg
new file mode 100644
index 0000000..ce3c81d
Binary files /dev/null and b/public/assets/images/ushauriNew_log.jpeg differ
diff --git a/public/assets/styles/css/themes/dark-purple.min.css b/public/assets/styles/css/themes/dark-purple.min.css
index d455d58..d81523d 100644
--- a/public/assets/styles/css/themes/dark-purple.min.css
+++ b/public/assets/styles/css/themes/dark-purple.min.css
@@ -30468,7 +30468,7 @@ blockquote {
}
/*
-// dark theme
+// dark theme
*/
.dark-theme {
diff --git a/public/assets/styles/css/themes/lite-purple.min.css b/public/assets/styles/css/themes/lite-purple.min.css
index d54cc6e..1326e54 100644
--- a/public/assets/styles/css/themes/lite-purple.min.css
+++ b/public/assets/styles/css/themes/lite-purple.min.css
@@ -32938,7 +32938,7 @@ blockquote {
}
/*
-// dark theme
+// dark theme
*/
.dark-theme {
diff --git a/public/images/load_ushauri.gif b/public/images/load_ushauri.gif
new file mode 100644
index 0000000..fa2ba69
Binary files /dev/null and b/public/images/load_ushauri.gif differ
diff --git a/public/images/loader.gif b/public/images/loader.gif
new file mode 100644
index 0000000..a1b729d
Binary files /dev/null and b/public/images/loader.gif differ
diff --git a/public/images/loading-white.gif b/public/images/loading-white.gif
new file mode 100644
index 0000000..ba0ad5c
Binary files /dev/null and b/public/images/loading-white.gif differ
diff --git a/public/images/loading.gif b/public/images/loading.gif
new file mode 100644
index 0000000..d3d1c51
Binary files /dev/null and b/public/images/loading.gif differ
diff --git a/public/template/UshauriExtract.sql b/public/template/UshauriExtract.sql
new file mode 100644
index 0000000..0d0ad48
--- /dev/null
+++ b/public/template/UshauriExtract.sql
@@ -0,0 +1,159 @@
+use kenyaemr_datatools;
+SELECT *,
+CASE
+ WHEN DWHValidation.HIV_DiagnosisDate_Validation = 'Invalid' THEN 'Invalid'
+ WHEN DWHValidation.HIV_EnrollmentDate_Validation = 'Invalid' THEN 'Invalid'
+ WHEN DWHValidation.HIV_ARTStartDate_Validation = 'Invalid' THEN 'Invalid'
+ WHEN DWHValidation.HIV_FirstVLDate_Validation = 'Invalid' THEN 'Invalid'
+ WHEN DWHValidation.HIV_LastVLDate_Validation = 'Invalid' THEN 'Invalid'
+ WHEN DWHValidation.date_confirmed_hiv_positive = 'Missing' THEN 'Invalid'
+ WHEN DWHValidation.enroll_date = 'Missing' THEN 'Invalid'
+ #WHEN DWHValidation.ARTStartDate = 'Missing' THEN 'Invalid'
+ WHEN datediff(CURDATE(), STR_TO_DATE(DWHValidation.ARTStartDate,'%d-%b-%Y')) > 200 and DWHValidation.First_VL_Date = 'Missing' THEN 'Invalid'
+ ELSE 'Valid'
+END as RecordValid
+FROM (
+SELECT *,
+round(DATEDIFF(CURRENT_DATE, STR_TO_DATE(TX_CURR.ARTStartDate,'%d-%b-%Y'))/365.25, 1) as Years_on_ART,
+ifnull(DATEDIFF(CURRENT_DATE, STR_TO_DATE(TX_CURR.Last_VL_Date,'%d-%b-%Y')), 'Missing') as days_since_lastVL,
+CASE
+ WHEN STR_TO_DATE(TX_CURR.date_confirmed_hiv_positive,'%d-%b-%Y') <= STR_TO_DATE(TX_CURR.DOB,'%d-%b-%Y') THEN 'Invalid'
+ WHEN STR_TO_DATE(TX_CURR.date_confirmed_hiv_positive,'%d-%b-%Y') < '01/01/1984' THEN 'Invalid'
+ WHEN STR_TO_DATE(TX_CURR.date_confirmed_hiv_positive,'%d-%b-%Y') > STR_TO_DATE(TX_CURR.enroll_date,'%d-%b-%Y') THEN 'Invalid'
+ WHEN STR_TO_DATE(TX_CURR.date_confirmed_hiv_positive,'%d-%b-%Y') > now() THEN 'Invalid'
+ WHEN STR_TO_DATE(TX_CURR.date_confirmed_hiv_positive,'%d-%b-%Y') = "Missing" THEN 'Invalid'
+ ELSE 'Valid'
+END AS HIV_DiagnosisDate_Validation,
+CASE
+ WHEN STR_TO_DATE(TX_CURR.enroll_date,'%d-%b-%Y') <= STR_TO_DATE(TX_CURR.DOB,'%d-%b-%Y') THEN 'Invalid'
+ WHEN STR_TO_DATE(TX_CURR.enroll_date,'%d-%b-%Y') < '01/01/2000' THEN 'Invalid'
+ WHEN STR_TO_DATE(TX_CURR.enroll_date,'%d-%b-%Y') > now() THEN 'Invalid'
+ WHEN STR_TO_DATE(TX_CURR.enroll_date,'%d-%b-%Y') < STR_TO_DATE(TX_CURR.date_confirmed_hiv_positive,'%d-%b-%Y') THEN 'Invalid'
+ ELSE 'Valid'
+END AS HIV_EnrollmentDate_Validation,
+CASE
+ WHEN STR_TO_DATE(TX_CURR.ARTStartDate,'%d-%b-%Y') <= STR_TO_DATE(TX_CURR.DOB,'%d-%b-%Y') THEN 'Invalid'
+ WHEN STR_TO_DATE(TX_CURR.ARTStartDate,'%d-%b-%Y') < STR_TO_DATE(TX_CURR.date_confirmed_hiv_positive,'%d-%b-%Y') THEN 'Invalid'
+ WHEN STR_TO_DATE(TX_CURR.ARTStartDate,'%d-%b-%Y') < STR_TO_DATE(TX_CURR.enroll_date,'%d-%b-%Y') THEN 'Invalid'
+ WHEN STR_TO_DATE(TX_CURR.ARTStartDate,'%d-%b-%Y') < '01/01/2004' THEN 'Invalid'
+ WHEN STR_TO_DATE(TX_CURR.ARTStartDate,'%d-%b-%Y') > now() THEN 'Invalid'
+ ELSE 'Valid'
+END AS HIV_ARTStartDate_Validation,
+CASE
+ WHEN STR_TO_DATE(TX_CURR.First_VL_date,'%d-%b-%Y') <= STR_TO_DATE(TX_CURR.DOB,'%d-%b-%Y') THEN 'Invalid'
+ WHEN STR_TO_DATE(TX_CURR.First_VL_date,'%d-%b-%Y') < STR_TO_DATE(TX_CURR.date_confirmed_hiv_positive,'%d-%b-%Y') THEN 'Invalid'
+ WHEN STR_TO_DATE(TX_CURR.First_VL_date,'%d-%b-%Y') < STR_TO_DATE(TX_CURR.enroll_date,'%d-%b-%Y') THEN 'Invalid'
+ WHEN STR_TO_DATE(TX_CURR.First_VL_date,'%d-%b-%Y') < STR_TO_DATE(TX_CURR.ARTStartDate,'%d-%b-%Y') THEN 'Invalid'
+ WHEN datediff(CURDATE(), STR_TO_DATE(TX_CURR.ARTStartDate,'%d-%b-%Y')) > 200 and TX_CURR.First_VL_Date = 'Missing' THEN 'Invalid'
+ WHEN STR_TO_DATE(TX_CURR.First_VL_date,'%d-%b-%Y') > now() THEN 'Invalid'
+ ELSE 'Valid'
+END AS HIV_FirstVLDate_Validation,
+CASE
+ WHEN STR_TO_DATE(TX_CURR.Last_VL_date,'%d-%b-%Y') <= STR_TO_DATE(TX_CURR.DOB,'%d-%b-%Y') THEN 'Invalid'
+ WHEN STR_TO_DATE(TX_CURR.Last_VL_date,'%d-%b-%Y') < STR_TO_DATE(TX_CURR.date_confirmed_hiv_positive,'%d-%b-%Y') THEN 'Invalid'
+ WHEN STR_TO_DATE(TX_CURR.Last_VL_date,'%d-%b-%Y') < STR_TO_DATE(TX_CURR.enroll_date,'%d-%b-%Y') THEN 'Invalid'
+ WHEN STR_TO_DATE(TX_CURR.Last_VL_date,'%d-%b-%Y') < STR_TO_DATE(TX_CURR.ARTStartDate,'%d-%b-%Y') THEN 'Invalid'
+ WHEN STR_TO_DATE(TX_CURR.Last_VL_date,'%d-%b-%Y') < STR_TO_DATE(TX_CURR.First_VL_date,'%d-%b-%Y') THEN 'Invalid'
+ WHEN STR_TO_DATE(TX_CURR.Last_VL_date,'%d-%b-%Y') > now() THEN 'Invalid'
+ ELSE 'Valid'
+END AS HIV_LastVLDate_Validation
+FROM (
+ SELECT (select siteCode from default_facility_info) MFL, (select Facilityname from default_facility_info) Facility,
+ I.unique_patient_no CCC_Number, round(DATEDIFF(LAST_DAY(now() - INTERVAL 1 MONTH), A.dob)/365.25, 2) AS ageInYears, A.Gender, ifnull(date_format(A.dob,'%d-%b-%Y'), 'Missing') DOB,
+ ifnull(date_format(E.date_confirmed_hiv_positive,'%d-%b-%Y'), 'Missing') date_confirmed_hiv_positive,
+ ifnull(date_format(A.enroll_date,'%d-%b-%Y'), 'Missing') enroll_date,
+ CASE
+ WHEN (select min(date_started_art_at_transferring_facility) from hiv_enrollment where patient_id = A.patient_id) IS NOT NULL
+ AND (select min(date_started_art_at_transferring_facility) from hiv_enrollment where patient_id = A.patient_id) <
+ (select min(date_started) from drug_event where patient_id = A.patient_id)
+ THEN ifnull(date_format((select min(date_started_art_at_transferring_facility) from hiv_enrollment where patient_id = A.patient_id),'%d-%b-%Y'),'Missing')
+ ELSE ifnull(date_format((select min(date_started) from drug_event where patient_id = A.patient_id),'%d-%b-%Y'),'Missing')
+ END AS ARTStartDate,
+ (select who_stage from kenyaemr_datatools.hiv_followup where patient_id = A.patient_id order by visit_date asc LIMIT 1) AS baselineWHO,
+ (select phone_number from kenyaemr_datatools.patient_demographics where patient_id = A.patient_id order by I.patient_id asc LIMIT 1) AS Phone_Number,
+ (select marital_status from kenyaemr_datatools.patient_demographics where patient_id = A.patient_id order by I.patient_id asc LIMIT 1) AS Marital_Status,
+ (select given_name from kenyaemr_datatools.patient_demographics where patient_id = A.patient_id order by I.patient_id asc LIMIT 1) AS FirstName,
+ (select middle_name from kenyaemr_datatools.patient_demographics where patient_id = A.patient_id order by I.patient_id asc LIMIT 1) AS MiddleName,
+ (select family_name from kenyaemr_datatools.patient_demographics where patient_id = A.patient_id order by I.patient_id asc LIMIT 1) AS LastName,
+ (select test_result from laboratory_extract where patient_id = A.patient_id and lab_test = 'CD4 Count' order by visit_date asc LIMIT 1) baselineCD4,
+ CASE
+ WHEN H.test_result IS NOT NULL THEN H.test_result
+ WHEN DATEDIFF(LAST_DAY(now() - INTERVAL 1 MONTH),
+ (
+ CASE
+ WHEN (select min(date_started_art_at_transferring_facility) from hiv_enrollment where patient_id = A.patient_id) IS NOT NULL
+ AND (select min(date_started_art_at_transferring_facility) from hiv_enrollment where patient_id = A.patient_id) <
+ (select min(date_started) from drug_event where patient_id = A.patient_id)
+ THEN ifnull((select min(date_started_art_at_transferring_facility) from hiv_enrollment where patient_id = A.patient_id),'Missing')
+ ELSE ifnull((select min(date_started) from drug_event where patient_id = A.patient_id),'Missing')
+ END #ARTSTARTDATE
+ )
+ ) < 183 THEN 'Not Eligible'
+ ELSE ifnull(H.test_result,'Missing')
+ END First_VL_Result,
+ ifnull(date_format(H.visit_date,'%d-%b-%Y'),'Missing') First_VL_Date,
+ ifnull(B.test_result,'Missing') Last_VL_Result, ifnull(date_format(B.visit_date,'%d-%b-%Y'),'Missing') Last_VL_Date,
+ if(D.person_present is null or D.person_present='', 'Missing', D.person_present) person_present, D.weight, D.height,
+ CASE
+ WHEN D.weight/ ((D.height/100) * (D.height/100)) < 18.5 THEN 'Underweight'
+ WHEN D.weight/ ((D.height/100) * (D.height/100)) between 18.5 and 25 THEN 'Normal'
+ WHEN D.weight/ ((D.height/100) * (D.height/100)) > 25 THEN 'Overweight'
+ END as nutritional_status, #D.nutritional_status,
+ D.temperature, D.muac,
+ D.population_type, D.key_population_type, D.who_stage AS currentWHO, D.presenting_complaints,
+ D.on_anti_tb_drugs, D.on_ipt, D.ever_on_ipt, ifnull(date_format(G.visit_date,'%d-%b-%Y'),'Missing') IPTStartDate,
+ CASE
+ WHEN F.outcome = 1267 THEN 'Completed'
+ WHEN F.outcome = 5240 THEN 'Lost to followup'
+ WHEN F.outcome = 159836 THEN 'Discontinue'
+ WHEN F.outcome = 160034 THEN 'Died'
+ WHEN F.outcome = 159492 THEN 'Transferred Out'
+ WHEN F.outcome = 112141 THEN 'Tuberculosis'
+ WHEN F.outcome = 102 THEN 'Drug Toxicity'
+ ELSE 'Missing'
+ END AS IPTOutcome,
+ ifnull(date_format(F.visit_date,'%d-%b-%Y'),'Missing') IPTOutcomeDate,
+ IF(D.tb_status IS NULL or D.tb_status = '', 'Not done', D.tb_status) TB_Status, D.has_known_allergies, D.has_chronic_illnesses_cormobidities, D.has_adverse_drug_reaction,
+ D.pregnancy_status, D.wants_pregnancy, D.family_planning_status, D.family_planning_method, D.ctx_dispensed, ifnull(C.regimen, 'Missing') current_regimen, C.regimen_line, D.arv_adherence, D.cacx_screening,
+ CASE
+ WHEN C.regimen IS NULL THEN 'Missing'
+ WHEN I.value_datetime > A.latest_vis_date and I.value_datetime < latest_tca THEN
+ CASE WHEN round(datediff(I.value_datetime, A.latest_vis_date)/30) = 0 THEN 1 ELSE round(datediff(I.value_datetime, A.latest_vis_date)/30) END
+ ELSE
+ CASE WHEN round(datediff(latest_tca, A.latest_vis_date)/30) = 0 THEN 1 ELSE round(datediff(latest_tca, A.latest_vis_date)/30) END
+ #WHEN round(datediff(latest_tca, A.latest_vis_date)/30) = 0 THEN 1
+ #ELSE round(datediff(latest_tca, A.latest_vis_date)/30)
+ END AS MMD,
+ D.stability,
+ date_format(D.visit_date,'%d-%b-%Y') last_visit_date, date_format(D.next_appointment_date,'%d-%b-%Y') next_appointment_date,
+ round(datediff(D.next_appointment_date, D.visit_date)/30) App_Months, D.next_appointment_reason,
+ CASE WHEN I.value_datetime > D.visit_date THEN date_format(I.value_datetime,'%d-%b-%Y') ELSE '' END AS refill_date, D.differentiated_care,
+ CASE WHEN MCH.program IS NOT NULL THEN MCH.program ELSE 'CCC' END Program, MCH.MCH_Date_enrolled, MCH.LMP, MCH.EDD
+ FROM current_in_care A
+ inner join kenyaemr_datatools.patient_demographics I on A.patient_id = I.patient_id
+ LEFT JOIN
+ (select * from (select * from laboratory_extract where lab_test = 'HIV VIRAL LOAD' order by visit_date desc) X group by X.patient_id) B on A.patient_id = B.patient_id
+ LEFT JOIN
+ (select * from (select * from drug_event where program = 'HIV' order by visit_date desc) Y group by Y.patient_id) C on A.patient_id = C.patient_id
+ LEFT JOIN
+ (select * from (select * from hiv_followup where person_present <> '' order by visit_date desc) Z group by Z.patient_id) D ON A.patient_id = D.patient_id
+ LEFT JOIN
+ (select * from (select * from hiv_enrollment order by visit_date asc) W group by W.patient_id) E on A.patient_id = E.patient_id
+ LEFT JOIN
+ (select * from (select * from kenyaemr_etl.etl_ipt_outcome order by visit_date desc) V group by V.patient_id) F on A.patient_id = F.patient_id
+ LEFT JOIN
+ (select * from (select * from kenyaemr_etl.etl_ipt_initiation order by visit_date desc) U group by U.patient_id) G on A.patient_id = G.patient_id
+ LEFT JOIN
+ (select * from (select * from laboratory_extract where lab_test = 'HIV VIRAL LOAD' order by visit_date asc) T group by T.patient_id) H on A.patient_id = H.patient_id
+ LEFT JOIN
+ (select * from (select person_id, value_datetime from openmrs.obs where concept_id=162549 order by value_datetime desc) S group by S.person_id) I on A.patient_id = I.person_id
+ LEFT JOIN
+ (
+ SELECT pp.patient_id, date_format(pp.date_enrolled,'%d-%b-%Y') MCH_Date_enrolled, date_format(mchEnrol.lmp,'%d-%b-%Y') LMP, date_format(date_add(mchEnrol.lmp, INTERVAL 280 DAY),'%d-%b-%Y') EDD, 'MCH' program
+ FROM openmrs.patient_program pp inner join kenyaemr_datatools.mch_enrollment mchEnrol on pp.patient_id = mchEnrol.patient_id
+ where program_id=4 #MCH Mother Services
+ and (date_completed >= LAST_DAY(now() - INTERVAL 1 MONTH) OR date_completed is null)
+ and voided=0
+ ) MCH ON A.patient_id = MCH.patient_id
+ ) TX_CURR) DWHValidation ;
+
diff --git a/public/template/UshauriTemplate.xlsx b/public/template/UshauriTemplate.xlsx
new file mode 100644
index 0000000..25ef495
Binary files /dev/null and b/public/template/UshauriTemplate.xlsx differ
diff --git a/resources/views/appointments/appointment_calender.blade.php b/resources/views/appointments/appointment_calender.blade.php
index e94ab96..331c1bd 100644
--- a/resources/views/appointments/appointment_calender.blade.php
+++ b/resources/views/appointments/appointment_calender.blade.php
@@ -2,6 +2,7 @@
@section('page-css')
+
@endsection
@section('main-content')
@@ -14,13 +15,12 @@
-
-
-
+
+ Export To PDF
+
+
+
-
-
-
@@ -30,23 +30,35 @@
@section('page-js')
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+ this.submit();
-
+ });
+
-