Ver Fonte

Patients list - device filters

Vijayakrishnan há 3 anos atrás
pai
commit
58a15a0260

+ 56 - 0
app/Http/Controllers/AdminController.php

@@ -166,6 +166,62 @@ class AdminController extends Controller
             }
         }
 
+        $fVal = $request->input('has_bp_device');
+        if($fVal) {
+            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)");
+            }
+            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)");
+            }
+        }
+
+        $fVal = $request->input('has_weight_scale');
+        if($fVal) {
+            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)");
+            }
+            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)");
+            }
+        }
+
+        $fVal = $request->input('has_pulse_ox');
+        if($fVal) {
+            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)");
+            }
+            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)");
+            }
+        }
+
+        $fVal = $request->input('has_temp_fun');
+        if($fVal) {
+            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)");
+            }
+            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)");
+            }
+        }
+
         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)';

+ 49 - 1
resources/views/app/admin/patients_filters.blade.php

@@ -365,6 +365,50 @@
 		</div>
 	</div>
 
+	<div class="sm-section">
+		<div class="">
+			<label>Has BP Device:</label>
+			<select name="has_bp_device" class="form-control input-sm" v-model="filters.has_bp_device">
+				<option value="">All</option>
+				<option value="YES">Yes</option>
+				<option value="NO">No</option>
+			</select>
+		</div>
+	</div>
+
+	<div class="sm-section">
+		<div class="">
+			<label>Has Weight Scale:</label>
+			<select name="has_weight_scale" class="form-control input-sm" v-model="filters.has_weight_scale">
+				<option value="">All</option>
+				<option value="YES">Yes</option>
+				<option value="NO">No</option>
+			</select>
+		</div>
+	</div>
+
+	<div class="sm-section">
+		<div class="">
+			<label>Has Pulse Ox:</label>
+			<select name="has_pulse_ox" class="form-control input-sm" v-model="filters.has_pulse_ox">
+				<option value="">All</option>
+				<option value="YES">Yes</option>
+				<option value="NO">No</option>
+			</select>
+		</div>
+	</div>
+
+	<div class="sm-section">
+		<div class="">
+			<label>Has Temp. Gun:</label>
+			<select name="has_temp_fun" class="form-control input-sm" v-model="filters.has_temp_fun">
+				<option value="">All</option>
+				<option value="YES">Yes</option>
+				<option value="NO">No</option>
+			</select>
+		</div>
+	</div>
+
 	@if($performer->pro->pro_type == 'ADMIN')
 	<div class="sm-section">
 		<div class="">
@@ -485,7 +529,11 @@ $allFilterKeys = [
 	'has_account',
 	'has_default_mcp_company_pro',
 	'has_default_mcp_company_pro_payer',
-	'has_default_mcp_company_location'
+	'has_default_mcp_company_location',
+	'has_bp_device',
+	'has_weight_scale',
+	'has_pulse_ox',
+	'has_temp_fun'
 ];
 for ($i=0; $i < count($allFilterKeys); $i++) {
 	if (!isset($loadedFilters[$allFilterKeys[$i]]) || !$loadedFilters[$allFilterKeys[$i]]) {