Răsfoiți Sursa

Meds - frequency/experience update

Vijayakrishnan 3 ani în urmă
părinte
comite
0b6d1c16b7
16 a modificat fișierele cu 653 adăugiri și 298 ștergeri
  1. 60 0
      app/Models/Point.php
  2. 97 79
      resources/views/app/patient/medications-center.blade.php
  3. 10 0
      resources/views/app/patient/module-specific-summary-renderers/medication/plan.blade.php
  4. 12 1
      resources/views/app/patient/note/rhs-sidebar.blade.php
  5. 39 0
      resources/views/app/patient/segment-templates/_child_plan/medication/edit-plan-in-place-optimized.php
  6. 42 0
      resources/views/app/patient/segment-templates/_child_plan/medication/edit-plan-optimized.php
  7. 46 0
      resources/views/app/patient/segment-templates/_child_plan/medication/last-plan-optimized.php
  8. 47 0
      resources/views/app/patient/segment-templates/_child_review/medication/edit-review-in-place-optimized.php
  9. 50 0
      resources/views/app/patient/segment-templates/_child_review/medication/edit-review-optimized.php
  10. 49 0
      resources/views/app/patient/segment-templates/_child_review/medication/last-review-optimized.php
  11. 12 2
      resources/views/app/patient/segment-templates/omega_medications/summary.blade.php
  12. 10 2
      resources/views/app/patient/wizard-partials/add-multiple-pre-existing.blade.php
  13. 56 89
      resources/views/app/patient/wizard-partials/common-fields-add.blade.php
  14. 62 90
      resources/views/app/patient/wizard-partials/common-fields-edit-optimized.blade.php
  15. 1 1
      resources/views/app/patient/wizard-partials/common-fields-edit.blade.php
  16. 60 34
      resources/views/app/patient/wizard-partials/common-script.blade.php

+ 60 - 0
app/Models/Point.php

@@ -106,6 +106,66 @@ class Point extends Model
             ->first();
     }
 
+    // NOTE: $point is not a point instance - but a raw object containing point data
+    public static function getCurrentAndPreviousChildReviews($point, $note) {
+        $current = null;
+        $previous = null;
+        $point = Point::where('id', $point->id)->first();
+        if ($point->lastChildReview) {
+            if ($point->last_child_review_point_scoped_note_id === $note->id) {
+                if($point->lastChildReview->data) {
+                    $current = $point->lastChildReview;
+                    $current->data = json_decode($current->data);
+                }
+                $previous = \App\Models\Point::where('id', '<', $point->lastChildReview->id)
+                    ->where('category', 'REVIEW')
+                    ->where('parent_point_id', $point->id)
+                    ->orderBy('id', 'DESC')
+                    ->first();
+                if($previous && $previous->data) {
+                    $previous->data = json_decode($previous->data);
+                }
+            }
+            else {
+                if($point->lastChildReview->data) {
+                    $previous = $point->lastChildReview;
+                    $previous->data = json_decode($previous->data);
+                }
+            }
+        }
+        return [$current, $previous];
+    }
+
+    // NOTE: $point is not a point instance - but a raw object containing point data
+    public static function getCurrentAndPreviousChildPlans($point, $note) {
+        $current = null;
+        $previous = null;
+        $point = Point::where('id', $point->id)->first();
+        if ($point->lastChildPlan) {
+            if ($point->last_child_plan_point_scoped_note_id === $note->id) {
+                if($point->lastChildPlan->data) {
+                    $current = $point->lastChildPlan;
+                    $current->data = json_decode($current->data);
+                }
+                $previous = \App\Models\Point::where('id', '<', $point->lastChildPlan->id)
+                    ->where('category', 'PLAN')
+                    ->where('parent_point_id', $point->id)
+                    ->orderBy('id', 'DESC')
+                    ->first();
+                if($previous && $previous->data) {
+                    $previous->data = json_decode($previous->data);
+                }
+            }
+            else {
+                if($point->lastChildPlan->data) {
+                    $previous = $point->lastChildPlan;
+                    $previous->data = json_decode($previous->data);
+                }
+            }
+        }
+        return [$current, $previous];
+    }
+
     public static function getGlobalSingletonOfCategory(Client $_patient, String $_category, $_assoc = false) {
         $point = Point
             ::where('client_id', $_patient->id)

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

@@ -53,8 +53,8 @@ if(!@$summaryView) {
                     <th class="border-bottom-0 text-secondary text-center width-30px">Rel.</th>
                 @endif
                 <th class="border-bottom-0 text-secondary">Name</th>
-                <th class="border-bottom-0 text-secondary w-30">Subjective</th>
-                <th class="border-bottom-0 text-secondary w-30">Plan</th>
+                <th class="border-bottom-0 text-secondary w-30">Subj. Frequency / Experience</th>
+                <th class="border-bottom-0 text-secondary w-30">Plan Frequency</th>
                 @if(!@$summaryView) <th class="border-bottom-0 text-secondary width-30px"></th> @endif
             </tr>
             </thead>
@@ -88,7 +88,19 @@ if(!@$summaryView) {
                             <div>
                                 @if(!@$summaryView)
                                     <div moe huge relative>
-                                        <a start show href="#" title="Edit"><?= !!@($medication->data->name) ? @($medication->data->name) : '-' ?></a>
+                                        <a start show href="#" title="Edit">
+                                            <?= !!@($medication->data->name) ? @($medication->data->name) : '-' ?>
+                                            <?php
+                                            if($medication->last_child_review_data) {
+                                                $review = json_decode($medication->last_child_review_data);
+                                                if(isset($review->value) && isset($review->experience)) {
+                                                    ?>
+                                                    <span class="text-dark text-sm ml-1">({{$review->value}})</span>
+                                                    <?php
+                                                }
+                                            }
+                                            ?>
+                                        </a>
                                         <form url="/api/visitPoint/updateTopLevel" no-auto-focus class="mcp-theme-1 frm-edit-medication">
                                             <input type="hidden" name="uid" value="<?= $medication->uid ?>">
                                             <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
@@ -167,12 +179,15 @@ if(!@$summaryView) {
                         </div>
                     </td>
                     <td>
+                        <?php
+                        list($currentChildReview, $previousChildReview) = @$point ? \App\Models\Point::getCurrentAndPreviousChildReviews($medication, $note) : [null, null];
+                        ?>
                         <div if-read-mode>
                             <div class="d-flex align-items-start position-relative">
                                 <div class="flex-grow-1">
                                     <?php
                                     $point = $medication;
-                                    include resource_path('views/app/patient/segment-templates/_child_review/last-review-optimized.php');
+                                    include resource_path('views/app/patient/segment-templates/_child_review/medication/last-review-optimized.php');
                                     ?>
                                 </div>
                                 @if(!@$summaryView)
@@ -187,7 +202,7 @@ if(!@$summaryView) {
                                     </a>
                                     <?php
                                     if($segment) {
-                                        include resource_path('views/app/patient/segment-templates/_child_review/edit-review-optimized.php');
+                                        include resource_path('views/app/patient/segment-templates/_child_review/medication/edit-review-optimized.php');
                                     }
                                     ?>
                                 </div>
@@ -197,17 +212,20 @@ if(!@$summaryView) {
                         <div if-edit-mode>
                             <?php
                             if($segment) {
-                                include resource_path('views/app/patient/segment-templates/_child_review/edit-review-in-place-optimized.php');
+                                include resource_path('views/app/patient/segment-templates/_child_review/medication/edit-review-in-place-optimized.php');
                             }
                             ?>
                         </div>
                     </td>
                     <td>
+                        <?php
+                        list($currentChildPlan, $previousChildPlan) = @$point ? \App\Models\Point::getCurrentAndPreviousChildPlans($medication, $note) : [null, null];
+                        ?>
                         <div if-read-mode>
                             <div class="d-flex align-items-start position-relative">
                                 <div class="flex-grow-1">
                                     <?php
-                                    include resource_path('views/app/patient/segment-templates/_child_plan/last-plan-optimized.php');
+                                    include resource_path('views/app/patient/segment-templates/_child_plan/medication/last-plan-optimized.php');
                                     ?>
                                 </div>
                                 @if(!@$summaryView)
@@ -222,7 +240,7 @@ if(!@$summaryView) {
                                     </a>
                                     <?php
                                     if($segment) {
-                                        include resource_path('views/app/patient/segment-templates/_child_plan/edit-plan-optimized.php');
+                                        include resource_path('views/app/patient/segment-templates/_child_plan/medication/edit-plan-optimized.php');
                                     }
                                     ?>
                                 </div>
@@ -232,7 +250,7 @@ if(!@$summaryView) {
                         <div if-edit-mode>
                             <?php
                             if($segment) {
-                                include resource_path('views/app/patient/segment-templates/_child_plan/edit-plan-in-place-optimized.php');
+                                include resource_path('views/app/patient/segment-templates/_child_plan/medication/edit-plan-in-place-optimized.php');
                             }
                             ?>
                         </div>
@@ -270,86 +288,86 @@ if(!@$summaryView) {
                     @include('app.patient.wizard-partials.add-multiple-pre-existing', ['label' => 'medication', 'adder' => 'Prescriber'])
                 </div>
                 <div class="cm-tab d-none" tab-key="add-single">
-                            <div class="row">
-                                <div class="col-8">
-                                    <form action="/api/visitPoint/addTopLevel" class="mcp-theme-1 w-100" id="frm-add-medication" novalidate>
-                                        <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">
-
-                                        <input type="hidden" name="isRemovedDueToEntryError" value="0">
-
-                                        <div class="d-flex align-items-baseline mb-2">
-                                            <b>Add Medication</b>
-                                            @if(count($favorites))
-                                                <div class="d-inline position-relative on-click-menu ml-4">
-                                                <span class="text-primary c-pointer">
-                                                    <i class="fa fa-bookmark text-info mr-1"></i> Common Medications <i class="ml-1 fa fa-caret-down"></i>
-                                                </span>
-                                                    <div menu right class="bg-white border">
-                                                        @foreach($favorites as $favorite)
-                                                            <a native target="_blank" href="#"
-                                                               data-name="{{@($favorite->data->name)}}"
-                                                               data-medId="{{@($favorite->data->medId)}}"
-                                                               data-routedMedId="{{@($favorite->data->routedMedId)}}"
-                                                               data-routedDosageFormMedId="{{@($favorite->data->routedDosageFormMedId)}}"
-                                                               data-gcnSeqno="{{@($favorite->data->gcnSeqno)}}"
-                                                               class="px-2 py-1 d-block text-nowrap text-sm favorite-item">
-                                                                {{$favorite->data->name}}
-                                                            </a>
-                                                        @endforeach
-                                                    </div>
-                                                </div>
-                                            @endif
-                                        </div>
-                                        <div class="mb-2">
-                                            <label class="mb-0 font-weight-bold">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 class="row">
+                        <div class="col-8">
+                            <form action="/api/visitPoint/addTopLevel" class="mcp-theme-1 w-100" id="frm-add-medication" novalidate>
+                                <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">
+
+                                <input type="hidden" name="isRemovedDueToEntryError" value="0">
+
+                                <div class="d-flex align-items-baseline mb-2">
+                                    <b>Add Medication</b>
+                                    @if(count($favorites))
+                                        <div class="d-inline position-relative on-click-menu ml-4">
+                                        <span class="text-primary c-pointer">
+                                            <i class="fa fa-bookmark text-info mr-1"></i> Common Medications <i class="ml-1 fa fa-caret-down"></i>
+                                        </span>
+                                            <div menu right class="bg-white border">
+                                                @foreach($favorites as $favorite)
+                                                    <a native target="_blank" href="#"
+                                                       data-name="{{@($favorite->data->name)}}"
+                                                       data-medId="{{@($favorite->data->medId)}}"
+                                                       data-routedMedId="{{@($favorite->data->routedMedId)}}"
+                                                       data-routedDosageFormMedId="{{@($favorite->data->routedDosageFormMedId)}}"
+                                                       data-gcnSeqno="{{@($favorite->data->gcnSeqno)}}"
+                                                       class="px-2 py-1 d-block text-nowrap text-sm favorite-item">
+                                                        {{$favorite->data->name}}
+                                                    </a>
+                                                @endforeach
+                                            </div>
                                         </div>
+                                    @endif
+                                </div>
+                                <div class="mb-2">
+                                    <label class="mb-0 font-weight-bold">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>
 
-                                        <?php $point = null; ?>
-                                        @include('app.patient.wizard-partials.common-fields-optimized', ['label' => 'medication', 'addVerbPT' => 'Prescribed'])
+                                <?php $point = null; ?>
+                                @include('app.patient.wizard-partials.common-fields-optimized', ['label' => 'medication', 'addVerbPT' => 'Prescribed'])
 
-                                        <div class="d-flex align-items-center">
-                                            <button type="submit" class="btn btn-sm btn-primary mr-2">Save Medication</button>
-                                            <button type="button" class="btn btn-sm btn-default border-secondary bg-white border mr-2" onclick="return closeStagPopup()">Close</button>
-                                        </div>
-                                    </form>
+                                <div class="d-flex align-items-center">
+                                    <button type="submit" class="btn btn-sm btn-primary mr-2">Save Medication</button>
+                                    <button type="button" class="btn btn-sm btn-default border-secondary bg-white border mr-2" onclick="return closeStagPopup()">Close</button>
                                 </div>
-                                <div class="col-4 border-left">
+                            </form>
+                        </div>
+                        <div class="col-4 border-left">
 
-                                    <?php
-                                    $problems = \App\Models\Point::getPointsOfCategory($patient, "PROBLEM");
-                                    ?>
-                                    @if(count($problems))
-                                        <h6 class="my-0 font-weight-bold text-secondary mb-2">Active Problems</h6>
-                                        <div class="bg-light border px-2 pt-2 pb-1 mb-0">
-                                            @foreach($problems as $problem)
-                                                <div class="mb-1">
-                                                    <b><?= !!@($problem->data->name) ? @($problem->data->name) : '-' ?></b>
-                                                </div>
-                                            @endforeach
+                            <?php
+                            $problems = \App\Models\Point::getPointsOfCategory($patient, "PROBLEM");
+                            ?>
+                            @if(count($problems))
+                                <h6 class="my-0 font-weight-bold text-secondary mb-2">Active Problems</h6>
+                                <div class="bg-light border px-2 pt-2 pb-1 mb-0">
+                                    @foreach($problems as $problem)
+                                        <div class="mb-1">
+                                            <b><?= !!@($problem->data->name) ? @($problem->data->name) : '-' ?></b>
                                         </div>
-                                        <hr class="my-3 m-neg-3">
-                                    @endif
+                                    @endforeach
+                                </div>
+                                <hr class="my-3 m-neg-3">
+                            @endif
 
-                                    <div class="fdb-rx-vigilance max-height-400px overflow-auto">
+                            <div class="fdb-rx-vigilance max-height-400px overflow-auto">
 
-                                    </div>
-                                </div>
                             </div>
                         </div>
+                    </div>
+                </div>
             </div>
         </div>
         @endif

+ 10 - 0
resources/views/app/patient/module-specific-summary-renderers/medication/plan.blade.php

@@ -23,6 +23,16 @@
                     <td class="px-2">
                         <div class=" <?= $point->is_removed ? 'strike-through' : '' ?> grow-till-300px">
                             <?= !!@($point->data->name) ? @($point->data->name) : '-' ?>
+                            <?php
+                            if($point->lastChildReview) {
+                                $review = json_decode($point->lastChildReview->data);
+                                if(isset($review->value) && isset($review->experience)) {
+                                    ?>
+                                    <span class="text-dark text-sm ml-1">({{$review->value}})</span>
+                                    <?php
+                                }
+                            }
+                            ?>
                         </div>
                     </td>
                     <td class="width-300px">

+ 12 - 1
resources/views/app/patient/note/rhs-sidebar.blade.php

@@ -111,7 +111,18 @@
                     <?php $rel = $medication->relevanceToNote($note); ?>
                     <div class="d-inline-flex align-items-baseline px-1 {{$rel ? 'bg-warning-mellow' : ''}}">
                         <span class="mr-1">•</span>
-                        <span>{{$medication->data->name}}</span>
+                        <span>{{$medication->data->name}}
+                        <?php
+                        if($medication->lastChildReview) {
+                            $review = json_decode($medication->lastChildReview->data);
+                            if(isset($review->value) && isset($review->experience)) {
+                                ?>
+                                <span class="text-dark text-sm ml-1">({{$review->value}})</span>
+                                <?php
+                            }
+                        }
+                        ?>
+                        </span>
                     </div>
                 @endforeach
             @else

+ 39 - 0
resources/views/app/patient/segment-templates/_child_plan/medication/edit-plan-in-place-optimized.php

@@ -0,0 +1,39 @@
+<div class="d-flex align-items-start">
+    <div visit-moe relative class="d-block flex-grow-1">
+        <form show url="/api/visitPoint/upsertChildPlan" class="mcp-theme-1 w-100" left>
+            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+            <input type="hidden" name="data">
+
+            <div class="mb-2">
+                <label class="text-sm mb-0 font-weight-bold text-secondary">Frequency</label>
+                <input type="text"
+                       data-name="value"
+                       value="<?= @($currentChildPlan->data->value) ? trim(strip_tags($currentChildPlan->data->value)) : '' ?>"
+                       class="form-control form-control-sm min-width-unset">
+            </div>
+
+            <div class="d-none">
+                <button submit class="btn btn-sm btn-primary mr-2">Save</button>
+                <button cancel class="btn btn-sm btn-default border">Cancel</button>
+            </div>
+        </form>
+    </div>
+    <?php if($currentChildPlan): ?>
+        <div visit-moe relative class="d-inline">
+            <a start show href="#" class="pl-2 pr-1 text-center d-block" title="Delete Plan">
+                <i class="fa fa-trash-alt text-danger on-hover-opaque"></i>
+            </a>
+            <form url="/api/visitPoint/destroyCurrentChildPlan" class="mcp-theme-1" right>
+                <input type="hidden" name="uid" value="<?= $point->uid ?>">
+
+                <p class="mb-2">Delete this plan?</p>
+
+                <div>
+                    <button submit class="btn btn-sm btn-danger mr-2">Delete</button>
+                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                </div>
+            </form>
+        </div>
+    <?php endif; ?>
+</div>

+ 42 - 0
resources/views/app/patient/segment-templates/_child_plan/medication/edit-plan-optimized.php

@@ -0,0 +1,42 @@
+<div visit-moe large class="d-inline">
+    <a start show href="#" class="px-1 text-center d-block" title="<?= $currentChildPlan ? 'Edit Plan' : 'Add Plan'?>">
+        <i class="fa <?= $currentChildPlan ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
+    </a>
+    <form url="/api/visitPoint/upsertChildPlan" class="mcp-theme-1 w-100" left>
+        <input type="hidden" name="uid" value="<?= $point->uid ?>">
+        <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+        <input type="hidden" name="data">
+
+        <p class="mb-2"><b>Plan</b></p>
+
+        <div class="mb-2">
+            <label class="text-sm mb-0 font-weight-bold text-secondary">Frequency</label>
+            <input type="text"
+                   data-name="value"
+                   value="<?= @($currentChildPlan->data->value) ? trim(strip_tags($currentChildPlan->data->value)) : '' ?>"
+                   class="form-control form-control-sm min-width-unset">
+        </div>
+
+        <div>
+            <button submit class="btn btn-sm btn-primary mr-2">Save</button>
+            <button cancel class="btn btn-sm btn-default border">Cancel</button>
+        </div>
+    </form>
+</div>
+<?php if($currentChildPlan): ?>
+    <div visit-moe relative class="d-inline">
+        <a start show href="#" class="px-1 text-center d-block" title="Delete Plan">
+            <i class="fa fa-trash-alt text-danger on-hover-opaque"></i>
+        </a>
+        <form url="/api/visitPoint/destroyCurrentChildPlan" class="mcp-theme-1" right>
+            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+
+            <p class="mb-2">Delete this plan?</p>
+
+            <div>
+                <button submit class="btn btn-sm btn-danger mr-2">Delete</button>
+                <button cancel class="btn btn-sm btn-default border">Cancel</button>
+            </div>
+        </form>
+    </div>
+<?php endif; ?>

+ 46 - 0
resources/views/app/patient/segment-templates/_child_plan/medication/last-plan-optimized.php

@@ -0,0 +1,46 @@
+<?php if ($point->last_child_plan_point_id && $point->last_child_plan_data): ?>
+    <?php $parsedPlan = json_decode($point->last_child_plan_data); ?>
+    <div class="<?= !@$flat && $point->last_child_plan_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
+        <div>
+            <div class="inline-html-container">
+                <?php if(@$parsedPlan->value): ?>
+                    <div><span class="text-sm">Freq: </span><?= trim(strip_tags($parsedPlan->value)) ?></div>
+                <?php endif; ?>
+            </div>
+        </div>
+        <span class="screen-only">
+        <?php if ($point->last_child_plan_point_scoped_note_id === $patient->core_note_id): ?>
+            <span class="text-sm">(updated on the patient's chart)</span>
+        <?php else: ?>
+            <?php if ($point->last_child_plan_point_scoped_note_id === $note->id): ?>
+                <span class="text-sm">(updated on this note)</span>
+            <?php else: ?>
+                <?php if(!@$summaryView): ?>
+                    <div class="d-inline position-relative on-click-menu">
+                        <span class="text-sm text-primary c-pointer">
+                            <?= relative_friendly_date($point->last_child_plan_effective_date) ?>
+                            <?php if($point->last_child_plan_creator): ?>
+                                by <?= $point->last_child_plan_creator ?>
+                            <?php endif; ?>
+                        </span>
+                        <div menu right class="bg-white border">
+                            <a native target="_blank"
+                               href="/patients/view/<?= $patient->uid ?>/notes/view/<?= $point->last_child_plan_note_uid ?>"
+                               class="px-2 py-1 d-block text-nowrap text-sm">Go to note</a>
+                        </div>
+                    </div>
+                <?php else: ?>
+                    <span class="text-sm text-secondary">
+                        <?= relative_friendly_date($point->last_child_plan_effective_date) ?>
+                        <?php if($point->last_child_plan_creator): ?>
+                            by <?= $point->last_child_plan_creator ?>
+                        <?php endif; ?>
+                    </span>
+                <?php endif; ?>
+            <?php endif; ?>
+        <?php endif; ?>
+        </span>
+    </div>
+<?php else: ?>
+    <div class="inline-html-container text-secondary text-sm">-</div>
+<?php endif; ?>

+ 47 - 0
resources/views/app/patient/segment-templates/_child_review/medication/edit-review-in-place-optimized.php

@@ -0,0 +1,47 @@
+<div class="d-flex align-items-start">
+    <div visit-moe relative class="d-block flex-grow-1">
+        <form show url="/api/visitPoint/upsertChildReview" class="mcp-theme-1" right>
+            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+            <input type="hidden" name="data">
+
+            <div class="mb-2">
+                <label class="text-sm mb-0 font-weight-bold text-secondary">Frequency</label>
+                <input type="text"
+                       data-name="value"
+                       value="<?= @($currentChildReview->data->value) ? trim(strip_tags($currentChildReview->data->value)) : '' ?>"
+                       class="form-control form-control-sm min-width-unset">
+            </div>
+            <div class="mb-2">
+                <label class="text-sm mb-0 font-weight-bold text-secondary">Experience</label>
+                <input type="text"
+                       data-name="experience"
+                       value="<?= @($currentChildReview->data->experience) ?>"
+                       class="form-control form-control-sm min-width-unset">
+            </div>
+
+            <div class="d-none">
+                <button submit class="btn btn-sm btn-primary mr-2">Save</button>
+                <button cancel class="btn btn-sm btn-default border">Cancel</button>
+            </div>
+        </form>
+    </div>
+    <?php if(!empty($currentValue)): ?>
+        <div visit-moe relative class="d-inline">
+            <a start show href="#" class="pl-2 pr-1 text-center d-block" title="Undo Changes">
+                <i class="fa fa-trash-alt text-danger on-hover-opaque"></i>
+            </a>
+            <form url="/api/visitPoint/destroyCurrentChildReview" class="mcp-theme-1" right>
+                <input type="hidden" name="uid" value="<?= $point->uid ?>">
+
+                <p class="mb-2">Undo Changes?</p>
+
+                <div>
+                    <button submit class="btn btn-sm btn-danger mr-2">Delete</button>
+                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                </div>
+            </form>
+        </div>
+    <?php endif; ?>
+</div>
+

+ 50 - 0
resources/views/app/patient/segment-templates/_child_review/medication/edit-review-optimized.php

@@ -0,0 +1,50 @@
+<div visit-moe large class="d-inline">
+    <a start show href="#" class="px-1 text-center d-block" title="<?= $currentChildReview ? 'Edit Subjective' : 'Add Subjective'?>">
+        <i class="fa <?= $currentChildReview ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
+    </a>
+    <form url="/api/visitPoint/upsertChildReview" class="mcp-theme-1 w-100" left>
+        <input type="hidden" name="uid" value="<?= $point->uid ?>">
+        <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+        <input type="hidden" name="data">
+
+        <p class="mb-2"><b>Subjective</b></p>
+
+        <div class="mb-2">
+            <label class="text-sm mb-0 font-weight-bold text-secondary">Frequency</label>
+            <input type="text"
+                   data-name="value"
+                   value="<?= @($currentChildReview->data->value) ? trim(strip_tags($currentChildReview->data->value)) : '' ?>"
+                   class="form-control form-control-sm min-width-unset">
+        </div>
+        <div class="mb-2">
+            <label class="text-sm mb-0 font-weight-bold text-secondary">Experience</label>
+            <input type="text"
+                   data-name="experience"
+                   value="<?= @($currentChildReview->data->experience) ?>"
+                   class="form-control form-control-sm min-width-unset">
+        </div>
+
+        <div>
+            <button submit class="btn btn-sm btn-primary mr-2">Save</button>
+            <button cancel class="btn btn-sm btn-default border">Cancel</button>
+        </div>
+    </form>
+</div>
+<?php if($currentChildReview): ?>
+    <div visit-moe relative class="d-inline">
+        <a start show href="#" class="px-1 text-center d-block" title="Undo Changes">
+            <i class="fa fa-trash-alt text-danger on-hover-opaque"></i>
+        </a>
+        <form url="/api/visitPoint/destroyCurrentChildReview" class="mcp-theme-1" right>
+            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+
+            <p class="mb-2">Undo Changes?</p>
+
+            <div>
+                <button submit class="btn btn-sm btn-danger mr-2">Delete</button>
+                <button cancel class="btn btn-sm btn-default border">Cancel</button>
+            </div>
+        </form>
+    </div>
+<?php endif; ?>
+

+ 49 - 0
resources/views/app/patient/segment-templates/_child_review/medication/last-review-optimized.php

@@ -0,0 +1,49 @@
+<?php if ($point->last_child_review_point_id && $point->last_child_review_data): ?>
+    <?php $parsedReview = json_decode($point->last_child_review_data); ?>
+    <div class="<?= $point->last_child_review_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
+        <div>
+            <div class="inline-html-container">
+                <?php if(@$parsedReview->value): ?>
+                    <div><span class="text-sm">Freq: </span><?= trim(strip_tags($parsedReview->value)) ?></div>
+                <?php endif; ?>
+                <?php if(@$parsedReview->experience): ?>
+                    <div><span class="text-sm">Experience: </span><?= $parsedReview->experience ?></div>
+                <?php endif; ?>
+            </div>
+        </div>
+        <span class="screen-only">
+        <?php if ($point->last_child_review_point_scoped_note_id === $patient->core_note_id): ?>
+            <span class="text-sm">(updated on the patient's chart)</span>
+        <?php else: ?>
+            <?php if ($point->last_child_review_point_scoped_note_id === $note->id): ?>
+                <span class="text-sm">(updated on this note)</span>
+            <?php else: ?>
+                <?php if(!@$summaryView): ?>
+                    <div class="d-inline position-relative on-click-menu">
+                        <span class="text-sm text-primary c-pointer">
+                            <?= relative_friendly_date($point->last_child_review_effective_date) ?>
+                            <?php if($point->last_child_review_creator): ?>
+                                by <?= $point->last_child_review_creator ?>
+                            <?php endif; ?>
+                        </span>
+                        <div menu right class="bg-white border">
+                            <a native target="_blank"
+                               href="/patients/view/<?= $patient->uid ?>/notes/view/<?= $point->last_child_review_note_uid ?>"
+                               class="px-2 py-1 d-block text-nowrap text-sm">Go to note</a>
+                        </div>
+                    </div>
+                <?php else: ?>
+                    <span class="text-sm text-secondary">
+                        <?= relative_friendly_date($point->last_child_review_effective_date) ?>
+                        <?php if($point->last_child_review_creator): ?>
+                            by <?= $point->last_child_review_creator ?>
+                        <?php endif; ?>
+                    </span>
+                <?php endif; ?>
+            <?php endif; ?>
+        <?php endif; ?>
+        </span>
+    </div>
+<?php else: ?>
+    <div class="inline-html-container text-secondary text-sm">-</div>
+<?php endif; ?>

+ 12 - 2
resources/views/app/patient/segment-templates/omega_medications/summary.blade.php

@@ -32,13 +32,23 @@ $plural = 'Medications';
 		<td class="px-2">
 			<div class=" <?= $point->is_removed ? 'strike-through' : '' ?> grow-till-300px">
 				<?= !!@($point->data->name) ? @($point->data->name) : '-' ?>
+				<?php
+				if($point->lastChildReview) {
+					$review = json_decode($point->lastChildReview->data);
+					if(isset($review->value) && isset($review->experience)) {
+						?>
+						<span class="text-dark text-sm ml-1">({{$review->value}})</span>
+						<?php
+					}
+				}
+				?>
 			</div>
 		</td>
 		<td class="width-300px">
 			<div class="d-flex align-items-baseline pl-2">
 				<?php $review = $point->childReviewAddedInNote($note); ?>
-				<?php if(!!$review && @$review->data->value): ?>
-					<span class="pr-2">{!! $review->data->value !!}</span>
+				<?php if(!!$review && @$review->data->experience): ?>
+					<span class="pr-2">{!! $review->data->experience !!}</span>
 				<?php endif; ?>
 				<span class="text-nowrap">
 					<?php if ($point->is_removed): ?>

+ 10 - 2
resources/views/app/patient/wizard-partials/add-multiple-pre-existing.blade.php

@@ -17,8 +17,11 @@
                     <th class="border-bottom-0 text-secondary">Specialty</th>
                     <th class="border-bottom-0 text-secondary">Organization</th>
                 @endif
-                <th class="border-bottom-0 text-secondary">Subjective</th>
-                <th class="border-bottom-0 text-secondary">Plan</th>
+                <th class="border-bottom-0 text-secondary {{$label === 'medication' ? 'width-150px' : '' }}">{{$label === 'medication' ? 'Subj. Frequency' : 'Subjective'}}</th>
+                @if($label === 'medication')
+                    <th class="border-bottom-0 text-secondary">Subj. Experience</th>
+                @endif
+                <th class="border-bottom-0 text-secondary {{$label === 'medication' ? 'width-150px' : '' }}">{{$label === 'medication' ? 'Plan Frequency' : 'Plan'}}</th>
                 <th class="border-bottom-0 text-secondary width-140px">Start Date</th>
                 <th class="d-none border-bottom-0 text-secondary text-nowrap">{{$adder}}</th>
                 <th class="border-bottom-0 text-secondary width-50px"></th>
@@ -101,6 +104,11 @@
                 <td class="p-0">
                     <textarea rows="1" key="value" bucket="childReviewData"></textarea>
                 </td>
+                @if($label === 'medication')
+                    <td class="p-0">
+                        <textarea rows="1" key="experience" bucket="childReviewData"></textarea>
+                    </td>
+                @endif
                 <td class="p-0">
                     <textarea rows="1" key="value" bucket="childPlanData"></textarea>
                 </td>

+ 56 - 89
resources/views/app/patient/wizard-partials/common-fields-add.blade.php

@@ -170,103 +170,70 @@
     @if(1 || $patient->core_note_id !== $note->id) {{-- allow review/plan from core note --}}
 	<div class="row">
         @if(!@$noReview)
-            <div class="mb-2 col-md-6 pr-0">
-                <?php
-                $currentValue = '';
-                $previousValue = '';
-                $previousChildReview = null;
-                if (@$point) {
-                    if ($point->lastChildReview && $point->last_child_review_point_scoped_note_id === $note->id) {
-                        $parsedReview = json_decode($point->lastChildReview->data);
-                        if (@($parsedReview->value)) {
-                            $currentValue = $parsedReview->value;
-                            $previousChildReview = \App\Models\Point::where('id', '<', $point->lastChildReview->id)
-                                ->where('category', 'REVIEW')
-                                ->where('parent_point_id', $point->id)
-                                ->orderBy('id', 'DESC')
-                                ->first();
-                            if ($previousChildReview && $previousChildReview->data) {
-                                $parsedReview = json_decode($previousChildReview->data);
-                                if (@($parsedReview->value)) {
-                                    $previousValue = $parsedReview->value;
-                                }
-                            }
-                        }
-                    } else {
-                        $previousChildReview = \App\Models\Point::where('parent_point_id', $point->id)
-                            ->where('category', 'REVIEW')
-                            ->orderBy('id', 'DESC')
-                            ->first();
-                        if ($previousChildReview && $previousChildReview->data) {
-                            $parsedReview = json_decode($previousChildReview->data);
-                            if (@$parsedReview->value) {
-                                $previousValue = $parsedReview->value;
-                            }
-                        }
-                    }
-                }
+            <?php
+            list($currentChildReview, $previousChildReview) = @$point ? \App\Models\Point::getCurrentAndPreviousChildReviews($point, $note) : [null, null];
             ?>
-                <label class="text-sm mb-0 font-weight-bold">{{@$reviewLabel ? $reviewLabel : 'Subjective'}}</label>
-                <div note-rte
-                     class="form-group mb-2 rte-holder bg-white border rounded"
-                     data-field-name="reviewValue"><?= $currentValue ?></div>
-                <?php if($previousValue): ?>
-                <div class="mb-2">
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous {{@$reviewLabel ? $reviewLabel : 'Subjective'}} / <?= friendlier_date($previousChildReview->created_at) ?> (click to copy)</span>
+            @if($label === 'medication')
+                <div class="mb-2 col-md-3 pr-0 pb-2">
+                    <label class="text-sm mb-0 font-weight-bold">Subj. Frequency</label>
+                    <input type="text"
+                           data-name="value"
+                           data-container-name="childReviewData"
+                           class="form-control form-control-sm min-width-unset">
+                </div>
+                <div class="mb-2 col-md-6 pr-0 pb-2">
+                    <label class="text-sm mb-0 font-weight-bold">Subj. Experience</label>
+                    <input type="text"
+                           data-name="experience"
+                           data-container-name="childReviewData"
+                           class="form-control form-control-sm min-width-unset">
+                </div>
+            @else
+                <div class="mb-2 col-md-6 pr-0">
+                    <label class="text-sm mb-0 font-weight-bold">{{@$reviewLabel ? $reviewLabel : 'Subjective'}}</label>
+                    <div note-rte
+                         class="form-group mb-2 rte-holder bg-white border rounded"
+                         data-field-name="reviewValue"><?= @($currentChildReview->data->value) ?></div>
+                    <?php if($previousChildReview && @($previousChildReview->data->value)): ?>
+                    <div class="mb-2">
+                        <div class="d-flex align-items-baseline mb-1">
+                            <span class="text-sm text-secondary">Previous {{@$reviewLabel ? $reviewLabel : 'Subjective'}} / <?= friendlier_date($previousChildReview->created_at) ?> (click to copy)</span>
+                        </div>
+                        <div class="p-1 bg-light border inline-html-container click-to-copy"><?= $previousChildReview->data->value ?></div>
                     </div>
-                    <div class="p-1 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
+                    <?php endif; ?>
                 </div>
-                <div class="d-none disallow-if-review-same-as" compare-width="reviewValue"><?= str_compact($previousValue) ?></div>
-                <?php endif; ?>
-            </div>
+            @endif
         @endif
 
         @if(!@$noPlan)
-            <div class="mb-2 col-md-6">
-                <?php
-                $currentValue = '';
-                $previousValue = '';
-                $previousChildPlan = null;
-                if (@$point) {
-                    if ($point->lastChildPlan && $point->last_child_plan_point_scoped_note_id === $note->id) {
-                        $parsedPlan = json_decode($point->lastChildPlan->data);
-                        $currentValue = @($parsedPlan->value) ? $parsedPlan->value : '';
-                        $previousChildPlan = \App\Models\Point::where('id', '<', $point->lastChildPlan->id)
-                            ->where('category', 'PLAN')
-                            ->where('parent_point_id', $point->id)
-                            ->orderBy('id', 'DESC')
-                            ->first();
-                        if ($previousChildPlan && $previousChildPlan->data) {
-                            $parsedPlan = json_decode($previousChildPlan->data);
-                            $previousValue = $parsedPlan->value;
-                        }
-                    } else {
-                        $previousChildPlan = \App\Models\Point::where('parent_point_id', $point->id)
-                            ->where('category', 'PLAN')
-                            ->orderBy('id', 'DESC')
-                            ->first();
-                        if ($previousChildPlan && $previousChildPlan->data) {
-                            $parsedPlan = json_decode($previousChildPlan->data);
-                            $previousValue = $parsedPlan->value;
-                        }
-                    }
-                }
-                ?>
-                <label class="text-sm mb-0 font-weight-bold">{{@$planLabel ? $planLabel : 'Plan'}}</label>
-                <div note-rte
-                     class="form-group mb-2 rte-holder bg-white border rounded"
-                     data-field-name="planValue"><?= $currentValue ?></div>
-                <?php if($previousValue): ?>
-                <div class="mb-2">
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous {{@$planLabel ? $planLabel : 'Plan'}} / <?= friendlier_date($previousChildPlan->created_at) ?> (click to copy)</span>
+            <?php
+            list($currentChildPlan, $previousChildPlan) = @$point ? \App\Models\Point::getCurrentAndPreviousChildPlans($point, $note) : [null, null];
+            ?>
+            @if($label === 'medication')
+                <div class="mb-2 col-md-3 pb-2">
+                    <label class="text-sm mb-0 font-weight-bold">Plan Frequency</label>
+                    <input type="text"
+                           data-name="value"
+                           data-container-name="childPlanData"
+                           class="form-control form-control-sm min-width-unset">
+                </div>
+            @else
+                <div class="mb-2 col-md-6">
+                    <label class="text-sm mb-0 font-weight-bold">{{@$planLabel ? $planLabel : 'Plan'}}</label>
+                    <div note-rte
+                         class="form-group mb-2 rte-holder bg-white border rounded"
+                         data-field-name="planValue"><?= @($currentChildPlan->data->value) ?></div>
+                    <?php if($previousChildPlan && @($previousChildPlan->data->value)): ?>
+                    <div class="mb-2">
+                        <div class="d-flex align-items-baseline mb-1">
+                            <span class="text-sm text-secondary">Previous {{@$planLabel ? $planLabel : 'Plan'}} / <?= friendlier_date($previousChildPlan->created_at) ?> (click to copy)</span>
+                        </div>
+                        <div class="p-1 bg-light border inline-html-container click-to-copy"><?= $previousChildPlan->data->value ?></div>
                     </div>
-                    <div class="p-1 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
+                    <?php endif; ?>
                 </div>
-                <div class="d-none disallow-if-plan-same-as" compare-width="planValue"><?= str_compact($previousValue) ?></div>
-                <?php endif; ?>
-            </div>
+            @endif
         @endif
 	</div>
     @endif

+ 62 - 90
resources/views/app/patient/wizard-partials/common-fields-edit-optimized.blade.php

@@ -31,7 +31,7 @@
             <div class="d-flex align-items-baseline mt-1">
                 <label class="my-0 d-inline-flex align-items-center">
                     <input type="radio" name="additionReasonCategory" value="ON_INTAKE"
-				{{ !$point ? 'checked' : '' }}
+				            {{ !$point ? 'checked' : '' }}
                             {{$point && $point->addition_reason_category === 'ON_INTAKE' ? 'checked' : ''}}
                             {{0 && $point && $point->added_in_note_id !== $note->id ? 'readonly disabled' : ''}}>
                     <span class="ml-1">Pre-existing</span>
@@ -148,103 +148,75 @@
     @if(1 || $patient->core_note_id !== $note->id) {{-- allow review/plan from core note --}}
 	<div class="row">
         @if(!@$noReview)
-            <div class="mb-2 col-md-6">
-                <?php
-                $currentValue = '';
-                $previousValue = '';
-                $previousChildReview = null;
-                if (@$point) {
-                    if ($point->last_child_review_point_id && $point->last_child_review_point_scoped_note_id === $note->id) {
-                        $parsedReview = json_decode($point->last_child_review_data);
-                        if (@($parsedReview->value)) {
-                            $currentValue = $parsedReview->value;
-                            /*$previousChildReview = \App\Models\Point::where('id', '<', $point->last_child_review_point_id)
-                                ->where('category', 'REVIEW')
-                                ->where('parent_point_id', $point->id)
-                                ->orderBy('id', 'DESC')
-                                ->first();
-                            if ($previousChildReview && $previousChildReview->data) {
-                                $parsedReview = json_decode($previousChildReview->data);
-                                if (@($parsedReview->value)) {
-                                    $previousValue = $parsedReview->value;
-                                }
-                            }*/
-                        }
-                    } else {
-                        /*$previousChildReview = \App\Models\Point::where('parent_point_id', $point->id)
-                            ->where('category', 'REVIEW')
-                            ->orderBy('id', 'DESC')
-                            ->first();
-                        if ($previousChildReview && $previousChildReview->data) {
-                            $parsedReview = json_decode($previousChildReview->data);
-                            if (@$parsedReview->value) {
-                                $previousValue = $parsedReview->value;
-                            }
-                        }*/
-                    }
-                }
+            <?php
+            list($currentChildReview, $previousChildReview) = @$point ? \App\Models\Point::getCurrentAndPreviousChildReviews($point, $note) : [null, null];
             ?>
-                <label class="text-sm mb-0 font-weight-bold">{{@$reviewLabel ? $reviewLabel : 'Subjective'}}</label>
-                <div note-rte
-                     class="form-group mb-2 rte-holder bg-white border rounded"
-                     data-field-name="reviewValue"><?= $currentValue ?></div>
-                <?php if($previousValue): ?>
-                <div class="mb-2">
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous {{@$reviewLabel ? $reviewLabel : 'Subjective'}} / <?= friendlier_date($previousChildReview->created_at) ?> (click to copy)</span>
+            @if($label === 'medication')
+                <div class="mb-2 col-md-3 pr-0 pb-2">
+                    <label class="text-sm mb-0 font-weight-bold">Subj. Frequency</label>
+                    <input type="text"
+                           data-name="value"
+                           data-container-name="childReviewData"
+                           value="{{@($currentChildReview->data->value)}}"
+                           class="form-control form-control-sm min-width-unset">
+                </div>
+                <div class="mb-2 col-md-6 pr-0 pb-2">
+                    <label class="text-sm mb-0 font-weight-bold">Subj. Experience</label>
+                    <input type="text"
+                           data-name="experience"
+                           data-container-name="childReviewData"
+                           value="{{@($currentChildReview->data->experience)}}"
+                           class="form-control form-control-sm min-width-unset">
+                </div>
+            @else
+                <div class="mb-2 col-md-6 pr-0">
+                    <label class="text-sm mb-0 font-weight-bold">{{@$reviewLabel ? $reviewLabel : 'Subjective'}}</label>
+                    <div note-rte
+                         class="form-group mb-2 rte-holder bg-white border rounded"
+                         data-field-name="reviewValue"><?= @($currentChildReview->data->value) ?></div>
+                    <?php if($previousChildReview && @($previousChildReview->data->value)): ?>
+                    <div class="mb-2">
+                        <div class="d-flex align-items-baseline mb-1">
+                            <span class="text-sm text-secondary">Previous {{@$reviewLabel ? $reviewLabel : 'Subjective'}} / <?= friendlier_date($previousChildReview->created_at) ?> (click to copy)</span>
+                        </div>
+                        <div class="p-1 bg-light border inline-html-container click-to-copy"><?= $previousChildReview->data->value ?></div>
                     </div>
-                    <div class="p-1 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
+                    <div class="d-none disallow-if-review-same-as" compare-width="reviewValue"><?= str_compact($previousChildReview->data->value) ?></div>
+                    <?php endif; ?>
                 </div>
-                <div class="d-none disallow-if-review-same-as" compare-width="reviewValue"><?= str_compact($previousValue) ?></div>
-                <?php endif; ?>
-            </div>
+            @endif
         @endif
 
         @if(!@$noPlan)
-            <div class="mb-2 col-md-6">
-                <?php
-                $currentValue = '';
-                $previousValue = '';
-                $previousChildPlan = null;
-                if (@$point) {
-                    if ($point->last_child_plan_point_id && $point->last_child_plan_point_scoped_note_id === $note->id) {
-                        $parsedPlan = json_decode($point->last_child_plan_data);
-                        $currentValue = @($parsedPlan->value) ? $parsedPlan->value : '';
-                        /*$previousChildPlan = \App\Models\Point::where('id', '<', $point->last_child_plan_point_id)
-                            ->where('category', 'PLAN')
-                            ->where('parent_point_id', $point->id)
-                            ->orderBy('id', 'DESC')
-                            ->first();
-                        if ($previousChildPlan && $previousChildPlan->data) {
-                            $parsedPlan = json_decode($previousChildPlan->data);
-                            $previousValue = $parsedPlan->value;
-                        }*/
-                    } else {
-                        /*$previousChildPlan = \App\Models\Point::where('parent_point_id', $point->id)
-                            ->where('category', 'PLAN')
-                            ->orderBy('id', 'DESC')
-                            ->first();
-                        if ($previousChildPlan && $previousChildPlan->data) {
-                            $parsedPlan = json_decode($previousChildPlan->data);
-                            $previousValue = $parsedPlan->value;
-                        }*/
-                    }
-                }
-                ?>
-                <label class="text-sm mb-0 font-weight-bold">{{@$planLabel ? $planLabel : 'Plan'}}</label>
-                <div note-rte
-                     class="form-group mb-2 rte-holder bg-white border rounded"
-                     data-field-name="planValue"><?= $currentValue ?></div>
-                <?php if($previousValue): ?>
-                <div class="mb-2">
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous {{@$planLabel ? $planLabel : 'Plan'}} / <?= friendlier_date($previousChildPlan->created_at) ?> (click to copy)</span>
+            <?php
+            list($currentChildPlan, $previousChildPlan) = @$point ? \App\Models\Point::getCurrentAndPreviousChildPlans($point, $note) : [null, null];
+            ?>
+            @if($label === 'medication')
+                <div class="mb-2 col-md-3 pb-2">
+                    <label class="text-sm mb-0 font-weight-bold">Plan Frequency</label>
+                    <input type="text"
+                           data-name="value"
+                           data-container-name="childPlanData"
+                           value="{{@($currentChildPlan->data->value)}}"
+                           class="form-control form-control-sm min-width-unset">
+                </div>
+            @else
+                <div class="mb-2 col-md-6">
+                    <label class="text-sm mb-0 font-weight-bold">{{@$planLabel ? $planLabel : 'Plan'}}</label>
+                    <div note-rte
+                         class="form-group mb-2 rte-holder bg-white border rounded"
+                         data-field-name="planValue"><?= @($currentChildPlan->data->value) ?></div>
+                    <?php if($previousChildPlan && @($previousChildPlan->data->value)): ?>
+                    <div class="mb-2">
+                        <div class="d-flex align-items-baseline mb-1">
+                            <span class="text-sm text-secondary">Previous {{@$planLabel ? $planLabel : 'Plan'}} / <?= friendlier_date($previousChildPlan->created_at) ?> (click to copy)</span>
+                        </div>
+                        <div class="p-1 bg-light border inline-html-container click-to-copy"><?= $previousChildPlan->data->value ?></div>
                     </div>
-                    <div class="p-1 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
+                    <div class="d-none disallow-if-plan-same-as" compare-width="planValue"><?= str_compact($previousChildPlan->data->value) ?></div>
+                    <?php endif; ?>
                 </div>
-                <div class="d-none disallow-if-plan-same-as" compare-width="planValue"><?= str_compact($previousValue) ?></div>
-                <?php endif; ?>
-            </div>
+            @endif
         @endif
 	</div>
     @endif

+ 1 - 1
resources/views/app/patient/wizard-partials/common-fields-edit.blade.php

@@ -148,7 +148,7 @@
     @if(1 || $patient->core_note_id !== $note->id) {{-- allow review/plan from core note --}}
 	<div class="row">
         @if(!@$noReview)
-            <div class="mb-2 col-md-6">
+            <div class="mb-2 col-md-6 pr-0">
                 <?php
                 $currentValue = '';
                 $previousValue = '';

+ 60 - 34
resources/views/app/patient/wizard-partials/common-script.blade.php

@@ -262,7 +262,7 @@ parentSegment.find('#frm-add-{{$label}}')
             parsed = JSON.parse(dataField.val());
         }
 
-        @if(1 || $patient->core_note_id !== $note->id)
+        @if($label !== 'medication')
         // store plan content
         let planContent = parsed && parsed.planValue ? parsed.planValue : '';
         let reviewContent = parsed && parsed.reviewValue ? parsed.reviewValue : '';
@@ -274,7 +274,7 @@ parentSegment.find('#frm-add-{{$label}}')
         if(parsed.reviewValue) delete parsed.reviewValue;
         @endif
 
-        form.find('[data-name]').each(function() {
+        form.find('[data-name]:not([data-container-name])').each(function() {
             if(!parsed) parsed = {};
 
             let keys = $(this).attr('data-name').split('->');
@@ -303,17 +303,30 @@ parentSegment.find('#frm-add-{{$label}}')
 
         let payload = {};
         form.serializeArray().map(x => {payload[x.name] = x.value;});
-        @if(1 || $patient->core_note_id !== $note->id)
-        if(!!reviewContent && $.trim($('<div/>').html(reviewContent).text())) {
-            payload.childReviewData = JSON.stringify({
-                value: reviewContent
-            })
-        }
-        if(!!planContent && $.trim($('<div/>').html(planContent).text())) {
-            payload.childPlanData = JSON.stringify({
-                value: planContent
-            })
-        }
+
+        @if($label === 'medication')
+            form.find('[data-name][data-container-name]').each(function() {
+                let dataContainer = $(this).attr('data-container-name');
+                if(!payload[dataContainer]) {
+                    payload[dataContainer] = {};
+                }
+                else {
+                    payload[dataContainer] = JSON.parse(payload[dataContainer]);
+                }
+                payload[dataContainer][$(this).attr('data-name')] = $(this).val();
+                payload[dataContainer] = JSON.stringify(payload[dataContainer]);
+            });
+        @else
+            if(!!reviewContent && $.trim($('<div/>').html(reviewContent).text())) {
+                payload.childReviewData = JSON.stringify({
+                    value: reviewContent
+                })
+            }
+            if(!!planContent && $.trim($('<div/>').html(planContent).text())) {
+                payload.childPlanData = JSON.stringify({
+                    value: planContent
+                })
+            }
         @endif
 
         $.post(form.attr('action'), payload, _data => {
@@ -354,7 +367,7 @@ parentSegment.find('.frm-edit-{{$label}}')
             parsed = JSON.parse(dataField.val());
         }
 
-        @if(1 || $patient->core_note_id !== $note->id)
+        @if($label !== 'medication')
 
         let reviewContent = parsed && parsed.reviewValue ? parsed.reviewValue : '';
         let planContent = parsed && parsed.planValue ? parsed.planValue : '';
@@ -416,27 +429,40 @@ parentSegment.find('.frm-edit-{{$label}}')
 
         let payload = {};
         form.serializeArray().map(x => {payload[x.name] = x.value;});
-        @if(1 || $patient->core_note_id !== $note->id)
-        if(!!reviewContent && $.trim($('<div/>').html(reviewContent).text())) {
-            payload.childReviewData = JSON.stringify({
-                value: reviewContent
-            })
-        }
-        if(!!planContent && $.trim($('<div/>').html(planContent).text())) {
-            payload.childPlanData = JSON.stringify({
-                value: planContent
-            })
-        }
-        // if added/removed during-visit, require plan
-        /*if(form.find('[name="isRemovedDueToEntryError"]:checked').val() !== '1' &&
-            ((form.find('[name="isRemoved"]:checked').val() === '0' && form.find('[name="additionReasonCategory"]:checked').val() === 'DURING_VISIT') ||
-            (form.find('[name="isRemoved"]:checked').val() === '1' && form.find('[name="removalReasonCategory"]:checked').val() === 'DURING_VISIT'))
-        ) {
-            if(!planContent) {
-                alert('Updates during visit require an accompanying plan!');
-                return false;
+
+        @if($label === 'medication')
+            form.find('[data-name][data-container-name]').each(function() {
+                let dataContainer = $(this).attr('data-container-name');
+                if(!payload[dataContainer]) {
+                    payload[dataContainer] = {};
+                }
+                else {
+                    payload[dataContainer] = JSON.parse(payload[dataContainer]);
+                }
+                payload[dataContainer][$(this).attr('data-name')] = $(this).val();
+                payload[dataContainer] = JSON.stringify(payload[dataContainer]);
+            });
+        @else
+            if(!!reviewContent && $.trim($('<div/>').html(reviewContent).text())) {
+                payload.childReviewData = JSON.stringify({
+                    value: reviewContent
+                })
             }
-        }*/
+            if(!!planContent && $.trim($('<div/>').html(planContent).text())) {
+                payload.childPlanData = JSON.stringify({
+                    value: planContent
+                })
+            }
+            // if added/removed during-visit, require plan
+            /*if(form.find('[name="isRemovedDueToEntryError"]:checked').val() !== '1' &&
+                ((form.find('[name="isRemoved"]:checked').val() === '0' && form.find('[name="additionReasonCategory"]:checked').val() === 'DURING_VISIT') ||
+                (form.find('[name="isRemoved"]:checked').val() === '1' && form.find('[name="removalReasonCategory"]:checked').val() === 'DURING_VISIT'))
+            ) {
+                if(!planContent) {
+                    alert('Updates during visit require an accompanying plan!');
+                    return false;
+                }
+            }*/
         @endif
 
         $.post(form.attr('url'), payload, _data => {