Explorar el Código

Universal medications - undo-removal feature

Vijayakrishnan hace 4 años
padre
commit
077bd11b9a

+ 1 - 1
resources/views/app/patient/page-sections/v0521_rx/edit.blade.php

@@ -23,7 +23,7 @@
         <hr class="m-neg-4">
         <div class="">
             <label class="mb-1 text-secondary d-flex align-items-center">
-                <input type="checkbox" name="was_existing_at_visit_start">
+                <input type="checkbox" name="was_existing_at_visit_start" {{@$parsed->was_existing_at_visit_start ? 'checked' : ''}}>
                 <span class="ml-2">Patient is already on this medication</span>
             </label>
         </div>

+ 12 - 0
resources/views/app/patient/page-sections/v0521_rx/form.blade.php

@@ -72,6 +72,18 @@ use App\Models\Note;
                                    href="{{route('patients.view.notes.view.section-view', compact('patient', 'note', 'section', 'view', 'page'))}}">
                                     Remove
                                 </a>
+                            @else
+                                <?php $view = 'undo-remove'; ?>
+                                <a class="text-info ml-2"
+                                   native target="_blank"
+                                   open-in-stag-popup
+                                   mc-initer="undo-remove-medication-{{$page->id}}"
+                                   update-parent
+                                   popup-style="narrow"
+                                   title="Undo Remove Medication?"
+                                   href="{{route('patients.view.notes.view.section-view', compact('patient', 'note', 'section', 'view', 'page'))}}">
+                                    Undo-Removal
+                                </a>
                             @endif
                         </td>
                     </tr>

+ 49 - 0
resources/views/app/patient/page-sections/v0521_rx/undo-remove.blade.php

@@ -0,0 +1,49 @@
+<?php $parsed = $page->data ? json_decode($page->data) : false; ?>
+@if(!!$parsed)
+<div class="p-3 border-top mt-3 mcp-theme-1" id="undo-remove-medication-container-{{$page->id}}">
+    <form action="">
+        <p>Undo removal of this medication?</p>
+        <hr class="m-neg-4">
+        <div class="d-flex align-items-center justify-content-center">
+            <button class="btn btn-sm btn-danger px-3 mr-2 btn-save" type="button">Yes</button>
+            <button class="btn btn-sm btn-default border btn-close-stag-popup px-3" type="button">No</button>
+        </div>
+    </form>
+</div>
+<script>
+    (function() {
+        function init() {
+            let parent = $('#undo-remove-medication-container-{{$page->id}}'),
+                form = parent.find('form').first();
+            parent.find('.btn-save')
+                .off('click')
+                .on('click', function() {
+                    if(!form[0].checkValidity()) {
+                        form[0].reportValidity();
+                        return false;
+                    }
+                    showMask();
+                    let newData = {!! $page->data !!};
+                    newData.removed_during_note_uid = null;
+                    newData.removal_memo = null;
+                    let payload = {
+                        uid: '{{$page->uid}}',
+                        newData: JSON.stringify(newData)
+                    };
+                    $.post('/api/page/change', payload, _data => {
+                        if(!hasResponseError(_data)) {
+                            toastr.success('Medication updated!');
+                            closeStagPopup();
+                        }
+                    }, 'json');
+                    return false;
+                });
+        }
+        addMCInitializer('undo-remove-medication-{{$page->id}}', init, '#undo-remove-medication-container-{{$page->id}}');
+    }).call(window);
+</script>
+@else
+    <div class="p-3 border-top mt-3 mcp-theme-1" id="undo-remove-medication-container-{{$page->id}}">
+        <div class="text-secondary">Invalid/corrupt input!</div>
+    </div>
+@endif