Răsfoiți Sursa

Show previous plan + copy from previous plan

Vijayakrishnan 3 ani în urmă
părinte
comite
de3190d29a

+ 29 - 1
resources/views/app/patient/segment-templates/_child_plan/edit-plan.php

@@ -1,8 +1,27 @@
 <?php
 $currentValue = '';
+$previousValue = '';
+$previousChildPlan = null;
 if ($point->lastChildPlan && $point->last_child_plan_point_scoped_note_id === $note->id) {
     $parsedPlan = json_decode($point->lastChildPlan->data);
     $currentValue = $parsedPlan->value;
+    $previousChildPlan = \App\Models\Point::where('id', '<', $point->lastChildPlan->id)
+        ->where('parent_point_id', $point->id)
+        ->orderBy('id', 'DESC')
+        ->first();
+    if($previousChildPlan && $previousChildPlan->data) {
+        $parsedPlan = json_decode($previousChildPlan->data);
+        $previousValue = $parsedPlan->value;
+    }
+}
+else {
+    $previousChildPlan = \App\Models\Point::where('parent_point_id', $point->id)
+        ->orderBy('id', 'DESC')
+        ->first();
+    if($previousChildPlan && $previousChildPlan->data) {
+        $parsedPlan = json_decode($previousChildPlan->data);
+        $previousValue = $parsedPlan->value;
+    }
 }
 ?>
 <div visit-moe large relative class="d-inline">
@@ -12,7 +31,16 @@ if ($point->lastChildPlan && $point->last_child_plan_point_scoped_note_id === $n
         <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
         <input type="hidden" name="data">
 
-        <p class="mb-2"><b>Review</b></p>
+        <p class="mb-2"><b>Plan</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 Plan / <?= friendlier_date($previousChildPlan->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">
             <div note-rte