Browse Source

Pmhx - add to problems list via popup

Vijayakrishnan 3 years ago
parent
commit
10718fae0a

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

@@ -316,6 +316,10 @@ class NoteController extends Controller
         return view('app.patient.medications-reconcile', compact('patient', 'note'));
         return view('app.patient.medications-reconcile', compact('patient', 'note'));
     }
     }
 
 
+    public function problemsQuickAdd(Request $request, Client $patient, Note $note) {
+        return view('app.patient.problems-quick-add', compact('patient', 'note'));
+    }
+
     public function problemsCenter(Request $request, Client $patient, Note $note) {
     public function problemsCenter(Request $request, Client $patient, Note $note) {
         return view('app.patient.problems-center', compact('patient', 'note'));
         return view('app.patient.problems-center', compact('patient', 'note'));
     }
     }

+ 13 - 0
public/js/stag-suggest.js

@@ -186,6 +186,19 @@
             return false;
             return false;
         });
         });
 
 
+        // outside click
+        $(document)
+            .off('mousedown.stag-suggest-outer-click')
+            .on('mousedown.stag-suggest-outer-click', function (_e) {
+                let elem = $(_e.target);
+                if(!elem.is('.stag-suggestions-container') && !elem.closest('.stag-suggestions-container').length) {
+                    if($('.suggestions-outer:not(.d-none)').length) {
+                        $('.suggestions-outer').addClass('d-none');
+                        return false;
+                    }
+                }
+            });
+
     }
     }
     addMCInitializer('stag-suggest', window.initStagSuggest);
     addMCInitializer('stag-suggest', window.initStagSuggest);
 })();
 })();

+ 221 - 0
resources/views/app/patient/problems-quick-add.blade.php

@@ -0,0 +1,221 @@
+<?php
+
+use App\Models\Point;
+use App\Models\Client;
+use App\Models\Note;
+use App\Models\Segment;
+
+/** @var Client $patient */
+/** @var Note $note */
+
+$formID = rand(100000, 999999);
+
+?>
+
+<div class="mt-3 p-3 border-top" id="problems-quick-add-{{$formID}}">
+    <div class="d-flex align-items-center">
+        <form action="/api/visitPoint/addTopLevel" class="mcp-theme-1 w-100" id="frm-add-problem">
+            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
+            <input type="hidden" name="category" value="PROBLEM">
+            <input type="hidden" name="data">
+
+            <input type="hidden" data-name="dxid">
+            <input type="hidden" data-name="icd-type">
+
+            <input type="hidden" name="additionReasonCategory">
+            <input type="hidden" name="isRemoved">
+            <input type="hidden" name="removalReasonCategory">
+            <input type="hidden" name="isRemovedDueToEntryError">
+
+            <div class="row mb-2">
+                <div class="col-8 pr-0">
+                    <label class="text-sm text-secondary mb-0">Name</label>
+                    <input type="text"
+                           data-name="name"
+                           class="form-control form-control-sm"
+                           stag-suggest
+                           stag-suggest-ep="/fdb-dx-suggest/json"
+                           required>
+                </div>
+                <div class="col-4">
+                    <label class="text-sm text-secondary mb-0">ICD</label>
+                    <select data-name="icd"
+                            class="form-control form-control-sm min-width-unset"
+                            disabled>
+                    </select>
+                </div>
+            </div>
+            <div class="row mb-2">
+                <div class="col-12">
+                    <label class="text-sm text-secondary mb-0">Historic / Preexisting / New</label>
+                    <select class="form-control form-control-sm additionReasonCategory_ui"
+                            name="additionReasonCategory_ui" required>
+                        <option value="">-- select --</option>
+                        <option value="HISTORIC">Historic</option>
+                        <option value="PRE_EXISTING" selected>Preexisting</option>
+                        <option value="NEW">New (Found during this visit)</option>
+                    </select>
+                </div>
+            </div>
+            <div class="row mb-2">
+                <div class="col-4 pr-0">
+                    <div class="start_date_ui" style="display: none">
+                        <label class="text-sm text-secondary mb-0">Start Date</label>
+                        <input type="date"
+                               data-name="start_date"
+                               class="form-control form-control-sm min-width-unset">
+                    </div>
+                </div>
+                <div class="col-4 pr-0">
+                    <div class="removalEffectiveDate_ui" style="display: none">
+                        <label class="text-sm text-secondary mb-0">End Date</label>
+                        <input type="date"
+                               name="removalEffectiveDate"
+                               class="form-control form-control-sm min-width-unset">
+                    </div>
+                </div>
+                <div class="col-4">
+                    <div class="removalReasonMemo_ui" style="display: none">
+                        <label class="text-sm text-secondary mb-0">Removal By/Memo</label>
+                        <input type="text"
+                               name="removalReasonMemo"
+                               class="form-control form-control-sm min-width-unset">
+                    </div>
+                </div>
+            </div>
+
+            <div class="d-flex align-items-center">
+                <button type="submit" class="btn btn-sm btn-primary mr-2 my-1">Save Problem</button>
+            </div>
+        </form>
+    </div>
+</div>
+
+<script>
+    (function () {
+        function init() {
+            let parentSegment = $('#problems-quick-add-{{$formID}}');
+            parentSegment.find('input[stag-suggest][data-name="name"]')
+                .off('stag-suggest-selected')
+                .on('stag-suggest-selected', (_e, _input, _data) => {
+                    $(_input).closest('form').find('input[data-name="dxid"]').val(_data.dxid);
+                    let icdSelect = $(_input).closest('form').find('[data-name="icd"]').empty().prop('disabled', true);
+                    $.get('/fdb-dx-icds-for-dxid?dxid=' + _data.dxid, _data => {
+                        icdSelect.empty().append('<option value="">-- select --</option>');
+                        for (let i = 0; i < _data.length; i++) {
+                            icdSelect.append('<option value="' + _data[i].search_icd_cd + '" data-icd-type="' + _data[i].icd_cd_type + '">' + _data[i].search_icd_cd + ' (' + (_data[i].icd_cd_type === '01' ? 'ICD-9' : 'ICD-10') + ') - ' + _data[i].icd_desc + '</option>')
+                        }
+                        icdSelect.prop('disabled', false);
+                        if (_data.length === 1) {
+                            icdSelect.val(_data[0].routed_med_id).trigger('change');
+                        }
+                    }, 'json');
+                });
+
+            // on route selection
+            parentSegment.find('input[data-name="icd"]')
+                .off('change')
+                .on('change', function () {
+                    $(this).closest('form').find('input[data-name="icd-type"]').val($(this).find('option:selected').attr('data-icd-type'));
+                });
+
+            parentSegment.find('.additionReasonCategory_ui')
+                .off('change')
+                .on('change', function () {
+
+                    let form = $(this).closest('form');
+
+                    // additionReasonCategory
+                    // isRemoved
+                    // removalReasonCategory
+                    form.find('[name="isRemovedDueToEntryError"]').val('0');
+
+                    form.find('.start_date_ui').hide();
+                    form.find('.removalEffectiveDate_ui').hide();
+                    form.find('.removalReasonMemo_ui').hide();
+
+                    if (this.value === 'HISTORIC') {
+                        form.find('[name="additionReasonCategory"]').val('ON_INTAKE');
+                        form.find('[name="isRemoved"]').val('1');
+                        form.find('.start_date_ui').show();
+                        form.find('.removalEffectiveDate_ui').show();
+                        form.find('.removalReasonMemo_ui').show();
+                    } else if (this.value === 'PRE_EXISTING') {
+                        form.find('[name="additionReasonCategory"]').val('ON_INTAKE');
+                        form.find('[name="isRemoved"]').val('0');
+                        form.find('.start_date_ui').show();
+                    } else if (this.value === 'NEW') {
+                        form.find('[name="additionReasonCategory"]').val('DURING_VISIT');
+                        form.find('[name="isRemoved"]').val('0');
+                        form.find('.start_date_ui').show().find('input').val('{{date('Y-m-d')}}');
+                    }
+
+                });
+
+            parentSegment.find('#frm-add-problem')
+                .off('submit')
+                .on('submit', function () {
+
+                    let form = $(this);
+
+                    if (!form[0].checkValidity()) {
+                        form[0].reportValidity();
+                        return false;
+                    }
+
+                    // add [data-name] values to payload
+                    let dataField = form.find('[name="data"]').first();
+                    let parsed = null;
+                    if (dataField.val()) {
+                        parsed = JSON.parse(dataField.val());
+                    }
+                    form.find('[data-name]').each(function () {
+                        if (!parsed) parsed = {};
+
+                        let keys = $(this).attr('data-name').split('->');
+                        let currentNode = parsed;
+                        for (let i = 0; i < keys.length; i++) {
+                            if (i !== keys.length - 1) {
+                                if (typeof currentNode[keys[i]] === 'undefined') {
+                                    currentNode[keys[i]] = {};
+                                }
+                                currentNode = currentNode[keys[i]];
+                            } else {
+                                if ($(this).is(':checkbox')) {
+                                    currentNode[keys[i]] = $(this).prop('checked');
+                                } else {
+                                    currentNode[keys[i]] = $(this).val();
+                                }
+                            }
+                        }
+
+                    });
+                    if (parsed) {
+                        dataField.val(JSON.stringify(parsed));
+                    }
+
+                    $.post(form.attr('action'), form.serialize(), _data => {
+                        if (!hasResponseError(_data)) {
+                            hideMask();
+                            $('.visit-segment[data-segment-template-name="intake_problems"]').find('.refresh-segment').trigger('click');
+                            closeStagPopup();
+                        }
+                    }, 'json');
+                    return false;
+                });
+
+            initStagSuggest();
+
+            $('.additionReasonCategory_ui').trigger('change');
+
+            @if(request()->input('dx'))
+            parentSegment.find('input[stag-suggest][data-name="name"]')
+                .val('{{request()->input('dx')}}')
+                .trigger('keypress');
+            @endif
+
+        }
+
+        addMCInitializer('problems-quick-add-{{$note->id}}', init)
+    }).call(window);
+</script>

+ 10 - 0
resources/views/app/patient/segment-templates/past_medical_history/edit.blade.php

@@ -122,6 +122,16 @@ for ($i = 0; $i < count($fields); $i++) {
                                                             </div>
                                                             </div>
                                                         </div>
                                                         </div>
                                                     </div>
                                                     </div>
+                                                    <a v-show="common['{{$fName}}']"
+                                                       class="ml-1"
+                                                       native target="_blank"
+                                                       open-in-stag-popup
+                                                       popup-style="stag-popup-sm overflow-visible"
+                                                       title="Add to Problems List"
+                                                       mc-initer="problems-quick-add-{{$note->id}}"
+                                                       href="/problems-quick-add/{{$patient->uid}}/{{$note->uid}}?dx={{urlencode($values[$k])}}">
+                                                        <i class="fa fa-plus-circle on-hover-opaque"></i>
+                                                    </a>
                                                 </div>
                                                 </div>
                                                 <span v-show="common['{{$fName}}'] && common['{{$fName}}__comments']"
                                                 <span v-show="common['{{$fName}}'] && common['{{$fName}}__comments']"
                                                       v-html="common['{{$fName}}__comments']"
                                                       v-html="common['{{$fName}}__comments']"

+ 2 - 0
routes/web.php

@@ -384,6 +384,8 @@ Route::middleware('pro.auth')->group(function () {
     Route::get('/problems-center/{patient}/{note}', 'NoteController@problemsCenter')->name('problems-center');
     Route::get('/problems-center/{patient}/{note}', 'NoteController@problemsCenter')->name('problems-center');
     Route::get('/goals-center/{patient}/{note}', 'NoteController@goalsCenter')->name('goals-center');
     Route::get('/goals-center/{patient}/{note}', 'NoteController@goalsCenter')->name('goals-center');
 
 
+    Route::get('/problems-quick-add/{patient}/{note}', 'NoteController@problemsQuickAdd')->name('problems-quick-add');
+
     //mb claim single view
     //mb claim single view
     Route::get('mb-claims/view/{mbClaim}', 'PatientController@mbClaim')->name('mb-claim');
     Route::get('mb-claims/view/{mbClaim}', 'PatientController@mbClaim')->name('mb-claim');