Vijayakrishnan 3 жил өмнө
parent
commit
93129f207e

+ 2 - 2
app/Http/Controllers/NoteController.php

@@ -308,8 +308,8 @@ class NoteController extends Controller
         return '<div class="mrv-content border-top px-3 pt-2 mt-3">' . @$segment->summary_html . '</div>';
     }
 
-    public function medicationsCenter(Request $request, Client $client, Note $note) {
-        return view('app.patient.medications-center', compact('client', 'note'));
+    public function medicationsCenter(Request $request, Client $patient, Note $note) {
+        return view('app.patient.medications-center', compact('patient', 'note'));
     }
 
     // TODO move to utility

+ 1 - 0
app/Models/Note.php

@@ -66,6 +66,7 @@ class Note extends Model
     public function segments()
     {
         return $this->hasMany(Segment::class, 'note_id', 'id')
+            ->where('id', '!=', $this->core_segment_id) // dont include core-segment
             ->where('is_active', true)
             ->orderBy('position_index', 'asc');
     }

+ 9 - 0
public/css/style.css

@@ -562,6 +562,12 @@ input.search_field, textarea.search_field {
     min-width: calc(100% - 0.5rem);
     right: 0.5rem;
 }
+[stag-suggest-bottom-left]~.stag-suggestions-container .suggestions-outer {
+    bottom: 30px;
+    left: 0;
+    top: auto;
+    right: auto;
+}
 .suggestions-outer .suggest-item, .suggestions-outer .no-suggest-items {
     padding: 0.25rem 0.5rem;
     text-decoration: none;
@@ -1034,6 +1040,9 @@ body .node input[type="number"] {
     padding: 0.75rem;
     min-height: 220px;
 }
+.stag-popup.overflow-visible>.stag-popup-content {
+    overflow: visible;
+}
 .stag-popup.min-height-unset>form {
     min-height: unset !important;
 }

+ 241 - 2
resources/views/app/patient/medications-center.blade.php

@@ -1,3 +1,242 @@
+<?php
+
+use App\Models\Point;
+use App\Models\Client;
+use App\Models\Note;
+use App\Models\Segment;
+
+/** @var Client $patient */
+/** @var Note $note */
+
+$points = Point
+    ::where('client_id', $patient->id)
+    ->where('category', 'MEDICATION')
+    ->where('is_removed_due_to_entry_error', false)
+    ->orderBy('is_removed')
+    ->orderBy('created_at')
+    ->get();
+foreach ($points as $point) {
+    if ($point->data) {
+        $point->data = json_decode($point->data);
+    }
+}
+$medications = $points;
+
+?>
+
 <div class="mt-3 p-3 border-top min-height-500px" id="medications-center-{{$note->id}}">
-Hello
-</div>
+    <div>
+
+        <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">Name</th>
+                <th class="border-bottom-0 text-secondary">Frequency</th>
+                <th class="border-bottom-0 text-secondary">Active?</th>
+                <th class="border-bottom-0 text-secondary">Edit</th>
+                <th class="border-bottom-0 text-secondary">Started</th>
+                <th class="border-bottom-0 text-secondary">Ended</th>
+                <th class="border-bottom-0 text-secondary">Last Review</th>
+                <th class="border-bottom-0 text-secondary">Last Plan</th>
+            </tr>
+            </thead>
+            <?php foreach($medications as $medication): ?>
+            <?php $point = $medication; ?>
+            <tr>
+                <td>
+                    <b><?= !!@($medication->data->name) ? @($medication->data->name) : '-' ?></b>
+                </td>
+                <td>
+                    <?= !!@($medication->data->frequency) ? @($medication->data->frequency) : '-' ?>
+                </td>
+                <td>
+                    <?= $medication->is_removed ? 'NO' : '<b>YES</b>' ?>
+                </td>
+                <td>
+                    EDIT
+                </td>
+                <td>
+                    <?= !!@($medication->data->start_date) ? @($medication->data->start_date) : '-' ?>
+                    @if(!!@($medication->data->prescriber))
+                        <div class="mt-1">By: <?= !!@($medication->data->prescriber) ? @($medication->data->prescriber) : '-' ?></div>
+                    @endif
+                </td>
+                <td>
+                    <?= !!@($medication->removal_effective_date) ? @($medication->removal_effective_date) : '-' ?>
+                    @if(!!@($medication->removal_reason_memo))
+                        <div class="mt-1">By: <?= !!@($medication->removal_reason_memo) ? @($medication->removal_reason_memo) : '-' ?></div>
+                    @endif
+                </td>
+                <td>
+                    <div class="d-flex align-items-start">
+                        <div class="flex-grow-1">
+                            <?php
+                            $point = $medication;
+                            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<?= !!@($medication->data->name) ? ' for ' . @($medication->data->name) : '' ?>"
+                           href="/point/review-log/<?= $medication->uid ?>?popupmode=1">
+                            <i class="fa fa-history"></i>
+                        </a>
+                    </div>
+                </td>
+                <td>
+                    <div class="d-flex align-items-start">
+                        <div class="flex-grow-1">
+                            <?php
+                            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<?= !!@($medication->data->name) ? ' for ' . @($medication->data->name) : '' ?>"
+                           href="/point/plan-log/<?= $medication->uid ?>?popupmode=1">
+                            <i class="fa fa-history"></i>
+                        </a>
+                    </div>
+                </td>
+            </tr>
+            <?php endforeach; ?>
+        </table>
+
+        <div class="d-flex align-items-center">
+            <div class="mt-1 w-100 border p-2 bg-aliceblue border-info rounded">
+                <!--<a href="#" start show class="btn btn-sm btn btn-outline-primary">+ Add new medication, prescribed during this visit</a>-->
+                <form action="/api/visitPoint/addTopLevel" class="mcp-theme-1 w-100" id="frm-add-medication">
+                    <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
+                    <input type="hidden" name="category" value="MEDICATION">
+                    <input type="hidden" name="data">
+
+                    <input type="hidden" data-name="medId">
+                    <input type="hidden" data-name="routedMedId">
+                    <input type="hidden" data-name="routedDosageFormMedId">
+                    <input type="hidden" data-name="gcnSeqno">
+
+                    <p class="mb-2"><b>Add Medication</b></p>
+
+                    <div class="d-flex align-items-start">
+
+                        <div class="mb-2 w-25">
+                            <label class="text-sm text-secondary mb-1">Name</label>
+                            <input type="text"
+                                   data-name="name"
+                                   class="form-control form-control-sm"
+                                   stag-suggest
+                                   stag-suggest-bottom-left
+                                   stag-suggest-ep="/fdb-med-suggest-v2/json"
+                                   required>
+                        </div>
+                        <div class="mb-2 ml-2">
+                            <label class="text-sm text-secondary mb-1">Frequency</label>
+                            <input type="text" class="form-control form-control-sm" data-name="frequency"
+                                   data-option-list="frequency-options" autocomplete="off">
+                            <div id="frequency-options" class="data-option-list">
+                                <div>Once a day</div>
+                                <div>Twice a day</div>
+                            </div>
+                        </div>
+                        <div class="mb-2 ml-2">
+                            <label class="text-sm text-secondary mb-1">Existing / New</label>
+                            <select class="form-control form-control-sm" name="additionReasonCategory" required>
+                                <option value="">-- select --</option>
+                                <option value="ON_INTAKE">Existing (Patient was already on this)</option>
+                                <option value="DURING_VISIT">New (Prescribed during this visit)</option>
+                            </select>
+                        </div>
+                        <div class="mb-2 ml-2 flex-grow-1">
+                            <label class="text-sm text-secondary mb-1">Description</label>
+                            <textarea rows="1" data-name="description" class="form-control form-control-sm"></textarea>
+                        </div>
+
+                    </div>
+
+                    <div class="d-flex align-items-center">
+                        <button type="submit" class="btn btn-sm btn-primary mr-2">Submit</button>
+                        <button type="button" class="btn btn-sm btn-default border mr-2" onclick="closeStagPopup()">Close</button>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+
+<script>
+    (function() {
+        function init() {
+            let parentSegment = $('#medications-center-{{$note->id}}');
+            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="routedMedId"]').val(_data.routed_med_id);
+                    $(_input).closest('form').find('input[data-name="routedDosageFormMedId"]').val(_data.routed_dosage_form_med_id);
+                    $(_input).closest('form').find('input[data-name="gcnSeqno"]').val(_data.gcn_seqno);
+                    $(_input).closest('form').find('input[data-name="medId"]').val(_data.medid);
+                    return false;
+                });
+
+            parentSegment.find('#frm-add-medication')
+                .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();
+                            // TODO: update intake and plan meds
+                            refreshDynamicStagPopup();
+                        }
+                    }, 'json');
+                    return false;
+                });
+
+            initStagSuggest();
+        }
+        addMCInitializer('medications-center-{{$note->id}}', init, '#medications-center-{{$note->id}}')
+    }).call(window);
+</script>

+ 3 - 2
resources/views/app/patient/note/dashboard.blade.php

@@ -2230,10 +2230,11 @@
                         </div>
                         <div class="nbt-container p-2 border-right border-info d-inline-flex align-self-stretch">
                             <div native target="_blank"
-                                 class="c-pointer mrv-trigger d-inline-flex align-items-center"
+                                 class="c-pointer d-inline-flex align-items-center"
                                  open-in-stag-popup
+                                 mc-initer="medications-center-{{$note->id}}"
                                  title="Medications Center"
-                                 popup-style="wide"
+                                 popup-style="wide overflow-visible"
                                  href="/medications-center/{{$patient->uid}}/{{$note->uid}}">
                                 <i class="fa fa-bolt mr-1"></i>
                                 <span>Rx</span>

+ 1 - 1
routes/web.php

@@ -316,7 +316,7 @@ Route::middleware('pro.auth')->group(function () {
     Route::get('/point/plan-log/{point}', 'NoteController@planLog')->name('point-plan-log');
     Route::get('/note/pdf/{note}', 'NoteController@downloadAsPdf')->name('note-pdf');
     Route::get('/segment-summary/{segment}', 'NoteController@segmentSummary')->name('segment-summary');
-    Route::get('/medications-center/{client}/{note}', 'NoteController@medicationsCenter')->name('medications-center');
+    Route::get('/medications-center/{patient}/{note}', 'NoteController@medicationsCenter')->name('medications-center');
 
     //mb claim single view
     Route::get('mb-claims/view/{mbClaim}', 'PatientController@mbClaim')->name('mb-claim');