Преглед изворни кода

Allergies, intake and plan - logic fixes

Vijayakrishnan пре 3 година
родитељ
комит
889d252f30

+ 1 - 21
resources/views/app/patient/segment-templates/intake_allergies/summary.blade.php

@@ -4,27 +4,7 @@ use App\Models\Point;
 
 /** @var \App\Models\Client $patient */
 
-$allergies = Point
-    ::where('client_id', $patient->id)
-    ->where('category', 'ALLERGY')
-    ->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('is_removed_due_to_entry_error', false)
-                    ->where('removed_in_note_id', $note->id);
-            });
-    })
-    ->orderBy('created_at')
-    ->get();
-
-foreach ($allergies as $allergy) {
-    if ($allergy->data) {
-        $allergy->data = json_decode($allergy->data);
-    }
-}
+$allergies = Point::getIntakePointsOfCategory($patient, 'ALLERGY', $note);
 
 ?>
 

+ 87 - 1
resources/views/app/patient/segment-templates/plan_allergies/edit.blade.php

@@ -1 +1,87 @@
-<h1>Edit for plan_allergies</h1>
+<?php
+
+use App\Models\Point;
+use \App\Models\Client;
+use \App\Models\Note;
+use \App\Models\Segment;
+
+/** @var Client $patient */
+/** @var Note $note */
+/** @var Segment $segment */
+
+$allergies = Point::getPlanPointsOfCategory($patient, 'ALLERGY', $note);
+$intakeOrVisit = 'PLAN';
+?>
+<div>
+
+    <div class="d-flex mb-2">
+        <table class="table table-sm table-bordered table-striped mb-0 bg-white">
+            <thead>
+            <tr class="">
+                <th class="border-bottom-0">Allergy</th>
+                <th class="border-bottom-0">Last Review</th>
+                <th class="border-bottom-0">Review Today</th>
+            </tr>
+            </thead>
+            <?php foreach($allergies as $allergy): ?>
+                <tr>
+                    <td>
+                        <div class="d-flex align-items-baseline">
+                            <div class="<?= $allergy->is_removed ? 'strike-through' : '' ?>">
+                                <b><?= !!@($allergy->data->name) ? @($allergy->data->name) : '-' ?></b>
+                                <?= !!@($allergy->data->description) ? '/&nbsp;' . @($allergy->data->description) : '' ?>
+                            </div>
+
+                            <!-- common actions -->
+                            <div class="ml-auto d-inline-flex align-items-baseline pr-2">
+                                <?php
+                                $point = $allergy;
+                                $label = 'Allergy';
+                                include resource_path('views/app/patient/segment-templates/_common_actions/remove-undo.php');
+                                ?>
+                            </div>
+                        </div>
+                    </td>
+                    <td>
+                        <?php
+                        $point = $allergy;
+                        include resource_path('views/app/patient/segment-templates/_child_review/last-review.php');
+                        ?>
+                    </td>
+                    <td>
+                        <?php
+                        $point = $allergy;
+                        include resource_path('views/app/patient/segment-templates/_child_review/edit-review.php');
+                        ?>
+                    </td>
+                </tr>
+            <?php endforeach; ?>
+        </table>
+    </div>
+
+    <div visit-moe class="mt-1">
+        <a href="#" start show class="btn btn-sm btn btn-outline-primary">+ Add new allergy, added during this visit</a>
+        <form url="/api/visitPoint/addTopLevelDuringVisit" class="mcp-theme-1">
+            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+            <input type="hidden" name="category" value="ALLERGY">
+            <input type="hidden" name="data">
+
+            <p class="mb-2"><b>Add Allergy (plan)</b></p>
+
+            <div class="mb-2">
+                <label class="text-sm text-secondary mb-1">Name</label>
+                <input type="text" data-name="name" class="form-control form-control-sm">
+            </div>
+            <div class="mb-2">
+                <label class="text-sm text-secondary mb-1">Description</label>
+                <input type="text" data-name="description" class="form-control form-control-sm">
+            </div>
+
+            <div>
+                <button submit class="btn btn-sm btn-primary mr-2">Submit</button>
+                <button cancel class="btn btn-sm btn-default border">Cancel</button>
+            </div>
+        </form>
+    </div>
+</div>
+

+ 28 - 1
resources/views/app/patient/segment-templates/plan_allergies/summary.blade.php

@@ -1 +1,28 @@
-<h1>Summary for plan_allergies</h1>
+<?php
+
+use App\Models\Point;
+
+/** @var \App\Models\Client $patient */
+
+$allergies = Point::getPlanPointsOfCategory($patient, 'ALLERGY', $note);
+
+?>
+
+<?php if (!count($allergies)): ?>
+    <div class="text-secondary">No allergies</div>
+<?php else: ?>
+    <?php foreach ($allergies as $allergy): ?>
+        <div class="d-flex align-items-baseline mb-2">
+            <div class="<?= $allergy->is_removed ? 'strike-through' : '' ?>">
+                <b><?= !!@($allergy->data->name) ? @($allergy->data->name) : '-' ?></b>
+                <?= !!@($allergy->data->description) ? '/&nbsp;' . @($allergy->data->description) : '' ?>
+            </div>
+            <?php if ($allergy->is_removed): ?>
+                <span class="ml-2 text-sm text-secondary">Removed during visit</span>
+            <?php elseif ($allergy->added_in_note_id === $note->id): ?>
+                <span class="ml-2 text-sm text-success">* Added during visit</span>
+            <?php endif; ?>
+        </div>
+    <?php endforeach; ?>
+<?php endif; ?>
+