|
@@ -132,10 +132,10 @@ class AdminController extends Controller
|
|
|
$fVal = $request->input('has_account');
|
|
|
if($fVal) {
|
|
|
if($fVal === 'YES') {
|
|
|
- $patients = $patients->whereRaw("((SELECT COUNT(ac.id) FROM account_client ac WHERE ac.client_id = client.id) > 0)");
|
|
|
+ $patients = $patients->whereRaw("((SELECT COUNT(ac.id) FROM account_client ac WHERE ac.client_id = admin_patient_list.id) > 0)");
|
|
|
}
|
|
|
else {
|
|
|
- $patients = $patients->whereRaw("((SELECT COUNT(ac.id) FROM account_client ac WHERE ac.client_id = client.id) = 0)");
|
|
|
+ $patients = $patients->whereRaw("((SELECT COUNT(ac.id) FROM account_client ac WHERE ac.client_id = admin_patient_list.id) = 0)");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -174,12 +174,12 @@ class AdminController extends Controller
|
|
|
if($fVal === 'YES') {
|
|
|
$patients = $patients->whereRaw("((SELECT count(sh.id) " .
|
|
|
"FROM shipment sh LEFT JOIN supply_order so ON so.shipment_id = sh.id " .
|
|
|
- "WHERE so.product_id = 1 AND sh.status IN ('DELIVERED', 'DISPATCHED') AND so.client_id = client.id) > 0)");
|
|
|
+ "WHERE so.product_id = 1 AND sh.status IN ('DELIVERED', 'DISPATCHED') AND so.client_id = admin_patient_list.id) > 0)");
|
|
|
}
|
|
|
else {
|
|
|
$patients = $patients->whereRaw("((SELECT count(sh.id) " .
|
|
|
"FROM shipment sh LEFT JOIN supply_order so ON so.shipment_id = sh.id " .
|
|
|
- "WHERE so.product_id = 1 AND sh.status IN ('DELIVERED', 'DISPATCHED') AND so.client_id = client.id) = 0)");
|
|
|
+ "WHERE so.product_id = 1 AND sh.status IN ('DELIVERED', 'DISPATCHED') AND so.client_id = admin_patient_list.id) = 0)");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -188,12 +188,12 @@ class AdminController extends Controller
|
|
|
if($fVal === 'YES') {
|
|
|
$patients = $patients->whereRaw("((SELECT count(sh.id) " .
|
|
|
"FROM shipment sh LEFT JOIN supply_order so ON so.shipment_id = sh.id " .
|
|
|
- "WHERE so.product_id = 2 AND sh.status IN ('DELIVERED', 'DISPATCHED') AND so.client_id = client.id) > 0)");
|
|
|
+ "WHERE so.product_id = 2 AND sh.status IN ('DELIVERED', 'DISPATCHED') AND so.client_id = admin_patient_list.id) > 0)");
|
|
|
}
|
|
|
else {
|
|
|
$patients = $patients->whereRaw("((SELECT count(sh.id) " .
|
|
|
"FROM shipment sh LEFT JOIN supply_order so ON so.shipment_id = sh.id " .
|
|
|
- "WHERE so.product_id = 2 AND sh.status IN ('DELIVERED', 'DISPATCHED') AND so.client_id = client.id) = 0)");
|
|
|
+ "WHERE so.product_id = 2 AND sh.status IN ('DELIVERED', 'DISPATCHED') AND so.client_id = admin_patient_list.id) = 0)");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -202,12 +202,12 @@ class AdminController extends Controller
|
|
|
if($fVal === 'YES') {
|
|
|
$patients = $patients->whereRaw("((SELECT count(sh.id) " .
|
|
|
"FROM shipment sh LEFT JOIN supply_order so ON so.shipment_id = sh.id " .
|
|
|
- "WHERE so.product_id = 3 AND sh.status IN ('DELIVERED', 'DISPATCHED') AND so.client_id = client.id) > 0)");
|
|
|
+ "WHERE so.product_id = 3 AND sh.status IN ('DELIVERED', 'DISPATCHED') AND so.client_id = admin_patient_list.id) > 0)");
|
|
|
}
|
|
|
else {
|
|
|
$patients = $patients->whereRaw("((SELECT count(sh.id) " .
|
|
|
"FROM shipment sh LEFT JOIN supply_order so ON so.shipment_id = sh.id " .
|
|
|
- "WHERE so.product_id = 3 AND sh.status IN ('DELIVERED', 'DISPATCHED') AND so.client_id = client.id) = 0)");
|
|
|
+ "WHERE so.product_id = 3 AND sh.status IN ('DELIVERED', 'DISPATCHED') AND so.client_id = admin_patient_list.id) = 0)");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -216,24 +216,24 @@ class AdminController extends Controller
|
|
|
if($fVal === 'YES') {
|
|
|
$patients = $patients->whereRaw("((SELECT count(sh.id) " .
|
|
|
"FROM shipment sh LEFT JOIN supply_order so ON so.shipment_id = sh.id " .
|
|
|
- "WHERE so.product_id = 4 AND sh.status IN ('DELIVERED', 'DISPATCHED') AND so.client_id = client.id) > 0)");
|
|
|
+ "WHERE so.product_id = 4 AND sh.status IN ('DELIVERED', 'DISPATCHED') AND so.client_id = admin_patient_list.id) > 0)");
|
|
|
}
|
|
|
else {
|
|
|
$patients = $patients->whereRaw("((SELECT count(sh.id) " .
|
|
|
"FROM shipment sh LEFT JOIN supply_order so ON so.shipment_id = sh.id " .
|
|
|
- "WHERE so.product_id = 4 AND sh.status IN ('DELIVERED', 'DISPATCHED') AND so.client_id = client.id) = 0)");
|
|
|
+ "WHERE so.product_id = 4 AND sh.status IN ('DELIVERED', 'DISPATCHED') AND so.client_id = admin_patient_list.id) = 0)");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$fVal = $request->input('imei');
|
|
|
if($fVal) {
|
|
|
$patients = $patients->whereRaw("((SELECT count(cbd.id) FROM client_bdt_device cbd
|
|
|
- WHERE cbd.client_id = client.id AND cbd.device_id IN (SELECT bd.id FROM bdt_device bd WHERE bd.imei LIKE '%$fVal%' AND bd.is_active IS TRUE)) > 0)");
|
|
|
+ WHERE cbd.client_id = admin_patient_list.id AND cbd.device_id IN (SELECT bd.id FROM bdt_device bd WHERE bd.imei LIKE '%$fVal%' AND bd.is_active IS TRUE)) > 0)");
|
|
|
}
|
|
|
|
|
|
if($request->input('number_of_measurements')){
|
|
|
$keyName = $request->input('number_of_measurements');
|
|
|
- $measurementCountQuery = '(SELECT COUNT(*) FROM measurement WHERE measurement.client_id = client.id AND is_active IS TRUE AND is_cellular IS TRUE AND is_cellular_zero IS NOT TRUE)';
|
|
|
+ $measurementCountQuery = '(SELECT COUNT(*) FROM measurement WHERE measurement.client_id = admin_patient_list.id AND is_active IS TRUE AND is_cellular IS TRUE AND is_cellular_zero IS NOT TRUE)';
|
|
|
switch($keyName) {
|
|
|
case 'EXACTLY':
|
|
|
if($request->input('number_of_measurements_value_1')) {
|
|
@@ -328,7 +328,7 @@ class AdminController extends Controller
|
|
|
|
|
|
}
|
|
|
|
|
|
- $sortBy = $request->input('sort_by') ?: 'display_name';
|
|
|
+ $sortBy = $request->input('sort_by') ?: 'name_first';
|
|
|
$sortDir = $request->input('sort_dir') ?: 'ASC';
|
|
|
|
|
|
$sortBySQL = "$sortBy $sortDir NULLS LAST";
|