Ver código fonte

Visit UI - top-level queries fix

Vijayakrishnan 3 anos atrás
pai
commit
dc22ed3279
1 arquivos alterados com 8 adições e 2 exclusões
  1. 8 2
      app/Models/Point.php

+ 8 - 2
app/Models/Point.php

@@ -44,7 +44,14 @@ class Point extends Model
         $points = Point
             ::where('client_id', $_patient->id)
             ->where('category', $_category)
-            ->where('addition_reason_category', 'ON_INTAKE')
+            ->where(function ($query1) use ($_note) {
+                $query1
+                    ->where('addition_reason_category', 'ON_INTAKE')
+                    ->orWhere(function ($query2) use ($_note) {
+                        $query2->where('addition_reason_category', 'DURING_VISIT')
+                            ->where('added_in_note_id', '<>', $_note->id);
+                    });
+            })
             ->where(function ($query1) use ($_note) {
                 $query1
                     ->where('is_removed', false)
@@ -67,7 +74,6 @@ class Point extends Model
         $points = Point
             ::where('client_id', $_patient->id)
             ->where('category', $_category)
-            ->where('addition_reason_category', 'DURING_VISIT')
             ->where(function ($query1) use ($_note) {
                 $query1
                     ->where('is_removed', false)