Jelajahi Sumber

Med reconciliation update (wip)

Vijayakrishnan 3 tahun lalu
induk
melakukan
992a54460d

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

@@ -280,7 +280,7 @@ list($medications, $counts) = Point::getPointsOfCategoryExtended($patient, 'MEDI
                 'update-parent ' +
                 'open-in-stag-popup ' +
                 'mc-initer="medications-reconcile-{{$note->id}}" ' +
-                'popup-style="stag-popup-md" ' +
+                'popup-style="medium" ' +
                 'class="btn-reconcile-active btn btn-sm mr-2 btn-info text-white font-weight-bold">Reconcile Active Medications</a>')
                 .appendTo(buttonContainer);
         }

+ 74 - 10
resources/views/app/patient/medications-reconcile.blade.php

@@ -10,7 +10,6 @@ use App\Models\Note;
 $points = Point
     ::where('client_id', $patient->id)
     ->where('category', 'MEDICATION')
-    ->where('is_removed_due_to_entry_error', false)
     ->where('is_removed', false)
     ->orderBy('created_at')
     ->get();
@@ -27,17 +26,55 @@ $medications = $points;
     <table class="table table-sm table-striped table-bordered">
         <thead>
         <tr>
-            <th class="border-bottom-0">Medication</th>
-            <th class="border-bottom-0">Subjective</th>
+            <th class="text-secondary bg-light border-bottom-0 w-25">Medication</th>
+            <th class="text-secondary bg-light border-bottom-0 w-25">Previous Subjective</th>
+            <th class="text-secondary bg-light border-bottom-0 w-25">Previous Plan</th>
+            <th class="text-secondary bg-light border-bottom-0 w-25">New Subjective</th>
         </tr>
         </thead>
         @foreach($medications as $medication)
-        <tr>
-            <td class="w-50">{{$medication->data->name}}</td>
-            <td class="p-0">
-                <input type="text" class="form-control form-control-sm border-0 rounded-0 shadow-none" data-point-uid="{{$medication->uid}}" value="Reconciled">
-            </td>
-        </tr>
+            <?php
+            $default = '';
+
+            // get most recent child plan for this point that was created before this note
+            $mostRecentPlanBeforeThisNote = Point::where('parent_point_id', $medication->id)
+                ->where('category', 'PLAN')
+                ->where('added_in_note_id', '<', $note->id)
+                ->orderBy('id', 'DESC')
+                ->first();
+
+            // get most recent child review for this point that was created before this note
+            $mostRecentReviewBeforeThisNote = Point::where('parent_point_id', $medication->id)
+                ->where('category', 'REVIEW')
+                ->where('added_in_note_id', '<', $note->id)
+                ->orderBy('id', 'DESC')
+                ->first();
+
+            // get child review for this point created on this note
+            $newReview = Point::where('parent_point_id', $medication->id)
+                ->where('category', 'REVIEW')
+                ->where('added_in_note_id', $note->id)
+                ->orderBy('id', 'DESC')
+                ->first();
+            if($newReview && $newReview->data) {
+                $newReview->data = json_decode($newReview->data);
+                $default = $newReview->data->value;
+            }
+            ?>
+            <tr>
+                <td class="bg-light font-weight-bold">{{$medication->data->name}}</td>
+                <td class="bg-light">
+                    @include('app/patient/wizard-partials/show-review', ['point' => $medication, 'review' => $mostRecentReviewBeforeThisNote])
+                </td>
+                <td class="bg-light">
+                    @include('app/patient/wizard-partials/show-plan', ['point' => $medication, 'plan' => $mostRecentPlanBeforeThisNote])
+                </td>
+                <td class="p-0 bg-white">
+                    <div note-rte slim-rte ignore-changes
+                         data-point-uid="{{$medication->uid}}"
+                         class="form-group rte-holder mb-0 bg-white border-0 rounded-0"><?= $default ?></div>
+                </td>
+            </tr>
         @endforeach
     </table>
     <div class="d-flex align-items-center justify-content-center">
@@ -48,6 +85,32 @@ $medications = $points;
 
 <script>
     (function() {
+        function __initRTEs(_collection) {
+            _collection.each(function() {
+                let noteRTE = $(this);
+                $(this).wrap(
+                    $('<div class="rte-holder"/>')
+                        .attr('data-shortcuts', '')
+                );
+                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: {
+                        toolbar: false
+                    }
+                });
+                quill.root.innerHTML = existingContent;
+                $(quill.container)
+                    .find('.ql-editor[contenteditable]')
+                    .attr('data-field', fieldName)
+                    .attr('data-editor-id', editorID)
+                    .attr('with-shortcuts', 1);
+
+            });
+        }
         function init() {
             $('#medications-reconcile-{{$note->id}} .btn-save-reviews')
                 .off('click')
@@ -62,7 +125,7 @@ $medications = $points;
                              parentPointUid: $(this).attr('data-point-uid'),
                              data: JSON.stringify({
                                  isReconciled: true,
-                                 value: $(this).val()
+                                 value: $(this).find('.ql-editor').html()
                              })
                          });
                     });
@@ -83,6 +146,7 @@ $medications = $points;
                     });
 
                 });
+            __initRTEs($('#medications-reconcile-{{$note->id}} [note-rte]'))
         }
         addMCInitializer('medications-reconcile-{{$note->id}}', init, '#medications-reconcile-{{$note->id}}')
     }).call(window);

+ 28 - 0
resources/views/app/patient/wizard-partials/show-plan.blade.php

@@ -0,0 +1,28 @@
+@if($plan)
+    <?php $parsedPlan = json_decode($plan->data); ?>
+    @if($parsedPlan && !empty(trim(strip_tags($parsedPlan->value))))
+        <div class="inline-html-container <?= $point->last_child_plan_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
+            <div><?= @$parsedPlan->value ?></div>
+        </div>
+        <div class="d-flex align-items-baseline">
+            @if ($point->last_child_plan_point_scoped_note_id === $patient->core_note_id)
+                <span class="text-sm">(updated on the patient's chart)</span>
+            @else
+                @if ($point->last_child_plan_point_scoped_note_id === $note->id)
+                    <span class="text-sm">(updated on this note)</span>
+                @else
+                    <a native target="_blank" class="text-sm"
+                       href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $plan->note]) ?>">
+                        <?= friendlier_date($plan->note->effective_dateest) ?>
+                    </a>
+                @endif
+            @endif
+            <span class="mx-2 text-secondary text-sm">|</span>
+            <a class="text-sm" href="#">Copy to new subjective</a>
+        </div>
+    @else
+        <span class="text-secondary text-sm">None</span>
+    @endif
+@else
+    <span class="text-secondary text-sm">None</span>
+@endif

+ 28 - 0
resources/views/app/patient/wizard-partials/show-review.blade.php

@@ -0,0 +1,28 @@
+@if($review)
+    <?php $parsedReview = json_decode($review->data); ?>
+    @if($parsedReview && !empty(trim(strip_tags($parsedReview->value))))
+        <div class="inline-html-container <?= $point->last_child_review_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
+            <div><?= @$parsedReview->value ?></div>
+        </div>
+        <div class="d-flex align-items-baseline pt-1 border-top mt-1 mb-2">
+            @if ($point->last_child_review_point_scoped_note_id === $patient->core_note_id)
+                <span class="text-sm">(updated on the patient's chart)</span>
+            @else
+                @if ($point->last_child_review_point_scoped_note_id === $note->id)
+                    <span class="text-sm">(updated on this note)</span>
+                @else
+                    <a native target="_blank" class="text-sm"
+                       href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $review->note]) ?>">
+                        <?= friendlier_date($review->note->effective_dateest) ?>
+                    </a>
+                @endif
+            @endif
+            <span class="mx-2 text-secondary text-sm">|</span>
+            <a href="#" class="text-sm">Copy to new subjective</a>
+        </div>
+    @else
+        <span class="text-secondary text-sm">None</span>
+    @endif
+@else
+    <span class="text-secondary text-sm">None</span>
+@endif