Просмотр исходного кода

Omega - intake/plan logic updates

Vijayakrishnan 3 лет назад
Родитель
Сommit
16295ccd89
1 измененных файлов с 3 добавлено и 2 удалено
  1. 3 2
      app/Models/Point.php

+ 3 - 2
app/Models/Point.php

@@ -123,6 +123,7 @@ class Point extends Model
             ::where('client_id', $_patient->id)
             ->where('category', $_category)
             ->where('is_removed_due_to_entry_error', false)
+            ->whereRaw("(is_removed = TRUE OR addition_reason_category != 'DURING_VISIT' OR added_in_note_id != {$_note->id})")
             ->where(function ($query1) use ($_note) {
                 $query1
                     ->where(function ($query2) use ($_note) {
@@ -152,6 +153,7 @@ class Point extends Model
         $points = Point
             ::where('client_id', $_patient->id)
             ->where('is_removed_due_to_entry_error', false)
+            ->whereRaw("(is_removed = TRUE OR addition_reason_category != 'DURING_VISIT' OR added_in_note_id != {$_note->id})")
             ->where(function ($query1) use ($_note) {
                 $query1
                     ->where(function ($query2) use ($_note) {
@@ -223,8 +225,7 @@ class Point extends Model
                             ->where('removal_reason_category', 'DURING_VISIT')
                             ->where('removed_in_note_id', $_note->id);
                     })
-                    ->orWhere('last_child_plan_point_scoped_note_id', $_note->id)
-                    ->orWhereRaw("(SELECT count(id) from note_point WHERE is_active IS TRUE AND note_id = {$_note->id} AND point_id = point.id) > 0");
+                    ->orWhere('last_child_plan_point_scoped_note_id', $_note->id);
             })
             ->orderBy('created_at')
             ->get();