Forráskód Böngészése

Patients list - has-email and has-account filters

Vijayakrishnan 3 éve
szülő
commit
4ec0e2f92b

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

@@ -116,6 +116,26 @@ class AdminController extends Controller
         $this->filterMultiQuery($request, $patients, 'created_at', 'created_at', 'created_at_value_1', 'created_at_value_2');
         $this->filterMultiQuery($request, $patients, 'most_recent_completed_mcp_note_date', 'last_visit_category', 'last_visit_value_1', 'last_visit_value_2');
 
+        $hasEmail = $request->input('has_email');
+        if($hasEmail) {
+            if($hasEmail === 'YES') {
+                $patients = $patients->whereRaw("(email_address IS NOT NULL AND TRIM(email_address) != '')");
+            }
+            else {
+                $patients = $patients->whereRaw("(email_address IS NULL OR TRIM(email_address) = '')");
+            }
+        }
+
+        $hasAccount = $request->input('has_account');
+        if($hasAccount) {
+            if($hasAccount === 'YES') {
+                $patients = $patients->whereRaw("((SELECT COUNT(ac.id) FROM account_client ac WHERE ac.client_id = client.id) > 0)");
+            }
+            else {
+                $patients = $patients->whereRaw("((SELECT COUNT(ac.id) FROM account_client ac WHERE ac.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)';

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

@@ -310,6 +310,28 @@
 		</div>
 	</div>
 
+	<div class="sm-section">
+		<div class="">
+			<label>Has Email:</label>
+			<select name="has_email" class="form-control input-sm" v-model="filters.has_email">
+				<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 Account:</label>
+			<select name="has_account" class="form-control input-sm" v-model="filters.has_account">
+				<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="">
@@ -426,7 +448,8 @@ $allFilterKeys = [
 	'created_at',
 	'created_at_value_1',
 	'created_at_value_2',
-
+	'has_email',
+	'has_account'
 ];
 for ($i=0; $i < count($allFilterKeys); $i++) {
 	if (!isset($loadedFilters[$allFilterKeys[$i]]) || !$loadedFilters[$allFilterKeys[$i]]) {

+ 1 - 1
resources/views/app/patient/coverage_column_renderer.blade.php

@@ -45,7 +45,7 @@
                     <span class="text-muted d-block text-sm ml-1">(Ded: {{format_number(@$patient->mpb_remaining)}})</span>
                 @endif
             @endif
-            @if($coverage->plan_type === 'COMMERCIAL')
+            @if($coverage && $coverage->plan_type === 'COMMERCIAL')
                 @if(@$coverage->deductible_amount && !!+@$coverage->deductible_amount)
                     <span class="text-muted d-block text-sm ml-1">(Ded: {{format_number(@$coverage->deductible_amount)}})</span>
                 @endif