瀏覽代碼

Omega - module UI (wip)

Vijayakrishnan 3 年之前
父節點
當前提交
ff7503e0e2

+ 29 - 0
app/Models/Point.php

@@ -148,6 +148,35 @@ class Point extends Model
         return $points;
     }
 
+    public static function getIntakePoints(Client $_patient, Note $_note, $_assoc = false) {
+        $points = Point
+            ::where('client_id', $_patient->id)
+            ->where('is_removed_due_to_entry_error', false)
+            ->where(function ($query1) use ($_note) {
+                $query1
+                    ->where(function ($query2) use ($_note) {
+                        $query2->where('is_removed', false)
+                            ->where('addition_reason_category', 'ON_INTAKE')
+                            ->where('added_in_note_id', $_note->id);
+                    })
+                    ->orWhere(function ($query2) use ($_note) {
+                        $query2->where('is_removed', true)
+                            ->where('removal_reason_category', 'ON_INTAKE')
+                            ->where('removed_in_note_id', $_note->id);
+                    })
+                    ->orWhere('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)

+ 14 - 0
resources/views/app/patient/module-specific-summary-renderers/intake_behavior/summary.blade.php

@@ -0,0 +1,14 @@
+@foreach($points as $point)
+    <div class="d-flex align-items-start" data-uid="{{$point ? $point->uid : ''}}">
+        <b class="mr-2">{{ucwords(str_replace('_', ' ', strtolower($point->category)))}}</b>
+        <div class="flex-grow-1 ml-3">
+            @if($point)
+                <?php
+                include resource_path('views/app/patient/segment-templates/_child_review/last-review-flat.php');
+                ?>
+            @else
+                -
+            @endif
+        </div>
+    </div>
+@endforeach

+ 14 - 0
resources/views/app/patient/module-specific-summary-renderers/intake_exercise/summary.blade.php

@@ -0,0 +1,14 @@
+@foreach($points as $point)
+    <div class="d-flex align-items-start" data-uid="{{$point ? $point->uid : ''}}">
+        <b class="mr-2">{{ucwords(str_replace('_', ' ', strtolower($point->category)))}}</b>
+        <div class="flex-grow-1 ml-3">
+            @if($point)
+                <?php
+                include resource_path('views/app/patient/segment-templates/_child_review/last-review-flat.php');
+                ?>
+            @else
+                -
+            @endif
+        </div>
+    </div>
+@endforeach

+ 14 - 0
resources/views/app/patient/module-specific-summary-renderers/intake_generic/summary.blade.php

@@ -0,0 +1,14 @@
+@foreach($points as $point)
+    <div class="d-flex align-items-start" data-uid="{{$point ? $point->uid : ''}}">
+        <b class="mr-2">{{ucwords(str_replace('_', ' ', strtolower($point->category)))}}</b>
+        <div class="flex-grow-1 ml-3">
+            @if($point)
+                <?php
+                include resource_path('views/app/patient/segment-templates/_child_review/last-review-flat.php');
+                ?>
+            @else
+                -
+            @endif
+        </div>
+    </div>
+@endforeach

+ 14 - 0
resources/views/app/patient/module-specific-summary-renderers/intake_nutrition/summary.blade.php

@@ -0,0 +1,14 @@
+@foreach($points as $point)
+    <div class="d-flex align-items-start" data-uid="{{$point ? $point->uid : ''}}">
+        <b class="mr-2">{{ucwords(str_replace('_', ' ', strtolower($point->category)))}}</b>
+        <div class="flex-grow-1 ml-3">
+            @if($point)
+                <?php
+                include resource_path('views/app/patient/segment-templates/_child_review/last-review-flat.php');
+                ?>
+            @else
+                -
+            @endif
+        </div>
+    </div>
+@endforeach

+ 8 - 0
resources/views/app/patient/segment-templates/_child_review/last-review-flat.php

@@ -0,0 +1,8 @@
+<?php if ($point->lastChildReview): ?>
+    <?php $parsedReview = json_decode($point->lastChildReview->data); ?>
+    <div class="d-inline-flex">
+        <div class="inline-html-container"><?= @$parsedReview->value ?></div>
+    </div>
+<?php else: ?>
+    <span class="text-secondary text-sm">-</span>
+<?php endif; ?>

+ 0 - 1
resources/views/app/patient/segment-templates/omega_subjective_system/edit.blade.php

@@ -1 +0,0 @@
-<h1>omega_subjective_system</h1>

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

@@ -1 +1,41 @@
-<h1>omega_subjective_system</h1>
+<?php
+
+use App\Models\Point;
+
+/** @var \App\Models\Client $patient */
+/** @var \App\Models\Note $note */
+
+$points = Point::getIntakePoints($patient, $note);
+
+$topLevelPointToRendererMap = [
+    'HIGH_SUGAR_BEVERAGES' => 'intake_nutrition',
+    'WATER_INTAKE' => 'intake_nutrition',
+    'FAST_FOOD' => 'intake_nutrition',
+    'SNACKS' => 'intake_nutrition',
+    'VEGETABLES' => 'intake_nutrition',
+    'PORTION_SIZES' => 'intake_nutrition',
+    'DAILY_INTAKE_CARBOHYDRATES' => 'intake_nutrition',
+    'DAILY_INTAKE_CALORIES' => 'intake_nutrition',
+    'AEROBIC_ACTIVITY' => 'intake_exercise',
+    'STRENGTH_TRAINING' => 'intake_exercise',
+    'NEAT,' => 'intake_exercise',
+    'SELF_MONITORING' => 'intake_behavior',
+    'FOOD_TRIGGERS' => 'intake_behavior',
+    'CRAVINGS' => 'intake_behavior',
+    'SLEEP_HABITS' => 'intake_behavior',
+];
+
+$pointMap = [];
+
+foreach($points as $point){
+    if(!isset($topLevelPointToRendererMap[$point->category])) continue;
+    if(!isset($pointMap[$point->category])) $pointMap[$point->category] = [];
+    $pointMap[$point->category][] = $point;
+}
+
+foreach ($pointMap as $category => $points) {
+?>
+    @include('app.patient.module-specific-summary-renderers.' . $topLevelPointToRendererMap[$category] . '.summary', compact('points'))
+<?php
+}
+