浏览代码

LS centers read-moe/edit-mode UI impl

Vijayakrishnan 3 年之前
父节点
当前提交
33d042db17
共有 41 个文件被更改,包括 1523 次插入3074 次删除
  1. 1 1
      config/app.php
  2. 10 0
      public/css/style.css
  3. 213 32
      resources/views/app/patient/behavior-center.blade.php
  4. 214 31
      resources/views/app/patient/exercise-center.blade.php
  5. 2 2
      resources/views/app/patient/note/segment_script.blade.php
  6. 103 33
      resources/views/app/patient/nutrition-center.blade.php
  7. 6 106
      resources/views/app/patient/segment-templates/_child_plan/behavior/CRAVINGS/edit-plan.php
  8. 6 105
      resources/views/app/patient/segment-templates/_child_plan/behavior/FOOD_TRIGGERS/edit-plan.php
  9. 62 169
      resources/views/app/patient/segment-templates/_child_plan/behavior/SELF_MONITORING/edit-plan.php
  10. 11 105
      resources/views/app/patient/segment-templates/_child_plan/behavior/SLEEP_HABITS/edit-plan.php
  11. 15 0
      resources/views/app/patient/segment-templates/_child_plan/delete-plan.php
  12. 1 1
      resources/views/app/patient/segment-templates/_child_plan/edit-plan.php
  13. 186 310
      resources/views/app/patient/segment-templates/_child_plan/exercise/AEROBIC_ACTIVITY/edit-plan.php
  14. 32 130
      resources/views/app/patient/segment-templates/_child_plan/exercise/NEAT/edit-plan.php
  15. 35 134
      resources/views/app/patient/segment-templates/_child_plan/exercise/STRENGTH_TRAINING/edit-plan.php
  16. 8 41
      resources/views/app/patient/segment-templates/_child_plan/nutrition/DAILY_INTAKE_CALORIES/edit-plan.php
  17. 8 41
      resources/views/app/patient/segment-templates/_child_plan/nutrition/DAILY_INTAKE_CARBOHYDRATES/edit-plan.php
  18. 8 41
      resources/views/app/patient/segment-templates/_child_plan/nutrition/FAST_FOOD/edit-plan.php
  19. 8 41
      resources/views/app/patient/segment-templates/_child_plan/nutrition/HIGH_SUGAR_BEVERAGES/edit-plan.php
  20. 8 41
      resources/views/app/patient/segment-templates/_child_plan/nutrition/PORTION_SIZES/edit-plan.php
  21. 8 41
      resources/views/app/patient/segment-templates/_child_plan/nutrition/SNACKS/edit-plan.php
  22. 8 41
      resources/views/app/patient/segment-templates/_child_plan/nutrition/VEGETABLES/edit-plan.php
  23. 8 41
      resources/views/app/patient/segment-templates/_child_plan/nutrition/WATER_INTAKE/edit-plan.php
  24. 42 142
      resources/views/app/patient/segment-templates/_child_review/behavior/CRAVINGS/edit-review.php
  25. 46 145
      resources/views/app/patient/segment-templates/_child_review/behavior/FOOD_TRIGGERS/edit-review.php
  26. 62 169
      resources/views/app/patient/segment-templates/_child_review/behavior/SELF_MONITORING/edit-review.php
  27. 11 106
      resources/views/app/patient/segment-templates/_child_review/behavior/SLEEP_HABITS/edit-review.php
  28. 15 0
      resources/views/app/patient/segment-templates/_child_review/delete-review.php
  29. 1 1
      resources/views/app/patient/segment-templates/_child_review/edit-review.php
  30. 186 310
      resources/views/app/patient/segment-templates/_child_review/exercise/AEROBIC_ACTIVITY/edit-review.php
  31. 32 130
      resources/views/app/patient/segment-templates/_child_review/exercise/NEAT/edit-review.php
  32. 35 134
      resources/views/app/patient/segment-templates/_child_review/exercise/STRENGTH_TRAINING/edit-review.php
  33. 9 42
      resources/views/app/patient/segment-templates/_child_review/nutrition/DAILY_INTAKE_CALORIES/edit-review.php
  34. 9 42
      resources/views/app/patient/segment-templates/_child_review/nutrition/DAILY_INTAKE_CARBOHYDRATES/edit-review.php
  35. 8 48
      resources/views/app/patient/segment-templates/_child_review/nutrition/FAST_FOOD/edit-review.php
  36. 9 42
      resources/views/app/patient/segment-templates/_child_review/nutrition/HIGH_SUGAR_BEVERAGES/edit-review.php
  37. 9 42
      resources/views/app/patient/segment-templates/_child_review/nutrition/PORTION_SIZES/edit-review.php
  38. 8 48
      resources/views/app/patient/segment-templates/_child_review/nutrition/SNACKS/edit-review.php
  39. 9 42
      resources/views/app/patient/segment-templates/_child_review/nutrition/VEGETABLES/edit-review.php
  40. 9 42
      resources/views/app/patient/segment-templates/_child_review/nutrition/WATER_INTAKE/edit-review.php
  41. 62 102
      resources/views/app/patient/wizard-partials/common-script.blade.php

+ 1 - 1
config/app.php

@@ -65,7 +65,7 @@ return [
 
     'hrm2_url' => env('HRM2_URL'),
 
-    'asset_version' => 30,
+    'asset_version' => 31,
 
     'temp_dir' => env('TEMP_DIR'),
 

+ 10 - 0
public/css/style.css

@@ -2501,3 +2501,13 @@ table.table-cage tr td:last-child {
 table.table-xs tr td {
 	padding: 0.15rem;
 }
+
+[if-edit-mode], [if-read-mode] {
+    display: none;
+}
+.edit [if-edit-mode] {
+    display: block;
+}
+.read [if-read-mode] {
+    display: block;
+}

+ 213 - 32
resources/views/app/patient/behavior-center.blade.php

@@ -24,7 +24,7 @@ $points = [
 <div class="mt-3 p-3 border-top-behavior-rx" id="behavior-center-{{$note->id}}">
     <div class="point-table-container">
 
-        <table class="table table-sm table-bordered mb-0 bg-white mb-2 point-table">
+        <table class="table table-sm table-bordered mb-0 bg-white mb-2 point-table read">
 
             @foreach($points as $p)
                 <?php $point = $p['point']; ?>
@@ -42,45 +42,153 @@ $points = [
                         </div>
                     </td>
                     <td class="w-40">
-                        <div class="d-flex align-items-start position-relative">
-                            <div class="flex-grow-1">
-                                @if($point)
-                                    <?php
-                                    include resource_path('views/app/patient/segment-templates/_child_review/behavior/' . $p['category'] . '/last-review.php');
-                                    ?>
-                                @else
-                                    -
-                                @endif
-                            </div>
-                            <div class="d-inline-flex flex-column ml-1">
+                        <div if-read-mode>
+                            @if($point)
                                 <?php
-                                $segment = $note->getSegmentByInternalName('intake_behavior');
-                                if($segment) {
-                                    include resource_path('views/app/patient/segment-templates/_child_review/behavior/' . $p['category'] . '/edit-review.php');
+                                include resource_path('views/app/patient/segment-templates/_child_review/behavior/' . $p['category'] . '/last-review.php');
+                                ?>
+                            @else
+                                -
+                            @endif
+                        </div>
+                        <div if-edit-mode>
+                            <?php
+                            $segment = $note->getSegmentByInternalName('intake_behavior');
+                            if($segment) {
+                                $currentValue = '';
+                                $previousValue = '';
+                                $previousChildReview = null;
+                                if (@$point) {
+                                    if ($point->lastChildReview && $point->last_child_review_point_scoped_note_id === $note->id) {
+                                        $currentValue = json_decode($point->lastChildReview->data);
+                                        $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) {
+                                            $previousValue = json_decode($previousChildReview->data);
+                                        }
+                                    }
+                                    else {
+                                        $previousChildReview = \App\Models\Point::where('parent_point_id', $point->id)
+                                            ->where('category', 'REVIEW')
+                                            ->orderBy('id', 'DESC')
+                                            ->first();
+                                        if($previousChildReview && $previousChildReview->data) {
+                                            $previousValue = json_decode($previousChildReview->data);
+                                        }
+                                    }
                                 }
                                 ?>
-                            </div>
+                                <div visit-moe relative class="d-block">
+                                    <form show url="/api/visitPoint/<?= $point ? 'upsertChildReview' : 'addTopLevel' ?>"
+                                          class="mcp-theme-1 frm-review-plan-lifestyle frm-review-plan-behavior" right>
+
+                                        @if($point)
+                                            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+                                            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+                                            <input type="hidden" name="data">
+                                        @else
+                                            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
+                                            <input type="hidden" name="category" value="<?= $p['category'] ?>">
+                                            <input type="hidden" name="additionReasonCategory" value="ON_INTAKE">
+                                            <input type="hidden" name="childReviewData">
+                                        @endif
+
+                                        @if($previousValue)
+                                            <div class="mb-2">
+                                                <div class="d-flex align-items-baseline mb-1">
+                                                    <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?>)</span>
+                                                </div>
+                                                <div class="p-2 bg-light border inline-html-container">
+                                                    <?php $review = $previousValue; ?>
+                                                    <?php include(resource_path('views/app/patient/segment-templates/_child_review/behavior/' . $p['category'] . '/view-review.php')); ?>
+                                                </div>
+                                            </div>
+                                        @endif
+                                        <?php include resource_path('views/app/patient/segment-templates/_child_review/behavior/' . $p['category'] . '/edit-review.php'); ?>
+                                    </form>
+                                </div>
+                                @if(!empty($currentValue))
+                                    <?php include(resource_path('views/app/patient/segment-templates/_child_review/delete-review.php')); ?>
+                                @endif
+                                <?php
+                            }
+                            ?>
                         </div>
                     </td>
                     <td class="w-40">
-                        <div class="d-flex align-items-start position-relative">
-                            <div class="flex-grow-1">
-                                @if($point)
-                                    <?php
-                                    include resource_path('views/app/patient/segment-templates/_child_plan/behavior/' . $p['category'] . '/last-plan.php');
-                                    ?>
-                                @else
-                                    -
-                                @endif
-                            </div>
-                            <div class="d-inline-flex flex-column ml-1">
-                                <?php
-                                $segment = $note->getSegmentByInternalName('plan_behavior');
-                                if($segment) {
-                                    include resource_path('views/app/patient/segment-templates/_child_plan/behavior/' . $p['category'] . '/edit-plan.php');
+                        <div if-read-mode>
+                            @if($point)
+                                <?php include resource_path('views/app/patient/segment-templates/_child_plan/behavior/' . $p['category'] . '/last-plan.php'); ?>
+                            @else
+                                -
+                            @endif
+                        </div>
+                        <div if-edit-mode>
+                            <?php
+                            $segment = $note->getSegmentByInternalName('plan_behavior');
+                            if($segment) {
+                                $currentValue = '';
+                                $previousValue = '';
+                                $previousChildPlan = null;
+                                if (@$point) {
+                                    if ($point->lastChildPlan && $point->last_child_plan_point_scoped_note_id === $note->id) {
+                                        $currentValue = json_decode($point->lastChildPlan->data);
+                                        $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) {
+                                            $previousValue = json_decode($previousChildPlan->data);
+                                        }
+                                    }
+                                    else {
+                                        $previousChildPlan = \App\Models\Point::where('parent_point_id', $point->id)
+                                            ->where('category', 'PLAN')
+                                            ->orderBy('id', 'DESC')
+                                            ->first();
+                                        if($previousChildPlan && $previousChildPlan->data) {
+                                            $previousValue = json_decode($previousChildPlan->data);
+                                        }
+                                    }
                                 }
                                 ?>
-                            </div>
+                                <div visit-moe relative class="d-block">
+                                    <form show url="/api/visitPoint/<?= $point ? 'upsertChildPlan' : 'addTopLevel' ?>"
+                                          class="mcp-theme-1 frm-review-plan-lifestyle frm-review-plan-behavior" right>
+                                        @if($point)
+                                            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+                                            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+                                            <input type="hidden" name="data">
+                                        @else
+                                            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
+                                            <input type="hidden" name="category" value="<?= $p['category'] ?>">
+                                            <input type="hidden" name="additionReasonCategory" value="DURING_VISIT">
+                                            <input type="hidden" name="childPlanData">
+                                        @endif
+                                        @if($previousValue)
+                                            <div class="mb-2">
+                                                <div class="d-flex align-items-baseline mb-1">
+                                                    <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?>)</span>
+                                                </div>
+                                                <div class="p-2 bg-light border inline-html-container">
+                                                    <?php $plan = $previousValue; ?>
+                                                    <?php include(resource_path('views/app/patient/segment-templates/_child_plan/behavior/' . $p['category'] . '/view-plan.php')); ?>
+                                                </div>
+                                            </div>
+                                        @endif
+                                        <?php include resource_path('views/app/patient/segment-templates/_child_plan/behavior/' . $p['category'] . '/edit-plan.php'); ?>
+                                    </form>
+                                </div>
+                                @if(!empty($currentValue))
+                                    <?php include(resource_path('views/app/patient/segment-templates/_child_plan/delete-plan.php')); ?>
+                                @endif
+                                <?php
+                            }
+                            ?>
                         </div>
                     </td>
                 </tr>
@@ -93,10 +201,83 @@ $points = [
 <script>
     (function() {
         function init() {
+
+            let mode = 'read';
+
             let parentSegment = $('#behavior-center-{{$note->id}}');
             @include('app.patient.wizard-partials.common-script', ['label' => 'behavior', 'segment_part' => 'behavior'])
             initSegmentMoes(parentSegment);
             __initRTEs(parentSegment.find('[note-rte]:not(.ql-container)'));
+
+            // custom buttons on title bar
+            $('.button-container').remove();
+            let buttonContainer = $('<div/>').addClass('button-container ml-4 mr-auto');
+            let titleElem = $('#behavior-center-{{$note->id}}').closest('.stag-popup').find('.stag-popup-title>span');
+            titleElem.next().removeClass('ml-auto');
+            titleElem.parent().addClass('align-items-center');
+
+            // add button for "Edit Mode"
+            $('.btn-toggle-edit-mode').remove();
+            let button = $('<a href="#" native target="_blank" data-mode="read" ' +
+                'class="btn-toggle-edit-mode btn btn-sm mr-2 btn-info text-white font-weight-bold shadow-none">Switch to Edit Mode</a>')
+                .appendTo(buttonContainer);
+
+            $('<div class="d-inline-flex align-self-stretch align-items-center">' +
+                '<span class="autosave-indicator saving text-sm text-secondary">Saving changes &hellip;</span>' +
+                '<span class="autosave-indicator saved text-sm text-secondary">' +
+                '<i class="fa fa-check"></i>' +
+                ' Saved' +
+                '</span>' +
+                '</div>').appendTo(buttonContainer);
+
+            buttonContainer.insertAfter(titleElem);
+
+            button
+                .off('click.toggle-edit')
+                .on('click.toggle-edit', function () {
+                    if (mode === 'read') {
+                        mode = 'edit';
+                        $(this).text('Back to Read Mode');
+                        $('#behavior-center-{{$note->id}} .point-table').removeClass('read').addClass('edit');
+                    } else {
+                        refreshDynamicStagPopup();
+                    }
+                    return false;
+                });
+
+            // HACK: create empty top-level points if not existing
+            let createCalls = [];
+
+            <?php
+            $missing = [];
+            foreach ($points as $p) {
+                if(!$p['point']) {
+                    $missing[] = $p['category'];
+                }
+            }
+            if(count($missing)) {
+            foreach ($missing as $m) {
+            ?>
+            createCalls.push($.ajax({
+                url: "/api/visitPoint/addTopLevel",
+                type: 'post',
+                data: {
+                    noteUid: '{{$note->uid}}',
+                    category: '{{$m}}',
+                    additionReasonCategory: 'ON_INTAKE'
+                },
+                success: function(jsonSaveResponse) {},
+                error: function(jqXHR, textStatus, errorThrown) {}
+            }));
+            <?php
+            }
+            ?>
+            Promise.all(createCalls).then(() => {
+                refreshDynamicStagPopup();
+            });
+            <?php
+            }
+            ?>
         }
         addMCInitializer('behavior-center-{{$note->id}}', init, '#behavior-center-{{$note->id}}');
     }).call(window);

+ 214 - 31
resources/views/app/patient/exercise-center.blade.php

@@ -22,7 +22,7 @@ $points = [
 <div class="mt-3 p-3 border-top-exercise-rx" id="exercise-center-{{$note->id}}">
     <div class="point-table-container">
 
-        <table class="table table-sm table-bordered mb-0 bg-white mb-2 point-table">
+        <table class="table table-sm table-bordered mb-0 bg-white mb-2 point-table read">
 
             @foreach($points as $p)
                 <?php $point = $p['point']; ?>
@@ -38,45 +38,154 @@ $points = [
                         </div>
                     </td>
                     <td class="w-40">
-                        <div class="d-flex align-items-start position-relative">
-                            <div class="flex-grow-1">
-                                @if($point)
-                                    <?php
-                                    include resource_path('views/app/patient/segment-templates/_child_review/exercise/' . $p['category'] . '/last-review.php');
-                                    ?>
-                                @else
-                                    -
-                                @endif
-                            </div>
-                            <div class="d-inline-flex flex-column ml-1">
+                        <div if-read-mode>
+                            @if($point)
                                 <?php
-                                $segment = $note->getSegmentByInternalName('intake_exercise');
-                                if($segment) {
-                                    include resource_path('views/app/patient/segment-templates/_child_review/exercise/' . $p['category'] . '/edit-review.php');
-                                }
+                                include resource_path('views/app/patient/segment-templates/_child_review/exercise/' . $p['category'] . '/last-review.php');
                                 ?>
+                            @else
+                                -
+                            @endif
+                        </div>
+                        <div if-edit-mode>
+                            <?php
+                            $segment = $note->getSegmentByInternalName('intake_exercise');
+                            if($segment) {
+                            $currentValue = '';
+                            $previousValue = '';
+                            $previousChildReview = null;
+                            if (@$point) {
+                                if ($point->lastChildReview && $point->last_child_review_point_scoped_note_id === $note->id) {
+                                    $currentValue = json_decode($point->lastChildReview->data);
+                                    $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) {
+                                        $previousValue = json_decode($previousChildReview->data);
+                                    }
+                                } else {
+                                    $previousChildReview = \App\Models\Point::where('parent_point_id', $point->id)
+                                        ->where('category', 'REVIEW')
+                                        ->orderBy('id', 'DESC')
+                                        ->first();
+                                    if ($previousChildReview && $previousChildReview->data) {
+                                        $previousValue = json_decode($previousChildReview->data);
+                                    }
+                                }
+                            }
+                            ?>
+                            <div visit-moe relative class="d-block">
+                                <form show url="/api/visitPoint/<?= $point ? 'upsertChildReview' : 'addTopLevel' ?>"
+                                      class="mcp-theme-1 frm-review-plan-lifestyle frm-review-plan-exercise" right>
+
+                                    @if($point)
+                                        <input type="hidden" name="uid" value="<?= $point->uid ?>">
+                                        <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+                                        <input type="hidden" name="data">
+                                    @else
+                                        <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
+                                        <input type="hidden" name="category" value="<?= $p['category'] ?>">
+                                        <input type="hidden" name="additionReasonCategory" value="ON_INTAKE">
+                                        <input type="hidden" name="childReviewData">
+                                    @endif
+
+                                    @if($previousValue)
+                                        <div class="mb-2">
+                                            <div class="d-flex align-items-baseline mb-1">
+                                                <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?>)</span>
+                                            </div>
+                                            <div class="p-2 bg-light border inline-html-container">
+                                                <?php $review = $previousValue; ?>
+                                                <?php include(resource_path('views/app/patient/segment-templates/_child_review/exercise/' . $p['category'] . '/view-review.php')); ?>
+                                            </div>
+                                        </div>
+                                    @endif
+                                    <?php include resource_path('views/app/patient/segment-templates/_child_review/exercise/' . $p['category'] . '/edit-review.php'); ?>
+                                </form>
                             </div>
+                            @if(!empty($currentValue))
+                                <?php include(resource_path('views/app/patient/segment-templates/_child_review/delete-review.php')); ?>
+                            @endif
+                            <?php
+                            }
+                            ?>
                         </div>
                     </td>
                     <td class="w-40">
-                        <div class="d-flex align-items-start position-relative">
-                            <div class="flex-grow-1">
-                                @if($point)
-                                    <?php
-                                    include resource_path('views/app/patient/segment-templates/_child_plan/exercise/' . $p['category'] . '/last-plan.php');
-                                    ?>
-                                @else
-                                    -
-                                @endif
-                            </div>
-                            <div class="d-inline-flex flex-column ml-1">
+                        <div if-read-mode>
+                            @if($point)
                                 <?php
-                                $segment = $note->getSegmentByInternalName('plan_exercise');
-                                if($segment) {
-                                    include resource_path('views/app/patient/segment-templates/_child_plan/exercise/' . $p['category'] . '/edit-plan.php');
-                                }
+                                include resource_path('views/app/patient/segment-templates/_child_plan/exercise/' . $p['category'] . '/last-plan.php');
                                 ?>
+                            @else
+                                -
+                            @endif
+                        </div>
+                        <div if-edit-mode>
+                            <?php
+                            $segment = $note->getSegmentByInternalName('plan_exercise');
+                            if($segment) {
+                            $currentValue = '';
+                            $previousValue = '';
+                            $previousChildPlan = null;
+                            if (@$point) {
+                                if ($point->lastChildPlan && $point->last_child_plan_point_scoped_note_id === $note->id) {
+                                    $currentValue = json_decode($point->lastChildPlan->data);
+                                    $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) {
+                                        $previousValue = json_decode($previousChildPlan->data);
+                                    }
+                                }
+                                else {
+                                    $previousChildPlan = \App\Models\Point::where('parent_point_id', $point->id)
+                                        ->where('category', 'PLAN')
+                                        ->orderBy('id', 'DESC')
+                                        ->first();
+                                    if($previousChildPlan && $previousChildPlan->data) {
+                                        $previousValue = json_decode($previousChildPlan->data);
+                                    }
+                                }
+                            }
+                            ?>
+                            <div visit-moe relative class="d-block">
+                                <form show url="/api/visitPoint/<?= $point ? 'upsertChildPlan' : 'addTopLevel' ?>"
+                                      class="mcp-theme-1 frm-review-plan-lifestyle frm-review-plan-exercise" right>
+                                    @if($point)
+                                        <input type="hidden" name="uid" value="<?= $point->uid ?>">
+                                        <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+                                        <input type="hidden" name="data">
+                                    @else
+                                        <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
+                                        <input type="hidden" name="category" value="<?= $p['category'] ?>">
+                                        <input type="hidden" name="additionReasonCategory" value="DURING_VISIT">
+                                        <input type="hidden" name="childPlanData">
+                                    @endif
+                                    @if($previousValue)
+                                        <div class="mb-2">
+                                            <div class="d-flex align-items-baseline mb-1">
+                                                <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?>)</span>
+                                            </div>
+                                            <div class="p-2 bg-light border inline-html-container">
+                                                <?php $plan = $previousValue; ?>
+                                                <?php include(resource_path('views/app/patient/segment-templates/_child_plan/exercise/' . $p['category'] . '/view-plan.php')); ?>
+                                            </div>
+                                        </div>
+                                    @endif
+                                    <?php include resource_path('views/app/patient/segment-templates/_child_plan/exercise/' . $p['category'] . '/edit-plan.php'); ?>
+                                </form>
                             </div>
+                            @if(!empty($currentValue))
+                                <?php include(resource_path('views/app/patient/segment-templates/_child_plan/delete-plan.php')); ?>
+                            @endif
+                            <?php
+                            }
+                            ?>
                         </div>
                     </td>
                 </tr>
@@ -95,10 +204,84 @@ $points = [
 <script>
     (function() {
         function init() {
+
+            let mode = 'read';
+
             let parentSegment = $('#exercise-center-{{$note->id}}');
             @include('app.patient.wizard-partials.common-script', ['label' => 'exercise', 'segment_part' => 'exercise'])
             initSegmentMoes(parentSegment);
             __initRTEs(parentSegment.find('[note-rte]:not(.ql-container)'));
+
+            // custom buttons on title bar
+            $('.button-container').remove();
+            let buttonContainer = $('<div/>').addClass('button-container ml-4 mr-auto');
+            let titleElem = $('#exercise-center-{{$note->id}}').closest('.stag-popup').find('.stag-popup-title>span');
+            titleElem.next().removeClass('ml-auto');
+            titleElem.parent().addClass('align-items-center');
+
+            // add button for "Edit Mode"
+            $('.btn-toggle-edit-mode').remove();
+            let button = $('<a href="#" native target="_blank" data-mode="read" ' +
+                'class="btn-toggle-edit-mode btn btn-sm mr-2 btn-info text-white font-weight-bold shadow-none">Switch to Edit Mode</a>')
+                .appendTo(buttonContainer);
+
+            $('<div class="d-inline-flex align-self-stretch align-items-center">' +
+                '<span class="autosave-indicator saving text-sm text-secondary">Saving changes &hellip;</span>' +
+                '<span class="autosave-indicator saved text-sm text-secondary">' +
+                '<i class="fa fa-check"></i>' +
+                ' Saved' +
+                '</span>' +
+                '</div>').appendTo(buttonContainer);
+
+            buttonContainer.insertAfter(titleElem);
+
+            button
+                .off('click.toggle-edit')
+                .on('click.toggle-edit', function () {
+                    if (mode === 'read') {
+                        mode = 'edit';
+                        $(this).text('Back to Read Mode');
+                        $('#exercise-center-{{$note->id}} .point-table').removeClass('read').addClass('edit');
+                    } else {
+                        refreshDynamicStagPopup();
+                    }
+                    return false;
+                });
+
+            // HACK: create empty top-level points if not existing
+            let createCalls = [];
+
+            <?php
+            $missing = [];
+            foreach ($points as $p) {
+                if(!$p['point']) {
+                    $missing[] = $p['category'];
+                }
+            }
+            if(count($missing)) {
+            foreach ($missing as $m) {
+            ?>
+            createCalls.push($.ajax({
+                url: "/api/visitPoint/addTopLevel",
+                type: 'post',
+                data: {
+                    noteUid: '{{$note->uid}}',
+                    category: '{{$m}}',
+                    additionReasonCategory: 'ON_INTAKE'
+                },
+                success: function(jsonSaveResponse) {},
+                error: function(jqXHR, textStatus, errorThrown) {}
+            }));
+            <?php
+            }
+            ?>
+            Promise.all(createCalls).then(() => {
+                refreshDynamicStagPopup();
+            });
+            <?php
+            }
+            ?>
+
         }
         addMCInitializer('exercise-center-{{$note->id}}', init, '#exercise-center-{{$note->id}}');
     }).call(window);

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

@@ -327,8 +327,8 @@
                 $(_trigger).closest('.visit-segment').find('.autosave-indicator').removeClass('show');
                 $(_trigger).closest('.visit-segment').find('.autosave-indicator.saving').addClass('show');
                 saveVisitForm(_trigger, true, false, () => {
-                    $('.autosave-indicator').removeClass('show');
-                    $('.autosave-indicator.saved').addClass('show');
+                    $(_trigger).closest('.visit-segment').find('.autosave-indicator').removeClass('show');
+                    $(_trigger).closest('.visit-segment').find('.autosave-indicator.saved').addClass('show');
                     /*window.setTimeout(() => {
                         $('.autosave-indicator').removeClass('show');
                     }, 1000);*/

+ 103 - 33
resources/views/app/patient/nutrition-center.blade.php

@@ -32,7 +32,7 @@ $points = [
 <div class="mt-3 p-3 border-top-nutrition-rx" id="nutrition-center-{{$note->id}}">
     <div class="point-table-container">
 
-        <table class="table table-sm table-bordered mb-0 bg-white mb-2 point-table">
+        <table class="table table-sm table-bordered mb-0 bg-white mb-2 point-table read">
 		<tr class="point-row">
 			<td></td>
 			<td>Subjective</td>
@@ -69,45 +69,41 @@ $points = [
                         </div>
                     </td>
                     <td class="w-40">
-                        <div class="d-flex align-items-start position-relative">
-                            <div class="flex-grow-1">
-                                @if($point)
-                                    <?php
-                                    include resource_path('views/app/patient/segment-templates/_child_review/nutrition/' . $p['category'] . '/last-review.php');
-                                    ?>
-                                @else
-                                    -
-                                @endif
-                            </div>
-                            <div class="d-inline-flex flex-column ml-1">
+                        <div if-read-mode>
+                            @if($point)
                                 <?php
-                                $segment = $note->getSegmentByInternalName('intake_nutrition');
-                                if($segment) {
-                                    include resource_path('views/app/patient/segment-templates/_child_review/nutrition/' . $p['category'] . '/edit-review.php');
-                                }
+                                include resource_path('views/app/patient/segment-templates/_child_review/nutrition/' . $p['category'] . '/last-review.php');
                                 ?>
-                            </div>
+                            @else
+                                -
+                            @endif
+                        </div>
+                        <div if-edit-mode>
+                            <?php
+                            $segment = $note->getSegmentByInternalName('intake_nutrition');
+                            if($segment) {
+                                include resource_path('views/app/patient/segment-templates/_child_review/nutrition/' . $p['category'] . '/edit-review.php');
+                            }
+                            ?>
                         </div>
                     </td>
                     <td class="w-40">
-                        <div class="d-flex align-items-start position-relative">
-                            <div class="flex-grow-1">
-                                @if($point)
-                                    <?php
-                                    include resource_path('views/app/patient/segment-templates/_child_plan/nutrition/' . $p['category'] . '/last-plan.php');
-                                    ?>
-                                @else
-                                    -
-                                @endif
-                            </div>
-                            <div class="d-inline-flex flex-column ml-1">
+                        <div if-read-mode>
+                            @if($point)
                                 <?php
-                                $segment = $note->getSegmentByInternalName('plan_nutrition');
-                                if($segment) {
-                                    include resource_path('views/app/patient/segment-templates/_child_plan/nutrition/' . $p['category'] . '/edit-plan.php');
-                                }
+                                include resource_path('views/app/patient/segment-templates/_child_plan/nutrition/' . $p['category'] . '/last-plan.php');
                                 ?>
-                            </div>
+                            @else
+                                -
+                            @endif
+                        </div>
+                        <div if-edit-mode>
+                            <?php
+                            $segment = $note->getSegmentByInternalName('plan_nutrition');
+                            if($segment) {
+                                include resource_path('views/app/patient/segment-templates/_child_plan/nutrition/' . $p['category'] . '/edit-plan.php');
+                            }
+                            ?>
                         </div>
                     </td>
                 </tr>
@@ -120,10 +116,84 @@ $points = [
 <script>
     (function() {
         function init() {
+
+            let mode = 'read';
+
             let parentSegment = $('#nutrition-center-{{$note->id}}');
             @include('app.patient.wizard-partials.common-script', ['label' => 'nutrition', 'segment_part' => 'nutrition'])
             initSegmentMoes(parentSegment);
             __initRTEs(parentSegment.find('[note-rte]:not(.ql-container)'));
+
+            // custom buttons on title bar
+            $('.button-container').remove();
+            let buttonContainer = $('<div/>').addClass('button-container ml-4 mr-auto');
+            let titleElem = $('#nutrition-center-{{$note->id}}').closest('.stag-popup').find('.stag-popup-title>span');
+            titleElem.next().removeClass('ml-auto');
+            titleElem.parent().addClass('align-items-center');
+
+            // add button for "Edit Mode"
+            $('.btn-toggle-edit-mode').remove();
+            let button = $('<a href="#" native target="_blank" data-mode="read" ' +
+                'class="btn-toggle-edit-mode btn btn-sm mr-2 btn-info text-white font-weight-bold shadow-none">Switch to Edit Mode</a>')
+                .appendTo(buttonContainer);
+
+            $('<div class="d-inline-flex align-self-stretch align-items-center">' +
+                '<span class="autosave-indicator saving text-sm text-secondary">Saving changes &hellip;</span>' +
+                '<span class="autosave-indicator saved text-sm text-secondary">' +
+                    '<i class="fa fa-check"></i>' +
+                    ' Saved' +
+                '</span>' +
+            '</div>').appendTo(buttonContainer);
+
+            buttonContainer.insertAfter(titleElem);
+
+            button
+                .off('click.toggle-edit')
+                .on('click.toggle-edit', function () {
+                    if (mode === 'read') {
+                        mode = 'edit';
+                        $(this).text('Back to Read Mode');
+                        $('#nutrition-center-{{$note->id}} .point-table').removeClass('read').addClass('edit');
+                    } else {
+                        refreshDynamicStagPopup();
+                    }
+                    return false;
+                });
+
+            // HACK: create empty top-level points if not existing
+            let createCalls = [];
+
+            <?php
+            $missing = [];
+            foreach ($points as $p) {
+                if(!$p['point']) {
+                    $missing[] = $p['category'];
+                }
+            }
+            if(count($missing)) {
+                foreach ($missing as $m) {
+                    ?>
+                    createCalls.push($.ajax({
+                        url: "/api/visitPoint/addTopLevel",
+                        type: 'post',
+                        data: {
+                            noteUid: '{{$note->uid}}',
+                            category: '{{$m}}',
+                            additionReasonCategory: 'ON_INTAKE'
+                        },
+                        success: function(jsonSaveResponse) {},
+                        error: function(jqXHR, textStatus, errorThrown) {}
+                    }));
+                    <?php
+                }
+                ?>
+                Promise.all(createCalls).then(() => {
+                    refreshDynamicStagPopup();
+                });
+                <?php
+            }
+            ?>
+
         }
         addMCInitializer('nutrition-center-{{$note->id}}', init, '#nutrition-center-{{$note->id}}');
     }).call(window);

+ 6 - 106
resources/views/app/patient/segment-templates/_child_plan/behavior/CRAVINGS/edit-plan.php

@@ -1,108 +1,8 @@
-<?php
+<p class="mb-2"><b>Change Goal</b></p>
 
-/*
-Format:
-{
-    sugar: bool,
-    starches: bool,
-    friedFood: bool,
-    sweetDrinks: bool,
-    other: bool,
-    otherDetail: text
-    memo: text
-}
- */
-
-$currentValue = '';
-$previousValue = '';
-$previousChildPlan = null;
-if (@$point) {
-    if ($point->lastChildPlan && $point->last_child_plan_point_scoped_note_id === $note->id) {
-        $currentValue = json_decode($point->lastChildPlan->data);
-        $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) {
-            $previousValue = json_decode($previousChildPlan->data);
-        }
-    }
-    else {
-        $previousChildPlan = \App\Models\Point::where('parent_point_id', $point->id)
-            ->where('category', 'PLAN')
-            ->orderBy('id', 'DESC')
-            ->first();
-        if($previousChildPlan && $previousChildPlan->data) {
-            $previousValue = json_decode($previousChildPlan->data);
-        }
-    }
-}
-?>
-<div visit-moe fixed-center largest relative class="d-inline">
-    <a start show href="#" class="px-1 text-center d-block" title="<?= !empty($currentValue) ? 'Edit Plan' : 'Add Plan'?>">
-        <i class="fa <?= !empty($currentValue) ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
-    </a>
-    <form url="/api/visitPoint/<?= $point ? 'upsertChildPlan' : 'addTopLevel' ?>"
-          class="mcp-theme-1 frm-review-plan-lifestyle frm-review-plan-behavior" right>
-
-        <?php if($point): ?>
-            <input type="hidden" name="uid" value="<?= $point->uid ?>">
-            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
-        <?php else: ?>
-            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-            <input type="hidden" name="category" value="<?= $p['category'] ?>">
-            <input type="hidden" name="additionReasonCategory" value="DURING_VISIT">
-        <?php endif; ?>
-
-        <?php if ($point): ?>
-            <input type="hidden" name="data">
-        <?php else: ?>
-            <input type="hidden" name="childPlanData">
-        <?php endif; ?>
-
-        <?php if($previousValue): ?>
-            <div class="mb-2">
-                <div class="d-flex align-items-baseline mb-1">
-                    <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?>)</span>
-                </div>
-                <div class="p-2 bg-light border inline-html-container">
-                    <?php $plan = $previousValue; ?>
-                    <?php include(resource_path('views/app/patient/segment-templates/_child_plan/behavior/' . $p['category'] . '/view-plan.php')); ?>
-                </div>
-            </div>
-        <?php endif; ?>
-
-        <p class="mb-2"><b>Change Goal</b></p>
-
-        <div class="mb-2">
-            <div note-rte slim-rte
-                 class="form-group mb-2 border-left border-right rte-holder"
-                 data-container-name="<?= $point ? 'data' : 'childPlanData' ?>"
-                 data-field-name="memo"><?= @($currentValue->memo) ?></div>
-        </div>
-
-        <div>
-            <button type="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 class="mb-2">
+    <div note-rte slim-rte
+         class="form-group mb-2 border-left border-right rte-holder"
+         data-container-name="<?= $point ? 'data' : 'childPlanData' ?>"
+         data-field-name="memo"><?= @($currentValue->memo) ?></div>
 </div>
-<?php if(!empty($currentValue)): ?>
-    <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; ?>
-

+ 6 - 105
resources/views/app/patient/segment-templates/_child_plan/behavior/FOOD_TRIGGERS/edit-plan.php

@@ -1,107 +1,8 @@
-<?php
+<p class="mb-2"><b>Change Goal</b></p>
 
-/*
-Format:
-{
-    stress: bool,
-    work: bool,
-    social: bool,
-    reward: bool,
-    relaxation: bool,
-    memo: text
-}
- */
-
-$currentValue = '';
-$previousValue = '';
-$previousChildPlan = null;
-if (@$point) {
-    if ($point->lastChildPlan && $point->last_child_plan_point_scoped_note_id === $note->id) {
-        $currentValue = json_decode($point->lastChildPlan->data);
-        $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) {
-            $previousValue = json_decode($previousChildPlan->data);
-        }
-    }
-    else {
-        $previousChildPlan = \App\Models\Point::where('parent_point_id', $point->id)
-            ->where('category', 'PLAN')
-            ->orderBy('id', 'DESC')
-            ->first();
-        if($previousChildPlan && $previousChildPlan->data) {
-            $previousValue = json_decode($previousChildPlan->data);
-        }
-    }
-}
-?>
-<div visit-moe fixed-center largest relative class="d-inline">
-    <a start show href="#" class="px-1 text-center d-block" title="<?= !empty($currentValue) ? 'Edit Plan' : 'Add Plan'?>">
-        <i class="fa <?= !empty($currentValue) ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
-    </a>
-    <form url="/api/visitPoint/<?= $point ? 'upsertChildPlan' : 'addTopLevel' ?>"
-          class="mcp-theme-1 frm-review-plan-lifestyle frm-review-plan-behavior" right>
-
-        <?php if($point): ?>
-            <input type="hidden" name="uid" value="<?= $point->uid ?>">
-            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
-        <?php else: ?>
-            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-            <input type="hidden" name="category" value="<?= $p['category'] ?>">
-            <input type="hidden" name="additionReasonCategory" value="DURING_VISIT">
-        <?php endif; ?>
-
-        <?php if ($point): ?>
-            <input type="hidden" name="data">
-        <?php else: ?>
-            <input type="hidden" name="childPlanData">
-        <?php endif; ?>
-
-        <?php if($previousValue): ?>
-            <div class="mb-2">
-                <div class="d-flex align-items-baseline mb-1">
-                    <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?>)</span>
-                </div>
-                <div class="p-2 bg-light border inline-html-container">
-                    <?php $plan = $previousValue; ?>
-                    <?php include(resource_path('views/app/patient/segment-templates/_child_plan/behavior/' . $p['category'] . '/view-plan.php')); ?>
-                </div>
-            </div>
-        <?php endif; ?>
-
-        <p class="mb-2"><b>Change Goal</b></p>
-
-        <div class="mb-2">
-            <div note-rte slim-rte
-                 class="form-group mb-2 border-left border-right rte-holder"
-                 data-container-name="<?= $point ? 'data' : 'childPlanData' ?>"
-                 data-field-name="memo"><?= @($currentValue->memo) ?></div>
-        </div>
-
-        <div>
-            <button type="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 class="mb-2">
+    <div note-rte slim-rte
+         class="form-group mb-2 border-left border-right rte-holder"
+         data-container-name="<?= $point ? 'data' : 'childPlanData' ?>"
+         data-field-name="memo"><?= @($currentValue->memo) ?></div>
 </div>
-<?php if(!empty($currentValue)): ?>
-    <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; ?>
-

+ 62 - 169
resources/views/app/patient/segment-templates/_child_plan/behavior/SELF_MONITORING/edit-plan.php

@@ -1,180 +1,73 @@
-<?php
+<p class="mb-2"><b>Self Monitoring</b></p>
 
-/*
-Format:
-{
-    weighInsPerWeek: number,
-    tracking: {
-        calorieIntake: bool,
-        dailyCarbIntake: bool,
-        portionSize: bool,
-        eatingSpeed: bool,
-        other: bool
-        otherDetail: text
-    },
-    foodMonitoring: {
-        phoneTracker: bool,
-        dailyFoodLog: bool
-    }
-    memo: text
-}
- */
-
-$currentValue = '';
-$previousValue = '';
-$previousChildPlan = null;
-if (@$point) {
-    if ($point->lastChildPlan && $point->last_child_plan_point_scoped_note_id === $note->id) {
-        $currentValue = json_decode($point->lastChildPlan->data);
-        $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) {
-            $previousValue = json_decode($previousChildPlan->data);
-        }
-    }
-    else {
-        $previousChildPlan = \App\Models\Point::where('parent_point_id', $point->id)
-            ->where('category', 'PLAN')
-            ->orderBy('id', 'DESC')
-            ->first();
-        if($previousChildPlan && $previousChildPlan->data) {
-            $previousValue = json_decode($previousChildPlan->data);
-        }
-    }
-}
-?>
-<div visit-moe fixed-center largest relative class="d-inline">
-    <a start show href="#" class="px-1 text-center d-block" title="<?= !empty($currentValue) ? 'Edit Plan' : 'Add Plan'?>">
-        <i class="fa <?= !empty($currentValue) ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
-    </a>
-    <form url="/api/visitPoint/<?= $point ? 'upsertChildPlan' : 'addTopLevel' ?>"
-          class="mcp-theme-1 frm-review-plan-lifestyle frm-review-plan-behavior" right>
-
-        <?php if($point): ?>
-            <input type="hidden" name="uid" value="<?= $point->uid ?>">
-            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
-        <?php else: ?>
-            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-            <input type="hidden" name="category" value="<?= $p['category'] ?>">
-            <input type="hidden" name="additionReasonCategory" value="DURING_VISIT">
-        <?php endif; ?>
-
-        <?php if ($point): ?>
-            <input type="hidden" name="data">
-        <?php else: ?>
-            <input type="hidden" name="childPlanData">
-        <?php endif; ?>
-
-        <?php if($previousValue): ?>
-            <div class="mb-2">
-                <div class="d-flex align-items-baseline mb-1">
-                    <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?>)</span>
-                </div>
-                <div class="p-2 bg-light border inline-html-container">
-                    <?php $plan = $previousValue; ?>
-                    <?php include(resource_path('views/app/patient/segment-templates/_child_plan/behavior/' . $p['category'] . '/view-plan.php')); ?>
-                </div>
-            </div>
-        <?php endif; ?>
-
-        <p class="mb-2"><b>Self Monitoring</b></p>
+<div class="mb-2 d-flex align-items-center">
+    <label class="my-0 mr-2">Number of weigh-ins per week:</label>
+    <input type="text" data-name="weighInsPerWeek" class="form-control form-control-sm min-width-unset width-100px" value="<?= @($currentValue->weighInsPerWeek) ?>">
+</div>
 
-        <div class="mb-2 d-flex align-items-center">
-            <label class="my-0 mr-2">Number of weigh-ins per week:</label>
-            <input type="text" data-name="weighInsPerWeek" class="form-control form-control-sm min-width-unset width-100px" value="<?= @($currentValue->weighInsPerWeek) ?>">
+<div class="mb-2">
+    <label class="mb-2 font-weight-bold text-secondary">Track the following:</label>
+    <div class="row mb-1">
+        <div class="col-4">
+            <label class="d-flex align-items-center mb-1">
+                <input type="checkbox" data-name="tracking->calorieIntake" <?= @($currentValue->tracking->calorieIntake) ? 'checked' : ''?>>
+                <span class="ml-2">Calorie Intake</span>
+            </label>
         </div>
-
-        <div class="mb-2">
-            <label class="mb-2 font-weight-bold text-secondary">Track the following:</label>
-            <div class="row mb-1">
-                <div class="col-4">
-                    <label class="d-flex align-items-center mb-1">
-                        <input type="checkbox" data-name="tracking->calorieIntake" <?= @($currentValue->tracking->calorieIntake) ? 'checked' : ''?>>
-                        <span class="ml-2">Calorie Intake</span>
-                    </label>
-                </div>
-                <div class="col-4">
-                    <label class="d-flex align-items-center mb-1">
-                        <input type="checkbox" data-name="tracking->dailyCarbIntake" <?= @($currentValue->tracking->dailyCarbIntake) ? 'checked' : ''?>>
-                        <span class="ml-2">Daily Carb Intake</span>
-                    </label>
-                </div>
-                <div class="col-4">
-                    <label class="d-flex align-items-center mb-1">
-                        <input type="checkbox" data-name="tracking->portionSize" <?= @($currentValue->tracking->portionSize) ? 'checked' : ''?>>
-                        <span class="ml-2">Portion Size</span>
-                    </label>
-                </div>
-            </div>
-            <div class="row">
-                <div class="col-4">
-                    <label class="d-flex align-items-center mb-1">
-                        <input type="checkbox" data-name="tracking->eatingSpeed" <?= @($currentValue->tracking->eatingSpeed) ? 'checked' : ''?>>
-                        <span class="ml-2">Eating Speed</span>
-                    </label>
-                </div>
-                <div class="col-8">
-                    <label class="d-flex align-items-center mb-1">
-                        <input type="checkbox" data-name="tracking->other" <?= @($currentValue->tracking->other) ? 'checked' : ''?>>
-                        <span class="ml-2">Other</span>
-                        <input if-tracking-other type="text" class="form-control form-control-sm min-width-unset flex-grow-1 ml-2" data-name="tracking->otherDetail" value="<?= @($currentValue->tracking->otherDetail) ?>">
-                    </label>
-                </div>
-            </div>
+        <div class="col-4">
+            <label class="d-flex align-items-center mb-1">
+                <input type="checkbox" data-name="tracking->dailyCarbIntake" <?= @($currentValue->tracking->dailyCarbIntake) ? 'checked' : ''?>>
+                <span class="ml-2">Daily Carb Intake</span>
+            </label>
         </div>
-
-        <div class="mb-2">
-            <label class="mb-2 font-weight-bold text-secondary">Food monitoring:</label>
-            <div class="row">
-                <div class="col-4">
-                    <label class="d-flex align-items-center mb-1">
-                        <input type="checkbox" data-name="foodMonitoring->phoneTracker" <?= @($currentValue->foodMonitoring->phoneTracker) ? 'checked' : ''?>>
-                        <img src="/img/behavior-rx/phone-tracker.png" class="icon-nutrition-rx-md mx-2">
-                        <span class="">Phone Tracker</span>
-                    </label>
-                </div>
-                <div class="col-4">
-                    <label class="d-flex align-items-center mb-1">
-                        <input type="checkbox" data-name="foodMonitoring->dailyFoodLog" <?= @($currentValue->foodMonitoring->dailyFoodLog) ? 'checked' : ''?>>
-                        <img src="/img/behavior-rx/food-log.png" class="icon-nutrition-rx-md mx-2">
-                        <span class="">Daily Food Log</span>
-                    </label>
-                </div>
-            </div>
+        <div class="col-4">
+            <label class="d-flex align-items-center mb-1">
+                <input type="checkbox" data-name="tracking->portionSize" <?= @($currentValue->tracking->portionSize) ? 'checked' : ''?>>
+                <span class="ml-2">Portion Size</span>
+            </label>
         </div>
-
-        <div class="mb-2">
-            <label for="" class="mb-1">Memo</label>
-            <div note-rte slim-rte
-                 class="form-group mb-2 border-left border-right rte-holder"
-                 data-container-name="<?= $point ? 'data' : 'childPlanData' ?>"
-                 data-field-name="memo"><?= @($currentValue->memo) ?></div>
+    </div>
+    <div class="row">
+        <div class="col-4">
+            <label class="d-flex align-items-center mb-1">
+                <input type="checkbox" data-name="tracking->eatingSpeed" <?= @($currentValue->tracking->eatingSpeed) ? 'checked' : ''?>>
+                <span class="ml-2">Eating Speed</span>
+            </label>
         </div>
-
-        <div>
-            <button type="submit"  class="btn btn-sm btn-primary mr-2">Save</button>
-            <button cancel class="btn btn-sm btn-default border">Cancel</button>
+        <div class="col-8">
+            <label class="d-flex align-items-center mb-1">
+                <input type="checkbox" data-name="tracking->other" <?= @($currentValue->tracking->other) ? 'checked' : ''?>>
+                <span class="ml-2">Other</span>
+                <input if-tracking-other type="text" class="form-control form-control-sm min-width-unset flex-grow-1 ml-2" data-name="tracking->otherDetail" value="<?= @($currentValue->tracking->otherDetail) ?>">
+            </label>
         </div>
-    </form>
+    </div>
 </div>
-<?php if(!empty($currentValue)): ?>
-    <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 class="mb-2">
+    <label class="mb-2 font-weight-bold text-secondary">Food monitoring:</label>
+    <div class="row">
+        <div class="col-4">
+            <label class="d-flex align-items-center mb-1">
+                <input type="checkbox" data-name="foodMonitoring->phoneTracker" <?= @($currentValue->foodMonitoring->phoneTracker) ? 'checked' : ''?>>
+                <img src="/img/behavior-rx/phone-tracker.png" class="icon-nutrition-rx-md mx-2">
+                <span class="">Phone Tracker</span>
+            </label>
+        </div>
+        <div class="col-4">
+            <label class="d-flex align-items-center mb-1">
+                <input type="checkbox" data-name="foodMonitoring->dailyFoodLog" <?= @($currentValue->foodMonitoring->dailyFoodLog) ? 'checked' : ''?>>
+                <img src="/img/behavior-rx/food-log.png" class="icon-nutrition-rx-md mx-2">
+                <span class="">Daily Food Log</span>
+            </label>
+        </div>
     </div>
-<?php endif; ?>
+</div>
 
+<div class="mb-2">
+    <label for="" class="mb-1">Memo</label>
+    <div note-rte slim-rte
+         class="form-group mb-2 border-left border-right rte-holder"
+         data-container-name="<?= $point ? 'data' : 'childPlanData' ?>"
+         data-field-name="memo"><?= @($currentValue->memo) ?></div>
+</div>

+ 11 - 105
resources/views/app/patient/segment-templates/_child_plan/behavior/SLEEP_HABITS/edit-plan.php

@@ -1,109 +1,15 @@
-<?php
+<p class="mb-2"><b>Sleep Habits</b></p>
 
-/*
-Format:
-{
-    hoursOfSleep: number,
-    memo: text
-}
- */
-
-$currentValue = '';
-$previousValue = '';
-$previousChildPlan = null;
-if (@$point) {
-    if ($point->lastChildPlan && $point->last_child_plan_point_scoped_note_id === $note->id) {
-        $currentValue = json_decode($point->lastChildPlan->data);
-        $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) {
-            $previousValue = json_decode($previousChildPlan->data);
-        }
-    }
-    else {
-        $previousChildPlan = \App\Models\Point::where('parent_point_id', $point->id)
-            ->where('category', 'PLAN')
-            ->orderBy('id', 'DESC')
-            ->first();
-        if($previousChildPlan && $previousChildPlan->data) {
-            $previousValue = json_decode($previousChildPlan->data);
-        }
-    }
-}
-?>
-<div visit-moe fixed-center largest relative class="d-inline">
-    <a start show href="#" class="px-1 text-center d-block" title="<?= !empty($currentValue) ? 'Edit Plan' : 'Add Plan'?>">
-        <i class="fa <?= !empty($currentValue) ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
-    </a>
-    <form url="/api/visitPoint/<?= $point ? 'upsertChildPlan' : 'addTopLevel' ?>"
-          class="mcp-theme-1 frm-review-plan-lifestyle frm-review-plan-behavior" right>
-
-        <?php if($point): ?>
-            <input type="hidden" name="uid" value="<?= $point->uid ?>">
-            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
-        <?php else: ?>
-            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-            <input type="hidden" name="category" value="<?= $p['category'] ?>">
-            <input type="hidden" name="additionReasonCategory" value="DURING_VISIT">
-        <?php endif; ?>
-
-        <?php if ($point): ?>
-            <input type="hidden" name="data">
-        <?php else: ?>
-            <input type="hidden" name="childPlanData">
-        <?php endif; ?>
-
-        <?php if($previousValue): ?>
-            <div class="mb-2">
-                <div class="d-flex align-items-baseline mb-1">
-                    <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?>)</span>
-                </div>
-                <div class="p-2 bg-light border inline-html-container">
-                    <?php $plan = $previousValue; ?>
-                    <?php include(resource_path('views/app/patient/segment-templates/_child_plan/behavior/' . $p['category'] . '/view-plan.php')); ?>
-                </div>
-            </div>
-        <?php endif; ?>
-
-        <p class="mb-2"><b>Sleep Habits</b></p>
-
-        <div class="mb-2 d-flex align-items-center">
-            <label class="my-0 mr-2">Hours of sleep:</label>
-            <input type="text" data-name="hoursOfSleep" class="form-control form-control-sm min-width-unset width-100px" value="<?= @($currentValue->hoursOfSleep) ?>">
-        </div>
-
-        <div class="mb-2">
-            <label for="" class="mb-1">Memo</label>
-            <div note-rte slim-rte
-                 class="form-group mb-2 border-left border-right rte-holder"
-                 data-container-name="<?= $point ? 'data' : 'childPlanData' ?>"
-                 data-field-name="memo"><?= @($currentValue->memo) ?></div>
-        </div>
-
-        <div>
-            <button type="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 class="mb-2 d-flex align-items-center">
+    <label class="my-0 mr-2">Hours of sleep:</label>
+    <input type="text" data-name="hoursOfSleep" class="form-control form-control-sm min-width-unset width-100px" value="<?= @($currentValue->hoursOfSleep) ?>">
 </div>
-<?php if(!empty($currentValue)): ?>
-    <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; ?>
+<div class="mb-2">
+    <label for="" class="mb-1">Memo</label>
+    <div note-rte slim-rte
+         class="form-group mb-2 border-left border-right rte-holder"
+         data-container-name="<?= $point ? 'data' : 'childPlanData' ?>"
+         data-field-name="memo"><?= @($currentValue->memo) ?></div>
+</div>
 

+ 15 - 0
resources/views/app/patient/segment-templates/_child_plan/delete-plan.php

@@ -0,0 +1,15 @@
+<div visit-moe relative class="d-block">
+    <a start show href="#" class="px-1 text-left" title="Delete Plan">
+        Delete Plan
+    </a>
+    <form url="/api/visitPoint/destroyCurrentChildPlan" class="mcp-theme-1">
+        <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>

+ 1 - 1
resources/views/app/patient/segment-templates/_child_plan/edit-plan.php

@@ -44,7 +44,7 @@ else {
         <?php if($previousValue): ?>
         <div class="mb-2">
             <div class="d-flex align-items-baseline mb-1">
-                <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?>) (click to copy)</span>
+                <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?> (click to copy)</span>
             </div>
             <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
         </div>

+ 186 - 310
resources/views/app/patient/segment-templates/_child_plan/exercise/AEROBIC_ACTIVITY/edit-plan.php

@@ -1,315 +1,191 @@
-<?php
+<p class="mb-2"><b>Change Goal:</b></p>
 
-/*
-Format:
-{
-    active: true/false,
-    walk: {
-        active: true/false,
-        frequency: 1..7,
-        intensity: light/moderate/vigorous,
-        time: number,
-    },
-    jog: {
-        active: true/false,
-        frequency: 1..7,
-        intensity: light/moderate/vigorous,
-        time: number,
-    },
-    elliptical: {
-        active: true/false,
-        frequency: 1..7,
-        intensity: light/moderate/vigorous,
-        time: number,
-    },
-    swim: {
-        active: true/false,
-        frequency: 1..7,
-        intensity: light/moderate/vigorous,
-        time: number,
-    },
-    bike: {
-        active: true/false,
-        frequency: 1..7,
-        intensity: light/moderate/vigorous,
-        time: number,
-    },
-    memo: text
-}
- */
+<label class="mb-2 d-flex align-items-center">
+    <input type="checkbox" data-name="active" <?= @($currentValue->active) ? 'checked' : ''?>>
+    <span class="ml-2">Prescribe aerobic activities?</span>
+</label>
 
-$currentValue = '';
-$previousValue = '';
-$previousChildPlan = null;
-if (@$point) {
-    if ($point->lastChildPlan && $point->last_child_plan_point_scoped_note_id === $note->id) {
-        $currentValue = json_decode($point->lastChildPlan->data);
-        $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) {
-            $previousValue = json_decode($previousChildPlan->data);
-        }
-    }
-    else {
-        $previousChildPlan = \App\Models\Point::where('parent_point_id', $point->id)
-            ->where('category', 'PLAN')
-            ->orderBy('id', 'DESC')
-            ->first();
-        if($previousChildPlan && $previousChildPlan->data) {
-            $previousValue = json_decode($previousChildPlan->data);
-        }
-    }
-}
-?>
-<div visit-moe fixed-center largest relative class="d-inline">
-    <a start show href="#" class="px-1 text-center d-block" title="<?= !empty($currentValue) ? 'Edit Plan' : 'Add Plan'?>">
-        <i class="fa <?= !empty($currentValue) ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
-    </a>
-    <form url="/api/visitPoint/<?= $point ? 'upsertChildPlan' : 'addTopLevel' ?>"
-          class="mcp-theme-1 frm-review-plan-lifestyle frm-review-plan-exercise" right>
-
-        <?php if($point): ?>
-            <input type="hidden" name="uid" value="<?= $point->uid ?>">
-            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
-        <?php else: ?>
-            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-            <input type="hidden" name="category" value="<?= $p['category'] ?>">
-            <input type="hidden" name="additionReasonCategory" value="DURING_VISIT">
-        <?php endif; ?>
-
-        <?php if ($point): ?>
-            <input type="hidden" name="data">
-        <?php else: ?>
-            <input type="hidden" name="childPlanData">
-        <?php endif; ?>
-
-        <?php if($previousValue): ?>
-            <div class="mb-2">
-                <div class="d-flex align-items-baseline mb-1">
-                    <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?>)</span>
-                </div>
-                <div class="p-2 bg-light border inline-html-container">
-                    <?php $plan = $previousValue; ?>
-                    <?php include(resource_path('views/app/patient/segment-templates/_child_plan/exercise/' . $p['category'] . '/view-plan.php')); ?>
-                </div>
+<table if-active class="table table-sm table-bordered" style="table-layout: fixed">
+    <tbody>
+    <tr>
+        <td class="align-middle">Activity</td>
+        <td class="text-left">
+            <div class="d-flex align-items-center">
+                <input type="checkbox" class="d-none" data-name="walk->active" <?= @($currentValue->walk->active) ? 'checked' : '' ?>>
+                <img src="/img/exercise-rx/walk.png" class="icon-nutrition-rx-row mx-1 <?= @($currentValue->walk->active) ? '' : 'opacity-35' ?>">
+                <button data-type="walk" class="btn-toggle-activity flex-grow-1 shadow-none btn btn-sm <?= @($currentValue->walk->active) ? 'btn-info' : 'btn-default border' ?>">
+                    Walk
+                </button>
             </div>
-        <?php endif; ?>
-
-        <p class="mb-2"><b>Change Goal:</b></p>
-
-        <label class="mb-2 d-flex align-items-center">
-            <input type="checkbox" data-name="active" <?= @($currentValue->active) ? 'checked' : ''?>>
-            <span class="ml-2">Prescribe aerobic activities?</span>
-        </label>
-
-        <table if-active class="table table-sm table-bordered" style="table-layout: fixed">
-            <tbody>
-            <tr>
-                <td class="align-middle">Activity</td>
-                <td class="text-left">
-                    <div class="d-flex align-items-center">
-                        <input type="checkbox" class="d-none" data-name="walk->active" <?= @($currentValue->walk->active) ? 'checked' : '' ?>>
-                        <img src="/img/exercise-rx/walk.png" class="icon-nutrition-rx-row mx-1 <?= @($currentValue->walk->active) ? '' : 'opacity-35' ?>">
-                        <button data-type="walk" class="btn-toggle-activity flex-grow-1 shadow-none btn btn-sm <?= @($currentValue->walk->active) ? 'btn-info' : 'btn-default border' ?>">
-                            Walk
-                        </button>
-                    </div>
-                </td>
-                <td class="text-left">
-                    <div class="d-flex align-items-center">
-                        <input type="checkbox" class="d-none" data-name="jog->active" <?= @($currentValue->jog->active) ? 'checked' : '' ?>>
-                        <img src="/img/exercise-rx/jog.png" class="icon-nutrition-rx-row mx-1 <?= @($currentValue->jog->active) ? '' : 'opacity-35' ?>">
-                        <button data-type="jog" class="btn-toggle-activity flex-grow-1 shadow-none btn btn-sm <?= @($currentValue->jog->active) ? 'btn-info' : 'btn-default border' ?>">
-                            Jog
-                        </button>
-                    </div>
-                </td>
-                <td class="text-left">
-                    <div class="d-flex align-items-center">
-                        <input type="checkbox" class="d-none" data-name="elliptical->active" <?= @($currentValue->elliptical->active) ? 'checked' : '' ?>>
-                        <img src="/img/exercise-rx/elliptical.png" class="icon-nutrition-rx-row mx-1 <?= @($currentValue->elliptical->active) ? '' : 'opacity-35' ?>">
-                        <button data-type="elliptical" class="btn-toggle-activity flex-grow-1 shadow-none btn btn-sm <?= @($currentValue->elliptical->active) ? 'btn-info' : 'btn-default border' ?>">
-                            Elliptical
-                        </button>
-                    </div>
-                </td>
-                <td class="text-left">
-                    <div class="d-flex align-items-center">
-                        <input type="checkbox" class="d-none" data-name="swim->active" <?= @($currentValue->swim->active) ? 'checked' : '' ?>>
-                        <img src="/img/exercise-rx/swim.png" class="icon-nutrition-rx-row mx-1 <?= @($currentValue->swim->active) ? '' : 'opacity-35' ?>">
-                        <button data-type="swim" class="btn-toggle-activity flex-grow-1 shadow-none btn btn-sm <?= @($currentValue->swim->active) ? 'btn-info' : 'btn-default border' ?>">
-                            Swim
-                        </button>
-                    </div>
-                </td>
-                <td class="text-left">
-                    <div class="d-flex align-items-center">
-                        <input type="checkbox" class="d-none" data-name="bike->active" <?= @($currentValue->bike->active) ? 'checked' : '' ?>>
-                        <img src="/img/exercise-rx/bike.png" class="icon-nutrition-rx-row mx-1 <?= @($currentValue->bike->active) ? '' : 'opacity-35' ?>">
-                        <button data-type="bike" class="btn-toggle-activity flex-grow-1 shadow-none btn btn-sm <?= @($currentValue->bike->active) ? 'btn-info' : 'btn-default border' ?>">
-                            Bike
-                        </button>
-                    </div>
-                </td>
-            </tr>
-            <tr>
-                <td>Frequency (days/wk)</td>
-                <td>
-                    <select if-walk-active class="form-control form-control-sm min-width-unset px-0" data-name="walk->frequency">
-                        <option value="">-- select --</option>
-                        <option value="1" <?= @($currentValue->walk->frequency) == 1 ? 'selected' : ''?>>1 day</option>
-                        <option value="2" <?= @($currentValue->walk->frequency) == 2 ? 'selected' : ''?>>2 days</option>
-                        <option value="3" <?= @($currentValue->walk->frequency) == 3 ? 'selected' : ''?>>3 days</option>
-                        <option value="4" <?= @($currentValue->walk->frequency) == 4 ? 'selected' : ''?>>4 days</option>
-                        <option value="5" <?= @($currentValue->walk->frequency) == 5 ? 'selected' : ''?>>5 days</option>
-                        <option value="6" <?= @($currentValue->walk->frequency) == 6 ? 'selected' : ''?>>6 days</option>
-                        <option value="7" <?= @($currentValue->walk->frequency) == 7 ? 'selected' : ''?>>7 days</option>
-                    </select>
-                </td>
-                <td>
-                    <select if-jog-active class="form-control form-control-sm min-width-unset px-0" data-name="jog->frequency">
-                        <option value="">-- select --</option>
-                        <option value="1" <?= @($currentValue->jog->frequency) == 1 ? 'selected' : ''?>>1 day</option>
-                        <option value="2" <?= @($currentValue->jog->frequency) == 2 ? 'selected' : ''?>>2 days</option>
-                        <option value="3" <?= @($currentValue->jog->frequency) == 3 ? 'selected' : ''?>>3 days</option>
-                        <option value="4" <?= @($currentValue->jog->frequency) == 4 ? 'selected' : ''?>>4 days</option>
-                        <option value="5" <?= @($currentValue->jog->frequency) == 5 ? 'selected' : ''?>>5 days</option>
-                        <option value="6" <?= @($currentValue->jog->frequency) == 6 ? 'selected' : ''?>>6 days</option>
-                        <option value="7" <?= @($currentValue->jog->frequency) == 7 ? 'selected' : ''?>>7 days</option>
-                    </select>
-                </td>
-                <td>
-                    <select if-elliptical-active class="form-control form-control-sm min-width-unset px-0" data-name="elliptical->frequency">
-                        <option value="">-- select --</option>
-                        <option value="1" <?= @($currentValue->elliptical->frequency) == 1 ? 'selected' : ''?>>1 day</option>
-                        <option value="2" <?= @($currentValue->elliptical->frequency) == 2 ? 'selected' : ''?>>2 days</option>
-                        <option value="3" <?= @($currentValue->elliptical->frequency) == 3 ? 'selected' : ''?>>3 days</option>
-                        <option value="4" <?= @($currentValue->elliptical->frequency) == 4 ? 'selected' : ''?>>4 days</option>
-                        <option value="5" <?= @($currentValue->elliptical->frequency) == 5 ? 'selected' : ''?>>5 days</option>
-                        <option value="6" <?= @($currentValue->elliptical->frequency) == 6 ? 'selected' : ''?>>6 days</option>
-                        <option value="7" <?= @($currentValue->elliptical->frequency) == 7 ? 'selected' : ''?>>7 days</option>
-                    </select>
-                </td>
-                <td>
-                    <select if-swim-active class="form-control form-control-sm min-width-unset px-0" data-name="swim->frequency">
-                        <option value="">-- select --</option>
-                        <option value="1" <?= @($currentValue->swim->frequency) == 1 ? 'selected' : ''?>>1 day</option>
-                        <option value="2" <?= @($currentValue->swim->frequency) == 2 ? 'selected' : ''?>>2 days</option>
-                        <option value="3" <?= @($currentValue->swim->frequency) == 3 ? 'selected' : ''?>>3 days</option>
-                        <option value="4" <?= @($currentValue->swim->frequency) == 4 ? 'selected' : ''?>>4 days</option>
-                        <option value="5" <?= @($currentValue->swim->frequency) == 5 ? 'selected' : ''?>>5 days</option>
-                        <option value="6" <?= @($currentValue->swim->frequency) == 6 ? 'selected' : ''?>>6 days</option>
-                        <option value="7" <?= @($currentValue->swim->frequency) == 7 ? 'selected' : ''?>>7 days</option>
-                    </select>
-                </td>
-                <td>
-                    <select if-bike-active class="form-control form-control-sm min-width-unset px-0" data-name="bike->frequency">
-                        <option value="">-- select --</option>
-                        <option value="1" <?= @($currentValue->bike->frequency) == 1 ? 'selected' : ''?>>1 day</option>
-                        <option value="2" <?= @($currentValue->bike->frequency) == 2 ? 'selected' : ''?>>2 days</option>
-                        <option value="3" <?= @($currentValue->bike->frequency) == 3 ? 'selected' : ''?>>3 days</option>
-                        <option value="4" <?= @($currentValue->bike->frequency) == 4 ? 'selected' : ''?>>4 days</option>
-                        <option value="5" <?= @($currentValue->bike->frequency) == 5 ? 'selected' : ''?>>5 days</option>
-                        <option value="6" <?= @($currentValue->bike->frequency) == 6 ? 'selected' : ''?>>6 days</option>
-                        <option value="7" <?= @($currentValue->bike->frequency) == 7 ? 'selected' : ''?>>7 days</option>
-                    </select>
-                </td>
-            </tr>
-            <tr>
-                <td>Intensity</td>
-                <td>
-                    <select if-walk-active class="form-control form-control-sm min-width-unset px-0" data-name="walk->intensity">
-                        <option value="">-- select --</option>
-                        <option value="Light" <?= @($currentValue->walk->intensity) == 'Light' ? 'selected' : ''?>>Light</option>
-                        <option value="Moderate" <?= @($currentValue->walk->intensity) == 'Moderate' ? 'selected' : ''?>>Moderate</option>
-                        <option value="Vigorous" <?= @($currentValue->walk->intensity) == 'Vigorous' ? 'selected' : ''?>>Vigorous</option>
-                    </select>
-                </td>
-                <td>
-                    <select if-jog-active class="form-control form-control-sm min-width-unset px-0" data-name="jog->intensity">
-                        <option value="">-- select --</option>
-                        <option value="Light" <?= @($currentValue->jog->intensity) == 'Light' ? 'selected' : ''?>>Light</option>
-                        <option value="Moderate" <?= @($currentValue->jog->intensity) == 'Moderate' ? 'selected' : ''?>>Moderate</option>
-                        <option value="Vigorous" <?= @($currentValue->jog->intensity) == 'Vigorous' ? 'selected' : ''?>>Vigorous</option>
-                    </select>
-                </td>
-                <td>
-                    <select if-elliptical-active class="form-control form-control-sm min-width-unset px-0" data-name="elliptical->intensity">
-                        <option value="">-- select --</option>
-                        <option value="Light" <?= @($currentValue->elliptical->intensity) == 'Light' ? 'selected' : ''?>>Light</option>
-                        <option value="Moderate" <?= @($currentValue->elliptical->intensity) == 'Moderate' ? 'selected' : ''?>>Moderate</option>
-                        <option value="Vigorous" <?= @($currentValue->elliptical->intensity) == 'Vigorous' ? 'selected' : ''?>>Vigorous</option>
-                    </select>
-                </td>
-                <td>
-                    <select if-swim-active class="form-control form-control-sm min-width-unset px-0" data-name="swim->intensity">
-                        <option value="">-- select --</option>
-                        <option value="Light" <?= @($currentValue->swim->intensity) == 'Light' ? 'selected' : ''?>>Light</option>
-                        <option value="Moderate" <?= @($currentValue->swim->intensity) == 'Moderate' ? 'selected' : ''?>>Moderate</option>
-                        <option value="Vigorous" <?= @($currentValue->swim->intensity) == 'Vigorous' ? 'selected' : ''?>>Vigorous</option>
-                    </select>
-                </td>
-                <td>
-                    <select if-bike-active class="form-control form-control-sm min-width-unset px-0" data-name="bike->intensity">
-                        <option value="">-- select --</option>
-                        <option value="Light" <?= @($currentValue->bike->intensity) == 'Light' ? 'selected' : ''?>>Light</option>
-                        <option value="Moderate" <?= @($currentValue->bike->intensity) == 'Moderate' ? 'selected' : ''?>>Moderate</option>
-                        <option value="Vigorous" <?= @($currentValue->bike->intensity) == 'Vigorous' ? 'selected' : ''?>>Vigorous</option>
-                    </select>
-                </td>
-            </tr>
-            <tr>
-                <td>Time (mins/day)</td>
-                <td>
-                    <input if-walk-active class="form-control form-control-sm min-width-unset px-1" type="text" data-name="walk->time" value="<?= @($currentValue->walk->time) ?>">
-                </td>
-                <td>
-                    <input if-jog-active class="form-control form-control-sm min-width-unset px-1" type="text" data-name="jog->time" value="<?= @($currentValue->jog->time) ?>">
-                </td>
-                <td>
-                    <input if-elliptical-active class="form-control form-control-sm min-width-unset px-1" type="text" data-name="elliptical->time" value="<?= @($currentValue->elliptical->time) ?>">
-                </td>
-                <td>
-                    <input if-swim-active class="form-control form-control-sm min-width-unset px-1" type="text" data-name="swim->time" value="<?= @($currentValue->swim->time) ?>">
-                </td>
-                <td>
-                    <input if-bike-active class="form-control form-control-sm min-width-unset px-1" type="text" data-name="bike->time" value="<?= @($currentValue->bike->time) ?>">
-                </td>
-            </tr>
-            </tbody>
-        </table>
-
-        <div if-active class="mb-2">
-            <label for="" class="mb-1">Memo</label>
-            <div note-rte slim-rte
-                 class="form-group mb-2 border-left border-right rte-holder"
-                 data-container-name="<?= $point ? 'data' : 'childPlanData' ?>"
-                 data-field-name="memo"><?= @($currentValue->memo) ?></div>
-        </div>
-        <div>
-            <button type="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="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>
+        </td>
+        <td class="text-left">
+            <div class="d-flex align-items-center">
+                <input type="checkbox" class="d-none" data-name="jog->active" <?= @($currentValue->jog->active) ? 'checked' : '' ?>>
+                <img src="/img/exercise-rx/jog.png" class="icon-nutrition-rx-row mx-1 <?= @($currentValue->jog->active) ? '' : 'opacity-35' ?>">
+                <button data-type="jog" class="btn-toggle-activity flex-grow-1 shadow-none btn btn-sm <?= @($currentValue->jog->active) ? 'btn-info' : 'btn-default border' ?>">
+                    Jog
+                </button>
+            </div>
+        </td>
+        <td class="text-left">
+            <div class="d-flex align-items-center">
+                <input type="checkbox" class="d-none" data-name="elliptical->active" <?= @($currentValue->elliptical->active) ? 'checked' : '' ?>>
+                <img src="/img/exercise-rx/elliptical.png" class="icon-nutrition-rx-row mx-1 <?= @($currentValue->elliptical->active) ? '' : 'opacity-35' ?>">
+                <button data-type="elliptical" class="btn-toggle-activity flex-grow-1 shadow-none btn btn-sm <?= @($currentValue->elliptical->active) ? 'btn-info' : 'btn-default border' ?>">
+                    Elliptical
+                </button>
             </div>
-        </form>
-    </div>
-<?php endif; ?>
+        </td>
+        <td class="text-left">
+            <div class="d-flex align-items-center">
+                <input type="checkbox" class="d-none" data-name="swim->active" <?= @($currentValue->swim->active) ? 'checked' : '' ?>>
+                <img src="/img/exercise-rx/swim.png" class="icon-nutrition-rx-row mx-1 <?= @($currentValue->swim->active) ? '' : 'opacity-35' ?>">
+                <button data-type="swim" class="btn-toggle-activity flex-grow-1 shadow-none btn btn-sm <?= @($currentValue->swim->active) ? 'btn-info' : 'btn-default border' ?>">
+                    Swim
+                </button>
+            </div>
+        </td>
+        <td class="text-left">
+            <div class="d-flex align-items-center">
+                <input type="checkbox" class="d-none" data-name="bike->active" <?= @($currentValue->bike->active) ? 'checked' : '' ?>>
+                <img src="/img/exercise-rx/bike.png" class="icon-nutrition-rx-row mx-1 <?= @($currentValue->bike->active) ? '' : 'opacity-35' ?>">
+                <button data-type="bike" class="btn-toggle-activity flex-grow-1 shadow-none btn btn-sm <?= @($currentValue->bike->active) ? 'btn-info' : 'btn-default border' ?>">
+                    Bike
+                </button>
+            </div>
+        </td>
+    </tr>
+    <tr>
+        <td>Frequency (days/wk)</td>
+        <td>
+            <select if-walk-active class="form-control form-control-sm min-width-unset px-0" data-name="walk->frequency">
+                <option value="">-- select --</option>
+                <option value="1" <?= @($currentValue->walk->frequency) == 1 ? 'selected' : ''?>>1 day</option>
+                <option value="2" <?= @($currentValue->walk->frequency) == 2 ? 'selected' : ''?>>2 days</option>
+                <option value="3" <?= @($currentValue->walk->frequency) == 3 ? 'selected' : ''?>>3 days</option>
+                <option value="4" <?= @($currentValue->walk->frequency) == 4 ? 'selected' : ''?>>4 days</option>
+                <option value="5" <?= @($currentValue->walk->frequency) == 5 ? 'selected' : ''?>>5 days</option>
+                <option value="6" <?= @($currentValue->walk->frequency) == 6 ? 'selected' : ''?>>6 days</option>
+                <option value="7" <?= @($currentValue->walk->frequency) == 7 ? 'selected' : ''?>>7 days</option>
+            </select>
+        </td>
+        <td>
+            <select if-jog-active class="form-control form-control-sm min-width-unset px-0" data-name="jog->frequency">
+                <option value="">-- select --</option>
+                <option value="1" <?= @($currentValue->jog->frequency) == 1 ? 'selected' : ''?>>1 day</option>
+                <option value="2" <?= @($currentValue->jog->frequency) == 2 ? 'selected' : ''?>>2 days</option>
+                <option value="3" <?= @($currentValue->jog->frequency) == 3 ? 'selected' : ''?>>3 days</option>
+                <option value="4" <?= @($currentValue->jog->frequency) == 4 ? 'selected' : ''?>>4 days</option>
+                <option value="5" <?= @($currentValue->jog->frequency) == 5 ? 'selected' : ''?>>5 days</option>
+                <option value="6" <?= @($currentValue->jog->frequency) == 6 ? 'selected' : ''?>>6 days</option>
+                <option value="7" <?= @($currentValue->jog->frequency) == 7 ? 'selected' : ''?>>7 days</option>
+            </select>
+        </td>
+        <td>
+            <select if-elliptical-active class="form-control form-control-sm min-width-unset px-0" data-name="elliptical->frequency">
+                <option value="">-- select --</option>
+                <option value="1" <?= @($currentValue->elliptical->frequency) == 1 ? 'selected' : ''?>>1 day</option>
+                <option value="2" <?= @($currentValue->elliptical->frequency) == 2 ? 'selected' : ''?>>2 days</option>
+                <option value="3" <?= @($currentValue->elliptical->frequency) == 3 ? 'selected' : ''?>>3 days</option>
+                <option value="4" <?= @($currentValue->elliptical->frequency) == 4 ? 'selected' : ''?>>4 days</option>
+                <option value="5" <?= @($currentValue->elliptical->frequency) == 5 ? 'selected' : ''?>>5 days</option>
+                <option value="6" <?= @($currentValue->elliptical->frequency) == 6 ? 'selected' : ''?>>6 days</option>
+                <option value="7" <?= @($currentValue->elliptical->frequency) == 7 ? 'selected' : ''?>>7 days</option>
+            </select>
+        </td>
+        <td>
+            <select if-swim-active class="form-control form-control-sm min-width-unset px-0" data-name="swim->frequency">
+                <option value="">-- select --</option>
+                <option value="1" <?= @($currentValue->swim->frequency) == 1 ? 'selected' : ''?>>1 day</option>
+                <option value="2" <?= @($currentValue->swim->frequency) == 2 ? 'selected' : ''?>>2 days</option>
+                <option value="3" <?= @($currentValue->swim->frequency) == 3 ? 'selected' : ''?>>3 days</option>
+                <option value="4" <?= @($currentValue->swim->frequency) == 4 ? 'selected' : ''?>>4 days</option>
+                <option value="5" <?= @($currentValue->swim->frequency) == 5 ? 'selected' : ''?>>5 days</option>
+                <option value="6" <?= @($currentValue->swim->frequency) == 6 ? 'selected' : ''?>>6 days</option>
+                <option value="7" <?= @($currentValue->swim->frequency) == 7 ? 'selected' : ''?>>7 days</option>
+            </select>
+        </td>
+        <td>
+            <select if-bike-active class="form-control form-control-sm min-width-unset px-0" data-name="bike->frequency">
+                <option value="">-- select --</option>
+                <option value="1" <?= @($currentValue->bike->frequency) == 1 ? 'selected' : ''?>>1 day</option>
+                <option value="2" <?= @($currentValue->bike->frequency) == 2 ? 'selected' : ''?>>2 days</option>
+                <option value="3" <?= @($currentValue->bike->frequency) == 3 ? 'selected' : ''?>>3 days</option>
+                <option value="4" <?= @($currentValue->bike->frequency) == 4 ? 'selected' : ''?>>4 days</option>
+                <option value="5" <?= @($currentValue->bike->frequency) == 5 ? 'selected' : ''?>>5 days</option>
+                <option value="6" <?= @($currentValue->bike->frequency) == 6 ? 'selected' : ''?>>6 days</option>
+                <option value="7" <?= @($currentValue->bike->frequency) == 7 ? 'selected' : ''?>>7 days</option>
+            </select>
+        </td>
+    </tr>
+    <tr>
+        <td>Intensity</td>
+        <td>
+            <select if-walk-active class="form-control form-control-sm min-width-unset px-0" data-name="walk->intensity">
+                <option value="">-- select --</option>
+                <option value="Light" <?= @($currentValue->walk->intensity) == 'Light' ? 'selected' : ''?>>Light</option>
+                <option value="Moderate" <?= @($currentValue->walk->intensity) == 'Moderate' ? 'selected' : ''?>>Moderate</option>
+                <option value="Vigorous" <?= @($currentValue->walk->intensity) == 'Vigorous' ? 'selected' : ''?>>Vigorous</option>
+            </select>
+        </td>
+        <td>
+            <select if-jog-active class="form-control form-control-sm min-width-unset px-0" data-name="jog->intensity">
+                <option value="">-- select --</option>
+                <option value="Light" <?= @($currentValue->jog->intensity) == 'Light' ? 'selected' : ''?>>Light</option>
+                <option value="Moderate" <?= @($currentValue->jog->intensity) == 'Moderate' ? 'selected' : ''?>>Moderate</option>
+                <option value="Vigorous" <?= @($currentValue->jog->intensity) == 'Vigorous' ? 'selected' : ''?>>Vigorous</option>
+            </select>
+        </td>
+        <td>
+            <select if-elliptical-active class="form-control form-control-sm min-width-unset px-0" data-name="elliptical->intensity">
+                <option value="">-- select --</option>
+                <option value="Light" <?= @($currentValue->elliptical->intensity) == 'Light' ? 'selected' : ''?>>Light</option>
+                <option value="Moderate" <?= @($currentValue->elliptical->intensity) == 'Moderate' ? 'selected' : ''?>>Moderate</option>
+                <option value="Vigorous" <?= @($currentValue->elliptical->intensity) == 'Vigorous' ? 'selected' : ''?>>Vigorous</option>
+            </select>
+        </td>
+        <td>
+            <select if-swim-active class="form-control form-control-sm min-width-unset px-0" data-name="swim->intensity">
+                <option value="">-- select --</option>
+                <option value="Light" <?= @($currentValue->swim->intensity) == 'Light' ? 'selected' : ''?>>Light</option>
+                <option value="Moderate" <?= @($currentValue->swim->intensity) == 'Moderate' ? 'selected' : ''?>>Moderate</option>
+                <option value="Vigorous" <?= @($currentValue->swim->intensity) == 'Vigorous' ? 'selected' : ''?>>Vigorous</option>
+            </select>
+        </td>
+        <td>
+            <select if-bike-active class="form-control form-control-sm min-width-unset px-0" data-name="bike->intensity">
+                <option value="">-- select --</option>
+                <option value="Light" <?= @($currentValue->bike->intensity) == 'Light' ? 'selected' : ''?>>Light</option>
+                <option value="Moderate" <?= @($currentValue->bike->intensity) == 'Moderate' ? 'selected' : ''?>>Moderate</option>
+                <option value="Vigorous" <?= @($currentValue->bike->intensity) == 'Vigorous' ? 'selected' : ''?>>Vigorous</option>
+            </select>
+        </td>
+    </tr>
+    <tr>
+        <td>Time (mins/day)</td>
+        <td>
+            <input if-walk-active class="form-control form-control-sm min-width-unset px-1" type="text" data-name="walk->time" value="<?= @($currentValue->walk->time) ?>">
+        </td>
+        <td>
+            <input if-jog-active class="form-control form-control-sm min-width-unset px-1" type="text" data-name="jog->time" value="<?= @($currentValue->jog->time) ?>">
+        </td>
+        <td>
+            <input if-elliptical-active class="form-control form-control-sm min-width-unset px-1" type="text" data-name="elliptical->time" value="<?= @($currentValue->elliptical->time) ?>">
+        </td>
+        <td>
+            <input if-swim-active class="form-control form-control-sm min-width-unset px-1" type="text" data-name="swim->time" value="<?= @($currentValue->swim->time) ?>">
+        </td>
+        <td>
+            <input if-bike-active class="form-control form-control-sm min-width-unset px-1" type="text" data-name="bike->time" value="<?= @($currentValue->bike->time) ?>">
+        </td>
+    </tr>
+    </tbody>
+</table>
 
+<div if-active class="mb-2">
+    <label for="" class="mb-1">Memo</label>
+    <div note-rte slim-rte
+         class="form-group mb-2 border-left border-right rte-holder"
+         data-container-name="<?= $point ? 'data' : 'childPlanData' ?>"
+         data-field-name="memo"><?= @($currentValue->memo) ?></div>
+</div>

+ 32 - 130
resources/views/app/patient/segment-templates/_child_plan/exercise/NEAT/edit-plan.php

@@ -1,132 +1,34 @@
-<?php
-
-/*
-Format:
-{
-    active: true/false,
-    parkAway: true/false,
-    stairsInsteadOfElevators: true/false,
-    standInsteadOfSit: true/false,
-    stepsGoals: number,
-    memo: text
-}
- */
-
-$currentValue = '';
-$previousValue = '';
-$previousChildPlan = null;
-if (@$point) {
-    if ($point->lastChildPlan && $point->last_child_plan_point_scoped_note_id === $note->id) {
-        $currentValue = json_decode($point->lastChildPlan->data);
-        $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) {
-            $previousValue = json_decode($previousChildPlan->data);
-        }
-    }
-    else {
-        $previousChildPlan = \App\Models\Point::where('parent_point_id', $point->id)
-            ->where('category', 'PLAN')
-            ->orderBy('id', 'DESC')
-            ->first();
-        if($previousChildPlan && $previousChildPlan->data) {
-            $previousValue = json_decode($previousChildPlan->data);
-        }
-    }
-}
-?>
-<div visit-moe fixed-center largest relative class="d-inline">
-    <a start show href="#" class="px-1 text-center d-block" title="<?= !empty($currentValue) ? 'Edit Plan' : 'Add Plan'?>">
-        <i class="fa <?= !empty($currentValue) ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
-    </a>
-    <form url="/api/visitPoint/<?= $point ? 'upsertChildPlan' : 'addTopLevel' ?>"
-          class="mcp-theme-1 frm-review-plan-lifestyle frm-review-plan-exercise" right>
-
-        <?php if($point): ?>
-            <input type="hidden" name="uid" value="<?= $point->uid ?>">
-            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
-        <?php else: ?>
-            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-            <input type="hidden" name="category" value="<?= $p['category'] ?>">
-            <input type="hidden" name="additionReasonCategory" value="ON_INTAKE">
-        <?php endif; ?>
-
-        <?php if ($point): ?>
-            <input type="hidden" name="data">
-        <?php else: ?>
-            <input type="hidden" name="childPlanData">
-        <?php endif; ?>
-
-        <?php if($previousValue): ?>
-            <div class="mb-2">
-                <div class="d-flex align-items-baseline mb-1">
-                    <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?>)</span>
-                </div>
-                <div class="p-2 bg-light border inline-html-container">
-                    <?php $plan = $previousValue; ?>
-                    <?php include(resource_path('views/app/patient/segment-templates/_child_plan/exercise/' . $p['category'] . '/view-plan.php')); ?>
-                </div>
-            </div>
-        <?php endif; ?>
-
-        <p class="mb-2"><b>Change Goal:</b></p>
-
-        <label class="mb-2 d-flex align-items-center">
-            <input type="checkbox" data-name="active" <?= @($currentValue->active) ? 'checked' : ''?>>
-            <span class="ml-2">Prescribe Non-Exercise Activity Time (NEAT) Instructions?</span>
-        </label>
-
-        <div if-active>
-            <label class="mb-2 d-flex align-items-baseline">
-                <input type="checkbox" data-name="parkAway" <?= @($currentValue->parkAway) ? 'checked' : ''?>>
-                <span class="ml-2">Park away from entrances</span>
-            </label>
-            <label class="mb-2 d-flex align-items-baseline">
-                <input type="checkbox" data-name="stairsInsteadOfElevators" <?= @($currentValue->stairsInsteadOfElevators) ? 'checked' : ''?>>
-                <span class="ml-2">Take the stairs instead of elevator/escalator</span>
-            </label>
-            <label class="mb-2 d-flex align-items-baseline">
-                <input type="checkbox" data-name="standInsteadOfSit" <?= @($currentValue->standInsteadOfSit) ? 'checked' : ''?>>
-                <span class="ml-2">Prefer standing over sitting</span>
-            </label>
-            <div class="row mb-2">
-                <div class="col-6">
-                    <label class="mb-1">Steps/day goal</label>
-                    <input type="text" data-name="stepsGoals" class="form-control form-control-sm" value="<?= @($currentValue->stepsGoals) ?>">
-                </div>
-            </div>
-            <div class="mb-2">
-                <label for="" class="mb-1">Other</label>
-                <div note-rte slim-rte
-                     class="form-group mb-2 border-left border-right rte-holder"
-                     data-container-name="<?= $point ? 'data' : 'childPlanData' ?>"
-                     data-field-name="memo"><?= @($currentValue->memo) ?></div>
-            </div>
+<p class="mb-2"><b>Change Goal:</b></p>
+
+<label class="mb-2 d-flex align-items-center">
+    <input type="checkbox" data-name="active" <?= @($currentValue->active) ? 'checked' : ''?>>
+    <span class="ml-2">Prescribe Non-Exercise Activity Time (NEAT) Instructions?</span>
+</label>
+
+<div if-active>
+    <label class="mb-2 d-flex align-items-baseline">
+        <input type="checkbox" data-name="parkAway" <?= @($currentValue->parkAway) ? 'checked' : ''?>>
+        <span class="ml-2">Park away from entrances</span>
+    </label>
+    <label class="mb-2 d-flex align-items-baseline">
+        <input type="checkbox" data-name="stairsInsteadOfElevators" <?= @($currentValue->stairsInsteadOfElevators) ? 'checked' : ''?>>
+        <span class="ml-2">Take the stairs instead of elevator/escalator</span>
+    </label>
+    <label class="mb-2 d-flex align-items-baseline">
+        <input type="checkbox" data-name="standInsteadOfSit" <?= @($currentValue->standInsteadOfSit) ? 'checked' : ''?>>
+        <span class="ml-2">Prefer standing over sitting</span>
+    </label>
+    <div class="row mb-2">
+        <div class="col-6">
+            <label class="mb-1">Steps/day goal</label>
+            <input type="text" data-name="stepsGoals" class="form-control form-control-sm" value="<?= @($currentValue->stepsGoals) ?>">
         </div>
-        <div>
-            <button type="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="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; ?>
-
+    <div class="mb-2">
+        <label for="" class="mb-1">Other</label>
+        <div note-rte slim-rte
+             class="form-group mb-2 border-left border-right rte-holder"
+             data-container-name="<?= $point ? 'data' : 'childPlanData' ?>"
+             data-field-name="memo"><?= @($currentValue->memo) ?></div>
+    </div>
+</div>

+ 35 - 134
resources/views/app/patient/segment-templates/_child_plan/exercise/STRENGTH_TRAINING/edit-plan.php

@@ -1,137 +1,38 @@
-<?php
-
-/*
-Format:
-{
-    active: true/false,
-    muscleStrengthening: true/false,
-    allMajorMuscleGroups: true/false,
-    reps: number,
-    sets: number,
-    resistanceBandsBodyWeight: true/false,
-    memo: text
-}
- */
-
-$currentValue = '';
-$previousValue = '';
-$previousChildPlan = null;
-if (@$point) {
-    if ($point->lastChildPlan && $point->last_child_plan_point_scoped_note_id === $note->id) {
-        $currentValue = json_decode($point->lastChildPlan->data);
-        $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) {
-            $previousValue = json_decode($previousChildPlan->data);
-        }
-    }
-    else {
-        $previousChildPlan = \App\Models\Point::where('parent_point_id', $point->id)
-            ->where('category', 'PLAN')
-            ->orderBy('id', 'DESC')
-            ->first();
-        if($previousChildPlan && $previousChildPlan->data) {
-            $previousValue = json_decode($previousChildPlan->data);
-        }
-    }
-}
-?>
-<div visit-moe fixed-center largest relative class="d-inline">
-    <a start show href="#" class="px-1 text-center d-block" title="<?= !empty($currentValue) ? 'Edit Plan' : 'Add Plan'?>">
-        <i class="fa <?= !empty($currentValue) ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
-    </a>
-    <form url="/api/visitPoint/<?= $point ? 'upsertChildPlan' : 'addTopLevel' ?>"
-          class="mcp-theme-1 frm-review-plan-lifestyle frm-review-plan-exercise" right>
-
-        <?php if($point): ?>
-            <input type="hidden" name="uid" value="<?= $point->uid ?>">
-            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
-        <?php else: ?>
-            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-            <input type="hidden" name="category" value="<?= $p['category'] ?>">
-            <input type="hidden" name="additionReasonCategory" value="DURING_VISIT">
-        <?php endif; ?>
-
-        <?php if ($point): ?>
-            <input type="hidden" name="data">
-        <?php else: ?>
-            <input type="hidden" name="childPlanData">
-        <?php endif; ?>
-
-        <?php if($previousValue): ?>
-            <div class="mb-2">
-                <div class="d-flex align-items-baseline mb-1">
-                    <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?>)</span>
-                </div>
-                <div class="p-2 bg-light border inline-html-container">
-                    <?php $plan = $previousValue; ?>
-                    <?php include(resource_path('views/app/patient/segment-templates/_child_plan/exercise/' . $p['category'] . '/view-plan.php')); ?>
-                </div>
-            </div>
-        <?php endif; ?>
-
-        <p class="mb-2"><b>Change Goal:</b></p>
-
-        <label class="mb-2 d-flex align-items-center">
-            <input type="checkbox" data-name="active" <?= @($currentValue->active) ? 'checked' : ''?>>
-            <span class="ml-2">Prescribe strength training?</span>
-        </label>
-
-        <div if-active>
-            <label class="mb-2 d-flex align-items-baseline">
-                <input type="checkbox" data-name="muscleStrengthening" <?= @($currentValue->muscleStrengthening) ? 'checked' : ''?>>
-                <span class="ml-2">Do muscle strengthening exercises on moderate or greater intensity at least two days per week</span>
-            </label>
-            <label class="mb-2 d-flex align-items-baseline">
-                <input type="checkbox" data-name="allMajorMuscleGroups" <?= @($currentValue->allMajorMuscleGroups) ? 'checked' : ''?>>
-                <span class="ml-2">Do exercises to strengthen all major muscle groups: legs, hips, back, chest, abdomen, shoulders and arms</span>
-            </label>
-            <div class="row mb-2">
-                <div class="col-6">
-                    <label class="mb-1">Number of sets for each exercise</label>
-                    <input type="text" data-name="sets" class="form-control form-control-sm" value="<?= @($currentValue->sets) ?>">
-                </div>
-                <div class="col-6">
-                    <label class="mb-1">Number of repetitions per set</label>
-                    <input type="text" data-name="reps" class="form-control form-control-sm" value="<?= @($currentValue->reps) ?>">
-                </div>
-            </div>
-            <label class="mb-2 d-flex align-items-baseline">
-                <input type="checkbox" data-name="resistanceBandsBodyWeight" <?= @($currentValue->resistanceBandsBodyWeight) ? 'checked' : ''?>>
-                <span class="ml-2">Use resistance bands or using body weight to do exercises</span>
-            </label>
-            <div if-active class="mb-2">
-                <label for="" class="mb-1">Memo</label>
-                <div note-rte slim-rte
-                     class="form-group mb-2 border-left border-right rte-holder"
-                     data-container-name="<?= $point ? 'data' : 'childPlanData' ?>"
-                     data-field-name="memo"><?= @($currentValue->memo) ?></div>
-            </div>
+<p class="mb-2"><b>Change Goal:</b></p>
+
+<label class="mb-2 d-flex align-items-center">
+    <input type="checkbox" data-name="active" <?= @($currentValue->active) ? 'checked' : ''?>>
+    <span class="ml-2">Prescribe strength training?</span>
+</label>
+
+<div if-active>
+    <label class="mb-2 d-flex align-items-baseline">
+        <input type="checkbox" data-name="muscleStrengthening" <?= @($currentValue->muscleStrengthening) ? 'checked' : ''?>>
+        <span class="ml-2">Do muscle strengthening exercises on moderate or greater intensity at least two days per week</span>
+    </label>
+    <label class="mb-2 d-flex align-items-baseline">
+        <input type="checkbox" data-name="allMajorMuscleGroups" <?= @($currentValue->allMajorMuscleGroups) ? 'checked' : ''?>>
+        <span class="ml-2">Do exercises to strengthen all major muscle groups: legs, hips, back, chest, abdomen, shoulders and arms</span>
+    </label>
+    <div class="row mb-2">
+        <div class="col-6">
+            <label class="mb-1">Number of sets for each exercise</label>
+            <input type="text" data-name="sets" class="form-control form-control-sm" value="<?= @($currentValue->sets) ?>">
         </div>
-        <div>
-            <button type="submit"  class="btn btn-sm btn-primary mr-2">Save</button>
-            <button cancel class="btn btn-sm btn-default border">Cancel</button>
+        <div class="col-6">
+            <label class="mb-1">Number of repetitions per set</label>
+            <input type="text" data-name="reps" class="form-control form-control-sm" value="<?= @($currentValue->reps) ?>">
         </div>
-    </form>
-</div>
-<?php if(!empty($currentValue)): ?>
-    <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; ?>
-
+    <label class="mb-2 d-flex align-items-baseline">
+        <input type="checkbox" data-name="resistanceBandsBodyWeight" <?= @($currentValue->resistanceBandsBodyWeight) ? 'checked' : ''?>>
+        <span class="ml-2">Use resistance bands or using body weight to do exercises</span>
+    </label>
+    <div if-active class="mb-2">
+        <label for="" class="mb-1">Memo</label>
+        <div note-rte slim-rte
+             class="form-group mb-2 border-left border-right rte-holder"
+             data-container-name="<?= $point ? 'data' : 'childPlanData' ?>"
+             data-field-name="memo"><?= @($currentValue->memo) ?></div>
+    </div>
+</div>

+ 8 - 41
resources/views/app/patient/segment-templates/_child_plan/nutrition/DAILY_INTAKE_CALORIES/edit-plan.php

@@ -32,12 +32,9 @@ if (@$point) {
     }
 }
 ?>
-<div moe wide class="d-inline">
-    <a start show href="#" class="px-1 text-center d-block" title="<?= !empty($currentValue) ? 'Edit Plan' : 'Add Plan'?>">
-        <i class="fa <?= !empty($currentValue) ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
-    </a>
+<div visit-moe wide class="d-block">
     <?php if($point): ?>
-        <form url="/api/visitPoint/upsertChildPlan" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
+        <form show url="/api/visitPoint/upsertChildPlan" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
             <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
             <input type="hidden" name="data">
@@ -49,7 +46,7 @@ if (@$point) {
             <?php if($previousValue): ?>
                 <div class="mb-2">
                     <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?>) (click to copy)</span>
+                        <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?> (click to copy)</span>
                     </div>
                     <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
                 </div>
@@ -58,52 +55,22 @@ if (@$point) {
             <p class="mb-2"><b>Change goal:</b></p>
 
             <div class="mb-2">
-                <div note-rte
+                <div note-rte slim-rte
                     <?= $segment->segmentTemplate->internal_name === 'intake_problems' ? 'use-shortcuts="hpi,user"' : '' ?>
                      class="form-group mb-2 border-left border-right rte-holder"
                      data-field-name="value"><?= $currentValue ?></div>
             </div>
-            <div>
-                <button type="submit"  class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
         </form>
     <?php else: ?>
-        <form url="/api/visitPoint/addTopLevel" class="mcp-theme-1 frm-add-review-plan-nutrition w-100" left>
-            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-            <input type="hidden" name="category" value="<?= $p['category'] ?>">
-            <input type="hidden" name="additionReasonCategory" value="ON_INTAKE">
-            <input type="hidden" name="data">
 
-            <?php if($previousValue): ?>
-                <div class="mb-2">
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?>) (click to copy)</span>
-                    </div>
-                    <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
-                </div>
-            <?php endif; ?>
-
-            <p class="mb-2"><b>Change goal:</b></p>
-
-            <div class="mb-2">
-                <div note-rte
-                     class="form-group mb-2 border-left border-right rte-holder"
-                     data-field-name="planValue"><?= $currentValue ?></div>
-            </div>
-            <div>
-                <button type="submit" class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
-        </form>
     <?php endif; ?>
 </div>
 <?php if(!empty($currentValue)): ?>
-    <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>
+    <div visit-moe relative class="d-block">
+        <a start show href="#" class="px-1 text-left" title="Delete Plan">
+            Delete Plan
         </a>
-        <form url="/api/visitPoint/destroyCurrentChildPlan" class="mcp-theme-1" right>
+        <form url="/api/visitPoint/destroyCurrentChildPlan" class="mcp-theme-1">
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
 
             <p class="mb-2">Delete this plan?</p>

+ 8 - 41
resources/views/app/patient/segment-templates/_child_plan/nutrition/DAILY_INTAKE_CARBOHYDRATES/edit-plan.php

@@ -32,12 +32,9 @@ if (@$point) {
     }
 }
 ?>
-<div moe wide class="d-inline">
-    <a start show href="#" class="px-1 text-center d-block" title="<?= !empty($currentValue) ? 'Edit Plan' : 'Add Plan'?>">
-        <i class="fa <?= !empty($currentValue) ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
-    </a>
+<div visit-moe wide class="d-block">
     <?php if($point): ?>
-        <form url="/api/visitPoint/upsertChildPlan" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
+        <form show url="/api/visitPoint/upsertChildPlan" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
             <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
             <input type="hidden" name="data">
@@ -49,7 +46,7 @@ if (@$point) {
             <?php if($previousValue): ?>
                 <div class="mb-2">
                     <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?>) (click to copy)</span>
+                        <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?> (click to copy)</span>
                     </div>
                     <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
                 </div>
@@ -58,52 +55,22 @@ if (@$point) {
             <p class="mb-2"><b>Change goal:</b></p>
 
             <div class="mb-2">
-                <div note-rte
+                <div note-rte slim-rte
                     <?= $segment->segmentTemplate->internal_name === 'intake_problems' ? 'use-shortcuts="hpi,user"' : '' ?>
                      class="form-group mb-2 border-left border-right rte-holder"
                      data-field-name="value"><?= $currentValue ?></div>
             </div>
-            <div>
-                <button type="submit"  class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
         </form>
     <?php else: ?>
-        <form url="/api/visitPoint/addTopLevel" class="mcp-theme-1 frm-add-review-plan-nutrition w-100" left>
-            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-            <input type="hidden" name="category" value="<?= $p['category'] ?>">
-            <input type="hidden" name="additionReasonCategory" value="ON_INTAKE">
-            <input type="hidden" name="data">
 
-            <?php if($previousValue): ?>
-                <div class="mb-2">
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?>) (click to copy)</span>
-                    </div>
-                    <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
-                </div>
-            <?php endif; ?>
-
-            <p class="mb-2"><b>Change goal:</b></p>
-
-            <div class="mb-2">
-                <div note-rte
-                     class="form-group mb-2 border-left border-right rte-holder"
-                     data-field-name="planValue"><?= $currentValue ?></div>
-            </div>
-            <div>
-                <button type="submit" class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
-        </form>
     <?php endif; ?>
 </div>
 <?php if(!empty($currentValue)): ?>
-    <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>
+    <div visit-moe relative class="d-block">
+        <a start show href="#" class="px-1 text-left" title="Delete Plan">
+            Delete Plan
         </a>
-        <form url="/api/visitPoint/destroyCurrentChildPlan" class="mcp-theme-1" right>
+        <form url="/api/visitPoint/destroyCurrentChildPlan" class="mcp-theme-1">
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
 
             <p class="mb-2">Delete this plan?</p>

+ 8 - 41
resources/views/app/patient/segment-templates/_child_plan/nutrition/FAST_FOOD/edit-plan.php

@@ -32,12 +32,9 @@ if (@$point) {
     }
 }
 ?>
-<div moe wide class="d-inline">
-    <a start show href="#" class="px-1 text-center d-block" title="<?= !empty($currentValue) ? 'Edit Plan' : 'Add Plan'?>">
-        <i class="fa <?= !empty($currentValue) ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
-    </a>
+<div visit-moe wide class="d-block">
     <?php if($point): ?>
-        <form url="/api/visitPoint/upsertChildPlan" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
+        <form show url="/api/visitPoint/upsertChildPlan" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
             <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
             <input type="hidden" name="data">
@@ -49,7 +46,7 @@ if (@$point) {
             <?php if($previousValue): ?>
                 <div class="mb-2">
                     <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?>) (click to copy)</span>
+                        <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?> (click to copy)</span>
                     </div>
                     <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
                 </div>
@@ -58,52 +55,22 @@ if (@$point) {
             <p class="mb-2"><b>Change goal:</b></p>
 
             <div class="mb-2">
-                <div note-rte
+                <div note-rte slim-rte
                     <?= $segment->segmentTemplate->internal_name === 'intake_problems' ? 'use-shortcuts="hpi,user"' : '' ?>
                      class="form-group mb-2 border-left border-right rte-holder"
                      data-field-name="value"><?= $currentValue ?></div>
             </div>
-            <div>
-                <button type="submit"  class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
         </form>
     <?php else: ?>
-        <form url="/api/visitPoint/addTopLevel" class="mcp-theme-1 frm-add-review-plan-nutrition w-100" left>
-            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-            <input type="hidden" name="category" value="<?= $p['category'] ?>">
-            <input type="hidden" name="additionReasonCategory" value="ON_INTAKE">
-            <input type="hidden" name="data">
 
-            <?php if($previousValue): ?>
-                <div class="mb-2">
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?>) (click to copy)</span>
-                    </div>
-                    <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
-                </div>
-            <?php endif; ?>
-
-            <p class="mb-2"><b>Change goal:</b></p>
-
-            <div class="mb-2">
-                <div note-rte
-                     class="form-group mb-2 border-left border-right rte-holder"
-                     data-field-name="planValue"><?= $currentValue ?></div>
-            </div>
-            <div>
-                <button type="submit" class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
-        </form>
     <?php endif; ?>
 </div>
 <?php if(!empty($currentValue)): ?>
-    <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>
+    <div visit-moe relative class="d-block">
+        <a start show href="#" class="px-1 text-left" title="Delete Plan">
+            Delete Plan
         </a>
-        <form url="/api/visitPoint/destroyCurrentChildPlan" class="mcp-theme-1" right>
+        <form url="/api/visitPoint/destroyCurrentChildPlan" class="mcp-theme-1">
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
 
             <p class="mb-2">Delete this plan?</p>

+ 8 - 41
resources/views/app/patient/segment-templates/_child_plan/nutrition/HIGH_SUGAR_BEVERAGES/edit-plan.php

@@ -32,12 +32,9 @@ if (@$point) {
     }
 }
 ?>
-<div moe wide class="d-inline">
-    <a start show href="#" class="px-1 text-center d-block" title="<?= !empty($currentValue) ? 'Edit Plan' : 'Add Plan'?>">
-        <i class="fa <?= !empty($currentValue) ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
-    </a>
+<div visit-moe wide class="d-block">
     <?php if($point): ?>
-        <form url="/api/visitPoint/upsertChildPlan" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
+        <form show url="/api/visitPoint/upsertChildPlan" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
             <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
             <input type="hidden" name="data">
@@ -49,7 +46,7 @@ if (@$point) {
             <?php if($previousValue): ?>
                 <div class="mb-2">
                     <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?>) (click to copy)</span>
+                        <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?> (click to copy)</span>
                     </div>
                     <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
                 </div>
@@ -58,52 +55,22 @@ if (@$point) {
             <p class="mb-2"><b>Change goal:</b></p>
 
             <div class="mb-2">
-                <div note-rte
+                <div note-rte slim-rte
                     <?= $segment->segmentTemplate->internal_name === 'intake_problems' ? 'use-shortcuts="hpi,user"' : '' ?>
                      class="form-group mb-2 border-left border-right rte-holder"
                      data-field-name="value"><?= $currentValue ?></div>
             </div>
-            <div>
-                <button type="submit"  class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
         </form>
     <?php else: ?>
-        <form url="/api/visitPoint/addTopLevel" class="mcp-theme-1 frm-add-review-plan-nutrition w-100" left>
-            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-            <input type="hidden" name="category" value="<?= $p['category'] ?>">
-            <input type="hidden" name="additionReasonCategory" value="ON_INTAKE">
-            <input type="hidden" name="data">
 
-            <?php if($previousValue): ?>
-                <div class="mb-2">
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?>) (click to copy)</span>
-                    </div>
-                    <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
-                </div>
-            <?php endif; ?>
-
-            <p class="mb-2"><b>Change goal:</b></p>
-
-            <div class="mb-2">
-                <div note-rte
-                     class="form-group mb-2 border-left border-right rte-holder"
-                     data-field-name="planValue"><?= $currentValue ?></div>
-            </div>
-            <div>
-                <button type="submit" class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
-        </form>
     <?php endif; ?>
 </div>
 <?php if(!empty($currentValue)): ?>
-    <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>
+    <div visit-moe relative class="d-block">
+        <a start show href="#" class="px-1 text-left" title="Delete Plan">
+            Delete Plan
         </a>
-        <form url="/api/visitPoint/destroyCurrentChildPlan" class="mcp-theme-1" right>
+        <form url="/api/visitPoint/destroyCurrentChildPlan" class="mcp-theme-1">
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
 
             <p class="mb-2">Delete this plan?</p>

+ 8 - 41
resources/views/app/patient/segment-templates/_child_plan/nutrition/PORTION_SIZES/edit-plan.php

@@ -32,12 +32,9 @@ if (@$point) {
     }
 }
 ?>
-<div moe wide class="d-inline">
-    <a start show href="#" class="px-1 text-center d-block" title="<?= !empty($currentValue) ? 'Edit Plan' : 'Add Plan'?>">
-        <i class="fa <?= !empty($currentValue) ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
-    </a>
+<div visit-moe wide class="d-block">
     <?php if($point): ?>
-        <form url="/api/visitPoint/upsertChildPlan" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
+        <form show url="/api/visitPoint/upsertChildPlan" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
             <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
             <input type="hidden" name="data">
@@ -49,7 +46,7 @@ if (@$point) {
             <?php if($previousValue): ?>
                 <div class="mb-2">
                     <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?>) (click to copy)</span>
+                        <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?> (click to copy)</span>
                     </div>
                     <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
                 </div>
@@ -58,52 +55,22 @@ if (@$point) {
             <p class="mb-2"><b>Change goal:</b></p>
 
             <div class="mb-2">
-                <div note-rte
+                <div note-rte slim-rte
                     <?= $segment->segmentTemplate->internal_name === 'intake_problems' ? 'use-shortcuts="hpi,user"' : '' ?>
                      class="form-group mb-2 border-left border-right rte-holder"
                      data-field-name="value"><?= $currentValue ?></div>
             </div>
-            <div>
-                <button type="submit"  class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
         </form>
     <?php else: ?>
-        <form url="/api/visitPoint/addTopLevel" class="mcp-theme-1 frm-add-review-plan-nutrition w-100" left>
-            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-            <input type="hidden" name="category" value="<?= $p['category'] ?>">
-            <input type="hidden" name="additionReasonCategory" value="ON_INTAKE">
-            <input type="hidden" name="data">
 
-            <?php if($previousValue): ?>
-                <div class="mb-2">
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?>) (click to copy)</span>
-                    </div>
-                    <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
-                </div>
-            <?php endif; ?>
-
-            <p class="mb-2"><b>Change goal:</b></p>
-
-            <div class="mb-2">
-                <div note-rte
-                     class="form-group mb-2 border-left border-right rte-holder"
-                     data-field-name="planValue"><?= $currentValue ?></div>
-            </div>
-            <div>
-                <button type="submit" class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
-        </form>
     <?php endif; ?>
 </div>
 <?php if(!empty($currentValue)): ?>
-    <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>
+    <div visit-moe relative class="d-block">
+        <a start show href="#" class="px-1 text-left" title="Delete Plan">
+            Delete Plan
         </a>
-        <form url="/api/visitPoint/destroyCurrentChildPlan" class="mcp-theme-1" right>
+        <form url="/api/visitPoint/destroyCurrentChildPlan" class="mcp-theme-1">
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
 
             <p class="mb-2">Delete this plan?</p>

+ 8 - 41
resources/views/app/patient/segment-templates/_child_plan/nutrition/SNACKS/edit-plan.php

@@ -32,12 +32,9 @@ if (@$point) {
     }
 }
 ?>
-<div moe wide class="d-inline">
-    <a start show href="#" class="px-1 text-center d-block" title="<?= !empty($currentValue) ? 'Edit Plan' : 'Add Plan'?>">
-        <i class="fa <?= !empty($currentValue) ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
-    </a>
+<div visit-moe wide class="d-block">
     <?php if($point): ?>
-        <form url="/api/visitPoint/upsertChildPlan" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
+        <form show url="/api/visitPoint/upsertChildPlan" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
             <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
             <input type="hidden" name="data">
@@ -49,7 +46,7 @@ if (@$point) {
             <?php if($previousValue): ?>
                 <div class="mb-2">
                     <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?>) (click to copy)</span>
+                        <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?> (click to copy)</span>
                     </div>
                     <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
                 </div>
@@ -58,52 +55,22 @@ if (@$point) {
             <p class="mb-2"><b>Change goal:</b></p>
 
             <div class="mb-2">
-                <div note-rte
+                <div note-rte slim-rte
                     <?= $segment->segmentTemplate->internal_name === 'intake_problems' ? 'use-shortcuts="hpi,user"' : '' ?>
                      class="form-group mb-2 border-left border-right rte-holder"
                      data-field-name="value"><?= $currentValue ?></div>
             </div>
-            <div>
-                <button type="submit"  class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
         </form>
     <?php else: ?>
-        <form url="/api/visitPoint/addTopLevel" class="mcp-theme-1 frm-add-review-plan-nutrition w-100" left>
-            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-            <input type="hidden" name="category" value="<?= $p['category'] ?>">
-            <input type="hidden" name="additionReasonCategory" value="ON_INTAKE">
-            <input type="hidden" name="data">
 
-            <?php if($previousValue): ?>
-                <div class="mb-2">
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?>) (click to copy)</span>
-                    </div>
-                    <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
-                </div>
-            <?php endif; ?>
-
-            <p class="mb-2"><b>Change goal:</b></p>
-
-            <div class="mb-2">
-                <div note-rte
-                     class="form-group mb-2 border-left border-right rte-holder"
-                     data-field-name="planValue"><?= $currentValue ?></div>
-            </div>
-            <div>
-                <button type="submit" class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
-        </form>
     <?php endif; ?>
 </div>
 <?php if(!empty($currentValue)): ?>
-    <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>
+    <div visit-moe relative class="d-block">
+        <a start show href="#" class="px-1 text-left" title="Delete Plan">
+            Delete Plan
         </a>
-        <form url="/api/visitPoint/destroyCurrentChildPlan" class="mcp-theme-1" right>
+        <form url="/api/visitPoint/destroyCurrentChildPlan" class="mcp-theme-1">
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
 
             <p class="mb-2">Delete this plan?</p>

+ 8 - 41
resources/views/app/patient/segment-templates/_child_plan/nutrition/VEGETABLES/edit-plan.php

@@ -32,12 +32,9 @@ if (@$point) {
     }
 }
 ?>
-<div moe wide class="d-inline">
-    <a start show href="#" class="px-1 text-center d-block" title="<?= !empty($currentValue) ? 'Edit Plan' : 'Add Plan'?>">
-        <i class="fa <?= !empty($currentValue) ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
-    </a>
+<div visit-moe wide class="d-block">
     <?php if($point): ?>
-        <form url="/api/visitPoint/upsertChildPlan" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
+        <form show url="/api/visitPoint/upsertChildPlan" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
             <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
             <input type="hidden" name="data">
@@ -49,7 +46,7 @@ if (@$point) {
             <?php if($previousValue): ?>
                 <div class="mb-2">
                     <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?>) (click to copy)</span>
+                        <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?> (click to copy)</span>
                     </div>
                     <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
                 </div>
@@ -58,52 +55,22 @@ if (@$point) {
             <p class="mb-2"><b>Change goal:</b></p>
 
             <div class="mb-2">
-                <div note-rte
+                <div note-rte slim-rte
                     <?= $segment->segmentTemplate->internal_name === 'intake_problems' ? 'use-shortcuts="hpi,user"' : '' ?>
                      class="form-group mb-2 border-left border-right rte-holder"
                      data-field-name="value"><?= $currentValue ?></div>
             </div>
-            <div>
-                <button type="submit"  class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
         </form>
     <?php else: ?>
-        <form url="/api/visitPoint/addTopLevel" class="mcp-theme-1 frm-add-review-plan-nutrition w-100" left>
-            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-            <input type="hidden" name="category" value="<?= $p['category'] ?>">
-            <input type="hidden" name="additionReasonCategory" value="ON_INTAKE">
-            <input type="hidden" name="data">
 
-            <?php if($previousValue): ?>
-                <div class="mb-2">
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?>) (click to copy)</span>
-                    </div>
-                    <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
-                </div>
-            <?php endif; ?>
-
-            <p class="mb-2"><b>Change goal:</b></p>
-
-            <div class="mb-2">
-                <div note-rte
-                     class="form-group mb-2 border-left border-right rte-holder"
-                     data-field-name="planValue"><?= $currentValue ?></div>
-            </div>
-            <div>
-                <button type="submit" class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
-        </form>
     <?php endif; ?>
 </div>
 <?php if(!empty($currentValue)): ?>
-    <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>
+    <div visit-moe relative class="d-block">
+        <a start show href="#" class="px-1 text-left" title="Delete Plan">
+            Delete Plan
         </a>
-        <form url="/api/visitPoint/destroyCurrentChildPlan" class="mcp-theme-1" right>
+        <form url="/api/visitPoint/destroyCurrentChildPlan" class="mcp-theme-1">
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
 
             <p class="mb-2">Delete this plan?</p>

+ 8 - 41
resources/views/app/patient/segment-templates/_child_plan/nutrition/WATER_INTAKE/edit-plan.php

@@ -32,12 +32,9 @@ if (@$point) {
     }
 }
 ?>
-<div moe wide class="d-inline">
-    <a start show href="#" class="px-1 text-center d-block" title="<?= !empty($currentValue) ? 'Edit Plan' : 'Add Plan'?>">
-        <i class="fa <?= !empty($currentValue) ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
-    </a>
+<div visit-moe wide class="d-block">
     <?php if($point): ?>
-        <form url="/api/visitPoint/upsertChildPlan" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
+        <form show url="/api/visitPoint/upsertChildPlan" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
             <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
             <input type="hidden" name="data">
@@ -49,7 +46,7 @@ if (@$point) {
             <?php if($previousValue): ?>
                 <div class="mb-2">
                     <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?>) (click to copy)</span>
+                        <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?> (click to copy)</span>
                     </div>
                     <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
                 </div>
@@ -58,52 +55,22 @@ if (@$point) {
             <p class="mb-2"><b>Change goal:</b></p>
 
             <div class="mb-2">
-                <div note-rte
+                <div note-rte slim-rte
                     <?= $segment->segmentTemplate->internal_name === 'intake_problems' ? 'use-shortcuts="hpi,user"' : '' ?>
                      class="form-group mb-2 border-left border-right rte-holder"
                      data-field-name="value"><?= $currentValue ?></div>
             </div>
-            <div>
-                <button type="submit" class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
         </form>
     <?php else: ?>
-        <form url="/api/visitPoint/addTopLevel" class="mcp-theme-1 frm-add-review-plan-nutrition w-100" left>
-            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-            <input type="hidden" name="category" value="<?= $p['category'] ?>">
-            <input type="hidden" name="additionReasonCategory" value="ON_INTAKE">
-            <input type="hidden" name="data">
 
-            <?php if($previousValue): ?>
-                <div class="mb-2">
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?>) (click to copy)</span>
-                    </div>
-                    <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
-                </div>
-            <?php endif; ?>
-
-            <p class="mb-2"><b>Change goal:</b></p>
-
-            <div class="mb-2">
-                <div note-rte
-                     class="form-group mb-2 border-left border-right rte-holder"
-                     data-field-name="planValue"><?= $currentValue ?></div>
-            </div>
-            <div>
-                <button type="submit" class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
-        </form>
     <?php endif; ?>
 </div>
 <?php if(!empty($currentValue)): ?>
-    <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>
+    <div visit-moe relative class="d-block">
+        <a start show href="#" class="px-1 text-left" title="Delete Plan">
+            Delete Plan
         </a>
-        <form url="/api/visitPoint/destroyCurrentChildPlan" class="mcp-theme-1" right>
+        <form url="/api/visitPoint/destroyCurrentChildPlan" class="mcp-theme-1">
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
 
             <p class="mb-2">Delete this plan?</p>

+ 42 - 142
resources/views/app/patient/segment-templates/_child_review/behavior/CRAVINGS/edit-review.php

@@ -1,147 +1,47 @@
-<?php
-
-/*
-Format:
-{
-    sugar: bool,
-    starches: bool,
-    friedFood: bool,
-    sweetDrinks: bool,
-    other: bool,
-    otherDetail: text
-    memo: text
-}
- */
-
-$currentValue = '';
-$previousValue = '';
-$previousChildReview = null;
-if (@$point) {
-    if ($point->lastChildReview && $point->last_child_review_point_scoped_note_id === $note->id) {
-        $currentValue = json_decode($point->lastChildReview->data);
-        $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) {
-            $previousValue = json_decode($previousChildReview->data);
-        }
-    }
-    else {
-        $previousChildReview = \App\Models\Point::where('parent_point_id', $point->id)
-            ->where('category', 'REVIEW')
-            ->orderBy('id', 'DESC')
-            ->first();
-        if($previousChildReview && $previousChildReview->data) {
-            $previousValue = json_decode($previousChildReview->data);
-        }
-    }
-}
-?>
-<div visit-moe fixed-center largest relative class="d-inline">
-    <a start show href="#" class="px-1 text-center d-block" title="<?= !empty($currentValue) ? 'Edit Subjective' : 'Add Subjective'?>">
-        <i class="fa <?= !empty($currentValue) ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
-    </a>
-    <form url="/api/visitPoint/<?= $point ? 'upsertChildReview' : 'addTopLevel' ?>"
-          class="mcp-theme-1 frm-review-plan-lifestyle frm-review-plan-behavior" right>
-
-        <?php if($point): ?>
-            <input type="hidden" name="uid" value="<?= $point->uid ?>">
-            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
-        <?php else: ?>
-            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-            <input type="hidden" name="category" value="<?= $p['category'] ?>">
-            <input type="hidden" name="additionReasonCategory" value="ON_INTAKE">
-        <?php endif; ?>
-
-        <?php if ($point): ?>
-            <input type="hidden" name="data">
-        <?php else: ?>
-            <input type="hidden" name="childReviewData">
-        <?php endif; ?>
-
-        <?php if($previousValue): ?>
-            <div class="mb-2">
-                <div class="d-flex align-items-baseline mb-1">
-                    <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?>)</span>
-                </div>
-                <div class="p-2 bg-light border inline-html-container">
-                    <?php $review = $previousValue; ?>
-                    <?php include(resource_path('views/app/patient/segment-templates/_child_review/behavior/' . $p['category'] . '/view-review.php')); ?>
-                </div>
-            </div>
-        <?php endif; ?>
-
-        <p class="mb-2"><b>Current Cravings</b></p>
-
-        <div class="mb-2">
-            <div class="row mb-1">
-                <div class="col-4">
-                    <label class="d-flex align-items-center mb-1">
-                        <input type="checkbox" data-name="sugar" <?= @($currentValue->sugar) ? 'checked' : ''?>>
-                        <span class="mx-2">Sugar</span>
-                    </label>
-                </div>
-                <div class="col-4">
-                    <label class="d-flex align-items-center mb-1">
-                        <input type="checkbox" data-name="starches" <?= @($currentValue->starches) ? 'checked' : ''?>>
-                        <span class="mx-2">Starches</span>
-                    </label>
-                </div>
-                <div class="col-4">
-                    <label class="d-flex align-items-center mb-1">
-                        <input type="checkbox" data-name="friedFood" <?= @($currentValue->friedFood) ? 'checked' : ''?>>
-                        <span class="mx-2">Fried Food</span>
-                    </label>
-                </div>
-            </div>
-            <div class="row">
-                <div class="col-4">
-                    <label class="d-flex align-items-center mb-1">
-                        <input type="checkbox" data-name="sweetDrinks" <?= @($currentValue->sweetDrinks) ? 'checked' : ''?>>
-                        <span class="mx-2">Sweet Drinks</span>
-                    </label>
-                </div>
-                <div class="col-8">
-                    <label class="d-flex align-items-center mb-1">
-                        <input type="checkbox" data-name="other" <?= @($currentValue->other) ? 'checked' : ''?>>
-                        <span class="ml-2">Other</span>
-                        <input if-other type="text" class="form-control form-control-sm min-width-unset flex-grow-1 ml-2" data-name="otherDetail" value="<?= @($currentValue->otherDetail) ?>">
-                    </label>
-                </div>
-            </div>
+<p class="mb-2"><b>Current Cravings</b></p>
+
+<div class="mb-2">
+    <div class="row mb-1">
+        <div class="col-4">
+            <label class="d-flex align-items-center mb-1">
+                <input type="checkbox" data-name="sugar" <?= @($currentValue->sugar) ? 'checked' : ''?>>
+                <span class="mx-2">Sugar</span>
+            </label>
         </div>
-
-        <div class="mb-2">
-            <label for="" class="mb-1">Memo</label>
-            <div note-rte slim-rte
-                 class="form-group mb-2 border-left border-right rte-holder"
-                 data-container-name="<?= $point ? 'data' : 'childReviewData' ?>"
-                 data-field-name="memo"><?= @($currentValue->memo) ?></div>
+        <div class="col-4">
+            <label class="d-flex align-items-center mb-1">
+                <input type="checkbox" data-name="starches" <?= @($currentValue->starches) ? 'checked' : ''?>>
+                <span class="mx-2">Starches</span>
+            </label>
         </div>
-
-        <div>
-            <button type="submit"  class="btn btn-sm btn-primary mr-2">Save</button>
-            <button cancel class="btn btn-sm btn-default border">Cancel</button>
+        <div class="col-4">
+            <label class="d-flex align-items-center mb-1">
+                <input type="checkbox" data-name="friedFood" <?= @($currentValue->friedFood) ? 'checked' : ''?>>
+                <span class="mx-2">Fried Food</span>
+            </label>
+        </div>
+    </div>
+    <div class="row">
+        <div class="col-4">
+            <label class="d-flex align-items-center mb-1">
+                <input type="checkbox" data-name="sweetDrinks" <?= @($currentValue->sweetDrinks) ? 'checked' : ''?>>
+                <span class="mx-2">Sweet Drinks</span>
+            </label>
+        </div>
+        <div class="col-8">
+            <label class="d-flex align-items-center mb-1">
+                <input type="checkbox" data-name="other" <?= @($currentValue->other) ? 'checked' : ''?>>
+                <span class="ml-2">Other</span>
+                <input if-other type="text" class="form-control form-control-sm min-width-unset flex-grow-1 ml-2" data-name="otherDetail" value="<?= @($currentValue->otherDetail) ?>">
+            </label>
         </div>
-    </form>
-</div>
-<?php if(!empty($currentValue)): ?>
-    <div visit-moe relative class="d-inline">
-        <a start show href="#" class="px-1 text-center d-block" title="Delete Subjective">
-            <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">Delete this subjective?</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>
 
+<div class="mb-2">
+    <label for="" class="mb-1">Memo</label>
+    <div note-rte slim-rte
+         class="form-group mb-2 border-left border-right rte-holder"
+         data-container-name="<?= $point ? 'data' : 'childReviewData' ?>"
+         data-field-name="memo"><?= @($currentValue->memo) ?></div>
+</div>

+ 46 - 145
resources/views/app/patient/segment-templates/_child_review/behavior/FOOD_TRIGGERS/edit-review.php

@@ -1,150 +1,51 @@
-<?php
-
-/*
-Format:
-{
-    stress: bool,
-    work: bool,
-    social: bool,
-    reward: bool,
-    relaxation: bool,
-    memo: text
-}
- */
-
-$currentValue = '';
-$previousValue = '';
-$previousChildReview = null;
-if (@$point) {
-    if ($point->lastChildReview && $point->last_child_review_point_scoped_note_id === $note->id) {
-        $currentValue = json_decode($point->lastChildReview->data);
-        $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) {
-            $previousValue = json_decode($previousChildReview->data);
-        }
-    }
-    else {
-        $previousChildReview = \App\Models\Point::where('parent_point_id', $point->id)
-            ->where('category', 'REVIEW')
-            ->orderBy('id', 'DESC')
-            ->first();
-        if($previousChildReview && $previousChildReview->data) {
-            $previousValue = json_decode($previousChildReview->data);
-        }
-    }
-}
-?>
-<div visit-moe fixed-center largest relative class="d-inline">
-    <a start show href="#" class="px-1 text-center d-block" title="<?= !empty($currentValue) ? 'Edit Subjective' : 'Add Subjective'?>">
-        <i class="fa <?= !empty($currentValue) ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
-    </a>
-    <form url="/api/visitPoint/<?= $point ? 'upsertChildReview' : 'addTopLevel' ?>"
-          class="mcp-theme-1 frm-review-plan-lifestyle frm-review-plan-behavior" right>
-
-        <?php if($point): ?>
-            <input type="hidden" name="uid" value="<?= $point->uid ?>">
-            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
-        <?php else: ?>
-            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-            <input type="hidden" name="category" value="<?= $p['category'] ?>">
-            <input type="hidden" name="additionReasonCategory" value="ON_INTAKE">
-        <?php endif; ?>
-
-        <?php if ($point): ?>
-            <input type="hidden" name="data">
-        <?php else: ?>
-            <input type="hidden" name="childReviewData">
-        <?php endif; ?>
-
-        <?php if($previousValue): ?>
-            <div class="mb-2">
-                <div class="d-flex align-items-baseline mb-1">
-                    <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?>)</span>
-                </div>
-                <div class="p-2 bg-light border inline-html-container">
-                    <?php $review = $previousValue; ?>
-                    <?php include(resource_path('views/app/patient/segment-templates/_child_review/behavior/' . $p['category'] . '/view-review.php')); ?>
-                </div>
-            </div>
-        <?php endif; ?>
-
-        <p class="mb-2"><b>Current Food Triggers</b></p>
-
-        <div class="mb-2">
-            <div class="row mb-1">
-                <div class="col-4">
-                    <label class="d-flex align-items-center mb-1">
-                        <input type="checkbox" data-name="stress" <?= @($currentValue->stress) ? 'checked' : ''?>>
-                        <span class="mx-2">Stress</span>
-                        <img src="/img/behavior-rx/stress.png" class="icon-nutrition-rx-row">
-                    </label>
-                </div>
-                <div class="col-4">
-                    <label class="d-flex align-items-center mb-1">
-                        <input type="checkbox" data-name="work" <?= @($currentValue->work) ? 'checked' : ''?>>
-                        <span class="mx-2">Work</span>
-                        <img src="/img/behavior-rx/work.png" class="icon-nutrition-rx-row">
-                    </label>
-                </div>
-                <div class="col-4">
-                    <label class="d-flex align-items-center mb-1">
-                        <input type="checkbox" data-name="social" <?= @($currentValue->social) ? 'checked' : ''?>>
-                        <span class="mx-2">Social</span>
-                        <img src="/img/behavior-rx/social.png" class="icon-nutrition-rx-row">
-                    </label>
-                </div>
-            </div>
-            <div class="row">
-                <div class="col-4">
-                    <label class="d-flex align-items-center mb-1">
-                        <input type="checkbox" data-name="reward" <?= @($currentValue->reward) ? 'checked' : ''?>>
-                        <span class="mx-2">Reward</span>
-                        <img src="/img/behavior-rx/reward.png" class="icon-nutrition-rx-row">
-                    </label>
-                </div>
-                <div class="col-8">
-                    <label class="d-flex align-items-center mb-1">
-                        <input type="checkbox" data-name="relaxation" <?= @($currentValue->relaxation) ? 'checked' : ''?>>
-                        <span class="mx-2">Relaxation</span>
-                        <img src="/img/behavior-rx/relaxation.png" class="icon-nutrition-rx-row">
-                    </label>
-                </div>
-            </div>
+<p class="mb-2"><b>Current Food Triggers</b></p>
+
+<div class="mb-2">
+    <div class="row mb-1">
+        <div class="col-4">
+            <label class="d-flex align-items-center mb-1">
+                <input type="checkbox" data-name="stress" <?= @($currentValue->stress) ? 'checked' : ''?>>
+                <span class="mx-2">Stress</span>
+                <img src="/img/behavior-rx/stress.png" class="icon-nutrition-rx-row">
+            </label>
         </div>
-
-        <div class="mb-2">
-            <label for="" class="mb-1">Memo</label>
-            <div note-rte slim-rte
-                 class="form-group mb-2 border-left border-right rte-holder"
-                 data-container-name="<?= $point ? 'data' : 'childReviewData' ?>"
-                 data-field-name="memo"><?= @($currentValue->memo) ?></div>
+        <div class="col-4">
+            <label class="d-flex align-items-center mb-1">
+                <input type="checkbox" data-name="work" <?= @($currentValue->work) ? 'checked' : ''?>>
+                <span class="mx-2">Work</span>
+                <img src="/img/behavior-rx/work.png" class="icon-nutrition-rx-row">
+            </label>
         </div>
-
-        <div>
-            <button type="submit"  class="btn btn-sm btn-primary mr-2">Save</button>
-            <button cancel class="btn btn-sm btn-default border">Cancel</button>
+        <div class="col-4">
+            <label class="d-flex align-items-center mb-1">
+                <input type="checkbox" data-name="social" <?= @($currentValue->social) ? 'checked' : ''?>>
+                <span class="mx-2">Social</span>
+                <img src="/img/behavior-rx/social.png" class="icon-nutrition-rx-row">
+            </label>
+        </div>
+    </div>
+    <div class="row">
+        <div class="col-4">
+            <label class="d-flex align-items-center mb-1">
+                <input type="checkbox" data-name="reward" <?= @($currentValue->reward) ? 'checked' : ''?>>
+                <span class="mx-2">Reward</span>
+                <img src="/img/behavior-rx/reward.png" class="icon-nutrition-rx-row">
+            </label>
+        </div>
+        <div class="col-8">
+            <label class="d-flex align-items-center mb-1">
+                <input type="checkbox" data-name="relaxation" <?= @($currentValue->relaxation) ? 'checked' : ''?>>
+                <span class="mx-2">Relaxation</span>
+                <img src="/img/behavior-rx/relaxation.png" class="icon-nutrition-rx-row">
+            </label>
         </div>
-    </form>
-</div>
-<?php if(!empty($currentValue)): ?>
-    <div visit-moe relative class="d-inline">
-        <a start show href="#" class="px-1 text-center d-block" title="Delete Subjective">
-            <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">Delete this subjective?</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>
 
+<div class="mb-2">
+    <label for="" class="mb-1">Memo</label>
+    <div note-rte slim-rte
+         class="form-group mb-2 border-left border-right rte-holder"
+         data-container-name="<?= $point ? 'data' : 'childReviewData' ?>"
+         data-field-name="memo"><?= @($currentValue->memo) ?></div>
+</div>

+ 62 - 169
resources/views/app/patient/segment-templates/_child_review/behavior/SELF_MONITORING/edit-review.php

@@ -1,180 +1,73 @@
-<?php
+<p class="mb-2"><b>Self Monitoring</b></p>
 
-/*
-Format:
-{
-    weighInsPerWeek: number,
-    tracking: {
-        calorieIntake: bool,
-        dailyCarbIntake: bool,
-        portionSize: bool,
-        eatingSpeed: bool,
-        other: bool
-        otherDetail: text
-    },
-    foodMonitoring: {
-        phoneTracker: bool,
-        dailyFoodLog: bool
-    }
-    memo: text
-}
- */
-
-$currentValue = '';
-$previousValue = '';
-$previousChildReview = null;
-if (@$point) {
-    if ($point->lastChildReview && $point->last_child_review_point_scoped_note_id === $note->id) {
-        $currentValue = json_decode($point->lastChildReview->data);
-        $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) {
-            $previousValue = json_decode($previousChildReview->data);
-        }
-    }
-    else {
-        $previousChildReview = \App\Models\Point::where('parent_point_id', $point->id)
-            ->where('category', 'REVIEW')
-            ->orderBy('id', 'DESC')
-            ->first();
-        if($previousChildReview && $previousChildReview->data) {
-            $previousValue = json_decode($previousChildReview->data);
-        }
-    }
-}
-?>
-<div visit-moe fixed-center largest relative class="d-inline">
-    <a start show href="#" class="px-1 text-center d-block" title="<?= !empty($currentValue) ? 'Edit Subjective' : 'Add Subjective'?>">
-        <i class="fa <?= !empty($currentValue) ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
-    </a>
-    <form url="/api/visitPoint/<?= $point ? 'upsertChildReview' : 'addTopLevel' ?>"
-          class="mcp-theme-1 frm-review-plan-lifestyle frm-review-plan-behavior" right>
-
-        <?php if($point): ?>
-            <input type="hidden" name="uid" value="<?= $point->uid ?>">
-            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
-        <?php else: ?>
-            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-            <input type="hidden" name="category" value="<?= $p['category'] ?>">
-            <input type="hidden" name="additionReasonCategory" value="ON_INTAKE">
-        <?php endif; ?>
-
-        <?php if ($point): ?>
-            <input type="hidden" name="data">
-        <?php else: ?>
-            <input type="hidden" name="childReviewData">
-        <?php endif; ?>
-
-        <?php if($previousValue): ?>
-            <div class="mb-2">
-                <div class="d-flex align-items-baseline mb-1">
-                    <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?>)</span>
-                </div>
-                <div class="p-2 bg-light border inline-html-container">
-                    <?php $review = $previousValue; ?>
-                    <?php include(resource_path('views/app/patient/segment-templates/_child_review/behavior/' . $p['category'] . '/view-review.php')); ?>
-                </div>
-            </div>
-        <?php endif; ?>
-
-        <p class="mb-2"><b>Self Monitoring</b></p>
+<div class="mb-2 d-flex align-items-center">
+    <label class="my-0 mr-2">Current number of weigh-ins per week:</label>
+    <input type="text" data-name="weighInsPerWeek" class="form-control form-control-sm min-width-unset width-100px" value="<?= @($currentValue->weighInsPerWeek) ?>">
+</div>
 
-        <div class="mb-2 d-flex align-items-center">
-            <label class="my-0 mr-2">Current number of weigh-ins per week:</label>
-            <input type="text" data-name="weighInsPerWeek" class="form-control form-control-sm min-width-unset width-100px" value="<?= @($currentValue->weighInsPerWeek) ?>">
+<div class="mb-2">
+    <label class="mb-2 font-weight-bold text-secondary">Currently tracking:</label>
+    <div class="row mb-1">
+        <div class="col-4">
+            <label class="d-flex align-items-center mb-1">
+                <input type="checkbox" data-name="tracking->calorieIntake" <?= @($currentValue->tracking->calorieIntake) ? 'checked' : ''?>>
+                <span class="ml-2">Calorie Intake</span>
+            </label>
         </div>
-
-        <div class="mb-2">
-            <label class="mb-2 font-weight-bold text-secondary">Currently tracking:</label>
-            <div class="row mb-1">
-                <div class="col-4">
-                    <label class="d-flex align-items-center mb-1">
-                        <input type="checkbox" data-name="tracking->calorieIntake" <?= @($currentValue->tracking->calorieIntake) ? 'checked' : ''?>>
-                        <span class="ml-2">Calorie Intake</span>
-                    </label>
-                </div>
-                <div class="col-4">
-                    <label class="d-flex align-items-center mb-1">
-                        <input type="checkbox" data-name="tracking->dailyCarbIntake" <?= @($currentValue->tracking->dailyCarbIntake) ? 'checked' : ''?>>
-                        <span class="ml-2">Daily Carb Intake</span>
-                    </label>
-                </div>
-                <div class="col-4">
-                    <label class="d-flex align-items-center mb-1">
-                        <input type="checkbox" data-name="tracking->portionSize" <?= @($currentValue->tracking->portionSize) ? 'checked' : ''?>>
-                        <span class="ml-2">Portion Size</span>
-                    </label>
-                </div>
-            </div>
-            <div class="row">
-                <div class="col-4">
-                    <label class="d-flex align-items-center mb-1">
-                        <input type="checkbox" data-name="tracking->eatingSpeed" <?= @($currentValue->tracking->eatingSpeed) ? 'checked' : ''?>>
-                        <span class="ml-2">Eating Speed</span>
-                    </label>
-                </div>
-                <div class="col-8">
-                    <label class="d-flex align-items-center mb-1">
-                        <input type="checkbox" data-name="tracking->other" <?= @($currentValue->tracking->other) ? 'checked' : ''?>>
-                        <span class="ml-2">Other</span>
-                        <input if-tracking-other type="text" class="form-control form-control-sm min-width-unset flex-grow-1 ml-2" data-name="tracking->otherDetail" value="<?= @($currentValue->tracking->otherDetail) ?>">
-                    </label>
-                </div>
-            </div>
+        <div class="col-4">
+            <label class="d-flex align-items-center mb-1">
+                <input type="checkbox" data-name="tracking->dailyCarbIntake" <?= @($currentValue->tracking->dailyCarbIntake) ? 'checked' : ''?>>
+                <span class="ml-2">Daily Carb Intake</span>
+            </label>
         </div>
-
-        <div class="mb-2">
-            <label class="mb-2 font-weight-bold text-secondary">Current food monitoring:</label>
-            <div class="row">
-                <div class="col-4">
-                    <label class="d-flex align-items-center mb-1">
-                        <input type="checkbox" data-name="foodMonitoring->phoneTracker" <?= @($currentValue->foodMonitoring->phoneTracker) ? 'checked' : ''?>>
-                        <img src="/img/behavior-rx/phone-tracker.png" class="icon-nutrition-rx-md mx-2">
-                        <span class="">Phone Tracker</span>
-                    </label>
-                </div>
-                <div class="col-4">
-                    <label class="d-flex align-items-center mb-1">
-                        <input type="checkbox" data-name="foodMonitoring->dailyFoodLog" <?= @($currentValue->foodMonitoring->dailyFoodLog) ? 'checked' : ''?>>
-                        <img src="/img/behavior-rx/food-log.png" class="icon-nutrition-rx-md mx-2">
-                        <span class="">Daily Food Log</span>
-                    </label>
-                </div>
-            </div>
+        <div class="col-4">
+            <label class="d-flex align-items-center mb-1">
+                <input type="checkbox" data-name="tracking->portionSize" <?= @($currentValue->tracking->portionSize) ? 'checked' : ''?>>
+                <span class="ml-2">Portion Size</span>
+            </label>
         </div>
-
-        <div class="mb-2">
-            <label for="" class="mb-1">Memo</label>
-            <div note-rte slim-rte
-                 class="form-group mb-2 border-left border-right rte-holder"
-                 data-container-name="<?= $point ? 'data' : 'childReviewData' ?>"
-                 data-field-name="memo"><?= @($currentValue->memo) ?></div>
+    </div>
+    <div class="row">
+        <div class="col-4">
+            <label class="d-flex align-items-center mb-1">
+                <input type="checkbox" data-name="tracking->eatingSpeed" <?= @($currentValue->tracking->eatingSpeed) ? 'checked' : ''?>>
+                <span class="ml-2">Eating Speed</span>
+            </label>
         </div>
-
-        <div>
-            <button type="submit"  class="btn btn-sm btn-primary mr-2">Save</button>
-            <button cancel class="btn btn-sm btn-default border">Cancel</button>
+        <div class="col-8">
+            <label class="d-flex align-items-center mb-1">
+                <input type="checkbox" data-name="tracking->other" <?= @($currentValue->tracking->other) ? 'checked' : ''?>>
+                <span class="ml-2">Other</span>
+                <input if-tracking-other type="text" class="form-control form-control-sm min-width-unset flex-grow-1 ml-2" data-name="tracking->otherDetail" value="<?= @($currentValue->tracking->otherDetail) ?>">
+            </label>
         </div>
-    </form>
+    </div>
 </div>
-<?php if(!empty($currentValue)): ?>
-    <div visit-moe relative class="d-inline">
-        <a start show href="#" class="px-1 text-center d-block" title="Delete Subjective">
-            <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">Delete this subjective?</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 class="mb-2">
+    <label class="mb-2 font-weight-bold text-secondary">Current food monitoring:</label>
+    <div class="row">
+        <div class="col-4">
+            <label class="d-flex align-items-center mb-1">
+                <input type="checkbox" data-name="foodMonitoring->phoneTracker" <?= @($currentValue->foodMonitoring->phoneTracker) ? 'checked' : ''?>>
+                <img src="/img/behavior-rx/phone-tracker.png" class="icon-nutrition-rx-md mx-2">
+                <span class="">Phone Tracker</span>
+            </label>
+        </div>
+        <div class="col-4">
+            <label class="d-flex align-items-center mb-1">
+                <input type="checkbox" data-name="foodMonitoring->dailyFoodLog" <?= @($currentValue->foodMonitoring->dailyFoodLog) ? 'checked' : ''?>>
+                <img src="/img/behavior-rx/food-log.png" class="icon-nutrition-rx-md mx-2">
+                <span class="">Daily Food Log</span>
+            </label>
+        </div>
     </div>
-<?php endif; ?>
+</div>
 
+<div class="mb-2">
+    <label for="" class="mb-1">Memo</label>
+    <div note-rte slim-rte
+         class="form-group mb-2 border-left border-right rte-holder"
+         data-container-name="<?= $point ? 'data' : 'childReviewData' ?>"
+         data-field-name="memo"><?= @($currentValue->memo) ?></div>
+</div>

+ 11 - 106
resources/views/app/patient/segment-templates/_child_review/behavior/SLEEP_HABITS/edit-review.php

@@ -1,109 +1,14 @@
-<?php
+<p class="mb-2"><b>Sleep Habits</b></p>
 
-/*
-Format:
-{
-    hoursOfSleep: number,
-    memo: text
-}
- */
-
-$currentValue = '';
-$previousValue = '';
-$previousChildReview = null;
-if (@$point) {
-    if ($point->lastChildReview && $point->last_child_review_point_scoped_note_id === $note->id) {
-        $currentValue = json_decode($point->lastChildReview->data);
-        $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) {
-            $previousValue = json_decode($previousChildReview->data);
-        }
-    }
-    else {
-        $previousChildReview = \App\Models\Point::where('parent_point_id', $point->id)
-            ->where('category', 'REVIEW')
-            ->orderBy('id', 'DESC')
-            ->first();
-        if($previousChildReview && $previousChildReview->data) {
-            $previousValue = json_decode($previousChildReview->data);
-        }
-    }
-}
-?>
-<div visit-moe fixed-center largest relative class="d-inline">
-    <a start show href="#" class="px-1 text-center d-block" title="<?= !empty($currentValue) ? 'Edit Subjective' : 'Add Subjective'?>">
-        <i class="fa <?= !empty($currentValue) ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
-    </a>
-    <form url="/api/visitPoint/<?= $point ? 'upsertChildReview' : 'addTopLevel' ?>"
-          class="mcp-theme-1 frm-review-plan-lifestyle frm-review-plan-behavior" right>
-
-        <?php if($point): ?>
-            <input type="hidden" name="uid" value="<?= $point->uid ?>">
-            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
-        <?php else: ?>
-            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-            <input type="hidden" name="category" value="<?= $p['category'] ?>">
-            <input type="hidden" name="additionReasonCategory" value="ON_INTAKE">
-        <?php endif; ?>
-
-        <?php if ($point): ?>
-            <input type="hidden" name="data">
-        <?php else: ?>
-            <input type="hidden" name="childReviewData">
-        <?php endif; ?>
-
-        <?php if($previousValue): ?>
-            <div class="mb-2">
-                <div class="d-flex align-items-baseline mb-1">
-                    <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?>)</span>
-                </div>
-                <div class="p-2 bg-light border inline-html-container">
-                    <?php $review = $previousValue; ?>
-                    <?php include(resource_path('views/app/patient/segment-templates/_child_review/behavior/' . $p['category'] . '/view-review.php')); ?>
-                </div>
-            </div>
-        <?php endif; ?>
-
-        <p class="mb-2"><b>Sleep Habits</b></p>
-
-        <div class="mb-2 d-flex align-items-center">
-            <label class="my-0 mr-2">Current hours of sleep:</label>
-            <input type="text" data-name="hoursOfSleep" class="form-control form-control-sm min-width-unset width-100px" value="<?= @($currentValue->hoursOfSleep) ?>">
-        </div>
-
-        <div class="mb-2">
-            <label for="" class="mb-1">Memo</label>
-            <div note-rte slim-rte
-                 class="form-group mb-2 border-left border-right rte-holder"
-                 data-container-name="<?= $point ? 'data' : 'childReviewData' ?>"
-                 data-field-name="memo"><?= @($currentValue->memo) ?></div>
-        </div>
-
-        <div>
-            <button type="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 class="mb-2 d-flex align-items-center">
+    <label class="my-0 mr-2">Current hours of sleep:</label>
+    <input type="text" data-name="hoursOfSleep" class="form-control form-control-sm min-width-unset width-100px" value="<?= @($currentValue->hoursOfSleep) ?>">
 </div>
-<?php if(!empty($currentValue)): ?>
-    <div visit-moe relative class="d-inline">
-        <a start show href="#" class="px-1 text-center d-block" title="Delete Subjective">
-            <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">Delete this subjective?</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 class="mb-2">
+    <label for="" class="mb-1">Memo</label>
+    <div note-rte slim-rte
+         class="form-group mb-2 border-left border-right rte-holder"
+         data-container-name="<?= $point ? 'data' : 'childReviewData' ?>"
+         data-field-name="memo"><?= @($currentValue->memo) ?></div>
+</div>

+ 15 - 0
resources/views/app/patient/segment-templates/_child_review/delete-review.php

@@ -0,0 +1,15 @@
+<div visit-moe relative class="d-block">
+    <a start show href="#" class="px-1" title="Delete Subjective">
+        Delete Subjective
+    </a>
+    <form url="/api/visitPoint/destroyCurrentChildReview" class="mcp-theme-1">
+        <input type="hidden" name="uid" value="<?= $point->uid ?>">
+
+        <p class="mb-2">Delete this subjective?</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>

+ 1 - 1
resources/views/app/patient/segment-templates/_child_review/edit-review.php

@@ -48,7 +48,7 @@ else {
         <?php if($previousValue): ?>
             <div class="mb-2">
                 <div class="d-flex align-items-baseline mb-1">
-                    <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?>) (click to copy)</span>
+                    <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?> (click to copy)</span>
                 </div>
                 <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
             </div>

+ 186 - 310
resources/views/app/patient/segment-templates/_child_review/exercise/AEROBIC_ACTIVITY/edit-review.php

@@ -1,315 +1,191 @@
-<?php
+<p class="mb-2"><b>Current Aerobic Activity</b></p>
 
-/*
-Format:
-{
-    active: true/false,
-    walk: {
-        active: true/false,
-        frequency: 1..7,
-        intensity: light/moderate/vigorous,
-        time: number,
-    },
-    jog: {
-        active: true/false,
-        frequency: 1..7,
-        intensity: light/moderate/vigorous,
-        time: number,
-    },
-    elliptical: {
-        active: true/false,
-        frequency: 1..7,
-        intensity: light/moderate/vigorous,
-        time: number,
-    },
-    swim: {
-        active: true/false,
-        frequency: 1..7,
-        intensity: light/moderate/vigorous,
-        time: number,
-    },
-    bike: {
-        active: true/false,
-        frequency: 1..7,
-        intensity: light/moderate/vigorous,
-        time: number,
-    },
-    memo: text
-}
- */
+<label class="mb-2 d-flex align-items-center">
+    <input type="checkbox" data-name="active" <?= @($currentValue->active) ? 'checked' : ''?>>
+    <span class="ml-2">Any current aerobic activities?</span>
+</label>
 
-$currentValue = '';
-$previousValue = '';
-$previousChildReview = null;
-if (@$point) {
-    if ($point->lastChildReview && $point->last_child_review_point_scoped_note_id === $note->id) {
-        $currentValue = json_decode($point->lastChildReview->data);
-        $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) {
-            $previousValue = json_decode($previousChildReview->data);
-        }
-    }
-    else {
-        $previousChildReview = \App\Models\Point::where('parent_point_id', $point->id)
-            ->where('category', 'REVIEW')
-            ->orderBy('id', 'DESC')
-            ->first();
-        if($previousChildReview && $previousChildReview->data) {
-            $previousValue = json_decode($previousChildReview->data);
-        }
-    }
-}
-?>
-<div visit-moe fixed-center largest relative class="d-inline">
-    <a start show href="#" class="px-1 text-center d-block" title="<?= !empty($currentValue) ? 'Edit Subjective' : 'Add Subjective'?>">
-        <i class="fa <?= !empty($currentValue) ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
-    </a>
-    <form url="/api/visitPoint/<?= $point ? 'upsertChildReview' : 'addTopLevel' ?>"
-          class="mcp-theme-1 frm-review-plan-lifestyle frm-review-plan-exercise" right>
-
-        <?php if($point): ?>
-            <input type="hidden" name="uid" value="<?= $point->uid ?>">
-            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
-        <?php else: ?>
-            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-            <input type="hidden" name="category" value="<?= $p['category'] ?>">
-            <input type="hidden" name="additionReasonCategory" value="ON_INTAKE">
-        <?php endif; ?>
-
-        <?php if ($point): ?>
-            <input type="hidden" name="data">
-        <?php else: ?>
-            <input type="hidden" name="childReviewData">
-        <?php endif; ?>
-
-        <?php if($previousValue): ?>
-            <div class="mb-2">
-                <div class="d-flex align-items-baseline mb-1">
-                    <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?>)</span>
-                </div>
-                <div class="p-2 bg-light border inline-html-container">
-                    <?php $review = $previousValue; ?>
-                    <?php include(resource_path('views/app/patient/segment-templates/_child_review/exercise/' . $p['category'] . '/view-review.php')); ?>
-                </div>
+<table if-active class="table table-sm table-bordered" style="table-layout: fixed">
+    <tbody>
+    <tr>
+        <td class="align-middle">Activity</td>
+        <td class="text-left">
+            <div class="d-flex align-items-center">
+                <input type="checkbox" class="d-none" data-name="walk->active" <?= @($currentValue->walk->active) ? 'checked' : '' ?>>
+                <img src="/img/exercise-rx/walk.png" class="icon-nutrition-rx-row mx-1 <?= @($currentValue->walk->active) ? '' : 'opacity-35' ?>">
+                <button data-type="walk" class="btn-toggle-activity flex-grow-1 shadow-none btn btn-sm <?= @($currentValue->walk->active) ? 'btn-info' : 'btn-default border' ?>">
+                    Walk
+                </button>
             </div>
-        <?php endif; ?>
-
-        <p class="mb-2"><b>Current Aerobic Activity</b></p>
-
-        <label class="mb-2 d-flex align-items-center">
-            <input type="checkbox" data-name="active" <?= @($currentValue->active) ? 'checked' : ''?>>
-            <span class="ml-2">Any current aerobic activities?</span>
-        </label>
-
-        <table if-active class="table table-sm table-bordered" style="table-layout: fixed">
-            <tbody>
-            <tr>
-                <td class="align-middle">Activity</td>
-                <td class="text-left">
-                    <div class="d-flex align-items-center">
-                        <input type="checkbox" class="d-none" data-name="walk->active" <?= @($currentValue->walk->active) ? 'checked' : '' ?>>
-                        <img src="/img/exercise-rx/walk.png" class="icon-nutrition-rx-row mx-1 <?= @($currentValue->walk->active) ? '' : 'opacity-35' ?>">
-                        <button data-type="walk" class="btn-toggle-activity flex-grow-1 shadow-none btn btn-sm <?= @($currentValue->walk->active) ? 'btn-info' : 'btn-default border' ?>">
-                            Walk
-                        </button>
-                    </div>
-                </td>
-                <td class="text-left">
-                    <div class="d-flex align-items-center">
-                        <input type="checkbox" class="d-none" data-name="jog->active" <?= @($currentValue->jog->active) ? 'checked' : '' ?>>
-                        <img src="/img/exercise-rx/jog.png" class="icon-nutrition-rx-row mx-1 <?= @($currentValue->jog->active) ? '' : 'opacity-35' ?>">
-                        <button data-type="jog" class="btn-toggle-activity flex-grow-1 shadow-none btn btn-sm <?= @($currentValue->jog->active) ? 'btn-info' : 'btn-default border' ?>">
-                            Jog
-                        </button>
-                    </div>
-                </td>
-                <td class="text-left">
-                    <div class="d-flex align-items-center">
-                        <input type="checkbox" class="d-none" data-name="elliptical->active" <?= @($currentValue->elliptical->active) ? 'checked' : '' ?>>
-                        <img src="/img/exercise-rx/elliptical.png" class="icon-nutrition-rx-row mx-1 <?= @($currentValue->elliptical->active) ? '' : 'opacity-35' ?>">
-                        <button data-type="elliptical" class="btn-toggle-activity flex-grow-1 shadow-none btn btn-sm <?= @($currentValue->elliptical->active) ? 'btn-info' : 'btn-default border' ?>">
-                            Elliptical
-                        </button>
-                    </div>
-                </td>
-                <td class="text-left">
-                    <div class="d-flex align-items-center">
-                        <input type="checkbox" class="d-none" data-name="swim->active" <?= @($currentValue->swim->active) ? 'checked' : '' ?>>
-                        <img src="/img/exercise-rx/swim.png" class="icon-nutrition-rx-row mx-1 <?= @($currentValue->swim->active) ? '' : 'opacity-35' ?>">
-                        <button data-type="swim" class="btn-toggle-activity flex-grow-1 shadow-none btn btn-sm <?= @($currentValue->swim->active) ? 'btn-info' : 'btn-default border' ?>">
-                            Swim
-                        </button>
-                    </div>
-                </td>
-                <td class="text-left">
-                    <div class="d-flex align-items-center">
-                        <input type="checkbox" class="d-none" data-name="bike->active" <?= @($currentValue->bike->active) ? 'checked' : '' ?>>
-                        <img src="/img/exercise-rx/bike.png" class="icon-nutrition-rx-row mx-1 <?= @($currentValue->bike->active) ? '' : 'opacity-35' ?>">
-                        <button data-type="bike" class="btn-toggle-activity flex-grow-1 shadow-none btn btn-sm <?= @($currentValue->bike->active) ? 'btn-info' : 'btn-default border' ?>">
-                            Bike
-                        </button>
-                    </div>
-                </td>
-            </tr>
-            <tr>
-                <td>Frequency (days/wk)</td>
-                <td>
-                    <select if-walk-active class="form-control form-control-sm min-width-unset px-0" data-name="walk->frequency">
-                        <option value="">-- select --</option>
-                        <option value="1" <?= @($currentValue->walk->frequency) == 1 ? 'selected' : ''?>>1 day</option>
-                        <option value="2" <?= @($currentValue->walk->frequency) == 2 ? 'selected' : ''?>>2 days</option>
-                        <option value="3" <?= @($currentValue->walk->frequency) == 3 ? 'selected' : ''?>>3 days</option>
-                        <option value="4" <?= @($currentValue->walk->frequency) == 4 ? 'selected' : ''?>>4 days</option>
-                        <option value="5" <?= @($currentValue->walk->frequency) == 5 ? 'selected' : ''?>>5 days</option>
-                        <option value="6" <?= @($currentValue->walk->frequency) == 6 ? 'selected' : ''?>>6 days</option>
-                        <option value="7" <?= @($currentValue->walk->frequency) == 7 ? 'selected' : ''?>>7 days</option>
-                    </select>
-                </td>
-                <td>
-                    <select if-jog-active class="form-control form-control-sm min-width-unset px-0" data-name="jog->frequency">
-                        <option value="">-- select --</option>
-                        <option value="1" <?= @($currentValue->jog->frequency) == 1 ? 'selected' : ''?>>1 day</option>
-                        <option value="2" <?= @($currentValue->jog->frequency) == 2 ? 'selected' : ''?>>2 days</option>
-                        <option value="3" <?= @($currentValue->jog->frequency) == 3 ? 'selected' : ''?>>3 days</option>
-                        <option value="4" <?= @($currentValue->jog->frequency) == 4 ? 'selected' : ''?>>4 days</option>
-                        <option value="5" <?= @($currentValue->jog->frequency) == 5 ? 'selected' : ''?>>5 days</option>
-                        <option value="6" <?= @($currentValue->jog->frequency) == 6 ? 'selected' : ''?>>6 days</option>
-                        <option value="7" <?= @($currentValue->jog->frequency) == 7 ? 'selected' : ''?>>7 days</option>
-                    </select>
-                </td>
-                <td>
-                    <select if-elliptical-active class="form-control form-control-sm min-width-unset px-0" data-name="elliptical->frequency">
-                        <option value="">-- select --</option>
-                        <option value="1" <?= @($currentValue->elliptical->frequency) == 1 ? 'selected' : ''?>>1 day</option>
-                        <option value="2" <?= @($currentValue->elliptical->frequency) == 2 ? 'selected' : ''?>>2 days</option>
-                        <option value="3" <?= @($currentValue->elliptical->frequency) == 3 ? 'selected' : ''?>>3 days</option>
-                        <option value="4" <?= @($currentValue->elliptical->frequency) == 4 ? 'selected' : ''?>>4 days</option>
-                        <option value="5" <?= @($currentValue->elliptical->frequency) == 5 ? 'selected' : ''?>>5 days</option>
-                        <option value="6" <?= @($currentValue->elliptical->frequency) == 6 ? 'selected' : ''?>>6 days</option>
-                        <option value="7" <?= @($currentValue->elliptical->frequency) == 7 ? 'selected' : ''?>>7 days</option>
-                    </select>
-                </td>
-                <td>
-                    <select if-swim-active class="form-control form-control-sm min-width-unset px-0" data-name="swim->frequency">
-                        <option value="">-- select --</option>
-                        <option value="1" <?= @($currentValue->swim->frequency) == 1 ? 'selected' : ''?>>1 day</option>
-                        <option value="2" <?= @($currentValue->swim->frequency) == 2 ? 'selected' : ''?>>2 days</option>
-                        <option value="3" <?= @($currentValue->swim->frequency) == 3 ? 'selected' : ''?>>3 days</option>
-                        <option value="4" <?= @($currentValue->swim->frequency) == 4 ? 'selected' : ''?>>4 days</option>
-                        <option value="5" <?= @($currentValue->swim->frequency) == 5 ? 'selected' : ''?>>5 days</option>
-                        <option value="6" <?= @($currentValue->swim->frequency) == 6 ? 'selected' : ''?>>6 days</option>
-                        <option value="7" <?= @($currentValue->swim->frequency) == 7 ? 'selected' : ''?>>7 days</option>
-                    </select>
-                </td>
-                <td>
-                    <select if-bike-active class="form-control form-control-sm min-width-unset px-0" data-name="bike->frequency">
-                        <option value="">-- select --</option>
-                        <option value="1" <?= @($currentValue->bike->frequency) == 1 ? 'selected' : ''?>>1 day</option>
-                        <option value="2" <?= @($currentValue->bike->frequency) == 2 ? 'selected' : ''?>>2 days</option>
-                        <option value="3" <?= @($currentValue->bike->frequency) == 3 ? 'selected' : ''?>>3 days</option>
-                        <option value="4" <?= @($currentValue->bike->frequency) == 4 ? 'selected' : ''?>>4 days</option>
-                        <option value="5" <?= @($currentValue->bike->frequency) == 5 ? 'selected' : ''?>>5 days</option>
-                        <option value="6" <?= @($currentValue->bike->frequency) == 6 ? 'selected' : ''?>>6 days</option>
-                        <option value="7" <?= @($currentValue->bike->frequency) == 7 ? 'selected' : ''?>>7 days</option>
-                    </select>
-                </td>
-            </tr>
-            <tr>
-                <td>Intensity</td>
-                <td>
-                    <select if-walk-active class="form-control form-control-sm min-width-unset px-0" data-name="walk->intensity">
-                        <option value="">-- select --</option>
-                        <option value="Light" <?= @($currentValue->walk->intensity) == 'Light' ? 'selected' : ''?>>Light</option>
-                        <option value="Moderate" <?= @($currentValue->walk->intensity) == 'Moderate' ? 'selected' : ''?>>Moderate</option>
-                        <option value="Vigorous" <?= @($currentValue->walk->intensity) == 'Vigorous' ? 'selected' : ''?>>Vigorous</option>
-                    </select>
-                </td>
-                <td>
-                    <select if-jog-active class="form-control form-control-sm min-width-unset px-0" data-name="jog->intensity">
-                        <option value="">-- select --</option>
-                        <option value="Light" <?= @($currentValue->jog->intensity) == 'Light' ? 'selected' : ''?>>Light</option>
-                        <option value="Moderate" <?= @($currentValue->jog->intensity) == 'Moderate' ? 'selected' : ''?>>Moderate</option>
-                        <option value="Vigorous" <?= @($currentValue->jog->intensity) == 'Vigorous' ? 'selected' : ''?>>Vigorous</option>
-                    </select>
-                </td>
-                <td>
-                    <select if-elliptical-active class="form-control form-control-sm min-width-unset px-0" data-name="elliptical->intensity">
-                        <option value="">-- select --</option>
-                        <option value="Light" <?= @($currentValue->elliptical->intensity) == 'Light' ? 'selected' : ''?>>Light</option>
-                        <option value="Moderate" <?= @($currentValue->elliptical->intensity) == 'Moderate' ? 'selected' : ''?>>Moderate</option>
-                        <option value="Vigorous" <?= @($currentValue->elliptical->intensity) == 'Vigorous' ? 'selected' : ''?>>Vigorous</option>
-                    </select>
-                </td>
-                <td>
-                    <select if-swim-active class="form-control form-control-sm min-width-unset px-0" data-name="swim->intensity">
-                        <option value="">-- select --</option>
-                        <option value="Light" <?= @($currentValue->swim->intensity) == 'Light' ? 'selected' : ''?>>Light</option>
-                        <option value="Moderate" <?= @($currentValue->swim->intensity) == 'Moderate' ? 'selected' : ''?>>Moderate</option>
-                        <option value="Vigorous" <?= @($currentValue->swim->intensity) == 'Vigorous' ? 'selected' : ''?>>Vigorous</option>
-                    </select>
-                </td>
-                <td>
-                    <select if-bike-active class="form-control form-control-sm min-width-unset px-0" data-name="bike->intensity">
-                        <option value="">-- select --</option>
-                        <option value="Light" <?= @($currentValue->bike->intensity) == 'Light' ? 'selected' : ''?>>Light</option>
-                        <option value="Moderate" <?= @($currentValue->bike->intensity) == 'Moderate' ? 'selected' : ''?>>Moderate</option>
-                        <option value="Vigorous" <?= @($currentValue->bike->intensity) == 'Vigorous' ? 'selected' : ''?>>Vigorous</option>
-                    </select>
-                </td>
-            </tr>
-            <tr>
-                <td>Time (mins/day)</td>
-                <td>
-                    <input if-walk-active class="form-control form-control-sm min-width-unset px-1" type="text" data-name="walk->time" value="<?= @($currentValue->walk->time) ?>">
-                </td>
-                <td>
-                    <input if-jog-active class="form-control form-control-sm min-width-unset px-1" type="text" data-name="jog->time" value="<?= @($currentValue->jog->time) ?>">
-                </td>
-                <td>
-                    <input if-elliptical-active class="form-control form-control-sm min-width-unset px-1" type="text" data-name="elliptical->time" value="<?= @($currentValue->elliptical->time) ?>">
-                </td>
-                <td>
-                    <input if-swim-active class="form-control form-control-sm min-width-unset px-1" type="text" data-name="swim->time" value="<?= @($currentValue->swim->time) ?>">
-                </td>
-                <td>
-                    <input if-bike-active class="form-control form-control-sm min-width-unset px-1" type="text" data-name="bike->time" value="<?= @($currentValue->bike->time) ?>">
-                </td>
-            </tr>
-            </tbody>
-        </table>
-
-        <div if-active class="mb-2">
-            <label for="" class="mb-1">Memo</label>
-            <div note-rte slim-rte
-                 class="form-group mb-2 border-left border-right rte-holder"
-                 data-container-name="<?= $point ? 'data' : 'childReviewData' ?>"
-                 data-field-name="memo"><?= @($currentValue->memo) ?></div>
-        </div>
-        <div>
-            <button type="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="px-1 text-center d-block" title="Delete Subjective">
-            <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">Delete this subjective?</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>
+        </td>
+        <td class="text-left">
+            <div class="d-flex align-items-center">
+                <input type="checkbox" class="d-none" data-name="jog->active" <?= @($currentValue->jog->active) ? 'checked' : '' ?>>
+                <img src="/img/exercise-rx/jog.png" class="icon-nutrition-rx-row mx-1 <?= @($currentValue->jog->active) ? '' : 'opacity-35' ?>">
+                <button data-type="jog" class="btn-toggle-activity flex-grow-1 shadow-none btn btn-sm <?= @($currentValue->jog->active) ? 'btn-info' : 'btn-default border' ?>">
+                    Jog
+                </button>
+            </div>
+        </td>
+        <td class="text-left">
+            <div class="d-flex align-items-center">
+                <input type="checkbox" class="d-none" data-name="elliptical->active" <?= @($currentValue->elliptical->active) ? 'checked' : '' ?>>
+                <img src="/img/exercise-rx/elliptical.png" class="icon-nutrition-rx-row mx-1 <?= @($currentValue->elliptical->active) ? '' : 'opacity-35' ?>">
+                <button data-type="elliptical" class="btn-toggle-activity flex-grow-1 shadow-none btn btn-sm <?= @($currentValue->elliptical->active) ? 'btn-info' : 'btn-default border' ?>">
+                    Elliptical
+                </button>
             </div>
-        </form>
-    </div>
-<?php endif; ?>
+        </td>
+        <td class="text-left">
+            <div class="d-flex align-items-center">
+                <input type="checkbox" class="d-none" data-name="swim->active" <?= @($currentValue->swim->active) ? 'checked' : '' ?>>
+                <img src="/img/exercise-rx/swim.png" class="icon-nutrition-rx-row mx-1 <?= @($currentValue->swim->active) ? '' : 'opacity-35' ?>">
+                <button data-type="swim" class="btn-toggle-activity flex-grow-1 shadow-none btn btn-sm <?= @($currentValue->swim->active) ? 'btn-info' : 'btn-default border' ?>">
+                    Swim
+                </button>
+            </div>
+        </td>
+        <td class="text-left">
+            <div class="d-flex align-items-center">
+                <input type="checkbox" class="d-none" data-name="bike->active" <?= @($currentValue->bike->active) ? 'checked' : '' ?>>
+                <img src="/img/exercise-rx/bike.png" class="icon-nutrition-rx-row mx-1 <?= @($currentValue->bike->active) ? '' : 'opacity-35' ?>">
+                <button data-type="bike" class="btn-toggle-activity flex-grow-1 shadow-none btn btn-sm <?= @($currentValue->bike->active) ? 'btn-info' : 'btn-default border' ?>">
+                    Bike
+                </button>
+            </div>
+        </td>
+    </tr>
+    <tr>
+        <td>Frequency (days/wk)</td>
+        <td>
+            <select if-walk-active class="form-control form-control-sm min-width-unset px-0" data-name="walk->frequency">
+                <option value="">-- select --</option>
+                <option value="1" <?= @($currentValue->walk->frequency) == 1 ? 'selected' : ''?>>1 day</option>
+                <option value="2" <?= @($currentValue->walk->frequency) == 2 ? 'selected' : ''?>>2 days</option>
+                <option value="3" <?= @($currentValue->walk->frequency) == 3 ? 'selected' : ''?>>3 days</option>
+                <option value="4" <?= @($currentValue->walk->frequency) == 4 ? 'selected' : ''?>>4 days</option>
+                <option value="5" <?= @($currentValue->walk->frequency) == 5 ? 'selected' : ''?>>5 days</option>
+                <option value="6" <?= @($currentValue->walk->frequency) == 6 ? 'selected' : ''?>>6 days</option>
+                <option value="7" <?= @($currentValue->walk->frequency) == 7 ? 'selected' : ''?>>7 days</option>
+            </select>
+        </td>
+        <td>
+            <select if-jog-active class="form-control form-control-sm min-width-unset px-0" data-name="jog->frequency">
+                <option value="">-- select --</option>
+                <option value="1" <?= @($currentValue->jog->frequency) == 1 ? 'selected' : ''?>>1 day</option>
+                <option value="2" <?= @($currentValue->jog->frequency) == 2 ? 'selected' : ''?>>2 days</option>
+                <option value="3" <?= @($currentValue->jog->frequency) == 3 ? 'selected' : ''?>>3 days</option>
+                <option value="4" <?= @($currentValue->jog->frequency) == 4 ? 'selected' : ''?>>4 days</option>
+                <option value="5" <?= @($currentValue->jog->frequency) == 5 ? 'selected' : ''?>>5 days</option>
+                <option value="6" <?= @($currentValue->jog->frequency) == 6 ? 'selected' : ''?>>6 days</option>
+                <option value="7" <?= @($currentValue->jog->frequency) == 7 ? 'selected' : ''?>>7 days</option>
+            </select>
+        </td>
+        <td>
+            <select if-elliptical-active class="form-control form-control-sm min-width-unset px-0" data-name="elliptical->frequency">
+                <option value="">-- select --</option>
+                <option value="1" <?= @($currentValue->elliptical->frequency) == 1 ? 'selected' : ''?>>1 day</option>
+                <option value="2" <?= @($currentValue->elliptical->frequency) == 2 ? 'selected' : ''?>>2 days</option>
+                <option value="3" <?= @($currentValue->elliptical->frequency) == 3 ? 'selected' : ''?>>3 days</option>
+                <option value="4" <?= @($currentValue->elliptical->frequency) == 4 ? 'selected' : ''?>>4 days</option>
+                <option value="5" <?= @($currentValue->elliptical->frequency) == 5 ? 'selected' : ''?>>5 days</option>
+                <option value="6" <?= @($currentValue->elliptical->frequency) == 6 ? 'selected' : ''?>>6 days</option>
+                <option value="7" <?= @($currentValue->elliptical->frequency) == 7 ? 'selected' : ''?>>7 days</option>
+            </select>
+        </td>
+        <td>
+            <select if-swim-active class="form-control form-control-sm min-width-unset px-0" data-name="swim->frequency">
+                <option value="">-- select --</option>
+                <option value="1" <?= @($currentValue->swim->frequency) == 1 ? 'selected' : ''?>>1 day</option>
+                <option value="2" <?= @($currentValue->swim->frequency) == 2 ? 'selected' : ''?>>2 days</option>
+                <option value="3" <?= @($currentValue->swim->frequency) == 3 ? 'selected' : ''?>>3 days</option>
+                <option value="4" <?= @($currentValue->swim->frequency) == 4 ? 'selected' : ''?>>4 days</option>
+                <option value="5" <?= @($currentValue->swim->frequency) == 5 ? 'selected' : ''?>>5 days</option>
+                <option value="6" <?= @($currentValue->swim->frequency) == 6 ? 'selected' : ''?>>6 days</option>
+                <option value="7" <?= @($currentValue->swim->frequency) == 7 ? 'selected' : ''?>>7 days</option>
+            </select>
+        </td>
+        <td>
+            <select if-bike-active class="form-control form-control-sm min-width-unset px-0" data-name="bike->frequency">
+                <option value="">-- select --</option>
+                <option value="1" <?= @($currentValue->bike->frequency) == 1 ? 'selected' : ''?>>1 day</option>
+                <option value="2" <?= @($currentValue->bike->frequency) == 2 ? 'selected' : ''?>>2 days</option>
+                <option value="3" <?= @($currentValue->bike->frequency) == 3 ? 'selected' : ''?>>3 days</option>
+                <option value="4" <?= @($currentValue->bike->frequency) == 4 ? 'selected' : ''?>>4 days</option>
+                <option value="5" <?= @($currentValue->bike->frequency) == 5 ? 'selected' : ''?>>5 days</option>
+                <option value="6" <?= @($currentValue->bike->frequency) == 6 ? 'selected' : ''?>>6 days</option>
+                <option value="7" <?= @($currentValue->bike->frequency) == 7 ? 'selected' : ''?>>7 days</option>
+            </select>
+        </td>
+    </tr>
+    <tr>
+        <td>Intensity</td>
+        <td>
+            <select if-walk-active class="form-control form-control-sm min-width-unset px-0" data-name="walk->intensity">
+                <option value="">-- select --</option>
+                <option value="Light" <?= @($currentValue->walk->intensity) == 'Light' ? 'selected' : ''?>>Light</option>
+                <option value="Moderate" <?= @($currentValue->walk->intensity) == 'Moderate' ? 'selected' : ''?>>Moderate</option>
+                <option value="Vigorous" <?= @($currentValue->walk->intensity) == 'Vigorous' ? 'selected' : ''?>>Vigorous</option>
+            </select>
+        </td>
+        <td>
+            <select if-jog-active class="form-control form-control-sm min-width-unset px-0" data-name="jog->intensity">
+                <option value="">-- select --</option>
+                <option value="Light" <?= @($currentValue->jog->intensity) == 'Light' ? 'selected' : ''?>>Light</option>
+                <option value="Moderate" <?= @($currentValue->jog->intensity) == 'Moderate' ? 'selected' : ''?>>Moderate</option>
+                <option value="Vigorous" <?= @($currentValue->jog->intensity) == 'Vigorous' ? 'selected' : ''?>>Vigorous</option>
+            </select>
+        </td>
+        <td>
+            <select if-elliptical-active class="form-control form-control-sm min-width-unset px-0" data-name="elliptical->intensity">
+                <option value="">-- select --</option>
+                <option value="Light" <?= @($currentValue->elliptical->intensity) == 'Light' ? 'selected' : ''?>>Light</option>
+                <option value="Moderate" <?= @($currentValue->elliptical->intensity) == 'Moderate' ? 'selected' : ''?>>Moderate</option>
+                <option value="Vigorous" <?= @($currentValue->elliptical->intensity) == 'Vigorous' ? 'selected' : ''?>>Vigorous</option>
+            </select>
+        </td>
+        <td>
+            <select if-swim-active class="form-control form-control-sm min-width-unset px-0" data-name="swim->intensity">
+                <option value="">-- select --</option>
+                <option value="Light" <?= @($currentValue->swim->intensity) == 'Light' ? 'selected' : ''?>>Light</option>
+                <option value="Moderate" <?= @($currentValue->swim->intensity) == 'Moderate' ? 'selected' : ''?>>Moderate</option>
+                <option value="Vigorous" <?= @($currentValue->swim->intensity) == 'Vigorous' ? 'selected' : ''?>>Vigorous</option>
+            </select>
+        </td>
+        <td>
+            <select if-bike-active class="form-control form-control-sm min-width-unset px-0" data-name="bike->intensity">
+                <option value="">-- select --</option>
+                <option value="Light" <?= @($currentValue->bike->intensity) == 'Light' ? 'selected' : ''?>>Light</option>
+                <option value="Moderate" <?= @($currentValue->bike->intensity) == 'Moderate' ? 'selected' : ''?>>Moderate</option>
+                <option value="Vigorous" <?= @($currentValue->bike->intensity) == 'Vigorous' ? 'selected' : ''?>>Vigorous</option>
+            </select>
+        </td>
+    </tr>
+    <tr>
+        <td>Time (mins/day)</td>
+        <td>
+            <input if-walk-active class="form-control form-control-sm min-width-unset px-1" type="text" data-name="walk->time" value="<?= @($currentValue->walk->time) ?>">
+        </td>
+        <td>
+            <input if-jog-active class="form-control form-control-sm min-width-unset px-1" type="text" data-name="jog->time" value="<?= @($currentValue->jog->time) ?>">
+        </td>
+        <td>
+            <input if-elliptical-active class="form-control form-control-sm min-width-unset px-1" type="text" data-name="elliptical->time" value="<?= @($currentValue->elliptical->time) ?>">
+        </td>
+        <td>
+            <input if-swim-active class="form-control form-control-sm min-width-unset px-1" type="text" data-name="swim->time" value="<?= @($currentValue->swim->time) ?>">
+        </td>
+        <td>
+            <input if-bike-active class="form-control form-control-sm min-width-unset px-1" type="text" data-name="bike->time" value="<?= @($currentValue->bike->time) ?>">
+        </td>
+    </tr>
+    </tbody>
+</table>
 
+<div if-active class="mb-2">
+    <label for="" class="mb-1">Memo</label>
+    <div note-rte slim-rte
+         class="form-group mb-2 border-left border-right rte-holder"
+         data-container-name="<?= $point ? 'data' : 'childReviewData' ?>"
+         data-field-name="memo"><?= @($currentValue->memo) ?></div>
+</div>

+ 32 - 130
resources/views/app/patient/segment-templates/_child_review/exercise/NEAT/edit-review.php

@@ -1,132 +1,34 @@
-<?php
-
-/*
-Format:
-{
-    active: true/false,
-    parkAway: true/false,
-    stairsInsteadOfElevators: true/false,
-    standInsteadOfSit: true/false,
-    stepsGoals: number,
-    memo: text
-}
- */
-
-$currentValue = '';
-$previousValue = '';
-$previousChildReview = null;
-if (@$point) {
-    if ($point->lastChildReview && $point->last_child_review_point_scoped_note_id === $note->id) {
-        $currentValue = json_decode($point->lastChildReview->data);
-        $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) {
-            $previousValue = json_decode($previousChildReview->data);
-        }
-    }
-    else {
-        $previousChildReview = \App\Models\Point::where('parent_point_id', $point->id)
-            ->where('category', 'REVIEW')
-            ->orderBy('id', 'DESC')
-            ->first();
-        if($previousChildReview && $previousChildReview->data) {
-            $previousValue = json_decode($previousChildReview->data);
-        }
-    }
-}
-?>
-<div visit-moe fixed-center largest relative class="d-inline">
-    <a start show href="#" class="px-1 text-center d-block" title="<?= !empty($currentValue) ? 'Edit Subjective' : 'Add Subjective'?>">
-        <i class="fa <?= !empty($currentValue) ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
-    </a>
-    <form url="/api/visitPoint/<?= $point ? 'upsertChildReview' : 'addTopLevel' ?>"
-          class="mcp-theme-1 frm-review-plan-lifestyle frm-review-plan-exercise" right>
-
-        <?php if($point): ?>
-            <input type="hidden" name="uid" value="<?= $point->uid ?>">
-            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
-        <?php else: ?>
-            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-            <input type="hidden" name="category" value="<?= $p['category'] ?>">
-            <input type="hidden" name="additionReasonCategory" value="ON_INTAKE">
-        <?php endif; ?>
-
-        <?php if ($point): ?>
-            <input type="hidden" name="data">
-        <?php else: ?>
-            <input type="hidden" name="childReviewData">
-        <?php endif; ?>
-
-        <?php if($previousValue): ?>
-            <div class="mb-2">
-                <div class="d-flex align-items-baseline mb-1">
-                    <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?>)</span>
-                </div>
-                <div class="p-2 bg-light border inline-html-container">
-                    <?php $review = $previousValue; ?>
-                    <?php include(resource_path('views/app/patient/segment-templates/_child_review/exercise/' . $p['category'] . '/view-review.php')); ?>
-                </div>
-            </div>
-        <?php endif; ?>
-
-        <p class="mb-2"><b>Current Non-Exercise Activity Time (NEAT)</b></p>
-
-        <label class="mb-2 d-flex align-items-center">
-            <input type="checkbox" data-name="active" <?= @($currentValue->active) ? 'checked' : ''?>>
-            <span class="ml-2">Record Non-Exercise Activity Time (NEAT)</span>
-        </label>
-
-        <div if-active>
-            <label class="mb-2 d-flex align-items-baseline">
-                <input type="checkbox" data-name="parkAway" <?= @($currentValue->parkAway) ? 'checked' : ''?>>
-                <span class="ml-2">Currently parks away from entrances</span>
-            </label>
-            <label class="mb-2 d-flex align-items-baseline">
-                <input type="checkbox" data-name="stairsInsteadOfElevators" <?= @($currentValue->stairsInsteadOfElevators) ? 'checked' : ''?>>
-                <span class="ml-2">Currently takes the stairs instead of elevator/escalator</span>
-            </label>
-            <label class="mb-2 d-flex align-items-baseline">
-                <input type="checkbox" data-name="standInsteadOfSit" <?= @($currentValue->standInsteadOfSit) ? 'checked' : ''?>>
-                <span class="ml-2">Currently prefers standing over sitting</span>
-            </label>
-            <div class="row mb-2">
-                <div class="col-6">
-                    <label class="mb-1">Current steps/day</label>
-                    <input type="text" data-name="stepsGoals" class="form-control form-control-sm" value="<?= @($currentValue->stepsGoals) ?>">
-                </div>
-            </div>
-            <div class="mb-2">
-                <label for="" class="mb-1">Other</label>
-                <div note-rte slim-rte
-                     class="form-group mb-2 border-left border-right rte-holder"
-                     data-container-name="<?= $point ? 'data' : 'childReviewData' ?>"
-                     data-field-name="memo"><?= @($currentValue->memo) ?></div>
-            </div>
+<p class="mb-2"><b>Current Non-Exercise Activity Time (NEAT)</b></p>
+
+<label class="mb-2 d-flex align-items-center">
+    <input type="checkbox" data-name="active" <?= @($currentValue->active) ? 'checked' : ''?>>
+    <span class="ml-2">Record Non-Exercise Activity Time (NEAT)</span>
+</label>
+
+<div if-active>
+    <label class="mb-2 d-flex align-items-baseline">
+        <input type="checkbox" data-name="parkAway" <?= @($currentValue->parkAway) ? 'checked' : ''?>>
+        <span class="ml-2">Currently parks away from entrances</span>
+    </label>
+    <label class="mb-2 d-flex align-items-baseline">
+        <input type="checkbox" data-name="stairsInsteadOfElevators" <?= @($currentValue->stairsInsteadOfElevators) ? 'checked' : ''?>>
+        <span class="ml-2">Currently takes the stairs instead of elevator/escalator</span>
+    </label>
+    <label class="mb-2 d-flex align-items-baseline">
+        <input type="checkbox" data-name="standInsteadOfSit" <?= @($currentValue->standInsteadOfSit) ? 'checked' : ''?>>
+        <span class="ml-2">Currently prefers standing over sitting</span>
+    </label>
+    <div class="row mb-2">
+        <div class="col-6">
+            <label class="mb-1">Current steps/day</label>
+            <input type="text" data-name="stepsGoals" class="form-control form-control-sm" value="<?= @($currentValue->stepsGoals) ?>">
         </div>
-        <div>
-            <button type="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="px-1 text-center d-block" title="Delete Subjective">
-            <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">Delete this subjective?</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 class="mb-2">
+        <label for="" class="mb-1">Other</label>
+        <div note-rte slim-rte
+             class="form-group mb-2 border-left border-right rte-holder"
+             data-container-name="<?= $point ? 'data' : 'childReviewData' ?>"
+             data-field-name="memo"><?= @($currentValue->memo) ?></div>
+    </div>
+</div>

+ 35 - 134
resources/views/app/patient/segment-templates/_child_review/exercise/STRENGTH_TRAINING/edit-review.php

@@ -1,137 +1,38 @@
-<?php
-
-/*
-Format:
-{
-    active: true/false,
-    muscleStrengthening: true/false,
-    allMajorMuscleGroups: true/false,
-    reps: number,
-    sets: number,
-    resistanceBandsBodyWeight: true/false,
-    memo: text
-}
- */
-
-$currentValue = '';
-$previousValue = '';
-$previousChildReview = null;
-if (@$point) {
-    if ($point->lastChildReview && $point->last_child_review_point_scoped_note_id === $note->id) {
-        $currentValue = json_decode($point->lastChildReview->data);
-        $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) {
-            $previousValue = json_decode($previousChildReview->data);
-        }
-    }
-    else {
-        $previousChildReview = \App\Models\Point::where('parent_point_id', $point->id)
-            ->where('category', 'REVIEW')
-            ->orderBy('id', 'DESC')
-            ->first();
-        if($previousChildReview && $previousChildReview->data) {
-            $previousValue = json_decode($previousChildReview->data);
-        }
-    }
-}
-?>
-<div visit-moe fixed-center largest relative class="d-inline">
-    <a start show href="#" class="px-1 text-center d-block" title="<?= !empty($currentValue) ? 'Edit Subjective' : 'Add Subjective'?>">
-        <i class="fa <?= !empty($currentValue) ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
-    </a>
-    <form url="/api/visitPoint/<?= $point ? 'upsertChildReview' : 'addTopLevel' ?>"
-          class="mcp-theme-1 frm-review-plan-lifestyle frm-review-plan-exercise" right>
-
-        <?php if($point): ?>
-            <input type="hidden" name="uid" value="<?= $point->uid ?>">
-            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
-        <?php else: ?>
-            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-            <input type="hidden" name="category" value="<?= $p['category'] ?>">
-            <input type="hidden" name="additionReasonCategory" value="ON_INTAKE">
-        <?php endif; ?>
-
-        <?php if ($point): ?>
-            <input type="hidden" name="data">
-        <?php else: ?>
-            <input type="hidden" name="childReviewData">
-        <?php endif; ?>
-
-        <?php if($previousValue): ?>
-            <div class="mb-2">
-                <div class="d-flex align-items-baseline mb-1">
-                    <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?>)</span>
-                </div>
-                <div class="p-2 bg-light border inline-html-container">
-                    <?php $review = $previousValue; ?>
-                    <?php include(resource_path('views/app/patient/segment-templates/_child_review/exercise/' . $p['category'] . '/view-review.php')); ?>
-                </div>
-            </div>
-        <?php endif; ?>
-
-        <p class="mb-2"><b>Current Strength Training</b></p>
-
-        <label class="mb-2 d-flex align-items-center">
-            <input type="checkbox" data-name="active" <?= @($currentValue->active) ? 'checked' : ''?>>
-            <span class="ml-2">Currently doing strength training?</span>
-        </label>
-
-        <div if-active>
-            <label class="mb-2 d-flex align-items-baseline">
-                <input type="checkbox" data-name="muscleStrengthening" <?= @($currentValue->muscleStrengthening) ? 'checked' : ''?>>
-                <span class="ml-2">Currently doing muscle strengthening exercises on moderate or greater intensity at least two days per week</span>
-            </label>
-            <label class="mb-2 d-flex align-items-baseline">
-                <input type="checkbox" data-name="allMajorMuscleGroups" <?= @($currentValue->allMajorMuscleGroups) ? 'checked' : ''?>>
-                <span class="ml-2">Currently doing exercises to strengthen all major muscle groups: legs, hips, back, chest, abdomen, shoulders and arms</span>
-            </label>
-            <div class="row mb-2">
-                <div class="col-6">
-                    <label class="mb-1">Number of sets for each exercise</label>
-                    <input type="text" data-name="sets" class="form-control form-control-sm" value="<?= @($currentValue->sets) ?>">
-                </div>
-                <div class="col-6">
-                    <label class="mb-1">Number of repetitions per set</label>
-                    <input type="text" data-name="reps" class="form-control form-control-sm" value="<?= @($currentValue->reps) ?>">
-                </div>
-            </div>
-            <label class="mb-2 d-flex align-items-baseline">
-                <input type="checkbox" data-name="resistanceBandsBodyWeight" <?= @($currentValue->resistanceBandsBodyWeight) ? 'checked' : ''?>>
-                <span class="ml-2">Currently using resistance bands or using body weight to do exercises</span>
-            </label>
-            <div if-active class="mb-2">
-                <label for="" class="mb-1">Memo</label>
-                <div note-rte slim-rte
-                     class="form-group mb-2 border-left border-right rte-holder"
-                     data-container-name="<?= $point ? 'data' : 'childReviewData' ?>"
-                     data-field-name="memo"><?= @($currentValue->memo) ?></div>
-            </div>
+<p class="mb-2"><b>Current Strength Training</b></p>
+
+<label class="mb-2 d-flex align-items-center">
+    <input type="checkbox" data-name="active" <?= @($currentValue->active) ? 'checked' : ''?>>
+    <span class="ml-2">Currently doing strength training?</span>
+</label>
+
+<div if-active>
+    <label class="mb-2 d-flex align-items-baseline">
+        <input type="checkbox" data-name="muscleStrengthening" <?= @($currentValue->muscleStrengthening) ? 'checked' : ''?>>
+        <span class="ml-2">Currently doing muscle strengthening exercises on moderate or greater intensity at least two days per week</span>
+    </label>
+    <label class="mb-2 d-flex align-items-baseline">
+        <input type="checkbox" data-name="allMajorMuscleGroups" <?= @($currentValue->allMajorMuscleGroups) ? 'checked' : ''?>>
+        <span class="ml-2">Currently doing exercises to strengthen all major muscle groups: legs, hips, back, chest, abdomen, shoulders and arms</span>
+    </label>
+    <div class="row mb-2">
+        <div class="col-6">
+            <label class="mb-1">Number of sets for each exercise</label>
+            <input type="text" data-name="sets" class="form-control form-control-sm" value="<?= @($currentValue->sets) ?>">
         </div>
-        <div>
-            <button type="submit"  class="btn btn-sm btn-primary mr-2">Save</button>
-            <button cancel class="btn btn-sm btn-default border">Cancel</button>
+        <div class="col-6">
+            <label class="mb-1">Number of repetitions per set</label>
+            <input type="text" data-name="reps" class="form-control form-control-sm" value="<?= @($currentValue->reps) ?>">
         </div>
-    </form>
-</div>
-<?php if(!empty($currentValue)): ?>
-    <div visit-moe relative class="d-inline">
-        <a start show href="#" class="px-1 text-center d-block" title="Delete Subjective">
-            <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">Delete this subjective?</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; ?>
-
+    <label class="mb-2 d-flex align-items-baseline">
+        <input type="checkbox" data-name="resistanceBandsBodyWeight" <?= @($currentValue->resistanceBandsBodyWeight) ? 'checked' : ''?>>
+        <span class="ml-2">Currently using resistance bands or using body weight to do exercises</span>
+    </label>
+    <div if-active class="mb-2">
+        <label for="" class="mb-1">Memo</label>
+        <div note-rte slim-rte
+             class="form-group mb-2 border-left border-right rte-holder"
+             data-container-name="<?= $point ? 'data' : 'childReviewData' ?>"
+             data-field-name="memo"><?= @($currentValue->memo) ?></div>
+    </div>
+</div>

+ 9 - 42
resources/views/app/patient/segment-templates/_child_review/nutrition/DAILY_INTAKE_CALORIES/edit-review.php

@@ -32,12 +32,9 @@ if (@$point) {
     }
 }
 ?>
-<div moe wide class="d-inline">
-    <a start show href="#" class="px-1 text-center d-block" title="<?= !empty($currentValue) ? 'Edit Subjective' : 'Add Subjective'?>">
-        <i class="fa <?= !empty($currentValue) ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
-    </a>
+<div visit-moe wide class="d-block">
     <?php if($point): ?>
-        <form url="/api/visitPoint/upsertChildReview" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
+        <form show url="/api/visitPoint/upsertChildReview" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
             <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
             <input type="hidden" name="data">
@@ -49,7 +46,7 @@ if (@$point) {
             <?php if($previousValue): ?>
                 <div class="mb-2">
                     <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?>) (click to copy)</span>
+                        <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?> (click to copy)</span>
                     </div>
                     <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
                 </div>
@@ -58,52 +55,22 @@ if (@$point) {
             <p class="mb-2"><b>Current Daily Calories</b></p>
 
             <div class="mb-2">
-                <div note-rte
+                <div note-rte slim-rte
                      <?= $segment->segmentTemplate->internal_name === 'intake_problems' ? 'use-shortcuts="hpi,user"' : '' ?>
-                     class="form-group mb-2 border-left border-right rte-holder"
+                     class="form-group mb-0 border-left border-right rte-holder"
                      data-field-name="value"><?= $currentValue ?></div>
             </div>
-            <div>
-                <button type="submit"  class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
         </form>
     <?php else: ?>
-        <form url="/api/visitPoint/addTopLevel" class="mcp-theme-1 frm-add-review-plan-nutrition w-100" left>
-            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-            <input type="hidden" name="category" value="<?= $p['category'] ?>">
-            <input type="hidden" name="additionReasonCategory" value="ON_INTAKE">
-            <input type="hidden" name="data">
-
-            <?php if($previousValue): ?>
-                <div class="mb-2">
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?>) (click to copy)</span>
-                    </div>
-                    <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
-                </div>
-            <?php endif; ?>
 
-            <p class="mb-2"><b>Current Daily Calories</b></p>
-
-            <div class="mb-2">
-                <div note-rte
-                     class="form-group mb-2 border-left border-right rte-holder"
-                     data-field-name="reviewValue"><?= $currentValue ?></div>
-            </div>
-            <div>
-                <button type="submit" class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
-        </form>
     <?php endif; ?>
 </div>
 <?php if(!empty($currentValue)): ?>
-    <div visit-moe relative class="d-inline">
-        <a start show href="#" class="px-1 text-center d-block" title="Delete Subjective">
-            <i class="fa fa-trash-alt text-danger on-hover-opaque"></i>
+    <div visit-moe relative class="d-block">
+        <a start show href="#" class="px-1 text-left" title="Delete Subjective">
+            Delete Subjective
         </a>
-        <form url="/api/visitPoint/destroyCurrentChildReview" class="mcp-theme-1" right>
+        <form url="/api/visitPoint/destroyCurrentChildReview" class="mcp-theme-1">
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
 
             <p class="mb-2">Delete this subjective?</p>

+ 9 - 42
resources/views/app/patient/segment-templates/_child_review/nutrition/DAILY_INTAKE_CARBOHYDRATES/edit-review.php

@@ -32,12 +32,9 @@ if (@$point) {
     }
 }
 ?>
-<div moe wide class="d-inline">
-    <a start show href="#" class="px-1 text-center d-block" title="<?= !empty($currentValue) ? 'Edit Subjective' : 'Add Subjective'?>">
-        <i class="fa <?= !empty($currentValue) ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
-    </a>
+<div visit-moe wide class="d-block">
     <?php if($point): ?>
-        <form url="/api/visitPoint/upsertChildReview" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
+        <form show url="/api/visitPoint/upsertChildReview" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
             <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
             <input type="hidden" name="data">
@@ -49,7 +46,7 @@ if (@$point) {
             <?php if($previousValue): ?>
                 <div class="mb-2">
                     <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?>) (click to copy)</span>
+                        <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?> (click to copy)</span>
                     </div>
                     <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
                 </div>
@@ -58,52 +55,22 @@ if (@$point) {
             <p class="mb-2"><b>Current Carbohydrate Intake (grams)</b></p>
 
             <div class="mb-2">
-                <div note-rte
+                <div note-rte slim-rte
                      <?= $segment->segmentTemplate->internal_name === 'intake_problems' ? 'use-shortcuts="hpi,user"' : '' ?>
-                     class="form-group mb-2 border-left border-right rte-holder"
+                     class="form-group mb-0 border-left border-right rte-holder"
                      data-field-name="value"><?= $currentValue ?></div>
             </div>
-            <div>
-                <button type="submit"  class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
         </form>
     <?php else: ?>
-        <form url="/api/visitPoint/addTopLevel" class="mcp-theme-1 frm-add-review-plan-nutrition w-100" left>
-            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-            <input type="hidden" name="category" value="<?= $p['category'] ?>">
-            <input type="hidden" name="additionReasonCategory" value="ON_INTAKE">
-            <input type="hidden" name="data">
-
-            <?php if($previousValue): ?>
-                <div class="mb-2">
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?>) (click to copy)</span>
-                    </div>
-                    <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
-                </div>
-            <?php endif; ?>
 
-            <p class="mb-2"><b>Current Carbohydrate Intake (grams)</b></p>
-
-            <div class="mb-2">
-                <div note-rte
-                     class="form-group mb-2 border-left border-right rte-holder"
-                     data-field-name="reviewValue"><?= $currentValue ?></div>
-            </div>
-            <div>
-                <button type="submit" class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
-        </form>
     <?php endif; ?>
 </div>
 <?php if(!empty($currentValue)): ?>
-    <div visit-moe relative class="d-inline">
-        <a start show href="#" class="px-1 text-center d-block" title="Delete Subjective">
-            <i class="fa fa-trash-alt text-danger on-hover-opaque"></i>
+    <div visit-moe relative class="d-block">
+        <a start show href="#" class="px-1 text-left" title="Delete Subjective">
+            Delete Subjective
         </a>
-        <form url="/api/visitPoint/destroyCurrentChildReview" class="mcp-theme-1" right>
+        <form url="/api/visitPoint/destroyCurrentChildReview" class="mcp-theme-1">
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
 
             <p class="mb-2">Delete this subjective?</p>

+ 8 - 48
resources/views/app/patient/segment-templates/_child_review/nutrition/FAST_FOOD/edit-review.php

@@ -32,12 +32,9 @@ if (@$point) {
     }
 }
 ?>
-<div moe wide class="d-inline">
-    <a start show href="#" class="px-1 text-center d-block" title="<?= !empty($currentMealsPerWeek) || !empty($currentSelfPreparedMealsPerWeek) ? 'Edit Subjective' : 'Add Subjective'?>">
-        <i class="fa <?= !empty($currentMealsPerWeek) || !empty($currentSelfPreparedMealsPerWeek) ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
-    </a>
+<div visit-moe wide class="d-block">
     <?php if($point): ?>
-        <form url="/api/visitPoint/upsertChildReview" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
+        <form show url="/api/visitPoint/upsertChildReview" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
             <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
             <input type="hidden" name="data">
@@ -49,7 +46,7 @@ if (@$point) {
             <?php if($previousValue): ?>
                 <div class="mb-2">
                     <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?>) (click to copy)</span>
+                        <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?> (click to copy)</span>
                     </div>
                     <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
                 </div>
@@ -65,58 +62,21 @@ if (@$point) {
             <p class="mb-2"><b>Self prepared meals per week</b></p>
 
             <div class="mb-2">
-                <div note-rte slim-rte class="form-group mb-2 border-left border-right rte-holder"
+                <div note-rte slim-rte class="form-group mb-0 border-left border-right rte-holder"
                      data-field-name="selfPrepMealsPerWeek"><?= $currentSelfPreparedMealsPerWeek ?></div>
             </div>
 
-            <div>
-                <button type="submit"  class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
         </form>
     <?php else: ?>
-        <form url="/api/visitPoint/addTopLevel" class="mcp-theme-1 frm-add-review-plan-nutrition w-100" left>
-            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-            <input type="hidden" name="category" value="<?= $p['category'] ?>">
-            <input type="hidden" name="additionReasonCategory" value="ON_INTAKE">
-            <input type="hidden" name="data">
-
-            <?php if($previousValue): ?>
-                <div class="mb-2">
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?>) (click to copy)</span>
-                    </div>
-                    <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
-                </div>
-            <?php endif; ?>
-
-            <p class="mb-2"><b>Current Consumption (meals per week)</b></p>
 
-            <div class="mb-2">
-                <div note-rte slim-rte class="form-group mb-2 border-left border-right rte-holder"
-                     data-field-name="reviewValue__mealsPerWeek"></div>
-            </div>
-
-            <p class="mb-2"><b>Self prepared meals per week</b></p>
-
-            <div class="mb-2">
-                <div note-rte slim-rte class="form-group mb-2 border-left border-right rte-holder"
-                     data-field-name="reviewValue__selfPrepMealsPerWeek"></div>
-            </div>
-
-            <div>
-                <button type="submit" class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
-        </form>
     <?php endif; ?>
 </div>
 <?php if(!empty($currentMealsPerWeek) || !empty($currentSelfPreparedMealsPerWeek)): ?>
-    <div visit-moe relative class="d-inline">
-        <a start show href="#" class="px-1 text-center d-block" title="Delete Subjective">
-            <i class="fa fa-trash-alt text-danger on-hover-opaque"></i>
+    <div visit-moe relative class="d-block">
+        <a start show href="#" class="px-1 text-left" title="Delete Subjective">
+            Delete Subjective
         </a>
-        <form url="/api/visitPoint/destroyCurrentChildReview" class="mcp-theme-1" right>
+        <form url="/api/visitPoint/destroyCurrentChildReview" class="mcp-theme-1">
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
 
             <p class="mb-2">Delete this subjective?</p>

+ 9 - 42
resources/views/app/patient/segment-templates/_child_review/nutrition/HIGH_SUGAR_BEVERAGES/edit-review.php

@@ -32,12 +32,9 @@ if (@$point) {
     }
 }
 ?>
-<div moe wide class="d-inline">
-    <a start show href="#" class="px-1 text-center d-block" title="<?= !empty($currentValue) ? 'Edit Subjective' : 'Add Subjective'?>">
-        <i class="fa <?= !empty($currentValue) ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
-    </a>
+<div visit-moe wide class="d-block">
     <?php if($point): ?>
-        <form url="/api/visitPoint/upsertChildReview" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
+        <form show url="/api/visitPoint/upsertChildReview" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
             <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
             <input type="hidden" name="data">
@@ -49,7 +46,7 @@ if (@$point) {
             <?php if($previousValue): ?>
                 <div class="mb-2">
                     <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?>) (click to copy)</span>
+                        <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?> (click to copy)</span>
                     </div>
                     <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
                 </div>
@@ -58,52 +55,22 @@ if (@$point) {
             <p class="mb-2"><b>Current Consumption (soda, sweet-tea, coffee, juice, etc.)</b></p>
 
             <div class="mb-2">
-                <div note-rte
+                <div note-rte slim-rte
                      <?= $segment->segmentTemplate->internal_name === 'intake_problems' ? 'use-shortcuts="hpi,user"' : '' ?>
-                     class="form-group mb-2 border-left border-right rte-holder"
+                     class="form-group mb-0 border-left border-right rte-holder"
                      data-field-name="value"><?= $currentValue ?></div>
             </div>
-            <div>
-                <button type="submit" class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
         </form>
     <?php else: ?>
-        <form url="/api/visitPoint/addTopLevel" class="mcp-theme-1 frm-add-review-plan-nutrition w-100" left>
-            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-            <input type="hidden" name="category" value="<?= $p['category'] ?>">
-            <input type="hidden" name="additionReasonCategory" value="ON_INTAKE">
-            <input type="hidden" name="data">
-
-            <?php if($previousValue): ?>
-                <div class="mb-2">
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?>) (click to copy)</span>
-                    </div>
-                    <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
-                </div>
-            <?php endif; ?>
 
-            <p class="mb-2"><b>Current Consumption (soda, sweet-tea, coffee, juice, etc.)</b></p>
-
-            <div class="mb-2">
-                <div note-rte
-                     class="form-group mb-2 border-left border-right rte-holder"
-                     data-field-name="reviewValue"><?= $currentValue ?></div>
-            </div>
-            <div>
-                <button type="submit" class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
-        </form>
     <?php endif; ?>
 </div>
 <?php if(!empty($currentValue)): ?>
-    <div visit-moe relative class="d-inline">
-        <a start show href="#" class="px-1 text-center d-block" title="Delete Subjective">
-            <i class="fa fa-trash-alt text-danger on-hover-opaque"></i>
+    <div visit-moe relative class="d-block">
+        <a start show href="#" class="px-1 text-left" title="Delete Subjective">
+            Delete Subjective
         </a>
-        <form url="/api/visitPoint/destroyCurrentChildReview" class="mcp-theme-1" right>
+        <form url="/api/visitPoint/destroyCurrentChildReview" class="mcp-theme-1">
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
 
             <p class="mb-2">Delete this subjective?</p>

+ 9 - 42
resources/views/app/patient/segment-templates/_child_review/nutrition/PORTION_SIZES/edit-review.php

@@ -32,12 +32,9 @@ if (@$point) {
     }
 }
 ?>
-<div moe wide class="d-inline">
-    <a start show href="#" class="px-1 text-center d-block" title="<?= !empty($currentValue) ? 'Edit Subjective' : 'Add Subjective'?>">
-        <i class="fa <?= !empty($currentValue) ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
-    </a>
+<div visit-moe wide class="d-block">
     <?php if($point): ?>
-        <form url="/api/visitPoint/upsertChildReview" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
+        <form show url="/api/visitPoint/upsertChildReview" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
             <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
             <input type="hidden" name="data">
@@ -49,7 +46,7 @@ if (@$point) {
             <?php if($previousValue): ?>
                 <div class="mb-2">
                     <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?>) (click to copy)</span>
+                        <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?> (click to copy)</span>
                     </div>
                     <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
                 </div>
@@ -58,52 +55,22 @@ if (@$point) {
             <p class="mb-2"><b>Current average number of servings/meal</b></p>
 
             <div class="mb-2">
-                <div note-rte
+                <div note-rte slim-rte
                      <?= $segment->segmentTemplate->internal_name === 'intake_problems' ? 'use-shortcuts="hpi,user"' : '' ?>
-                     class="form-group mb-2 border-left border-right rte-holder"
+                     class="form-group mb-0 border-left border-right rte-holder"
                      data-field-name="value"><?= $currentValue ?></div>
             </div>
-            <div>
-                <button type="submit"  class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
         </form>
     <?php else: ?>
-        <form url="/api/visitPoint/addTopLevel" class="mcp-theme-1 frm-add-review-plan-nutrition w-100" left>
-            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-            <input type="hidden" name="category" value="<?= $p['category'] ?>">
-            <input type="hidden" name="additionReasonCategory" value="ON_INTAKE">
-            <input type="hidden" name="data">
-
-            <?php if($previousValue): ?>
-                <div class="mb-2">
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?>) (click to copy)</span>
-                    </div>
-                    <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
-                </div>
-            <?php endif; ?>
 
-            <p class="mb-2"><b>Current average number of servings/meal</b></p>
-
-            <div class="mb-2">
-                <div note-rte
-                     class="form-group mb-2 border-left border-right rte-holder"
-                     data-field-name="reviewValue"><?= $currentValue ?></div>
-            </div>
-            <div>
-                <button type="submit" class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
-        </form>
     <?php endif; ?>
 </div>
 <?php if(!empty($currentValue)): ?>
-    <div visit-moe relative class="d-inline">
-        <a start show href="#" class="px-1 text-center d-block" title="Delete Subjective">
-            <i class="fa fa-trash-alt text-danger on-hover-opaque"></i>
+    <div visit-moe relative class="d-block">
+        <a start show href="#" class="px-1 text-left" title="Delete Subjective">
+            Delete Subjective
         </a>
-        <form url="/api/visitPoint/destroyCurrentChildReview" class="mcp-theme-1" right>
+        <form url="/api/visitPoint/destroyCurrentChildReview" class="mcp-theme-1">
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
 
             <p class="mb-2">Delete this subjective?</p>

+ 8 - 48
resources/views/app/patient/segment-templates/_child_review/nutrition/SNACKS/edit-review.php

@@ -32,12 +32,9 @@ if (@$point) {
     }
 }
 ?>
-<div moe wide class="d-inline">
-    <a start show href="#" class="px-1 text-center d-block" title="<?= !empty($currentUnhealthySnacks) || !empty($currentHealthySnacks) ? 'Edit Subjective' : 'Add Subjective'?>">
-        <i class="fa <?= !empty($currentUnhealthySnacks) || !empty($currentHealthySnacks) ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
-    </a>
+<div visit-moe wide class="d-block">
     <?php if($point): ?>
-        <form url="/api/visitPoint/upsertChildReview" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
+        <form show url="/api/visitPoint/upsertChildReview" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
             <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
             <input type="hidden" name="data">
@@ -49,7 +46,7 @@ if (@$point) {
             <?php if($previousValue): ?>
                 <div class="mb-2">
                     <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?>) (click to copy)</span>
+                        <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?> (click to copy)</span>
                     </div>
                     <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
                 </div>
@@ -65,58 +62,21 @@ if (@$point) {
 
             <p class="mb-1"><img class="icon-nutrition-rx-row-sm" src="/img/nutrition-rx/hs.png">&nbsp;Healthy Snacks</p>
             <div class="mb-2">
-                <div note-rte slim-rte class="form-group mb-2 border-left border-right rte-holder"
+                <div note-rte slim-rte class="form-group mb-0 border-left border-right rte-holder"
                      data-field-name="healthySnacks"><?= $currentHealthySnacks ?></div>
             </div>
 
-            <div>
-                <button type="submit"  class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
         </form>
     <?php else: ?>
-        <form url="/api/visitPoint/addTopLevel" class="mcp-theme-1 frm-add-review-plan-nutrition w-100" left>
-            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-            <input type="hidden" name="category" value="<?= $p['category'] ?>">
-            <input type="hidden" name="additionReasonCategory" value="ON_INTAKE">
-            <input type="hidden" name="data">
-
-            <?php if($previousValue): ?>
-                <div class="mb-2">
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?>) (click to copy)</span>
-                    </div>
-                    <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
-                </div>
-            <?php endif; ?>
-
-            <p class="mb-2"><b>Current Consumption</b></p>
 
-            <p class="mb-1"><img class="icon-nutrition-rx-row-sm" src="/img/nutrition-rx/us.png">&nbsp;Unhealthy Snacks</p>
-            <div class="mb-2">
-                <div note-rte slim-rte class="form-group mb-2 border-left border-right rte-holder"
-                     data-field-name="reviewValue__unhealthySnacks"></div>
-            </div>
-
-            <p class="mb-1"><img class="icon-nutrition-rx-row-sm" src="/img/nutrition-rx/hs.png">&nbsp;Healthy Snacks</p>
-            <div class="mb-2">
-                <div note-rte slim-rte class="form-group mb-2 border-left border-right rte-holder"
-                     data-field-name="reviewValue__healthySnacks"></div>
-            </div>
-
-            <div>
-                <button type="submit" class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
-        </form>
     <?php endif; ?>
 </div>
 <?php if(!empty($currentUnhealthySnacks) || !empty($currentHealthySnacks)): ?>
-    <div visit-moe relative class="d-inline">
-        <a start show href="#" class="px-1 text-center d-block" title="Delete Subjective">
-            <i class="fa fa-trash-alt text-danger on-hover-opaque"></i>
+    <div visit-moe relative class="d-block">
+        <a start show href="#" class="px-1 text-left" title="Delete Subjective">
+            Delete Subjective
         </a>
-        <form url="/api/visitPoint/destroyCurrentChildReview" class="mcp-theme-1" right>
+        <form url="/api/visitPoint/destroyCurrentChildReview" class="mcp-theme-1">
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
 
             <p class="mb-2">Delete this subjective?</p>

+ 9 - 42
resources/views/app/patient/segment-templates/_child_review/nutrition/VEGETABLES/edit-review.php

@@ -32,12 +32,9 @@ if (@$point) {
     }
 }
 ?>
-<div moe wide class="d-inline">
-    <a start show href="#" class="px-1 text-center d-block" title="<?= !empty($currentValue) ? 'Edit Subjective' : 'Add Subjective'?>">
-        <i class="fa <?= !empty($currentValue) ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
-    </a>
+<div visit-moe wide class="d-block">
     <?php if($point): ?>
-        <form url="/api/visitPoint/upsertChildReview" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
+        <form show url="/api/visitPoint/upsertChildReview" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
             <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
             <input type="hidden" name="data">
@@ -49,7 +46,7 @@ if (@$point) {
             <?php if($previousValue): ?>
                 <div class="mb-2">
                     <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?>) (click to copy)</span>
+                        <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?> (click to copy)</span>
                     </div>
                     <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
                 </div>
@@ -58,52 +55,22 @@ if (@$point) {
             <p class="mb-2"><b>Current Consumption</b></p>
 
             <div class="mb-2">
-                <div note-rte
+                <div note-rte slim-rte
                      <?= $segment->segmentTemplate->internal_name === 'intake_problems' ? 'use-shortcuts="hpi,user"' : '' ?>
-                     class="form-group mb-2 border-left border-right rte-holder"
+                     class="form-group mb-0 border-left border-right rte-holder"
                      data-field-name="value"><?= $currentValue ?></div>
             </div>
-            <div>
-                <button type="submit"  class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
         </form>
     <?php else: ?>
-        <form url="/api/visitPoint/addTopLevel" class="mcp-theme-1 frm-add-review-plan-nutrition w-100" left>
-            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-            <input type="hidden" name="category" value="<?= $p['category'] ?>">
-            <input type="hidden" name="additionReasonCategory" value="ON_INTAKE">
-            <input type="hidden" name="data">
-
-            <?php if($previousValue): ?>
-                <div class="mb-2">
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?>) (click to copy)</span>
-                    </div>
-                    <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
-                </div>
-            <?php endif; ?>
 
-            <p class="mb-2"><b>Current Consumption</b></p>
-
-            <div class="mb-2">
-                <div note-rte
-                     class="form-group mb-2 border-left border-right rte-holder"
-                     data-field-name="reviewValue"><?= $currentValue ?></div>
-            </div>
-            <div>
-                <button type="submit" class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
-        </form>
     <?php endif; ?>
 </div>
 <?php if(!empty($currentValue)): ?>
-    <div visit-moe relative class="d-inline">
-        <a start show href="#" class="px-1 text-center d-block" title="Delete Subjective">
-            <i class="fa fa-trash-alt text-danger on-hover-opaque"></i>
+    <div visit-moe relative class="d-block">
+        <a start show href="#" class="px-1 text-left" title="Delete Subjective">
+            Delete Subjective
         </a>
-        <form url="/api/visitPoint/destroyCurrentChildReview" class="mcp-theme-1" right>
+        <form url="/api/visitPoint/destroyCurrentChildReview" class="mcp-theme-1">
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
 
             <p class="mb-2">Delete this subjective?</p>

+ 9 - 42
resources/views/app/patient/segment-templates/_child_review/nutrition/WATER_INTAKE/edit-review.php

@@ -32,12 +32,9 @@ if (@$point) {
     }
 }
 ?>
-<div moe wide class="d-inline">
-    <a start show href="#" class="px-1 text-center d-block" title="<?= !empty($currentValue) ? 'Edit Subjective' : 'Add Subjective'?>">
-        <i class="fa <?= !empty($currentValue) ? 'fa-pencil-alt' : 'fa-plus-square'?>"></i>
-    </a>
+<div visit-moe wide class="d-block">
     <?php if($point): ?>
-        <form url="/api/visitPoint/upsertChildReview" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
+        <form show url="/api/visitPoint/upsertChildReview" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
             <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
             <input type="hidden" name="data">
@@ -49,7 +46,7 @@ if (@$point) {
             <?php if($previousValue): ?>
                 <div class="mb-2">
                     <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?>) (click to copy)</span>
+                        <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?> (click to copy)</span>
                     </div>
                     <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
                 </div>
@@ -58,52 +55,22 @@ if (@$point) {
             <p class="mb-2"><b>Current Intake (ounces per day)</b></p>
 
             <div class="mb-2">
-                <div note-rte
+                <div note-rte slim-rte
                      <?= $segment->segmentTemplate->internal_name === 'intake_problems' ? 'use-shortcuts="hpi,user"' : '' ?>
-                     class="form-group mb-2 border-left border-right rte-holder"
+                     class="form-group mb-0 border-left border-right rte-holder"
                      data-field-name="value"><?= $currentValue ?></div>
             </div>
-            <div>
-                <button type="submit"  class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
         </form>
     <?php else: ?>
-        <form url="/api/visitPoint/addTopLevel" class="mcp-theme-1 frm-add-review-plan-nutrition w-100" left>
-            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
-            <input type="hidden" name="category" value="<?= $p['category'] ?>">
-            <input type="hidden" name="additionReasonCategory" value="ON_INTAKE">
-            <input type="hidden" name="data">
-
-            <?php if($previousValue): ?>
-                <div class="mb-2">
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?>) (click to copy)</span>
-                    </div>
-                    <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
-                </div>
-            <?php endif; ?>
 
-            <p class="mb-2"><b>Current Intake (ounces per day)</b></p>
-
-            <div class="mb-2">
-                <div note-rte
-                     class="form-group mb-2 border-left border-right rte-holder"
-                     data-field-name="reviewValue"><?= $currentValue ?></div>
-            </div>
-            <div>
-                <button type="submit" class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
-        </form>
     <?php endif; ?>
 </div>
 <?php if(!empty($currentValue)): ?>
-    <div visit-moe relative class="d-inline">
-        <a start show href="#" class="px-1 text-center d-block" title="Delete Subjective">
-            <i class="fa fa-trash-alt text-danger on-hover-opaque"></i>
+    <div visit-moe relative class="d-block">
+        <a start show href="#" class="px-1 text-left" title="Delete Subjective">
+            Delete Subjective
         </a>
-        <form url="/api/visitPoint/destroyCurrentChildReview" class="mcp-theme-1" right>
+        <form url="/api/visitPoint/destroyCurrentChildReview" class="mcp-theme-1">
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
 
             <p class="mb-2">Delete this subjective?</p>

+ 62 - 102
resources/views/app/patient/wizard-partials/common-script.blade.php

@@ -107,6 +107,8 @@ function __initRTEs(_collection) {
             }
 
             pElem.find('input[name=' + ($(el).attr('data-container-name') ? $(el).attr('data-container-name') : 'data') + ']').val(v);
+
+            $(el).trigger('rich-text-input');
         };
 
         if(!noteRTE.is('[ignore-changes]')) {
@@ -450,108 +452,6 @@ parentSegment.find('.frm-edit-{{$label}}')
     });
 
 // special case for nutrition form handling
-parentSegment.find('.frm-add-review-plan-{{$label}}')
-    .off('submit')
-    .on('submit', function () {
-
-        let form = $(this);
-
-        showMask();
-
-        // add [data-name] values to payload
-        let dataField = form.find('[name="data"]').first();
-        let parsed = null;
-        if(dataField.val()) {
-            parsed = JSON.parse(dataField.val());
-        }
-
-        // store plan content
-        let planContent = parsed && parsed.planValue ? parsed.planValue : '';
-        let reviewContent = parsed && parsed.reviewValue ? parsed.reviewValue : '';
-        if(parsed.planValue) delete parsed.planValue;
-        if(parsed.reviewValue) delete parsed.reviewValue;
-
-        // rich review content
-        let richReviewContent = false;
-        if(parsed) {
-            for(let x in parsed) {
-                if(parsed.hasOwnProperty(x) && x.indexOf('reviewValue__') === 0) {
-                    if(!richReviewContent) richReviewContent = {};
-                    richReviewContent[x.substr(13)] = parsed[x];
-                    delete parsed[x];
-                }
-            }
-        }
-
-        // rich plan content
-        let richPlanContent = false;
-        if(parsed) {
-            for(let x in parsed) {
-                if(parsed.hasOwnProperty(x) && x.indexOf('planValue__') === 0) {
-                    if(!richPlanContent) richPlanContent = {};
-                    richPlanContent[x.substr(11)] = parsed[x];
-                    delete parsed[x];
-                }
-            }
-        }
-
-        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));
-        }
-
-        let payload = {};
-        form.serializeArray().map(x => {payload[x.name] = x.value;});
-        if(richReviewContent !== false) {
-            payload.childReviewData = JSON.stringify(richReviewContent);
-        }
-        else if(!!reviewContent && $.trim($('<div/>').html(reviewContent).text())) {
-            payload.childReviewData = JSON.stringify({
-                value: reviewContent
-            })
-        }
-        if(richPlanContent !== false) {
-            payload.childPlanData = JSON.stringify(richPlanContent);
-        }
-        else if(!!planContent && $.trim($('<div/>').html(planContent).text())) {
-            payload.childPlanData = JSON.stringify({
-                value: planContent
-            })
-        }
-
-        $.post(form.attr('url'), payload, _data => {
-            if(!hasResponseError(_data)) {
-                hideMask();
-                refreshDynamicStagPopup();
-                $('.visit-segment[data-segment-template-name="intake_{{$segment_part}}"]').find('.refresh-segment').trigger('click');
-                $('.visit-segment[data-segment-template-name="plan_{{$segment_part}}"]').find('.refresh-segment').trigger('click');
-            }
-        }, 'json');
-        return false;
-    });
-
 parentSegment.find('.frm-upsert-review-plan-{{$label}}')
     .off('submit')
     .on('submit', function () {
@@ -794,4 +694,64 @@ parentSegment.find('.btn-entry-type')
     });
 parentSegment.find('.btn-entry-type[data-entry-type="Pre-Existing"]').trigger('click');
 
+const debounce = (func, wait) => {
+    let timeout;
+    return function executedFunction(...args) {
+        const later = () => {
+            clearTimeout(timeout);
+            func(...args);
+        };
+        clearTimeout(timeout);
+        timeout = setTimeout(later, wait);
+    };
+};
+
+let debouncedLifestyleSaver = debounce(function(_trigger) {
+    $(_trigger).closest('.stag-popup').find('.autosave-indicator').removeClass('show');
+    $(_trigger).closest('.stag-popup').find('.autosave-indicator.saving').addClass('show');
+    saveVisitForm(_trigger, true, false, () => {
+        $(_trigger).closest('.stag-popup').find('.autosave-indicator').removeClass('show');
+        $(_trigger).closest('.stag-popup').find('.autosave-indicator.saved').addClass('show');
+    });
+}, 500);
+
+// auto save for segments with edit-mode
+$(document).off('input.auto-save-input', '[if-edit-mode] [visit-moe] form input[type="text"]');
+$(document).on('input.auto-save-input', '[if-edit-mode] [visit-moe] form input[type="text"]', function () {
+    if($(this).closest('.point-table').is('.edit')) {
+        debouncedLifestyleSaver(this);
+    }
+});
+$(document).off('change.auto-save-select-change', '[if-edit-mode] [visit-moe] form select');
+$(document).on('change.auto-save-select-change', '[if-edit-mode] [visit-moe] form select', function () {
+    if($(this).closest('.point-table').is('.edit')) {
+        debouncedLifestyleSaver(this);
+    }
+});
+$(document).off('change.auto-save-checkbox-change', '[if-edit-mode] [visit-moe] form input[type="checkbox"]');
+$(document).on('change.auto-save-checkbox-change', '[if-edit-mode] [visit-moe] form input[type="checkbox"]', function () {
+    if($(this).closest('.point-table').is('.edit')) {
+        debouncedLifestyleSaver(this);
+    }
+});
+$(document).off('change.auto-save-radio-change', '[if-edit-mode] [visit-moe] form input[type="radio"]');
+$(document).on('change.auto-save-radio-change', '[if-edit-mode] [visit-moe] form input[type="radio"]', function () {
+    if($(this).closest('.point-table').is('.edit')) {
+        debouncedLifestyleSaver(this);
+    }
+});
+$(document).off('input.auto-save-textarea-input', '[if-edit-mode] [visit-moe] form textarea');
+$(document).on('input.auto-save-textarea-input', '[if-edit-mode] [visit-moe] form textarea', function () {
+    if($(this).closest('.point-table').is('.edit')) {
+        debouncedLifestyleSaver(this);
+    }
+});
+
+$(document).off('rich-text-input.auto-save-rich-text-input', '[if-edit-mode] [visit-moe] form [note-rte]');
+$(document).on('rich-text-input.auto-save-rich-text-input', '[if-edit-mode] [visit-moe] form [note-rte]', function () {
+    if($(this).closest('.point-table').is('.edit')) {
+        debouncedLifestyleSaver(this);
+    }
+});
+
 initStagSuggest();