Prechádzať zdrojové kódy

Support for custom shortcut-lists

Vijayakrishnan 3 rokov pred
rodič
commit
d532d5917f

+ 18 - 7
public/js/shortcut.js

@@ -39,14 +39,14 @@
         }
         return { x: x, y: y };
     }
-    function show(_initial = false) {
+    function show(_initial = false, _options) {
         let pos = getCaretPos();
         // strPart = '';
         if(pos) {
             index = -1;
-            options = window.userShortcuts;
+            options = _options;
             if(strPart.length > 1) {
-                options = window.userShortcuts.filter(function(_x) {
+                options = _options.filter(function(_x) {
                     return _x.name.toLowerCase().indexOf(strPart.substr(1).toLowerCase()) !== -1;
                 });
             }
@@ -59,7 +59,6 @@
                         .attr('title', options[i].value)
                 );
             }
-            console.log(strPart)
             if(_initial) {
                 menu
                     .css({
@@ -125,7 +124,13 @@
                     case 64:
                         backtrackAfterApplying = true;
                         strPart = '@';
-                        show(true);
+                        let options = window.userShortcuts, noteRTE = $(input).closest('[note-rte]');
+                        if(noteRTE.length && noteRTE.is('[use-shortcuts]') && noteRTE.attr('use-shortcuts') && noteRTE.attr('use-shortcuts') !== 'user') {
+                            if(window[noteRTE.attr('use-shortcuts') + 'Shortcuts']) {
+                                options = window[noteRTE.attr('use-shortcuts') + 'Shortcuts'];
+                            }
+                        }
+                        show(true, options);
                         break;
                     default:
                         if(!isVisible()) return;
@@ -211,9 +216,15 @@
             })
             .off('keyup.shortcuts', '[with-shortcuts]')
             .on('keyup.shortcuts', '[with-shortcuts]', function(_e) {
-                console.log('Reached keyup!', strPart);
+                let input = this;
+                let options = window.userShortcuts, noteRTE = $(input).closest('[note-rte]');
+                if(noteRTE.length && noteRTE.is('[use-shortcuts]') && noteRTE.attr('use-shortcuts') && noteRTE.attr('use-shortcuts') !== 'user') {
+                    if(window[noteRTE.attr('use-shortcuts') + 'Shortcuts']) {
+                        options = window[noteRTE.attr('use-shortcuts') + 'Shortcuts'];
+                    }
+                }
                 if(isVisible() && refreshOptions) {
-                    show();
+                    show(false, options);
                 }
             })
             .off('paste.shortcuts', '[with-shortcuts]')

+ 7 - 3
resources/views/app/patient/medications-center.blade.php

@@ -447,6 +447,8 @@ $medications = $points;
         function initVisitMoeRTEs() {
             $('.stag-popup [visit-moe]').find('[note-rte]:not(.ql-container)').each(function() {
 
+                let noteRTE = $(this);
+
                 $(this).wrap(
                     $('<div class="border-left border-right rte-holder"/>')
                         .attr('data-shortcuts', '')
@@ -466,9 +468,11 @@ $medications = $points;
                 var toolbar = $(quill.container).prev('.ql-toolbar');
 
                 // add button for new shortcut
-                var newSCButton = $('<button class="btn bg-white btn-sm btn-default text-primary w-auto px-2 border py-0 ' +
-                    'text-sm add-shortcut" data-editor-id="' + editorID + '">+ Shortcut</button>');
-                toolbar.append(newSCButton);
+                if(!noteRTE.is('[use-shortcuts]') || !noteRTE.attr('use-shortcuts')) {
+                    var newSCButton = $('<button class="btn bg-white btn-sm btn-default text-primary w-auto px-2 border py-0 ' +
+                        'text-sm add-shortcut" data-editor-id="' + editorID + '">+ Shortcut</button>');
+                    toolbar.append(newSCButton);
+                }
 
                 quill.root.innerHTML = existingContent;
 

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

@@ -534,6 +534,54 @@
                         }
                         ?>
                         <script>window.userShortcuts = <?= json_encode($shortCutsObject); ?>;</script>
+                        <script>
+                            window.hpiShortcuts = [
+                                {
+                                    name: 'Explain the problem.',
+                                    value: 'Explain the problem. ',
+                                },
+                                {
+                                    name: 'What happened between today and our last visit?',
+                                    value: 'What happened between today and our last visit? ',
+                                },
+                                {
+                                    name: 'How did it go with the plan I gave you?',
+                                    value: 'How did it go with the plan I gave you? ',
+                                },
+                                {
+                                    name: 'What barriers have you felt following the plan?',
+                                    value: 'What barriers have you felt following the plan? ',
+                                },
+                                {
+                                    name: 'How long have you had this?',
+                                    value: 'How long have you had this? ',
+                                },
+                                {
+                                    name: 'When does it get worse?',
+                                    value: 'When does it get worse? ',
+                                },
+                                {
+                                    name: 'When does it get better?',
+                                    value: 'When does it get better? ',
+                                },
+                                {
+                                    name: 'What have you done for treatment?',
+                                    value: 'What have you done for treatment? ',
+                                },
+                                {
+                                    name: 'How does it affect your ADLs?',
+                                    value: 'How does it affect your ADLs? ',
+                                },
+                                {
+                                    name: 'How do you cope?',
+                                    value: 'How do you cope? ',
+                                },
+                                {
+                                    name: 'How does this affect you emotionally?',
+                                    value: 'How does this affect you emotionally? ',
+                                },
+                            ];
+                        </script>
                         <script>window.segmentInitializers = {};</script>
                         <?php
                         $shortcuts = "";

+ 7 - 3
resources/views/app/patient/note/segment_script.blade.php

@@ -212,6 +212,8 @@
         function initRTEs(_parent) {
             _parent.find('[note-rte]:not(.ql-container)').each(function() {
 
+                let noteRTE = $(this);
+
                 $(this).wrap(
                     $('<div class="border-left border-right rte-holder"/>')
                         .attr('data-shortcuts', '')
@@ -231,9 +233,11 @@
                 var toolbar = $(quill.container).prev('.ql-toolbar');
 
                 // add button for new shortcut
-                var newSCButton = $('<button class="btn bg-white btn-sm btn-default text-primary w-auto px-2 border py-0 ' +
-                    'text-sm add-shortcut" data-editor-id="' + editorID + '">+ Shortcut</button>');
-                toolbar.append(newSCButton);
+                if(!noteRTE.is('[use-shortcuts]') || !noteRTE.attr('use-shortcuts')) {
+                    var newSCButton = $('<button class="btn bg-white btn-sm btn-default text-primary w-auto px-2 border py-0 ' +
+                        'text-sm add-shortcut" data-editor-id="' + editorID + '">+ Shortcut</button>');
+                    toolbar.append(newSCButton);
+                }
 
                 quill.root.innerHTML = existingContent;
 

+ 1 - 0
resources/views/app/patient/segment-templates/_child_review/edit-review.php

@@ -50,6 +50,7 @@ else {
 
         <div class="mb-2">
             <div note-rte
+                 <?= $segment->segmentTemplate->internal_name === 'intake_medications' ? 'use-shortcuts="hpi"' : '' ?>
                  class="form-group mb-2 border-left border-right rte-holder"
                  data-field-name="value"><?= $currentValue ?></div>
         </div>