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

Goals wizard - add/edit plan & review + relevance

Vijayakrishnan пре 3 година
родитељ
комит
c3805ceecb
1 измењених фајлова са 138 додато и 19 уклоњено
  1. 138 19
      resources/views/app/patient/goals-center.blade.php

+ 138 - 19
resources/views/app/patient/goals-center.blade.php

@@ -32,6 +32,7 @@ $goals = $points;
         <table class="table table-sm table-bordered table-striped mb-0 bg-white mb-2">
             <thead>
             <tr class="">
+                <th class="border-bottom-0 text-secondary text-center width-30px">Rel.</th>
                 <th class="border-bottom-0 text-secondary">Goal</th>
                 <th class="border-bottom-0 text-secondary">Category</th>
                 <th class="border-bottom-0 text-secondary">Active?</th>
@@ -43,9 +44,30 @@ $goals = $points;
                 <th class="border-bottom-0 text-secondary">Last Plan</th>
             </tr>
             </thead>
+            <?php $prevRowRemoved = -1; ?>
             <?php foreach($goals as $goal): ?>
             <?php $point = $goal; ?>
+            @if($prevRowRemoved !== -1 && $prevRowRemoved !== $goal->is_removed)
+                <tr>
+                    <td colspan="10" class="px-0 pt-1 pb-0 on-hover-opaque bg-secondary"></td>
+                </tr>
+            @endif
+            <?php $prevRowRemoved = $goal->is_removed; ?>
+            <?php $rel = $goal->relevanceToNote($note); ?>
             <tr class="{{$goal->is_removed ? 'on-hover-opaque' : ''}}">
+                <td class="text-center">
+                    <a href="#" class="toggle-relevance"
+                       data-relevant="{{$rel ? '1' : '0'}}"
+                       data-rel-uid="{{$rel ? $rel->uid : ''}}"
+                       data-point-uid="{{$goal->uid}}"
+                       title="Mark as{{$rel ? ' not ' : ' '}}relevant to this visit">
+                        @if($rel)
+                            <i class="fa fa-star text-sm text-info"></i>
+                        @else
+                            <i class="fa fa-star text-sm text-secondary on-hover-opaque"></i>
+                        @endif
+                    </a>
+                </td>
                 <td>
                     <div class="d-flex align-items-baseline">
                         @if($goal->is_removed)
@@ -64,8 +86,8 @@ $goals = $points;
                                     @endif
                                 </div>
                             @endif
-                            @if($goal->is_removed && ($goal->added_in_note_id !== $note->id && $goal->removed_in_note_id === $note->id))
-                                <div class="mt-1 text-sm text-secondary">Discontinued during this visit</div>
+                            @if($goal->is_removed && $goal->removed_in_note_id === $note->id)
+                                <div class="mt-1 text-sm text-secondary">Removed during this visit</div>
                             @endif
                         </div>
                     </div>
@@ -311,14 +333,22 @@ $goals = $points;
                             include resource_path('views/app/patient/segment-templates/_child_review/last-review.php');
                             ?>
                         </div>
-                        <a class="px-2 view-review-log"
-                           native target="_blank"
-                           open-in-stag-popup
-                           popup-style="stag-popup-md"
-                           title="Review log<?= !!@($goal->data->goal) ? ' for ' . @($goal->data->goal) : '' ?>"
-                           href="/point/review-log/<?= $goal->uid ?>?popupmode=1">
-                            <i class="fa fa-history"></i>
-                        </a>
+                        <div class="d-inline-flex flex-nowrap">
+                            <a class="px-2 view-review-log"
+                               native target="_blank"
+                               open-in-stag-popup
+                               popup-style="stag-popup-md"
+                               title="Review log<?= !!@($goal->data->goal) ? ' for ' . @($goal->data->goal) : '' ?>"
+                               href="/point/review-log/<?= $goal->uid ?>?popupmode=1">
+                                <i class="fa fa-history"></i>
+                            </a>
+                            <?php
+                            $segment = $note->getSegmentByInternalName('intake_goals');
+                            if($segment) {
+                                include resource_path('views/app/patient/segment-templates/_child_review/edit-review.php');
+                            }
+                            ?>
+                        </div>
                     </div>
                 </td>
                 <td>
@@ -328,14 +358,22 @@ $goals = $points;
                             include resource_path('views/app/patient/segment-templates/_child_plan/last-plan.php');
                             ?>
                         </div>
-                        <a class="px-2 view-review-log"
-                           native target="_blank"
-                           open-in-stag-popup
-                           popup-style="stag-popup-md"
-                           title="Plan log<?= !!@($goal->data->goal) ? ' for ' . @($goal->data->goal) : '' ?>"
-                           href="/point/plan-log/<?= $goal->uid ?>?popupmode=1">
-                            <i class="fa fa-history"></i>
-                        </a>
+                        <div class="d-inline-flex flex-nowrap">
+                            <a class="px-2 view-review-log"
+                               native target="_blank"
+                               open-in-stag-popup
+                               popup-style="stag-popup-md"
+                               title="Plan log<?= !!@($goal->data->goal) ? ' for ' . @($goal->data->goal) : '' ?>"
+                               href="/point/plan-log/<?= $goal->uid ?>?popupmode=1">
+                                <i class="fa fa-history"></i>
+                            </a>
+                            <?php
+                            $segment = $note->getSegmentByInternalName('plan_goals');
+                            if($segment) {
+                                include resource_path('views/app/patient/segment-templates/_child_plan/edit-plan.php');
+                            }
+                            ?>
+                        </div>
                     </div>
                 </td>
             </tr>
@@ -502,6 +540,54 @@ $goals = $points;
 
 <script>
     (function() {
+        function initVisitMoeRTEs() {
+            $('.stag-popup [visit-moe]').find('[note-rte]:not(.ql-container)').each(function() {
+
+                $(this).wrap(
+                    $('<div class="border-left border-right rte-holder"/>')
+                        .attr('data-shortcuts', '')
+                );
+
+                // give a unique id to this editor instance
+                var editorID = Math.ceil(Math.random() * 99999),
+                    fieldName = $(this).attr('data-field-name') ? $(this).attr('data-field-name') : 'free_text';
+
+                var el = this;
+                var existingContent = $(el).html();
+                var quill = new Quill(el, {
+                    theme: 'snow',
+                    modules: stagQuillConfig
+                });
+
+                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);
+
+                quill.root.innerHTML = existingContent;
+
+                let onTextChange = function(delta, oldDelta, source) {
+                    var content = quill.root.innerHTML;
+                    let dataObject = {};
+                    dataObject[fieldName] = content;
+                    var dataValue = JSON.stringify(dataObject);
+                    $(el).closest('[visit-moe]').find('input[name=data]').val(dataValue);
+                };
+
+                quill.on('text-change', onTextChange);
+
+                $(quill.container)
+                    .find('.ql-editor[contenteditable]')
+                    .attr('data-field', fieldName)
+                    .attr('data-editor-id', editorID)
+                    .attr('with-shortcuts', 1);
+
+                // set value initially
+                onTextChange();
+            });
+        }
         function init() {
             let parentSegment = $('#goals-center-{{$note->id}}');
 
@@ -660,10 +746,43 @@ $goals = $points;
                     return false;
                 });
 
+            parentSegment.find('.toggle-relevance')
+                .off('click.toggle-relevance')
+                .on('click.toggle-relevance', function () {
+                    if(+$(this).attr('data-relevant') === 0) {
+                        $.post('/api/visitPoint/markPointRelevantToNote', {
+                            noteUid: '{{$note->uid}}',
+                            pointUid: $(this).attr('data-point-uid')
+                        }, _data => {
+                            if(!hasResponseError(_data)) {
+                                refreshDynamicStagPopup();
+                            }
+                        }, 'json');
+                    }
+                    else {
+                        if($(this).attr('data-rel-uid')) {
+                            $.post('/api/visitPoint/undoMarkPointRelevantToNote', {
+                                uid: $(this).attr('data-rel-uid')
+                            }, _data => {
+                                if(!hasResponseError(_data)) {
+                                    refreshDynamicStagPopup();
+                                }
+                            }, 'json');
+                        }
+                        else {
+                            console.log('Error - missing rel uid');
+                        }
+                    }
+                    return false;
+                });
+
             initStagSuggest();
 
             $('.additionReasonCategory_ui').trigger('change');
+
+            initSegmentMoes($('#goals-center-{{$note->id}}'));
+            initVisitMoeRTEs();
         }
-        addMCInitializer('goals-center-{{$note->id}}', init, '#goals-center-{{$note->id}}')
+        addMCInitializer('goals-center-{{$note->id}}', init, '#goals-center-{{$note->id}}');
     }).call(window);
 </script>