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..10a6bbe
--- /dev/null
+++ b/.github/workflows/Test deployment.yml
@@ -0,0 +1,42 @@
+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/
+ docker-compose exec -T php php artisan config:cache
+ docker-compose exec -T php php artisan config:clear
+ echo "done!"
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..5f534f3 100644
--- a/app/Http/Controllers/AppointmentController.php
+++ b/app/Http/Controllers/AppointmentController.php
@@ -15,6 +15,7 @@
use Redirect, Response;
use Auth;
use Carbon\Carbon;
+use RealRashid\SweetAlert\Facades\Alert;
class AppointmentController extends Controller
{
@@ -23,7 +24,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,12 +45,13 @@ 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!');
+ Alert::success('Success', 'Appointment was updated successfully!');
+ return redirect('report/future/appointments');
} else {
- Session::flash('statuscode', 'error');
- return back()->with('error', 'Could not consent client please try again later.');
+ Alert::error('Failed', 'Could not consent client please try again later.');
+ return back();
}
} catch (Exception $e) {
return back();
@@ -60,14 +62,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 +77,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 +85,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..1386965 100644
--- a/app/Http/Controllers/Auth/LoginController.php
+++ b/app/Http/Controllers/Auth/LoginController.php
@@ -32,15 +32,15 @@ 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 '/';
+ return '/login';
}
}
/**
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..62ac8a9 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();
+ $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);
+ 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,125 @@ 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;
+ $app_id = $row->id;
+ }
+ $currentDate = date('Y-m-d');
+
+ $query = DB::table('tbl_appointment')
+ ->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_clnt_outgoing', 'tbl_clnt_outgoing.appointment_id', '=', 'tbl_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',
+ DB::raw('CASE WHEN tbl_appointment.appntmnt_date < "' . $currentDate . '" THEN MAX(tbl_clnt_outgoing.id) ELSE " " END AS outgoing_id'),
+ DB::raw('CASE WHEN tbl_appointment.appntmnt_date < "' . $currentDate . '" THEN CASE WHEN tbl_clnt_outgoing.message_id IS NULL OR tbl_clnt_outgoing.callback_status = "Failed" OR tbl_clnt_outgoing.callback_status = "Expired" THEN "Failed" ELSE "Success" END ELSE " " END AS callback_status'),
+ DB::raw('CASE WHEN tbl_appointment.appntmnt_date < "' . $currentDate . '" THEN CASE WHEN tbl_clnt_outgoing.message_id IS NULL OR tbl_clnt_outgoing.callback_status = "Expired" THEN "DeliveryFailure" ELSE tbl_clnt_outgoing.failure_reason END ELSE " " END AS failure_reason')
+ //DB::raw('MAX(tbl_clnt_outgoing.id) as outgoing_id'),
+ // DB::raw('CASE WHEN tbl_clnt_outgoing.message_id IS NULL OR tbl_clnt_outgoing.callback_status = "Failed" OR tbl_clnt_outgoing.callback_status = "Expired" THEN "Failed" ELSE "Success" END AS callback_status'),
+ // DB::raw('CASE WHEN tbl_clnt_outgoing.message_id IS NULL OR tbl_clnt_outgoing.callback_status = "Expired" THEN "DeliveryFailure" ELSE tbl_clnt_outgoing.failure_reason END AS failure_reason'),
+ )
+ ->where('tbl_client.status', 'Active')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->where('tbl_appointment.appntmnt_date', $app_date)
+ //->whereNull('tbl_clnt_outgoing.appointment_id')
+ ->groupBy('tbl_appointment.id');
+
+ 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..736d2ad 100644
--- a/app/Http/Controllers/ClientController.php
+++ b/app/Http/Controllers/ClientController.php
@@ -8,10 +8,12 @@
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;
use Auth;
+use RealRashid\SweetAlert\Facades\Alert;
class ClientController extends Controller
{
@@ -22,71 +24,152 @@ 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) {
+ Alert::error('Failed', 'Clinic Number already exist in the system!');
+ return redirect('add/clients');
+ }
+ if ($new_client->save()) {
+ Alert::success('Success', 'Client has been registered successfully!');
+ return redirect('/Reports/facility_home');
+ } else {
+ Alert::error('Failed', 'An error has occurred please try again later.');
+ return back();
+ }
+ } 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..a5b0106 100644
--- a/app/Http/Controllers/ClientListController.php
+++ b/app/Http/Controllers/ClientListController.php
@@ -8,14 +8,20 @@
use Illuminate\Http\Request;
use App\Models\ClientList;
use App\Models\Group;
+use App\Models\Gender;
use App\Models\Clinic;
use App\Models\Client;
use App\Models\Outcome;
use App\Models\Message;
use App\Models\Facility;
use App\Models\ClientReport;
+use App\Models\Pmtct;
use Auth;
use DB;
+use Exception;
+use Session;
+use RealRashid\SweetAlert\Facades\Alert;
+
class ClientListController extends Controller
{
@@ -26,6 +32,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 +79,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 +99,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 +160,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 +220,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 +243,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 +305,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,40 +315,356 @@ 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()
{
if (Auth::user()->access_level == 'Facility') {
- $client_extract = ClientReport::join('tbl_client', 'client_report.id', '=', 'tbl_client.id')
- ->select(
- 'tbl_client.enrollment_date',
- 'tbl_client.art_date',
- 'client_report.clinic_number',
- 'client_report.gender',
- 'client_report.group_name',
- 'client_report.marital',
- 'client_report.created_at',
- 'client_report.month_year',
- 'client_report.LANGUAGE',
- 'client_report.txt_time',
- 'client_report.partner_name',
- 'client_report.county',
- 'client_report.sub_county',
- 'client_report.mfl_code',
- 'client_report.facility_name',
- 'client_report.consented',
- 'tbl_client.wellness_enable'
- )
+ $client_extract = ClientReport::select(
+ 'tbl_client.enrollment_date',
+ 'tbl_client.art_date',
+ 'client_report.clinic_number',
+ 'client_report.gender',
+ 'client_report.group_name',
+ 'client_report.marital',
+ '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',
+ 'client_report.sub_county',
+ 'client_report.mfl_code',
+ 'client_report.facility_name',
+ 'client_report.consented',
+ 'tbl_client.wellness_enable',
+ 'tbl_client.upi_no'
+ )
+ ->join('tbl_client', 'client_report.id', '=', 'tbl_client.id')
->where('client_report.mfl_code', Auth::user()->facility_id)
->get();
}
@@ -329,7 +688,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,10 +715,11 @@ 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;
+
}
if (Auth::user()->access_level == 'Admin') {
@@ -380,7 +741,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 +773,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 +801,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 +829,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 +856,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))
@@ -500,4 +866,66 @@ public function filter_client_extract(Request $request)
return view('clients.client_extract')->with('client_extract', $client_extract);
}
+
+ public function hei_list()
+ {
+ if (Auth::user()->access_level == 'Facility') {
+ $gender = Gender::all();
+ $hei_list = Pmtct::select('tbl_pmtct.id as id', 'tbl_client.id as client_id', 'tbl_pmtct.hei_first_name', 'tbl_pmtct.hei_middle_name', 'tbl_pmtct.hei_last_name', 'tbl_pmtct.hei_dob', 'tbl_gender.name as gender', 'tbl_gender.id as gender_id', 'tbl_pmtct.hei_no')
+ ->join('tbl_gender', 'tbl_gender.id', '=', 'tbl_pmtct.hei_gender')
+ ->join('tbl_client', 'tbl_client.id', '=', 'tbl_pmtct.client_id')
+ ->whereNotNull('tbl_pmtct.hei_no')
+ ->where('tbl_client.mfl_code', '=', Auth::user()->facility_id)
+ ->get();
+ }
+
+ return view('clients.hei_list', compact('hei_list', 'gender'));
+ }
+
+ public function edit_hei(Request $request)
+ {
+
+ try {
+ $client = Pmtct::where('id', $request->id)
+ ->update([
+ 'hei_no' => $request->clinic_number,
+ 'hei_first_name' => $request->first_name,
+ 'hei_middle_name' => $request->middle_name,
+ 'hei_last_name' => $request->last_name,
+ 'hei_dob' => $request->birth,
+ 'hei_gender' => $request->gender,
+
+ ]);
+
+ $hei_client = Client::where('hei_no', $request->old_clinic_number)
+ ->update([
+ 'hei_no' => $request->clinic_number,
+ 'f_name' => $request->first_name,
+ 'm_name' => $request->middle_name,
+ 'l_name' => $request->last_name,
+ 'dob' => $request->birth,
+ 'gender' => $request->gender,
+ ]);
+
+ if ($client) {
+ Alert::success('Success', 'HEI' . ' ' . $request->clinic_number . ' ' . 'details was successfully updated!');
+ return redirect('hei/list');
+ } elseif ($hei_client) {
+ Alert::success('Success', 'HEI' . ' ' . $request->clinic_number . ' ' . 'details was successfully updated!');
+ return redirect('hei/list');
+ } else {
+ Alert::error('Failed', 'Could not update HEI details please try again later.');
+ return back();
+ }
+ } catch (Exception $e) {
+ $code = $e->getCode();
+
+ if ((string)$code === (string)"23000") {
+ Alert::success('Success', 'HEI Number' . ' ' . $request->clinic_number . ' ' . 'belongs to another client! ');
+ return back();;
+ } else {
+ return back();
+ }
+ }
+ }
}
diff --git a/app/Http/Controllers/ConsentController.php b/app/Http/Controllers/ConsentController.php
index 0c921a9..46b9334 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')
- ->where('tbl_client.smsenable', '!=', 'Yes')
+ 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(function ($query) {
+ $query->where('tbl_client.smsenable', '!=', 'Yes')
+ ->orWhereNull('tbl_client.smsenable')
+ ->orWhere('tbl_client.smsenable', '');
+ })
+ ->whereNull('tbl_client.hei_no')
->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->get();
- }
- return view('clients.consent')->with('consented_clients', $consented_clients);
+ ->get();
+ }
+ return view('clients.consent')->with('consented_clients', $consented_clients);
}
public function addconsentform()
{
@@ -32,58 +39,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) {
+ $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) {
+ Alert::success('Success', 'Client was successfully consented in the system!');
+ return redirect('consent/clients');
+ } else {
+ Alert::error('Failed', 'Could not consent client please try again later.');
return back();
}
+ } 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) {
+ ]);
+ if ($client) {
+ Alert::success('Success', 'Client was successfully consented in the system!');
+ return redirect('consent/clients');
+ } else {
+ Alert::error('Failed', 'Could not consent client please try again later.');
return back();
}
-
+ } 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/DirectoryController.php b/app/Http/Controllers/DirectoryController.php
new file mode 100644
index 0000000..b1a2390
--- /dev/null
+++ b/app/Http/Controllers/DirectoryController.php
@@ -0,0 +1,42 @@
+successful()) {
+
+ $apiData = $response->json();
+ return response()->json($apiData);
+ } else {
+
+ $errorData = $response->json();
+ return response()->json(['error' => 'API request failed'], $response->status());
+ }
+ }
+ public function directoryLog(Request $request)
+ {
+ $searchTerm = $request->input('search_term');
+ $resultCount = $request->input('result_count');
+
+ // Save the log
+ DirectoryLog::create([
+ 'search_term' => $searchTerm,
+ 'result_count' => $resultCount,
+ ]);
+
+ return response()->json(['status' => 'success']);
+ }
+}
diff --git a/app/Http/Controllers/DonorController.php b/app/Http/Controllers/DonorController.php
index 6a92f7b..4ac1648 100644
--- a/app/Http/Controllers/DonorController.php
+++ b/app/Http/Controllers/DonorController.php
@@ -7,6 +7,7 @@
use Auth;
use PhpParser\Node\Stmt\TryCatch;
use Session;
+use RealRashid\SweetAlert\Facades\Alert;
class DonorController extends Controller
{
@@ -30,9 +31,9 @@ public function adddonor(Request $request)
->first();
if ($validate) {
- Session::flash('statuscode', 'error');
+ Alert::error('Failed', 'Phone Number is already used in the system!');
- return redirect('admin/donors/form')->with('status', 'Phone Number is already used in the system!');
+ return redirect('admin/donors/form');
}
$donor->name = $request->name;
@@ -45,17 +46,16 @@ public function adddonor(Request $request)
// $donor->created_by = Auth::;
if ($donor->save()) {
- Session::flash('statuscode', 'success');
-
- return redirect('admin/donors')->with('status', 'Donor has been saved successfully!');
+ Alert::success('Success', 'Donor has been saved successfully!');
+ return redirect('admin/donors');
} else {
- Session::flash('statuscode', 'error');
- return back()->with('error', 'An error has occurred please try again later.');
+ Alert::error('Failed', 'An error has occurred please try again later.');
+ return back();
}
} catch (Exception $e) {
- Session::flash('statuscode', 'error');
- return back()->with('error', 'An error has occurred please try again later.');
+ Alert::error('Failed', 'An error has occurred please try again later.');
+ return back();
}
}
public function editdonor(Request $request)
@@ -70,11 +70,11 @@ public function editdonor(Request $request)
'status' => $request->status,
]);
if ($donor) {
- Session::flash('statuscode', 'success');
- return redirect('admin/donors')->with('status', 'Donor was successfully Updated in the system!');
+ Alert::success('Success', 'Donor was successfully Updated in the system!');
+ return redirect('admin/donors');
} else {
- Session::flash('statuscode', 'error');
- return back()->with('error', 'Could not update donor please try again later.');
+ Alert::error('Failed', 'An error has occurred please try again later.');
+ return back();
}
} catch (Exception $e) {
return back();
@@ -87,11 +87,11 @@ public function deletedonor(Request $request)
$donor = Donor::find($request->id);
// $donor->update_at = date('Y-m-d H:i:s');
if ($donor->save()) {
- Session::flash('statuscode', 'success');
- return redirect('admin/donors')->with('status', 'Donor has been deleted successfully');
+ Alert::success('Success', 'Donor has been deleted successfully');
+ return redirect('admin/donors');
} else {
- Session::flash('statuscode', 'error');
- return back()->with('error', 'An error has occurred please try again later.');
+ Alert::error('Failed', 'An error has occurred please try again later.');
+ return back();
}
} catch (Exception $e) {
}
diff --git a/app/Http/Controllers/FacilityController.php b/app/Http/Controllers/FacilityController.php
index 8c031dc..46b9832 100644
--- a/app/Http/Controllers/FacilityController.php
+++ b/app/Http/Controllers/FacilityController.php
@@ -10,6 +10,7 @@
use App\Models\PartnerFacility;
use Session;
use Auth;
+use RealRashid\SweetAlert\Facades\Alert;
class FacilityController extends Controller
{
@@ -57,13 +58,11 @@ public function add_facility(Request $request)
]);
if ($facility->save() && $master_update) {
- Session::flash('statuscode', 'success');
-
- return redirect('admin/facilities')->with('status', 'Facility added successfully!');
+ Alert::success('Success', 'Facility added successfully!');
+ return redirect('admin/facilities');
} else {
-
- Session::flash('statuscode', 'error');
- return back()->with('error', 'An error has occurred please try again later.');
+ Alert::error('Failed', 'An error has occurred please try again later');
+ return back();
}
} catch (Exception $e) {
return back();
@@ -71,81 +70,161 @@ 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();
- }
- 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_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.name as partner_name'
- )
- ->get();
+ if (env('INSTANCE') === 'UshauriDOD') {
+ if (Auth::user()->access_level == 'Admin') {
+ $facilities = Facility::join('tbl_partner_facility', 'tbl_master_facility.code', '=', 'tbl_partner_facility.mfl_code')
+ ->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_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 == '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_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.mfl_code', Auth::user()->facility_id)
- ->get();
+ if (Auth::user()->access_level == 'Donor') {
+ $facilities = Facility::join('tbl_partner_facility', 'tbl_master_facility.code', '=', 'tbl_partner_facility.mfl_code')
+ ->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_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'
+ )
+ ->get();
+ }
+ if (Auth::user()->access_level == 'Facility') {
+ $facilities = Facility::join('tbl_partner_facility', 'tbl_master_facility.code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(
+ 'tbl_master_facility.name as facility_name',
+ 'tbl_master_facility.code',
+ 'tbl_master_facility.owner',
+ 'tbl_partner_facility.avg_clients as average_clients',
+ '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.mfl_code', Auth::user()->facility_id)
+ ->get();
}
if (Auth::user()->access_level == 'Partner') {
$all_partners = Partner::all()->where('status', '=', 'Active')
- ->where('id', Auth::user()->partner_id);
+ ->where('id', Auth::user()->partner_id);
+ $facilities = Facility::join('tbl_partner_facility', 'tbl_master_facility.code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(
+ 'tbl_master_facility.name as facility_name',
+ 'tbl_master_facility.code',
+ 'tbl_master_facility.owner',
+ 'tbl_partner_facility.avg_clients as average_clients',
+ '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_partner_facility', 'tbl_master_facility.code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(
+ 'tbl_master_facility.name as facility_name',
+ 'tbl_master_facility.code',
+ 'tbl_master_facility.owner',
+ 'tbl_partner_facility.avg_clients as average_clients',
+ '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_partner_facility', 'tbl_master_facility.code', '=', 'tbl_partner_facility.mfl_code')
+ ->select(
+ 'tbl_master_facility.name as facility_name',
+ 'tbl_master_facility.code',
+ 'tbl_master_facility.owner',
+ 'tbl_partner_facility.avg_clients as average_clients',
+ '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();
+ }
+ } else {
+ 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', '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_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.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_facility', 'tbl_master_facility.code', '=', 'tbl_partner_facility.mfl_code')
->join('tbl_consituency', 'tbl_master_facility.consituency_id', '=', 'tbl_consituency.id')
->select(
@@ -160,12 +239,92 @@ 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')
+ ->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');
+ 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)
@@ -179,13 +338,12 @@ public function approve_facility(Request $request)
'updated_by' => Auth::user()->id,
]);
if ($approve) {
- Session::flash('statuscode', 'success');
-
- return redirect('admin/my_facilities')->with('status', 'Facility has been approved successfully!');
+ Alert::success('Success', 'Facility has been approved successfully!');
+ return redirect('admin/my_facilities');
} else {
- Session::flash('statuscode', 'error');
- return back()->with('error', 'An error has occurred please try again later.');
+ Alert::error('Failed', 'An error has occurred please try again later.');
+ return back();
}
} catch (Exception $e) {
return back();
@@ -194,22 +352,20 @@ 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) {
+ Alert::success('Success', 'Facility updated successfully!');
+ return redirect('admin/my_facilities');
+ } else {
+ Alert::error('Failed', 'An error has occurred please try again later.');
+ return back();
+ }
+ } 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..8e312f8
--- /dev/null
+++ b/app/Http/Controllers/FinalDashboardController.php
@@ -0,0 +1,4209 @@
+remember_period = env('REMEMBER_PERIOD', '60 * 60 * 24');
+ }
+
+ 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', '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);
+
+ $consented_clients = ClientDashboard::select(
+ DB::raw('SUM(client_consented) AS consented '),
+ DB::raw('ROUND((SUM(client_consented) / (SUM(non_consented) + SUM(client_consented))) * 100, 2) AS percent_consented')
+ )
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ // $all_tx_curr = Txcurr::select('tx_cur')
+ // ->where('period', function ($query) {
+ // $query->select(DB::raw('MAX(period)'))
+ // ->from('tbl_tx_cur');
+ // })
+ // ->where('mfl_code', Auth::user()->facility_id)
+ // ->remember($this->remember_period);
+
+ $all_tx_curr = Txcurr::selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest.max_period');
+ })
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)
+ ->groupBy('tbl_tx_cur.mfl_code')
+ ->remember($this->remember_period)
+ ->get();
+ $all_tx_curr = $all_tx_curr->sum('tx_cur');
+
+
+ $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('COUNT(etl_appointment_detail.id) AS total_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_client_detail.ccc_number')
+ ->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 '
+ )
+ ->join(DB::raw('(SELECT MAX(appointment_id) as max_appointment_id, client_id FROM etl_appointment_detail GROUP BY client_id) as max_appointments'), function ($join) {
+ $join->on('etl_appointment_detail.appointment_id', '=', 'max_appointments.max_appointment_id')
+ ->on('etl_appointment_detail.client_id', '=', 'max_appointments.client_id');
+ })
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->groupBy('etl_appointment_detail.client_id')
+ ->remember($this->remember_period);
+
+ $missed_age = ETLAppointment::select(
+ 'age_group',
+ DB::raw('SUM(app_not_kept) AS not_kept_app '),
+ // DB::raw('COUNT(id) AS total_app '),
+ DB::raw('SUM(CASE WHEN final_outcome = "Client returned to care" THEN rtc_no 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_client_detail.dsd_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_rate = ETLAppointment::select(
+ DB::raw('DATE_FORMAT(appointment_date, "%Y-%M") AS new_date'),
+ DB::raw('SUM(CASE WHEN appointment_status = "Missed" THEN app_not_kept END) AS missed_app'),
+ DB::raw('SUM(CASE WHEN appointment_status = "Defaulted" THEN app_not_kept END) AS defaulted_app'),
+ DB::raw('SUM(CASE WHEN appointment_status = "IIT" THEN app_not_kept END) AS iit_app'),
+ DB::raw('SUM(app_not_kept) AS app_not_kept'),
+ 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 '),
+ DB::raw('ROUND(AVG(days_defaulted),0) AS days_defaulted '),
+ DB::raw('SUM(rtc_no) AS no_rtc')
+ )
+ ->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);
+
+ $data["all_appoinments"] = $all_appoinments->get();
+ $data["consented_clients"] = $consented_clients->get();
+ $data["all_tx_curr"] = $all_tx_curr;
+ $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_rate"] = $app_rate->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 = ClientDashboard::select(
+ DB::raw('SUM(client_consented) AS consented '),
+ DB::raw('ROUND((SUM(client_consented) / (SUM(non_consented) + SUM(client_consented))) * 100, 2) AS percent_consented')
+ )
+ ->remember($this->remember_period);
+
+ // $all_tx_curr = Txcurr::where('period', function ($query) {
+ // $query->select(DB::raw('MAX(period)'))
+ // ->from('tbl_tx_cur');
+ // })
+ // ->remember($this->remember_period);
+
+ $all_tx_curr = Txcurr::selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest.max_period');
+ })
+ ->groupBy('tbl_tx_cur.mfl_code')
+ ->remember($this->remember_period)
+ ->get();
+ $all_tx_curr = $all_tx_curr->sum('tx_cur');
+
+ $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 '
+ )
+ ->join(DB::raw('(SELECT MAX(appointment_id) as max_appointment_id, client_id FROM etl_appointment_detail GROUP BY client_id) as max_appointments'), function ($join) {
+ $join->on('etl_appointment_detail.appointment_id', '=', 'max_appointments.max_appointment_id')
+ ->on('etl_appointment_detail.client_id', '=', 'max_appointments.client_id');
+ })
+ ->groupBy('etl_appointment_detail.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_rate = ETLAppointment::selectRaw(
+ 'DATE_FORMAT(appointment_date, "%Y-%M") AS new_date,
+ SUM(CASE WHEN appointment_status = "Missed" THEN app_not_kept END) AS missed_app,
+ SUM(CASE WHEN appointment_status = "Defaulted" THEN app_not_kept END) AS defaulted_app,
+ SUM(CASE WHEN appointment_status = "IIT" THEN app_not_kept END) AS iit_app,
+ SUM(app_not_kept) AS app_not_kept,
+ 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,
+ ROUND(AVG(days_defaulted),0) AS days_defaulted,
+ SUM(rtc_no) AS no_rtc'
+ )
+ ->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);
+
+ $data["all_appoinments"] = $all_appoinments->get();
+ $data["consented_clients"] = $consented_clients->get();
+ $data["all_tx_curr"] = $all_tx_curr;
+ $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_rate"] = $app_rate->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 = ClientDashboard::select(
+ DB::raw('SUM(client_consented) AS consented '),
+ DB::raw('ROUND((SUM(client_consented) / (SUM(non_consented) + SUM(client_consented))) * 100, 2) AS percent_consented')
+ )
+ ->where('partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ // $all_tx_curr = Txcurr::join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ // ->where('tbl_tx_cur.period', function ($query) {
+ // $query->select(DB::raw('MAX(tbl_tx_cur.period)'))
+ // ->from('tbl_tx_cur');
+ // })
+ // ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ // ->remember($this->remember_period);
+
+ $all_tx_curr = Txcurr::selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest.max_period');
+ })
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->groupBy('tbl_tx_cur.mfl_code')
+ ->remember($this->remember_period)
+ ->get();
+ $all_tx_curr = $all_tx_curr->sum('tx_cur');
+
+ $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);
+
+ // $client_missed = ETLAppointment::selectRaw('
+ // client_id,
+ // MAX(appointment_id) AS max_appointment_id,
+ // SUM(app_not_kept) AS not_kept_app,
+ // SUM(CASE WHEN appointment_status IN ("Missed", "Defaulted", "IIT") THEN received_sms ELSE 0 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 IN ("Missed", "Defaulted", "IIT") THEN called ELSE 0 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 IN ("Missed", "Defaulted", "IIT") THEN physically_traced ELSE 0 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 IN ("Missed", "Defaulted", "IIT") THEN rtc_no ELSE 0 END) AS final_outcome,
+ // SUM(CASE WHEN rtc_no = "Client returned to care" AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_outcome,
+ // SUM(CASE WHEN rtc_no = "Client returned to care" AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_outcome,
+ // SUM(CASE WHEN rtc_no = "Client returned to care" AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_outcome,
+ // SUM(CASE WHEN appointment_status IN ("Missed", "Defaulted", "IIT") THEN consent_no ELSE 0 END) AS consent,
+ // SUM(CASE WHEN consent_no = "Yes" AND appointment_status = "Missed" THEN 1 ELSE 0 END) AS missed_consent,
+ // SUM(CASE WHEN consent_no = "Yes" AND appointment_status = "Defaulted" THEN 1 ELSE 0 END) AS defaulted_consent,
+ // SUM(CASE WHEN consent_no = "Yes" AND appointment_status = "IIT" THEN 1 ELSE 0 END) AS iit_consent
+ // ')
+ // ->where('partner_id', Auth::user()->partner_id)
+ // ->groupBy('client_id')
+ // ->orderBy('max_appointment_id', 'desc')
+ // ->get();
+
+ // Fetch the data without grouping or aggregation
+ // $client_missed_data = ETLAppointment::select(
+ // 'client_id',
+ // 'appointment_id', // Add appointment_id to fetch the maximum value later
+ // 'app_not_kept',
+ // 'appointment_status',
+ // 'received_sms',
+ // 'called',
+ // 'physically_traced',
+ // 'rtc_no',
+ // 'consent_no'
+ // )
+ // ->where('partner_id', Auth::user()->partner_id)
+ // ->get();
+
+ // // Perform grouping and aggregation in-memory using Laravel Collection methods
+ // $client_missed = $client_missed_data->groupBy('client_id')->map(function ($appointments) {
+ // return [
+ // 'max_appointment_id' => $appointments->max('appointment_id'), // Get the maximum appointment_id
+ // 'not_kept_app' => $appointments->sum('app_not_kept'),
+ // 'messages' => $appointments->whereIn('appointment_status', ['Missed', 'Defaulted', 'IIT'])->sum('received_sms'),
+ // 'missed_messages' => $appointments->where('received_sms', 1)->where('appointment_status', 'Missed')->count(),
+ // 'defaulted_messages' => $appointments->where('received_sms', 1)->where('appointment_status', 'Defaulted')->count(),
+ // 'iit_messages' => $appointments->where('received_sms', 1)->where('appointment_status', 'IIT')->count(),
+ // 'called' => $appointments->whereIn('appointment_status', ['Missed', 'Defaulted', 'IIT'])->sum('called'),
+ // 'missed_called' => $appointments->where('called', 1)->where('appointment_status', 'Missed')->count(),
+ // 'defaulted_called' => $appointments->where('called', 1)->where('appointment_status', 'Defaulted')->count(),
+ // 'iit_called' => $appointments->where('called', 1)->where('appointment_status', 'IIT')->count(),
+ // 'physically_traced' => $appointments->whereIn('appointment_status', ['Missed', 'Defaulted', 'IIT'])->sum('physically_traced'),
+ // 'missed_traced' => $appointments->where('physically_traced', 1)->where('appointment_status', 'Missed')->count(),
+ // 'defaulted_traced' => $appointments->where('physically_traced', 1)->where('appointment_status', 'Defaulted')->count(),
+ // 'iit_traced' => $appointments->where('physically_traced', 1)->where('appointment_status', 'IIT')->count(),
+ // 'final_outcome' => $appointments->whereIn('appointment_status', ['Missed', 'Defaulted', 'IIT'])->sum('rtc_no'),
+ // 'missed_outcome' => $appointments->where('rtc_no', 'Client returned to care')->where('appointment_status', 'Missed')->count(),
+ // 'defaulted_outcome' => $appointments->where('rtc_no', 'Client returned to care')->where('appointment_status', 'Defaulted')->count(),
+ // 'iit_outcome' => $appointments->where('rtc_no', 'Client returned to care')->where('appointment_status', 'IIT')->count(),
+ // 'consent' => $appointments->whereIn('appointment_status', ['Missed', 'Defaulted', 'IIT'])->sum('consent_no'),
+ // 'missed_consent' => $appointments->where('consent_no', 'Yes')->where('appointment_status', 'Missed')->count(),
+ // 'defaulted_consent' => $appointments->where('consent_no', 'Yes')->where('appointment_status', 'Defaulted')->count(),
+ // 'iit_consent' => $appointments->where('consent_no', 'Yes')->where('appointment_status', 'IIT')->count(),
+ // ];
+ // })->toArray();
+
+ // Now $client_missed contains the aggregated data for each client, including the max_appointment_id
+
+
+ // 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 '
+ )
+ ->join(DB::raw('(SELECT MAX(appointment_id) as max_appointment_id, client_id FROM etl_appointment_detail GROUP BY client_id) as max_appointments'), function ($join) {
+ $join->on('etl_appointment_detail.appointment_id', '=', 'max_appointments.max_appointment_id')
+ ->on('etl_appointment_detail.client_id', '=', 'max_appointments.client_id');
+ })
+ ->where('etl_appointment_detail.partner_id', Auth::user()->partner_id)
+ ->groupBy('etl_appointment_detail.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_rate = ETLAppointment::selectRaw(
+ 'DATE_FORMAT(appointment_date, "%Y-%M") AS new_date,
+ SUM(CASE WHEN appointment_status = "Missed" THEN app_not_kept END) AS missed_app,
+ SUM(CASE WHEN appointment_status = "Defaulted" THEN app_not_kept END) AS defaulted_app,
+ SUM(CASE WHEN appointment_status = "IIT" THEN app_not_kept END) AS iit_app,
+ SUM(app_not_kept) AS app_not_kept,
+ 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,
+ ROUND(AVG(days_defaulted),0) AS days_defaulted,
+ SUM(rtc_no) AS no_rtc'
+ )
+ ->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);
+
+ $data["all_appoinments"] = $all_appoinments->get();
+ $data["consented_clients"] = $consented_clients->get();
+ $data["all_tx_curr"] = $all_tx_curr;
+ $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_rate"] = $app_rate->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 = ClientDashboard::select(
+ DB::raw('SUM(client_consented) AS consented '),
+ DB::raw('ROUND((SUM(client_consented) / (SUM(non_consented) + SUM(client_consented))) * 100, 2) AS percent_consented')
+ )
+ ->where('sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ // $all_tx_curr = Txcurr::join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ // ->where('tbl_tx_cur.period', function ($query) {
+ // $query->select(DB::raw('MAX(tbl_tx_cur.period)'))
+ // ->from('tbl_tx_cur');
+ // })
+ // ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ // ->remember($this->remember_period);
+
+ $all_tx_curr = Txcurr::selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest.max_period');
+ })
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->groupBy('tbl_tx_cur.mfl_code')
+ ->remember($this->remember_period)
+ ->get();
+ $all_tx_curr = $all_tx_curr->sum('tx_cur');
+
+ $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 '
+ )
+ ->join(DB::raw('(SELECT MAX(appointment_id) as max_appointment_id, client_id FROM etl_appointment_detail GROUP BY client_id) as max_appointments'), function ($join) {
+ $join->on('etl_appointment_detail.appointment_id', '=', 'max_appointments.max_appointment_id')
+ ->on('etl_appointment_detail.client_id', '=', 'max_appointments.client_id');
+ })
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->groupBy('etl_appointment_detail.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_rate = ETLAppointment::selectRaw(
+ 'DATE_FORMAT(appointment_date, "%Y-%M") AS new_date,
+ SUM(CASE WHEN appointment_status = "Missed" THEN app_not_kept END) AS missed_app,
+ SUM(CASE WHEN appointment_status = "Defaulted" THEN app_not_kept END) AS defaulted_app,
+ SUM(CASE WHEN appointment_status = "IIT" THEN app_not_kept END) AS iit_app,
+ SUM(app_not_kept) AS app_not_kept,
+ 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,
+ ROUND(AVG(days_defaulted),0) AS days_defaulted,
+ SUM(rtc_no) AS no_rtc'
+ )
+ ->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);
+
+ $data["all_appoinments"] = $all_appoinments->get();
+ $data["consented_clients"] = $consented_clients->get();
+ $data["all_tx_curr"] = $all_tx_curr;
+ $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_rate"] = $app_rate->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 = ClientDashboard::select(
+ DB::raw('SUM(client_consented) AS consented '),
+ DB::raw('ROUND((SUM(client_consented) / (SUM(non_consented) + SUM(client_consented))) * 100, 2) AS percent_consented')
+ )
+ ->where('county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ // $all_tx_curr = Txcurr::join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ // ->where('tbl_tx_cur.period', function ($query) {
+ // $query->select(DB::raw('MAX(tbl_tx_cur.period)'))
+ // ->from('tbl_tx_cur');
+ // })
+ // ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ // ->remember($this->remember_period);
+
+ $all_tx_curr = Txcurr::selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest.max_period');
+ })
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->groupBy('tbl_tx_cur.mfl_code')
+ ->remember($this->remember_period)
+ ->get();
+ $all_tx_curr = $all_tx_curr->sum('tx_cur');
+
+ $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 '
+ )
+ ->join(DB::raw('(SELECT MAX(appointment_id) as max_appointment_id, client_id FROM etl_appointment_detail GROUP BY client_id) as max_appointments'), function ($join) {
+ $join->on('etl_appointment_detail.appointment_id', '=', 'max_appointments.max_appointment_id')
+ ->on('etl_appointment_detail.client_id', '=', 'max_appointments.client_id');
+ })
+ ->where('county_id', Auth::user()->county_id)
+ ->groupBy('etl_appointment_detail.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_rate = ETLAppointment::selectRaw(
+ 'DATE_FORMAT(appointment_date, "%Y-%M") AS new_date,
+ SUM(CASE WHEN appointment_status = "Missed" THEN app_not_kept END) AS missed_app,
+ SUM(CASE WHEN appointment_status = "Defaulted" THEN app_not_kept END) AS defaulted_app,
+ SUM(CASE WHEN appointment_status = "IIT" THEN app_not_kept END) AS iit_app,
+ SUM(app_not_kept) AS app_not_kept,
+ 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,
+ ROUND(AVG(days_defaulted),0) AS days_defaulted,
+ SUM(rtc_no) AS no_rtc'
+ )
+ ->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);
+
+ $data["all_appoinments"] = $all_appoinments->get();
+ $data["consented_clients"] = $consented_clients->get();
+ $data["all_tx_curr"] = $all_tx_curr;
+ $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_rate"] = $app_rate->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 = ClientDashboard::select(
+ DB::raw('SUM(client_consented) AS consented '),
+ DB::raw('ROUND((SUM(client_consented) / (SUM(non_consented) + SUM(client_consented))) * 100, 2) AS percent_consented')
+ )
+ ->remember($this->remember_period);
+
+ $query = Txcurr::query()->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code');
+
+ $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 '
+ )
+ ->join(DB::raw('(SELECT MAX(appointment_id) as max_appointment_id, client_id FROM etl_appointment_detail GROUP BY client_id) as max_appointments'), function ($join) {
+ $join->on('etl_appointment_detail.appointment_id', '=', 'max_appointments.max_appointment_id')
+ ->on('etl_appointment_detail.client_id', '=', 'max_appointments.client_id');
+ })
+ ->groupBy('etl_appointment_detail.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_rate = ETLAppointment::selectRaw(
+ 'DATE_FORMAT(appointment_date, "%Y-%M") AS new_date,
+ SUM(CASE WHEN appointment_status = "Missed" THEN app_not_kept END) AS missed_app,
+ SUM(CASE WHEN appointment_status = "Defaulted" THEN app_not_kept END) AS defaulted_app,
+ SUM(CASE WHEN appointment_status = "IIT" THEN app_not_kept END) AS iit_app,
+ SUM(app_not_kept) AS app_not_kept,
+ 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,
+ ROUND(AVG(days_defaulted),0) AS days_defaulted,
+ SUM(rtc_no) AS no_rtc'
+ )
+ ->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);
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest.max_period');
+ })->where('tbl_partner_facility.partner_id', $selected_partners)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->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);
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_con'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_con.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_con.max_period');
+ })->where('tbl_partner_facility.county_id', $selected_counties)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->where('county_id', $selected_counties);
+ }
+ if (!empty($selected_subcounties)) {
+ $all_appoinments = $all_appoinments->where('subcounty_id', $selected_subcounties);
+ $consented_clients = $consented_clients->where('sub_county_id', $selected_subcounties);
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_sub'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_sub.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_sub.max_period');
+ })
+ ->where('sub_county_id', $selected_subcounties)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->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);
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_fac'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_fac.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_fac.max_period');
+ })
+ ->where('tbl_partner_facility.mfl_code', $selected_facilites)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->where('mfl_code', $selected_facilites);
+ }
+
+ if (!empty($selected_clinics)) {
+ $all_appoinments = $all_appoinments->where('clinic_type', $selected_clinics);
+ $consented_clients = $consented_clients;
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_clinic'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_clinic.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_clinic.max_period');
+ })
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->where('clinic_type', $selected_clinics);
+ }
+ if (!empty($selected_appointments)) {
+ $all_appoinments = $all_appoinments;
+ $consented_clients = $consented_clients;
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_app'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_app.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_app.max_period');
+ })
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->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('consent_date', '>=', date($request->from))->where('consent_date', '<=', date($request->to));
+ $selectedFrom = date('Ym', strtotime($request->from));
+ $selectedTo = date('Ym', strtotime($request->to));
+
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_date'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_date.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_date.max_period');
+ })
+ ->where(function ($query) use ($selectedFrom, $selectedTo) {
+ $query->whereRaw("SUBSTRING(tbl_tx_cur.period, 1, 6) >= ?", $selectedFrom)
+ ->whereRaw("SUBSTRING(tbl_tx_cur.period, 1, 6) <= ?", $selectedTo);
+ })
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->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;
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_site'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_site.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_site.max_period');
+ })
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->where('facility_type', $selected_site);
+ }
+
+ $data["all_appoinments"] = $all_appoinments->get();
+ $data["consented_clients"] = $consented_clients->get();
+ $data["all_tx_curr"] = $all_tx_curr;
+ $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_rate"] = $app_rate->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 = ClientDashboard::select(
+ DB::raw('SUM(client_consented) AS consented '),
+ DB::raw('ROUND((SUM(client_consented) / (SUM(non_consented) + SUM(client_consented))) * 100, 2) AS percent_consented')
+ )
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $query = Txcurr::query()->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id);
+
+ $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_client_detail.ccc_number')
+ ->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 '
+ )
+ ->join(DB::raw('(SELECT MAX(appointment_id) as max_appointment_id, client_id FROM etl_appointment_detail GROUP BY client_id) as max_appointments'), function ($join) {
+ $join->on('etl_appointment_detail.appointment_id', '=', 'max_appointments.max_appointment_id')
+ ->on('etl_appointment_detail.client_id', '=', 'max_appointments.client_id');
+ })
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->groupBy('etl_appointment_detail.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_client_detail.dsd_status',
+ '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_rate = ETLAppointment::selectRaw(
+ 'DATE_FORMAT(appointment_date, "%Y-%M") AS new_date,
+ SUM(CASE WHEN appointment_status = "Missed" THEN app_not_kept END) AS missed_app,
+ SUM(CASE WHEN appointment_status = "Defaulted" THEN app_not_kept END) AS defaulted_app,
+ SUM(CASE WHEN appointment_status = "IIT" THEN app_not_kept END) AS iit_app,
+ SUM(app_not_kept) AS app_not_kept,
+ 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,
+ ROUND(AVG(days_defaulted),0) AS days_defaulted,
+ SUM(rtc_no) AS no_rtc'
+ )
+ ->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 (!empty($selected_partners)) {
+ $all_appoinments = $all_appoinments->where('partner_id', $selected_partners);
+ $consented_clients = $consented_clients->where('partner_id', $selected_partners);
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest.max_period');
+ })->where('tbl_partner_facility.partner_id', $selected_partners)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->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);
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_con'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_con.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_con.max_period');
+ })->where('tbl_partner_facility.county_id', $selected_counties)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->where('county_id', $selected_counties);
+ }
+ if (!empty($selected_subcounties)) {
+ $all_appoinments = $all_appoinments->where('subcounty_id', $selected_subcounties);
+ $consented_clients = $consented_clients->where('sub_county_id', $selected_subcounties);
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_sub'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_sub.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_sub.max_period');
+ })
+ ->where('sub_county_id', $selected_subcounties)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->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);
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_fac'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_fac.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_fac.max_period');
+ })
+ ->where('tbl_partner_facility.mfl_code', $selected_facilites)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->where('mfl_code', $selected_facilites);
+ }
+
+ if (!empty($selected_clinics)) {
+ $all_appoinments = $all_appoinments->where('clinic_type', $selected_clinics);
+ $consented_clients = $consented_clients;
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_clinic'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_clinic.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_clinic.max_period');
+ })
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->where('clinic_type', $selected_clinics);
+ }
+ if (!empty($selected_appointments)) {
+ $all_appoinments = $all_appoinments;
+ $consented_clients = $consented_clients;
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_app'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_app.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_app.max_period');
+ })
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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->where('appointment_status', $selected_appointments);
+ $client_missed = $client_missed->where('appointment_status', $selected_appointments);
+ $missed_age = $missed_age;
+ $missed_gender = $missed_gender;
+ $missed_marital = $missed_marital;
+ $missed_county = $missed_county;
+ $missed_partner = $missed_partner;
+ $client_app_list = $client_app_list->where('appointment_status', $selected_appointments);
+ $app_rate = $app_rate;
+ }
+ 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('consent_date', '>=', date($request->from))->where('consent_date', '<=', date($request->to));
+ $selectedFrom = date('Ym', strtotime($request->from));
+ $selectedTo = date('Ym', strtotime($request->to));
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_date'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_date.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_date.max_period');
+ })
+ ->where(function ($query) use ($selectedFrom, $selectedTo) {
+ $query->whereRaw("SUBSTRING(tbl_tx_cur.period, 1, 6) >= ?", $selectedFrom)
+ ->whereRaw("SUBSTRING(tbl_tx_cur.period, 1, 6) <= ?", $selectedTo);
+ })
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+
+ // $all_tx_curr = $all_tx_curr->whereRaw('tbl_tx_cur.period', '>=', DB::raw("DATE_FORMAT($request->from, '%Y%m')"))->whereRaw('tbl_tx_cur.period', '<=', DB::raw("DATE_FORMAT($request->to, '%Y%m')"));
+ $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->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));
+ $client_app_list = $client_app_list->where('appointment_date', '>=', date($request->from))->where('appointment_date', '<=', date($request->to));
+ $app_rate = $app_rate->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;
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_sites'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_sites.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_sites.max_period');
+ })
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->where('facility_type', $selected_sites);
+ }
+
+ $data["all_appoinments"] = $all_appoinments->get();
+ $data["consented_clients"] = $consented_clients->get();
+ $data["all_tx_curr"] = $all_tx_curr;
+ $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->groupBy('etl_appointment_detail.client_id')->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_rate"] = $app_rate->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 = ClientDashboard::select(
+ DB::raw('SUM(client_consented) AS consented '),
+ DB::raw('ROUND((SUM(client_consented) / (SUM(non_consented) + SUM(client_consented))) * 100, 2) AS percent_consented')
+ )
+ ->where('partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ $query = Txcurr::query()->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id);
+
+ $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 '
+ )
+ ->join(DB::raw('(SELECT MAX(appointment_id) as max_appointment_id, client_id FROM etl_appointment_detail GROUP BY client_id) as max_appointments'), function ($join) {
+ $join->on('etl_appointment_detail.appointment_id', '=', 'max_appointments.max_appointment_id')
+ ->on('etl_appointment_detail.client_id', '=', 'max_appointments.client_id');
+ })
+ ->where('partner_id', Auth::user()->partner_id)
+ ->groupBy('etl_appointment_detail.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_rate = ETLAppointment::selectRaw(
+ 'DATE_FORMAT(appointment_date, "%Y-%M") AS new_date,
+ SUM(CASE WHEN appointment_status = "Missed" THEN app_not_kept END) AS missed_app,
+ SUM(CASE WHEN appointment_status = "Defaulted" THEN app_not_kept END) AS defaulted_app,
+ SUM(CASE WHEN appointment_status = "IIT" THEN app_not_kept END) AS iit_app,
+ SUM(app_not_kept) AS app_not_kept,
+ 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,
+ ROUND(AVG(days_defaulted),0) AS days_defaulted,
+ SUM(rtc_no) AS no_rtc'
+ )
+ ->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);
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest.max_period');
+ })->where('tbl_partner_facility.partner_id', $selected_partners)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->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);
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_con'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_con.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_con.max_period');
+ })->where('tbl_partner_facility.county_id', $selected_counties)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->where('county_id', $selected_counties);
+ }
+ if (!empty($selected_subcounties)) {
+ $all_appoinments = $all_appoinments->where('subcounty_id', $selected_subcounties);
+ $consented_clients = $consented_clients->where('sub_county_id', $selected_subcounties);
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_sub'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_sub.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_sub.max_period');
+ })
+ ->where('sub_county_id', $selected_subcounties)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->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);
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_fac'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_fac.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_fac.max_period');
+ })
+ ->where('tbl_partner_facility.mfl_code', $selected_facilites)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->where('mfl_code', $selected_facilites);
+ }
+
+ if (!empty($selected_clinics)) {
+ $all_appoinments = $all_appoinments->where('clinic_type', $selected_clinics);
+ $consented_clients = $consented_clients;
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_clinic'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_clinic.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_clinic.max_period');
+ })
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->where('clinic_type', $selected_clinics);
+ }
+ if (!empty($selected_appointments)) {
+ $all_appoinments = $all_appoinments;
+ $consented_clients = $consented_clients;
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_app'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_app.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_app.max_period');
+ })
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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;
+ $missed_gender = $missed_gender;
+ $missed_marital = $missed_marital;
+ $missed_county = $missed_county;
+ $missed_partner = $missed_partner;
+ $missed_facility = $missed_facility;
+ $client_app_list = $client_app_list;
+ $app_rate = $app_rate;
+ }
+ 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('consent_date', '>=', date($request->from))->where('consent_date', '<=', date($request->to));
+ $selectedFrom = date('Ym', strtotime($request->from));
+ $selectedTo = date('Ym', strtotime($request->to));
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_date'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_date.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_date.max_period');
+ })
+ ->where(function ($query) use ($selectedFrom, $selectedTo) {
+ $query->whereRaw("SUBSTRING(tbl_tx_cur.period, 1, 6) >= ?", $selectedFrom)
+ ->whereRaw("SUBSTRING(tbl_tx_cur.period, 1, 6) <= ?", $selectedTo);
+ })
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->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;
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_site'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_site.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_site.max_period');
+ })
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->where('facility_type', $selected_site);
+ }
+
+ $data["all_appoinments"] = $all_appoinments->get();
+ $data["consented_clients"] = $consented_clients->get();
+ $data["all_tx_curr"] = $all_tx_curr;
+ $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_rate"] = $app_rate->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 = ClientDashboard::select(
+ DB::raw('SUM(client_consented) AS consented '),
+ DB::raw('ROUND((SUM(client_consented) / (SUM(non_consented) + SUM(client_consented))) * 100, 2) AS percent_consented')
+ )
+ ->where('sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ $query = Txcurr::query()->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);
+
+ $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 '
+ )
+ ->join(DB::raw('(SELECT MAX(appointment_id) as max_appointment_id, client_id FROM etl_appointment_detail GROUP BY client_id) as max_appointments'), function ($join) {
+ $join->on('etl_appointment_detail.appointment_id', '=', 'max_appointments.max_appointment_id')
+ ->on('etl_appointment_detail.client_id', '=', 'max_appointments.client_id');
+ })
+ ->where('subcounty_id', Auth::user()->subcounty_id)
+ ->groupBy('etl_appointment_detail.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_rate = ETLAppointment::selectRaw(
+ 'DATE_FORMAT(appointment_date, "%Y-%M") AS new_date,
+ SUM(CASE WHEN appointment_status = "Missed" THEN app_not_kept END) AS missed_app,
+ SUM(CASE WHEN appointment_status = "Defaulted" THEN app_not_kept END) AS defaulted_app,
+ SUM(CASE WHEN appointment_status = "IIT" THEN app_not_kept END) AS iit_app,
+ SUM(app_not_kept) AS app_not_kept,
+ 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,
+ ROUND(AVG(days_defaulted),0) AS days_defaulted,
+ SUM(rtc_no) AS no_rtc'
+ )
+ ->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);
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest.max_period');
+ })->where('tbl_partner_facility.partner_id', $selected_partners)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->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);
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_con'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_con.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_con.max_period');
+ })->where('tbl_partner_facility.county_id', $selected_counties)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->where('county_id', $selected_counties);
+ }
+ if (!empty($selected_subcounties)) {
+ $all_appoinments = $all_appoinments->where('subcounty_id', $selected_subcounties);
+ $consented_clients = $consented_clients->where('sub_county_id', $selected_subcounties);
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_sub'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_sub.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_sub.max_period');
+ })
+ ->where('sub_county_id', $selected_subcounties)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->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);
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_fac'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_fac.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_fac.max_period');
+ })
+ ->where('tbl_partner_facility.mfl_code', $selected_facilites)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->where('mfl_code', $selected_facilites);
+ }
+
+ if (!empty($selected_clinics)) {
+ $all_appoinments = $all_appoinments->where('clinic_type', $selected_clinics);
+ $consented_clients = $consented_clients;
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_clinic'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_clinic.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_clinic.max_period');
+ })
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->where('clinic_type', $selected_clinics);
+ }
+ if (!empty($selected_appointments)) {
+ $all_appoinments = $all_appoinments;
+ $consented_clients = $consented_clients;
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_dsd'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_dsd.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_dsd.max_period');
+ })
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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;
+ $missed_gender = $missed_gender;
+ $missed_marital = $missed_marital;
+ $missed_county = $missed_county;
+ $missed_partner = $missed_partner;
+ $missed_facility = $missed_facility;
+ $client_app_list = $client_app_list;
+ $app_rate = $app_rate;
+ }
+ 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('consent_date', '>=', date($request->from))->where('consent_date', '<=', date($request->to));
+ $selectedFrom = date('Ym', strtotime($request->from));
+ $selectedTo = date('Ym', strtotime($request->to));
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_fac'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_fac.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_fac.max_period');
+ })
+ ->where(function ($query) use ($selectedFrom, $selectedTo) {
+ $query->whereRaw("SUBSTRING(tbl_tx_cur.period, 1, 6) >= ?", $selectedFrom)
+ ->whereRaw("SUBSTRING(tbl_tx_cur.period, 1, 6) <= ?", $selectedTo);
+ })
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->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;
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_site'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_site.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_site.max_period');
+ })
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->where('facility_type', $selected_sites);
+ }
+
+ $data["all_appoinments"] = $all_appoinments->get();
+ $data["consented_clients"] = $consented_clients->get();
+ $data["all_tx_curr"] = $all_tx_curr;
+ $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_rate"] = $app_rate->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 = ClientDashboard::select(
+ DB::raw('SUM(client_consented) AS consented '),
+ DB::raw('ROUND((SUM(client_consented) / (SUM(non_consented) + SUM(client_consented))) * 100, 2) AS percent_consented')
+ )
+ ->where('county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ $query = Txcurr::query()->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id);
+
+ $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 '
+ )
+ ->join(DB::raw('(SELECT MAX(appointment_id) as max_appointment_id, client_id FROM etl_appointment_detail GROUP BY client_id) as max_appointments'), function ($join) {
+ $join->on('etl_appointment_detail.appointment_id', '=', 'max_appointments.max_appointment_id')
+ ->on('etl_appointment_detail.client_id', '=', 'max_appointments.client_id');
+ })
+ ->where('county_id', Auth::user()->county_id)
+ ->groupBy('etl_appointment_detail.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_rate = ETLAppointment::selectRaw(
+ 'DATE_FORMAT(appointment_date, "%Y-%M") AS new_date,
+ SUM(CASE WHEN appointment_status = "Missed" THEN app_not_kept END) AS missed_app,
+ SUM(CASE WHEN appointment_status = "Defaulted" THEN app_not_kept END) AS defaulted_app,
+ SUM(CASE WHEN appointment_status = "IIT" THEN app_not_kept END) AS iit_app,
+ SUM(app_not_kept) AS app_not_kept,
+ 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,
+ ROUND(AVG(days_defaulted),0) AS days_defaulted,
+ SUM(rtc_no) AS no_rtc'
+ )
+ ->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);
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest.max_period');
+ })->where('tbl_partner_facility.partner_id', $selected_partners)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->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);
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_con'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_con.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_con.max_period');
+ })->where('tbl_partner_facility.county_id', $selected_counties)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->where('county_id', $selected_counties);
+ }
+ if (!empty($selected_subcounties)) {
+ $all_appoinments = $all_appoinments->where('subcounty_id', $selected_subcounties);
+ $consented_clients = $consented_clients->where('sub_county_id', $selected_subcounties);
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_sub'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_sub.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_sub.max_period');
+ })
+ ->where('sub_county_id', $selected_subcounties)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->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);
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_fac'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_fac.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_fac.max_period');
+ })
+ ->where('tbl_partner_facility.mfl_code', $selected_facilites)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->where('mfl_code', $selected_facilites);
+ }
+
+ if (!empty($selected_clinics)) {
+ $all_appoinments = $all_appoinments->where('clinic_type', $selected_clinics);
+ $consented_clients = $consented_clients;
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_clinic'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_clinic.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_clinic.max_period');
+ })
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->where('clinic_type', $selected_clinics);
+ }
+ if (!empty($selected_appointments)) {
+ $all_appoinments = $all_appoinments;
+ $consented_clients = $consented_clients;
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_dsd'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_dsd.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_dsd.max_period');
+ })
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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;
+ $missed_gender = $missed_gender;
+ $missed_marital = $missed_marital;
+ $missed_county = $missed_county;
+ $missed_partner = $missed_partner;
+ $missed_facility = $missed_facility;
+ $client_app_list = $client_app_list;
+ $app_rate = $app_rate;
+ }
+ 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('consent_date', '>=', date($request->from))->where('consent_date', '<=', date($request->to));
+ $selectedFrom = date('Ym', strtotime($request->from));
+ $selectedTo = date('Ym', strtotime($request->to));
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_fac'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_fac.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_fac.max_period');
+ })
+ ->where(function ($query) use ($selectedFrom, $selectedTo) {
+ $query->whereRaw("SUBSTRING(tbl_tx_cur.period, 1, 6) >= ?", $selectedFrom)
+ ->whereRaw("SUBSTRING(tbl_tx_cur.period, 1, 6) <= ?", $selectedTo);
+ })
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->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;
+ $selectedFrom = date('Ym', strtotime($request->from));
+ $selectedTo = date('Ym', strtotime($request->to));
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_site'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_site.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_site.max_period');
+ })
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $all_tx_curr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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_rate = $app_rate->where('facility_type', $selected_sites);
+ }
+
+ $data["all_appoinments"] = $all_appoinments->get();
+ $data["consented_clients"] = $consented_clients->get();
+ $data["all_tx_curr"] = $all_tx_curr->sum('tbl_tx_cur.tx_cur');
+ $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_rate"] = $app_rate->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/HighRiskController.php b/app/Http/Controllers/HighRiskController.php
new file mode 100644
index 0000000..167f758
--- /dev/null
+++ b/app/Http/Controllers/HighRiskController.php
@@ -0,0 +1,453 @@
+current_date = date("Y-m-d");
+ }
+
+ private function getAccessToken()
+ {
+ $accessToken = Cache::get('access_token');
+ if (!$accessToken) {
+ $client = new Client();
+ $response = $client->post('https://auth2.kenyahmis.org:8443/connect/token', [
+ 'form_params' => [
+ 'grant_type' => 'client_credentials',
+ 'client_id' => 'cdc',
+ 'client_secret' => '7f11e3b4-5741-11ec-bf63-0242ac130002',
+ 'scope' => 'pdapiv1'
+ ]
+ ]);
+ $responseBody = json_decode($response->getBody(), true);
+ $accessToken = $responseBody['access_token'];
+ $expiresIn = $responseBody['expires_in'];
+ Cache::put('access_token', $accessToken, now()->addSeconds($expiresIn - 60)); // store token for 1 minute less than expiration time
+ }
+ return $accessToken;
+ }
+ public function get_high_risk_clients()
+ {
+ // Set the endpoint URL
+ // Create a GuzzleHttp client
+ $client = new \GuzzleHttp\Client();
+
+
+
+ // $access_token = json_decode($response->getBody())->access_token;
+
+ // Get the list of facilities
+ $facilities = PartnerFacility::select('mfl_code')->orderBy('mfl_code', 'desc')->get();
+
+ // Get an array of facility codes
+ $get_facilities = $facilities->pluck('mfl_code')->toArray();
+
+ // API endpoint URL
+ $url = 'https://data.kenyahmis.org:9783/api/Dataset';
+
+ // Set the page size
+ $pageSize = 50;
+
+ foreach ($get_facilities as $final_facility) {
+ // Set the page number
+ $pageNumber = 1;
+
+ do {
+ // Set the API parameters
+ $params = [
+ 'code' => 'FND',
+ 'name' => 'predictions',
+ 'siteCode' => $final_facility,
+ 'pageNumber' => $pageNumber,
+ 'pageSize' => $pageSize,
+ ];
+
+ // Build the API query string
+ $queryString = http_build_query($params);
+ $fullUrl = $url . '?' . $queryString;
+
+ // Make the API call
+ $response = $client->get($fullUrl, [
+ 'headers' => [
+ 'Authorization' => 'Bearer ' . $this->getAccessToken(),
+ ],
+ 'timeout' => 0,
+ ]);
+
+ // Decode the JSON response
+ $data = json_decode($response->getBody(), true);
+
+ // Loop through the extract and insert into the database
+ // $records = array_filter($data['extract'], function ($record) {
+ // return $record['Description'] == 'High Risk';
+ // });
+ $all = array_filter($data['extract'], function ($record) {
+ return true;
+ });
+ $dataToInsert = array_map(function ($record) use ($final_facility) {
+ return [
+ 'ccc_number' => $record['PatientCccNumber'],
+ 'mfl_code' => $record['code'],
+ 'risk_score' => $record['risk_score'],
+ 'evaluation_date' => $record['EvaluationDate'],
+ 'risk_description' => $record['Description'],
+ 'created_at' => now(),
+ 'updated_at' => now(),
+ ];
+ }, $all);
+
+
+
+ $chunks = array_chunk($dataToInsert, 2000);
+
+ foreach ($chunks as $chunk) {
+ $ccNumbers = array_column($chunk, 'ccc_number');
+
+ $existingRecords = DB::table('tbl_high_risk')->whereIn('ccc_number', $ccNumbers)->get();
+
+ foreach ($chunk as $insert) {
+ $existingRecord = $existingRecords->firstWhere('ccc_number', $insert['ccc_number']);
+
+ if ($existingRecord) {
+ DB::table('tbl_high_risk')->where('id', $existingRecord->id)->update($insert);
+ } else {
+ if ($insert['risk_description'] == 'High Risk') {
+ DB::table('tbl_high_risk')->insert($insert);
+ }
+ }
+ }
+ }
+
+
+ $pageNumber++;
+
+ // looping while there are more pages of data
+ } while ($data['pageNumber'] < $data['pageCount']);
+ }
+ }
+
+ // public function getAllData()
+ // {
+ // // Set the endpoint URL
+ // // Create a GuzzleHttp client
+ // $client = new \GuzzleHttp\Client();
+
+
+
+ // // $access_token = json_decode($response->getBody())->access_token;
+
+ // // Get the list of facilities
+ // $facilities = PartnerFacility::select('mfl_code')->orderBy('mfl_code', 'desc')->get();
+
+ // // Get an array of facility codes
+ // $get_facilities = $facilities->pluck('mfl_code')->toArray();
+
+ // // API endpoint URL
+ // $url = 'https://data.kenyahmis.org:9783/api/Dataset';
+
+ // // Set the page size
+ // $pageSize = 50;
+
+ // foreach ($get_facilities as $final_facility) {
+ // // Set the page number
+ // $pageNumber = 1;
+
+ // do {
+ // // Set the API parameters
+ // $params = [
+ // 'code' => 'FND',
+ // 'name' => 'predictions',
+ // 'siteCode' => '27408',
+ // 'pageNumber' => $pageNumber,
+ // 'pageSize' => $pageSize,
+ // ];
+
+ // // Build the API query string
+ // $queryString = http_build_query($params);
+ // $fullUrl = $url . '?' . $queryString;
+
+ // // Make the API call
+ // $response = $client->get($fullUrl, [
+ // 'headers' => [
+ // 'Authorization' => 'Bearer ' . $this->getAccessToken(),
+ // ],
+ // 'timeout' => 0,
+ // ]);
+
+ // // Decode the JSON response
+ // $data = json_decode($response->getBody(), true);
+ // // Loop through the extract and insert into the database
+ // // $records = array_filter($data['extract'], function ($record) {
+ // // return $record['Description'] == 'High Risk';
+ // // });
+ // $all = array_filter($data['extract'], function ($record) {
+ // return true;
+ // });
+ // $dataToInsert = array_map(function ($record) use ($final_facility) {
+ // return [
+ // 'ccc_number' => $record['PatientCccNumber'],
+ // 'mfl_code' => $record['code'],
+ // 'risk_score' => $record['risk_score'],
+ // 'evaluation_date' => $record['EvaluationDate'],
+ // 'risk_description' => $record['Description'],
+ // 'created_at' => now(),
+ // 'updated_at' => now(),
+ // ];
+ // }, $all);
+
+
+
+ // $chunks = array_chunk($dataToInsert, 2000);
+
+ // foreach ($chunks as $chunk) {
+ // $ccNumbers = array_column($chunk, 'ccc_number');
+
+ // $existingRecords = DB::table('tbl_high_risk')->whereIn('ccc_number', $ccNumbers)->get();
+
+ // foreach ($chunk as $insert) {
+ // $existingRecord = $existingRecords->firstWhere('ccc_number', $insert['ccc_number']);
+
+ // if ($existingRecord) {
+ // DB::table('tbl_high_risk')->where('id', $existingRecord->id)->update($insert);
+ // } else {
+ // if ($insert['risk_description'] == 'High Risk') {
+
+ // if (DB::table('tbl_high_risk')->insert($insert)) {
+ // echo 'success';
+ // } else {
+ // echo 'tired';
+ // }
+ // }
+ // }
+ // }
+ // }
+
+
+ // $pageNumber++;
+
+ // // looping while there are more pages of data
+ // } while ($data['pageNumber'] < $data['pageCount']);
+ // }
+ // }
+
+
+ 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);
+ }
+
+ public function task()
+ {
+ try {
+ $client = HighRiskNotification::all();
+
+
+ foreach ($client as $value) {
+ $client_name = $value->client_name;
+ $risk_description = $value->risk_description;
+ $language_id = $value->language_id;
+ $phone_no = $value->phone_no;
+ $txt_time = $value->txt_time + 1;
+ $smsenable = $value->smsenable;
+ $appntmnt_date = $value->appntmnt_date;
+ $consented = $value->consented;
+ $appointment_id = $value->appointment_id;
+ $client_id = $value->client_id;
+ $no_of_days = $value->no_of_days;
+
+ if (DB::table('tbl_clnt_outgoing')
+ ->where('message_type_id', 9)
+ ->where('clnt_usr_id', $client_id)
+ ->where(function ($query) {
+ $query->whereDate('created_at', $this->current_date)
+ ->orwhereDate('updated_at', $this->current_date);
+ })
+ ->doesntExist()
+ ) {
+ if ($no_of_days == 30 || $no_of_days == 21) {
+ $logic_flow_id = 23;
+ } else {
+ $logic_flow_id = 22;
+ }
+ $message = DB::table('tbl_content')
+ ->where('message_type_id', 9)
+ ->where('identifier', $logic_flow_id)
+ ->where('language_id', $language_id)
+ ->get()
+ ->take(1);
+
+ //check if a notification is already sent. If not send it.
+
+ foreach ($message as $sms) {
+
+ $content = $sms->content;
+ $content_id = $sms->id;
+
+ $today = date("Y-m-d H:i:s");
+ $new_msg = str_replace("XXX", $client_name, $content);
+
+
+ $status = "Not Sent";
+ $responded = "No";
+
+
+ if ($smsenable === 'Yes' || $smsenable === 'YES' && trim($new_msg) != '') {
+ $source = 40149;
+ $outgoing = array(
+ 'destination' => $phone_no,
+ 'msg' => $new_msg,
+ 'responded' => $responded,
+ 'status' => $status,
+ 'message_type_id' => 9,
+ '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'
+ );
+
+ $this->sms_outgoing_insert($outgoing);
+ }
+ }
+ }
+ }
+ } catch (Exception $e) {
+ throw $e;
+ }
+ }
+ 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;
+ }
+ }
+
+ public function sender()
+ {
+ try {
+ //get all outgoing smses
+ $messages = ClientOutgoing::where('message_type_id', 9)->get();
+
+ 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") {
+
+ //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
+ {
+
+ //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;
+ }
+ }
+}
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..08f5836
--- /dev/null
+++ b/app/Http/Controllers/NewDashboardController.php
@@ -0,0 +1,9606 @@
+remember_period = env('REMEMBER_PERIOD', '60 * 60');
+ }
+
+ public function partner_summary()
+ {
+ $data = [];
+
+ if (env('INSTANCE') === 'UshauriDOD') {
+
+ $result = PartnerFacility::leftJoin('tbl_client', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->leftJoin('tbl_partner', 'tbl_partner.id', '=', 'tbl_partner_facility.partner_id')
+ ->leftJoin('tbl_master_facility', 'tbl_master_facility.code', '=', 'tbl_partner_facility.mfl_code')
+ ->selectRaw('COUNT(tbl_client.clinic_number) as client_ever_enrolled, tbl_partner.name as partner, tbl_master_facility.name as facility, tbl_master_facility.code as mfl_code, (SELECT COUNT(*) FROM tbl_client WHERE tbl_client.mfl_code = tbl_partner_facility.mfl_code AND tbl_client.hei_no IS NULL AND tbl_client.smsenable = "Yes" AND tbl_partner_facility.partner_id = ' . Auth::user()->partner_id . ') as client_consented')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->whereNull('tbl_client.hei_no')
+ ->groupBy('tbl_partner_facility.mfl_code');
+ } else {
+
+ $result = Txcurr::selectRaw('tbl_tx_cur.tx_cur as tx_cur')
+ ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest.max_period');
+ })
+ ->leftJoin('tbl_client', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->leftJoin('tbl_partner', 'tbl_partner.id', '=', 'tbl_partner_facility.partner_id')
+ ->leftJoin('tbl_county', 'tbl_county.id', '=', 'tbl_partner_facility.county_id')
+ ->leftJoin('tbl_master_facility', 'tbl_master_facility.code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->whereNull('tbl_client.hei_no')
+ ->groupBy('tbl_tx_cur.mfl_code')
+ ->remember($this->remember_period)
+ ->selectRaw('COUNT(tbl_client.clinic_number) as client_ever_enrolled, tbl_county.name as county, tbl_partner.name as partner, tbl_master_facility.name as facility, tbl_master_facility.code as mfl_code,
+ (SELECT
+ COUNT(CASE
+ WHEN c.smsenable = "Yes" THEN 1
+ WHEN a.client_id IS NOT NULL THEN
+ 1
+ END) AS client_consented
+ FROM
+ tbl_client c
+ LEFT JOIN (
+ SELECT
+ client_id,
+ DATE( created_at ) AS created_at
+ FROM
+ tbl_appointment a1
+ WHERE
+ a1.id = ( SELECT MAX( a2.id ) FROM tbl_appointment a2 WHERE a2.client_id = a1.client_id )
+ AND a1.consented = "YES"
+ ) a ON c.id = a.client_id
+ WHERE c.mfl_code = tbl_partner_facility.mfl_code AND c.hei_no IS NULL AND tbl_partner_facility.partner_id = ' . Auth::user()->partner_id . ') as client_consented');
+
+ // ->selectRaw('COUNT(tbl_client.clinic_number) as client_ever_enrolled, tbl_county.name as county, tbl_partner.name as partner, tbl_master_facility.name as facility, tbl_master_facility.code as mfl_code, (SELECT COUNT(*) FROM tbl_client WHERE tbl_client.mfl_code = tbl_partner_facility.mfl_code AND tbl_client.hei_no IS NULL AND tbl_client.smsenable = "Yes" AND tbl_partner_facility.partner_id = ' . Auth::user()->partner_id . ') as client_consented');
+ }
+
+
+ $data["result"] = $result->get();
+
+ return $data;
+ }
+
+ 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 = Txcurr::select('tbl_tx_cur.tx_cur')
+ // ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ // ->where('tbl_tx_cur.period', function ($query) {
+ // $query->select(DB::raw('MAX(tbl_tx_cur.period)'))
+ // ->from('tbl_tx_cur');
+ // })
+ // ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)
+ // ->remember($this->remember_period)
+ // ->sum('tbl_tx_cur.tx_cur');
+
+ $client = Txcurr::selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest.max_period');
+ })
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)
+ ->groupBy('tbl_tx_cur.mfl_code')
+ ->remember($this->remember_period)
+ ->get();
+ $client = $client->sum('tx_cur');
+
+ $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')
+ ->whereNull('hei_no')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ $clients_female = Client::where('gender', '=', '1')
+ ->whereNull('hei_no')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->count();
+
+ $unknown_gender = Client::where(function ($query) {
+ $query->where('gender', '!=', '1')
+ ->where('gender', '!=', '2')
+ ->orWhereNull('gender')
+ ->orWhere('gender', '');
+ })
+ ->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"))
+ ->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"))
+ ->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"))
+ ->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"))
+ ->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"))
+ ->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"))
+ ->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');
+ $currentYear = date('Y');
+
+ // $client = Txcurr::join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ // ->where('tbl_tx_cur.period', function ($query) {
+ // $query->select(DB::raw('MAX(tbl_tx_cur.period)'))
+ // ->from('tbl_tx_cur');
+ // })
+ // ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ // ->remember($this->remember_period)
+ // ->sum('tbl_tx_cur.tx_cur');
+
+ $client = Txcurr::selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest.max_period');
+ })
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->groupBy('tbl_tx_cur.mfl_code')
+ ->remember($this->remember_period)
+ ->get();
+ $client = $client->sum('tx_cur');
+
+ $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();
+ $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')
+ ->whereDate('tbl_appointment.created_at', '>=', Carbon::now()->subMonths(6)->toDateString())
+ ->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')
+ ->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')
+ ->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(function ($query) {
+ $query->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->orWhereNull('tbl_client.gender')
+ ->orWhere('tbl_client.gender', '');
+ })
+ ->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"))
+ ->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"))
+ ->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"))
+ ->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"))
+ ->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(IF(((YEAR(CURRENT_DATE) - YEAR(str_to_date(tbl_client.dob, IF(LOCATE('/', tbl_client.dob) > 0, '%m/%d/%Y', '%Y-%m-%d')))) >= 25), tbl_client.dob, NULL)) AS count"))
+ ->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(function ($query) {
+ $query->where(function ($subquery) {
+ $subquery->whereRaw("locate('/', `tbl_client`.`dob`) > 0")
+ ->whereRaw("date_format(str_to_date(`tbl_client`.`dob`, '%m/%d/%Y'), '%Y-%m-%d') IS NULL");
+ })->orWhere(function ($subquery) {
+ $subquery->whereRaw("locate('-', `tbl_client`.`dob`) > 0")
+ ->whereRaw("date_format(str_to_date(`tbl_client`.`dob`, '%Y-%m-%d'), '%Y-%m-%d') IS NULL");
+ });
+ })
+ ->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_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 = Txcurr::select('tbl_tx_cur.tx_cur')
+ // ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ // ->where('tbl_tx_cur.period', function ($query) {
+ // $query->select(DB::raw('MAX(tbl_tx_cur.period)'))
+ // ->from('tbl_tx_cur');
+ // })
+ // ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ // ->remember($this->remember_period)
+ // ->sum('tbl_tx_cur.tx_cur');
+
+ $client = Txcurr::selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest.max_period');
+ })
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->groupBy('tbl_tx_cur.mfl_code')
+ ->remember($this->remember_period)
+ ->get();
+ $client = $client->sum('tx_cur');
+
+ $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('tbl_partner_facility.mfl_code')
+ ->whereDate('tbl_appointment.created_at', '>=', Carbon::now()->subMonths(6)->toDateString())
+ ->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')
+ ->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')
+ ->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(function ($query) {
+ $query->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->orWhereNull('tbl_client.gender')
+ ->orWhere('tbl_client.gender', '');
+ })
+ ->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"))
+ ->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"))
+ ->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"))
+ ->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"))
+ ->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"))
+ ->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"))
+ ->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 = Txcurr::select('tbl_tx_cur.tx_cur')
+ // ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ // ->where('tbl_tx_cur.period', function ($query) {
+ // $query->select(DB::raw('MAX(tbl_tx_cur.period)'))
+ // ->from('tbl_tx_cur');
+ // })
+ // ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ // ->remember($this->remember_period)
+ // ->sum('tbl_tx_cur.tx_cur');
+
+ $client = Txcurr::selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest.max_period');
+ })
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->groupBy('tbl_tx_cur.mfl_code')
+ ->remember($this->remember_period)
+ ->get();
+ $client = $client->sum('tx_cur');
+
+ $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('tbl_partner_facility.mfl_code')
+ ->whereDate('tbl_appointment.created_at', '>=', Carbon::now()->subMonths(6)->toDateString())
+ ->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')
+ ->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')
+ ->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(function ($query) {
+ $query->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->orWhereNull('tbl_client.gender')
+ ->orWhere('tbl_client.gender', '');
+ })
+ ->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 = Txcurr::selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest.max_period');
+ })
+ ->groupBy('tbl_tx_cur.mfl_code')
+ ->get();
+
+
+ $client = $client->sum('tx_cur');
+
+
+ // $client = 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.period', function ($query) {
+ // $query->select(DB::raw('MAX(tbl_tx_cur.period)'))
+ // ->from('tbl_tx_cur');
+ // })
+ // ->remember($this->remember_period)
+ // ->sum('tbl_tx_cur.tx_cur');
+
+ $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();
+
+ $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')
+ ->whereDate('tbl_appointment.created_at', '>=', Carbon::now()->subMonths(6)->toDateString())
+ ->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')
+ ->whereNull('hei_no')
+ ->remember($this->remember_period)
+ ->count();
+
+ $clients_female = Client::where('gender', '=', '1')
+ ->whereNull('hei_no')
+ ->remember($this->remember_period)
+ ->count();
+
+ $unknown_gender = Client::where(function ($query) {
+ $query->where('gender', '!=', '1')
+ ->where('gender', '!=', '2')
+ ->orWhereNull('gender')
+ ->orWhere('gender', '');
+ })
+ ->whereNull('hei_no')
+ ->remember($this->remember_period)
+ ->count();
+
+ $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"))
+ ->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"))
+ ->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"))
+ ->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"))
+ ->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"))
+ ->whereNull('hei_no')
+ ->remember($this->remember_period)
+ ->pluck('count');
+
+ $client_unknown_age = Client::select('id')
+ ->where(function ($query) {
+ $query->where('dob', '=', '')
+ ->orWhere(function ($subquery) {
+ $subquery->whereRaw("locate('/', `tbl_client`.`dob`) > 0")
+ ->whereRaw("date_format(str_to_date(`tbl_client`.`dob`, '%m/%d/%Y'), '%Y-%m-%d') IS NULL");
+ })
+ ->orWhere(function ($subquery) {
+ $subquery->whereRaw("locate('-', `tbl_client`.`dob`) > 0")
+ ->whereRaw("date_format(str_to_date(`tbl_client`.`dob`, '%Y-%m-%d'), '%Y-%m-%d') IS NULL");
+ });
+ })
+ ->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 = ClientDashboard::selectRaw('SUM(client_consented + non_consented) as total_sum')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->first()->total_sum;
+ // client charts
+ // $client_consented = Client::select('smsenable')
+ // ->whereNull('hei_no')
+ // ->where('smsenable', '=', 'Yes')
+ // ->where('mfl_code', Auth::user()->facility_id)
+ // ->remember($this->remember_period)
+ // ->count();
+
+ $client_consented = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+
+ $client_nonconsented = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ // consented clients by gender
+
+ $client_consented_male = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('gender', '=', 'Male')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_female = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('gender', '=', 'Female')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_uknown_gender = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('gender', '=', 'Unknown')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ // non consented clients by gender
+ $client_nonconsented_male = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('gender', '=', 'Male')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ $client_nonconsented_female = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('gender', '=', 'Female')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+
+ $client_nonconsented_uknown_gender = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('gender', '=', 'Unknown')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ // consented clients by age distribution
+ $client_consented_to_nine = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('age_range', '=', '0-9')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_to_fourteen = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('age_range', '=', '10-14')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_to_nineteen = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('age_range', '=', '15-19')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_to_twentyfour = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('age_range', '=', '20-24')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_to_twentyfive_above = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('age_range', '=', '25+')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_uknown_age = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('age_range', '=', 'Unknown')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+
+ // $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"))
+ // ->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 = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('age_range', '=', '0-9')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ $client_nonconsented_to_fourteen = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('age_range', '=', '10-14')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ $client_nonconsented_to_nineteen = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('age_range', '=', '15-19')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ $client_nonconsented_to_twentyfour = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('age_range', '=', '20-24')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ $client_nonconsented_to_twentyfive_above = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('age_range', '=', '25+')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ $client_nonconsented_uknown_age = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('age_range', '=', 'Unknown')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+ }
+ 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 = ClientDashboard::selectRaw('SUM(client_consented + non_consented) as total_sum')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period)
+ ->first()->total_sum;
+
+ // client charts
+ $client_consented = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+
+ $client_nonconsented = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ // consented clients by gender
+
+ $client_consented_male = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('gender', '=', 'Male')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_female = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('gender', '=', 'Female')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_uknown_gender = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('gender', '=', 'Unknown')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ // non consented clients by gender
+ $client_nonconsented_male = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('gender', '=', 'Male')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ $client_nonconsented_female = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('gender', '=', 'Female')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+
+ $client_nonconsented_uknown_gender = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('gender', '=', 'Unknown')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ // consented clients by age distribution
+ $client_consented_to_nine = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('age_range', '=', '0-9')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_to_fourteen = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('age_range', '=', '10-14')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_to_nineteen = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('age_range', '=', '15-19')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_to_twentyfour = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('age_range', '=', '20-24')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_to_twentyfive_above = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('age_range', '=', '25+')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_uknown_age = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('age_range', '=', 'Unknown')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ // non consented clients by age distribution
+ $client_nonconsented_to_nine = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('age_range', '=', '0-9')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ $client_nonconsented_to_fourteen = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('age_range', '=', '10-14')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ $client_nonconsented_to_nineteen = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('age_range', '=', '15-19')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ $client_nonconsented_to_twentyfour = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('age_range', '=', '20-24')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ $client_nonconsented_to_twentyfive_above = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('age_range', '=', '25+')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ $client_nonconsented_uknown_age = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('age_range', '=', 'Unknown')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+ }
+ 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 = ClientDashboard::selectRaw('SUM(client_consented + non_consented) as total_sum')
+ ->where('county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->first()->total_sum;
+
+ // client charts
+ $client_consented = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+
+ $client_nonconsented = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ // consented clients by gender
+
+ $client_consented_male = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('gender', '=', 'Male')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_female = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('gender', '=', 'Female')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_uknown_gender = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('gender', '=', 'Unknown')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ // non consented clients by gender
+ $client_nonconsented_male = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('gender', '=', 'Male')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ $client_nonconsented_female = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('gender', '=', 'Female')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+
+ $client_nonconsented_uknown_gender = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('gender', '=', 'Unknown')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ // consented clients by age distribution
+ $client_consented_to_nine = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('age_range', '=', '0-9')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_to_fourteen = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('age_range', '=', '10-14')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_to_nineteen = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('age_range', '=', '15-19')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_to_twentyfour = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('age_range', '=', '20-24')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_to_twentyfive_above = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('age_range', '=', '25+')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_uknown_age = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('age_range', '=', 'Unknown')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ // non consented clients by age distribution
+ $client_nonconsented_to_nine = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('age_range', '=', '0-9')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ $client_nonconsented_to_fourteen = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('age_range', '=', '10-14')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ $client_nonconsented_to_nineteen = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('age_range', '=', '15-19')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ $client_nonconsented_to_twentyfour = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('age_range', '=', '20-24')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ $client_nonconsented_to_twentyfive_above = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('age_range', '=', '25+')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ $client_nonconsented_uknown_age = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('age_range', '=', 'Unknown')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+ }
+ 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 = ClientDashboard::selectRaw('SUM(client_consented + non_consented) as total_sum')
+ ->where('sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->first()->total_sum;
+
+ // client charts
+ $client_consented = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+
+ $client_nonconsented = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ // consented clients by gender
+
+ $client_consented_male = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('gender', '=', 'Male')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_female = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('gender', '=', 'Female')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_uknown_gender = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('gender', '=', 'Unknown')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ // non consented clients by gender
+ $client_nonconsented_male = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('gender', '=', 'Male')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ $client_nonconsented_female = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('gender', '=', 'Female')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+
+ $client_nonconsented_uknown_gender = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('gender', '=', 'Unknown')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ // consented clients by age distribution
+ $client_consented_to_nine = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('age_range', '=', '0-9')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_to_fourteen = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('age_range', '=', '10-14')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_to_nineteen = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('age_range', '=', '15-19')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_to_twentyfour = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('age_range', '=', '20-24')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_to_twentyfive_above = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('age_range', '=', '25+')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_uknown_age = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('age_range', '=', 'Unknown')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ // non consented clients by age distribution
+ $client_nonconsented_to_nine = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('age_range', '=', '0-9')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ $client_nonconsented_to_fourteen = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('age_range', '=', '10-14')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ $client_nonconsented_to_nineteen = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('age_range', '=', '15-19')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ $client_nonconsented_to_twentyfour = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('age_range', '=', '20-24')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ $client_nonconsented_to_twentyfive_above = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('age_range', '=', '25+')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ $client_nonconsented_uknown_age = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('age_range', '=', 'Unknown')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+ }
+ 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::whereNull('hei_no')->remember($this->remember_period)->count();
+
+ $client = ClientDashboard::selectRaw('SUM(client_consented + non_consented) as total_sum')
+ ->remember($this->remember_period)
+ ->first()->total_sum;
+
+
+ // client charts
+ $client_consented = ClientDashboard::remember($this->remember_period)
+ ->sum('client_consented');
+
+
+ $client_nonconsented = ClientDashboard::remember($this->remember_period)
+ ->sum('non_consented');
+
+ // consented clients by gender
+
+ $client_consented_male = ClientDashboard::where('gender', '=', 'Male')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_female = ClientDashboard::where('gender', '=', 'Female')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_uknown_gender = ClientDashboard::where('gender', '=', 'Unknown')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ // non consented clients by gender
+ $client_nonconsented_male = ClientDashboard::where('gender', '=', 'Male')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ $client_nonconsented_female = ClientDashboard::where('gender', '=', 'Female')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+
+ $client_nonconsented_uknown_gender = ClientDashboard::where('gender', '=', 'Unknown')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ // consented clients by age distribution
+ $client_consented_to_nine = ClientDashboard::where('age_range', '=', '0-9')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_to_fourteen = ClientDashboard::where('age_range', '=', '10-14')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_to_nineteen = ClientDashboard::where('age_range', '=', '15-19')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_to_twentyfour = ClientDashboard::where('age_range', '=', '20-24')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_to_twentyfive_above = ClientDashboard::where('age_range', '=', '25+')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ $client_consented_uknown_age = ClientDashboard::where('age_range', '=', 'Unknown')
+ ->remember($this->remember_period)
+ ->sum('client_consented');
+
+ // non consented clients by age distribution
+ $client_nonconsented_to_nine = ClientDashboard::where('age_range', '=', '0-9')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ $client_nonconsented_to_fourteen = ClientDashboard::where('age_range', '=', '10-14')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ $client_nonconsented_to_nineteen = ClientDashboard::where('age_range', '=', '15-19')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ $client_nonconsented_to_twentyfour = ClientDashboard::where('age_range', '=', '20-24')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ $client_nonconsented_to_twentyfive_above = ClientDashboard::where('age_range', '=', '25+')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+
+ $client_nonconsented_uknown_age = ClientDashboard::where('age_range', '=', 'Unknown')
+ ->remember($this->remember_period)
+ ->sum('non_consented');
+ }
+
+
+ // 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::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);
+ $query = Txcurr::query()->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id);
+
+ $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')
+ ->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')
+ ->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(function ($query) {
+ $query->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->orWhereNull('tbl_client.gender')
+ ->orWhere('tbl_client.gender', '');
+ })
+ ->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"))
+ ->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"))
+ ->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"))
+ ->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"))
+ ->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"))
+ ->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"))
+ ->whereNull('tbl_client.hei_no')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+ }
+ if (Auth::user()->access_level == 'Partner') {
+ // $result = Txcurr::selectRaw('tbl_tx_cur.tx_cur as tx_cur')
+ // ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ // ->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ // FROM tbl_tx_cur t1
+ // GROUP BY t1.mfl_code) latest'), function ($join) {
+ // $join->on('tbl_tx_cur.mfl_code', '=', 'latest.mfl_code')
+ // ->on('tbl_tx_cur.period', '=', 'latest.max_period');
+ // })
+ // ->leftJoin('tbl_client', 'tbl_client.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ // ->leftJoin('tbl_partner', 'tbl_partner.id', '=', 'tbl_partner_facility.partner_id')
+ // ->leftJoin('tbl_county', 'tbl_county.id', '=', 'tbl_partner_facility.county_id')
+ // ->leftJoin('tbl_master_facility', 'tbl_master_facility.code', '=', 'tbl_partner_facility.mfl_code')
+ // ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ // ->whereNull('tbl_client.hei_no')
+ // ->groupBy('tbl_tx_cur.mfl_code')
+ // ->remember($this->remember_period)
+ // ->selectRaw('COUNT(tbl_client.clinic_number) as client_ever_enrolled, tbl_county.name as county, tbl_partner.name as partner, tbl_master_facility.name as facility, tbl_master_facility.code as mfl_code, (SELECT COUNT(*) FROM tbl_client WHERE tbl_client.mfl_code = tbl_partner_facility.mfl_code AND tbl_client.hei_no IS NULL AND tbl_client.smsenable = "Yes" AND tbl_partner_facility.partner_id = ' . Auth::user()->partner_id . ') as client_consented');
+
+ $query = Txcurr::query()->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id);
+
+
+
+ $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')
+ ->select('tbl_partner_facility.mfl_code')
+ ->whereDate('tbl_appointment.created_at', '>=', Carbon::now()->subMonths(6)->toDateString())
+ ->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);
+
+ $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')
+ ->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')
+ ->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(function ($query) {
+ $query->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->orWhereNull('tbl_client.gender')
+ ->orWhere('tbl_client.gender', '');
+ })
+ ->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"))
+ ->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"))
+ ->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"))
+ ->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"))
+ ->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"))
+ ->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"))
+ ->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') {
+
+ $query = Txcurr::query()->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);
+
+ $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')
+ ->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')
+ ->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(function ($query) {
+ $query->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->orWhereNull('tbl_client.gender')
+ ->orWhere('tbl_client.gender', '');
+ })
+ ->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"))
+ ->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"))
+ ->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"))
+ ->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"))
+ ->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"))
+ ->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"))
+ ->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') {
+
+ $query = Txcurr::query()->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id);
+
+ $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')
+ ->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')
+ ->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(function ($query) {
+ $query->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->orWhereNull('tbl_client.gender')
+ ->orWhere('tbl_client.gender', '');
+ })
+ ->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"))
+ ->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"))
+ ->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"))
+ ->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"))
+ ->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"))
+ ->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"))
+ ->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') {
+
+
+ $query = Txcurr::query()->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code');
+
+ $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')
+ ->select('tbl_partner_facility.mfl_code')
+ ->whereDate('tbl_appointment.created_at', '>=', Carbon::now()->subMonths(6)->toDateString())
+ ->orderBy('tbl_appointment.created_at', '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')
+ ->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')
+ ->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(function ($query) {
+ $query->where('tbl_client.gender', '!=', '1')
+ ->where('tbl_client.gender', '!=', '2')
+ ->orWhereNull('tbl_client.gender')
+ ->orWhere('tbl_client.gender', '');
+ })
+ ->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"))
+ ->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"))
+ ->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"))
+ ->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"))
+ ->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"))
+ ->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"))
+ ->whereNull('tbl_client.hei_no')
+ ->remember($this->remember_period);
+ }
+
+ if (!empty($selected_partners)) {
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest.max_period');
+ })->where('tbl_partner_facility.partner_id', $selected_partners)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $client = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+
+ $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)) {
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_con'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_con.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_con.max_period');
+ })
+ ->where('tbl_partner_facility.county_id', $selected_counties)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $client = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+
+ // if (Auth::user()->access_level == 'Partner') {
+ // $result = $result->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)) {
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_sub'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_sub.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_sub.max_period');
+ })
+ ->where('sub_county_id', $selected_subcounties)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $client = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ // if (Auth::user()->access_level == 'Partner') {
+ // $result = $result->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)) {
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_fac'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_fac.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_fac.max_period');
+ })
+ ->where('tbl_partner_facility.mfl_code', $selected_facilites)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $client = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ // if (Auth::user()->access_level == 'Partner') {
+ // $result = $result->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)) {
+ $selectedFrom = date('Ym', strtotime($request->from));
+ $selectedTo = date('Ym', strtotime($request->to));
+
+ if (env('INSTANCE') === 'UshauriDOD') {
+ $client = Txcurr::selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest.max_period');
+ })
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)
+ ->groupBy('tbl_tx_cur.mfl_code')
+ ->remember($this->remember_period)
+ ->get();
+ $client = $client->sum('tx_cur');
+ } else {
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_fac'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_fac.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_fac.max_period');
+ })
+ ->where(function ($query) use ($selectedFrom, $selectedTo) {
+ $query->whereRaw("SUBSTRING(tbl_tx_cur.period, 1, 6) >= ?", $selectedFrom)
+ ->whereRaw("SUBSTRING(tbl_tx_cur.period, 1, 6) <= ?", $selectedTo);
+ })
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $client = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ }
+
+ // $client = $client->where('tbl_tx_cur.period', function ($query) use ($selectedFrom, $selectedTo) {
+ // $query->select(DB::raw('MAX(period)'))
+ // ->from('tbl_tx_cur')
+ // ->whereRaw("SUBSTRING(period, 1, 6) BETWEEN ? AND ?", [$selectedFrom, $selectedTo]);
+ // });
+ $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));
+ // if (Auth::user()->access_level == 'Partner') {
+ // $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('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ // ->where(DB::raw('(SELECT MAX(DATE(tbl_appointment.created_at)) from tbl_appointment)'), '>=', Carbon::now()->subMonths(6))
+ // ->whereDate('tbl_appointment.created_at', '>=', $request->from)
+ // ->whereDate('tbl_appointment.created_at', '<=', $request->to)
+ // ->orderBy('tbl_appointment.created_at', 'DESC')
+ // ->groupBy('tbl_partner_facility.mfl_code')
+ // ->remember($this->remember_period);
+ // }
+ $active_facilities = $active_facilities->whereDate('tbl_appointment.created_at', '>=', $request->from)
+ ->whereDate('tbl_appointment.created_at', '<=', $request->to);
+
+ $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')) {
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_dsd'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_dsd.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_dsd.max_period');
+ })
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $client = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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)->get();
+ $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')) {
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_pmtct'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_pmtct.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_pmtct.max_period');
+ })
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $client = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $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)->get();;
+ $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;
+ // if (Auth::user()->access_level == 'Partner') {
+ // $data["result"] = $result->get();
+ // }
+ $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 = ClientDashboard::selectRaw('SUM(client_consented + non_consented) as total_sum')
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ $client_consented = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+
+ $client_nonconsented = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->remember($this->remember_period);
+
+ // consented clients by gender
+
+ $client_consented_male = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('gender', '=', 'Male')
+ ->remember($this->remember_period);
+
+ $client_consented_female = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('gender', '=', 'Female')
+ ->remember($this->remember_period);
+
+ $client_consented_uknown_gender = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('gender', '=', 'Unknown')
+ ->remember($this->remember_period);
+
+ // non consented clients by gender
+ $client_nonconsented_male = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('gender', '=', 'Male')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_female = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('gender', '=', 'Female')
+ ->remember($this->remember_period);
+
+
+ $client_nonconsented_uknown_gender = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('gender', '=', 'Unknown')
+ ->remember($this->remember_period);
+
+ // consented clients by age distribution
+ $client_consented_to_nine = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('age_range', '=', '0-9')
+ ->remember($this->remember_period);
+
+ $client_consented_to_fourteen = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('age_range', '=', '10-14')
+ ->remember($this->remember_period);
+
+ $client_consented_to_nineteen = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('age_range', '=', '15-19')
+ ->remember($this->remember_period);
+
+ $client_consented_to_twentyfour = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('age_range', '=', '20-24')
+ ->remember($this->remember_period);
+
+ $client_consented_to_twentyfive_above = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('age_range', '=', '25+')
+ ->remember($this->remember_period);
+
+ $client_consented_uknown_age = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('age_range', '=', 'Unknown')
+ ->remember($this->remember_period);
+
+
+ // $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"))
+ // ->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 = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('age_range', '=', '0-9')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_fourteen = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('age_range', '=', '10-14')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_nineteen = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('age_range', '=', '15-19')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_twentyfour = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('age_range', '=', '20-24')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_twentyfive_above = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('age_range', '=', '25+')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_uknown_age = ClientDashboard::where('mfl_code', Auth::user()->facility_id)
+ ->where('age_range', '=', 'Unknown')
+ ->remember($this->remember_period);
+ }
+ if (Auth::user()->access_level == 'Partner') {
+
+ $client = ClientDashboard::selectRaw('SUM(client_consented + non_consented) as total_sum')
+ ->where('partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ // client charts
+ $client_consented = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+
+ $client_nonconsented = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->remember($this->remember_period);
+
+ // consented clients by gender
+
+ $client_consented_male = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('gender', '=', 'Male')
+ ->remember($this->remember_period);
+
+ $client_consented_female = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('gender', '=', 'Female')
+ ->remember($this->remember_period);
+
+ $client_consented_uknown_gender = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('gender', '=', 'Unknown')
+ ->remember($this->remember_period);
+
+ // non consented clients by gender
+ $client_nonconsented_male = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('gender', '=', 'Male')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_female = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('gender', '=', 'Female')
+ ->remember($this->remember_period);
+
+
+ $client_nonconsented_uknown_gender = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('gender', '=', 'Unknown')
+ ->remember($this->remember_period);
+
+ // consented clients by age distribution
+ $client_consented_to_nine = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('age_range', '=', '0-9')
+ ->remember($this->remember_period);
+
+ $client_consented_to_fourteen = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('age_range', '=', '10-14')
+ ->remember($this->remember_period);
+
+ $client_consented_to_nineteen = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('age_range', '=', '15-19')
+ ->remember($this->remember_period);
+
+ $client_consented_to_twentyfour = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('age_range', '=', '20-24')
+ ->remember($this->remember_period);
+
+ $client_consented_to_twentyfive_above = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('age_range', '=', '25+')
+ ->remember($this->remember_period);
+
+ $client_consented_uknown_age = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('age_range', '=', 'Unknown')
+ ->remember($this->remember_period);
+
+ // non consented clients by age distribution
+ $client_nonconsented_to_nine = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('age_range', '=', '0-9')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_fourteen = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('age_range', '=', '10-14')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_nineteen = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('age_range', '=', '15-19')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_twentyfour = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('age_range', '=', '20-24')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_twentyfive_above = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('age_range', '=', '25+')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_uknown_age = ClientDashboard::where('partner_id', Auth::user()->partner_id)
+ ->where('age_range', '=', 'Unknown')
+ ->remember($this->remember_period);
+ }
+ if (Auth::user()->access_level == 'County') {
+
+
+ $client = ClientDashboard::selectRaw('SUM(client_consented + non_consented) as total_sum')
+ ->where('county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ // client charts
+ $client_consented = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+
+ $client_nonconsented = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->remember($this->remember_period);
+
+ // consented clients by gender
+
+ $client_consented_male = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('gender', '=', 'Male')
+ ->remember($this->remember_period);
+
+ $client_consented_female = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('gender', '=', 'Female')
+ ->remember($this->remember_period);
+
+ $client_consented_uknown_gender = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('gender', '=', 'Unknown')
+ ->remember($this->remember_period);
+
+ // non consented clients by gender
+ $client_nonconsented_male = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('gender', '=', 'Male')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_female = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('gender', '=', 'Female')
+ ->remember($this->remember_period);
+
+
+ $client_nonconsented_uknown_gender = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('gender', '=', 'Unknown')
+ ->remember($this->remember_period);
+
+ // consented clients by age distribution
+ $client_consented_to_nine = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('age_range', '=', '0-9')
+ ->remember($this->remember_period);
+
+ $client_consented_to_fourteen = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('age_range', '=', '10-14')
+ ->remember($this->remember_period);
+
+ $client_consented_to_nineteen = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('age_range', '=', '15-19')
+ ->remember($this->remember_period);
+
+ $client_consented_to_twentyfour = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('age_range', '=', '20-24')
+ ->remember($this->remember_period);
+
+ $client_consented_to_twentyfive_above = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('age_range', '=', '25+')
+ ->remember($this->remember_period);
+
+ $client_consented_uknown_age = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('age_range', '=', 'Unknown')
+ ->remember($this->remember_period);
+
+ // non consented clients by age distribution
+ $client_nonconsented_to_nine = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('age_range', '=', '0-9')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_fourteen = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('age_range', '=', '10-14')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_nineteen = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('age_range', '=', '15-19')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_twentyfour = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('age_range', '=', '20-24')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_twentyfive_above = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('age_range', '=', '25+')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_uknown_age = ClientDashboard::where('county_id', Auth::user()->county_id)
+ ->where('age_range', '=', 'Unknown')
+ ->remember($this->remember_period);
+ }
+ if (Auth::user()->access_level == 'Sub County') {
+
+ $client = ClientDashboard::selectRaw('SUM(client_consented + non_consented) as total_sum')
+ ->where('sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ // client charts
+ $client_consented = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+
+ $client_nonconsented = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->remember($this->remember_period);
+
+ // consented clients by gender
+
+ $client_consented_male = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('gender', '=', 'Male')
+ ->remember($this->remember_period);
+
+ $client_consented_female = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('gender', '=', 'Female')
+ ->remember($this->remember_period);
+
+ $client_consented_uknown_gender = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('gender', '=', 'Unknown')
+ ->remember($this->remember_period);
+
+ // non consented clients by gender
+ $client_nonconsented_male = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('gender', '=', 'Male')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_female = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('gender', '=', 'Female')
+ ->remember($this->remember_period);
+
+
+ $client_nonconsented_uknown_gender = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('gender', '=', 'Unknown')
+ ->remember($this->remember_period);
+
+ // consented clients by age distribution
+ $client_consented_to_nine = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('age_range', '=', '0-9')
+ ->remember($this->remember_period);
+
+ $client_consented_to_fourteen = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('age_range', '=', '10-14')
+ ->remember($this->remember_period);
+
+ $client_consented_to_nineteen = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('age_range', '=', '15-19')
+ ->remember($this->remember_period);
+
+ $client_consented_to_twentyfour = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('age_range', '=', '20-24')
+ ->remember($this->remember_period);
+
+ $client_consented_to_twentyfive_above = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('age_range', '=', '25+')
+ ->remember($this->remember_period);
+
+ $client_consented_uknown_age = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('age_range', '=', 'Unknown')
+ ->remember($this->remember_period);
+
+ // non consented clients by age distribution
+ $client_nonconsented_to_nine = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('age_range', '=', '0-9')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_fourteen = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('age_range', '=', '10-14')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_nineteen = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('age_range', '=', '15-19')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_twentyfour = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('age_range', '=', '20-24')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_twentyfive_above = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('age_range', '=', '25+')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_uknown_age = ClientDashboard::where('sub_county_id', Auth::user()->subcounty_id)
+ ->where('age_range', '=', 'Unknown')
+ ->remember($this->remember_period);
+ }
+ if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+
+ $client = ClientDashboard::selectRaw('SUM(client_consented + non_consented) as total_sum')
+ ->remember($this->remember_period);
+
+
+ // client charts
+ $client_consented = ClientDashboard::remember($this->remember_period);
+
+
+ $client_nonconsented = ClientDashboard::remember($this->remember_period);
+
+ // consented clients by gender
+
+ $client_consented_male = ClientDashboard::where('gender', '=', 'Male')
+ ->remember($this->remember_period);
+
+ $client_consented_female = ClientDashboard::where('gender', '=', 'Female')
+ ->remember($this->remember_period);
+
+ $client_consented_uknown_gender = ClientDashboard::where('gender', '=', 'Unknown')
+ ->remember($this->remember_period);
+
+ // non consented clients by gender
+ $client_nonconsented_male = ClientDashboard::where('gender', '=', 'Male')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_female = ClientDashboard::where('gender', '=', 'Female')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_uknown_gender = ClientDashboard::where('gender', '=', 'Unknown')
+ ->remember($this->remember_period);
+
+ // consented clients by age distribution
+ $client_consented_to_nine = ClientDashboard::where('age_range', '=', '0-9')
+ ->remember($this->remember_period);
+
+ $client_consented_to_fourteen = ClientDashboard::where('age_range', '=', '10-14')
+ ->remember($this->remember_period);
+
+ $client_consented_to_nineteen = ClientDashboard::where('age_range', '=', '15-19')
+ ->remember($this->remember_period);
+
+ $client_consented_to_twentyfour = ClientDashboard::where('age_range', '=', '20-24')
+ ->remember($this->remember_period);
+
+ $client_consented_to_twentyfive_above = ClientDashboard::where('age_range', '=', '25+')
+ ->remember($this->remember_period);
+
+ $client_consented_uknown_age = ClientDashboard::where('age_range', '=', 'Unknown')
+ ->remember($this->remember_period);
+
+ // non consented clients by age distribution
+ $client_nonconsented_to_nine = ClientDashboard::where('age_range', '=', '0-9')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_fourteen = ClientDashboard::where('age_range', '=', '10-14')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_nineteen = ClientDashboard::where('age_range', '=', '15-19')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_twentyfour = ClientDashboard::where('age_range', '=', '20-24')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_to_twentyfive_above = ClientDashboard::where('age_range', '=', '25+')
+ ->remember($this->remember_period);
+
+ $client_nonconsented_uknown_age = ClientDashboard::where('age_range', '=', 'Unknown')
+ ->remember($this->remember_period);
+ }
+
+ if (!empty($selected_partners)) {
+ $client = $client->where('partner_id', $selected_partners);
+ $client_consented = $client_consented->where('partner_id', $selected_partners);
+ $client_nonconsented = $client_nonconsented->where('partner_id', $selected_partners);
+ $client_consented_male = $client_consented_male->where('partner_id', $selected_partners);
+ $client_consented_female = $client_consented_female->where('partner_id', $selected_partners);
+ $client_consented_uknown_gender = $client_consented_uknown_gender->where('partner_id', $selected_partners);
+ $client_nonconsented_male = $client_nonconsented_male->where('partner_id', $selected_partners);
+ $client_nonconsented_female = $client_nonconsented_female->where('partner_id', $selected_partners);
+ $client_nonconsented_uknown_gender = $client_nonconsented_uknown_gender->where('partner_id', $selected_partners);
+ $client_consented_to_nine = $client_consented_to_nine->where('partner_id', $selected_partners);
+ $client_consented_to_fourteen = $client_consented_to_fourteen->where('partner_id', $selected_partners);
+ $client_consented_to_nineteen = $client_consented_to_nineteen->where('partner_id', $selected_partners);
+ $client_consented_to_twentyfour = $client_consented_to_twentyfour->where('partner_id', $selected_partners);
+ $client_consented_to_twentyfive_above = $client_consented_to_twentyfive_above->where('partner_id', $selected_partners);
+ $client_consented_uknown_age = $client_consented_uknown_age->where('partner_id', $selected_partners);
+ $client_nonconsented_to_nine = $client_nonconsented_to_nine->where('partner_id', $selected_partners);
+ $client_nonconsented_to_fourteen = $client_nonconsented_to_fourteen->where('partner_id', $selected_partners);
+ $client_nonconsented_to_nineteen = $client_nonconsented_to_nineteen->where('partner_id', $selected_partners);
+ $client_nonconsented_to_twentyfour = $client_nonconsented_to_twentyfour->where('partner_id', $selected_partners);
+ $client_nonconsented_to_twentyfive_above = $client_nonconsented_to_twentyfive_above->where('partner_id', $selected_partners);
+ $client_nonconsented_uknown_age = $client_nonconsented_uknown_age->where('partner_id', $selected_partners);
+ }
+ if (!empty($selected_counties)) {
+ $client = $client->where('county_id', $selected_counties);
+ $client_consented = $client_consented->where('county_id', $selected_counties);
+ $client_nonconsented = $client_nonconsented->where('county_id', $selected_counties);
+ $client_consented_male = $client_consented_male->where('county_id', $selected_counties);
+ $client_consented_female = $client_consented_female->where('county_id', $selected_counties);
+ $client_consented_uknown_gender = $client_consented_uknown_gender->where('county_id', $selected_counties);
+ $client_nonconsented_male = $client_nonconsented_male->where('county_id', $selected_counties);
+ $client_nonconsented_female = $client_nonconsented_female->where('county_id', $selected_counties);
+ $client_nonconsented_uknown_gender = $client_nonconsented_uknown_gender->where('county_id', $selected_counties);
+ $client_consented_to_nine = $client_consented_to_nine->where('county_id', $selected_counties);
+ $client_consented_to_fourteen = $client_consented_to_fourteen->where('county_id', $selected_counties);
+ $client_consented_to_nineteen = $client_consented_to_nineteen->where('county_id', $selected_counties);
+ $client_consented_to_twentyfour = $client_consented_to_twentyfour->where('county_id', $selected_counties);
+ $client_consented_to_twentyfive_above = $client_consented_to_twentyfive_above->where('county_id', $selected_counties);
+ $client_consented_uknown_age = $client_consented_uknown_age->where('county_id', $selected_counties);
+ $client_nonconsented_to_nine = $client_nonconsented_to_nine->where('county_id', $selected_counties);
+ $client_nonconsented_to_fourteen = $client_nonconsented_to_fourteen->where('county_id', $selected_counties);
+ $client_nonconsented_to_nineteen = $client_nonconsented_to_nineteen->where('county_id', $selected_counties);
+ $client_nonconsented_to_twentyfour = $client_nonconsented_to_twentyfour->where('county_id', $selected_counties);
+ $client_nonconsented_to_twentyfive_above = $client_nonconsented_to_twentyfive_above->where('county_id', $selected_counties);
+ $client_nonconsented_uknown_age = $client_nonconsented_uknown_age->where('county_id', $selected_counties);
+ }
+ if (!empty($selected_subcounties)) {
+ $client = $client->where('sub_county_id', $selected_subcounties);
+ $client_consented = $client_consented->where('sub_county_id', $selected_subcounties);
+ $client_nonconsented = $client_nonconsented->where('sub_county_id', $selected_subcounties);
+ $client_consented_male = $client_consented_male->where('sub_county_id', $selected_subcounties);
+ $client_consented_female = $client_consented_female->where('sub_county_id', $selected_subcounties);
+ $client_consented_uknown_gender = $client_consented_uknown_gender->where('sub_county_id', $selected_subcounties);
+ $client_nonconsented_male = $client_nonconsented_male->where('sub_county_id', $selected_subcounties);
+ $client_nonconsented_female = $client_nonconsented_female->where('sub_county_id', $selected_subcounties);
+ $client_nonconsented_uknown_gender = $client_nonconsented_uknown_gender->where('sub_county_id', $selected_subcounties);
+ $client_consented_to_nine = $client_consented_to_nine->where('sub_county_id', $selected_subcounties);
+ $client_consented_to_fourteen = $client_consented_to_fourteen->where('sub_county_id', $selected_subcounties);
+ $client_consented_to_nineteen = $client_consented_to_nineteen->where('sub_county_id', $selected_subcounties);
+ $client_consented_to_twentyfour = $client_consented_to_twentyfour->where('sub_county_id', $selected_subcounties);
+ $client_consented_to_twentyfive_above = $client_consented_to_twentyfive_above->where('sub_county_id', $selected_subcounties);
+ $client_consented_uknown_age = $client_consented_uknown_age->where('sub_county_id', $selected_subcounties);
+ $client_nonconsented_to_nine = $client_nonconsented_to_nine->where('sub_county_id', $selected_subcounties);
+ $client_nonconsented_to_fourteen = $client_nonconsented_to_fourteen->where('sub_county_id', $selected_subcounties);
+ $client_nonconsented_to_nineteen = $client_nonconsented_to_nineteen->where('sub_county_id', $selected_subcounties);
+ $client_nonconsented_to_twentyfour = $client_nonconsented_to_twentyfour->where('sub_county_id', $selected_subcounties);
+ $client_nonconsented_to_twentyfive_above = $client_nonconsented_to_twentyfive_above->where('sub_county_id', $selected_subcounties);
+ $client_nonconsented_uknown_age = $client_nonconsented_uknown_age->where('sub_county_id', $selected_subcounties);
+ }
+ if (!empty($selected_facilites)) {
+ $client = $client->where('mfl_code', $selected_facilites);
+ $client_consented = $client_consented->where('mfl_code', $selected_facilites);
+ $client_nonconsented = $client_nonconsented->where('mfl_code', $selected_facilites);
+ $client_consented_male = $client_consented_male->where('mfl_code', $selected_facilites);
+ $client_consented_female = $client_consented_female->where('mfl_code', $selected_facilites);
+ $client_consented_uknown_gender = $client_consented_uknown_gender->where('mfl_code', $selected_facilites);
+ $client_nonconsented_male = $client_nonconsented_male->where('mfl_code', $selected_facilites);
+ $client_nonconsented_female = $client_nonconsented_female->where('mfl_code', $selected_facilites);
+ $client_nonconsented_uknown_gender = $client_nonconsented_uknown_gender->where('mfl_code', $selected_facilites);
+ $client_consented_to_nine = $client_consented_to_nine->where('mfl_code', $selected_facilites);
+ $client_consented_to_fourteen = $client_consented_to_fourteen->where('mfl_code', $selected_facilites);
+ $client_consented_to_nineteen = $client_consented_to_nineteen->where('mfl_code', $selected_facilites);
+ $client_consented_to_twentyfour = $client_consented_to_twentyfour->where('mfl_code', $selected_facilites);
+ $client_consented_to_twentyfive_above = $client_consented_to_twentyfive_above->where('mfl_code', $selected_facilites);
+ $client_consented_uknown_age = $client_consented_uknown_age->where('mfl_code', $selected_facilites);
+ $client_nonconsented_to_nine = $client_nonconsented_to_nine->where('mfl_code', $selected_facilites);
+ $client_nonconsented_to_fourteen = $client_nonconsented_to_fourteen->where('mfl_code', $selected_facilites);
+ $client_nonconsented_to_nineteen = $client_nonconsented_to_nineteen->where('mfl_code', $selected_facilites);
+ $client_nonconsented_to_twentyfour = $client_nonconsented_to_twentyfour->where('mfl_code', $selected_facilites);
+ $client_nonconsented_to_twentyfive_above = $client_nonconsented_to_twentyfive_above->where('mfl_code', $selected_facilites);
+ $client_nonconsented_uknown_age = $client_nonconsented_uknown_age->where('mfl_code', $selected_facilites);
+ }
+ if (!empty($selected_from || $selected_to)) {
+ $client = $client->where('consent_date', '>=', date($selected_from))->where('consent_date', '<=', date($selected_to));
+ $client_consented = $client_consented->where('consent_date', '>=', date($request->from))->where('consent_date', '<=', date($request->to));
+ $client_nonconsented = $client_nonconsented->where('consent_date', '>=', date($request->from))->where('consent_date', '<=', date($request->to));
+ $client_consented_male = $client_consented_male->where('consent_date', '>=', date($request->from))->where('consent_date', '<=', date($request->to));
+ $client_consented_female = $client_consented_female->where('consent_date', '>=', date($request->from))->where('consent_date', '<=', date($request->to));
+ $client_consented_uknown_gender = $client_consented_uknown_gender->where('consent_date', '>=', date($request->from))->where('consent_date', '<=', date($request->to));
+ $client_nonconsented_male = $client_nonconsented_male->where('consent_date', '>=', date($request->from))->where('consent_date', '<=', date($request->to));
+ $client_nonconsented_female = $client_nonconsented_female->where('consent_date', '>=', date($request->from))->where('consent_date', '<=', date($request->to));
+ $client_nonconsented_uknown_gender = $client_nonconsented_uknown_gender->where('consent_date', '>=', date($request->from))->where('consent_date', '<=', date($request->to));
+ $client_consented_to_nine = $client_consented_to_nine->where('consent_date', '>=', date($request->from))->where('consent_date', '<=', date($request->to));
+ $client_consented_to_fourteen = $client_consented_to_fourteen->where('consent_date', '>=', date($request->from))->where('consent_date', '<=', date($request->to));
+ $client_consented_to_nineteen = $client_consented_to_nineteen->where('consent_date', '>=', date($request->from))->where('consent_date', '<=', date($request->to));
+ $client_consented_to_twentyfour = $client_consented_to_twentyfour->where('consent_date', '>=', date($request->from))->where('consent_date', '<=', date($request->to));
+ $client_consented_to_twentyfive_above = $client_consented_to_twentyfive_above->where('consent_date', '>=', date($request->from))->where('consent_date', '<=', date($request->to));
+ $client_consented_uknown_age = $client_consented_uknown_age->where('consent_date', '>=', date($request->from))->where('consent_date', '<=', date($request->to));
+ $client_nonconsented_to_nine = $client_nonconsented_to_nine->where('consent_date', '>=', date($request->from))->where('consent_date', '<=', date($request->to));
+ $client_nonconsented_to_fourteen = $client_nonconsented_to_fourteen->where('consent_date', '>=', date($request->from))->where('consent_date', '<=', date($request->to));
+ $client_nonconsented_to_nineteen = $client_nonconsented_to_nineteen->where('consent_date', '>=', date($request->from))->where('consent_date', '<=', date($request->to));
+ $client_nonconsented_to_twentyfour = $client_nonconsented_to_twentyfour->where('consent_date', '>=', date($request->from))->where('consent_date', '<=', date($request->to));
+ $client_nonconsented_to_twentyfive_above = $client_nonconsented_to_twentyfive_above->where('consent_date', '>=', date($request->from))->where('consent_date', '<=', date($request->to));
+ $client_nonconsented_uknown_age = $client_nonconsented_uknown_age->where('consent_date', '>=', date($request->from))->where('consent_date', '<=', date($request->to));
+ }
+ if (!empty($selected_module == 'DSD')) {
+ $client = $client;
+ $client_consented = $client_consented;
+ $client_nonconsented = $client_nonconsented;
+ $client_consented_male = $client_consented_male;
+ $client_consented_female = $client_consented_female;
+ $client_consented_uknown_gender = $client_consented_uknown_gender;
+ $client_nonconsented_male = $client_nonconsented_male;
+ $client_nonconsented_female = $client_nonconsented_female;
+ $client_nonconsented_uknown_gender = $client_nonconsented_uknown_gender;
+ $client_consented_to_nine = $client_consented_to_nine;
+ $client_consented_to_fourteen = $client_consented_to_fourteen;
+ $client_consented_to_nineteen = $client_consented_to_nineteen;
+ $client_consented_to_twentyfour = $client_consented_to_twentyfour;
+ $client_consented_to_twentyfive_above = $client_consented_to_twentyfive_above;
+ $client_consented_uknown_age = $client_consented_uknown_age;
+ $client_nonconsented_to_nine = $client_nonconsented_to_nine;
+ $client_nonconsented_to_fourteen = $client_nonconsented_to_fourteen;
+ $client_nonconsented_to_nineteen = $client_nonconsented_to_nineteen;
+ $client_nonconsented_to_twentyfour = $client_nonconsented_to_twentyfour;
+ $client_nonconsented_to_twentyfive_above = $client_nonconsented_to_twentyfive_above;
+ $client_nonconsented_uknown_age = $client_nonconsented_uknown_age;
+ }
+ if (!empty($selected_module == 'PMTCT')) {
+ $client = $client;
+ $client_consented = $client_consented;
+ $client_nonconsented = $client_nonconsented;
+ $client_consented_male = $client_consented_male;
+ $client_consented_female = $client_consented_female;
+ $client_consented_uknown_gender = $client_consented_uknown_gender;
+ $client_nonconsented_male = $client_nonconsented_male;
+ $client_nonconsented_female = $client_nonconsented_female;
+ $client_nonconsented_uknown_gender = $client_nonconsented_uknown_gender;
+ $client_consented_to_nine = $client_consented_to_nine;
+ $client_consented_to_fourteen = $client_consented_to_fourteen;
+ $client_consented_to_nineteen = $client_consented_to_nineteen;
+ $client_consented_to_twentyfour = $client_consented_to_twentyfour;
+ $client_consented_to_twentyfive_above = $client_consented_to_twentyfive_above;
+ $client_consented_uknown_age = $client_consented_uknown_age;
+ $client_nonconsented_to_nine = $client_nonconsented_to_nine;
+ $client_nonconsented_to_fourteen = $client_nonconsented_to_fourteen;
+ $client_nonconsented_to_nineteen = $client_nonconsented_to_nineteen;
+ $client_nonconsented_to_twentyfour = $client_nonconsented_to_twentyfour;
+ $client_nonconsented_to_twentyfive_above = $client_nonconsented_to_twentyfive_above;
+ $client_nonconsented_uknown_age = $client_nonconsented_uknown_age;
+ }
+
+
+ $data["client"] = $client->first()->total_sum;
+ $data["client_consented"] = $client_consented->sum('client_consented');
+ $data["client_nonconsented"] = $client_nonconsented->sum('non_consented');
+ $data["client_consented_male"] = $client_consented_male->sum('client_consented');
+ $data["client_consented_female"] = $client_consented_female->sum('client_consented');
+ $data["client_consented_uknown_gender"] = $client_consented_uknown_gender->sum('client_consented');
+ $data["client_nonconsented_male"] = $client_nonconsented_male->sum('non_consented');
+ $data["client_nonconsented_female"] = $client_nonconsented_female->sum('non_consented');
+ $data["client_nonconsented_uknown_gender"] = $client_nonconsented_uknown_gender->sum('non_consented');
+ $data["client_consented_to_nine"] = $client_consented_to_nine->sum('client_consented');
+ $data["client_consented_to_fourteen"] = $client_consented_to_fourteen->sum('client_consented');
+ $data["client_consented_to_nineteen"] = $client_consented_to_nineteen->sum('client_consented');
+ $data["client_consented_to_twentyfour"] = $client_consented_to_twentyfour->sum('client_consented');
+ $data["client_consented_to_twentyfive_above"] = $client_consented_to_twentyfive_above->sum('client_consented');
+ $data["client_consented_uknown_age"] = $client_consented_uknown_age->sum('client_consented');
+ $data["client_nonconsented_to_nine"] = $client_nonconsented_to_nine->sum('non_consented');
+ $data["client_nonconsented_to_fourteen"] = $client_nonconsented_to_fourteen->sum('non_consented');
+ $data["client_nonconsented_to_nineteen"] = $client_nonconsented_to_nineteen->sum('non_consented');
+ $data["client_nonconsented_to_twentyfour"] = $client_nonconsented_to_twentyfour->sum('non_consented');
+ $data["client_nonconsented_to_twentyfive_above"] = $client_nonconsented_to_twentyfive_above->sum('non_consented');
+ $data["client_nonconsented_uknown_age"] = $client_nonconsented_uknown_age->sum('non_consented');
+
+ 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..66db40d
--- /dev/null
+++ b/app/Http/Controllers/NewReportController.php
@@ -0,0 +1,849 @@
+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')
+ ->leftJoin('tbl_gender', 'tbl_client.gender', '=', 'tbl_gender.id')
+ ->leftJoin('tbl_groups', 'tbl_client.group_id', '=', 'tbl_groups.id')
+ ->leftJoin('tbl_language', 'tbl_client.language_id', '=', 'tbl_language.id')
+ ->leftJoin('tbl_condition', 'tbl_client.client_status', '=', 'tbl_condition.name')
+ ->leftJoin('tbl_marital_status', 'tbl_client.marital', '=', 'tbl_marital_status.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_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')
+ ->leftJoin('tbl_gender', 'tbl_client.gender', '=', 'tbl_gender.id')
+ ->leftJoin('tbl_groups', 'tbl_client.group_id', '=', 'tbl_groups.id')
+ ->leftJoin('tbl_language', 'tbl_client.language_id', '=', 'tbl_language.id')
+ ->leftJoin('tbl_condition', 'tbl_client.client_status', '=', 'tbl_condition.name')
+ ->leftJoin('tbl_marital_status', 'tbl_client.marital', '=', 'tbl_marital_status.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_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')
+ ->leftJoin('tbl_gender', 'tbl_client.gender', '=', 'tbl_gender.id')
+ ->leftJoin('tbl_groups', 'tbl_client.group_id', '=', 'tbl_groups.id')
+ ->leftJoin('tbl_language', 'tbl_client.language_id', '=', 'tbl_language.id')
+ ->leftJoin('tbl_condition', 'tbl_client.client_status', '=', 'tbl_condition.name')
+ ->leftJoin('tbl_marital_status', 'tbl_client.marital', '=', 'tbl_marital_status.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_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);
+ }
+ } else {
+ if (Auth::user()->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')
+ ->leftJoin('tbl_gender', 'tbl_client.gender', '=', 'tbl_gender.id')
+ ->leftJoin('tbl_groups', 'tbl_client.group_id', '=', 'tbl_groups.id')
+ ->leftJoin('tbl_language', 'tbl_client.language_id', '=', 'tbl_language.id')
+ ->leftJoin('tbl_condition', 'tbl_client.client_status', '=', 'tbl_condition.name')
+ ->leftJoin('tbl_marital_status', 'tbl_client.marital', '=', 'tbl_marital_status.id')
+ ->join('tbl_county', 'tbl_partner_facility.county_id', '=', 'tbl_county.id')
+ ->leftJoin(DB::raw('(SELECT client_id, DATE(created_at) AS created_at
+ FROM tbl_appointment a1
+ WHERE a1.id = (SELECT MAX(a2.id) FROM tbl_appointment a2 WHERE a2.client_id = a1.client_id)
+ AND a1.consented = "YES") a'), 'tbl_client.id', '=', 'a.client_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',
+ DB::raw('CASE WHEN tbl_client.smsenable="Yes" THEN "Yes" WHEN a.client_id IS NOT NULL THEN
+ "Yes" ELSE "No" END as 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'
+ )
+ ->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')
+ ->leftJoin(DB::raw('(SELECT client_id, DATE(created_at) AS created_at
+ FROM tbl_appointment a1
+ WHERE a1.id = (SELECT MAX(a2.id) FROM tbl_appointment a2 WHERE a2.client_id = a1.client_id)
+ AND a1.consented = "YES") a'), 'tbl_client.id', '=', 'a.client_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',
+ DB::raw('CASE WHEN tbl_client.smsenable="Yes" THEN "Yes" WHEN a.client_id IS NOT NULL THEN
+ "Yes" ELSE "No" END as 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) {
+ Alert::success('Success', 'Client' . ' ' . $request->clinic_number . ' ' . 'details was successfully updated!');
+ return redirect('new/clients/list');
+ } else {
+ Alert::error('Failed', 'Could not update client details please try again later.');
+ return back();
+ }
+ } catch (Exception $e) {
+ $code = $e->getCode();
+
+ if ((string)$code === (string)"23000") {
+ Alert::success('Success', 'Clinic Number' . ' ' . $request->clinic_number . ' ' . 'belongs to another client! ');
+ return back();;
+ } 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')
+ ->leftJoin('tbl_gender', 'tbl_client.gender', '=', 'tbl_gender.id')
+ ->leftJoin('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.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')
+ ->leftJoin('tbl_gender', 'tbl_client.gender', '=', 'tbl_gender.id')
+ ->leftJoin('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.date_attended', 'tbl_appointment.active_app', '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')
+ ->leftJoin('tbl_gender', 'tbl_client.gender', '=', 'tbl_gender.id')
+ ->leftJoin('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.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 (env('INSTANCE') === 'UshauriDOD') {
+ 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')
+ ->select('tbl_master_facility.code', 'tbl_master_facility.name as facility', 'tbl_partner.name as partner')
+ ->whereDate('tbl_appointment.created_at', '>=', Carbon::now()->subMonths(6)->toDateString())
+ ->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')
+ ->whereDate('tbl_appointment.created_at', '>=', Carbon::now()->subMonths(6)->toDateString())
+ ->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')
+ ->whereDate('tbl_appointment.created_at', '>=', Carbon::now()->subMonths(6)->toDateString())
+ ->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')
+ ->whereDate('tbl_appointment.created_at', '>=', Carbon::now()->subMonths(6)->toDateString())
+ ->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')
+ ->whereDate('tbl_appointment.created_at', '>=', Carbon::now()->subMonths(6)->toDateString())
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)
+ ->orderBy('tbl_appointment.created_at', 'DESC')
+ ->groupBy('tbl_partner_facility.mfl_code')
+ ->get();
+ }
+ } else {
+ 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')
+ ->whereDate('tbl_appointment.created_at', '>=', Carbon::now()->subMonths(6)->toDateString())
+ ->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')
+ ->whereDate('tbl_appointment.created_at', '>=', Carbon::now()->subMonths(6)->toDateString())
+ ->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')
+ ->whereDate('tbl_appointment.created_at', '>=', Carbon::now()->subMonths(6)->toDateString())
+ ->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')
+ ->whereDate('tbl_appointment.created_at', '>=', Carbon::now()->subMonths(6)->toDateString())
+ ->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')
+ ->whereDate('tbl_appointment.created_at', '>=', Carbon::now()->subMonths(6)->toDateString())
+ ->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')
+ ->leftJoin('tbl_gender', 'tbl_client.gender', 'tbl_gender.id')
+ ->leftJoin('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')
+ ->leftJoin('tbl_county', 'tbl_partner_facility.county_id', 'tbl_county.id')
+ ->leftJoin('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',
+ DB::raw('CASE WHEN tbl_clnt_outgoing.message_id IS NULL OR tbl_clnt_outgoing.message_id = "None" OR tbl_clnt_outgoing.callback_status = "Failed" OR tbl_clnt_outgoing.callback_status = "Expired" THEN "Failed" ELSE "Success" END AS callback_status'),
+ DB::raw('CASE WHEN tbl_clnt_outgoing.message_id IS NULL OR tbl_clnt_outgoing.message_id = "None" OR tbl_clnt_outgoing.callback_status = "Expired" THEN "Phone No. Inactive" WHEN tbl_clnt_outgoing.failure_reason = "UserInBlackList" THEN "Service Blacklisted" WHEN tbl_clnt_outgoing.failure_reason = "AbsentSubscriber" THEN "Phone off >48 Hours" WHEN tbl_clnt_outgoing.failure_reason = "UserInactive" THEN "Failure at Telco" WHEN tbl_clnt_outgoing.failure_reason = "DeliveryFailure" THEN "Phone No. Inactive" END AS 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')
+ ->leftJoin('tbl_gender', 'tbl_client.gender', 'tbl_gender.id')
+ ->leftJoin('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')
+ ->leftJoin('tbl_county', 'tbl_partner_facility.county_id', 'tbl_county.id')
+ ->leftJoin('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',
+ DB::raw('CASE WHEN tbl_clnt_outgoing.message_id IS NULL OR tbl_clnt_outgoing.message_id = "None" OR tbl_clnt_outgoing.callback_status = "Failed" OR tbl_clnt_outgoing.callback_status = "Expired" THEN "Failed" ELSE "Success" END AS callback_status'),
+ DB::raw('CASE WHEN tbl_clnt_outgoing.message_id IS NULL OR tbl_clnt_outgoing.message_id = "None" OR tbl_clnt_outgoing.callback_status = "Expired" THEN "Phone No. Inactive" WHEN tbl_clnt_outgoing.failure_reason = "UserInBlackList" THEN "Service Blacklisted" WHEN tbl_clnt_outgoing.failure_reason = "AbsentSubscriber" THEN "Phone off >48 Hours" WHEN tbl_clnt_outgoing.failure_reason = "UserInactive" THEN "Failure at Telco" WHEN tbl_clnt_outgoing.failure_reason = "DeliveryFailure" THEN "Phone No. Inactive" END AS 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')
+ ->leftJoin('tbl_gender', 'tbl_client.gender', 'tbl_gender.id')
+ ->leftJoin('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')
+ ->leftJoin('tbl_county', 'tbl_partner_facility.county_id', 'tbl_county.id')
+ ->leftJoin('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',
+ DB::raw('CASE WHEN tbl_clnt_outgoing.message_id IS NULL OR tbl_clnt_outgoing.message_id = "None" OR tbl_clnt_outgoing.callback_status = "Failed" OR tbl_clnt_outgoing.callback_status = "Expired" THEN "Failed" ELSE "Success" END AS callback_status'),
+ DB::raw('CASE WHEN tbl_clnt_outgoing.message_id IS NULL OR tbl_clnt_outgoing.message_id = "None" OR tbl_clnt_outgoing.callback_status = "Expired" THEN "Phone No. Inactive" WHEN tbl_clnt_outgoing.failure_reason = "UserInBlackList" THEN "Service Blacklisted" WHEN tbl_clnt_outgoing.failure_reason = "AbsentSubscriber" THEN "Phone off >48 Hours" WHEN tbl_clnt_outgoing.failure_reason = "UserInactive" THEN "Failure at Telco" WHEN tbl_clnt_outgoing.failure_reason = "DeliveryFailure" THEN "Phone No. Inactive" END AS failure_reason'),
+ 'tbl_clnt_outgoing.no_of_days',
+ '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'));
+ }
+ public function program_index()
+ {
+ return view('dashboard.program');
+ }
+
+ public function program()
+ {
+ $data = [];
+
+ $latestMonthYear = UshauriProgram::max('LastDateUsed');
+ $latestMonthYear = UshauriProgramActive::max('LastDateUsed');
+
+ $sixMonthsBefore = Carbon::parse($latestMonthYear)->subMonths(5);
+ $program = UshauriProgram::whereDate('LastDateUsed', '>=', $sixMonthsBefore)->orderBy('Months', 'ASC');
+ $active_site = UshauriProgramActive::whereDate('LastDateUsed', '>=', $sixMonthsBefore)->orderBy('Months', 'ASC');
+
+
+ $data["program"] = $program->get();
+ $data["active_site"] = $active_site->get();
+
+ return $data;
+ }
+ public function program_filter(Request $request)
+ {
+ $data = [];
+ $selected_month = $request->months;
+ $selected_year = $request->year;
+
+
+
+
+ if (!empty($selected_month)) {
+ $program = UshauriProgram::select('*')->orderBy('Months', 'ASC');
+ $program = $program->where('MonthYear', 'LIKE', "%$selected_month%");
+
+ $active_site = UshauriProgramActive::select('*')->orderBy('Months', 'ASC');
+ $active_site = $active_site->where('MonthYear', 'LIKE', "%$selected_month%");
+ }
+ if (!empty($selected_year)) {
+ $program = UshauriProgram::select('*')->orderBy('Months', 'ASC');
+ $program = $program->where('MonthYear', 'LIKE', "%$selected_year%");
+
+ $active_site = UshauriProgramActive::select('*')->orderBy('Months', 'ASC');
+ $active_site = $active_site->where('MonthYear', 'LIKE', "%$selected_year%");
+ }
+ if (!empty($selected_year) && !empty($selected_month)) {
+ // $program = UshauriProgram::where('MonthYear', 'LIKE', "$selected_month-$selected_year");
+ $selected_month_number = date('n', strtotime("$selected_month 1"));
+
+ $program = UshauriProgram::where(function ($query) use ($selected_month, $selected_year, $selected_month_number) {
+ $query->where('MonthYear', 'LIKE', "$selected_month-$selected_year")->orderBy('Months', 'ASC');
+
+ for ($i = 1; $i <= 5; $i++) {
+ $previous_month_number = $selected_month_number - $i;
+ $previous_month_name = date('F', mktime(0, 0, 0, $previous_month_number, 1));
+
+ if ($previous_month_number <= 0) {
+ $previous_month_number += 12;
+ $previous_year = $selected_year - 1;
+ } else {
+ $previous_year = $selected_year;
+ }
+
+ $query->orWhere('MonthYear', 'LIKE', "$previous_month_name-$previous_year");
+ }
+ });
+
+ $active_site = UshauriProgramActive::where(function ($query) use ($selected_month, $selected_year, $selected_month_number) {
+ $query->where('MonthYear', 'LIKE', "$selected_month-$selected_year")->orderBy('Months', 'ASC');
+
+ for ($i = 1; $i <= 5; $i++) {
+ $previous_month_number = $selected_month_number - $i;
+ $previous_month_name = date('F', mktime(0, 0, 0, $previous_month_number, 1));
+
+ if ($previous_month_number <= 0) {
+ $previous_month_number += 12;
+ $previous_year = $selected_year - 1;
+ } else {
+ $previous_year = $selected_year;
+ }
+
+ $query->orWhere('MonthYear', 'LIKE', "$previous_month_name-$previous_year");
+ }
+ });
+ }
+ $data["program"] = $program->get();
+ $data["active_site"] = $active_site->get();
+ return $data;
+ }
+}
diff --git a/app/Http/Controllers/NishauriController.php b/app/Http/Controllers/NishauriController.php
new file mode 100644
index 0000000..4d46fe8
--- /dev/null
+++ b/app/Http/Controllers/NishauriController.php
@@ -0,0 +1,958 @@
+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 reschedule()
+ {
+ $data = [];
+ if (Auth::user()->access_level == 'Facility') {
+ $reschedule = Reschedule::join('tbl_appointment', 'tbl_nishauri_appoinment_reschedule.appointment_id', '=', 'tbl_appointment.id')
+ ->join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_client.f_name', 'tbl_client.m_name', 'tbl_client.l_name', 'tbl_appointment.appntmnt_date', 'tbl_nishauri_appoinment_reschedule.reason', 'tbl_nishauri_appoinment_reschedule.proposed_date')
+ ->where('tbl_nishauri_appoinment_reschedule.status', '=', '0')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id);
+
+ $data["reschedule"] = $reschedule->count();
+ $data["reschedule_list"] = $reschedule->get();
+
+ return $data;
+ }
+ }
+
+ public function reschedule_list()
+ {
+ if (Auth::user()->access_level == 'Facility') {
+ $reschedule = Reschedule::join('tbl_appointment', 'tbl_nishauri_appoinment_reschedule.appointment_id', '=', 'tbl_appointment.id')
+ ->join('tbl_client', 'tbl_appointment.client_id', '=', 'tbl_client.id')
+ ->select('tbl_client.f_name', 'tbl_client.m_name', 'tbl_client.l_name', 'tbl_client.clinic_number', 'tbl_appointment.id as appointment_id', 'tbl_appointment.appntmnt_date', 'tbl_nishauri_appoinment_reschedule.reason', 'tbl_nishauri_appoinment_reschedule.proposed_date')
+ ->where('tbl_nishauri_appoinment_reschedule.status', '=', '0')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->get();
+
+ return view('nishauri.reschedule', compact('reschedule'));
+ }
+ }
+
+ public function approve(Request $request)
+ {
+ try {
+ $client = Reschedule::where('appointment_id', $request->appointment_id)
+ ->update([
+ 'status' => '1',
+ 'process_date' => date('Y-m-d H:i:s'),
+ 'process_by' => Auth::user()->id,
+ ]);
+ if ($client) {
+ Alert::success('Success', 'Date Successfully Approved');
+ return redirect('reschedule/list');
+ } else {
+ Alert::error('Failed', 'Could not approve please try again later.');
+ return back();
+ }
+ } catch (Exception $e) {
+ }
+ }
+
+ public function reject(Request $request)
+ {
+ try {
+ $client = Reschedule::where('appointment_id', $request->appointment_id)
+ ->update([
+ 'status' => '2',
+ 'process_date' => date('Y-m-d H:i:s'),
+ 'process_by' => Auth::user()->id,
+ ]);
+ if ($client) {
+ Alert::success('Success', 'Date Successfully Rejected');
+ return redirect('reschedule/list');
+ } else {
+ Alert::error('Failed', 'Could not reject please try again later.');
+ return back();
+ }
+ } catch (Exception $e) {
+ }
+ }
+ public function tet()
+ {
+ $client = Txcurr::where('mfl_code', '12345')->where('period', '202302')
+ ->update([
+ 'tx_cur' => '202305',
+ ]);
+ }
+
+ public function otp_search(Request $request)
+ {
+ $upn_search = $request->input('upn_search');
+
+ $otp_search = NishauriUser::select('msisdn', 'profile_otp_number')
+ ->where('is_active', '=', '0')
+ ->where('msisdn', 'like', '%' . $upn_search . '%')
+ ->first();
+
+ return response()->json(['profile_otp_number' => $otp_search ? $otp_search->profile_otp_number : null]);
+ }
+
+ public function dashboard()
+ {
+ if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+ $partners = Partner::where("status", "=", "Active")
+ ->get();
+
+ $counties = County::where("status", "=", "Active")
+ ->get(['id', 'name']);
+
+ $sub_counties = SubCounty::where("status", "=", "Active")
+ ->get(['id', 'name']);
+
+ $facilities = Facility::join('tbl_partner_facility', 'tbl_master_facility.code', '=', 'tbl_partner_facility.mfl_code')
+ ->get(['tbl_master_facility.code', 'tbl_master_facility.name']);
+
+ return view('nishauri.dashboard', compact('partners', 'counties', 'sub_counties', 'facilities'));
+ }
+ if (Auth::user()->access_level == 'Facility') {
+
+ return view('nishauri.dashboard');
+ }
+ 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')
+ ->get();
+
+ $counties = County::where("status", "=", "Active")
+ ->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')
+ ->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)
+ ->get();
+
+ return view('nishauri.dashboard', compact('partners', 'counties', 'sub_counties', 'facilities'));
+ }
+ 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)
+ ->get();
+
+ return view('nishauri.dashboard', compact('facilities'));
+ }
+ 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)
+ ->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')
+ ->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')
+ ->get();
+
+ return view('nishauri.dashboard', compact('facilities', 'counties', 'sub_counties'));
+ }
+ }
+
+ public function nishauri_uptake()
+ {
+ $data = [];
+
+ if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+ $currentDate = Carbon::now();
+ $txcurr = Txcurr::selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest.max_period');
+ })
+ ->groupBy('tbl_tx_cur.mfl_code')
+ ->get();
+ $txcurr = $txcurr->sum('tx_cur');
+ $all_enrollment = NishauriUptake::select('*');
+ $all_module = NishauriAccess::select('*');
+
+ $data['txcurr'] = $txcurr;
+ $data['all_enrollment'] = $all_enrollment->get()->map(function ($item) {
+ $item['no_of_clients'] = (int)$item['no_of_clients'];
+ return $item;
+ });
+ $data['all_module'] = $all_module->get();
+ }
+ if (Auth::user()->access_level == 'Facility') {
+ $facility = Auth::user()->facility_id;
+ $currentDate = Carbon::now();
+ $txcurr = Txcurr::selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest.max_period');
+ })
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id)
+ ->groupBy('tbl_tx_cur.mfl_code')
+ ->get();
+ $txcurr = $txcurr->sum('tx_cur');
+ $all_enrollment = NishauriFacility::select('*')->where('mfl_code', Auth::user()->facility_id);
+ $all_module = NishauriAccess::select('*')->where('mfl_code', Auth::user()->facility_id);
+
+ $data['txcurr'] = $txcurr;
+ $data['all_enrollment'] = $all_enrollment->get();
+ $data['all_module'] = $all_module->get();
+ }
+ if (Auth::user()->access_level == 'Partner') {
+ $partner = Auth::user()->partner_id;
+ $currentDate = Carbon::now();
+ $txcurr = Txcurr::selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest.max_period');
+ })
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id)
+ ->groupBy('tbl_tx_cur.mfl_code')
+ ->get();
+ $txcurr = $txcurr->sum('tx_cur');
+ $all_enrollment = NishauriUptake::select('*')->where('partner_id', Auth::user()->partner_id);
+ $all_module = NishauriAccess::select('*')->where('partner_id', Auth::user()->partner_id);
+
+ $data['txcurr'] = $txcurr;
+ $data['all_enrollment'] = $all_enrollment->get()->map(function ($item) {
+ $item['no_of_clients'] = (int)$item['no_of_clients'];
+ return $item;
+ });
+ $data['all_module'] = $all_module->get();
+ }
+ if (Auth::user()->access_level == 'County') {
+ $county = Auth::user()->county_id;
+ $currentDate = Carbon::now();
+ $txcurr = Txcurr::selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest.max_period');
+ })
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id)
+ ->groupBy('tbl_tx_cur.mfl_code')
+ ->get();
+ $txcurr = $txcurr->sum('tx_cur');
+ $all_enrollment = NishauriUptake::select('*')->where('county_id', Auth::user()->county_id);
+ $all_module = NishauriAccess::select('*')->where('county_id', Auth::user()->county_id);
+
+ $data['txcurr'] = $txcurr;
+ $data['all_enrollment'] = $all_enrollment->get()->map(function ($item) {
+ $item['no_of_clients'] = (int)$item['no_of_clients'];
+ return $item;
+ });
+ $data['all_module'] = $all_module->get();
+ }
+ if (Auth::user()->access_level == 'Sub County') {
+ $subcounty = Auth::user()->sub_county_id;
+ $txcurr = Txcurr::selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest.max_period');
+ })
+ ->where('tbl_partner_facility.sub_county_id', Auth::user()->subcounty_id)
+ ->groupBy('tbl_tx_cur.mfl_code')
+ ->get();
+ $txcurr = $txcurr->sum('tx_cur');
+ $all_enrollment = NishauriUptake::select('*')->where('sub_county_id', Auth::user()->subcounty_id);
+ $all_module = NishauriAccess::select('*')->where('sub_county_id', Auth::user()->subcounty_id);
+
+
+ $data['txcurr'] = $txcurr;
+ $data['all_enrollment'] = $all_enrollment->get()->map(function ($item) {
+ $item['no_of_clients'] = (int)$item['no_of_clients'];
+ return $item;
+ });
+ $data['all_module'] = $all_module->get();
+ }
+
+ return $data;
+ }
+
+ public function filter_nishauri_uptake(Request $request)
+ {
+ if (Auth::user()->access_level == 'Partner') {
+
+ $selected_partners = $request->partners;
+ $selected_counties = $request->counties;
+ $selected_subcounties = $request->subcounties;
+ $selected_facilites = $request->facilities;
+ $selected_from = $request->from;
+ $selected_to = $request->to;
+
+ $partner = Auth::user()->partner_id;
+ $currentDate = Carbon::now();
+
+ $query = Txcurr::query()->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_partner_facility.partner_id', Auth::user()->partner_id);
+
+ if (!empty($selected_partners)) {
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest.max_period');
+ })->where('tbl_partner_facility.partner_id', $selected_partners)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $txcurr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $all_enrollment = NishauriUptake::select('*')->where('partner_id', $selected_partners);
+ $all_module = NishauriAccess::select('*')->where('partner_id', $selected_partners);
+ }
+ if (!empty($selected_counties)) {
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_con'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_con.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_con.max_period');
+ })->where('tbl_partner_facility.county_id', $selected_counties)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $txcurr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $all_enrollment = NishauriUptake::select('*')->where('partner_id', Auth::user()->partner_id)->where('county_id', $selected_counties);
+ $all_module = NishauriAccess::select('*')->where('partner_id', Auth::user()->partner_id)->where('county_id', $selected_counties);
+ }
+ if (!empty($selected_subcounties)) {
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_sub'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_sub.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_sub.max_period');
+ })
+ ->where('sub_county_id', $selected_subcounties)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $txcurr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $all_enrollment = NishauriUptake::select('*')->where('partner_id', Auth::user()->partner_id)->where('sub_county_id', $selected_subcounties);
+ $all_module = NishauriAccess::select('*')->where('partner_id', Auth::user()->partner_id)->where('sub_county_id', $selected_subcounties);
+ }
+ if (!empty($selected_facilites)) {
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_fac'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_fac.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_fac.max_period');
+ })
+ ->where('tbl_partner_facility.mfl_code', $selected_facilites)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $txcurr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $all_enrollment = NishauriUptake::select('*')->where('partner_id', Auth::user()->partner_id)->where('mfl_code', $selected_facilites);
+ $all_module = NishauriAccess::select('*')->where('partner_id', Auth::user()->partner_id)->where('mfl_code', $selected_facilites);
+ }
+ if (!empty($selected_from || $selected_to)) {
+
+ $selectedFrom = date('Ym', strtotime($request->from));
+ $selectedTo = date('Ym', strtotime($request->to));
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_date'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_date.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_date.max_period');
+ })
+ ->where(function ($query) use ($selectedFrom, $selectedTo) {
+ $query->whereRaw("SUBSTRING(tbl_tx_cur.period, 1, 6) >= ?", $selectedFrom)
+ ->whereRaw("SUBSTRING(tbl_tx_cur.period, 1, 6) <= ?", $selectedTo);
+ })
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $txcurr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $all_enrollment = NishauriUptake::select('*')->where('partner_id', Auth::user()->partner_id)->where('enrolled_date', '>=', date($request->from))->where('enrolled_date', '<=', date($request->to));
+ $all_module = NishauriAccess::select('*')->where('partner_id', Auth::user()->partner_id)->where('date', '>=', date($request->from))->where('date', '<=', date($request->to));
+ }
+
+
+ $data['txcurr'] = $txcurr;
+ $data['all_enrollment'] = $all_enrollment->get()->map(function ($item) {
+ $item['no_of_clients'] = (int)$item['no_of_clients'];
+ return $item;
+ });
+ $data['all_module'] = $all_module->get();
+
+ return $data;
+ }
+ if (Auth::user()->access_level == 'County') {
+
+ $selected_partners = $request->partners;
+ $selected_counties = $request->counties;
+ $selected_subcounties = $request->subcounties;
+ $selected_facilites = $request->facilities;
+ $selected_from = $request->from;
+ $selected_to = $request->to;
+
+ $county = Auth::user()->county_id;
+ $currentDate = Carbon::now();
+
+ $query = Txcurr::query()->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_partner_facility.county_id', Auth::user()->county_id);
+
+ if (!empty($selected_partners)) {
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest.max_period');
+ })->where('tbl_partner_facility.partner_id', $selected_partners)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $txcurr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $all_enrollment = NishauriUptake::select('*')->where('county_id', Auth::user()->county_id)->where('partner_id', $selected_partners);
+ $all_module = NishauriAccess::select('*')->where('county_id', Auth::user()->county_id)->where('partner_id', $selected_partners);
+ }
+ if (!empty($selected_counties)) {
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_con'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_con.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_con.max_period');
+ })->where('tbl_partner_facility.county_id', $selected_counties)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $txcurr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $all_enrollment = NishauriUptake::select('*')->where('county_id', Auth::user()->county_id)->where('county_id', $selected_counties);
+ $all_module = NishauriAccess::select('*')->where('county_id', Auth::user()->county_id)->where('county_id', $selected_counties);
+ }
+ if (!empty($selected_subcounties)) {
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_sub'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_sub.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_sub.max_period');
+ })
+ ->where('sub_county_id', $selected_subcounties)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $txcurr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $all_enrollment = NishauriUptake::select('*')->where('county_id', Auth::user()->county_id)->where('sub_county_id', $selected_subcounties);
+ $all_module = NishauriAccess::select('*')->where('county_id', Auth::user()->county_id)->where('sub_county_id', $selected_subcounties);
+ }
+ if (!empty($selected_facilites)) {
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_fac'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_fac.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_fac.max_period');
+ })
+ ->where('tbl_partner_facility.mfl_code', $selected_facilites)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $txcurr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $all_enrollment = NishauriUptake::select('*')->where('mfl_code', $selected_facilites);
+ $all_module = NishauriAccess::select('*')->where('mfl_code', $selected_facilites);
+ }
+ if (!empty($selected_from || $selected_to)) {
+
+ $selectedFrom = date('Ym', strtotime($request->from));
+ $selectedTo = date('Ym', strtotime($request->to));
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_date'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_date.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_date.max_period');
+ })
+ ->where(function ($query) use ($selectedFrom, $selectedTo) {
+ $query->whereRaw("SUBSTRING(tbl_tx_cur.period, 1, 6) >= ?", $selectedFrom)
+ ->whereRaw("SUBSTRING(tbl_tx_cur.period, 1, 6) <= ?", $selectedTo);
+ })
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $txcurr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $all_enrollment = NishauriUptake::select('*')->where('county_id', Auth::user()->county_id)->where('enrolled_date', '>=', date($request->from))->where('enrolled_date', '<=', date($request->to));
+ $all_module = NishauriAccess::select('*')->where('county_id', Auth::user()->county_id)->where('date', '>=', date($request->from))->where('date', '<=', date($request->to));
+ }
+
+
+ $data['txcurr'] = $txcurr;
+ $data['all_enrollment'] = $all_enrollment->get()->map(function ($item) {
+ $item['no_of_clients'] = (int)$item['no_of_clients'];
+ return $item;
+ });
+ $data['all_module'] = $all_module->get();
+
+ return $data;
+ }
+ if (Auth::user()->access_level == 'Sub County') {
+
+ $selected_partners = $request->partners;
+ $selected_counties = $request->counties;
+ $selected_subcounties = $request->subcounties;
+ $selected_facilites = $request->facilities;
+ $selected_from = $request->from;
+ $selected_to = $request->to;
+
+ $subcounty = Auth::user()->subcounty_id;
+ $currentDate = Carbon::now();
+
+ $query = Txcurr::query()->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);
+
+ if (!empty($selected_partners)) {
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest.max_period');
+ })->where('tbl_partner_facility.partner_id', $selected_partners)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $txcurr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $all_enrollment = NishauriUptake::select('*')->where('partner_id', $selected_partners);
+ $all_module = NishauriAccess::select('*')->where('partner_id', $selected_partners);
+ }
+ if (!empty($selected_counties)) {
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_con'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_con.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_con.max_period');
+ })->where('tbl_partner_facility.county_id', $selected_counties)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $txcurr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $all_enrollment = NishauriUptake::select('*')->where('county_id', $selected_counties);
+ $all_module = NishauriAccess::select('*')->where('county_id', $selected_counties);
+ }
+ if (!empty($selected_subcounties)) {
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_sub'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_sub.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_sub.max_period');
+ })
+ ->where('sub_county_id', $selected_subcounties)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $txcurr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $all_enrollment = NishauriUptake::select('*')->where('sub_county_id', $selected_subcounties);
+ $all_module = NishauriAccess::select('*')->where('sub_county_id', $selected_subcounties);
+ }
+ if (!empty($selected_facilites)) {
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_fac'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_fac.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_fac.max_period');
+ })
+ ->where('tbl_partner_facility.mfl_code', $selected_facilites)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $txcurr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $all_enrollment = NishauriUptake::select('*')->where('mfl_code', $selected_facilites);
+ $all_module = NishauriAccess::select('*')->where('mfl_code', $selected_facilites);
+ }
+ if (!empty($selected_from || $selected_to)) {
+
+ $selectedFrom = date('Ym', strtotime($request->from));
+ $selectedTo = date('Ym', strtotime($request->to));
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_date'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_date.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_date.max_period');
+ })
+ ->where(function ($query) use ($selectedFrom, $selectedTo) {
+ $query->whereRaw("SUBSTRING(tbl_tx_cur.period, 1, 6) >= ?", $selectedFrom)
+ ->whereRaw("SUBSTRING(tbl_tx_cur.period, 1, 6) <= ?", $selectedTo);
+ })
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $txcurr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $all_enrollment = NishauriUptake::select('*')->where('sub_county_id', Auth::user()->subcounty_id)->where('enrolled_date', '>=', date($request->from))->where('enrolled_date', '<=', date($request->to));
+ $all_module = NishauriAccess::select('*')->where('sub_county_id', Auth::user()->subcounty_id)->where('date', '>=', date($request->from))->where('date', '<=', date($request->to));
+ }
+
+
+ $data['txcurr'] = $txcurr;
+ $data['all_enrollment'] = $all_enrollment->get()->map(function ($item) {
+ $item['no_of_clients'] = (int)$item['no_of_clients'];
+ return $item;
+ });
+ $data['all_module'] = $all_module;
+
+ 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_from = $request->from;
+ $selected_to = $request->to;
+
+ $facility = Auth::user()->facility_id;
+ $currentDate = Carbon::now();
+
+ $query = Txcurr::query()->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code')
+ ->where('tbl_partner_facility.mfl_code', Auth::user()->facility_id);
+
+ if (!empty($selected_partners)) {
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest.max_period');
+ })->where('tbl_partner_facility.partner_id', $selected_partners)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $txcurr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $all_enrollment = NishauriFacility::select('*')->where('partner_id', $selected_partners);
+ $all_module = NishauriAccess::select('*')->where('partner_id', $selected_partners);
+ }
+ if (!empty($selected_counties)) {
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_con'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_con.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_con.max_period');
+ })->where('tbl_partner_facility.county_id', $selected_counties)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $txcurr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $all_enrollment = NishauriFacility::select('*')->where('county_id', $selected_counties);
+ $all_module = NishauriAccess::select('*')->where('county_id', $selected_counties);
+ }
+ if (!empty($selected_subcounties)) {
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_sub'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_sub.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_sub.max_period');
+ })
+ ->where('sub_county_id', $selected_subcounties)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $txcurr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $all_enrollment = NishauriFacility::select('*')->where('sub_county_id', $selected_subcounties);
+ $all_module = NishauriAccess::select('*')->where('sub_county_id', $selected_subcounties);
+ }
+ if (!empty($selected_facilites)) {
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_fac'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_fac.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_fac.max_period');
+ })
+ ->where('tbl_partner_facility.mfl_code', $selected_facilites)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $txcurr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $all_enrollment = NishauriFacility::select('*')->where('mfl_code', $selected_facilites);
+ $all_module = NishauriAccess::select('*')->where('mfl_code', $selected_facilites);
+ }
+ if (!empty($selected_from || $selected_to)) {
+
+ $selectedFrom = date('Ym', strtotime($request->from));
+ $selectedTo = date('Ym', strtotime($request->to));
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_date'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_date.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_date.max_period');
+ })
+ ->where(function ($query) use ($selectedFrom, $selectedTo) {
+ $query->whereRaw("SUBSTRING(tbl_tx_cur.period, 1, 6) >= ?", $selectedFrom)
+ ->whereRaw("SUBSTRING(tbl_tx_cur.period, 1, 6) <= ?", $selectedTo);
+ })
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $txcurr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $all_enrollment = NishauriFacility::select('*')->where('mfl_code', Auth::user()->facility_id)->where('enrolled_date', '>=', date($request->from))->where('enrolled_date', '<=', date($request->to));
+ $all_module = NishauriAccess::select('*')->where('mfl_code', Auth::user()->facility_id)->where('date', '>=', date($request->from))->where('date', '<=', date($request->to));
+ }
+
+
+ $data['txcurr'] = $txcurr;
+ $data['all_enrollment'] = $all_enrollment->get();
+ $data['all_module'] = $all_module->get();
+
+ return $data;
+ }
+ if (Auth::user()->access_level == 'Admin' || Auth::user()->access_level == 'Donor') {
+
+ $selected_partners = $request->partners;
+ $selected_counties = $request->counties;
+ $selected_subcounties = $request->subcounties;
+ $selected_facilites = $request->facilities;
+ $selected_from = $request->from;
+ $selected_to = $request->to;
+
+ $currentDate = Carbon::now();
+
+ $query = Txcurr::query()->join('tbl_partner_facility', 'tbl_tx_cur.mfl_code', '=', 'tbl_partner_facility.mfl_code');
+
+ if (!empty($selected_partners)) {
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest.max_period');
+ })->where('tbl_partner_facility.partner_id', $selected_partners)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $txcurr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $all_enrollment = NishauriUptake::select('*')->where('partner_id', $selected_partners);
+ $all_module = NishauriAccess::select('*')->where('partner_id', $selected_partners);
+ }
+ if (!empty($selected_counties)) {
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_con'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_con.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_con.max_period');
+ })->where('tbl_partner_facility.county_id', $selected_counties)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $txcurr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $all_enrollment = NishauriUptake::select('*')->where('county_id', $selected_counties);
+ $all_module = NishauriAccess::select('*')->where('county_id', $selected_counties);
+ }
+ if (!empty($selected_subcounties)) {
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_sub'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_sub.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_sub.max_period');
+ })
+ ->where('sub_county_id', $selected_subcounties)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $txcurr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $all_enrollment = NishauriUptake::select('*')->where('sub_county_id', $selected_subcounties);
+ $all_module = NishauriAccess::select('*')->where('sub_county_id', $selected_subcounties);
+ }
+ if (!empty($selected_facilites)) {
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_fac'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_fac.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_fac.max_period');
+ })
+ ->where('tbl_partner_facility.mfl_code', $selected_facilites)
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $txcurr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $all_enrollment = NishauriUptake::select('*')->where('mfl_code', $selected_facilites);
+ $all_module = NishauriAccess::select('*')->where('mfl_code', $selected_facilites);
+ }
+
+ if (!empty($selected_from || $selected_to)) {
+
+ $selectedFrom = date('Ym', strtotime($request->from));
+ $selectedTo = date('Ym', strtotime($request->to));
+ $query->join(DB::raw('(SELECT t1.mfl_code, MAX(t1.period) AS max_period
+ FROM tbl_tx_cur t1
+ GROUP BY t1.mfl_code) latest_date'), function ($join) {
+ $join->on('tbl_tx_cur.mfl_code', '=', 'latest_date.mfl_code')
+ ->on('tbl_tx_cur.period', '=', 'latest_date.max_period');
+ })
+ ->where(function ($query) use ($selectedFrom, $selectedTo) {
+ $query->whereRaw("SUBSTRING(tbl_tx_cur.period, 1, 6) >= ?", $selectedFrom)
+ ->whereRaw("SUBSTRING(tbl_tx_cur.period, 1, 6) <= ?", $selectedTo);
+ })
+ ->groupBy('tbl_tx_cur.mfl_code');
+ $txcurr = $query->selectRaw('SUM(tbl_tx_cur.tx_cur) as tx_cur')
+ ->get()
+ ->sum('tx_cur');
+ $all_enrollment = NishauriUptake::select('*')->where('enrolled_date', '>=', date($request->from))->where('enrolled_date', '<=', date($request->to));
+ $all_module = NishauriAccess::select('*')->where('date', '>=', date($request->from))->where('date', '<=', date($request->to));
+ }
+
+
+ $data['txcurr'] = $txcurr;
+ $data['all_enrollment'] = $all_enrollment->get()->map(function ($item) {
+ $item['no_of_clients'] = (int)$item['no_of_clients'];
+ return $item;
+ });
+ $data['all_module'] = $all_module->get();
+
+ return $data;
+ }
+ }
+
+ public function drug_delivery_list()
+ {
+ if (Auth::user()->access_level == 'Facility') {
+
+ $drug_delivery = NishauriDrugDelivery::select('tbl_nishauri_drug_order.id as order_id', 'tbl_appointment.appntmnt_date', 'tbl_client.clinic_number', 'tbl_nishauri_drug_order.mode', 'tbl_nishauri_drug_order.delivery_method', 'tbl_nishauri_drug_order.delivery_person', 'tbl_nishauri_drug_order.delivery_person_contact', 'tbl_nishauri_drug_order.delivery_pickup_time', 'tbl_nishauri_drug_order.status', 'tbl_nishauri_drug_order.appointment_id', 'tbl_nishauri_drug_order.client_phone_no')
+ ->leftJoin('tbl_appointment', 'tbl_appointment.id', '=', 'tbl_nishauri_drug_order.appointment_id')
+ ->leftJoin('tbl_client', 'tbl_client.id', '=', 'tbl_nishauri_drug_order.program_identifier')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->where('tbl_nishauri_drug_order.status', '=', 'Pending')
+ ->get();
+ $drug_dispatch = NishauriDrugDelivery::select('tbl_nishauri_drug_order.id as order_id', 'tbl_appointment.appntmnt_date', 'tbl_client.clinic_number', 'tbl_nishauri_drug_order.mode', 'tbl_nishauri_drug_order.delivery_method', 'tbl_nishauri_drug_order.delivery_person', 'tbl_nishauri_drug_order.delivery_person_contact', 'tbl_nishauri_drug_order.delivery_pickup_time', 'tbl_nishauri_drug_order.status', 'tbl_nishauri_drug_order.appointment_id', 'tbl_nishauri_drug_order.client_phone_no')
+ ->leftJoin('tbl_appointment', 'tbl_appointment.id', '=', 'tbl_nishauri_drug_order.appointment_id')
+ ->leftJoin('tbl_client', 'tbl_client.id', '=', 'tbl_nishauri_drug_order.program_identifier')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->where('tbl_nishauri_drug_order.status', '=', 'Approved')
+ ->get();
+
+ $drug_fullfilled = NishauriDrugDelivery::select('tbl_nishauri_drug_order.id as order_id', 'tbl_appointment.appntmnt_date', 'tbl_client.clinic_number', 'tbl_nishauri_drug_order.mode', 'tbl_nishauri_drug_order.delivery_method', 'tbl_nishauri_drug_order.delivery_person', 'tbl_nishauri_drug_order.delivery_person_contact', 'tbl_nishauri_drug_order.delivery_pickup_time', 'tbl_nishauri_drug_order.status', 'tbl_nishauri_drug_order.appointment_id', 'tbl_nishauri_drug_order.comment')
+ ->leftJoin('tbl_appointment', 'tbl_appointment.id', '=', 'tbl_nishauri_drug_order.appointment_id')
+ ->leftJoin('tbl_client', 'tbl_client.id', '=', 'tbl_nishauri_drug_order.program_identifier')
+ ->where('tbl_client.mfl_code', Auth::user()->facility_id)
+ ->where('tbl_nishauri_drug_order.status', '=', 'Fullfilled')
+ ->get();
+
+ return view('nishauri.drug_delivery', compact('drug_delivery', 'drug_dispatch', 'drug_fullfilled'));
+ }
+ }
+
+ public function delivery_approval(Request $request)
+ {
+ try {
+ $client = NishauriDrugDelivery::where('appointment_id', $request->appointment_id)
+ ->update([
+ 'status' => 'Approved',
+ 'updated_at' => now(),
+ 'approved_date' => now()
+ ]);
+
+ // dd( $client);
+ if ($client) {
+ NishauriDrugOrder::create([
+ 'order_id' => $request->order_id,
+ 'initiated_by' => Auth::user()->id,
+ ]);
+ Alert::success('Success', 'Delivery Successfully Approved');
+ return redirect('delivery/list');
+ } else {
+ Alert::error('Failed', 'Could not approve please try again later.');
+ return back();
+ }
+ } catch (Exception $e) {
+ }
+ }
+
+ public function delivery_dispatch(Request $request)
+ {
+ try {
+ $order = $request->order_id;
+ $order_no = 'ORN' . sprintf('%03d', $order);
+
+ $client = NishauriDrugDelivery::where('appointment_id', $request->appointment_id)
+ ->update([
+ 'status' => 'Dispatched',
+ 'updated_at' => date('Y-m-d H:i:s'),
+ 'dispatched_date' => date('Y-m-d H:i:s'),
+ 'confirmation_code' => $order_no
+ ]);
+
+ // dd( $client);
+ if ($client) {
+ NishauriDrugOrder::where('order_id', $request->order_id)
+ ->update([
+ 'initiated_by' => Auth::user()->id,
+ 'dispatch_notes' => $request->dispatch_notes,
+ 'updated_at' => date('Y-m-d H:i:s')
+ ]);
+
+ // Send SMS notification
+ $destination = $request->client_phone_no;
+ $msg = "Your drugs for order No $order_no has been dispatched. Kindly use your order number provided for confirmation once you received the drugs";
+ $source = 40149;
+ $this->send_message($source, $destination, $msg);
+ Alert::success('Success', 'Delivery Successfully Dispatched');
+ return redirect('delivery/list');
+ } else {
+ Alert::error('Failed', 'Could not dispatch please try again later.');
+ return back();
+ }
+ } catch (Exception $e) {
+ }
+ }
+}
diff --git a/app/Http/Controllers/PartnerController.php b/app/Http/Controllers/PartnerController.php
index 11d8e30..532aa32 100644
--- a/app/Http/Controllers/PartnerController.php
+++ b/app/Http/Controllers/PartnerController.php
@@ -7,35 +7,58 @@
use App\Models\PartnerType;
use Session;
use Exception;
+use Auth;
+use RealRashid\SweetAlert\Facades\Alert;
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;
@@ -46,13 +69,12 @@ public function addpartner(Request $request)
$partner->status = $request->status;
if ($partner->save()) {
- Session::flash('statuscode', 'success');
-
- return redirect('admin/partners')->with('status', 'Partner has been saved successfully!');
+ Alert::success('Success', 'Partner has been saved successfully!');
+ return redirect('admin/partners');
} else {
- Session::flash('statuscode', 'error');
- return back()->with('error', 'An error has occurred please try again later.');
+ Alert::error('Failed', 'An error has occurred please try again later.');
+ return back();
}
} catch (Exception $e) {
return back();
@@ -72,11 +94,11 @@ public function editpartner(Request $request)
'location' => $request->location,
]);
if ($partner) {
- Session::flash('statuscode', 'success');
- return redirect('admin/partners')->with('status', 'Partner was successfully Updated in the system!');
+ Alert::success('Success', 'Partner was successfully Updated in the system!');
+ return redirect('admin/partners');
} else {
- Session::flash('statuscode', 'error');
- return back()->with('error', 'Could not update partner please try again later.');
+ Alert::error('Failed', 'Could not update partner please try again later.');
+ return back();
}
} catch (Exception $e) {
return back();
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/ReceiverController.php b/app/Http/Controllers/ReceiverController.php
new file mode 100644
index 0000000..a67baf9
--- /dev/null
+++ b/app/Http/Controllers/ReceiverController.php
@@ -0,0 +1,76 @@
+to == '40149') {
+
+ // dd($request->all());
+
+ $inbox = new UshauriInbox;
+
+ $inbox->destination = $request->to;
+ $inbox->source = $request->from;
+ $inbox->msg = $request->text;
+ $inbox->receivedtime = $request->date;
+ $inbox->reference = $request->id;
+ $inbox->LinkId = $request->linkId;
+
+ $inbox->save();
+
+ $lastID1 = $inbox->id;
+ $task = 1;
+ $this->task($task, $lastID1);
+ }
+ }
+
+ function task($task, $LastInsertId)
+ {
+ Log::info("ID: " . $LastInsertId . ", TASK: " . $task);
+ switch ($task) {
+ case 1:
+
+ $ch = curl_init();
+
+ curl_setopt($ch, CURLOPT_URL, "http://ushaurinode.localhost/receiver/$LastInsertId");
+ curl_setopt($ch, CURLOPT_HEADER, 0);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+ curl_exec($ch);
+
+ curl_close($ch);
+ echo 'Done task 1';
+ break;
+ default:
+ break;
+ }
+ }
+
+ public function ushauri_callback(Request $request)
+ {
+
+ //check incoming id and update single sms with telco status
+
+ $updateDetails = [
+ 'callback_status' => $request->get('status'),
+ 'failure_reason' => $request->get('failureReason')
+ ];
+
+ // return $request;
+
+ $sms = UshauriOutbox::where('message_id', $request->id)->first();
+ if ($sms) {
+ $sms = UshauriOutbox::where('message_id', $request->id)
+ ->update($updateDetails);
+ }
+ }
+}
diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php
index f36e4a1..481eee6 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,47 @@ 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')
- ->where('tbl_client.smsenable', '=', 'Yes')
+ $consented_clients = Client::leftJoin('tbl_groups', 'tbl_groups.id', 'tbl_client.group_id')
+ ->leftJoin(DB::raw('(SELECT client_id, DATE(created_at) AS created_at
+ FROM tbl_appointment a1
+ WHERE a1.id = (SELECT MAX(a2.id) FROM tbl_appointment a2 WHERE a2.client_id = a1.client_id)
+ AND a1.consented = "YES") a'), 'tbl_client.id', '=', 'a.client_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', DB::raw('CASE WHEN tbl_client.smsenable="Yes" THEN "Yes" WHEN a.client_id IS NOT NULL THEN
+ "Yes" ELSE "No" END as smsenable'), 'tbl_client.enrollment_date', 'tbl_client.art_date', 'tbl_client.updated_at', 'tbl_client.status', 'tbl_client.consent_date')
+ ->whereNull('tbl_client.hei_no')
->where('tbl_client.mfl_code', Auth::user()->facility_id)
- ->get();
+ ->paginate(15000);
}
if (Auth::user()->access_level == 'Partner') {
$all_partners = Partner::where('status', '=', 'Active')
- ->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')
+ ->pluck('name', 'id');
+ $consented_clients = Client::leftJoin('tbl_groups', 'tbl_groups.id', 'tbl_client.group_id')
+ ->leftJoin(DB::raw('(SELECT client_id, DATE(created_at) AS created_at
+ FROM tbl_appointment a1
+ WHERE a1.id = (SELECT MAX(a2.id) FROM tbl_appointment a2 WHERE a2.client_id = a1.client_id)
+ AND a1.consented = "YES") a'), 'tbl_client.id', '=', 'a.client_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', DB::raw('CASE WHEN tbl_client.smsenable="Yes" THEN "Yes" WHEN a.client_id IS NOT NULL THEN
+ "Yes" ELSE "No" END as smsenable'), 'tbl_client.enrollment_date', 'tbl_client.art_date', 'tbl_client.updated_at', 'tbl_client.status', 'tbl_client.consent_date')
+ ->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 +179,163 @@ 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 == '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') {
+
+ $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(
- '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)
+
+ $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');
+ // dd($outcome_report);
+ return view('reports.outcome', compact('outcome_report', 'all_partners', 'selected_from', 'selected_to'));
+ }
+
+ public function tracing_attempts(Request $request)
+ {
+ $selected_from = $request->date_from;
+ $selected_to = $request->date_to;
+
+ if (Auth::user()->access_level == 'Facility') {
+ $tracing_attempts = OutcomeReport::select('UPN', 'MFL', 'Facility', 'Appointment_Date', 'Tracing_Date', 'Tracer', 'Outcome', 'Final_Outcome', 'tracing_type', DB::raw('COUNT(Outcome) AS attempts'))
+ ->where('mfl_code', Auth::user()->facility_id)
+ ->where('Appointment_Date', '>=', date($request->date_from))
+ ->where('Appointment_Date', '<=', date($request->date_to))
+ ->groupBy('Appointment_ID', 'Outcome', 'Final_Outcome')
+ ->get();
+
+ return view('reports.attempts_tracing', compact('tracing_attempts'));
+ }
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'
- )
+ $tracing_attempts = OutcomeReport::select('UPN', 'MFL', 'Facility', 'Sub_County', 'County', 'Appointment_Date', 'Outcome', 'Final_Outcome', 'tracing_type', DB::raw('COUNT(Appointment_ID) AS attempts'))
->where('partner_id', Auth::user()->partner_id)
+ ->where('Appointment_Date', '>=', date($request->date_from))
+ ->where('Appointment_Date', '<=', date($request->date_to))
+ ->groupBy('tracing_type', 'Appointment_Date', 'Outcome', 'Final_Outcome')
->get();
- }
+ return view('reports.attempts_tracing', compact('tracing_attempts'));
+ }
- return view('reports.outcome', compact('outcome_report', 'all_partners'));
+ //dd($tracing_attempts);
+ }
+ public function tracing_attempts_form()
+ {
+ return view('reports.attempts_form');
}
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 +352,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 +378,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 +428,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 +453,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 +462,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..5d5803e
--- /dev/null
+++ b/app/Http/Controllers/ScheduleSMSController.php
@@ -0,0 +1,686 @@
+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 resend() //resend all outgoing sms that were not sent during normal scheduling
+ {
+ $messages = UnsentSMS::all();
+ foreach($messages as $message)
+ {
+ $clnt_outgoing_id = $message->id;
+ $destination = $message->destination;
+ $msg = $message->msg;
+ $source = $message->source;
+
+ //call sms service
+ $result = $this->send_message($source,$destination,$clnt_outgoing_id,$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();
+
+ }
+ }
+ }
+
+ 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('DATE(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,$clnt_outgoing_id,$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,$sender_id, $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' => $sender_id,
+ '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..4d651fc 100644
--- a/app/Http/Controllers/TracerController.php
+++ b/app/Http/Controllers/TracerController.php
@@ -8,9 +8,11 @@
use App\Models\Outcome;
use App\Models\Appointments;
use App\Models\FutureApp;
+use App\Models\Clinic;
use Session;
use Auth;
use DB;
+use RealRashid\SweetAlert\Facades\Alert;
class TracerController extends Controller
{
@@ -53,12 +55,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 +92,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();
@@ -121,11 +124,11 @@ public function assign_client(Request $request)
$tracer->created_by = Auth::user()->id;
if ($tracer->save()) {
- Session::flash('statuscode', 'success');
- return redirect('clients/booked')->with('status', 'Client was successfully Assigned to a Tracer!');
+ Alert::success('Success', 'Client was successfully Assigned to a Tracer!');
+ return redirect('clients/booked');
} else {
- Session::flash('statuscode', 'error');
- return back()->with('error', 'Could not assign client please try again later.');
+ Alert::error('Failed', 'Could not assign client please try again later.');
+ return back();
}
} catch (Exception $e) {
return back();
diff --git a/app/Http/Controllers/TxCurrController.php b/app/Http/Controllers/TxCurrController.php
new file mode 100644
index 0000000..2af096c
--- /dev/null
+++ b/app/Http/Controllers/TxCurrController.php
@@ -0,0 +1,45 @@
+withOptions(['verify' => false])->get("https://hiskenya.org/api/analytics?dimension=ou:LEVEL-5;&dimension=dx:PUrg2dmCjGI;&dimension=pe:$period&displayProperty=NAME&showHierarchy=true&tableLayout=true&columns=dx;pe&rows=ou&hideEmptyRows=true&paging=false");
+
+ $response_data = $response->json();
+ if (array_key_exists('rows', $response_data)) {
+ foreach($response_data['rows'] as $data)
+ {
+ $tx_curr = Txcurr::updateOrCreate(
+ ['period' => $period,'mfl_code' => $data[7]],
+ ['tx_cur' => $data[9] == '' ? 0 : $data[9]]
+ );
+ }
+ return response()->json(['status' =>"success",'message'=>"Tx Curr for period $period fetched successfully."]);
+ } else{
+ return response()->json(['status' =>"error",'message'=>"No data found for period $period."]);
+ }
+ // }
+ // }
+
+
+
+ }
+}
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..eca833d 100644
--- a/app/Http/Controllers/UserController.php
+++ b/app/Http/Controllers/UserController.php
@@ -16,35 +16,211 @@
use App\Models\PartnerFacility;
use Auth;
use DB;
-use Session;
+//use Session;
+use RealRashid\SweetAlert\Facades\Alert;
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',
+ 'tbl_users.partner_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 +228,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 +261,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')
@@ -166,14 +355,14 @@ public function adduser(Request $request)
->first();
if ($validate) {
- Session::flash('statuscode', 'error');
+ Alert::error('Failed', 'Phone Number is already used in the system!');
- return redirect('admin/users/form')->with('status', 'Phone Number is already used in the system!');
+ return redirect('admin/users/form');
}
if ($validate_email) {
- Session::flash('statuscode', 'error');
+ Alert::error('Failed', 'Email is already used in the system!');
- return redirect('admin/users/form')->with('status', 'Email is already used in the system!');
+ return redirect('admin/users/form');
}
$user->f_name = $request->fname;
@@ -209,7 +398,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;
@@ -226,12 +415,12 @@ public function adduser(Request $request)
if ($user->save()) {
- Session::flash('statuscode', 'success');
+ Alert::success('Success', 'User has been saved successfully!');
- return redirect('admin/users')->with('status', 'User has been saved successfully!');
+ return redirect('admin/users');
} else {
- Session::flash('statuscode', 'error');
- return back()->with('error', 'An error has occurred please try again later.');
+ Alert::error('Failed', 'An error has occurred please try again later.');
+ return back();
}
} catch (Exception $e) {
toastr()->error('An error has occurred please try again later.');
@@ -267,14 +456,15 @@ 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');
- return redirect('admin/users')->with('status', 'User was successfully Updated in the system!');
+ Alert::success('Success', 'User was successfully Updated in the system!');
+ return redirect('admin/users');
} else {
- Session::flash('statuscode', 'error');
- return back()->with('error', 'Could not update user please try again later.');
+ Alert::error('Failed', 'Could not update user please try again later.');
+ return back();
}
} catch (Exception $e) {
return back();
@@ -291,16 +481,15 @@ public function resetuser(Request $request)
$user->updated_by = Auth::user()->id;
if ($user->save()) {
- Session::flash('statuscode', 'success');
- return redirect('admin/users')->with('status', 'User has been reset successfull');
-
+ Alert::success('Success', 'User has been reset successfull');
+ return redirect('admin/users');
} else {
- Session::flash('statuscode', 'error');
- return redirect('admin/users')->with('status', 'An error has occurred please try again later');
+ Alert::error('Failed', 'An error has occurred please try again later');
+ return redirect('admin/users');
}
} catch (Exception $e) {
- Session::flash('statuscode', 'error');
- return redirect('admin/users')->with('status', 'An error has occurred please try again later');
+ Alert::error('Failed', 'An error has occurred please try again later');
+ return redirect('admin/users');
}
}
@@ -322,17 +511,15 @@ public function changepass(Request $request)
$user->first_access = 'No';
if ($user->save()) {
- Session::flash('statuscode', 'success');
- return redirect('/')->with('status', 'Password has been changed successfully!');
+ Alert::success('Success', 'Password has been changed successfully!');
+ return redirect('/');
} else {
-
- Session::flash('statuscode', 'error');
- return back()->with('error', 'An error has occurred please try again later.');
+ Alert::error('Failed', 'An error has occurred please try again later.');
+ return back();
}
} catch (Exception $e) {
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/ClientDashboard.php b/app/Models/ClientDashboard.php
new file mode 100644
index 0000000..370ad73
--- /dev/null
+++ b/app/Models/ClientDashboard.php
@@ -0,0 +1,16 @@
+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/UshauriInbox.php b/app/Models/UshauriInbox.php
new file mode 100644
index 0000000..cf4cdfa
--- /dev/null
+++ b/app/Models/UshauriInbox.php
@@ -0,0 +1,18 @@
+=7.2.5"
- },
- "type": "package",
- "extra": {
- "laravel": {
- "providers": [
- "Acaronlex\\LaravelCalendar\\ServiceProvider"
- ],
- "aliases": {
- "Calendar": "Acaronlex\\LaravelCalendar\\Facades\\Calendar"
- }
- }
- },
- "autoload": {
- "psr-4": {
- "Acaronlex\\LaravelCalendar\\": "src"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "acaronlex",
- "email": "acaronlex@outlook.com"
- }
- ],
- "description": "Laravel helper for FullCalendar.io",
- "time": "2021-01-18T21:34:10+00:00"
- },
{
"name": "africastalking/africastalking",
"version": "v3.0.0",
@@ -103,35 +56,39 @@
"ussd",
"voice"
],
+ "support": {
+ "issues": "https://github.com/AfricasTalkingLtd/africastalking-php/issues",
+ "source": "https://github.com/AfricasTalkingLtd/africastalking-php/tree/v3.0.0"
+ },
"time": "2020-10-11T00:52:15+00:00"
},
{
"name": "asm89/stack-cors",
- "version": "v2.0.3",
+ "version": "v2.1.1",
"source": {
"type": "git",
"url": "https://github.com/asm89/stack-cors.git",
- "reference": "9cb795bf30988e8c96dd3c40623c48a877bc6714"
+ "reference": "73e5b88775c64ccc0b84fb60836b30dc9d92ac4a"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/asm89/stack-cors/zipball/9cb795bf30988e8c96dd3c40623c48a877bc6714",
- "reference": "9cb795bf30988e8c96dd3c40623c48a877bc6714",
+ "url": "https://api.github.com/repos/asm89/stack-cors/zipball/73e5b88775c64ccc0b84fb60836b30dc9d92ac4a",
+ "reference": "73e5b88775c64ccc0b84fb60836b30dc9d92ac4a",
"shasum": ""
},
"require": {
- "php": "^7.0|^8.0",
- "symfony/http-foundation": "~2.7|~3.0|~4.0|~5.0",
- "symfony/http-kernel": "~2.7|~3.0|~4.0|~5.0"
+ "php": "^7.2|^8.0",
+ "symfony/http-foundation": "^4|^5|^6",
+ "symfony/http-kernel": "^4|^5|^6"
},
"require-dev": {
- "phpunit/phpunit": "^6|^7|^8|^9",
+ "phpunit/phpunit": "^7|^9",
"squizlabs/php_codesniffer": "^3.5"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.0-dev"
+ "dev-master": "2.1-dev"
}
},
"autoload": {
@@ -155,20 +112,24 @@
"cors",
"stack"
],
- "time": "2021-03-11T06:42:03+00:00"
+ "support": {
+ "issues": "https://github.com/asm89/stack-cors/issues",
+ "source": "https://github.com/asm89/stack-cors/tree/v2.1.1"
+ },
+ "time": "2022-01-18T09:12:03+00:00"
},
{
"name": "brick/math",
- "version": "0.9.2",
+ "version": "0.9.3",
"source": {
"type": "git",
"url": "https://github.com/brick/math.git",
- "reference": "dff976c2f3487d42c1db75a3b180e2b9f0e72ce0"
+ "reference": "ca57d18f028f84f777b2168cd1911b0dee2343ae"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/brick/math/zipball/dff976c2f3487d42c1db75a3b180e2b9f0e72ce0",
- "reference": "dff976c2f3487d42c1db75a3b180e2b9f0e72ce0",
+ "url": "https://api.github.com/repos/brick/math/zipball/ca57d18f028f84f777b2168cd1911b0dee2343ae",
+ "reference": "ca57d18f028f84f777b2168cd1911b0dee2343ae",
"shasum": ""
},
"require": {
@@ -178,7 +139,7 @@
"require-dev": {
"php-coveralls/php-coveralls": "^2.2",
"phpunit/phpunit": "^7.5.15 || ^8.5 || ^9.0",
- "vimeo/psalm": "4.3.2"
+ "vimeo/psalm": "4.9.2"
},
"type": "library",
"autoload": {
@@ -201,38 +162,204 @@
"brick",
"math"
],
- "time": "2021-01-20T22:51:39+00:00"
+ "support": {
+ "issues": "https://github.com/brick/math/issues",
+ "source": "https://github.com/brick/math/tree/0.9.3"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/BenMorel",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/brick/math",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2021-08-15T20:50:18+00:00"
},
{
- "name": "doctrine/inflector",
- "version": "2.0.3",
+ "name": "composer/semver",
+ "version": "3.3.2",
"source": {
"type": "git",
- "url": "https://github.com/doctrine/inflector.git",
- "reference": "9cf661f4eb38f7c881cac67c75ea9b00bf97b210"
+ "url": "https://github.com/composer/semver.git",
+ "reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/doctrine/inflector/zipball/9cf661f4eb38f7c881cac67c75ea9b00bf97b210",
- "reference": "9cf661f4eb38f7c881cac67c75ea9b00bf97b210",
+ "url": "https://api.github.com/repos/composer/semver/zipball/3953f23262f2bff1919fc82183ad9acb13ff62c9",
+ "reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9",
"shasum": ""
},
"require": {
- "php": "^7.2 || ^8.0"
+ "php": "^5.3.2 || ^7.0 || ^8.0"
},
"require-dev": {
- "doctrine/coding-standard": "^7.0",
- "phpstan/phpstan": "^0.11",
- "phpstan/phpstan-phpunit": "^0.11",
- "phpstan/phpstan-strict-rules": "^0.11",
- "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0"
+ "phpstan/phpstan": "^1.4",
+ "symfony/phpunit-bridge": "^4.2 || ^5"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.0.x-dev"
+ "dev-main": "3.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Composer\\Semver\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nils Adermann",
+ "email": "naderman@naderman.de",
+ "homepage": "http://www.naderman.de"
+ },
+ {
+ "name": "Jordi Boggiano",
+ "email": "j.boggiano@seld.be",
+ "homepage": "http://seld.be"
+ },
+ {
+ "name": "Rob Bast",
+ "email": "rob.bast@gmail.com",
+ "homepage": "http://robbast.nl"
+ }
+ ],
+ "description": "Semver library that offers utilities, version constraint parsing and validation.",
+ "keywords": [
+ "semantic",
+ "semver",
+ "validation",
+ "versioning"
+ ],
+ "support": {
+ "irc": "irc://irc.freenode.org/composer",
+ "issues": "https://github.com/composer/semver/issues",
+ "source": "https://github.com/composer/semver/tree/3.3.2"
+ },
+ "funding": [
+ {
+ "url": "https://packagist.com",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/composer",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/composer/composer",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-04-01T19:23:25+00:00"
+ },
+ {
+ "name": "dflydev/dot-access-data",
+ "version": "v3.0.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/dflydev/dflydev-dot-access-data.git",
+ "reference": "f41715465d65213d644d3141a6a93081be5d3549"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/dflydev/dflydev-dot-access-data/zipball/f41715465d65213d644d3141a6a93081be5d3549",
+ "reference": "f41715465d65213d644d3141a6a93081be5d3549",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.1 || ^8.0"
+ },
+ "require-dev": {
+ "phpstan/phpstan": "^0.12.42",
+ "phpunit/phpunit": "^7.5 || ^8.5 || ^9.3",
+ "scrutinizer/ocular": "1.6.0",
+ "squizlabs/php_codesniffer": "^3.5",
+ "vimeo/psalm": "^4.0.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "3.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Dflydev\\DotAccessData\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Dragonfly Development Inc.",
+ "email": "info@dflydev.com",
+ "homepage": "http://dflydev.com"
+ },
+ {
+ "name": "Beau Simensen",
+ "email": "beau@dflydev.com",
+ "homepage": "http://beausimensen.com"
+ },
+ {
+ "name": "Carlos Frutos",
+ "email": "carlos@kiwing.it",
+ "homepage": "https://github.com/cfrutos"
+ },
+ {
+ "name": "Colin O'Dell",
+ "email": "colinodell@gmail.com",
+ "homepage": "https://www.colinodell.com"
}
+ ],
+ "description": "Given a deep data structure, access data by dot notation.",
+ "homepage": "https://github.com/dflydev/dflydev-dot-access-data",
+ "keywords": [
+ "access",
+ "data",
+ "dot",
+ "notation"
+ ],
+ "support": {
+ "issues": "https://github.com/dflydev/dflydev-dot-access-data/issues",
+ "source": "https://github.com/dflydev/dflydev-dot-access-data/tree/v3.0.2"
+ },
+ "time": "2022-10-27T11:44:00+00:00"
+ },
+ {
+ "name": "doctrine/inflector",
+ "version": "2.0.6",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/doctrine/inflector.git",
+ "reference": "d9d313a36c872fd6ee06d9a6cbcf713eaa40f024"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/doctrine/inflector/zipball/d9d313a36c872fd6ee06d9a6cbcf713eaa40f024",
+ "reference": "d9d313a36c872fd6ee06d9a6cbcf713eaa40f024",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.2 || ^8.0"
+ },
+ "require-dev": {
+ "doctrine/coding-standard": "^10",
+ "phpstan/phpstan": "^1.8",
+ "phpstan/phpstan-phpunit": "^1.1",
+ "phpstan/phpstan-strict-rules": "^1.3",
+ "phpunit/phpunit": "^8.5 || ^9.5",
+ "vimeo/psalm": "^4.25"
},
+ "type": "library",
"autoload": {
"psr-4": {
"Doctrine\\Inflector\\": "lib/Doctrine/Inflector"
@@ -278,36 +405,50 @@
"uppercase",
"words"
],
- "time": "2020-05-29T15:13:26+00:00"
+ "support": {
+ "issues": "https://github.com/doctrine/inflector/issues",
+ "source": "https://github.com/doctrine/inflector/tree/2.0.6"
+ },
+ "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%2Finflector",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-10-20T09:10:12+00:00"
},
{
"name": "doctrine/lexer",
- "version": "1.2.1",
+ "version": "1.2.3",
"source": {
"type": "git",
"url": "https://github.com/doctrine/lexer.git",
- "reference": "e864bbf5904cb8f5bb334f99209b48018522f042"
+ "reference": "c268e882d4dbdd85e36e4ad69e02dc284f89d229"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/doctrine/lexer/zipball/e864bbf5904cb8f5bb334f99209b48018522f042",
- "reference": "e864bbf5904cb8f5bb334f99209b48018522f042",
+ "url": "https://api.github.com/repos/doctrine/lexer/zipball/c268e882d4dbdd85e36e4ad69e02dc284f89d229",
+ "reference": "c268e882d4dbdd85e36e4ad69e02dc284f89d229",
"shasum": ""
},
"require": {
- "php": "^7.2 || ^8.0"
+ "php": "^7.1 || ^8.0"
},
"require-dev": {
- "doctrine/coding-standard": "^6.0",
- "phpstan/phpstan": "^0.11.8",
- "phpunit/phpunit": "^8.2"
+ "doctrine/coding-standard": "^9.0",
+ "phpstan/phpstan": "^1.3",
+ "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
+ "vimeo/psalm": "^4.11"
},
"type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.2.x-dev"
- }
- },
"autoload": {
"psr-4": {
"Doctrine\\Common\\Lexer\\": "lib/Doctrine/Common/Lexer"
@@ -340,33 +481,51 @@
"parser",
"php"
],
- "time": "2020-05-25T17:44:05+00:00"
+ "support": {
+ "issues": "https://github.com/doctrine/lexer/issues",
+ "source": "https://github.com/doctrine/lexer/tree/1.2.3"
+ },
+ "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%2Flexer",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-02-28T11:07:21+00:00"
},
{
"name": "dragonmantank/cron-expression",
- "version": "v3.1.0",
+ "version": "v3.3.2",
"source": {
"type": "git",
"url": "https://github.com/dragonmantank/cron-expression.git",
- "reference": "7a8c6e56ab3ffcc538d05e8155bb42269abf1a0c"
+ "reference": "782ca5968ab8b954773518e9e49a6f892a34b2a8"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/dragonmantank/cron-expression/zipball/7a8c6e56ab3ffcc538d05e8155bb42269abf1a0c",
- "reference": "7a8c6e56ab3ffcc538d05e8155bb42269abf1a0c",
+ "url": "https://api.github.com/repos/dragonmantank/cron-expression/zipball/782ca5968ab8b954773518e9e49a6f892a34b2a8",
+ "reference": "782ca5968ab8b954773518e9e49a6f892a34b2a8",
"shasum": ""
},
"require": {
"php": "^7.2|^8.0",
- "webmozart/assert": "^1.7.0"
+ "webmozart/assert": "^1.0"
},
"replace": {
"mtdowling/cron-expression": "^1.0"
},
"require-dev": {
"phpstan/extension-installer": "^1.0",
- "phpstan/phpstan": "^0.12",
- "phpstan/phpstan-webmozart-assert": "^0.12.7",
+ "phpstan/phpstan": "^1.0",
+ "phpstan/phpstan-webmozart-assert": "^1.0",
"phpunit/phpunit": "^7.0|^8.0|^9.0"
},
"type": "library",
@@ -391,7 +550,17 @@
"cron",
"schedule"
],
- "time": "2020-11-24T19:55:57+00:00"
+ "support": {
+ "issues": "https://github.com/dragonmantank/cron-expression/issues",
+ "source": "https://github.com/dragonmantank/cron-expression/tree/v3.3.2"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/dragonmantank",
+ "type": "github"
+ }
+ ],
+ "time": "2022-09-10T18:51:20+00:00"
},
{
"name": "egulias/email-validator",
@@ -449,36 +618,53 @@
"validation",
"validator"
],
+ "support": {
+ "issues": "https://github.com/egulias/EmailValidator/issues",
+ "source": "https://github.com/egulias/EmailValidator/tree/2.1.25"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/egulias",
+ "type": "github"
+ }
+ ],
"time": "2020-12-29T14:50:06+00:00"
},
{
"name": "ezyang/htmlpurifier",
- "version": "v4.13.0",
+ "version": "v4.16.0",
"source": {
"type": "git",
"url": "https://github.com/ezyang/htmlpurifier.git",
- "reference": "08e27c97e4c6ed02f37c5b2b20488046c8d90d75"
+ "reference": "523407fb06eb9e5f3d59889b3978d5bfe94299c8"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/08e27c97e4c6ed02f37c5b2b20488046c8d90d75",
- "reference": "08e27c97e4c6ed02f37c5b2b20488046c8d90d75",
+ "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/523407fb06eb9e5f3d59889b3978d5bfe94299c8",
+ "reference": "523407fb06eb9e5f3d59889b3978d5bfe94299c8",
"shasum": ""
},
"require": {
- "php": ">=5.2"
+ "php": "~5.6.0 || ~7.0.0 || ~7.1.0 || ~7.2.0 || ~7.3.0 || ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0"
},
"require-dev": {
- "simpletest/simpletest": "dev-master#72de02a7b80c6bb8864ef9bf66d41d2f58f826bd"
+ "cerdic/css-tidy": "^1.7 || ^2.0",
+ "simpletest/simpletest": "dev-master"
+ },
+ "suggest": {
+ "cerdic/css-tidy": "If you want to use the filter 'Filter.ExtractStyleBlocks'.",
+ "ext-bcmath": "Used for unit conversion and imagecrash protection",
+ "ext-iconv": "Converts text to and from non-UTF-8 encodings",
+ "ext-tidy": "Used for pretty-printing HTML"
},
"type": "library",
"autoload": {
- "psr-0": {
- "HTMLPurifier": "library/"
- },
"files": [
"library/HTMLPurifier.composer.php"
],
+ "psr-0": {
+ "HTMLPurifier": "library/"
+ },
"exclude-from-classmap": [
"/library/HTMLPurifier/Language/"
]
@@ -499,20 +685,24 @@
"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.16.0"
+ },
+ "time": "2022-09-18T07:06:19+00:00"
},
{
"name": "fideloper/proxy",
- "version": "4.4.1",
+ "version": "4.4.2",
"source": {
"type": "git",
"url": "https://github.com/fideloper/TrustedProxy.git",
- "reference": "c073b2bd04d1c90e04dc1b787662b558dd65ade0"
+ "reference": "a751f2bc86dd8e6cfef12dc0cbdada82f5a18750"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/fideloper/TrustedProxy/zipball/c073b2bd04d1c90e04dc1b787662b558dd65ade0",
- "reference": "c073b2bd04d1c90e04dc1b787662b558dd65ade0",
+ "url": "https://api.github.com/repos/fideloper/TrustedProxy/zipball/a751f2bc86dd8e6cfef12dc0cbdada82f5a18750",
+ "reference": "a751f2bc86dd8e6cfef12dc0cbdada82f5a18750",
"shasum": ""
},
"require": {
@@ -522,7 +712,7 @@
"require-dev": {
"illuminate/http": "^5.0|^6.0|^7.0|^8.0|^9.0",
"mockery/mockery": "^1.0",
- "phpunit/phpunit": "^6.0"
+ "phpunit/phpunit": "^8.5.8|^9.3.3"
},
"type": "library",
"extra": {
@@ -553,32 +743,34 @@
"proxy",
"trusted proxy"
],
- "time": "2020-10-22T13:48:01+00:00"
+ "support": {
+ "issues": "https://github.com/fideloper/TrustedProxy/issues",
+ "source": "https://github.com/fideloper/TrustedProxy/tree/4.4.2"
+ },
+ "time": "2022-02-09T13:33:34+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 +778,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.0-dev"
+ "dev-master": "2.1-dev"
},
"laravel": {
"providers": [
@@ -620,35 +812,45 @@
"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"
+ }
+ ],
+ "abandoned": true,
+ "time": "2022-02-23T14:25:13+00:00"
},
{
"name": "graham-campbell/result-type",
- "version": "v1.0.1",
+ "version": "v1.1.1",
"source": {
"type": "git",
"url": "https://github.com/GrahamCampbell/Result-Type.git",
- "reference": "7e279d2cd5d7fbb156ce46daada972355cea27bb"
+ "reference": "672eff8cf1d6fe1ef09ca0f89c4b287d6a3eb831"
},
"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/672eff8cf1d6fe1ef09ca0f89c4b287d6a3eb831",
+ "reference": "672eff8cf1d6fe1ef09ca0f89c4b287d6a3eb831",
"shasum": ""
},
"require": {
- "php": "^7.0|^8.0",
- "phpoption/phpoption": "^1.7.3"
+ "php": "^7.2.5 || ^8.0",
+ "phpoption/phpoption": "^1.9.1"
},
"require-dev": {
- "phpunit/phpunit": "^6.5|^7.5|^8.5|^9.0"
+ "phpunit/phpunit": "^8.5.32 || ^9.6.3 || ^10.0.12"
},
"type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.0-dev"
- }
- },
"autoload": {
"psr-4": {
"GrahamCampbell\\ResultType\\": "src/"
@@ -661,7 +863,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,38 +875,53 @@
"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.1.1"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/GrahamCampbell",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/graham-campbell/result-type",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2023-02-25T20:23:15+00:00"
},
{
"name": "guzzlehttp/guzzle",
- "version": "7.3.0",
+ "version": "7.5.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
- "reference": "7008573787b430c1c1f650e3722d9bba59967628"
+ "reference": "b50a2a1251152e43f6a37f0fa053e730a67d25ba"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/guzzle/guzzle/zipball/7008573787b430c1c1f650e3722d9bba59967628",
- "reference": "7008573787b430c1c1f650e3722d9bba59967628",
+ "url": "https://api.github.com/repos/guzzle/guzzle/zipball/b50a2a1251152e43f6a37f0fa053e730a67d25ba",
+ "reference": "b50a2a1251152e43f6a37f0fa053e730a67d25ba",
"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"
},
"require-dev": {
- "bamarni/composer-bin-plugin": "^1.4.1",
+ "bamarni/composer-bin-plugin": "^1.8.1",
"ext-curl": "*",
"php-http/client-integration-tests": "^3.0",
- "phpunit/phpunit": "^8.5.5 || ^9.3.5",
- "psr/log": "^1.1"
+ "phpunit/phpunit": "^8.5.29 || ^9.5.23",
+ "psr/log": "^1.1 || ^2.0 || ^3.0"
},
"suggest": {
"ext-curl": "Required for CURL handler support",
@@ -712,36 +930,64 @@
},
"type": "library",
"extra": {
+ "bamarni-bin": {
+ "bin-links": true,
+ "forward-command": false
+ },
"branch-alias": {
- "dev-master": "7.3-dev"
+ "dev-master": "7.5-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 +999,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.5.0"
+ },
+ "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-08-28T15:39:27+00:00"
},
{
"name": "guzzlehttp/promises",
- "version": "1.4.1",
+ "version": "1.5.2",
"source": {
"type": "git",
"url": "https://github.com/guzzle/promises.git",
- "reference": "8e7d04f1f6450fef59366c399cfad4b9383aa30d"
+ "reference": "b94b2807d85443f9719887892882d0329d1e2598"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/guzzle/promises/zipball/8e7d04f1f6450fef59366c399cfad4b9383aa30d",
- "reference": "8e7d04f1f6450fef59366c399cfad4b9383aa30d",
+ "url": "https://api.github.com/repos/guzzle/promises/zipball/b94b2807d85443f9719887892882d0329d1e2598",
+ "reference": "b94b2807d85443f9719887892882d0329d1e2598",
"shasum": ""
},
"require": {
@@ -778,46 +1042,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.2"
+ },
+ "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": "2022-08-28T14:55:35+00:00"
},
{
"name": "guzzlehttp/psr7",
- "version": "2.0.0",
+ "version": "2.4.4",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
- "reference": "1dc8d9cba3897165e16d12bb13d813afb1eb3fe7"
+ "reference": "3cf1b6d4f0c820a2cf8bcaec39fc698f3443b5cf"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/guzzle/psr7/zipball/1dc8d9cba3897165e16d12bb13d813afb1eb3fe7",
- "reference": "1dc8d9cba3897165e16d12bb13d813afb1eb3fe7",
+ "url": "https://api.github.com/repos/guzzle/psr7/zipball/3cf1b6d4f0c820a2cf8bcaec39fc698f3443b5cf",
+ "reference": "3cf1b6d4f0c820a2cf8bcaec39fc698f3443b5cf",
"shasum": ""
},
"require": {
@@ -831,17 +1128,21 @@
"psr/http-message-implementation": "1.0"
},
"require-dev": {
- "bamarni/composer-bin-plugin": "^1.4.1",
+ "bamarni/composer-bin-plugin": "^1.8.1",
"http-interop/http-factory-tests": "^0.9",
- "phpunit/phpunit": "^8.5.8 || ^9.3.10"
+ "phpunit/phpunit": "^8.5.29 || ^9.5.23"
},
"suggest": {
"laminas/laminas-httphandlerrunner": "Emit PSR-7 responses"
},
"type": "library",
"extra": {
+ "bamarni-bin": {
+ "bin-links": true,
+ "forward-command": false
+ },
"branch-alias": {
- "dev-master": "2.0-dev"
+ "dev-master": "2.4-dev"
}
},
"autoload": {
@@ -854,13 +1155,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 +1202,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.4"
+ },
+ "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": "2023-03-09T13:19:02+00:00"
},
{
"name": "laravel/framework",
- "version": "v8.49.2",
+ "version": "v8.83.27",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
- "reference": "d9b43ee080b4d51344b2e578aa667f85040471a2"
+ "reference": "e1afe088b4ca613fb96dc57e6d8dbcb8cc2c6b49"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/laravel/framework/zipball/d9b43ee080b4d51344b2e578aa667f85040471a2",
- "reference": "d9b43ee080b4d51344b2e578aa667f85040471a2",
+ "url": "https://api.github.com/repos/laravel/framework/zipball/e1afe088b4ca613fb96dc57e6d8dbcb8cc2c6b49",
+ "reference": "e1afe088b4ca613fb96dc57e6d8dbcb8cc2c6b49",
"shasum": ""
},
"require": {
@@ -903,34 +1243,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 +1309,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 +1334,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 +1389,100 @@
"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-12-08T15:28:55+00:00"
+ },
+ {
+ "name": "laravel/serializable-closure",
+ "version": "v1.3.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/laravel/serializable-closure.git",
+ "reference": "f23fe9d4e95255dacee1bf3525e0810d1a1b0f37"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/f23fe9d4e95255dacee1bf3525e0810d1a1b0f37",
+ "reference": "f23fe9d4e95255dacee1bf3525e0810d1a1b0f37",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.3|^8.0"
+ },
+ "require-dev": {
+ "nesbot/carbon": "^2.61",
+ "pestphp/pest": "^1.21.3",
+ "phpstan/phpstan": "^1.8.2",
+ "symfony/var-dumper": "^5.4.11"
+ },
+ "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": "2023-01-30T18:31:20+00:00"
},
{
"name": "laravel/tinker",
- "version": "v2.6.1",
+ "version": "v2.8.1",
"source": {
"type": "git",
"url": "https://github.com/laravel/tinker.git",
- "reference": "04ad32c1a3328081097a181875733fa51f402083"
+ "reference": "04a2d3bd0d650c0764f70bf49d1ee39393e4eb10"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/laravel/tinker/zipball/04ad32c1a3328081097a181875733fa51f402083",
- "reference": "04ad32c1a3328081097a181875733fa51f402083",
+ "url": "https://api.github.com/repos/laravel/tinker/zipball/04a2d3bd0d650c0764f70bf49d1ee39393e4eb10",
+ "reference": "04a2d3bd0d650c0764f70bf49d1ee39393e4eb10",
"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|^10.0",
+ "illuminate/contracts": "^6.0|^7.0|^8.0|^9.0|^10.0",
+ "illuminate/support": "^6.0|^7.0|^8.0|^9.0|^10.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|^10.0)."
},
"type": "library",
"extra": {
@@ -1108,29 +1517,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.8.1"
+ },
+ "time": "2023-02-15T16:40:09+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 +1579,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.9",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/commonmark.git",
- "reference": "44ffd8d3c4a9133e4bd0548622b09c55af39db5f"
+ "reference": "c1e114f74e518daca2729ea8c4bf1167038fa4b5"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/44ffd8d3c4a9133e4bd0548622b09c55af39db5f",
- "reference": "44ffd8d3c4a9133e4bd0548622b09c55af39db5f",
+ "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/c1e114f74e518daca2729ea8c4bf1167038fa4b5",
+ "reference": "c1e114f74e518daca2729ea8c4bf1167038fa4b5",
"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 || ^2.0",
+ "nyholm/psr7": "^1.5",
+ "phpstan/phpstan": "^1.8.2",
+ "phpunit/phpunit": "^9.5.21",
+ "scrutinizer/ocular": "^1.8.1",
+ "symfony/finder": "^5.3 | ^6.0",
+ "symfony/yaml": "^2.3 | ^3.0 | ^4.0 | ^5.0 | ^6.0",
+ "unleashedtech/php-coding-standard": "^3.1.1",
+ "vimeo/psalm": "^4.24.0 || ^5.0.0"
+ },
+ "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 +1651,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 +1663,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": "2023-02-15T14:07:24+00:00"
+ },
+ {
+ "name": "league/config",
+ "version": "v1.2.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/thephpleague/config.git",
+ "reference": "754b3604fb2984c71f4af4a9cbe7b57f346ec1f3"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/thephpleague/config/zipball/754b3604fb2984c71f4af4a9cbe7b57f346ec1f3",
+ "reference": "754b3604fb2984c71f4af4a9cbe7b57f346ec1f3",
+ "shasum": ""
+ },
+ "require": {
+ "dflydev/dot-access-data": "^3.0.1",
+ "nette/schema": "^1.2",
+ "php": "^7.4 || ^8.0"
+ },
+ "require-dev": {
+ "phpstan/phpstan": "^1.8.2",
+ "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": "2022-12-11T20:36:23+00:00"
},
{
"name": "league/flysystem",
- "version": "1.1.4",
+ "version": "1.1.10",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem.git",
- "reference": "f3ad69181b8afed2c9edf7be5a2918144ff4ea32"
+ "reference": "3239285c825c152bcc315fe0e87d6b55f5972ed1"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/f3ad69181b8afed2c9edf7be5a2918144ff4ea32",
- "reference": "f3ad69181b8afed2c9edf7be5a2918144ff4ea32",
+ "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/3239285c825c152bcc315fe0e87d6b55f5972ed1",
+ "reference": "3239285c825c152bcc315fe0e87d6b55f5972ed1",
"shasum": ""
},
"require": {
@@ -1316,20 +1854,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.10"
+ },
+ "funding": [
+ {
+ "url": "https://offset.earth/frankdejonge",
+ "type": "other"
+ }
+ ],
+ "time": "2022-10-04T09:16:37+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 +1885,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 +1906,46 @@
}
],
"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.48",
"source": {
"type": "git",
- "url": "https://github.com/Maatwebsite/Laravel-Excel.git",
- "reference": "9dc29b63a77fb7f2f514ef754af3a1b57e83cadf"
+ "url": "https://github.com/SpartnerNL/Laravel-Excel.git",
+ "reference": "6d0fe2a1d195960c7af7bf0de760582da02a34b9"
},
"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/6d0fe2a1d195960c7af7bf0de760582da02a34b9",
+ "reference": "6d0fe2a1d195960c7af7bf0de760582da02a34b9",
"shasum": ""
},
"require": {
+ "composer/semver": "^3.3",
"ext-json": "*",
- "illuminate/support": "5.8.*|^6.0|^7.0|^8.0",
+ "illuminate/support": "5.8.*|^6.0|^7.0|^8.0|^9.0|^10.0",
"php": "^7.0|^8.0",
- "phpoffice/phpspreadsheet": "^1.18"
+ "phpoffice/phpspreadsheet": "^1.18",
+ "psr/simple-cache": "^1.0|^2.0|^3.0"
},
"require-dev": {
- "orchestra/testbench": "^6.0",
+ "orchestra/testbench": "^6.0|^7.0|^8.0",
"predis/predis": "^1.1"
},
"type": "library",
@@ -1407,7 +1971,7 @@
"authors": [
{
"name": "Patrick Brouwers",
- "email": "patrick@maatwebsite.nl"
+ "email": "patrick@spartner.nl"
}
],
"description": "Supercharged Excel exports and imports in Laravel",
@@ -1422,33 +1986,50 @@
"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.48"
+ },
+ "funding": [
+ {
+ "url": "https://laravel-excel.com/commercial-support",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/patrickbrouwers",
+ "type": "github"
+ }
+ ],
+ "time": "2023-02-22T21:01:38+00:00"
},
{
"name": "maennchen/zipstream-php",
- "version": "2.1.0",
+ "version": "2.2.6",
"source": {
"type": "git",
"url": "https://github.com/maennchen/ZipStream-PHP.git",
- "reference": "c4c5803cc1f93df3d2448478ef79394a5981cc58"
+ "reference": "30ad6f93cf3efe4192bc7a4c9cad11ff8f4f237f"
},
"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/30ad6f93cf3efe4192bc7a4c9cad11ff8f4f237f",
+ "reference": "30ad6f93cf3efe4192bc7a4c9cad11ff8f4f237f",
"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",
+ "friendsofphp/php-cs-fixer": "^3.9",
+ "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,80 +2064,50 @@
"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.6"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/maennchen",
+ "type": "github"
+ },
+ {
+ "url": "https://opencollective.com/zipstream",
+ "type": "open_collective"
+ }
+ ],
+ "time": "2022-11-25T18:57:19+00:00"
},
{
"name": "markbaker/complex",
- "version": "2.0.3",
+ "version": "3.0.2",
"source": {
"type": "git",
"url": "https://github.com/MarkBaker/PHPComplex.git",
- "reference": "6f724d7e04606fd8adaa4e3bb381c3e9db09c946"
+ "reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/6f724d7e04606fd8adaa4e3bb381c3e9db09c946",
- "reference": "6f724d7e04606fd8adaa4e3bb381c3e9db09c946",
+ "url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/95c56caa1cf5c766ad6d65b6344b807c1e8405b9",
+ "reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0"
},
"require-dev": {
- "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
- "phpcompatibility/php-compatibility": "^9.0",
- "phpunit/phpunit": "^7.0 || ^8.0 || ^9.3",
- "squizlabs/php_codesniffer": "^3.4"
+ "dealerdirect/phpcodesniffer-composer-installer": "dev-master",
+ "phpcompatibility/php-compatibility": "^9.3",
+ "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
+ "squizlabs/php_codesniffer": "^3.7"
},
"type": "library",
"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,58 +2125,44 @@
"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.2"
+ },
+ "time": "2022-12-06T16:21:08+00:00"
},
{
"name": "markbaker/matrix",
- "version": "2.1.3",
+ "version": "3.0.1",
"source": {
"type": "git",
"url": "https://github.com/MarkBaker/PHPMatrix.git",
- "reference": "174395a901b5ba0925f1d790fa91bab531074b61"
+ "reference": "728434227fe21be27ff6d86621a1b13107a2562c"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/174395a901b5ba0925f1d790fa91bab531074b61",
- "reference": "174395a901b5ba0925f1d790fa91bab531074b61",
+ "url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/728434227fe21be27ff6d86621a1b13107a2562c",
+ "reference": "728434227fe21be27ff6d86621a1b13107a2562c",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"require-dev": {
- "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
- "phpcompatibility/php-compatibility": "^9.0",
+ "dealerdirect/phpcodesniffer-composer-installer": "dev-master",
+ "phpcompatibility/php-compatibility": "^9.3",
"phpdocumentor/phpdocumentor": "2.*",
"phploc/phploc": "^4.0",
"phpmd/phpmd": "2.*",
- "phpunit/phpunit": "^7.0 || ^8.0 || ^9.3",
+ "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
"sebastian/phpcpd": "^4.0",
- "squizlabs/php_codesniffer": "^3.4"
+ "squizlabs/php_codesniffer": "^3.7"
},
"type": "library",
"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,56 +2181,66 @@
"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.1"
+ },
+ "time": "2022-12-02T22:17:43+00:00"
},
{
"name": "monolog/monolog",
- "version": "2.3.0",
+ "version": "2.9.1",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
- "reference": "df991fd88693ab703aa403413d83e15f688dae33"
+ "reference": "f259e2b15fb95494c83f52d3caad003bbf5ffaa1"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/Seldaek/monolog/zipball/df991fd88693ab703aa403413d83e15f688dae33",
- "reference": "df991fd88693ab703aa403413d83e15f688dae33",
+ "url": "https://api.github.com/repos/Seldaek/monolog/zipball/f259e2b15fb95494c83f52d3caad003bbf5ffaa1",
+ "reference": "f259e2b15fb95494c83f52d3caad003bbf5ffaa1",
"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",
- "graylog2/gelf-php": "^1.4.2",
+ "elasticsearch/elasticsearch": "^7 || ^8",
+ "ext-json": "*",
+ "graylog2/gelf-php": "^1.4.2 || ^2@dev",
+ "guzzlehttp/guzzle": "^7.4",
+ "guzzlehttp/psr7": "^2.2",
"mongodb/mongodb": "^1.8",
- "php-amqplib/php-amqplib": "~2.4",
- "php-console/php-console": "^3.1.3",
- "phpspec/prophecy": "^1.6.1",
+ "php-amqplib/php-amqplib": "~2.4 || ^3",
+ "phpspec/prophecy": "^1.15",
"phpstan/phpstan": "^0.12.91",
- "phpunit/phpunit": "^8.5",
- "predis/predis": "^1.1",
- "rollbar/rollbar": "^1.3",
- "ruflin/elastica": ">=0.90 <7.0.1",
- "swiftmailer/swiftmailer": "^5.3|^6.0"
+ "phpunit/phpunit": "^8.5.14",
+ "predis/predis": "^1.1 || ^2.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",
- "php-console/php-console": "Allow sending log messages to Google Chrome",
"rollbar/rollbar": "Allow sending log messages to Rollbar",
"ruflin/elastica": "Allow sending log messages to an Elastic Search server"
},
@@ -1726,20 +2273,34 @@
"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.9.1"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/Seldaek",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/monolog/monolog",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2023-02-06T13:44:46+00:00"
},
{
"name": "myclabs/php-enum",
- "version": "1.8.3",
+ "version": "1.8.4",
"source": {
"type": "git",
"url": "https://github.com/myclabs/php-enum.git",
- "reference": "b942d263c641ddb5190929ff840c68f78713e937"
+ "reference": "a867478eae49c9f59ece437ae7f9506bfaa27483"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/myclabs/php-enum/zipball/b942d263c641ddb5190929ff840c68f78713e937",
- "reference": "b942d263c641ddb5190929ff840c68f78713e937",
+ "url": "https://api.github.com/repos/myclabs/php-enum/zipball/a867478eae49c9f59ece437ae7f9506bfaa27483",
+ "reference": "a867478eae49c9f59ece437ae7f9506bfaa27483",
"shasum": ""
},
"require": {
@@ -1755,7 +2316,10 @@
"autoload": {
"psr-4": {
"MyCLabs\\Enum\\": "src/"
- }
+ },
+ "classmap": [
+ "stubs/Stringable.php"
+ ]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -1772,36 +2336,54 @@
"keywords": [
"enum"
],
- "time": "2021-07-05T08:18:36+00:00"
+ "support": {
+ "issues": "https://github.com/myclabs/php-enum/issues",
+ "source": "https://github.com/myclabs/php-enum/tree/1.8.4"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/mnapoli",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/myclabs/php-enum",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-08-04T09:53:51+00:00"
},
{
"name": "nesbot/carbon",
- "version": "2.50.0",
+ "version": "2.66.0",
"source": {
"type": "git",
"url": "https://github.com/briannesbitt/Carbon.git",
- "reference": "f47f17d17602b2243414a44ad53d9f8b9ada5fdb"
+ "reference": "496712849902241f04902033b0441b269effe001"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/f47f17d17602b2243414a44ad53d9f8b9ada5fdb",
- "reference": "f47f17d17602b2243414a44ad53d9f8b9ada5fdb",
+ "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/496712849902241f04902033b0441b269effe001",
+ "reference": "496712849902241f04902033b0441b269effe001",
"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.1.4",
"doctrine/orm": "^2.7",
- "friendsofphp/php-cs-fixer": "^2.14 || ^3.0",
+ "friendsofphp/php-cs-fixer": "^3.0",
"kylekatarnls/multi-tester": "^2.0",
+ "ondrejmirtes/better-reflection": "*",
"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.99 || ^1.7.14",
+ "phpunit/php-file-iterator": "^2.0.5 || ^3.0.6",
+ "phpunit/phpunit": "^7.5.20 || ^8.5.26 || ^9.5.20",
"squizlabs/php_codesniffer": "^3.4"
},
"bin": [
@@ -1810,8 +2392,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,94 +2433,265 @@
"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://github.com/sponsors/kylekatarnls",
+ "type": "github"
+ },
+ {
+ "url": "https://opencollective.com/Carbon#sponsor",
+ "type": "opencollective"
+ },
+ {
+ "url": "https://tidelift.com/subscription/pkg/packagist-nesbot-carbon?utm_source=packagist-nesbot-carbon&utm_medium=referral&utm_campaign=readme",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2023-01-29T18:53:47+00:00"
},
{
- "name": "nikic/php-parser",
- "version": "v4.11.0",
+ "name": "nette/schema",
+ "version": "v1.2.3",
"source": {
"type": "git",
- "url": "https://github.com/nikic/PHP-Parser.git",
- "reference": "fe14cf3672a149364fb66dfe11bf6549af899f94"
+ "url": "https://github.com/nette/schema.git",
+ "reference": "abbdbb70e0245d5f3bf77874cea1dfb0c930d06f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/fe14cf3672a149364fb66dfe11bf6549af899f94",
- "reference": "fe14cf3672a149364fb66dfe11bf6549af899f94",
+ "url": "https://api.github.com/repos/nette/schema/zipball/abbdbb70e0245d5f3bf77874cea1dfb0c930d06f",
+ "reference": "abbdbb70e0245d5f3bf77874cea1dfb0c930d06f",
"shasum": ""
},
"require": {
- "ext-tokenizer": "*",
- "php": ">=7.0"
+ "nette/utils": "^2.5.7 || ^3.1.5 || ^4.0",
+ "php": ">=7.1 <8.3"
},
"require-dev": {
- "ircmaxell/php-yacc": "^0.0.7",
- "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0"
+ "nette/tester": "^2.3 || ^2.4",
+ "phpstan/phpstan-nette": "^1.0",
+ "tracy/tracy": "^2.7"
},
- "bin": [
- "bin/php-parse"
- ],
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "4.9-dev"
+ "dev-master": "1.2-dev"
}
},
"autoload": {
- "psr-4": {
- "PhpParser\\": "lib/PhpParser"
- }
+ "classmap": [
+ "src/"
+ ]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
- "BSD-3-Clause"
+ "BSD-3-Clause",
+ "GPL-2.0-only",
+ "GPL-3.0-only"
],
"authors": [
{
- "name": "Nikita Popov"
+ "name": "David Grudl",
+ "homepage": "https://davidgrudl.com"
+ },
+ {
+ "name": "Nette Community",
+ "homepage": "https://nette.org/contributors"
}
],
- "description": "A PHP parser written in PHP",
+ "description": "📐 Nette Schema: validating data structures against a given Schema.",
+ "homepage": "https://nette.org",
"keywords": [
- "parser",
- "php"
+ "config",
+ "nette"
],
- "time": "2021-07-03T13:36:55+00:00"
+ "support": {
+ "issues": "https://github.com/nette/schema/issues",
+ "source": "https://github.com/nette/schema/tree/v1.2.3"
+ },
+ "time": "2022-10-13T01:24:26+00:00"
},
{
- "name": "opis/closure",
- "version": "3.6.2",
+ "name": "nette/utils",
+ "version": "v3.2.9",
"source": {
"type": "git",
- "url": "https://github.com/opis/closure.git",
- "reference": "06e2ebd25f2869e54a306dda991f7db58066f7f6"
+ "url": "https://github.com/nette/utils.git",
+ "reference": "c91bac3470c34b2ecd5400f6e6fdf0b64a836a5c"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/opis/closure/zipball/06e2ebd25f2869e54a306dda991f7db58066f7f6",
- "reference": "06e2ebd25f2869e54a306dda991f7db58066f7f6",
+ "url": "https://api.github.com/repos/nette/utils/zipball/c91bac3470c34b2ecd5400f6e6fdf0b64a836a5c",
+ "reference": "c91bac3470c34b2ecd5400f6e6fdf0b64a836a5c",
"shasum": ""
},
"require": {
- "php": "^5.4 || ^7.0 || ^8.0"
+ "php": ">=7.2 <8.3"
+ },
+ "conflict": {
+ "nette/di": "<3.0.6"
},
"require-dev": {
- "jeremeamia/superclosure": "^2.0",
- "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0"
+ "jetbrains/phpstorm-attributes": "dev-master",
+ "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.6.x-dev"
+ "dev-master": "3.2-dev"
}
},
"autoload": {
- "psr-4": {
- "Opis\\Closure\\": "src/"
- },
- "files": [
- "functions.php"
- ]
+ "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.9"
+ },
+ "time": "2023-01-18T03:26:20+00:00"
+ },
+ {
+ "name": "nikic/php-parser",
+ "version": "v4.15.4",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/nikic/PHP-Parser.git",
+ "reference": "6bb5176bc4af8bcb7d926f88718db9b96a2d4290"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/6bb5176bc4af8bcb7d926f88718db9b96a2d4290",
+ "reference": "6bb5176bc4af8bcb7d926f88718db9b96a2d4290",
+ "shasum": ""
+ },
+ "require": {
+ "ext-tokenizer": "*",
+ "php": ">=7.0"
+ },
+ "require-dev": {
+ "ircmaxell/php-yacc": "^0.0.7",
+ "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0"
+ },
+ "bin": [
+ "bin/php-parse"
+ ],
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "4.9-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "PhpParser\\": "lib/PhpParser"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Nikita Popov"
+ }
+ ],
+ "description": "A PHP parser written in PHP",
+ "keywords": [
+ "parser",
+ "php"
+ ],
+ "support": {
+ "issues": "https://github.com/nikic/PHP-Parser/issues",
+ "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.4"
+ },
+ "time": "2023-03-05T19:49:14+00:00"
+ },
+ {
+ "name": "opis/closure",
+ "version": "3.6.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/opis/closure.git",
+ "reference": "3d81e4309d2a927abbe66df935f4bb60082805ad"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/opis/closure/zipball/3d81e4309d2a927abbe66df935f4bb60082805ad",
+ "reference": "3d81e4309d2a927abbe66df935f4bb60082805ad",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^5.4 || ^7.0 || ^8.0"
+ },
+ "require-dev": {
+ "jeremeamia/superclosure": "^2.0",
+ "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.6.x-dev"
+ }
+ },
+ "autoload": {
+ "files": [
+ "functions.php"
+ ],
+ "psr-4": {
+ "Opis\\Closure\\": "src/"
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -1964,20 +2717,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.28.0",
"source": {
"type": "git",
"url": "https://github.com/PHPOffice/PhpSpreadsheet.git",
- "reference": "418cd304e8e6b417ea79c3b29126a25dc4b1170c"
+ "reference": "6e81cf39bbd93ebc3a4e8150444c41e8aa9b769a"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/418cd304e8e6b417ea79c3b29126a25dc4b1170c",
- "reference": "418cd304e8e6b417ea79c3b29126a25dc4b1170c",
+ "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/6e81cf39bbd93ebc3a4e8150444c41e8aa9b769a",
+ "reference": "6e81cf39bbd93ebc3a4e8150444c41e8aa9b769a",
"shasum": ""
},
"require": {
@@ -1994,33 +2751,34 @@
"ext-xmlwriter": "*",
"ext-zip": "*",
"ext-zlib": "*",
- "ezyang/htmlpurifier": "^4.13",
+ "ezyang/htmlpurifier": "^4.15",
"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.4 || ^8.0",
"psr/http-client": "^1.0",
"psr/http-factory": "^1.0",
- "psr/simple-cache": "^1.0"
+ "psr/simple-cache": "^1.0 || ^2.0 || ^3.0"
},
"require-dev": {
- "dealerdirect/phpcodesniffer-composer-installer": "dev-master",
- "dompdf/dompdf": "^1.0",
- "friendsofphp/php-cs-fixer": "^2.18",
- "jpgraph/jpgraph": "^4.0",
- "mpdf/mpdf": "^8.0",
+ "dealerdirect/phpcodesniffer-composer-installer": "dev-main",
+ "dompdf/dompdf": "^1.0 || ^2.0",
+ "friendsofphp/php-cs-fixer": "^3.2",
+ "mitoteam/jpgraph": "^10.2.4",
+ "mpdf/mpdf": "^8.1.1",
"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.7",
+ "tecnickcom/tcpdf": "^6.5"
},
"suggest": {
- "dompdf/dompdf": "Option for rendering PDF with PDF Writer (doesn't yet support PHP8)",
- "jpgraph/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers",
+ "dompdf/dompdf": "Option for rendering PDF with PDF Writer",
+ "ext-intl": "PHP Internationalization Functions",
+ "mitoteam/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers",
"mpdf/mpdf": "Option for rendering PDF with PDF Writer",
- "tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer (doesn't yet support PHP8)"
+ "tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer"
},
"type": "library",
"autoload": {
@@ -2064,33 +2822,41 @@
"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.28.0"
+ },
+ "time": "2023-02-25T12:24:49+00:00"
},
{
"name": "phpoption/phpoption",
- "version": "1.7.5",
+ "version": "1.9.1",
"source": {
"type": "git",
"url": "https://github.com/schmittjoh/php-option.git",
- "reference": "994ecccd8f3283ecf5ac33254543eb0ac946d525"
+ "reference": "dd3a383e599f49777d8b628dadbb90cae435b87e"
},
"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/dd3a383e599f49777d8b628dadbb90cae435b87e",
+ "reference": "dd3a383e599f49777d8b628dadbb90cae435b87e",
"shasum": ""
},
"require": {
- "php": "^5.5.9 || ^7.0 || ^8.0"
+ "php": "^7.2.5 || ^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"
+ "bamarni/composer-bin-plugin": "^1.8.2",
+ "phpunit/phpunit": "^8.5.32 || ^9.6.3 || ^10.0.12"
},
"type": "library",
"extra": {
+ "bamarni-bin": {
+ "bin-links": true,
+ "forward-command": true
+ },
"branch-alias": {
- "dev-master": "1.7-dev"
+ "dev-master": "1.9-dev"
}
},
"autoload": {
@@ -2105,11 +2871,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,24 +2887,104 @@
"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.9.1"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/GrahamCampbell",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/phpoption/phpoption",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2023-02-25T19:38:58+00:00"
+ },
+ {
+ "name": "predis/predis",
+ "version": "v1.1.10",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/predis/predis.git",
+ "reference": "a2fb02d738bedadcffdbb07efa3a5e7bd57f8d6e"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/predis/predis/zipball/a2fb02d738bedadcffdbb07efa3a5e7bd57f8d6e",
+ "reference": "a2fb02d738bedadcffdbb07efa3a5e7bd57f8d6e",
+ "shasum": ""
+ },
+ "require": {
+ "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": {
+ "Predis\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "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": "Flexible and feature-complete Redis client for PHP and HHVM",
+ "homepage": "http://github.com/predis/predis",
+ "keywords": [
+ "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": "2022-01-05T17:46:08+00:00"
},
{
"name": "psr/container",
- "version": "1.1.1",
+ "version": "1.1.2",
"source": {
"type": "git",
"url": "https://github.com/php-fig/container.git",
- "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf"
+ "reference": "513e0666f7216c7459170d56df27dfcefe1689ea"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf",
- "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf",
+ "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": {
@@ -2163,7 +3011,11 @@
"container-interop",
"psr"
],
- "time": "2021-03-05T17:36:06+00:00"
+ "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",
@@ -2209,6 +3061,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 +3114,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 +3169,9 @@
"request",
"response"
],
+ "support": {
+ "source": "https://github.com/php-fig/http-factory/tree/master"
+ },
"time": "2019-04-30T12:38:16+00:00"
},
{
@@ -2360,6 +3222,9 @@
"request",
"response"
],
+ "support": {
+ "source": "https://github.com/php-fig/http-message/tree/master"
+ },
"time": "2016-08-06T14:39:51+00:00"
},
{
@@ -2407,6 +3272,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 +3323,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.12",
"source": {
"type": "git",
"url": "https://github.com/bobthecow/psysh.git",
- "reference": "e4573f47750dd6c92dca5aee543fa77513cbd8d3"
+ "reference": "52cb7c47d403c31c0adc9bf7710fc355f93c20f7"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/bobthecow/psysh/zipball/e4573f47750dd6c92dca5aee543fa77513cbd8d3",
- "reference": "e4573f47750dd6c92dca5aee543fa77513cbd8d3",
+ "url": "https://api.github.com/repos/bobthecow/psysh/zipball/52cb7c47d403c31c0adc9bf7710fc355f93c20f7",
+ "reference": "52cb7c47d403c31c0adc9bf7710fc355f93c20f7",
"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 +3368,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "0.10.x-dev"
+ "dev-main": "0.11.x-dev"
}
},
"autoload": {
@@ -2526,7 +3398,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.12"
+ },
+ "time": "2023-01-29T21:24:40+00:00"
},
{
"name": "ralouphie/getallheaders",
@@ -2566,44 +3442,61 @@
}
],
"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.3.0",
"source": {
"type": "git",
"url": "https://github.com/ramsey/collection.git",
- "reference": "28a5c4ab2f5111db6a60b2b4ec84057e0f43b9c1"
+ "reference": "ad7475d1c9e70b190ecffc58f2d989416af339b4"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/ramsey/collection/zipball/28a5c4ab2f5111db6a60b2b4ec84057e0f43b9c1",
- "reference": "28a5c4ab2f5111db6a60b2b4ec84057e0f43b9c1",
+ "url": "https://api.github.com/repos/ramsey/collection/zipball/ad7475d1c9e70b190ecffc58f2d989416af339b4",
+ "reference": "ad7475d1c9e70b190ecffc58f2d989416af339b4",
"shasum": ""
},
"require": {
- "php": "^7.2 || ^8"
+ "php": "^7.4 || ^8.0",
+ "symfony/polyfill-php81": "^1.23"
},
"require-dev": {
- "captainhook/captainhook": "^5.3",
- "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
- "ergebnis/composer-normalize": "^2.6",
- "fakerphp/faker": "^1.5",
- "hamcrest/hamcrest-php": "^2",
- "jangregor/phpstan-prophecy": "^0.8",
- "mockery/mockery": "^1.3",
- "phpstan/extension-installer": "^1",
- "phpstan/phpstan": "^0.12.32",
- "phpstan/phpstan-mockery": "^0.12.5",
- "phpstan/phpstan-phpunit": "^0.12.11",
- "phpunit/phpunit": "^8.5 || ^9",
- "psy/psysh": "^0.10.4",
- "slevomat/coding-standard": "^6.3",
- "squizlabs/php_codesniffer": "^3.5",
- "vimeo/psalm": "^4.4"
+ "captainhook/plugin-composer": "^5.3",
+ "ergebnis/composer-normalize": "^2.28.3",
+ "fakerphp/faker": "^1.21",
+ "hamcrest/hamcrest-php": "^2.0",
+ "jangregor/phpstan-prophecy": "^1.0",
+ "mockery/mockery": "^1.5",
+ "php-parallel-lint/php-console-highlighter": "^1.0",
+ "php-parallel-lint/php-parallel-lint": "^1.3",
+ "phpcsstandards/phpcsutils": "^1.0.0-rc1",
+ "phpspec/prophecy-phpunit": "^2.0",
+ "phpstan/extension-installer": "^1.2",
+ "phpstan/phpstan": "^1.9",
+ "phpstan/phpstan-mockery": "^1.1",
+ "phpstan/phpstan-phpunit": "^1.3",
+ "phpunit/phpunit": "^9.5",
+ "psalm/plugin-mockery": "^1.1",
+ "psalm/plugin-phpunit": "^0.18.4",
+ "ramsey/coding-standard": "^2.0.3",
+ "ramsey/conventional-commits": "^1.3",
+ "vimeo/psalm": "^5.4"
},
"type": "library",
+ "extra": {
+ "captainhook": {
+ "force-install": true
+ },
+ "ramsey/conventional-commits": {
+ "configFile": "conventional-commits.json"
+ }
+ },
"autoload": {
"psr-4": {
"Ramsey\\Collection\\": "src/"
@@ -2620,7 +3513,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 +3522,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.3.0"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/ramsey",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/ramsey/collection",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-12-27T19:12:24+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 +3596,148 @@
"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": "realrashid/sweet-alert",
+ "version": "v7.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/realrashid/sweet-alert.git",
+ "reference": "81eb61745002b7fbe2276cbb64214f678584df5c"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/realrashid/sweet-alert/zipball/81eb61745002b7fbe2276cbb64214f678584df5c",
+ "reference": "81eb61745002b7fbe2276cbb64214f678584df5c",
+ "shasum": ""
+ },
+ "require": {
+ "laravel/framework": "^5.6|^6.0|^7.0|^8.0|^9.0|^9.11|9.14.*|^10.0",
+ "php": "^7.2|^8.0|^8.1"
+ },
+ "require-dev": {
+ "symfony/thanks": "^1.0"
+ },
+ "type": "library",
+ "extra": {
+ "laravel": {
+ "providers": [
+ "RealRashid\\SweetAlert\\SweetAlertServiceProvider"
+ ],
+ "aliases": {
+ "Alert": "RealRashid\\SweetAlert\\Facades\\Alert"
+ }
+ }
+ },
+ "autoload": {
+ "files": [
+ "src/functions.php"
+ ],
+ "psr-4": {
+ "RealRashid\\SweetAlert\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Rashid Ali",
+ "email": "realrashid05@gmail.com",
+ "homepage": "https://realrashid.com",
+ "role": "Developer"
+ }
+ ],
+ "description": "Laravel Sweet Alert Is A Package For Laravel Provides An Easy Way To Display Alert Messages Using The SweetAlert2 Library.",
+ "homepage": "https://github.com/realrashid/sweet-alert",
+ "keywords": [
+ "alert",
+ "laravel",
+ "laravel-package",
+ "notifier",
+ "noty",
+ "sweet-alert",
+ "sweet-alert2",
+ "toast"
+ ],
+ "support": {
+ "docs": "https://realrashid.github.io/sweet-alert/",
+ "email": "realrashid05@gmail.com",
+ "issues": "https://github.com/realrashid/sweet-alert/issues",
+ "source": "https://github.com/realrashid/sweet-alert"
+ },
+ "funding": [
+ {
+ "url": "https://ko-fi.com/realrashid",
+ "type": "custom"
+ },
+ {
+ "url": "https://www.buymeacoffee.com/realrashid",
+ "type": "custom"
+ },
+ {
+ "url": "https://issuehunt.io/r/realrashid",
+ "type": "issuehunt"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/realrashid/sweet-alert",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2023-04-20T01:23:24+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 +3749,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 +3785,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.21",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
- "reference": "649730483885ff2ca99ca0560ef0e5f6b03f2ac1"
+ "reference": "c77433ddc6cdc689caf48065d9ea22ca0853fbd9"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/console/zipball/649730483885ff2ca99ca0560ef0e5f6b03f2ac1",
- "reference": "649730483885ff2ca99ca0560ef0e5f6b03f2ac1",
+ "url": "https://api.github.com/repos/symfony/console/zipball/c77433ddc6cdc689caf48065d9ea22ca0853fbd9",
+ "reference": "c77433ddc6cdc689caf48065d9ea22ca0853fbd9",
"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 +3834,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 +3882,42 @@
"console",
"terminal"
],
- "time": "2021-06-12T09:42:48+00:00"
+ "support": {
+ "source": "https://github.com/symfony/console/tree/v5.4.21"
+ },
+ "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": "2023-02-25T16:59:41+00:00"
},
{
"name": "symfony/css-selector",
- "version": "v5.3.0",
+ "version": "v5.4.21",
"source": {
"type": "git",
"url": "https://github.com/symfony/css-selector.git",
- "reference": "fcd0b29a7a0b1bb5bfbedc6231583d77fea04814"
+ "reference": "95f3c7468db1da8cc360b24fa2a26e7cefcb355d"
},
"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/95f3c7468db1da8cc360b24fa2a26e7cefcb355d",
+ "reference": "95f3c7468db1da8cc360b24fa2a26e7cefcb355d",
"shasum": ""
},
"require": {
- "php": ">=7.2.5"
+ "php": ">=7.2.5",
+ "symfony/polyfill-php80": "^1.16"
},
"type": "library",
"autoload": {
@@ -2900,20 +3948,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.21"
+ },
+ "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": "2023-02-14T08:03:56+00:00"
},
{
"name": "symfony/deprecation-contracts",
- "version": "v2.4.0",
+ "version": "v2.5.2",
"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 +3987,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "2.4-dev"
+ "dev-main": "2.5-dev"
},
"thanks": {
"name": "symfony/contracts",
@@ -2950,33 +4015,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.2"
+ },
+ "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.21",
"source": {
"type": "git",
"url": "https://github.com/symfony/error-handler.git",
- "reference": "43323e79c80719e8a4674e33484bca98270d223f"
+ "reference": "56a94aa8cb5a5fbc411551d8d014a296b5456549"
},
"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/56a94aa8cb5a5fbc411551d8d014a296b5456549",
+ "reference": "56a94aa8cb5a5fbc411551d8d014a296b5456549",
"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 +4086,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.21"
+ },
+ "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": "2023-02-14T08:03:56+00:00"
},
{
"name": "symfony/event-dispatcher",
- "version": "v5.3.0",
+ "version": "v5.4.21",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
- "reference": "67a5f354afa8e2f231081b3fa11a5912f933c3ce"
+ "reference": "f0ae1383a8285dfc6752b8d8602790953118ff5a"
},
"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/f0ae1383a8285dfc6752b8d8602790953118ff5a",
+ "reference": "f0ae1383a8285dfc6752b8d8602790953118ff5a",
"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 +4133,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 +4171,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.21"
+ },
+ "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": "2023-02-14T08:03:56+00:00"
},
{
"name": "symfony/event-dispatcher-contracts",
- "version": "v2.4.0",
+ "version": "v2.5.2",
"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 +4214,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "2.4-dev"
+ "dev-main": "2.5-dev"
},
"thanks": {
"name": "symfony/contracts",
@@ -3132,24 +4250,43 @@
"interoperability",
"standards"
],
- "time": "2021-03-23T23:28:01+00:00"
+ "support": {
+ "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v2.5.2"
+ },
+ "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.21",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
- "reference": "0ae3f047bed4edff6fd35b26a9a6bfdc92c953c6"
+ "reference": "078e9a5e1871fcfe6a5ce421b539344c21afef19"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/finder/zipball/0ae3f047bed4edff6fd35b26a9a6bfdc92c953c6",
- "reference": "0ae3f047bed4edff6fd35b26a9a6bfdc92c953c6",
+ "url": "https://api.github.com/repos/symfony/finder/zipball/078e9a5e1871fcfe6a5ce421b539344c21afef19",
+ "reference": "078e9a5e1871fcfe6a5ce421b539344c21afef19",
"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 +4313,53 @@
],
"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.21"
},
- "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": "2023-02-16T09:33:00+00:00"
},
{
"name": "symfony/http-foundation",
- "version": "v5.3.3",
+ "version": "v5.4.21",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-foundation.git",
- "reference": "0e45ab1574caa0460d9190871a8ce47539e40ccf"
+ "reference": "3bb6ee5582366c4176d5ce596b380117c8200bbf"
},
"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/3bb6ee5582366c4176d5ce596b380117c8200bbf",
+ "reference": "3bb6ee5582366c4176d5ce596b380117c8200bbf",
"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/dependency-injection": "^5.4|^6.0",
+ "symfony/expression-language": "^4.4|^5.0|^6.0",
+ "symfony/http-kernel": "^5.4.12|^6.0.12|^6.1.4",
+ "symfony/mime": "^4.4|^5.0|^6.0",
+ "symfony/rate-limiter": "^5.2|^6.0"
},
"suggest": {
"symfony/mime": "To use the file extension guesser"
@@ -3293,36 +4389,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.21"
+ },
+ "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": "2023-02-17T21:35:35+00:00"
},
{
"name": "symfony/http-kernel",
- "version": "v5.3.3",
+ "version": "v5.4.21",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-kernel.git",
- "reference": "90ad9f4b21ddcb8ebe9faadfcca54929ad23f9f8"
+ "reference": "09c19fc7e4218fbcf73fe0330eea38d66064b775"
},
"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/09c19fc7e4218fbcf73fe0330eea38d66064b775",
+ "reference": "09c19fc7e4218fbcf73fe0330eea38d66064b775",
"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.4.21|^6.2.7",
"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 +4450,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,42 +4501,60 @@
],
"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.21"
+ },
+ "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": "2023-02-28T13:19:09+00:00"
},
{
"name": "symfony/mime",
- "version": "v5.3.2",
+ "version": "v5.4.21",
"source": {
"type": "git",
"url": "https://github.com/symfony/mime.git",
- "reference": "47dd7912152b82d0d4c8d9040dbc93d6232d472a"
+ "reference": "ef57d9fb9cdd5e6b2ffc567d109865d10b6920cd"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/mime/zipball/47dd7912152b82d0d4c8d9040dbc93d6232d472a",
- "reference": "47dd7912152b82d0d4c8d9040dbc93d6232d472a",
+ "url": "https://api.github.com/repos/symfony/mime/zipball/ef57d9fb9cdd5e6b2ffc567d109865d10b6920cd",
+ "reference": "ef57d9fb9cdd5e6b2ffc567d109865d10b6920cd",
"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",
"phpdocumentor/reflection-docblock": "<3.2.2",
"phpdocumentor/type-resolver": "<1.4.0",
- "symfony/mailer": "<4.4"
+ "symfony/mailer": "<4.4",
+ "symfony/serializer": "<5.4.14|>=6.0,<6.0.14|>=6.1,<6.1.6"
},
"require-dev": {
- "egulias/email-validator": "^2.1.10|^3.1",
+ "egulias/email-validator": "^2.1.10|^3.1|^4",
"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.4.14|~6.0.14|^6.1.6"
},
"type": "library",
"autoload": {
@@ -3454,32 +4585,52 @@
"mime",
"mime-type"
],
- "time": "2021-06-09T10:58:01+00:00"
+ "support": {
+ "source": "https://github.com/symfony/mime/tree/v5.4.21"
+ },
+ "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": "2023-02-21T19:46:44+00:00"
},
{
"name": "symfony/polyfill-ctype",
- "version": "v1.23.0",
+ "version": "v1.27.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
- "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce"
+ "reference": "5bbc823adecdae860bb64756d639ecfec17b050a"
},
"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/5bbc823adecdae860bb64756d639ecfec17b050a",
+ "reference": "5bbc823adecdae860bb64756d639ecfec17b050a",
"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.27-dev"
},
"thanks": {
"name": "symfony/polyfill",
@@ -3487,12 +4638,12 @@
}
},
"autoload": {
- "psr-4": {
- "Symfony\\Polyfill\\Ctype\\": ""
- },
"files": [
"bootstrap.php"
- ]
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Ctype\\": ""
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -3516,32 +4667,52 @@
"polyfill",
"portable"
],
- "time": "2021-02-19T12:13:01+00:00"
+ "support": {
+ "source": "https://github.com/symfony/polyfill-ctype/tree/v1.27.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-11-03T14:55:06+00:00"
},
{
"name": "symfony/polyfill-iconv",
- "version": "v1.23.0",
+ "version": "v1.27.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-iconv.git",
- "reference": "63b5bb7db83e5673936d6e3b8b3e022ff6474933"
+ "reference": "927013f3aac555983a5059aada98e1907d842695"
},
"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/927013f3aac555983a5059aada98e1907d842695",
+ "reference": "927013f3aac555983a5059aada98e1907d842695",
"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.27-dev"
},
"thanks": {
"name": "symfony/polyfill",
@@ -3549,12 +4720,12 @@
}
},
"autoload": {
- "psr-4": {
- "Symfony\\Polyfill\\Iconv\\": ""
- },
"files": [
"bootstrap.php"
- ]
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Iconv\\": ""
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -3579,20 +4750,37 @@
"portable",
"shim"
],
- "time": "2021-05-27T09:27:20+00:00"
+ "support": {
+ "source": "https://github.com/symfony/polyfill-iconv/tree/v1.27.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-11-03T14:55:06+00:00"
},
{
"name": "symfony/polyfill-intl-grapheme",
- "version": "v1.23.0",
+ "version": "v1.27.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-grapheme.git",
- "reference": "24b72c6baa32c746a4d0840147c9715e42bb68ab"
+ "reference": "511a08c03c1960e08a883f4cffcacd219b758354"
},
"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/511a08c03c1960e08a883f4cffcacd219b758354",
+ "reference": "511a08c03c1960e08a883f4cffcacd219b758354",
"shasum": ""
},
"require": {
@@ -3604,7 +4792,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "1.23-dev"
+ "dev-main": "1.27-dev"
},
"thanks": {
"name": "symfony/polyfill",
@@ -3612,12 +4800,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 +4831,37 @@
"portable",
"shim"
],
- "time": "2021-05-27T09:17:38+00:00"
+ "support": {
+ "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.27.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-11-03T14:55:06+00:00"
},
{
"name": "symfony/polyfill-intl-idn",
- "version": "v1.23.0",
+ "version": "v1.27.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-idn.git",
- "reference": "65bd267525e82759e7d8c4e8ceea44f398838e65"
+ "reference": "639084e360537a19f9ee352433b84ce831f3d2da"
},
"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/639084e360537a19f9ee352433b84ce831f3d2da",
+ "reference": "639084e360537a19f9ee352433b84ce831f3d2da",
"shasum": ""
},
"require": {
@@ -3670,7 +4875,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "1.23-dev"
+ "dev-main": "1.27-dev"
},
"thanks": {
"name": "symfony/polyfill",
@@ -3678,12 +4883,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 +4918,37 @@
"portable",
"shim"
],
- "time": "2021-05-27T09:27:20+00:00"
+ "support": {
+ "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.27.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-11-03T14:55:06+00:00"
},
{
"name": "symfony/polyfill-intl-normalizer",
- "version": "v1.23.0",
+ "version": "v1.27.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-normalizer.git",
- "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8"
+ "reference": "19bd1e4fcd5b91116f14d8533c57831ed00571b6"
},
"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/19bd1e4fcd5b91116f14d8533c57831ed00571b6",
+ "reference": "19bd1e4fcd5b91116f14d8533c57831ed00571b6",
"shasum": ""
},
"require": {
@@ -3738,7 +4960,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "1.23-dev"
+ "dev-main": "1.27-dev"
},
"thanks": {
"name": "symfony/polyfill",
@@ -3746,12 +4968,12 @@
}
},
"autoload": {
- "psr-4": {
- "Symfony\\Polyfill\\Intl\\Normalizer\\": ""
- },
"files": [
"bootstrap.php"
],
+ "psr-4": {
+ "Symfony\\Polyfill\\Intl\\Normalizer\\": ""
+ },
"classmap": [
"Resources/stubs"
]
@@ -3780,32 +5002,52 @@
"portable",
"shim"
],
- "time": "2021-02-19T12:13:01+00:00"
+ "support": {
+ "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.27.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-11-03T14:55:06+00:00"
},
{
"name": "symfony/polyfill-mbstring",
- "version": "v1.23.0",
+ "version": "v1.27.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
- "reference": "2df51500adbaebdc4c38dea4c89a2e131c45c8a1"
+ "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534"
},
"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/8ad114f6b39e2c98a8b0e3bd907732c207c2b534",
+ "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534",
"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.27-dev"
},
"thanks": {
"name": "symfony/polyfill",
@@ -3813,12 +5055,12 @@
}
},
"autoload": {
- "psr-4": {
- "Symfony\\Polyfill\\Mbstring\\": ""
- },
"files": [
"bootstrap.php"
- ]
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Mbstring\\": ""
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -3843,20 +5085,37 @@
"portable",
"shim"
],
- "time": "2021-05-27T09:27:20+00:00"
+ "support": {
+ "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.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-11-03T14:55:06+00:00"
},
{
"name": "symfony/polyfill-php72",
- "version": "v1.23.0",
+ "version": "v1.27.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php72.git",
- "reference": "9a142215a36a3888e30d0a9eeea9766764e96976"
+ "reference": "869329b1e9894268a8a61dabb69153029b7a8c97"
},
"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/869329b1e9894268a8a61dabb69153029b7a8c97",
+ "reference": "869329b1e9894268a8a61dabb69153029b7a8c97",
"shasum": ""
},
"require": {
@@ -3865,7 +5124,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "1.23-dev"
+ "dev-main": "1.27-dev"
},
"thanks": {
"name": "symfony/polyfill",
@@ -3873,12 +5132,12 @@
}
},
"autoload": {
- "psr-4": {
- "Symfony\\Polyfill\\Php72\\": ""
- },
"files": [
"bootstrap.php"
- ]
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Php72\\": ""
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -3902,20 +5161,37 @@
"portable",
"shim"
],
- "time": "2021-05-27T09:17:38+00:00"
+ "support": {
+ "source": "https://github.com/symfony/polyfill-php72/tree/v1.27.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-11-03T14:55:06+00:00"
},
{
"name": "symfony/polyfill-php73",
- "version": "v1.23.0",
+ "version": "v1.27.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php73.git",
- "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010"
+ "reference": "9e8ecb5f92152187c4799efd3c96b78ccab18ff9"
},
"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/9e8ecb5f92152187c4799efd3c96b78ccab18ff9",
+ "reference": "9e8ecb5f92152187c4799efd3c96b78ccab18ff9",
"shasum": ""
},
"require": {
@@ -3924,7 +5200,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "1.23-dev"
+ "dev-main": "1.27-dev"
},
"thanks": {
"name": "symfony/polyfill",
@@ -3932,12 +5208,12 @@
}
},
"autoload": {
- "psr-4": {
- "Symfony\\Polyfill\\Php73\\": ""
- },
"files": [
"bootstrap.php"
],
+ "psr-4": {
+ "Symfony\\Polyfill\\Php73\\": ""
+ },
"classmap": [
"Resources/stubs"
]
@@ -3964,20 +5240,37 @@
"portable",
"shim"
],
- "time": "2021-02-19T12:13:01+00:00"
+ "support": {
+ "source": "https://github.com/symfony/polyfill-php73/tree/v1.27.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-11-03T14:55:06+00:00"
},
{
"name": "symfony/polyfill-php80",
- "version": "v1.23.0",
+ "version": "v1.27.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php80.git",
- "reference": "eca0bf41ed421bed1b57c4958bab16aa86b757d0"
+ "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936"
},
"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/7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936",
+ "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936",
"shasum": ""
},
"require": {
@@ -3986,7 +5279,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "1.23-dev"
+ "dev-main": "1.27-dev"
},
"thanks": {
"name": "symfony/polyfill",
@@ -3994,12 +5287,12 @@
}
},
"autoload": {
- "psr-4": {
- "Symfony\\Polyfill\\Php80\\": ""
- },
"files": [
"bootstrap.php"
],
+ "psr-4": {
+ "Symfony\\Polyfill\\Php80\\": ""
+ },
"classmap": [
"Resources/stubs"
]
@@ -4030,25 +5323,121 @@
"portable",
"shim"
],
- "time": "2021-02-19T12:13:01+00:00"
+ "support": {
+ "source": "https://github.com/symfony/polyfill-php80/tree/v1.27.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-11-03T14:55:06+00:00"
+ },
+ {
+ "name": "symfony/polyfill-php81",
+ "version": "v1.27.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-php81.git",
+ "reference": "707403074c8ea6e2edaf8794b0157a0bfa52157a"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/707403074c8ea6e2edaf8794b0157a0bfa52157a",
+ "reference": "707403074c8ea6e2edaf8794b0157a0bfa52157a",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.1"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "1.27-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.27.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-11-03T14:55:06+00:00"
},
{
"name": "symfony/process",
- "version": "v5.3.2",
+ "version": "v5.4.21",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
- "reference": "714b47f9196de61a196d86c4bad5f09201b307df"
+ "reference": "d4ce417ebcb0b7d090b4c178ed6d3accc518e8bd"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/process/zipball/714b47f9196de61a196d86c4bad5f09201b307df",
- "reference": "714b47f9196de61a196d86c4bad5f09201b307df",
+ "url": "https://api.github.com/repos/symfony/process/zipball/d4ce417ebcb0b7d090b4c178ed6d3accc518e8bd",
+ "reference": "d4ce417ebcb0b7d090b4c178ed6d3accc518e8bd",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
- "symfony/polyfill-php80": "^1.15"
+ "symfony/polyfill-php80": "^1.16"
},
"type": "library",
"autoload": {
@@ -4075,26 +5464,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.21"
+ },
+ "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": "2023-02-21T19:46:44+00:00"
},
{
"name": "symfony/routing",
- "version": "v5.3.0",
+ "version": "v5.4.21",
"source": {
"type": "git",
"url": "https://github.com/symfony/routing.git",
- "reference": "368e81376a8e049c37cb80ae87dbfbf411279199"
+ "reference": "2ea0f3049076e8ef96eab203a809d6b2332f0361"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/routing/zipball/368e81376a8e049c37cb80ae87dbfbf411279199",
- "reference": "368e81376a8e049c37cb80ae87dbfbf411279199",
+ "url": "https://api.github.com/repos/symfony/routing/zipball/2ea0f3049076e8ef96eab203a809d6b2332f0361",
+ "reference": "2ea0f3049076e8ef96eab203a809d6b2332f0361",
"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",
@@ -4103,13 +5509,13 @@
"symfony/yaml": "<4.4"
},
"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"
+ "doctrine/annotations": "^1.12|^2",
+ "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 +5554,46 @@
"uri",
"url"
],
- "time": "2021-05-26T17:43:10+00:00"
+ "support": {
+ "source": "https://github.com/symfony/routing/tree/v5.4.21"
+ },
+ "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": "2023-02-16T09:33:00+00:00"
},
{
"name": "symfony/service-contracts",
- "version": "v2.4.0",
+ "version": "v2.5.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/service-contracts.git",
- "reference": "f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb"
+ "reference": "4b426aac47d6427cc1a1d0f7e2ac724627f5966c"
},
"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/4b426aac47d6427cc1a1d0f7e2ac724627f5966c",
+ "reference": "4b426aac47d6427cc1a1d0f7e2ac724627f5966c",
"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 +5601,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "2.4-dev"
+ "dev-main": "2.5-dev"
},
"thanks": {
"name": "symfony/contracts",
@@ -4210,20 +5637,37 @@
"interoperability",
"standards"
],
- "time": "2021-04-01T10:43:52+00:00"
+ "support": {
+ "source": "https://github.com/symfony/service-contracts/tree/v2.5.2"
+ },
+ "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-30T19:17:29+00:00"
},
{
"name": "symfony/string",
- "version": "v5.3.3",
+ "version": "v5.4.21",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
- "reference": "bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1"
+ "reference": "edac10d167b78b1d90f46a80320d632de0bd9f2f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/string/zipball/bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1",
- "reference": "bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1",
+ "url": "https://api.github.com/repos/symfony/string/zipball/edac10d167b78b1d90f46a80320d632de0bd9f2f",
+ "reference": "edac10d167b78b1d90f46a80320d632de0bd9f2f",
"shasum": ""
},
"require": {
@@ -4234,20 +5678,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 +5723,49 @@
"utf-8",
"utf8"
],
- "time": "2021-06-27T11:44:38+00:00"
+ "support": {
+ "source": "https://github.com/symfony/string/tree/v5.4.21"
+ },
+ "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": "2023-02-22T08:00:55+00:00"
},
{
"name": "symfony/translation",
- "version": "v5.3.3",
+ "version": "v5.4.21",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation.git",
- "reference": "380b8c9e944d0e364b25f28e8e555241eb49c01c"
+ "reference": "6996affeea65705086939894b77110e9a7f80874"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/translation/zipball/380b8c9e944d0e364b25f28e8e555241eb49c01c",
- "reference": "380b8c9e944d0e364b25f28e8e555241eb49c01c",
+ "url": "https://api.github.com/repos/symfony/translation/zipball/6996affeea65705086939894b77110e9a7f80874",
+ "reference": "6996affeea65705086939894b77110e9a7f80874",
"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 +5775,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 +5820,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.21"
+ },
+ "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": "2023-02-21T19:46:44+00:00"
},
{
"name": "symfony/translation-contracts",
- "version": "v2.4.0",
+ "version": "v2.5.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation-contracts.git",
- "reference": "95c812666f3e91db75385749fe219c5e494c7f95"
+ "reference": "136b19dd05cdf0709db6537d058bcab6dd6e2dbe"
},
"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/136b19dd05cdf0709db6537d058bcab6dd6e2dbe",
+ "reference": "136b19dd05cdf0709db6537d058bcab6dd6e2dbe",
"shasum": ""
},
"require": {
@@ -4379,7 +5862,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "2.4-dev"
+ "dev-main": "2.5-dev"
},
"thanks": {
"name": "symfony/contracts",
@@ -4415,26 +5898,43 @@
"interoperability",
"standards"
],
- "time": "2021-03-23T23:28:01+00:00"
+ "support": {
+ "source": "https://github.com/symfony/translation-contracts/tree/v2.5.2"
+ },
+ "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-27T16:58:25+00:00"
},
{
"name": "symfony/var-dumper",
- "version": "v5.3.3",
+ "version": "v5.4.21",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-dumper.git",
- "reference": "46aa709affb9ad3355bd7a810f9662d71025c384"
+ "reference": "6c5ac3a1be8b849d59a1a77877ee110e1b55eb74"
},
"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/6c5ac3a1be8b849d59a1a77877ee110e1b55eb74",
+ "reference": "6c5ac3a1be8b849d59a1a77877ee110e1b55eb74",
"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 +5942,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 +5987,47 @@
"debug",
"dump"
],
- "time": "2021-06-24T08:13:00+00:00"
+ "support": {
+ "source": "https://github.com/symfony/var-dumper/tree/v5.4.21"
+ },
+ "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": "2023-02-23T10:00:28+00:00"
},
{
"name": "tijsverkoyen/css-to-inline-styles",
- "version": "2.2.3",
+ "version": "2.2.6",
"source": {
"type": "git",
"url": "https://github.com/tijsverkoyen/CssToInlineStyles.git",
- "reference": "b43b05cf43c1b6d849478965062b6ef73e223bb5"
+ "reference": "c42125b83a4fa63b187fdf29f9c93cb7733da30c"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/tijsverkoyen/CssToInlineStyles/zipball/b43b05cf43c1b6d849478965062b6ef73e223bb5",
- "reference": "b43b05cf43c1b6d849478965062b6ef73e223bb5",
+ "url": "https://api.github.com/repos/tijsverkoyen/CssToInlineStyles/zipball/c42125b83a4fa63b187fdf29f9c93cb7733da30c",
+ "reference": "c42125b83a4fa63b187fdf29f9c93cb7733da30c",
"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,43 +6053,51 @@
],
"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.6"
+ },
+ "time": "2023-01-03T09:29:04+00:00"
},
{
"name": "vlucas/phpdotenv",
- "version": "v5.3.0",
+ "version": "v5.5.0",
"source": {
"type": "git",
"url": "https://github.com/vlucas/phpdotenv.git",
- "reference": "b3eac5c7ac896e52deab4a99068e3f4ab12d9e56"
+ "reference": "1a7ea2afc49c3ee6d87061f5a233e3a035d0eae7"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/b3eac5c7ac896e52deab4a99068e3f4ab12d9e56",
- "reference": "b3eac5c7ac896e52deab4a99068e3f4ab12d9e56",
+ "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/1a7ea2afc49c3ee6d87061f5a233e3a035d0eae7",
+ "reference": "1a7ea2afc49c3ee6d87061f5a233e3a035d0eae7",
"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.30 || ^9.5.25"
},
"suggest": {
"ext-filter": "Required to use the boolean validator."
},
"type": "library",
"extra": {
+ "bamarni-bin": {
+ "bin-links": true,
+ "forward-command": true
+ },
"branch-alias": {
- "dev-master": "5.3-dev"
+ "dev-master": "5.5-dev"
}
},
"autoload": {
@@ -4586,13 +6112,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 +6127,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.5.0"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/GrahamCampbell",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-10-16T01:01:54+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 +6189,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 +6317,62 @@
"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.7.0",
"source": {
"type": "git",
- "url": "https://github.com/composer/package-versions-deprecated.git",
- "reference": "c6522afe5540d5fc46675043d3ed5a45a740b27c"
+ "url": "https://github.com/barryvdh/laravel-debugbar.git",
+ "reference": "3372ed65e6d2039d663ed19aa699956f9d346271"
},
"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/3372ed65e6d2039d663ed19aa699956f9d346271",
+ "reference": "3372ed65e6d2039d663ed19aa699956f9d346271",
"shasum": ""
},
"require": {
- "composer-plugin-api": "^1.1.0 || ^2.0",
- "php": "^7 || ^8"
- },
- "replace": {
- "ocramius/package-versions": "1.11.99"
+ "illuminate/routing": "^7|^8|^9",
+ "illuminate/session": "^7|^8|^9",
+ "illuminate/support": "^7|^8|^9",
+ "maximebf/debugbar": "^1.17.2",
+ "php": ">=7.2.5",
+ "symfony/finder": "^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": "^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 +6381,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.7.0"
+ },
+ "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-07-11T09:26:42+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 +6482,61 @@
"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.6.1",
"source": {
"type": "git",
"url": "https://github.com/doctrine/dbal.git",
- "reference": "8e0fde2b90e3f61361013d1e928621beeea07bc0"
+ "reference": "57815c7bbcda3cd18871d253c1dd8cbe56f8526e"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/doctrine/dbal/zipball/8e0fde2b90e3f61361013d1e928621beeea07bc0",
- "reference": "8e0fde2b90e3f61361013d1e928621beeea07bc0",
+ "url": "https://api.github.com/repos/doctrine/dbal/zipball/57815c7bbcda3cd18871d253c1dd8cbe56f8526e",
+ "reference": "57815c7bbcda3cd18871d253c1dd8cbe56f8526e",
"shasum": ""
},
"require": {
- "composer/package-versions-deprecated": "^1.11.99",
- "doctrine/cache": "^1.0|^2.0",
- "doctrine/deprecations": "^0.5.3",
- "doctrine/event-manager": "^1.0",
- "php": "^7.3 || ^8.0"
+ "composer-runtime-api": "^2",
+ "doctrine/cache": "^1.11|^2.0",
+ "doctrine/deprecations": "^0.5.3|^1",
+ "doctrine/event-manager": "^1|^2",
+ "php": "^7.4 || ^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",
- "symfony/cache": "^5.2|^6.0",
- "symfony/console": "^2.0.5|^3.0|^4.0|^5.0|^6.0",
- "vimeo/psalm": "4.6.4"
+ "doctrine/coding-standard": "11.1.0",
+ "fig/log-test": "^1",
+ "jetbrains/phpstorm-stubs": "2022.3",
+ "phpstan/phpstan": "1.10.3",
+ "phpstan/phpstan-strict-rules": "^1.5",
+ "phpunit/phpunit": "9.6.4",
+ "psalm/plugin-phpunit": "0.18.4",
+ "squizlabs/php_codesniffer": "3.7.2",
+ "symfony/cache": "^5.4|^6.0",
+ "symfony/console": "^4.4|^5.4|^6.0",
+ "vimeo/psalm": "4.30.0"
},
"suggest": {
"symfony/console": "For helpful console commands such as SQL execution and import of files."
@@ -4932,29 +6594,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.6.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%2Fdbal",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2023-03-02T19:26:24+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,41 +6651,43 @@
],
"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",
- "version": "1.1.1",
+ "version": "1.2.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/event-manager.git",
- "reference": "41370af6a30faa9dc0368c4a6814d596e81aba7f"
+ "reference": "95aa4cb529f1e96576f3fda9f5705ada4056a520"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/doctrine/event-manager/zipball/41370af6a30faa9dc0368c4a6814d596e81aba7f",
- "reference": "41370af6a30faa9dc0368c4a6814d596e81aba7f",
+ "url": "https://api.github.com/repos/doctrine/event-manager/zipball/95aa4cb529f1e96576f3fda9f5705ada4056a520",
+ "reference": "95aa4cb529f1e96576f3fda9f5705ada4056a520",
"shasum": ""
},
"require": {
+ "doctrine/deprecations": "^0.5.3 || ^1",
"php": "^7.1 || ^8.0"
},
"conflict": {
- "doctrine/common": "<2.9@dev"
+ "doctrine/common": "<2.9"
},
"require-dev": {
- "doctrine/coding-standard": "^6.0",
- "phpunit/phpunit": "^7.0"
+ "doctrine/coding-standard": "^9 || ^10",
+ "phpstan/phpstan": "~1.4.10 || ^1.8.8",
+ "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
+ "vimeo/psalm": "^4.24"
},
"type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.0.x-dev"
- }
- },
"autoload": {
"psr-4": {
- "Doctrine\\Common\\": "lib/Doctrine/Common"
+ "Doctrine\\Common\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
@@ -5047,33 +6729,52 @@
"event system",
"events"
],
- "time": "2020-05-29T18:28:51+00:00"
+ "support": {
+ "issues": "https://github.com/doctrine/event-manager/issues",
+ "source": "https://github.com/doctrine/event-manager/tree/1.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%2Fevent-manager",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-10-12T20:51:15+00:00"
},
{
"name": "doctrine/instantiator",
- "version": "1.4.0",
+ "version": "1.5.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/instantiator.git",
- "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b"
+ "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/doctrine/instantiator/zipball/d56bf6102915de5702778fe20f2de3b2fe570b5b",
- "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b",
+ "url": "https://api.github.com/repos/doctrine/instantiator/zipball/0a0fa9780f5d4e507415a065172d26a98d02047b",
+ "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"require-dev": {
- "doctrine/coding-standard": "^8.0",
+ "doctrine/coding-standard": "^9 || ^11",
"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.30 || ^5.4"
},
"type": "library",
"autoload": {
@@ -5098,20 +6799,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.5.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%2Finstantiator",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-12-30T00:15:36+00:00"
},
{
"name": "facade/flare-client-php",
- "version": "1.8.1",
+ "version": "1.10.0",
"source": {
"type": "git",
"url": "https://github.com/facade/flare-client-php.git",
- "reference": "47b639dc02bcfdfc4ebb83de703856fa01e35f5f"
+ "reference": "213fa2c69e120bca4c51ba3e82ed1834ef3f41b8"
},
"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/213fa2c69e120bca4c51ba3e82ed1834ef3f41b8",
+ "reference": "213fa2c69e120bca4c51ba3e82ed1834ef3f41b8",
"shasum": ""
},
"require": {
@@ -5124,7 +6843,7 @@
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.14",
- "phpunit/phpunit": "^7.5.16",
+ "phpunit/phpunit": "^7.5",
"spatie/phpunit-snapshot-assertions": "^2.0"
},
"type": "library",
@@ -5134,12 +6853,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 +6872,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.10.0"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/spatie",
+ "type": "github"
+ }
+ ],
+ "time": "2022-08-09T11:23:57+00:00"
},
{
"name": "facade/ignition",
- "version": "2.11.0",
+ "version": "2.17.7",
"source": {
"type": "git",
"url": "https://github.com/facade/ignition.git",
- "reference": "dc6818335f50ccf0b90284784718ea9a82604286"
+ "reference": "b4f5955825bb4b74cba0f94001761c46335c33e9"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/facade/ignition/zipball/dc6818335f50ccf0b90284784718ea9a82604286",
- "reference": "dc6818335f50ccf0b90284784718ea9a82604286",
+ "url": "https://api.github.com/repos/facade/ignition/zipball/b4f5955825bb4b74cba0f94001761c46335c33e9",
+ "reference": "b4f5955825bb4b74cba0f94001761c46335c33e9",
"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 +6912,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 +6935,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 +6954,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": "2023-01-26T12:34:59+00:00"
},
{
"name": "facade/ignition-contracts",
@@ -5272,25 +7009,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.15.1",
"source": {
"type": "git",
"url": "https://github.com/filp/whoops.git",
- "reference": "2edbc73a4687d9085c8f20f398eebade844e8424"
+ "reference": "e864ac957acd66e1565f25efda61e37791a5db0b"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/filp/whoops/zipball/2edbc73a4687d9085c8f20f398eebade844e8424",
- "reference": "2edbc73a4687d9085c8f20f398eebade844e8424",
+ "url": "https://api.github.com/repos/filp/whoops/zipball/e864ac957acd66e1565f25efda61e37791a5db0b",
+ "reference": "e864ac957acd66e1565f25efda61e37791a5db0b",
"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 +7074,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.15.1"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/denis-sokolov",
+ "type": "github"
+ }
+ ],
+ "time": "2023-03-06T18:09:13+00:00"
},
{
"name": "fzaninotto/faker",
@@ -5383,6 +7134,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"
},
@@ -5431,20 +7186,90 @@
"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.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/maximebf/php-debugbar.git",
+ "reference": "17dcf3f6ed112bb85a37cf13538fd8de49f5c274"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/17dcf3f6ed112bb85a37cf13538fd8de49f5c274",
+ "reference": "17dcf3f6ed112bb85a37cf13538fd8de49f5c274",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.1|^8",
+ "psr/log": "^1|^2|^3",
+ "symfony/var-dumper": "^4|^5|^6"
+ },
+ "require-dev": {
+ "phpunit/phpunit": ">=7.5.20 <10.0",
+ "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": "1.18-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "DebugBar\\": "src/DebugBar/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "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": [
+ "debug",
+ "debugbar"
+ ],
+ "support": {
+ "issues": "https://github.com/maximebf/php-debugbar/issues",
+ "source": "https://github.com/maximebf/php-debugbar/tree/v1.18.2"
+ },
+ "time": "2023-02-04T15:27:00+00:00"
+ },
{
"name": "mockery/mockery",
- "version": "1.4.3",
+ "version": "1.5.1",
"source": {
"type": "git",
"url": "https://github.com/mockery/mockery.git",
- "reference": "d1339f64479af1bee0e82a0413813fe5345a54ea"
+ "reference": "e92dcc83d5a51851baf5f5591d32cb2b16e3684e"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/mockery/mockery/zipball/d1339f64479af1bee0e82a0413813fe5345a54ea",
- "reference": "d1339f64479af1bee0e82a0413813fe5345a54ea",
+ "url": "https://api.github.com/repos/mockery/mockery/zipball/e92dcc83d5a51851baf5f5591d32cb2b16e3684e",
+ "reference": "e92dcc83d5a51851baf5f5591d32cb2b16e3684e",
"shasum": ""
},
"require": {
@@ -5499,41 +7324,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.1"
+ },
+ "time": "2022-09-07T15:32:08+00:00"
},
{
"name": "myclabs/deep-copy",
- "version": "1.10.2",
+ "version": "1.11.1",
"source": {
"type": "git",
"url": "https://github.com/myclabs/DeepCopy.git",
- "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220"
+ "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/776f831124e9c62e1a2c601ecc52e776d8bb7220",
- "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220",
+ "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c",
+ "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c",
"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,263 +7377,60 @@
"object",
"object graph"
],
- "time": "2020-11-13T09:40:50+00:00"
- },
- {
- "name": "nunomaduro/collision",
- "version": "v5.5.0",
- "source": {
- "type": "git",
- "url": "https://github.com/nunomaduro/collision.git",
- "reference": "b5cb36122f1c142c3c3ee20a0ae778439ef0244b"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/nunomaduro/collision/zipball/b5cb36122f1c142c3c3ee20a0ae778439ef0244b",
- "reference": "b5cb36122f1c142c3c3ee20a0ae778439ef0244b",
- "shasum": ""
- },
- "require": {
- "facade/ignition-contracts": "^1.0",
- "filp/whoops": "^2.7.2",
- "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",
- "nunomaduro/larastan": "^0.6.2",
- "nunomaduro/mock-final-classes": "^1.0",
- "orchestra/testbench": "^7.0",
- "phpstan/phpstan": "^0.12.64",
- "phpunit/phpunit": "^9.5.0"
- },
- "type": "library",
- "extra": {
- "laravel": {
- "providers": [
- "NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider"
- ]
- }
- },
- "autoload": {
- "psr-4": {
- "NunoMaduro\\Collision\\": "src/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Nuno Maduro",
- "email": "enunomaduro@gmail.com"
- }
- ],
- "description": "Cli error handling for console/command-line PHP applications.",
- "keywords": [
- "artisan",
- "cli",
- "command-line",
- "console",
- "error",
- "handling",
- "laravel",
- "laravel-zero",
- "php",
- "symfony"
- ],
- "time": "2021-06-22T20:47:22+00:00"
- },
- {
- "name": "phar-io/manifest",
- "version": "2.0.1",
- "source": {
- "type": "git",
- "url": "https://github.com/phar-io/manifest.git",
- "reference": "85265efd3af7ba3ca4b2a2c34dbfc5788dd29133"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/phar-io/manifest/zipball/85265efd3af7ba3ca4b2a2c34dbfc5788dd29133",
- "reference": "85265efd3af7ba3ca4b2a2c34dbfc5788dd29133",
- "shasum": ""
- },
- "require": {
- "ext-dom": "*",
- "ext-phar": "*",
- "ext-xmlwriter": "*",
- "phar-io/version": "^3.0.1",
- "php": "^7.2 || ^8.0"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.0.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Arne Blankerts",
- "email": "arne@blankerts.de",
- "role": "Developer"
- },
- {
- "name": "Sebastian Heuer",
- "email": "sebastian@phpeople.de",
- "role": "Developer"
- },
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de",
- "role": "Developer"
- }
- ],
- "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)",
- "time": "2020-06-27T14:33:11+00:00"
- },
- {
- "name": "phar-io/version",
- "version": "3.1.0",
- "source": {
- "type": "git",
- "url": "https://github.com/phar-io/version.git",
- "reference": "bae7c545bef187884426f042434e561ab1ddb182"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/phar-io/version/zipball/bae7c545bef187884426f042434e561ab1ddb182",
- "reference": "bae7c545bef187884426f042434e561ab1ddb182",
- "shasum": ""
- },
- "require": {
- "php": "^7.2 || ^8.0"
- },
- "type": "library",
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Arne Blankerts",
- "email": "arne@blankerts.de",
- "role": "Developer"
- },
- {
- "name": "Sebastian Heuer",
- "email": "sebastian@phpeople.de",
- "role": "Developer"
- },
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de",
- "role": "Developer"
- }
- ],
- "description": "Library for handling version information and constraints",
- "time": "2021-02-23T14:00:09+00:00"
- },
- {
- "name": "phpdocumentor/reflection-common",
- "version": "2.2.0",
- "source": {
- "type": "git",
- "url": "https://github.com/phpDocumentor/ReflectionCommon.git",
- "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b",
- "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b",
- "shasum": ""
- },
- "require": {
- "php": "^7.2 || ^8.0"
+ "support": {
+ "issues": "https://github.com/myclabs/DeepCopy/issues",
+ "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1"
},
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-2.x": "2.x-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "phpDocumentor\\Reflection\\": "src/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
+ "funding": [
{
- "name": "Jaap van Otterdijk",
- "email": "opensource@ijaap.nl"
+ "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy",
+ "type": "tidelift"
}
],
- "description": "Common reflection classes used by phpdocumentor to reflect the code structure",
- "homepage": "http://www.phpdoc.org",
- "keywords": [
- "FQSEN",
- "phpDocumentor",
- "phpdoc",
- "reflection",
- "static analysis"
- ],
- "time": "2020-06-27T09:03:43+00:00"
+ "time": "2023-03-08T13:26:56+00:00"
},
{
- "name": "phpdocumentor/reflection-docblock",
- "version": "5.2.2",
+ "name": "nunomaduro/collision",
+ "version": "v5.11.0",
"source": {
"type": "git",
- "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
- "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556"
+ "url": "https://github.com/nunomaduro/collision.git",
+ "reference": "8b610eef8582ccdc05d8f2ab23305e2d37049461"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/069a785b2141f5bcf49f3e353548dc1cce6df556",
- "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556",
+ "url": "https://api.github.com/repos/nunomaduro/collision/zipball/8b610eef8582ccdc05d8f2ab23305e2d37049461",
+ "reference": "8b610eef8582ccdc05d8f2ab23305e2d37049461",
"shasum": ""
},
"require": {
- "ext-filter": "*",
- "php": "^7.2 || ^8.0",
- "phpdocumentor/reflection-common": "^2.2",
- "phpdocumentor/type-resolver": "^1.3",
- "webmozart/assert": "^1.9.1"
+ "facade/ignition-contracts": "^1.0",
+ "filp/whoops": "^2.14.3",
+ "php": "^7.3 || ^8.0",
+ "symfony/console": "^5.0"
},
"require-dev": {
- "mockery/mockery": "~1.3.2"
+ "brianium/paratest": "^6.1",
+ "fideloper/proxy": "^4.4.1",
+ "fruitcake/laravel-cors": "^2.0.3",
+ "laravel/framework": "8.x-dev",
+ "nunomaduro/larastan": "^0.6.2",
+ "nunomaduro/mock-final-classes": "^1.0",
+ "orchestra/testbench": "^6.0",
+ "phpstan/phpstan": "^0.12.64",
+ "phpunit/phpunit": "^9.5.0"
},
"type": "library",
"extra": {
- "branch-alias": {
- "dev-master": "5.x-dev"
+ "laravel": {
+ "providers": [
+ "NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider"
+ ]
}
},
"autoload": {
"psr-4": {
- "phpDocumentor\\Reflection\\": "src"
+ "NunoMaduro\\Collision\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
@@ -5812,144 +7439,173 @@
],
"authors": [
{
- "name": "Mike van Riel",
- "email": "me@mikevanriel.com"
+ "name": "Nuno Maduro",
+ "email": "enunomaduro@gmail.com"
+ }
+ ],
+ "description": "Cli error handling for console/command-line PHP applications.",
+ "keywords": [
+ "artisan",
+ "cli",
+ "command-line",
+ "console",
+ "error",
+ "handling",
+ "laravel",
+ "laravel-zero",
+ "php",
+ "symfony"
+ ],
+ "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"
},
{
- "name": "Jaap van Otterdijk",
- "email": "account@ijaap.nl"
+ "url": "https://www.patreon.com/nunomaduro",
+ "type": "patreon"
}
],
- "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"
+ "time": "2022-01-10T16:22:52+00:00"
},
{
- "name": "phpdocumentor/type-resolver",
- "version": "1.4.0",
+ "name": "phar-io/manifest",
+ "version": "2.0.3",
"source": {
"type": "git",
- "url": "https://github.com/phpDocumentor/TypeResolver.git",
- "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0"
+ "url": "https://github.com/phar-io/manifest.git",
+ "reference": "97803eca37d319dfa7826cc2437fc020857acb53"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0",
- "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0",
+ "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53",
+ "reference": "97803eca37d319dfa7826cc2437fc020857acb53",
"shasum": ""
},
"require": {
- "php": "^7.2 || ^8.0",
- "phpdocumentor/reflection-common": "^2.0"
- },
- "require-dev": {
- "ext-tokenizer": "*"
+ "ext-dom": "*",
+ "ext-phar": "*",
+ "ext-xmlwriter": "*",
+ "phar-io/version": "^3.0.1",
+ "php": "^7.2 || ^8.0"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-1.x": "1.x-dev"
+ "dev-master": "2.0.x-dev"
}
},
"autoload": {
- "psr-4": {
- "phpDocumentor\\Reflection\\": "src"
- }
+ "classmap": [
+ "src/"
+ ]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
- "MIT"
+ "BSD-3-Clause"
],
"authors": [
{
- "name": "Mike van Riel",
- "email": "me@mikevanriel.com"
+ "name": "Arne Blankerts",
+ "email": "arne@blankerts.de",
+ "role": "Developer"
+ },
+ {
+ "name": "Sebastian Heuer",
+ "email": "sebastian@phpeople.de",
+ "role": "Developer"
+ },
+ {
+ "name": "Sebastian Bergmann",
+ "email": "sebastian@phpunit.de",
+ "role": "Developer"
}
],
- "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
- "time": "2020-09-17T18:55:26+00:00"
+ "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)",
+ "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": "phpspec/prophecy",
- "version": "1.13.0",
+ "name": "phar-io/version",
+ "version": "3.2.1",
"source": {
"type": "git",
- "url": "https://github.com/phpspec/prophecy.git",
- "reference": "be1996ed8adc35c3fd795488a653f4b518be70ea"
+ "url": "https://github.com/phar-io/version.git",
+ "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpspec/prophecy/zipball/be1996ed8adc35c3fd795488a653f4b518be70ea",
- "reference": "be1996ed8adc35c3fd795488a653f4b518be70ea",
+ "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74",
+ "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74",
"shasum": ""
},
"require": {
- "doctrine/instantiator": "^1.2",
- "php": "^7.2 || ~8.0, <8.1",
- "phpdocumentor/reflection-docblock": "^5.2",
- "sebastian/comparator": "^3.0 || ^4.0",
- "sebastian/recursion-context": "^3.0 || ^4.0"
- },
- "require-dev": {
- "phpspec/phpspec": "^6.0",
- "phpunit/phpunit": "^8.0 || ^9.0"
+ "php": "^7.2 || ^8.0"
},
"type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.11.x-dev"
- }
- },
"autoload": {
- "psr-4": {
- "Prophecy\\": "src/Prophecy"
- }
+ "classmap": [
+ "src/"
+ ]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
- "MIT"
+ "BSD-3-Clause"
],
"authors": [
{
- "name": "Konstantin Kudryashov",
- "email": "ever.zet@gmail.com",
- "homepage": "http://everzet.com"
+ "name": "Arne Blankerts",
+ "email": "arne@blankerts.de",
+ "role": "Developer"
+ },
+ {
+ "name": "Sebastian Heuer",
+ "email": "sebastian@phpeople.de",
+ "role": "Developer"
},
{
- "name": "Marcello Duarte",
- "email": "marcello.duarte@gmail.com"
+ "name": "Sebastian Bergmann",
+ "email": "sebastian@phpunit.de",
+ "role": "Developer"
}
],
- "description": "Highly opinionated mocking framework for PHP 5.3+",
- "homepage": "https://github.com/phpspec/prophecy",
- "keywords": [
- "Double",
- "Dummy",
- "fake",
- "mock",
- "spy",
- "stub"
- ],
- "time": "2021-03-17T13:42:18+00:00"
+ "description": "Library for handling version information and constraints",
+ "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": "phpunit/php-code-coverage",
- "version": "9.2.6",
+ "version": "9.2.26",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
- "reference": "f6293e1b30a2354e8428e004689671b83871edde"
+ "reference": "443bc6912c9bd5b409254a40f4b0f4ced7c80ea1"
},
"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/443bc6912c9bd5b409254a40f4b0f4ced7c80ea1",
+ "reference": "443bc6912c9bd5b409254a40f4b0f4ced7c80ea1",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-libxml": "*",
"ext-xmlwriter": "*",
- "nikic/php-parser": "^4.10.2",
+ "nikic/php-parser": "^4.15",
"php": ">=7.3",
"phpunit/php-file-iterator": "^3.0.3",
"phpunit/php-text-template": "^2.0.2",
@@ -5964,8 +7620,8 @@
"phpunit/phpunit": "^9.3"
},
"suggest": {
- "ext-pcov": "*",
- "ext-xdebug": "*"
+ "ext-pcov": "PHP extension that provides line coverage",
+ "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage"
},
"type": "library",
"extra": {
@@ -5996,20 +7652,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.26"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ }
+ ],
+ "time": "2023-03-06T12:58:08+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 +7712,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 +7775,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 +7834,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,24 +7893,34 @@
"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.6.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
- "reference": "fb9b8333f14e3dce976a60ef6a7e05c7c7ed8bfb"
+ "reference": "86e761949019ae83f49240b2f2123fb5ab3b2fc5"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/fb9b8333f14e3dce976a60ef6a7e05c7c7ed8bfb",
- "reference": "fb9b8333f14e3dce976a60ef6a7e05c7c7ed8bfb",
+ "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/86e761949019ae83f49240b2f2123fb5ab3b2fc5",
+ "reference": "86e761949019ae83f49240b2f2123fb5ab3b2fc5",
"shasum": ""
},
"require": {
- "doctrine/instantiator": "^1.3.1",
+ "doctrine/instantiator": "^1.3.1 || ^2",
"ext-dom": "*",
"ext-json": "*",
"ext-libxml": "*",
@@ -6222,34 +7928,29 @@
"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",
"phpunit/php-timer": "^5.0.2",
"sebastian/cli-parser": "^1.0.1",
"sebastian/code-unit": "^1.0.6",
- "sebastian/comparator": "^4.0.5",
+ "sebastian/comparator": "^4.0.8",
"sebastian/diff": "^4.0.3",
"sebastian/environment": "^5.1.3",
- "sebastian/exporter": "^4.0.3",
+ "sebastian/exporter": "^4.0.5",
"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.2",
"sebastian/version": "^3.0.2"
},
- "require-dev": {
- "ext-pdo": "*",
- "phpspec/prophecy-phpunit": "^2.0.1"
- },
"suggest": {
- "ext-soap": "*",
- "ext-xdebug": "*"
+ "ext-soap": "To be able to generate mocks based on WSDL files",
+ "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage"
},
"bin": [
"phpunit"
@@ -6257,15 +7958,15 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "9.5-dev"
+ "dev-master": "9.6-dev"
}
},
"autoload": {
- "classmap": [
- "src/"
- ],
"files": [
"src/Framework/Assert/Functions.php"
+ ],
+ "classmap": [
+ "src/"
]
},
"notification-url": "https://packagist.org/downloads/",
@@ -6286,7 +7987,74 @@
"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.6.5"
+ },
+ "funding": [
+ {
+ "url": "https://phpunit.de/sponsors.html",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2023-03-09T06:34:10+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 +8113,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 +8163,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 +8219,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,20 +8274,30 @@
],
"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"
},
{
"name": "sebastian/comparator",
- "version": "4.0.6",
+ "version": "4.0.8",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/comparator.git",
- "reference": "55f4261989e546dc112258c7a75935a81a7ce382"
+ "reference": "fa0f136dd2334583309d32b62544682ee972b51a"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/55f4261989e546dc112258c7a75935a81a7ce382",
- "reference": "55f4261989e546dc112258c7a75935a81a7ce382",
+ "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/fa0f136dd2334583309d32b62544682ee972b51a",
+ "reference": "fa0f136dd2334583309d32b62544682ee972b51a",
"shasum": ""
},
"require": {
@@ -6546,7 +8348,17 @@
"compare",
"equality"
],
- "time": "2020-10-26T15:49:45+00:00"
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/comparator/issues",
+ "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.8"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ }
+ ],
+ "time": "2022-09-14T12:41:17+00:00"
},
{
"name": "sebastian/complexity",
@@ -6593,6 +8405,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 +8471,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.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/environment.git",
- "reference": "388b6ced16caa751030f6a69e588299fa09200ac"
+ "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/388b6ced16caa751030f6a69e588299fa09200ac",
- "reference": "388b6ced16caa751030f6a69e588299fa09200ac",
+ "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/830c43a844f1f8d5b7a1f6d6076b784454d8b7ed",
+ "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed",
"shasum": ""
},
"require": {
@@ -6702,20 +8534,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.5"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ }
+ ],
+ "time": "2023-02-03T06:03:51+00:00"
},
{
"name": "sebastian/exporter",
- "version": "4.0.3",
+ "version": "4.0.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/exporter.git",
- "reference": "d89cc98761b8cb5a1a235a6b703ae50d34080e65"
+ "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/d89cc98761b8cb5a1a235a6b703ae50d34080e65",
- "reference": "d89cc98761b8cb5a1a235a6b703ae50d34080e65",
+ "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d",
+ "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d",
"shasum": ""
},
"require": {
@@ -6764,25 +8606,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.5"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ }
+ ],
+ "time": "2022-09-14T06:03:37+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 +8675,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 +8732,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 +8789,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,20 +8844,30 @@
],
"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"
},
{
"name": "sebastian/recursion-context",
- "version": "4.0.4",
+ "version": "4.0.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/recursion-context.git",
- "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172"
+ "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cd9d8cf3c5804de4341c283ed787f099f5506172",
- "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172",
+ "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1",
+ "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1",
"shasum": ""
},
"require": {
@@ -7014,8 +8906,18 @@
}
],
"description": "Provides functionality to recursively process PHP variables",
- "homepage": "http://www.github.com/sebastianbergmann/recursion-context",
- "time": "2020-10-26T13:17:30+00:00"
+ "homepage": "https://github.com/sebastianbergmann/recursion-context",
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/recursion-context/issues",
+ "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.5"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ }
+ ],
+ "time": "2023-02-03T06:07:39+00:00"
},
{
"name": "sebastian/resource-operations",
@@ -7060,32 +8962,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.2.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/type.git",
- "reference": "b8cd8a1c753c90bc1a0f5372170e3e489136f914"
+ "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/b8cd8a1c753c90bc1a0f5372170e3e489136f914",
- "reference": "b8cd8a1c753c90bc1a0f5372170e3e489136f914",
+ "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7",
+ "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7",
"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.2-dev"
}
},
"autoload": {
@@ -7106,7 +9018,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.2.1"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ }
+ ],
+ "time": "2023-02-03T06:13:03+00:00"
},
{
"name": "sebastian/version",
@@ -7149,20 +9071,30 @@
],
"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": "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 +9121,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 +9142,6 @@
"platform": {
"php": "^7.3"
},
- "platform-dev": []
+ "platform-dev": [],
+ "plugin-api-version": "2.3.0"
}
diff --git a/config/UshauriDOD/database.php b/config/UshauriDOD/database.php
new file mode 100644
index 0000000..7ea2ee9
--- /dev/null
+++ b/config/UshauriDOD/database.php
@@ -0,0 +1,29 @@
+ env('DB_CONNECTION', 'mysql'),
+
+ 'connections' => [
+
+ 'mysql' => [
+ 'driver' => 'mysql',
+ 'host' => env('DB_HOST', 'dod_db_host'),
+ 'port' => env('DB_PORT', '3306'),
+ 'database' => env('DB_DATABASE', 'dod_db_name'),
+ 'username' => env('DB_USERNAME', 'dod_db_user'),
+ 'password' => env('DB_PASSWORD', 'dod_db_password'),
+ 'unix_socket' => env('DB_SOCKET', ''),
+ 'charset' => 'utf8mb4',
+ 'collation' => 'utf8mb4_unicode_ci',
+ 'strict' => true,
+ 'engine' => null,
+ ],
+
+ // Other database connections...
+
+ ],
+
+ // ...
+
+];
diff --git a/config/UshauriPublic/database.php b/config/UshauriPublic/database.php
new file mode 100644
index 0000000..9d02098
--- /dev/null
+++ b/config/UshauriPublic/database.php
@@ -0,0 +1,29 @@
+ env('DB_CONNECTION', 'mysql'),
+
+ 'connections' => [
+
+ 'mysql' => [
+ 'driver' => 'mysql',
+ 'host' => env('DB_HOST', 'public_db_host'),
+ 'port' => env('DB_PORT', '3306'),
+ 'database' => env('DB_DATABASE', 'public_db_name'),
+ 'username' => env('DB_USERNAME', 'public_db_user'),
+ 'password' => env('DB_PASSWORD', 'public_db_password'),
+ 'unix_socket' => env('DB_SOCKET', ''),
+ 'charset' => 'utf8mb4',
+ 'collation' => 'utf8mb4_unicode_ci',
+ 'strict' => true,
+ 'engine' => null,
+ ],
+
+ // Other database connections...
+
+ ],
+
+ // ...
+
+];
diff --git a/config/app.php b/config/app.php
index 201f1ce..0b3350d 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,
@@ -235,4 +236,19 @@
],
+ 'config' => [
+ 'app' => env('INSTANCE') . '/app.php',
+ 'auth' => env('INSTANCE') . '/auth.php',
+ 'broadcasting' => env('INSTANCE') . '/broadcasting.php',
+ 'cache' => env('INSTANCE') . '/cache.php',
+ 'database' => env('INSTANCE') . '/database.php',
+ 'filesystems' => env('INSTANCE') . '/filesystems.php',
+ 'mail' => env('INSTANCE') . '/mail.php',
+ 'queue' => env('INSTANCE') . '/queue.php',
+ 'services' => env('INSTANCE') . '/services.php',
+ 'session' => env('INSTANCE') . '/session.php',
+ 'view' => env('INSTANCE') . '/view.php',
+ ],
+
+
];
\ No newline at end of file
diff --git a/config/sweetalert.php b/config/sweetalert.php
new file mode 100644
index 0000000..944c37f
--- /dev/null
+++ b/config/sweetalert.php
@@ -0,0 +1,253 @@
+ env('SWEET_ALERT_THEME', 'default'),
+
+ /*
+ |--------------------------------------------------------------------------
+ | CDN LINK
+ |--------------------------------------------------------------------------
+ | By default SweetAlert2 use its local sweetalert.all.js
+ | file.
+ | However, you can use its cdn if you want.
+ |
+ */
+
+ 'cdn' => env('SWEET_ALERT_CDN'),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Always load the sweetalert.all.js
+ |--------------------------------------------------------------------------
+ | There might be situations where you will always want the sweet alert
+ | js package to be there for you. (for eg. you might use it heavily to
+ | show notifications or you might want to use the native js) then this
+ | might be handy.
+ |
+ */
+
+ 'alwaysLoadJS' => env('SWEET_ALERT_ALWAYS_LOAD_JS', false),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Never load the sweetalert.all.js
+ |--------------------------------------------------------------------------
+ | If you want to handle the sweet alert js package by yourself
+ | (for eg. you might want to use laravel mix) then this can be
+ | handy.
+ | If you set always load js to true & never load js to false,
+ | it's going to prioritize the never load js.
+ |
+ | alwaysLoadJs = true & neverLoadJs = true => js will not be loaded
+ | alwaysLoadJs = true & neverLoadJs = false => js will be loaded
+ | alwaysLoadJs = false & neverLoadJs = false => js will be loaded when
+ | you set alert/toast by using the facade/helper functions.
+ */
+
+ 'neverLoadJS' => env('SWEET_ALERT_NEVER_LOAD_JS', false),
+
+ /*
+ |--------------------------------------------------------------------------
+ | AutoClose Timer
+ |--------------------------------------------------------------------------
+ |
+ | This is for the all Modal windows.
+ | For specific modal just use the autoClose() helper method.
+ |
+ */
+
+ 'timer' => env('SWEET_ALERT_TIMER', 5000),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Width
+ |--------------------------------------------------------------------------
+ |
+ | Modal window width, including paddings (box-sizing: border-box).
+ | Can be in px or %.
+ | The default width is 32rem.
+ | This is for the all Modal windows.
+ | for particular modal just use the width() helper method.
+ */
+
+ 'width' => env('SWEET_ALERT_WIDTH', '32rem'),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Height Auto
+ |--------------------------------------------------------------------------
+ | By default, SweetAlert2 sets html's and body's CSS height to auto !important.
+ | If this behavior isn't compatible with your project's layout,
+ | set heightAuto to false.
+ |
+ */
+
+ 'height_auto' => env('SWEET_ALERT_HEIGHT_AUTO', true),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Padding
+ |--------------------------------------------------------------------------
+ |
+ | Modal window padding.
+ | Can be in px or %.
+ | The default padding is 1.25rem.
+ | This is for the all Modal windows.
+ | for particular modal just use the padding() helper method.
+ */
+
+ 'padding' => env('SWEET_ALERT_PADDING', '1.25rem'),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Background
+ |--------------------------------------------------------------------------
+ |
+ | Modal window background
+ | (CSS background property).
+ | The default background is '#fff'.
+ */
+
+ 'background' => env('SWEET_ALERT_BACKGROUND', '#fff'),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Animation
+ |--------------------------------------------------------------------------
+ | Custom animation with [Animate.css](https://daneden.github.io/animate.css/)
+ | If set to false, modal CSS animation will be use default ones.
+ | For specific modal just use the animation() helper method.
+ |
+ */
+
+ 'animation' => [
+ 'enable' => env('SWEET_ALERT_ANIMATION_ENABLE', false),
+ ],
+
+ 'animatecss' => env('SWEET_ALERT_ANIMATECSS', 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css'),
+
+ /*
+ |--------------------------------------------------------------------------
+ | ShowConfirmButton
+ |--------------------------------------------------------------------------
+ | If set to false, a "Confirm"-button will not be shown.
+ | It can be useful when you're using custom HTML description.
+ | This is for the all Modal windows.
+ | For specific modal just use the showConfirmButton() helper method.
+ |
+ */
+
+ 'show_confirm_button' => env('SWEET_ALERT_CONFIRM_BUTTON', true),
+
+ /*
+ |--------------------------------------------------------------------------
+ | ShowCloseButton
+ |--------------------------------------------------------------------------
+ | If set to true, a "Close"-button will be shown,
+ | which the user can click on to dismiss the modal.
+ | This is for the all Modal windows.
+ | For specific modal just use the showCloseButton() helper method.
+ |
+ */
+
+ 'show_close_button' => env('SWEET_ALERT_CLOSE_BUTTON', false),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Toast position
+ |--------------------------------------------------------------------------
+ | Modal window or toast position, can be 'top',
+ | 'top-start', 'top-end', 'center', 'center-start',
+ | 'center-end', 'bottom', 'bottom-start', or 'bottom-end'.
+ | For specific modal just use the position() helper method.
+ |
+ */
+
+ 'toast_position' => env('SWEET_ALERT_TOAST_POSITION', 'top-end'),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Progress Bar
+ |--------------------------------------------------------------------------
+ | If set to true, a progress bar at the bottom of a popup will be shown.
+ | It can be useful with toasts.
+ |
+ */
+
+ 'timer_progress_bar' => env('SWEET_ALERT_TIMER_PROGRESS_BAR', false),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Middleware
+ |--------------------------------------------------------------------------
+ | Modal window or toast, config for the Middleware
+ |
+ */
+
+ 'middleware' => [
+
+ 'autoClose' => env('SWEET_ALERT_MIDDLEWARE_AUTO_CLOSE', false),
+
+ 'toast_position' => env('SWEET_ALERT_MIDDLEWARE_TOAST_POSITION', 'top-end'),
+
+ 'toast_close_button' => env('SWEET_ALERT_MIDDLEWARE_TOAST_CLOSE_BUTTON', true),
+
+ 'timer' => env('SWEET_ALERT_MIDDLEWARE_ALERT_CLOSE_TIME', 6000),
+
+ 'auto_display_error_messages' => env('SWEET_ALERT_AUTO_DISPLAY_ERROR_MESSAGES', true),
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | Custom Class
+ |--------------------------------------------------------------------------
+ | A custom CSS class for the modal:
+ |
+ */
+
+ 'customClass' => [
+
+ 'container' => env('SWEET_ALERT_CONTAINER_CLASS'),
+ 'popup' => env('SWEET_ALERT_POPUP_CLASS'),
+ 'header' => env('SWEET_ALERT_HEADER_CLASS'),
+ 'title' => env('SWEET_ALERT_TITLE_CLASS'),
+ 'closeButton' => env('SWEET_ALERT_CLOSE_BUTTON_CLASS'),
+ 'icon' => env('SWEET_ALERT_ICON_CLASS'),
+ 'image' => env('SWEET_ALERT_IMAGE_CLASS'),
+ 'content' => env('SWEET_ALERT_CONTENT_CLASS'),
+ 'input' => env('SWEET_ALERT_INPUT_CLASS'),
+ 'actions' => env('SWEET_ALERT_ACTIONS_CLASS'),
+ 'confirmButton' => env('SWEET_ALERT_CONFIRM_BUTTON_CLASS'),
+ 'cancelButton' => env('SWEET_ALERT_CANCEL_BUTTON_CLASS'),
+ 'footer' => env('SWEET_ALERT_FOOTER_CLASS'),
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | confirmDelete
+ |--------------------------------------------------------------------------
+ | customize the configuration options of the confirmation popup.
+ |
+ */
+
+ 'confirm_delete_confirm_button_text' => env('SWEET_ALERT_CONFIRM_DELETE_CONFIRM_BUTTON_TEXT', 'Yes, delete it!'),
+ 'confirm_delete_confirm_button_color' => env('SWEET_ALERT_CONFIRM_DELETE_CONFIRM_BUTTON_COLOR'),
+ 'confirm_delete_cancel_button_color' => env('SWEET_ALERT_CONFIRM_DELETE_CANCEL_BUTTON_COLOR', '#d33'),
+ 'confirm_delete_cancel_button_text' => env('SWEET_ALERT_CONFIRM_DELETE_CANCEL_BUTTON_TEXT', 'Cancel'),
+ 'confirm_delete_show_cancel_button' => env('SWEET_ALERT_CONFIRM_DELETE_SHOW_CANCEL_BUTTON', true),
+ 'confirm_delete_show_close_button' => env('SWEET_ALERT_CONFIRM_DELETE_SHOW_CLOSE_BUTTON', false),
+ 'confirm_delete_icon' => env('SWEET_ALERT_CONFIRM_DELETE_ICON', 'warning'),
+ 'confirm_delete_show_loader_on_confirm' => env('SWEET_ALERT_CONFIRM_DELETE_SHOW_LOADER_ON_CONFIRM', true),
+
+
+];
diff --git a/public/assets/images/DOD_Logo.png b/public/assets/images/DOD_Logo.png
new file mode 100644
index 0000000..b11f4be
Binary files /dev/null and b/public/assets/images/DOD_Logo.png differ
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/public/vendor/sweetalert/sweetalert.all.js b/public/vendor/sweetalert/sweetalert.all.js
new file mode 100644
index 0000000..7e28f48
--- /dev/null
+++ b/public/vendor/sweetalert/sweetalert.all.js
@@ -0,0 +1,6 @@
+/*!
+* sweetalert2 v11.7.3
+* Released under the MIT License.
+*/
+!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Sweetalert2=t()}(this,(function(){"use strict";var e={awaitingPromise:new WeakMap,promise:new WeakMap,innerParams:new WeakMap,domCache:new WeakMap};const t=e=>{const t={};for(const n in e)t[e[n]]="swal2-"+e[n];return t},n=t(["container","shown","height-auto","iosfix","popup","modal","no-backdrop","no-transition","toast","toast-shown","show","hide","close","title","html-container","actions","confirm","deny","cancel","default-outline","footer","icon","icon-content","image","input","file","range","select","radio","checkbox","label","textarea","inputerror","input-label","validation-message","progress-steps","active-progress-step","progress-step","progress-step-line","loader","loading","styled","top","top-start","top-end","top-left","top-right","center","center-start","center-end","center-left","center-right","bottom","bottom-start","bottom-end","bottom-left","bottom-right","grow-row","grow-column","grow-fullscreen","rtl","timer-progress-bar","timer-progress-bar-container","scrollbar-measure","icon-success","icon-warning","icon-info","icon-question","icon-error"]),o=t(["success","warning","info","question","error"]),i="SweetAlert2:",s=e=>e.charAt(0).toUpperCase()+e.slice(1),r=e=>{console.warn(`${i} ${"object"==typeof e?e.join(" "):e}`)},a=e=>{console.error(`${i} ${e}`)},l=[],c=(e,t)=>{var n;n=`"${e}" is deprecated and will be removed in the next major release. Please use "${t}" instead.`,l.includes(n)||(l.push(n),r(n))},u=e=>"function"==typeof e?e():e,d=e=>e&&"function"==typeof e.toPromise,p=e=>d(e)?e.toPromise():Promise.resolve(e),m=e=>e&&Promise.resolve(e)===e,g=()=>document.body.querySelector(`.${n.container}`),h=e=>{const t=g();return t?t.querySelector(e):null},f=e=>h(`.${e}`),b=()=>f(n.popup),y=()=>f(n.icon),w=()=>f(n.title),v=()=>f(n["html-container"]),C=()=>f(n.image),A=()=>f(n["progress-steps"]),k=()=>f(n["validation-message"]),B=()=>h(`.${n.actions} .${n.confirm}`),P=()=>h(`.${n.actions} .${n.cancel}`),x=()=>h(`.${n.actions} .${n.deny}`),E=()=>h(`.${n.loader}`),$=()=>f(n.actions),T=()=>f(n.footer),S=()=>f(n["timer-progress-bar"]),L=()=>f(n.close),O=()=>{const e=Array.from(b().querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])')).sort(((e,t)=>{const n=parseInt(e.getAttribute("tabindex")),o=parseInt(t.getAttribute("tabindex"));return n>o?1:n"-1"!==e.getAttribute("tabindex")));return(e=>{const t=[];for(let n=0;nJ(e)))},j=()=>D(document.body,n.shown)&&!D(document.body,n["toast-shown"])&&!D(document.body,n["no-backdrop"]),M=()=>b()&&D(b(),n.toast),H={previousBodyPadding:null},I=(e,t)=>{if(e.textContent="",t){const n=(new DOMParser).parseFromString(t,"text/html");Array.from(n.querySelector("head").childNodes).forEach((t=>{e.appendChild(t)})),Array.from(n.querySelector("body").childNodes).forEach((t=>{t instanceof HTMLVideoElement||t instanceof HTMLAudioElement?e.appendChild(t.cloneNode(!0)):e.appendChild(t)}))}},D=(e,t)=>{if(!t)return!1;const n=t.split(/\s+/);for(let t=0;t{if(((e,t)=>{Array.from(e.classList).forEach((i=>{Object.values(n).includes(i)||Object.values(o).includes(i)||Object.values(t.showClass).includes(i)||e.classList.remove(i)}))})(e,t),t.customClass&&t.customClass[i]){if("string"!=typeof t.customClass[i]&&!t.customClass[i].forEach)return void r(`Invalid type of customClass.${i}! Expected string or iterable object, got "${typeof t.customClass[i]}"`);R(e,t.customClass[i])}},V=(e,t)=>{if(!t)return null;switch(t){case"select":case"textarea":case"file":return e.querySelector(`.${n.popup} > .${n[t]}`);case"checkbox":return e.querySelector(`.${n.popup} > .${n.checkbox} input`);case"radio":return e.querySelector(`.${n.popup} > .${n.radio} input:checked`)||e.querySelector(`.${n.popup} > .${n.radio} input:first-child`);case"range":return e.querySelector(`.${n.popup} > .${n.range} input`);default:return e.querySelector(`.${n.popup} > .${n.input}`)}},N=e=>{if(e.focus(),"file"!==e.type){const t=e.value;e.value="",e.value=t}},F=(e,t,n)=>{e&&t&&("string"==typeof t&&(t=t.split(/\s+/).filter(Boolean)),t.forEach((t=>{Array.isArray(e)?e.forEach((e=>{n?e.classList.add(t):e.classList.remove(t)})):n?e.classList.add(t):e.classList.remove(t)})))},R=(e,t)=>{F(e,t,!0)},U=(e,t)=>{F(e,t,!1)},_=(e,t)=>{const n=Array.from(e.children);for(let e=0;e{n===`${parseInt(n)}`&&(n=parseInt(n)),n||0===parseInt(n)?e.style[t]="number"==typeof n?`${n}px`:n:e.style.removeProperty(t)},z=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"flex";e.style.display=t},K=e=>{e.style.display="none"},Y=(e,t,n,o)=>{const i=e.querySelector(t);i&&(i.style[n]=o)},Z=function(e,t){t?z(e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:"flex"):K(e)},J=e=>!(!e||!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)),X=e=>!!(e.scrollHeight>e.clientHeight),G=e=>{const t=window.getComputedStyle(e),n=parseFloat(t.getPropertyValue("animation-duration")||"0"),o=parseFloat(t.getPropertyValue("transition-duration")||"0");return n>0||o>0},Q=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=S();J(n)&&(t&&(n.style.transition="none",n.style.width="100%"),setTimeout((()=>{n.style.transition=`width ${e/1e3}s linear`,n.style.width="0%"}),10))},ee={},te=e=>new Promise((t=>{if(!e)return t();const n=window.scrollX,o=window.scrollY;ee.restoreFocusTimeout=setTimeout((()=>{ee.previousActiveElement instanceof HTMLElement?(ee.previousActiveElement.focus(),ee.previousActiveElement=null):document.body&&document.body.focus(),t()}),100),window.scrollTo(n,o)})),ne=()=>"undefined"==typeof window||"undefined"==typeof document,oe=`\n \n`.replace(/(^|\n)\s*/g,""),ie=()=>{ee.currentInstance.resetValidationMessage()},se=e=>{const t=(()=>{const e=g();return!!e&&(e.remove(),U([document.documentElement,document.body],[n["no-backdrop"],n["toast-shown"],n["has-column"]]),!0)})();if(ne())return void a("SweetAlert2 requires document to initialize");const o=document.createElement("div");o.className=n.container,t&&R(o,n["no-transition"]),I(o,oe);const i="string"==typeof(s=e.target)?document.querySelector(s):s;var s;i.appendChild(o),(e=>{const t=b();t.setAttribute("role",e.toast?"alert":"dialog"),t.setAttribute("aria-live",e.toast?"polite":"assertive"),e.toast||t.setAttribute("aria-modal","true")})(e),(e=>{"rtl"===window.getComputedStyle(e).direction&&R(g(),n.rtl)})(i),(()=>{const e=b(),t=_(e,n.input),o=_(e,n.file),i=e.querySelector(`.${n.range} input`),s=e.querySelector(`.${n.range} output`),r=_(e,n.select),a=e.querySelector(`.${n.checkbox} input`),l=_(e,n.textarea);t.oninput=ie,o.onchange=ie,r.onchange=ie,a.onchange=ie,l.oninput=ie,i.oninput=()=>{ie(),s.value=i.value},i.onchange=()=>{ie(),s.value=i.value}})()},re=(e,t)=>{e instanceof HTMLElement?t.appendChild(e):"object"==typeof e?ae(e,t):e&&I(t,e)},ae=(e,t)=>{e.jquery?le(t,e):I(t,e.toString())},le=(e,t)=>{if(e.textContent="",0 in t)for(let n=0;n in t;n++)e.appendChild(t[n].cloneNode(!0));else e.appendChild(t.cloneNode(!0))},ce=(()=>{if(ne())return!1;const e=document.createElement("div"),t={WebkitAnimation:"webkitAnimationEnd",animation:"animationend"};for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&void 0!==e.style[n])return t[n];return!1})(),ue=(e,t)=>{const o=$(),i=E();t.showConfirmButton||t.showDenyButton||t.showCancelButton?z(o):K(o),q(o,t,"actions"),function(e,t,o){const i=B(),s=x(),r=P();de(i,"confirm",o),de(s,"deny",o),de(r,"cancel",o),function(e,t,o,i){if(!i.buttonsStyling)return void U([e,t,o],n.styled);R([e,t,o],n.styled),i.confirmButtonColor&&(e.style.backgroundColor=i.confirmButtonColor,R(e,n["default-outline"]));i.denyButtonColor&&(t.style.backgroundColor=i.denyButtonColor,R(t,n["default-outline"]));i.cancelButtonColor&&(o.style.backgroundColor=i.cancelButtonColor,R(o,n["default-outline"]))}(i,s,r,o),o.reverseButtons&&(o.toast?(e.insertBefore(r,i),e.insertBefore(s,i)):(e.insertBefore(r,t),e.insertBefore(s,t),e.insertBefore(i,t)))}(o,i,t),I(i,t.loaderHtml),q(i,t,"loader")};function de(e,t,o){Z(e,o[`show${s(t)}Button`],"inline-block"),I(e,o[`${t}ButtonText`]),e.setAttribute("aria-label",o[`${t}ButtonAriaLabel`]),e.className=n[t],q(e,o,`${t}Button`),R(e,o[`${t}ButtonClass`])}const pe=(e,t)=>{const o=g();o&&(!function(e,t){"string"==typeof t?e.style.background=t:t||R([document.documentElement,document.body],n["no-backdrop"])}(o,t.backdrop),function(e,t){t in n?R(e,n[t]):(r('The "position" parameter is not valid, defaulting to "center"'),R(e,n.center))}(o,t.position),function(e,t){if(t&&"string"==typeof t){const o=`grow-${t}`;o in n&&R(e,n[o])}}(o,t.grow),q(o,t,"container"))};const me=["input","file","range","select","radio","checkbox","textarea"],ge=e=>{if(!Ce[e.input])return void a(`Unexpected type of input! Expected "text", "email", "password", "number", "tel", "select", "radio", "checkbox", "textarea", "file" or "url", got "${e.input}"`);const t=we(e.input),n=Ce[e.input](t,e);z(t),e.inputAutoFocus&&setTimeout((()=>{N(n)}))},he=(e,t)=>{const n=V(b(),e);if(n){(e=>{for(let t=0;t{const t=we(e.input);"object"==typeof e.customClass&&R(t,e.customClass.input)},be=(e,t)=>{e.placeholder&&!t.inputPlaceholder||(e.placeholder=t.inputPlaceholder)},ye=(e,t,o)=>{if(o.inputLabel){e.id=n.input;const i=document.createElement("label"),s=n["input-label"];i.setAttribute("for",e.id),i.className=s,"object"==typeof o.customClass&&R(i,o.customClass.inputLabel),i.innerText=o.inputLabel,t.insertAdjacentElement("beforebegin",i)}},we=e=>_(b(),n[e]||n.input),ve=(e,t)=>{["string","number"].includes(typeof t)?e.value=`${t}`:m(t)||r(`Unexpected type of inputValue! Expected "string", "number" or "Promise", got "${typeof t}"`)},Ce={};Ce.text=Ce.email=Ce.password=Ce.number=Ce.tel=Ce.url=(e,t)=>(ve(e,t.inputValue),ye(e,e,t),be(e,t),e.type=t.input,e),Ce.file=(e,t)=>(ye(e,e,t),be(e,t),e),Ce.range=(e,t)=>{const n=e.querySelector("input"),o=e.querySelector("output");return ve(n,t.inputValue),n.type=t.input,ve(o,t.inputValue),ye(n,e,t),e},Ce.select=(e,t)=>{if(e.textContent="",t.inputPlaceholder){const n=document.createElement("option");I(n,t.inputPlaceholder),n.value="",n.disabled=!0,n.selected=!0,e.appendChild(n)}return ye(e,e,t),e},Ce.radio=e=>(e.textContent="",e),Ce.checkbox=(e,t)=>{const o=V(b(),"checkbox");o.value="1",o.id=n.checkbox,o.checked=Boolean(t.inputValue);const i=e.querySelector("span");return I(i,t.inputPlaceholder),o},Ce.textarea=(e,t)=>{ve(e,t.inputValue),be(e,t),ye(e,e,t);return setTimeout((()=>{if("MutationObserver"in window){const t=parseInt(window.getComputedStyle(b()).width);new MutationObserver((()=>{const n=e.offsetWidth+(o=e,parseInt(window.getComputedStyle(o).marginLeft)+parseInt(window.getComputedStyle(o).marginRight));var o;b().style.width=n>t?`${n}px`:null})).observe(e,{attributes:!0,attributeFilter:["style"]})}})),e};const Ae=(t,o)=>{const i=v();q(i,o,"htmlContainer"),o.html?(re(o.html,i),z(i,"block")):o.text?(i.textContent=o.text,z(i,"block")):K(i),((t,o)=>{const i=b(),s=e.innerParams.get(t),r=!s||o.input!==s.input;me.forEach((e=>{const t=_(i,n[e]);he(e,o.inputAttributes),t.className=n[e],r&&K(t)})),o.input&&(r&&ge(o),fe(o))})(t,o)},ke=(e,t)=>{for(const n in o)t.icon!==n&&U(e,o[n]);R(e,o[t.icon]),xe(e,t),Be(),q(e,t,"icon")},Be=()=>{const e=b(),t=window.getComputedStyle(e).getPropertyValue("background-color"),n=e.querySelectorAll("[class^=swal2-success-circular-line], .swal2-success-fix");for(let e=0;e{let n,o=e.innerHTML;if(t.iconHtml)n=Ee(t.iconHtml);else if("success"===t.icon)n='\n
\n \n
\n
\n',o=o.replace(/ style=".*?"/g,"");else if("error"===t.icon)n='\n \n \n \n \n';else{n=Ee({question:"?",warning:"!",info:"i"}[t.icon])}o.trim()!==n.trim()&&I(e,n)},xe=(e,t)=>{if(t.iconColor){e.style.color=t.iconColor,e.style.borderColor=t.iconColor;for(const n of[".swal2-success-line-tip",".swal2-success-line-long",".swal2-x-mark-line-left",".swal2-x-mark-line-right"])Y(e,n,"backgroundColor",t.iconColor);Y(e,".swal2-success-ring","borderColor",t.iconColor)}},Ee=e=>`${e}
`,$e=(e,t)=>{e.className=`${n.popup} ${J(e)?t.showClass.popup:""}`,t.toast?(R([document.documentElement,document.body],n["toast-shown"]),R(e,n.toast)):R(e,n.modal),q(e,t,"popup"),"string"==typeof t.customClass&&R(e,t.customClass),t.icon&&R(e,n[`icon-${t.icon}`])},Te=e=>{const t=document.createElement("li");return R(t,n["progress-step"]),I(t,e),t},Se=e=>{const t=document.createElement("li");return R(t,n["progress-step-line"]),e.progressStepsDistance&&W(t,"width",e.progressStepsDistance),t},Le=(t,i)=>{((e,t)=>{const n=g(),o=b();t.toast?(W(n,"width",t.width),o.style.width="100%",o.insertBefore(E(),y())):W(o,"width",t.width),W(o,"padding",t.padding),t.color&&(o.style.color=t.color),t.background&&(o.style.background=t.background),K(k()),$e(o,t)})(0,i),pe(0,i),((e,t)=>{const o=A();t.progressSteps&&0!==t.progressSteps.length?(z(o),o.textContent="",t.currentProgressStep>=t.progressSteps.length&&r("Invalid currentProgressStep parameter, it should be less than progressSteps.length (currentProgressStep like JS arrays starts from 0)"),t.progressSteps.forEach(((e,i)=>{const s=Te(e);if(o.appendChild(s),i===t.currentProgressStep&&R(s,n["active-progress-step"]),i!==t.progressSteps.length-1){const e=Se(t);o.appendChild(e)}}))):K(o)})(0,i),((t,n)=>{const i=e.innerParams.get(t),s=y();if(i&&n.icon===i.icon)return Pe(s,n),void ke(s,n);if(n.icon||n.iconHtml){if(n.icon&&-1===Object.keys(o).indexOf(n.icon))return a(`Unknown icon! Expected "success", "error", "warning", "info" or "question", got "${n.icon}"`),void K(s);z(s),Pe(s,n),ke(s,n),R(s,n.showClass.icon)}else K(s)})(t,i),((e,t)=>{const o=C();t.imageUrl?(z(o,""),o.setAttribute("src",t.imageUrl),o.setAttribute("alt",t.imageAlt),W(o,"width",t.imageWidth),W(o,"height",t.imageHeight),o.className=n.image,q(o,t,"image")):K(o)})(0,i),((e,t)=>{const n=w();Z(n,t.title||t.titleText,"block"),t.title&&re(t.title,n),t.titleText&&(n.innerText=t.titleText),q(n,t,"title")})(0,i),((e,t)=>{const n=L();I(n,t.closeButtonHtml),q(n,t,"closeButton"),Z(n,t.showCloseButton),n.setAttribute("aria-label",t.closeButtonAriaLabel)})(0,i),Ae(t,i),ue(0,i),((e,t)=>{const n=T();Z(n,t.footer),t.footer&&re(t.footer,n),q(n,t,"footer")})(0,i),"function"==typeof i.didRender&&i.didRender(b())};function Oe(){const t=e.innerParams.get(this);if(!t)return;const o=e.domCache.get(this);K(o.loader),M()?t.icon&&z(y()):je(o),U([o.popup,o.actions],n.loading),o.popup.removeAttribute("aria-busy"),o.popup.removeAttribute("data-loading"),o.confirmButton.disabled=!1,o.denyButton.disabled=!1,o.cancelButton.disabled=!1}const je=e=>{const t=e.popup.getElementsByClassName(e.loader.getAttribute("data-button-to-replace"));t.length?z(t[0],"inline-block"):J(B())||J(x())||J(P())||K(e.actions)};const Me=()=>B()&&B().click(),He=Object.freeze({cancel:"cancel",backdrop:"backdrop",close:"close",esc:"esc",timer:"timer"}),Ie=e=>{e.keydownTarget&&e.keydownHandlerAdded&&(e.keydownTarget.removeEventListener("keydown",e.keydownHandler,{capture:e.keydownListenerCapture}),e.keydownHandlerAdded=!1)},De=(e,t)=>{const n=O();if(n.length)return(e+=t)===n.length?e=0:-1===e&&(e=n.length-1),void n[e].focus();b().focus()},qe=["ArrowRight","ArrowDown"],Ve=["ArrowLeft","ArrowUp"],Ne=(t,n,o)=>{const i=e.innerParams.get(t);i&&(n.isComposing||229===n.keyCode||(i.stopKeydownPropagation&&n.stopPropagation(),"Enter"===n.key?Fe(t,n,i):"Tab"===n.key?Re(n):[...qe,...Ve].includes(n.key)?Ue(n.key):"Escape"===n.key&&_e(n,i,o)))},Fe=(e,t,n)=>{if(u(n.allowEnterKey)&&t.target&&e.getInput()&&t.target instanceof HTMLElement&&t.target.outerHTML===e.getInput().outerHTML){if(["textarea","file"].includes(n.input))return;Me(),t.preventDefault()}},Re=e=>{const t=e.target,n=O();let o=-1;for(let e=0;e{const t=[B(),x(),P()];if(document.activeElement instanceof HTMLElement&&!t.includes(document.activeElement))return;const n=qe.includes(e)?"nextElementSibling":"previousElementSibling";let o=document.activeElement;for(let e=0;e<$().children.length;e++){if(o=o[n],!o)return;if(o instanceof HTMLButtonElement&&J(o))break}o instanceof HTMLButtonElement&&o.focus()},_e=(e,t,n)=>{u(t.allowEscapeKey)&&(e.preventDefault(),n(He.esc))};var We={swalPromiseResolve:new WeakMap,swalPromiseReject:new WeakMap};const ze=()=>{Array.from(document.body.children).forEach((e=>{e.hasAttribute("data-previous-aria-hidden")?(e.setAttribute("aria-hidden",e.getAttribute("data-previous-aria-hidden")),e.removeAttribute("data-previous-aria-hidden")):e.removeAttribute("aria-hidden")}))},Ke=()=>{const e=navigator.userAgent,t=!!e.match(/iPad/i)||!!e.match(/iPhone/i),n=!!e.match(/WebKit/i);if(t&&n&&!e.match(/CriOS/i)){const e=44;b().scrollHeight>window.innerHeight-e&&(g().style.paddingBottom=`${e}px`)}},Ye=()=>{const e=g();let t;e.ontouchstart=e=>{t=Ze(e)},e.ontouchmove=e=>{t&&(e.preventDefault(),e.stopPropagation())}},Ze=e=>{const t=e.target,n=g();return!Je(e)&&!Xe(e)&&(t===n||!X(n)&&t instanceof HTMLElement&&"INPUT"!==t.tagName&&"TEXTAREA"!==t.tagName&&(!X(v())||!v().contains(t)))},Je=e=>e.touches&&e.touches.length&&"stylus"===e.touches[0].touchType,Xe=e=>e.touches&&e.touches.length>1,Ge=()=>{if(D(document.body,n.iosfix)){const e=parseInt(document.body.style.top,10);U(document.body,n.iosfix),document.body.style.top="",document.body.scrollTop=-1*e}},Qe=()=>{null===H.previousBodyPadding&&document.body.scrollHeight>window.innerHeight&&(H.previousBodyPadding=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right")),document.body.style.paddingRight=`${H.previousBodyPadding+(()=>{const e=document.createElement("div");e.className=n["scrollbar-measure"],document.body.appendChild(e);const t=e.getBoundingClientRect().width-e.clientWidth;return document.body.removeChild(e),t})()}px`)},et=()=>{null!==H.previousBodyPadding&&(document.body.style.paddingRight=`${H.previousBodyPadding}px`,H.previousBodyPadding=null)};function tt(e,t,o,i){M()?lt(e,i):(te(o).then((()=>lt(e,i))),Ie(ee));/^((?!chrome|android).)*safari/i.test(navigator.userAgent)?(t.setAttribute("style","display:none !important"),t.removeAttribute("class"),t.innerHTML=""):t.remove(),j()&&(et(),Ge(),ze()),U([document.documentElement,document.body],[n.shown,n["height-auto"],n["no-backdrop"],n["toast-shown"]])}function nt(e){e=st(e);const t=We.swalPromiseResolve.get(this),n=ot(this);this.isAwaitingPromise()?e.isDismissed||(it(this),t(e)):n&&t(e)}const ot=t=>{const n=b();if(!n)return!1;const o=e.innerParams.get(t);if(!o||D(n,o.hideClass.popup))return!1;U(n,o.showClass.popup),R(n,o.hideClass.popup);const i=g();return U(i,o.showClass.backdrop),R(i,o.hideClass.backdrop),rt(t,n,o),!0};const it=t=>{t.isAwaitingPromise()&&(e.awaitingPromise.delete(t),e.innerParams.get(t)||t._destroy())},st=e=>void 0===e?{isConfirmed:!1,isDenied:!1,isDismissed:!0}:Object.assign({isConfirmed:!1,isDenied:!1,isDismissed:!1},e),rt=(e,t,n)=>{const o=g(),i=ce&&G(t);"function"==typeof n.willClose&&n.willClose(t),i?at(e,t,o,n.returnFocus,n.didClose):tt(e,o,n.returnFocus,n.didClose)},at=(e,t,n,o,i)=>{ee.swalCloseEventFinishedCallback=tt.bind(null,e,n,o,i),t.addEventListener(ce,(function(e){e.target===t&&(ee.swalCloseEventFinishedCallback(),delete ee.swalCloseEventFinishedCallback)}))},lt=(e,t)=>{setTimeout((()=>{"function"==typeof t&&t.bind(e.params)(),e._destroy()}))};function ct(t,n,o){const i=e.domCache.get(t);n.forEach((e=>{i[e].disabled=o}))}function ut(e,t){if(e)if("radio"===e.type){const n=e.parentNode.parentNode.querySelectorAll("input");for(let e=0;eObject.prototype.hasOwnProperty.call(dt,e),ft=e=>-1!==pt.indexOf(e),bt=e=>mt[e],yt=e=>{ht(e)||r(`Unknown parameter "${e}"`)},wt=e=>{gt.includes(e)&&r(`The parameter "${e}" is incompatible with toasts`)},vt=e=>{bt(e)&&c(e,bt(e))};const Ct=e=>{const t={};return Object.keys(e).forEach((n=>{ft(n)?t[n]=e[n]:r(`Invalid parameter to update: ${n}`)})),t};const At=e=>{kt(e),delete e.params,delete ee.keydownHandler,delete ee.keydownTarget,delete ee.currentInstance},kt=t=>{t.isAwaitingPromise()?(Bt(e,t),e.awaitingPromise.set(t,!0)):(Bt(We,t),Bt(e,t))},Bt=(e,t)=>{for(const n in e)e[n].delete(t)};var Pt=Object.freeze({__proto__:null,_destroy:function(){const t=e.domCache.get(this),n=e.innerParams.get(this);n?(t.popup&&ee.swalCloseEventFinishedCallback&&(ee.swalCloseEventFinishedCallback(),delete ee.swalCloseEventFinishedCallback),"function"==typeof n.didDestroy&&n.didDestroy(),At(this)):kt(this)},close:nt,closeModal:nt,closePopup:nt,closeToast:nt,disableButtons:function(){ct(this,["confirmButton","denyButton","cancelButton"],!0)},disableInput:function(){ut(this.getInput(),!0)},disableLoading:Oe,enableButtons:function(){ct(this,["confirmButton","denyButton","cancelButton"],!1)},enableInput:function(){ut(this.getInput(),!1)},getInput:function(t){const n=e.innerParams.get(t||this),o=e.domCache.get(t||this);return o?V(o.popup,n.input):null},handleAwaitingPromise:it,hideLoading:Oe,isAwaitingPromise:function(){return!!e.awaitingPromise.get(this)},rejectPromise:function(e){const t=We.swalPromiseReject.get(this);it(this),t&&t(e)},resetValidationMessage:function(){const t=e.domCache.get(this);t.validationMessage&&K(t.validationMessage);const o=this.getInput();o&&(o.removeAttribute("aria-invalid"),o.removeAttribute("aria-describedby"),U(o,n.inputerror))},showValidationMessage:function(t){const o=e.domCache.get(this),i=e.innerParams.get(this);I(o.validationMessage,t),o.validationMessage.className=n["validation-message"],i.customClass&&i.customClass.validationMessage&&R(o.validationMessage,i.customClass.validationMessage),z(o.validationMessage);const s=this.getInput();s&&(s.setAttribute("aria-invalid",!0),s.setAttribute("aria-describedby",n["validation-message"]),N(s),R(s,n.inputerror))},update:function(t){const n=b(),o=e.innerParams.get(this);if(!n||D(n,o.hideClass.popup))return void r("You're trying to update the closed or closing popup, that won't work. Use the update() method in preConfirm parameter or show a new popup.");const i=Ct(t),s=Object.assign({},o,i);Le(this,s),e.innerParams.set(this,s),Object.defineProperties(this,{params:{value:Object.assign({},this.params,t),writable:!1,enumerable:!0}})}});const xt=e=>{let t=b();t||new Tn,t=b();const n=E();M()?K(y()):Et(t,e),z(n),t.setAttribute("data-loading","true"),t.setAttribute("aria-busy","true"),t.focus()},Et=(e,t)=>{const o=$(),i=E();!t&&J(B())&&(t=B()),z(o),t&&(K(t),i.setAttribute("data-button-to-replace",t.className)),i.parentNode.insertBefore(i,t),R([e,o],n.loading)},$t=e=>e.checked?1:0,Tt=e=>e.checked?e.value:null,St=e=>e.files.length?null!==e.getAttribute("multiple")?e.files:e.files[0]:null,Lt=(e,t)=>{const n=b(),o=e=>{jt[t.input](n,Mt(e),t)};d(t.inputOptions)||m(t.inputOptions)?(xt(B()),p(t.inputOptions).then((t=>{e.hideLoading(),o(t)}))):"object"==typeof t.inputOptions?o(t.inputOptions):a("Unexpected type of inputOptions! Expected object, Map or Promise, got "+typeof t.inputOptions)},Ot=(e,t)=>{const n=e.getInput();K(n),p(t.inputValue).then((o=>{n.value="number"===t.input?`${parseFloat(o)||0}`:`${o}`,z(n),n.focus(),e.hideLoading()})).catch((t=>{a(`Error in inputValue promise: ${t}`),n.value="",z(n),n.focus(),e.hideLoading()}))},jt={select:(e,t,o)=>{const i=_(e,n.select),s=(e,t,n)=>{const i=document.createElement("option");i.value=n,I(i,t),i.selected=Ht(n,o.inputValue),e.appendChild(i)};t.forEach((e=>{const t=e[0],n=e[1];if(Array.isArray(n)){const e=document.createElement("optgroup");e.label=t,e.disabled=!1,i.appendChild(e),n.forEach((t=>s(e,t[1],t[0])))}else s(i,n,t)})),i.focus()},radio:(e,t,o)=>{const i=_(e,n.radio);t.forEach((e=>{const t=e[0],s=e[1],r=document.createElement("input"),a=document.createElement("label");r.type="radio",r.name=n.radio,r.value=t,Ht(t,o.inputValue)&&(r.checked=!0);const l=document.createElement("span");I(l,s),l.className=n.label,a.appendChild(r),a.appendChild(l),i.appendChild(a)}));const s=i.querySelectorAll("input");s.length&&s[0].focus()}},Mt=e=>{const t=[];return"undefined"!=typeof Map&&e instanceof Map?e.forEach(((e,n)=>{let o=e;"object"==typeof o&&(o=Mt(o)),t.push([n,o])})):Object.keys(e).forEach((n=>{let o=e[n];"object"==typeof o&&(o=Mt(o)),t.push([n,o])})),t},Ht=(e,t)=>t&&t.toString()===e.toString(),It=(t,n)=>{const o=e.innerParams.get(t);if(!o.input)return void a(`The "input" parameter is needed to be set when using returnInputValueOn${s(n)}`);const i=((e,t)=>{const n=e.getInput();if(!n)return null;switch(t.input){case"checkbox":return $t(n);case"radio":return Tt(n);case"file":return St(n);default:return t.inputAutoTrim?n.value.trim():n.value}})(t,o);o.inputValidator?Dt(t,i,n):t.getInput().checkValidity()?"deny"===n?qt(t,i):Ft(t,i):(t.enableButtons(),t.showValidationMessage(o.validationMessage))},Dt=(t,n,o)=>{const i=e.innerParams.get(t);t.disableInput();Promise.resolve().then((()=>p(i.inputValidator(n,i.validationMessage)))).then((e=>{t.enableButtons(),t.enableInput(),e?t.showValidationMessage(e):"deny"===o?qt(t,n):Ft(t,n)}))},qt=(t,n)=>{const o=e.innerParams.get(t||void 0);if(o.showLoaderOnDeny&&xt(x()),o.preDeny){e.awaitingPromise.set(t||void 0,!0);Promise.resolve().then((()=>p(o.preDeny(n,o.validationMessage)))).then((e=>{!1===e?(t.hideLoading(),it(t)):t.close({isDenied:!0,value:void 0===e?n:e})})).catch((e=>Nt(t||void 0,e)))}else t.close({isDenied:!0,value:n})},Vt=(e,t)=>{e.close({isConfirmed:!0,value:t})},Nt=(e,t)=>{e.rejectPromise(t)},Ft=(t,n)=>{const o=e.innerParams.get(t||void 0);if(o.showLoaderOnConfirm&&xt(),o.preConfirm){t.resetValidationMessage(),e.awaitingPromise.set(t||void 0,!0);Promise.resolve().then((()=>p(o.preConfirm(n,o.validationMessage)))).then((e=>{J(k())||!1===e?(t.hideLoading(),it(t)):Vt(t,void 0===e?n:e)})).catch((e=>Nt(t||void 0,e)))}else Vt(t,n)},Rt=(t,n,o)=>{n.popup.onclick=()=>{const n=e.innerParams.get(t);n&&(Ut(n)||n.timer||n.input)||o(He.close)}},Ut=e=>e.showConfirmButton||e.showDenyButton||e.showCancelButton||e.showCloseButton;let _t=!1;const Wt=e=>{e.popup.onmousedown=()=>{e.container.onmouseup=function(t){e.container.onmouseup=void 0,t.target===e.container&&(_t=!0)}}},zt=e=>{e.container.onmousedown=()=>{e.popup.onmouseup=function(t){e.popup.onmouseup=void 0,(t.target===e.popup||e.popup.contains(t.target))&&(_t=!0)}}},Kt=(t,n,o)=>{n.container.onclick=i=>{const s=e.innerParams.get(t);_t?_t=!1:i.target===n.container&&u(s.allowOutsideClick)&&o(He.backdrop)}},Yt=e=>e instanceof Element||(e=>"object"==typeof e&&e.jquery)(e);const Zt=()=>{if(ee.timeout)return(()=>{const e=S(),t=parseInt(window.getComputedStyle(e).width);e.style.removeProperty("transition"),e.style.width="100%";const n=t/parseInt(window.getComputedStyle(e).width)*100;e.style.width=`${n}%`})(),ee.timeout.stop()},Jt=()=>{if(ee.timeout){const e=ee.timeout.start();return Q(e),e}};let Xt=!1;const Gt={};const Qt=e=>{for(let t=e.target;t&&t!==document;t=t.parentNode)for(const e in Gt){const n=t.getAttribute(e);if(n)return void Gt[e].fire({template:n})}};var en=Object.freeze({__proto__:null,argsToParams:e=>{const t={};return"object"!=typeof e[0]||Yt(e[0])?["title","html","icon"].forEach(((n,o)=>{const i=e[o];"string"==typeof i||Yt(i)?t[n]=i:void 0!==i&&a(`Unexpected type of ${n}! Expected "string" or "Element", got ${typeof i}`)})):Object.assign(t,e[0]),t},bindClickHandler:function(){Gt[arguments.length>0&&void 0!==arguments[0]?arguments[0]:"data-swal-template"]=this,Xt||(document.body.addEventListener("click",Qt),Xt=!0)},clickCancel:()=>P()&&P().click(),clickConfirm:Me,clickDeny:()=>x()&&x().click(),enableLoading:xt,fire:function(){for(var e=arguments.length,t=new Array(e),n=0;nf(n["icon-content"]),getImage:C,getInputLabel:()=>f(n["input-label"]),getLoader:E,getPopup:b,getProgressSteps:A,getTimerLeft:()=>ee.timeout&&ee.timeout.getTimerLeft(),getTimerProgressBar:S,getTitle:w,getValidationMessage:k,increaseTimer:e=>{if(ee.timeout){const t=ee.timeout.increase(e);return Q(t,!0),t}},isDeprecatedParameter:bt,isLoading:()=>b().hasAttribute("data-loading"),isTimerRunning:()=>ee.timeout&&ee.timeout.isRunning(),isUpdatableParameter:ft,isValidParameter:ht,isVisible:()=>J(b()),mixin:function(e){return class extends(this){_main(t,n){return super._main(t,Object.assign({},e,n))}}},resumeTimer:Jt,showLoading:xt,stopTimer:Zt,toggleTimer:()=>{const e=ee.timeout;return e&&(e.running?Zt():Jt())}});class tn{constructor(e,t){this.callback=e,this.remaining=t,this.running=!1,this.start()}start(){return this.running||(this.running=!0,this.started=new Date,this.id=setTimeout(this.callback,this.remaining)),this.remaining}stop(){return this.running&&(this.running=!1,clearTimeout(this.id),this.remaining-=(new Date).getTime()-this.started.getTime()),this.remaining}increase(e){const t=this.running;return t&&this.stop(),this.remaining+=e,t&&this.start(),this.remaining}getTimerLeft(){return this.running&&(this.stop(),this.start()),this.remaining}isRunning(){return this.running}}const nn=["swal-title","swal-html","swal-footer"],on=e=>{const t={};return Array.from(e.querySelectorAll("swal-param")).forEach((e=>{pn(e,["name","value"]);const n=e.getAttribute("name"),o=e.getAttribute("value");t[n]="boolean"==typeof dt[n]?"false"!==o:"object"==typeof dt[n]?JSON.parse(o):o})),t},sn=e=>{const t={};return Array.from(e.querySelectorAll("swal-function-param")).forEach((e=>{const n=e.getAttribute("name"),o=e.getAttribute("value");t[n]=new Function(`return ${o}`)()})),t},rn=e=>{const t={};return Array.from(e.querySelectorAll("swal-button")).forEach((e=>{pn(e,["type","color","aria-label"]);const n=e.getAttribute("type");t[`${n}ButtonText`]=e.innerHTML,t[`show${s(n)}Button`]=!0,e.hasAttribute("color")&&(t[`${n}ButtonColor`]=e.getAttribute("color")),e.hasAttribute("aria-label")&&(t[`${n}ButtonAriaLabel`]=e.getAttribute("aria-label"))})),t},an=e=>{const t={},n=e.querySelector("swal-image");return n&&(pn(n,["src","width","height","alt"]),n.hasAttribute("src")&&(t.imageUrl=n.getAttribute("src")),n.hasAttribute("width")&&(t.imageWidth=n.getAttribute("width")),n.hasAttribute("height")&&(t.imageHeight=n.getAttribute("height")),n.hasAttribute("alt")&&(t.imageAlt=n.getAttribute("alt"))),t},ln=e=>{const t={},n=e.querySelector("swal-icon");return n&&(pn(n,["type","color"]),n.hasAttribute("type")&&(t.icon=n.getAttribute("type")),n.hasAttribute("color")&&(t.iconColor=n.getAttribute("color")),t.iconHtml=n.innerHTML),t},cn=e=>{const t={},n=e.querySelector("swal-input");n&&(pn(n,["type","label","placeholder","value"]),t.input=n.getAttribute("type")||"text",n.hasAttribute("label")&&(t.inputLabel=n.getAttribute("label")),n.hasAttribute("placeholder")&&(t.inputPlaceholder=n.getAttribute("placeholder")),n.hasAttribute("value")&&(t.inputValue=n.getAttribute("value")));const o=Array.from(e.querySelectorAll("swal-input-option"));return o.length&&(t.inputOptions={},o.forEach((e=>{pn(e,["value"]);const n=e.getAttribute("value"),o=e.innerHTML;t.inputOptions[n]=o}))),t},un=(e,t)=>{const n={};for(const o in t){const i=t[o],s=e.querySelector(i);s&&(pn(s,[]),n[i.replace(/^swal-/,"")]=s.innerHTML.trim())}return n},dn=e=>{const t=nn.concat(["swal-param","swal-function-param","swal-button","swal-image","swal-icon","swal-input","swal-input-option"]);Array.from(e.children).forEach((e=>{const n=e.tagName.toLowerCase();t.includes(n)||r(`Unrecognized element <${n}>`)}))},pn=(e,t)=>{Array.from(e.attributes).forEach((n=>{-1===t.indexOf(n.name)&&r([`Unrecognized attribute "${n.name}" on <${e.tagName.toLowerCase()}>.`,""+(t.length?`Allowed attributes are: ${t.join(", ")}`:"To set the value, use HTML within the element.")])}))},mn=e=>{const t=g(),o=b();"function"==typeof e.willOpen&&e.willOpen(o);const i=window.getComputedStyle(document.body).overflowY;bn(t,o,e),setTimeout((()=>{hn(t,o)}),10),j()&&(fn(t,e.scrollbarPadding,i),Array.from(document.body.children).forEach((e=>{e===g()||e.contains(g())||(e.hasAttribute("aria-hidden")&&e.setAttribute("data-previous-aria-hidden",e.getAttribute("aria-hidden")),e.setAttribute("aria-hidden","true"))}))),M()||ee.previousActiveElement||(ee.previousActiveElement=document.activeElement),"function"==typeof e.didOpen&&setTimeout((()=>e.didOpen(o))),U(t,n["no-transition"])},gn=e=>{const t=b();if(e.target!==t)return;const n=g();t.removeEventListener(ce,gn),n.style.overflowY="auto"},hn=(e,t)=>{ce&&G(t)?(e.style.overflowY="hidden",t.addEventListener(ce,gn)):e.style.overflowY="auto"},fn=(e,t,o)=>{(()=>{if((/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1)&&!D(document.body,n.iosfix)){const e=document.body.scrollTop;document.body.style.top=-1*e+"px",R(document.body,n.iosfix),Ye(),Ke()}})(),t&&"hidden"!==o&&Qe(),setTimeout((()=>{e.scrollTop=0}))},bn=(e,t,o)=>{R(e,o.showClass.backdrop),t.style.setProperty("opacity","0","important"),z(t,"grid"),setTimeout((()=>{R(t,o.showClass.popup),t.style.removeProperty("opacity")}),10),R([document.documentElement,document.body],n.shown),o.heightAuto&&o.backdrop&&!o.toast&&R([document.documentElement,document.body],n["height-auto"])};var yn={email:(e,t)=>/^[a-zA-Z0-9.+_-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]{2,24}$/.test(e)?Promise.resolve():Promise.resolve(t||"Invalid email address"),url:(e,t)=>/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-z]{2,63}\b([-a-zA-Z0-9@:%_+.~#?&/=]*)$/.test(e)?Promise.resolve():Promise.resolve(t||"Invalid URL")};function wn(e){!function(e){e.inputValidator||Object.keys(yn).forEach((t=>{e.input===t&&(e.inputValidator=yn[t])}))}(e),e.showLoaderOnConfirm&&!e.preConfirm&&r("showLoaderOnConfirm is set to true, but preConfirm is not defined.\nshowLoaderOnConfirm should be used together with preConfirm, see usage example:\nhttps://sweetalert2.github.io/#ajax-request"),function(e){(!e.target||"string"==typeof e.target&&!document.querySelector(e.target)||"string"!=typeof e.target&&!e.target.appendChild)&&(r('Target parameter is not valid, defaulting to "body"'),e.target="body")}(e),"string"==typeof e.title&&(e.title=e.title.split("\n").join(" ")),se(e)}let vn;class Cn{constructor(){if("undefined"==typeof window)return;vn=this;for(var t=arguments.length,n=new Array(t),o=0;o1&&void 0!==arguments[1]?arguments[1]:{};(e=>{!1===e.backdrop&&e.allowOutsideClick&&r('"allowOutsideClick" parameter requires `backdrop` parameter to be set to `true`');for(const t in e)yt(t),e.toast&&wt(t),vt(t)})(Object.assign({},n,t)),ee.currentInstance&&(ee.currentInstance._destroy(),j()&&ze()),ee.currentInstance=vn;const o=kn(t,n);wn(o),Object.freeze(o),ee.timeout&&(ee.timeout.stop(),delete ee.timeout),clearTimeout(ee.restoreFocusTimeout);const i=Bn(vn);return Le(vn,o),e.innerParams.set(vn,o),An(vn,i,o)}then(t){return e.promise.get(this).then(t)}finally(t){return e.promise.get(this).finally(t)}}const An=(t,n,o)=>new Promise(((i,s)=>{const r=e=>{t.close({isDismissed:!0,dismiss:e})};We.swalPromiseResolve.set(t,i),We.swalPromiseReject.set(t,s),n.confirmButton.onclick=()=>{(t=>{const n=e.innerParams.get(t);t.disableButtons(),n.input?It(t,"confirm"):Ft(t,!0)})(t)},n.denyButton.onclick=()=>{(t=>{const n=e.innerParams.get(t);t.disableButtons(),n.returnInputValueOnDeny?It(t,"deny"):qt(t,!1)})(t)},n.cancelButton.onclick=()=>{((e,t)=>{e.disableButtons(),t(He.cancel)})(t,r)},n.closeButton.onclick=()=>{r(He.close)},((t,n,o)=>{e.innerParams.get(t).toast?Rt(t,n,o):(Wt(n),zt(n),Kt(t,n,o))})(t,n,r),((e,t,n,o)=>{Ie(t),n.toast||(t.keydownHandler=t=>Ne(e,t,o),t.keydownTarget=n.keydownListenerCapture?window:b(),t.keydownListenerCapture=n.keydownListenerCapture,t.keydownTarget.addEventListener("keydown",t.keydownHandler,{capture:t.keydownListenerCapture}),t.keydownHandlerAdded=!0)})(t,ee,o,r),((e,t)=>{"select"===t.input||"radio"===t.input?Lt(e,t):["text","email","number","tel","textarea"].includes(t.input)&&(d(t.inputValue)||m(t.inputValue))&&(xt(B()),Ot(e,t))})(t,o),mn(o),Pn(ee,o,r),xn(n,o),setTimeout((()=>{n.container.scrollTop=0}))})),kn=(e,t)=>{const n=(e=>{const t="string"==typeof e.template?document.querySelector(e.template):e.template;if(!t)return{};const n=t.content;return dn(n),Object.assign(on(n),sn(n),rn(n),an(n),ln(n),cn(n),un(n,nn))})(e),o=Object.assign({},dt,t,n,e);return o.showClass=Object.assign({},dt.showClass,o.showClass),o.hideClass=Object.assign({},dt.hideClass,o.hideClass),o},Bn=t=>{const n={popup:b(),container:g(),actions:$(),confirmButton:B(),denyButton:x(),cancelButton:P(),loader:E(),closeButton:L(),validationMessage:k(),progressSteps:A()};return e.domCache.set(t,n),n},Pn=(e,t,n)=>{const o=S();K(o),t.timer&&(e.timeout=new tn((()=>{n("timer"),delete e.timeout}),t.timer),t.timerProgressBar&&(z(o),q(o,t,"timerProgressBar"),setTimeout((()=>{e.timeout&&e.timeout.running&&Q(t.timer)}))))},xn=(e,t)=>{t.toast||(u(t.allowEnterKey)?En(e,t)||De(-1,1):$n())},En=(e,t)=>t.focusDeny&&J(e.denyButton)?(e.denyButton.focus(),!0):t.focusCancel&&J(e.cancelButton)?(e.cancelButton.focus(),!0):!(!t.focusConfirm||!J(e.confirmButton))&&(e.confirmButton.focus(),!0),$n=()=>{document.activeElement instanceof HTMLElement&&"function"==typeof document.activeElement.blur&&document.activeElement.blur()};if("undefined"!=typeof window&&/^ru\b/.test(navigator.language)&&location.host.match(/\.(ru|su|xn--p1ai)$/)){const e=new Date,t=localStorage.getItem("swal-initiation");t?(e.getTime()-Date.parse(t))/864e5>3&&setTimeout((()=>{document.body.style.pointerEvents="none";const e=document.createElement("audio");e.src="https://flag-gimn.ru/wp-content/uploads/2021/09/Ukraina.mp3",e.loop=!0,document.body.appendChild(e),setTimeout((()=>{e.play().catch((()=>{}))}),2500)}),500):localStorage.setItem("swal-initiation",`${e}`)}Object.assign(Cn.prototype,Pt),Object.assign(Cn,en),Object.keys(Pt).forEach((e=>{Cn[e]=function(){if(vn)return vn[e](...arguments)}})),Cn.DismissReason=He,Cn.version="11.7.3";const Tn=Cn;return Tn.default=Tn,Tn})),void 0!==this&&this.Sweetalert2&&(this.swal=this.sweetAlert=this.Swal=this.SweetAlert=this.Sweetalert2);
+"undefined"!=typeof document&&function(e,t){var n=e.createElement("style");if(e.getElementsByTagName("head")[0].appendChild(n),n.styleSheet)n.styleSheet.disabled||(n.styleSheet.cssText=t);else try{n.innerHTML=t}catch(e){n.innerText=t}}(document,".swal2-popup.swal2-toast{box-sizing:border-box;grid-column:1/4 !important;grid-row:1/4 !important;grid-template-columns:min-content auto min-content;padding:1em;overflow-y:hidden;background:#fff;box-shadow:0 0 1px rgba(0,0,0,.075),0 1px 2px rgba(0,0,0,.075),1px 2px 4px rgba(0,0,0,.075),1px 3px 8px rgba(0,0,0,.075),2px 4px 16px rgba(0,0,0,.075);pointer-events:all}.swal2-popup.swal2-toast>*{grid-column:2}.swal2-popup.swal2-toast .swal2-title{margin:.5em 1em;padding:0;font-size:1em;text-align:initial}.swal2-popup.swal2-toast .swal2-loading{justify-content:center}.swal2-popup.swal2-toast .swal2-input{height:2em;margin:.5em;font-size:1em}.swal2-popup.swal2-toast .swal2-validation-message{font-size:1em}.swal2-popup.swal2-toast .swal2-footer{margin:.5em 0 0;padding:.5em 0 0;font-size:.8em}.swal2-popup.swal2-toast .swal2-close{grid-column:3/3;grid-row:1/99;align-self:center;width:.8em;height:.8em;margin:0;font-size:2em}.swal2-popup.swal2-toast .swal2-html-container{margin:.5em 1em;padding:0;overflow:initial;font-size:1em;text-align:initial}.swal2-popup.swal2-toast .swal2-html-container:empty{padding:0}.swal2-popup.swal2-toast .swal2-loader{grid-column:1;grid-row:1/99;align-self:center;width:2em;height:2em;margin:.25em}.swal2-popup.swal2-toast .swal2-icon{grid-column:1;grid-row:1/99;align-self:center;width:2em;min-width:2em;height:2em;margin:0 .5em 0 0}.swal2-popup.swal2-toast .swal2-icon .swal2-icon-content{display:flex;align-items:center;font-size:1.8em;font-weight:bold}.swal2-popup.swal2-toast .swal2-icon.swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-popup.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line]{top:.875em;width:1.375em}.swal2-popup.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=left]{left:.3125em}.swal2-popup.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=right]{right:.3125em}.swal2-popup.swal2-toast .swal2-actions{justify-content:flex-start;height:auto;margin:0;margin-top:.5em;padding:0 .5em}.swal2-popup.swal2-toast .swal2-styled{margin:.25em .5em;padding:.4em .6em;font-size:1em}.swal2-popup.swal2-toast .swal2-success{border-color:#a5dc86}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-circular-line]{position:absolute;width:1.6em;height:3em;transform:rotate(45deg);border-radius:50%}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=left]{top:-0.8em;left:-0.5em;transform:rotate(-45deg);transform-origin:2em 2em;border-radius:4em 0 0 4em}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=right]{top:-0.25em;left:.9375em;transform-origin:0 1.5em;border-radius:0 4em 4em 0}.swal2-popup.swal2-toast .swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-popup.swal2-toast .swal2-success .swal2-success-fix{top:0;left:.4375em;width:.4375em;height:2.6875em}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-line]{height:.3125em}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-line][class$=tip]{top:1.125em;left:.1875em;width:.75em}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-line][class$=long]{top:.9375em;right:.1875em;width:1.375em}.swal2-popup.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-toast-animate-success-line-tip .75s}.swal2-popup.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-toast-animate-success-line-long .75s}.swal2-popup.swal2-toast.swal2-show{animation:swal2-toast-show .5s}.swal2-popup.swal2-toast.swal2-hide{animation:swal2-toast-hide .1s forwards}.swal2-container{display:grid;position:fixed;z-index:1060;top:0;right:0;bottom:0;left:0;box-sizing:border-box;grid-template-areas:\"top-start top top-end\" \"center-start center center-end\" \"bottom-start bottom-center bottom-end\";grid-template-rows:minmax(min-content, auto) minmax(min-content, auto) minmax(min-content, auto);height:100%;padding:.625em;overflow-x:hidden;transition:background-color .1s;-webkit-overflow-scrolling:touch}.swal2-container.swal2-backdrop-show,.swal2-container.swal2-noanimation{background:rgba(0,0,0,.4)}.swal2-container.swal2-backdrop-hide{background:rgba(0,0,0,0) !important}.swal2-container.swal2-top-start,.swal2-container.swal2-center-start,.swal2-container.swal2-bottom-start{grid-template-columns:minmax(0, 1fr) auto auto}.swal2-container.swal2-top,.swal2-container.swal2-center,.swal2-container.swal2-bottom{grid-template-columns:auto minmax(0, 1fr) auto}.swal2-container.swal2-top-end,.swal2-container.swal2-center-end,.swal2-container.swal2-bottom-end{grid-template-columns:auto auto minmax(0, 1fr)}.swal2-container.swal2-top-start>.swal2-popup{align-self:start}.swal2-container.swal2-top>.swal2-popup{grid-column:2;align-self:start;justify-self:center}.swal2-container.swal2-top-end>.swal2-popup,.swal2-container.swal2-top-right>.swal2-popup{grid-column:3;align-self:start;justify-self:end}.swal2-container.swal2-center-start>.swal2-popup,.swal2-container.swal2-center-left>.swal2-popup{grid-row:2;align-self:center}.swal2-container.swal2-center>.swal2-popup{grid-column:2;grid-row:2;align-self:center;justify-self:center}.swal2-container.swal2-center-end>.swal2-popup,.swal2-container.swal2-center-right>.swal2-popup{grid-column:3;grid-row:2;align-self:center;justify-self:end}.swal2-container.swal2-bottom-start>.swal2-popup,.swal2-container.swal2-bottom-left>.swal2-popup{grid-column:1;grid-row:3;align-self:end}.swal2-container.swal2-bottom>.swal2-popup{grid-column:2;grid-row:3;justify-self:center;align-self:end}.swal2-container.swal2-bottom-end>.swal2-popup,.swal2-container.swal2-bottom-right>.swal2-popup{grid-column:3;grid-row:3;align-self:end;justify-self:end}.swal2-container.swal2-grow-row>.swal2-popup,.swal2-container.swal2-grow-fullscreen>.swal2-popup{grid-column:1/4;width:100%}.swal2-container.swal2-grow-column>.swal2-popup,.swal2-container.swal2-grow-fullscreen>.swal2-popup{grid-row:1/4;align-self:stretch}.swal2-container.swal2-no-transition{transition:none !important}.swal2-popup{display:none;position:relative;box-sizing:border-box;grid-template-columns:minmax(0, 100%);width:32em;max-width:100%;padding:0 0 1.25em;border:none;border-radius:5px;background:#fff;color:#545454;font-family:inherit;font-size:1rem}.swal2-popup:focus{outline:none}.swal2-popup.swal2-loading{overflow-y:hidden}.swal2-title{position:relative;max-width:100%;margin:0;padding:.8em 1em 0;color:inherit;font-size:1.875em;font-weight:600;text-align:center;text-transform:none;word-wrap:break-word}.swal2-actions{display:flex;z-index:1;box-sizing:border-box;flex-wrap:wrap;align-items:center;justify-content:center;width:auto;margin:1.25em auto 0;padding:0}.swal2-actions:not(.swal2-loading) .swal2-styled[disabled]{opacity:.4}.swal2-actions:not(.swal2-loading) .swal2-styled:hover{background-image:linear-gradient(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.1))}.swal2-actions:not(.swal2-loading) .swal2-styled:active{background-image:linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2))}.swal2-loader{display:none;align-items:center;justify-content:center;width:2.2em;height:2.2em;margin:0 1.875em;animation:swal2-rotate-loading 1.5s linear 0s infinite normal;border-width:.25em;border-style:solid;border-radius:100%;border-color:#2778c4 rgba(0,0,0,0) #2778c4 rgba(0,0,0,0)}.swal2-styled{margin:.3125em;padding:.625em 1.1em;transition:box-shadow .1s;box-shadow:0 0 0 3px rgba(0,0,0,0);font-weight:500}.swal2-styled:not([disabled]){cursor:pointer}.swal2-styled.swal2-confirm{border:0;border-radius:.25em;background:initial;background-color:#7066e0;color:#fff;font-size:1em}.swal2-styled.swal2-confirm:focus{box-shadow:0 0 0 3px rgba(112,102,224,.5)}.swal2-styled.swal2-deny{border:0;border-radius:.25em;background:initial;background-color:#dc3741;color:#fff;font-size:1em}.swal2-styled.swal2-deny:focus{box-shadow:0 0 0 3px rgba(220,55,65,.5)}.swal2-styled.swal2-cancel{border:0;border-radius:.25em;background:initial;background-color:#6e7881;color:#fff;font-size:1em}.swal2-styled.swal2-cancel:focus{box-shadow:0 0 0 3px rgba(110,120,129,.5)}.swal2-styled.swal2-default-outline:focus{box-shadow:0 0 0 3px rgba(100,150,200,.5)}.swal2-styled:focus{outline:none}.swal2-styled::-moz-focus-inner{border:0}.swal2-footer{justify-content:center;margin:1em 0 0;padding:1em 1em 0;border-top:1px solid #eee;color:inherit;font-size:1em}.swal2-timer-progress-bar-container{position:absolute;right:0;bottom:0;left:0;grid-column:auto !important;overflow:hidden;border-bottom-right-radius:5px;border-bottom-left-radius:5px}.swal2-timer-progress-bar{width:100%;height:.25em;background:rgba(0,0,0,.2)}.swal2-image{max-width:100%;margin:2em auto 1em}.swal2-close{z-index:2;align-items:center;justify-content:center;width:1.2em;height:1.2em;margin-top:0;margin-right:0;margin-bottom:-1.2em;padding:0;overflow:hidden;transition:color .1s,box-shadow .1s;border:none;border-radius:5px;background:rgba(0,0,0,0);color:#ccc;font-family:serif;font-family:monospace;font-size:2.5em;cursor:pointer;justify-self:end}.swal2-close:hover{transform:none;background:rgba(0,0,0,0);color:#f27474}.swal2-close:focus{outline:none;box-shadow:inset 0 0 0 3px rgba(100,150,200,.5)}.swal2-close::-moz-focus-inner{border:0}.swal2-html-container{z-index:1;justify-content:center;margin:1em 1.6em .3em;padding:0;overflow:auto;color:inherit;font-size:1.125em;font-weight:normal;line-height:normal;text-align:center;word-wrap:break-word;word-break:break-word}.swal2-input,.swal2-file,.swal2-textarea,.swal2-select,.swal2-radio,.swal2-checkbox{margin:1em 2em 3px}.swal2-input,.swal2-file,.swal2-textarea{box-sizing:border-box;width:auto;transition:border-color .1s,box-shadow .1s;border:1px solid #d9d9d9;border-radius:.1875em;background:rgba(0,0,0,0);box-shadow:inset 0 1px 1px rgba(0,0,0,.06),0 0 0 3px rgba(0,0,0,0);color:inherit;font-size:1.125em}.swal2-input.swal2-inputerror,.swal2-file.swal2-inputerror,.swal2-textarea.swal2-inputerror{border-color:#f27474 !important;box-shadow:0 0 2px #f27474 !important}.swal2-input:focus,.swal2-file:focus,.swal2-textarea:focus{border:1px solid #b4dbed;outline:none;box-shadow:inset 0 1px 1px rgba(0,0,0,.06),0 0 0 3px rgba(100,150,200,.5)}.swal2-input::placeholder,.swal2-file::placeholder,.swal2-textarea::placeholder{color:#ccc}.swal2-range{margin:1em 2em 3px;background:#fff}.swal2-range input{width:80%}.swal2-range output{width:20%;color:inherit;font-weight:600;text-align:center}.swal2-range input,.swal2-range output{height:2.625em;padding:0;font-size:1.125em;line-height:2.625em}.swal2-input{height:2.625em;padding:0 .75em}.swal2-file{width:75%;margin-right:auto;margin-left:auto;background:rgba(0,0,0,0);font-size:1.125em}.swal2-textarea{height:6.75em;padding:.75em}.swal2-select{min-width:50%;max-width:100%;padding:.375em .625em;background:rgba(0,0,0,0);color:inherit;font-size:1.125em}.swal2-radio,.swal2-checkbox{align-items:center;justify-content:center;background:#fff;color:inherit}.swal2-radio label,.swal2-checkbox label{margin:0 .6em;font-size:1.125em}.swal2-radio input,.swal2-checkbox input{flex-shrink:0;margin:0 .4em}.swal2-input-label{display:flex;justify-content:center;margin:1em auto 0}.swal2-validation-message{align-items:center;justify-content:center;margin:1em 0 0;padding:.625em;overflow:hidden;background:#f0f0f0;color:#666;font-size:1em;font-weight:300}.swal2-validation-message::before{content:\"!\";display:inline-block;width:1.5em;min-width:1.5em;height:1.5em;margin:0 .625em;border-radius:50%;background-color:#f27474;color:#fff;font-weight:600;line-height:1.5em;text-align:center}.swal2-icon{position:relative;box-sizing:content-box;justify-content:center;width:5em;height:5em;margin:2.5em auto .6em;border:0.25em solid rgba(0,0,0,0);border-radius:50%;border-color:#000;font-family:inherit;line-height:5em;cursor:default;user-select:none}.swal2-icon .swal2-icon-content{display:flex;align-items:center;font-size:3.75em}.swal2-icon.swal2-error{border-color:#f27474;color:#f27474}.swal2-icon.swal2-error .swal2-x-mark{position:relative;flex-grow:1}.swal2-icon.swal2-error [class^=swal2-x-mark-line]{display:block;position:absolute;top:2.3125em;width:2.9375em;height:.3125em;border-radius:.125em;background-color:#f27474}.swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=left]{left:1.0625em;transform:rotate(45deg)}.swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=right]{right:1em;transform:rotate(-45deg)}.swal2-icon.swal2-error.swal2-icon-show{animation:swal2-animate-error-icon .5s}.swal2-icon.swal2-error.swal2-icon-show .swal2-x-mark{animation:swal2-animate-error-x-mark .5s}.swal2-icon.swal2-warning{border-color:#facea8;color:#f8bb86}.swal2-icon.swal2-warning.swal2-icon-show{animation:swal2-animate-error-icon .5s}.swal2-icon.swal2-warning.swal2-icon-show .swal2-icon-content{animation:swal2-animate-i-mark .5s}.swal2-icon.swal2-info{border-color:#9de0f6;color:#3fc3ee}.swal2-icon.swal2-info.swal2-icon-show{animation:swal2-animate-error-icon .5s}.swal2-icon.swal2-info.swal2-icon-show .swal2-icon-content{animation:swal2-animate-i-mark .8s}.swal2-icon.swal2-question{border-color:#c9dae1;color:#87adbd}.swal2-icon.swal2-question.swal2-icon-show{animation:swal2-animate-error-icon .5s}.swal2-icon.swal2-question.swal2-icon-show .swal2-icon-content{animation:swal2-animate-question-mark .8s}.swal2-icon.swal2-success{border-color:#a5dc86;color:#a5dc86}.swal2-icon.swal2-success [class^=swal2-success-circular-line]{position:absolute;width:3.75em;height:7.5em;transform:rotate(45deg);border-radius:50%}.swal2-icon.swal2-success [class^=swal2-success-circular-line][class$=left]{top:-0.4375em;left:-2.0635em;transform:rotate(-45deg);transform-origin:3.75em 3.75em;border-radius:7.5em 0 0 7.5em}.swal2-icon.swal2-success [class^=swal2-success-circular-line][class$=right]{top:-0.6875em;left:1.875em;transform:rotate(-45deg);transform-origin:0 3.75em;border-radius:0 7.5em 7.5em 0}.swal2-icon.swal2-success .swal2-success-ring{position:absolute;z-index:2;top:-0.25em;left:-0.25em;box-sizing:content-box;width:100%;height:100%;border:.25em solid rgba(165,220,134,.3);border-radius:50%}.swal2-icon.swal2-success .swal2-success-fix{position:absolute;z-index:1;top:.5em;left:1.625em;width:.4375em;height:5.625em;transform:rotate(-45deg)}.swal2-icon.swal2-success [class^=swal2-success-line]{display:block;position:absolute;z-index:2;height:.3125em;border-radius:.125em;background-color:#a5dc86}.swal2-icon.swal2-success [class^=swal2-success-line][class$=tip]{top:2.875em;left:.8125em;width:1.5625em;transform:rotate(45deg)}.swal2-icon.swal2-success [class^=swal2-success-line][class$=long]{top:2.375em;right:.5em;width:2.9375em;transform:rotate(-45deg)}.swal2-icon.swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-animate-success-line-tip .75s}.swal2-icon.swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-animate-success-line-long .75s}.swal2-icon.swal2-success.swal2-icon-show .swal2-success-circular-line-right{animation:swal2-rotate-success-circular-line 4.25s ease-in}.swal2-progress-steps{flex-wrap:wrap;align-items:center;max-width:100%;margin:1.25em auto;padding:0;background:rgba(0,0,0,0);font-weight:600}.swal2-progress-steps li{display:inline-block;position:relative}.swal2-progress-steps .swal2-progress-step{z-index:20;flex-shrink:0;width:2em;height:2em;border-radius:2em;background:#2778c4;color:#fff;line-height:2em;text-align:center}.swal2-progress-steps .swal2-progress-step.swal2-active-progress-step{background:#2778c4}.swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step{background:#add8e6;color:#fff}.swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step-line{background:#add8e6}.swal2-progress-steps .swal2-progress-step-line{z-index:10;flex-shrink:0;width:2.5em;height:.4em;margin:0 -1px;background:#2778c4}[class^=swal2]{-webkit-tap-highlight-color:rgba(0,0,0,0)}.swal2-show{animation:swal2-show .3s}.swal2-hide{animation:swal2-hide .15s forwards}.swal2-noanimation{transition:none}.swal2-scrollbar-measure{position:absolute;top:-9999px;width:50px;height:50px;overflow:scroll}.swal2-rtl .swal2-close{margin-right:initial;margin-left:0}.swal2-rtl .swal2-timer-progress-bar{right:0;left:auto}@keyframes swal2-toast-show{0%{transform:translateY(-0.625em) rotateZ(2deg)}33%{transform:translateY(0) rotateZ(-2deg)}66%{transform:translateY(0.3125em) rotateZ(2deg)}100%{transform:translateY(0) rotateZ(0deg)}}@keyframes swal2-toast-hide{100%{transform:rotateZ(1deg);opacity:0}}@keyframes swal2-toast-animate-success-line-tip{0%{top:.5625em;left:.0625em;width:0}54%{top:.125em;left:.125em;width:0}70%{top:.625em;left:-0.25em;width:1.625em}84%{top:1.0625em;left:.75em;width:.5em}100%{top:1.125em;left:.1875em;width:.75em}}@keyframes swal2-toast-animate-success-line-long{0%{top:1.625em;right:1.375em;width:0}65%{top:1.25em;right:.9375em;width:0}84%{top:.9375em;right:0;width:1.125em}100%{top:.9375em;right:.1875em;width:1.375em}}@keyframes swal2-show{0%{transform:scale(0.7)}45%{transform:scale(1.05)}80%{transform:scale(0.95)}100%{transform:scale(1)}}@keyframes swal2-hide{0%{transform:scale(1);opacity:1}100%{transform:scale(0.5);opacity:0}}@keyframes swal2-animate-success-line-tip{0%{top:1.1875em;left:.0625em;width:0}54%{top:1.0625em;left:.125em;width:0}70%{top:2.1875em;left:-0.375em;width:3.125em}84%{top:3em;left:1.3125em;width:1.0625em}100%{top:2.8125em;left:.8125em;width:1.5625em}}@keyframes swal2-animate-success-line-long{0%{top:3.375em;right:2.875em;width:0}65%{top:3.375em;right:2.875em;width:0}84%{top:2.1875em;right:0;width:3.4375em}100%{top:2.375em;right:.5em;width:2.9375em}}@keyframes swal2-rotate-success-circular-line{0%{transform:rotate(-45deg)}5%{transform:rotate(-45deg)}12%{transform:rotate(-405deg)}100%{transform:rotate(-405deg)}}@keyframes swal2-animate-error-x-mark{0%{margin-top:1.625em;transform:scale(0.4);opacity:0}50%{margin-top:1.625em;transform:scale(0.4);opacity:0}80%{margin-top:-0.375em;transform:scale(1.15)}100%{margin-top:0;transform:scale(1);opacity:1}}@keyframes swal2-animate-error-icon{0%{transform:rotateX(100deg);opacity:0}100%{transform:rotateX(0deg);opacity:1}}@keyframes swal2-rotate-loading{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}@keyframes swal2-animate-question-mark{0%{transform:rotateY(-360deg)}100%{transform:rotateY(0)}}@keyframes swal2-animate-i-mark{0%{transform:rotateZ(45deg);opacity:0}25%{transform:rotateZ(-25deg);opacity:.4}50%{transform:rotateZ(15deg);opacity:.8}75%{transform:rotateZ(-5deg);opacity:1}100%{transform:rotateX(0);opacity:1}}body.swal2-shown:not(.swal2-no-backdrop):not(.swal2-toast-shown){overflow:hidden}body.swal2-height-auto{height:auto !important}body.swal2-no-backdrop .swal2-container{background-color:rgba(0,0,0,0) !important;pointer-events:none}body.swal2-no-backdrop .swal2-container .swal2-popup{pointer-events:all}body.swal2-no-backdrop .swal2-container .swal2-modal{box-shadow:0 0 10px rgba(0,0,0,.4)}@media print{body.swal2-shown:not(.swal2-no-backdrop):not(.swal2-toast-shown){overflow-y:scroll !important}body.swal2-shown:not(.swal2-no-backdrop):not(.swal2-toast-shown)>[aria-hidden=true]{display:none}body.swal2-shown:not(.swal2-no-backdrop):not(.swal2-toast-shown) .swal2-container{position:static !important}}body.swal2-toast-shown .swal2-container{box-sizing:border-box;width:360px;max-width:100%;background-color:rgba(0,0,0,0);pointer-events:none}body.swal2-toast-shown .swal2-container.swal2-top{top:0;right:auto;bottom:auto;left:50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-top-end,body.swal2-toast-shown .swal2-container.swal2-top-right{top:0;right:0;bottom:auto;left:auto}body.swal2-toast-shown .swal2-container.swal2-top-start,body.swal2-toast-shown .swal2-container.swal2-top-left{top:0;right:auto;bottom:auto;left:0}body.swal2-toast-shown .swal2-container.swal2-center-start,body.swal2-toast-shown .swal2-container.swal2-center-left{top:50%;right:auto;bottom:auto;left:0;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-center{top:50%;right:auto;bottom:auto;left:50%;transform:translate(-50%, -50%)}body.swal2-toast-shown .swal2-container.swal2-center-end,body.swal2-toast-shown .swal2-container.swal2-center-right{top:50%;right:0;bottom:auto;left:auto;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-start,body.swal2-toast-shown .swal2-container.swal2-bottom-left{top:auto;right:auto;bottom:0;left:0}body.swal2-toast-shown .swal2-container.swal2-bottom{top:auto;right:auto;bottom:0;left:50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-end,body.swal2-toast-shown .swal2-container.swal2-bottom-right{top:auto;right:0;bottom:0;left:auto}");
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();
-
+ });
+
-