Przeglądaj źródła

Show previous review + copy from previous review

Vijayakrishnan 3 lat temu
rodzic
commit
41361fa3d5

+ 2 - 0
resources/views/app/patient/segment-templates/_child_plan/edit-plan.php

@@ -6,6 +6,7 @@ if ($point->lastChildPlan && $point->last_child_plan_point_scoped_note_id === $n
     $parsedPlan = json_decode($point->lastChildPlan->data);
     $currentValue = $parsedPlan->value;
     $previousChildPlan = \App\Models\Point::where('id', '<', $point->lastChildPlan->id)
+        ->where('category', 'PLAN')
         ->where('parent_point_id', $point->id)
         ->orderBy('id', 'DESC')
         ->first();
@@ -16,6 +17,7 @@ if ($point->lastChildPlan && $point->last_child_plan_point_scoped_note_id === $n
 }
 else {
     $previousChildPlan = \App\Models\Point::where('parent_point_id', $point->id)
+        ->where('category', 'PLAN')
         ->orderBy('id', 'DESC')
         ->first();
     if($previousChildPlan && $previousChildPlan->data) {

+ 35 - 1
resources/views/app/patient/segment-templates/_child_review/edit-review.php

@@ -1,8 +1,33 @@
 <?php
 $currentValue = '';
+$previousValue = '';
+$previousChildReview = null;
 if ($point->lastChildReview && $point->last_child_review_point_scoped_note_id === $note->id) {
     $parsedReview = json_decode($point->lastChildReview->data);
-    $currentValue = $parsedReview->value;
+    if(@$parsedReview->value) {
+        $currentValue = $parsedReview->value;
+        $previousChildReview = \App\Models\Point::where('id', '<', $point->lastChildReview->id)
+            ->where('category', 'REVIEW')
+            ->where('parent_point_id', $point->id)
+            ->orderBy('id', 'DESC')
+            ->first();
+        if($previousChildReview && $previousChildReview->data) {
+            $parsedReview = json_decode($previousChildReview->data);
+            $previousValue = $parsedReview->value;
+        }
+    }
+}
+else {
+    $previousChildReview = \App\Models\Point::where('parent_point_id', $point->id)
+        ->where('category', 'REVIEW')
+        ->orderBy('id', 'DESC')
+        ->first();
+    if($previousChildReview && $previousChildReview->data) {
+        $parsedReview = json_decode($previousChildReview->data);
+        if(@$parsedReview->value) {
+            $previousValue = $parsedReview->value;
+        }
+    }
 }
 ?>
 <div visit-moe relative class="d-inline">
@@ -14,6 +39,15 @@ if ($point->lastChildReview && $point->last_child_review_point_scoped_note_id ==
 
         <p class="mb-2"><b>Review</b></p>
 
+        <?php if($previousValue): ?>
+            <div class="mb-2">
+                <div class="d-flex align-items-baseline mb-1">
+                    <span class="text-sm text-secondary">Previous Review / <?= friendlier_date($previousChildReview->created_at) ?>) (click to copy)</span>
+                </div>
+                <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
+            </div>
+        <?php endif; ?>
+
         <div class="mb-2">
             <textarea data-name="value" class="form-control form-control-sm" rows="3"><?= $currentValue ?></textarea>
         </div>