Bladeren bron

Omega subj system - behavior/exercise/nutrition - show only if child review exists or relevant

Vijayakrishnan 3 jaren geleden
bovenliggende
commit
2f427e28f3

+ 20 - 0
app/Models/Point.php

@@ -179,6 +179,26 @@ class Point extends Model
         return $points;
     }
 
+    public static function getIntakePointsWithChildReview(Client $_patient, Note $_note, $_assoc = false) {
+        $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('last_child_review_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");
+            })
+            ->orderBy('created_at')
+            ->get();
+        foreach ($points as $point) {
+            if ($point->data) {
+                $point->data = json_decode($point->data, $_assoc);
+            }
+        }
+        return $points;
+    }
+
     public static function getPlanPointsOfCategory(Client $_patient, String $_category, Note $_note, $_assoc = false) {
         $points = Point
             ::where('client_id', $_patient->id)

+ 2 - 2
resources/views/app/patient/segment-templates/omega_subjective_system/summary.blade.php

@@ -5,7 +5,7 @@ use App\Models\Point;
 /** @var \App\Models\Client $patient */
 /** @var \App\Models\Note $note */
 
-$points = Point::getIntakePoints($patient, $note);
+$points = Point::getIntakePointsWithChildReview($patient, $note);
 
 $topLevelPointToRendererMap = [
     'HIGH_SUGAR_BEVERAGES' => 'nutrition',
@@ -18,7 +18,7 @@ $topLevelPointToRendererMap = [
     'DAILY_INTAKE_CALORIES' => 'nutrition',
     'AEROBIC_ACTIVITY' => 'exercise',
     'STRENGTH_TRAINING' => 'exercise',
-    'NEAT,' => 'exercise',
+    'NEAT' => 'exercise',
     'SELF_MONITORING' => 'behavior',
     'FOOD_TRIGGERS' => 'behavior',
     'CRAVINGS' => 'behavior',