Kaynağa Gözat

Dx wiz: make CC editable w. autosave + ensure segment update

Vijayakrishnan 3 yıl önce
ebeveyn
işleme
a42d48c859

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

@@ -336,6 +336,11 @@ class NoteController extends Controller
         }
     }
 
+    public function generateCC(Request $request, Note $note) {
+        $client = $note->client;
+        return view('app.patient.segment-templates.chief_complaint.generate', compact('note', 'client'));
+    }
+
     public function segmentSummary(Request $request, Segment $segment) {
         return '<div class="mrv-content border-top px-3 pt-2 mt-3">' . @$segment->summary_html . '</div>';
     }

+ 42 - 7
resources/views/app/patient/problems-center.blade.php

@@ -30,7 +30,26 @@ function isFavoriteProblem($_problem, $_favorites) {
             <span class="mx-2 text-secondary">|</span>
             <a href="#" class="regenerate-cc">Regenerate with relevant problems</a>
         </div>
-        <textarea rows="3" readonly class="cc-readonly form-control form-control-sm mb-0 bg-light"><?= $ccSegment && @$ccSegment->summary_html ? trim(strip_tags($ccSegment->summary_html)) : '' ?></textarea>
+
+        <?php
+        $segment = $note->getSegmentByInternalName('chief_complaint');
+        $ccPoint = Point::where('added_in_segment_id', $segment->id)->where('category', 'CHIEF_COMPLAINT')->orderBy('id', 'DESC')->first();
+        $parsed = null;
+        if ($ccPoint && !!@$ccPoint->data) {
+            $parsed = json_decode($ccPoint->data);
+        }
+        ?>
+        <div visit-moe class="d-block">
+            <form show="" url="/api/visitPoint/upsertNoteSingleton" class="mcp-theme-1" id="frm-cc-regenerate">
+                <input type="hidden" name="segmentUid" value="{{$segment->uid}}">
+                <input type="hidden" name="category" value="CHIEF_COMPLAINT">
+                <input type="hidden" name="data" value="">
+                <div note-rte slim-rte
+                     class="form-group mb-2 border-left border-right rte-holder cc-generated"
+                     data-field-name="free_text"
+                ><?= $parsed && @$parsed->free_text ? $parsed->free_text : '' ?></div>
+            </form>
+        </div>
 
         <hr class="m-neg-3 my-3">
         @endif
@@ -362,13 +381,10 @@ function isFavoriteProblem($_problem, $_favorites) {
                     showMask();
 
                     // refresh the cc
-                    $.post('/api/visit/updateSegmentHtml', {
-                        segmentUid: '{{$ccSegment->uid}}'
-                    }, _data => {
+                    $.get('/note/generate-cc/{{$note->uid}}', _data => {
                         if(!hasResponseError(_data)) {
-                            parentSegment.find('.cc-readonly').val(
-                                $.trim($('<div/>').html(_data.data.summaryHtml).text())
-                            );
+                            let quillInstance = $('#frm-cc-regenerate').find('.cc-generated').first().data('quillInstance');
+                            quillInstance.root.innerHTML = $.trim($('<div/>').html(_data.data).text());
                         }
                     }, 'json')
                     .then(function() {
@@ -397,6 +413,25 @@ function isFavoriteProblem($_problem, $_favorites) {
                     $(this).closest('.on-click-menu').find('[menu]').hide();
                     return false;
                 });
+
+            setTimeout(() => {
+                // custom buttons on title bar
+                $('.button-container').remove();
+                let buttonContainer = $('<div/>').addClass('button-container ml-4 mr-auto');
+                let titleElem = $('#problems-center-{{$note->id}}').closest('.stag-popup').find('.stag-popup-title>span');
+                titleElem.next().removeClass('ml-auto');
+                titleElem.parent().addClass('align-items-center');
+
+                $('<div class="d-inline-flex align-self-stretch align-items-center">' +
+                    '<span class="autosave-indicator saving text-sm text-secondary">Saving changes &hellip;</span>' +
+                    '<span class="autosave-indicator saved text-sm text-secondary">' +
+                    '<i class="fa fa-check"></i>' +
+                    ' Saved' +
+                    '</span>' +
+                    '</div>').appendTo(buttonContainer);
+
+                buttonContainer.insertAfter(titleElem);
+            }, 1000); // HACK - don't autosave the init-time induced 'change' events
         }
         addMCInitializer('problems-center-{{$note->id}}', init, '#problems-center-{{$note->id}}');
     }).call(window);

+ 31 - 0
resources/views/app/patient/segment-templates/chief_complaint/generate.blade.php

@@ -0,0 +1,31 @@
+<?php
+list($problemPoints, $counts) = \App\Models\Point::getPointsOfCategoryExtended($client, 'PROBLEM', $note);
+$problemNames = [];
+foreach ($problemPoints as $problemPoint) {
+    if($problemPoint->relevanceToNote($note)) {
+        $problemNames[] = $problemPoint->data->name;
+    }
+}
+$problems = '';
+for($i = 0; $i < count($problemNames); $i++) {
+    if($i > 0) {
+        if($i === count($problemNames) - 1) {
+            $problems .= " and ";
+        }
+        else {
+            $problems .= ", ";
+        }
+    }
+    $problems .= $problemNames[$i];
+}
+$defaultCC = "Patient {$client->name_first} {$client->name_last} " .
+    "is a {$client->age_in_years} year old" .
+    ($client->sex ? ($client->sex === 'F' ? ' female' : ($client->sex === 'M' ? ' male' : ' ' . $client->sex)) : '') .
+    ($problems ? " with a history of {$problems}" : "") .
+    ($note->new_or_fu_or_na === 'NEW' ? ' presenting for establishing care' : ' presenting for follow-up') .
+    ".";
+echo json_encode([
+    "success" => true,
+    "data" => $defaultCC
+]);
+?>

+ 7 - 0
resources/views/app/patient/wizard-partials/common-script.blade.php

@@ -121,6 +121,8 @@ function __initRTEs(_collection) {
             .attr('data-editor-id', editorID)
             .attr('with-shortcuts', 1);
 
+        $(el).data('quillInstance', quill);
+
         // set value initially
         if(!noteRTE.is('[ignore-changes]')) {
             onTextChange();
@@ -754,4 +756,9 @@ $(document).on('rich-text-input.auto-save-rich-text-input', '[if-edit-mode] [vis
     }
 });
 
+$(document).off('rich-text-input.auto-save-rich-text-input', '#frm-cc-regenerate [note-rte]');
+$(document).on('rich-text-input.auto-save-rich-text-input', '#frm-cc-regenerate [note-rte]', function () {
+    debouncedLifestyleSaver(this);
+});
+
 initStagSuggest();

+ 1 - 0
routes/web.php

@@ -456,6 +456,7 @@ Route::middleware('pro.auth')->group(function () {
     Route::get('/point/review-log/{point}', 'NoteController@reviewLog')->name('point-review-log');
     Route::get('/point/plan-log/{point}', 'NoteController@planLog')->name('point-plan-log');
     Route::get('/note/pdf/{note}', 'NoteController@downloadAsPdf')->name('note-pdf');
+    Route::get('/note/generate-cc/{note}', 'NoteController@generateCC')->name('note-generate-cc');
     Route::get('/note/ccm-agreement/{note}', 'NoteController@ccmAgreement')->name('ccm-agreement');
     Route::get('/note/rpm-agreement/{note}', 'NoteController@rpmAgreement')->name('rpm-agreement');
     Route::get('/segment-summary/{segment}', 'NoteController@segmentSummary')->name('segment-summary');