Jelajahi Sumber

Visit UI - $intakeOrVisit param in review includes

Vijayakrishnan 3 tahun lalu
induk
melakukan
d9e878f0a0

+ 24 - 1
app/Models/Point.php

@@ -20,7 +20,7 @@ class Point extends Model
 
     public function lastChildPlan()
     {
-        return $this->hasOne(Point::class, 'id', 'last_child_review_point_id');
+        return $this->hasOne(Point::class, 'id', 'last_child_plan_point_id');
     }
 
     public function lastChildPlanNote()
@@ -62,4 +62,27 @@ class Point extends Model
         }
         return $points;
     }
+
+    public static function getPlanPointsOfCategory(Client $_patient, String $_category, Note $_note, $_assoc = false) {
+        $points = Point
+            ::where('client_id', $_patient->id)
+            ->where('category', $_category)
+            ->where('addition_reason_category', 'DURING_VISIT')
+            ->where(function ($query1) use ($_note) {
+                $query1
+                    ->where('is_removed', false)
+                    ->orWhere(function ($query2) use ($_note) {
+                        $query2->where('is_removed', true)
+                            ->where('removed_in_note_id', $_note->id);
+                    });
+            })
+            ->orderBy('created_at')
+            ->get();
+        foreach ($points as $point) {
+            if ($point->data) {
+                $point->data = json_decode($point->data, $_assoc);
+            }
+        }
+        return $points;
+    }
 }

+ 22 - 9
resources/views/app/patient/segment-templates/_child_review/edit-review.php

@@ -1,6 +1,25 @@
-<div visit-moe>
+<?php
+if (!@$intakeOrVisit) {
+    $intakeOrVisit = 'INTAKE'; // default
+}
+$epPart = ($intakeOrVisit === 'INTAKE') ? 'Review' : 'Plan';
+$currentValue = '';
+if($intakeOrVisit === 'INTAKE') {
+    if ($point->lastChildReview && $point->last_child_review_point_scoped_note_id === $note->id) {
+        $parsedReview = json_decode($point->lastChildReview->data);
+        $currentValue = $parsedReview->value;
+    }
+}
+else {
+    if ($point->lastChildPlan && $point->last_child_plan_point_scoped_note_id === $note->id) {
+        $parsedReview = json_decode($point->lastChildPlan->data);
+        $currentValue = $parsedReview->value;
+    }
+}
+?>
+<div visit-moe relative>
     <a start show href="#">Edit</a>
-    <form url="/api/visitPoint/upsertChildReview" class="mcp-theme-1">
+    <form url="/api/visitPoint/upsertChild<?= $epPart ?>" class="mcp-theme-1" right>
         <input type="hidden" name="uid" value="<?= $point->uid ?>">
         <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
         <input type="hidden" name="data">
@@ -8,13 +27,7 @@
         <p class="mb-2"><b>Review</b></p>
 
         <div class="mb-2">
-            <textarea data-name="value" class="form-control form-control-sm" rows="3"
-            ><?php
-                if ($point->lastChildReview && $point->last_child_review_point_scoped_note_id === $note->id) {
-                    $parsedReview = json_decode($point->lastChildReview->data);
-                    echo $parsedReview->value;
-                }
-                ?></textarea>
+            <textarea data-name="value" class="form-control form-control-sm" rows="3"><?= $currentValue ?></textarea>
         </div>
         <div>
             <button submit class="btn btn-sm btn-primary mr-2">Save</button>

+ 35 - 11
resources/views/app/patient/segment-templates/_child_review/last-review.php

@@ -1,14 +1,38 @@
-<?php if($point->lastChildReview): ?>
-    <?php $parsedReview = json_decode($point->lastChildReview->data); ?>
-    <div><?= $parsedReview->value ?></div>
-    <div class="text-secondary text-sm"></div>
-    <?php if($point->last_child_review_point_scoped_note_id === $note->id): ?>
-        <span class="text-secondary text-sm">(reviewed on this note)</span>
+<?php
+if (!@$intakeOrVisit) {
+    $intakeOrVisit = 'INTAKE'; // default
+}
+?>
+<?php if ($intakeOrVisit === 'INTAKE'): ?>
+    <?php if ($point->lastChildReview): ?>
+        <?php $parsedReview = json_decode($point->lastChildReview->data); ?>
+        <div><?= $parsedReview->value ?></div>
+        <div class="text-secondary text-sm"></div>
+        <?php if ($point->last_child_review_point_scoped_note_id === $note->id): ?>
+            <span class="text-secondary text-sm">(reviewed on this note)</span>
+        <?php else: ?>
+            <a native target="_blank"
+               href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $point->lastChildReviewNote]) ?>">
+                <?= friendlier_date_time($point->last_child_review_effective_date) ?>
+            </a>
+        <?php endif; ?>
     <?php else: ?>
-        <a native target="_blank" href="<?= route('patients.view.notes.view.dashboard', ['patient'=>$patient, 'note'=>$point->lastChildReviewNote])?>">
-            <?= friendlier_date_time($point->last_child_review_effective_date) ?>
-        </a>
+        <span class="text-secondary text-sm">None</span>
     <?php endif; ?>
 <?php else: ?>
-    <span class="text-secondary text-sm">None</span>
-<?php endif; ?>
+    <?php if ($point->lastChildPlan): ?>
+        <?php $parsedReview = json_decode($point->lastChildPlan->data); ?>
+        <div><?= $parsedReview->value ?></div>
+        <div class="text-secondary text-sm"></div>
+        <?php if ($point->last_child_plan_point_scoped_note_id === $note->id): ?>
+            <span class="text-secondary text-sm">(reviewed on this note)</span>
+        <?php else: ?>
+            <a native target="_blank"
+               href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $point->lastChildPlanNote]) ?>">
+                <?= friendlier_date_time($point->last_child_plan_effective_date) ?>
+            </a>
+        <?php endif; ?>
+    <?php else: ?>
+        <span class="text-secondary text-sm">None</span>
+    <?php endif; ?>
+<?php endif; ?>