Преглед изворни кода

Limit patients to those with shadow_client_id == null

Vijayakrishnan пре 4 година
родитељ
комит
2c7f5282af
2 измењених фајлова са 9 додато и 7 уклоњено
  1. 6 5
      app/Http/Controllers/HomeController.php
  2. 3 2
      app/Models/Pro.php

+ 6 - 5
app/Http/Controllers/HomeController.php

@@ -589,11 +589,12 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
         $pro = $this->pro;
         $term = $request->input('term') ? trim($request->input('term')) : '';
         if (empty($term)) return '';
-        $clientQuery= Client::where(function ($q) use ($term) {
-            $q->where('name_first', 'ILIKE', '%' . $term . '%')
-                ->orWhere('name_last', 'ILIKE', '%' . $term . '%')
-                ->orWhere('cell_number', 'ILIKE', '%' . $term . '%');
-        });
+        $clientQuery= Client::whereNull('shadow_pro_id')
+            ->where(function ($q) use ($term) {
+                $q->where('name_first', 'ILIKE', '%' . $term . '%')
+                    ->orWhere('name_last', 'ILIKE', '%' . $term . '%')
+                    ->orWhere('cell_number', 'ILIKE', '%' . $term . '%');
+            });
 
         if($pro->pro_type != 'ADMIN') {
             $clientQuery->where(function ($q) use ($pro) {

+ 3 - 2
app/Models/Pro.php

@@ -280,10 +280,11 @@ class Pro extends Model
 
     public function getAccessibleClientsQuery() {
         $proID = $this->id;
+        $query = Client::whereNull('shadow_pro_id');
         if ($this->pro_type === 'ADMIN') {
-            $query = Client::where('id', '>', 0);
+            $query = $query->where('id', '>', 0);
         } else {
-            $query = Client::where(function ($q) use ($proID) {
+            $query = $query->where(function ($q) use ($proID) {
                 $q->where('mcp_pro_id', $proID)
                     ->orWhere('cm_pro_id', $proID)
                     ->orWhere('rmm_pro_id', $proID)