Răsfoiți Sursa

Visit UI - generic _common_actions

Vijayakrishnan 3 ani în urmă
părinte
comite
4c5c56011a

+ 28 - 0
app/Models/Point.php

@@ -22,4 +22,32 @@ class Point extends Model
     {
         return $this->hasOne(Point::class, 'id', 'last_child_review_point_id');
     }
+
+    public function lastChildPlanNote()
+    {
+        return $this->hasOne(Note::class, 'id', 'last_child_plan_point_scoped_note_id');
+    }
+
+    public static function getIntakePointsOfCategory(Client $_patient, String $_category, Note $_note) {
+        $points = Point
+            ::where('client_id', $_patient->id)
+            ->where('category', $_category)
+            ->where('addition_reason_category', 'ON_INTAKE')
+            ->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);
+            }
+        }
+        return $points;
+    }
 }

+ 55 - 0
resources/views/app/patient/segment-templates/_common_actions/remove-undo.php

@@ -0,0 +1,55 @@
+<?php if ($point->is_removed): ?>
+    <?php if ($point->is_removed_due_to_entry_error): ?>
+        <span class="font-weight-bold text-secondary mr-2">Entry error</span>
+    <?php else: ?>
+        <span class="font-weight-bold text-secondary mr-2">Removed on intake</span>
+    <?php endif; ?>
+    <div visit-moe>
+        <form show url="/api/visitPoint/undoMarkRemoved" class="mcp-theme-1">
+            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+            <a submit href="#">Undo</a>
+        </form>
+    </div>
+<?php else: ?>
+    <?php if($point->added_in_note_id === $note->id): ?>
+        <span class="font-weight-bold text-success mr-2">* Added on intake</span>
+    <?php endif; ?>
+    <div visit-moe>
+        <a start show href="#">Remove</a>
+        <form url="/api/visitPoint/markRemovedOnIntake" class="mcp-theme-1">
+            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+
+            <p class="mb-2"><b>Remove <?= $label ?> (on intake)</b></p>
+
+            <div class="mb-2">
+                <label class="text-sm text-secondary mb-1">Removal Reason</label>
+                <textarea name="removalReasonMemo" class="form-control form-control-sm" rows="2"></textarea>
+            </div>
+            <?php if($point->added_in_note_id === $note->id): ?>
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">Is Entry Error?  *</label>
+                    <select name="isRemovedDueToEntryError" class="form-control form-control-sm" required>
+                        <option value="">-- select --</option>
+                        <option value="1" selected>Yes</option>
+                        <option value="0">No</option>
+                    </select>
+                </div>
+            <?php else: ?>
+                <input type="hidden" name="isRemovedDueToEntryError" value="0">
+            <?php endif; ?>
+            <div class="mb-2">
+                <label class="text-sm text-secondary mb-1">Removal Effective Date</label>
+                <input type="date" name="removalEffectiveDate"
+                       value="<?= date('Y-m-d') ?>"
+                       max="<?= date('Y-m-d') ?>"
+                       class="form-control form-control-sm">
+            </div>
+            <div>
+                <button submit class="btn btn-sm btn-danger mr-2">Remove</button>
+                <button cancel class="btn btn-sm btn-default border">Cancel</button>
+            </div>
+        </form>
+    </div>
+<?php endif; ?>

+ 14 - 78
resources/views/app/patient/segment-templates/intake_medications/edit.php

@@ -1,29 +1,15 @@
 <?php
 
 use App\Models\Point;
+use \App\Models\Client;
+use \App\Models\Note;
+use \App\Models\Segment;
 
-/** @var \App\Models\Client $patient */
+/** @var Client $patient */
+/** @var Note $note */
+/** @var Segment $segment */
 
-$medications = Point
-    ::where('client_id', $patient->id)
-    ->where('category', 'MEDICATION')
-    ->where('addition_reason_category', 'ON_INTAKE')
-    ->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 ($medications as $medication) {
-    if ($medication->data) {
-        $medication->data = json_decode($medication->data);
-    }
-}
+$medications = Point::getIntakePointsOfCategory($patient, 'MEDICATION', $note);
 
 ?>
 <div>
@@ -47,65 +33,15 @@ foreach ($medications as $medication) {
                                 <?= !!@($medication->data->route) ? '/&nbsp;' . @($medication->data->route) : '' ?>
                                 <?= !!@($medication->data->frequency) ? '/&nbsp;' . @($medication->data->frequency) : '' ?>
                             </div>
-                            <div class="ml-auto d-inline-flex align-items-baseline pr-2">
-                                <?php if ($medication->is_removed): ?>
-                                    <?php if ($medication->is_removed_due_to_entry_error): ?>
-                                        <span class="font-weight-bold text-secondary mr-2">Entry error</span>
-                                    <?php else: ?>
-                                        <span class="font-weight-bold text-secondary mr-2">Removed on intake</span>
-                                    <?php endif; ?>
-                                    <div visit-moe>
-                                        <form show url="/api/visitPoint/undoMarkRemoved" class="mcp-theme-1">
-                                            <input type="hidden" name="uid" value="<?= $medication->uid ?>">
-                                            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
-                                            <a submit href="#">Undo</a>
-                                        </form>
-                                    </div>
-                                <?php else: ?>
-                                    <?php if($medication->added_in_note_id === $note->id): ?>
-                                        <span class="font-weight-bold text-success mr-2">* Added on intake</span>
-                                    <?php endif; ?>
-                                    <div visit-moe>
-                                        <a start show href="#">Remove</a>
-                                        <form url="/api/visitPoint/markRemovedOnIntake" class="mcp-theme-1">
-                                            <input type="hidden" name="uid" value="<?= $medication->uid ?>">
-                                            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
-
-                                            <p class="mb-2"><b>Remove Medication (on intake)</b></p>
 
-                                            <div class="mb-2">
-                                                <label class="text-sm text-secondary mb-1">Removal Reason</label>
-                                                <textarea name="removalReasonMemo" class="form-control form-control-sm" rows="2"></textarea>
-                                            </div>
-                                            <?php if($medication->added_in_note_id === $note->id): ?>
-                                                <div class="mb-2">
-                                                    <label class="text-sm text-secondary mb-1">Is Entry Error?  *</label>
-                                                    <select name="isRemovedDueToEntryError" class="form-control form-control-sm" required>
-                                                        <option value="">-- select --</option>
-                                                        <option value="1" selected>Yes</option>
-                                                        <option value="0">No</option>
-                                                    </select>
-                                                </div>
-                                            <?php else: ?>
-                                                <input type="hidden" name="isRemovedDueToEntryError" value="0">
-                                            <?php endif; ?>
-                                            <div class="mb-2">
-                                                <label class="text-sm text-secondary mb-1">Removal Effective Date</label>
-                                                <input type="date" name="removalEffectiveDate"
-                                                       value="<?= date('Y-m-d') ?>"
-                                                       max="<?= date('Y-m-d') ?>"
-                                                       class="form-control form-control-sm">
-                                            </div>
-                                            <div>
-                                                <button submit class="btn btn-sm btn-danger mr-2">Remove</button>
-                                                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-                                            </div>
-                                        </form>
-                                    </div>
-                                <?php endif; ?>
+                            <!-- common actions -->
+                            <div class="ml-auto d-inline-flex align-items-baseline pr-2">
+                                <?php
+                                $point = $medication;
+                                $label = 'Medication';
+                                include resource_path('views/app/patient/segment-templates/_common_actions/remove-undo.php');
+                                ?>
                             </div>
-
-
                         </div>
                     </td>
                     <td>