Przeglądaj źródła

Reconcile all active (wip)

Vijayakrishnan 3 lat temu
rodzic
commit
a644e80235

+ 1 - 0
resources/views/app/patient/medications-center.blade.php

@@ -570,6 +570,7 @@ $medications = $points;
                     'href="/medications-reconcile/{{$patient->uid}}/{{$note->uid}}" ' +
                     'title="Reconcile Active Medications" ' +
                     'open-in-stag-popup ' +
+                    'mc-initer="medications-reconcile-{{$note->id}}" ' +
                     'popup-style="stag-popup-md" ' +
                     'class="btn-reconcile-active btn btn-sm mr-2 btn-info text-white font-weight-bold">Reconcile Active Medications</a>')
                     .appendTo(buttonContainer);

+ 80 - 3
resources/views/app/patient/medications-reconcile.blade.php

@@ -1,11 +1,88 @@
-<div class="mt-3 p-3 border-top min-height-500px" id="medications-reconcile-{{$note->id}}">
-    TODO
+<?php
+
+use App\Models\Point;
+use App\Models\Client;
+use App\Models\Note;
+
+/** @var Client $patient */
+/** @var Note $note */
+
+$points = Point
+    ::where('client_id', $patient->id)
+    ->where('category', 'MEDICATION')
+    ->where('is_removed_due_to_entry_error', false)
+    ->where('is_removed', false)
+    ->orderBy('created_at')
+    ->get();
+foreach ($points as $point) {
+    if ($point->data) {
+        $point->data = json_decode($point->data);
+    }
+}
+$medications = $points;
+?>
+
+<div class="mt-3 p-3 border-top" id="medications-reconcile-{{$note->id}}">
+    <div class="mb-2 font-weight-bold text-secondary">The following medications will be marked as reconciled</div>
+    <table class="table table-sm table-striped table-bordered">
+        <thead>
+        <tr>
+            <th class="border-bottom-0">Medication</th>
+            <th class="border-bottom-0">Review</th>
+        </tr>
+        </thead>
+        @foreach($medications as $medication)
+        <tr>
+            <td class="w-50">{{$medication->data->name}}</td>
+            <td class="p-0">
+                <input type="text" class="form-control form-control-sm border-0 rounded-0 shadow-none" data-point-uid="{{$medication->uid}}" value="Reconciled">
+            </td>
+        </tr>
+        @endforeach
+    </table>
+    <div class="d-flex align-items-center justify-content-center">
+        <button class="btn btn-sm btn-primary mr-2 btn-save-reviews">Save</button>
+        <button class="btn btn-sm btn-default border mr-2" onclick="closeStagPopup()">Cancel</button>
+    </div>
 </div>
 
 <script>
     (function() {
         function init() {
-            // TODO
+            $('#medications-reconcile-{{$note->id}} .btn-save-reviews')
+                .off('click')
+                .on('click', function() {
+                    showMask();
+                    let payload = {
+                        noteUid: '{{$note->uid}}',
+                        reviews: []
+                    }
+                    $('#medications-reconcile-{{$note->id}} [data-point-uid]').each(function() {
+                         payload.reviews.push({
+                             parentPointUid: $(this).attr('data-point-uid'),
+                             data: JSON.stringify({
+                                 isReconciled: true,
+                                 value: $(this).val()
+                             })
+                         });
+                    });
+
+                    $.ajax({
+                        url: '/api/visitPoint/upsertChildReviewMulti',
+                        type:"POST",
+                        data: JSON.stringify(payload),
+                        contentType:"application/json; charset=utf-8",
+                        dataType:"json",
+                        success: function(_data) {
+                            if(!hasResponseError(_data)) {
+                                closeStagPopup();
+                            }
+                        }
+                    }).then(() => {
+                        hideMask();
+                    });
+
+                });
         }
         addMCInitializer('medications-reconcile-{{$note->id}}', init, '#medications-reconcile-{{$note->id}}')
     }).call(window);