浏览代码

Note single - Rx inline CRUD

Vijayakrishnan Krishnan 4 年之前
父节点
当前提交
7a092be227

+ 5 - 0
app/Http/Controllers/PatientController.php

@@ -171,4 +171,9 @@ class PatientController extends Controller
             "online" => $patient->is_online
         ]);
     }
+
+    public function embedSection(Request $request, Client $patient, $section) {
+        $selectable = true;
+        return view('app.patient.partials.' . $section, compact('patient', 'selectable'));
+    }
 }

+ 16 - 1
public/css/style.css

@@ -336,7 +336,7 @@ input.search_field, textarea.search_field {
         position: fixed;
         left: 0;
         top: 55px;
-        z-index: 9999;
+        z-index: 8;
         height: calc(100% - 55px);
         overflow-y: auto;
     }
@@ -579,3 +579,18 @@ input.search_field, textarea.search_field {
     text-align: center;
     justify-content: center;
 }
+.embed-mask {
+    position: fixed;
+    left: 0;
+    top: 0;
+    height: 100%;
+    width: 100%;
+    background: rgba(0, 0, 0, 0.1);
+    z-index: 98;
+}
+.embed-section {
+    background: #fff;
+    z-index: 99;
+    padding: 0;
+    border: 1px solid #ccc;
+}

+ 3 - 1
public/js/yemi.js

@@ -297,13 +297,15 @@ jQuery(document).ready(function () {
                         formToggle = true;
                     } else {
                         var isRealFormVisible = $(realForm).is(':visible');
-                        $(realForm).toggle(100);
                         if(isRealFormVisible){
                             hideMoeFormMask();
+                            $(realForm).toggle(100);
                         }else{
                             $(realForm)[0].reset();
                             showMoeFormMask();
                             setTimeout(function() {
+                                $('[moe]>form:visible').hide();
+                                $(realForm).toggle(100);
                                 initPrimaryForm($(realForm));
                             }, 100);
                         }

+ 1 - 158
resources/views/app/patient/dashboard.blade.php

@@ -443,122 +443,7 @@
                 </div>
 
                 {{-- rx --}}
-                <div class="mt-2 pb-1" rx-section>
-                    <div class="d-flex align-items-center mb-2 py-2 border-top border-bottom">
-                        <h6 class="my-0 font-weight-bold text-secondary">Current Medications</h6>
-                        <span class="mx-2 text-secondary">|</span>
-                        <div moe>
-                            <a start show class="py-0 font-weight-normal">Add</a>
-                            <form url="/api/clientInfoLine/create">
-                                <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
-                                <input type="hidden" name="category" value="rx">
-                                <div class="mb-2">
-                                    <input type="text" class="form-control form-control-sm" name="contentText" value="" placeholder="Medication">
-                                </div>
-                                <div class="mb-2">
-                                    <input type="text" class="form-control form-control-sm" name="strength" value="" placeholder="Strength/Form">
-                                </div>
-                                <div class="d-flex align-items-center">
-                                    <button class="btn btn-sm btn-primary mr-2" type="button" submit>Save</button>
-                                    <button class="btn btn-sm btn-default mr-2 border" type="button" cancel>Cancel</button>
-                                </div>
-                            </form>
-                        </div>
-
-                        <span class="mx-2 text-secondary">|</span>
-
-                        <div moe>
-                            <a start show class="">Multi</a>
-                            <form url="/api/clientInfoLine/createMultiple">
-                                <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
-                                <input type="hidden" name="category" value="rx">
-                                <div class="mb-2">
-                                    <textarea class="form-control form-control-sm" rows="8"
-                                              name="contentTexts" value=""
-                                              placeholder="Medications"></textarea>
-                                </div>
-                                <div class="d-flex align-items-center">
-                                    <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
-                                    <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
-                                </div>
-                            </form>
-                        </div>
-
-                        <span class="mx-2 text-secondary">|</span>
-                        <a start show class="py-0 font-weight-normal"
-                           href="/patients/view/{{ $patient->uid }}/medications">
-                            View All
-                        </a>
-                    </div>
-                    <table class="table table-sm border-0 m-0">
-                        <tbody>
-                        <?php $itemCount = 0; ?>
-                        @foreach($infoLines as $category => $lines)
-                            @if($category === "rx")
-                                @foreach ($lines as $line)
-                                    <?php $itemCount++; ?>
-                                    <tr>
-                                        <td class="text-black p-0 border-0">
-                                            <div class="d-flex">
-                                                <span moe relative class="mr-2">
-                                                    <a class="on-hover-opaque" start show title="Delete">
-                                                        <i class="font-size-11 fa fa-trash-alt text-danger"></i>
-                                                    </a>
-                                                    <form url="/api/clientInfoLine/remove">
-                                                        <input type="hidden" name="uid" value="{{ $line->uid }}">
-                                                        <p class="small">Are you sure you want to delete this entry?</p>
-                                                        <div class="d-flex align-items-center">
-                                                            <button class="btn btn-sm btn-danger mr-2" submit>Delete</button>
-                                                            <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
-                                                        </div>
-                                                    </form>
-                                                </span>
-                                                <div moe relative class="mr-2">
-                                                    <a class="on-hover-opaque" start show title="Edit">
-                                                        <i class="font-size-11 fa fa-edit"></i>
-                                                    </a>
-                                                    <form url="/api/clientInfoLine/updateContent">
-                                                        <input type="hidden" name="uid" value="{{ $line->uid }}">
-                                                        <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
-                                                        <input type="hidden" name="category" value="rx">
-                                                        <div class="mb-2">
-                                                            <input type="text" class="form-control form-control-sm"
-                                                                   name="contentText"
-                                                                   placeholder="Medication"
-                                                                   value="{{$line->contentText}}"></div>
-                                                        <div class="mb-2">
-                                                            <input type="text" class="form-control form-control-sm" name="strength"
-                                                                   value="{{getVal($line->contentDetail, "strength") }}" placeholder="Strength/Form">
-                                                        </div>
-                                                        <div class="d-flex align-items-center">
-                                                            <button class="btn btn-sm btn-primary mr-2" type="button" submit>Save</button>
-                                                            <button class="btn btn-sm btn-default mr-2 border" type="button" cancel>Cancel</button>
-                                                        </div>
-                                                    </form>
-                                                </div>
-                                                <span>
-                                                    <span class="font-weight-bold">{{$line->contentText}}</span>
-                                                    @if(!empty(getVal($line->contentDetail, "strength")))
-                                                    <span class="text-secondary">/</span>
-                                                    <span>{{getVal($line->contentDetail, "strength") }}</span>
-                                                    @endif
-                                                </span>
-                                            </div>
-                                        </td>
-                                    </tr>
-                                @endforeach
-                            @endif
-                        @endforeach
-                        @if($itemCount === 0)
-                            <tr>
-                                <td class="text-secondary p-0 border-0">
-                                    No items to show
-                                </td>
-                            </tr>
-                        @endif
-                        </tbody>
-                    </table>
-                </div>
+                @include('app/patient/partials/rx')
 
             </div>
             <div class="col-6">
@@ -1679,46 +1564,4 @@
         </div>
 
     </div>
-    <script>
-        (function() {
-            function init() {
-                $('input[type="text"][name="ICD"]').each(function() {
-                    var elem = this, dynID = 'icd-' + Math.ceil(Math.random() * 1000000);
-                    $(elem).attr('id', dynID);
-                    new window.Def.Autocompleter.Search(dynID,
-                        'https://clinicaltables.nlm.nih.gov/api/icd10cm/v3/search?sf=code,name&ef=name',
-                        {
-                            tableFormat: true,
-                            valueCols: [0],
-                            colHeaders: ['Code', 'Name'],
-                        }
-                    );
-                    window.Def.Autocompleter.Event.observeListSelections(dynID, function() {
-                        var autocomp = elem.autocomp;
-                        var name = autocomp.getSelectedItemData()[0].data['name'];
-                        $(elem).closest('form').find('[name="contentText"]').val(name);
-                        return false;
-                    });
-                });
-                $('[rx-section] input[type="text"][name="contentText"]').each(function() {
-                    var elem = this, dynID = 'rx-' + Math.ceil(Math.random() * 1000000);
-                    $(elem).attr('id', dynID);
-                    var strengthElem = $(elem).closest('form').find('[name="strength"]')[0],
-                        dynStrengthsID = 'rx-' + Math.ceil(Math.random() * 1000000) + '-strengths';
-                    $(strengthElem).attr('id', dynStrengthsID);
-                    new window.Def.Autocompleter.Prefetch(dynStrengthsID, []);
-                    new window.Def.Autocompleter.Search(dynID,
-                        'https://clinicaltables.nlm.nih.gov/api/rxterms/v3/search?ef=STRENGTHS_AND_FORMS');
-                    window.Def.Autocompleter.Event.observeListSelections(dynID, function() {
-                        var autocomp = elem.autocomp;
-                        var strengths =
-                            autocomp.getSelectedItemData()[0].data['STRENGTHS_AND_FORMS'];
-                        if (strengths)
-                            strengthElem.autocomp.setListAndField(strengths, '');
-                    });
-                });
-            }
-            addMCInitializer('patient-single', init);
-        })();
-    </script>
 @endsection

+ 9 - 0
resources/views/app/patient/note/dashboard.blade.php

@@ -255,6 +255,11 @@
                                     include(storage_path('sections/' . $sectionInternalName . '/actions.php'));
                                 }
                                 ?>
+                                <?php
+                                if(file_exists(storage_path('sections/' . $sectionInternalName . '/actions.blade.php'))) {
+                                    ?> @include('sections/' . $sectionInternalName . '/actions') <?php
+                                }
+                                ?>
                                 <a href="#" class="d-none text-danger if-edit ml-auto remove-section-trigger"
                                    data-uid="{{$section->uid}}"
                                    title="Remove {{$section->sectionTemplate->title}}">
@@ -795,6 +800,10 @@
                         }
                     }
                 });
+
+                $('div[embed]').each(function() {
+                    $(this).load($(this).attr('embed'));
+                });
             }
             addMCInitializer('sections-widget', initSectionsWidget);
         })();

+ 43 - 1
resources/views/layouts/template.blade.php

@@ -239,7 +239,49 @@
             });
         });
     </script>
+    <script>
+        (function() {
+            function init() {
+                $('input[type="text"][name="ICD"]').each(function() {
+                    var elem = this, dynID = 'icd-' + Math.ceil(Math.random() * 1000000);
+                    $(elem).attr('id', dynID);
+                    new window.Def.Autocompleter.Search(dynID,
+                        'https://clinicaltables.nlm.nih.gov/api/icd10cm/v3/search?sf=code,name&ef=name',
+                        {
+                            tableFormat: true,
+                            valueCols: [0],
+                            colHeaders: ['Code', 'Name'],
+                        }
+                    );
+                    window.Def.Autocompleter.Event.observeListSelections(dynID, function() {
+                        var autocomp = elem.autocomp;
+                        var name = autocomp.getSelectedItemData()[0].data['name'];
+                        $(elem).closest('form').find('[name="contentText"]').val(name);
+                        return false;
+                    });
+                });
+                $('[rx-section] input[type="text"][name="contentText"]').each(function() {
+                    var elem = this, dynID = 'rx-' + Math.ceil(Math.random() * 1000000);
+                    $(elem).attr('id', dynID);
+                    var strengthElem = $(elem).closest('form').find('[name="strength"]')[0],
+                        dynStrengthsID = 'rx-' + Math.ceil(Math.random() * 1000000) + '-strengths';
+                    $(strengthElem).attr('id', dynStrengthsID);
+                    new window.Def.Autocompleter.Prefetch(dynStrengthsID, []);
+                    new window.Def.Autocompleter.Search(dynID,
+                        'https://clinicaltables.nlm.nih.gov/api/rxterms/v3/search?ef=STRENGTHS_AND_FORMS');
+                    window.Def.Autocompleter.Event.observeListSelections(dynID, function() {
+                        var autocomp = elem.autocomp;
+                        var strengths =
+                            autocomp.getSelectedItemData()[0].data['STRENGTHS_AND_FORMS'];
+                        if (strengths)
+                            strengthElem.autocomp.setListAndField(strengths, '');
+                    });
+                });
+            }
+            addMCInitializer('patient-single', init);
+        })();
+    </script>
 
 </body>
 
-</html>
+</html>

+ 3 - 0
routes/web.php

@@ -114,6 +114,9 @@ Route::middleware('pro.auth')->group(function () {
     // Patient suggest
     Route::get('/patients-suggest', 'HomeController@patientsSuggest');
 
+    // embeddable sections
+    Route::get('/embed/{patient}/{section}', 'PatientController@embedSection')->name('embed-section');
+
     // AJAX presence poll
     Route::get('/patients/{patient}/presence', 'PatientController@presence');
 

+ 0 - 0
storage/sections/medication/actions.php → storage/sections/medication/actions-old.php


+ 52 - 0
storage/sections/medication/actions.blade.php

@@ -0,0 +1,52 @@
+<?php
+$infoLines = json_decode($patient->info_lines);
+$infoLines = !$infoLines ? [] : $infoLines;
+$rows = [];
+foreach ($infoLines as $category => $lines):
+    if ($category === "rx"):
+        foreach ($lines as $line):
+            $rows[] = '<label class="d-flex align-items-center current-medication-item mb-1 c-pointer">' .
+                '<input type="checkbox" checked class="my-0 mr-2">' .
+                '<span><b>' . $line->contentText . '</b>&nbsp;' .
+                @$line->contentDetail->strength .
+                '</span></label>';
+        endforeach;
+    endif;
+endforeach;
+?>
+
+<div class="position-relative d-none if-edit ml-3 pl-3 border-left">
+    <a href="#" onclick="$(this).siblings('.embed-section, .embed-mask').removeClass('d-none'); return false;">Current Medications</a>
+    <div class="embed-section min-width-300px bg-white position-absolute d-none current-medications-form">
+        <div>
+            @include('app/patient/partials/rx', ['selectable' => true])
+        </div>
+        <div class="m-2">
+            <form url="/no-op">
+                <button class="btn btn-primary btn-sm mr-1" type="button" onclick="return applySelectedMedication()">Apply</button>
+                <button class="btn btn-default border btn-sm" type="button" onclick="return cancelMedicationPopup()">Cancel</button>
+            </form>
+        </div>
+    </div>
+    <div class="embed-mask d-none" onclick="$(this).addClass('d-none'); $(this).siblings('.embed-section').addClass('d-none');"></div>
+</div>
+
+<script>
+    function applySelectedMedication() {
+        let html = [];
+        $('.rx-item-checkbox:checked').each(function() {
+            html.push('<p style="white-space: normal;">' + $.trim($(this).closest('.rx-item').find('.content-html').first().html()) + '</p>');
+        });
+        $('.embed-section, .embed-mask').addClass('d-none');
+        $('.ql-editor[contenteditable]:visible').first().html(html.join('')).focus();
+        return false;
+    }
+    function cancelMedicationPopup() {
+        $('.embed-section, .embed-mask').addClass('d-none');
+        hideMask();
+        hideMoeFormMask();
+        $('.ql-editor[contenteditable]:visible').first().focus();
+        return false;
+    }
+</script>
+