Jelajahi Sumber

Merge branch 'dev' of rav.triplestart.com:jmudaka/stagfe2

= 3 tahun lalu
induk
melakukan
c46db6de2e
86 mengubah file dengan 4770 tambahan dan 20 penghapusan
  1. 8 0
      app/Http/Controllers/NoteController.php
  2. 13 0
      app/Models/Point.php
  3. 36 5
      public/css/style.css
  4. TEMPAT SAMPAH
      public/img/exercise-rx.png
  5. TEMPAT SAMPAH
      public/img/exercise-rx/bike.png
  6. TEMPAT SAMPAH
      public/img/exercise-rx/elliptical.png
  7. TEMPAT SAMPAH
      public/img/exercise-rx/jog.png
  8. TEMPAT SAMPAH
      public/img/exercise-rx/strength.png
  9. TEMPAT SAMPAH
      public/img/exercise-rx/swim.png
  10. TEMPAT SAMPAH
      public/img/exercise-rx/walk.png
  11. TEMPAT SAMPAH
      public/img/nutrition-rx.png
  12. TEMPAT SAMPAH
      public/img/nutrition-rx/hs.png
  13. TEMPAT SAMPAH
      public/img/nutrition-rx/hsb.png
  14. TEMPAT SAMPAH
      public/img/nutrition-rx/ig.png
  15. TEMPAT SAMPAH
      public/img/nutrition-rx/us.png
  16. TEMPAT SAMPAH
      public/img/nutrition-rx/vc.png
  17. TEMPAT SAMPAH
      public/img/nutrition-rx/wi.png
  18. 12 9
      public/js/mc.js
  19. 1 1
      public/js/shortcut.js
  20. 2 1
      public/js/stag-popup.js
  21. 99 0
      resources/views/app/patient/exercise-center.blade.php
  22. 2 2
      resources/views/app/patient/note/dashboard.blade.php
  23. 20 0
      resources/views/app/patient/note/dashboard_script.blade.php
  24. 126 0
      resources/views/app/patient/nutrition-center.blade.php
  25. 1 1
      resources/views/app/patient/segment-templates/_child_plan/edit-plan.php
  26. 314 0
      resources/views/app/patient/segment-templates/_child_plan/exercise/AEROBIC_ACTIVITY/edit-plan.php
  27. 35 0
      resources/views/app/patient/segment-templates/_child_plan/exercise/AEROBIC_ACTIVITY/last-plan.php
  28. 56 0
      resources/views/app/patient/segment-templates/_child_plan/exercise/AEROBIC_ACTIVITY/view-plan.php
  29. 131 0
      resources/views/app/patient/segment-templates/_child_plan/exercise/NEAT/edit-plan.php
  30. 35 0
      resources/views/app/patient/segment-templates/_child_plan/exercise/NEAT/last-plan.php
  31. 31 0
      resources/views/app/patient/segment-templates/_child_plan/exercise/NEAT/view-plan.php
  32. 136 0
      resources/views/app/patient/segment-templates/_child_plan/exercise/STRENGTH_TRAINING/edit-plan.php
  33. 35 0
      resources/views/app/patient/segment-templates/_child_plan/exercise/STRENGTH_TRAINING/last-plan.php
  34. 36 0
      resources/views/app/patient/segment-templates/_child_plan/exercise/STRENGTH_TRAINING/view-plan.php
  35. 118 0
      resources/views/app/patient/segment-templates/_child_plan/nutrition/DAILY_INTAKE_CALORIES/edit-plan.php
  36. 33 0
      resources/views/app/patient/segment-templates/_child_plan/nutrition/DAILY_INTAKE_CALORIES/last-plan.php
  37. 118 0
      resources/views/app/patient/segment-templates/_child_plan/nutrition/DAILY_INTAKE_CARBOHYDRATES/edit-plan.php
  38. 33 0
      resources/views/app/patient/segment-templates/_child_plan/nutrition/DAILY_INTAKE_CARBOHYDRATES/last-plan.php
  39. 118 0
      resources/views/app/patient/segment-templates/_child_plan/nutrition/FAST_FOOD/edit-plan.php
  40. 33 0
      resources/views/app/patient/segment-templates/_child_plan/nutrition/FAST_FOOD/last-plan.php
  41. 118 0
      resources/views/app/patient/segment-templates/_child_plan/nutrition/HIGH_SUGAR_BEVERAGES/edit-plan.php
  42. 33 0
      resources/views/app/patient/segment-templates/_child_plan/nutrition/HIGH_SUGAR_BEVERAGES/last-plan.php
  43. 118 0
      resources/views/app/patient/segment-templates/_child_plan/nutrition/PORTION_SIZES/edit-plan.php
  44. 33 0
      resources/views/app/patient/segment-templates/_child_plan/nutrition/PORTION_SIZES/last-plan.php
  45. 118 0
      resources/views/app/patient/segment-templates/_child_plan/nutrition/SNACKS/edit-plan.php
  46. 33 0
      resources/views/app/patient/segment-templates/_child_plan/nutrition/SNACKS/last-plan.php
  47. 118 0
      resources/views/app/patient/segment-templates/_child_plan/nutrition/VEGETABLES/edit-plan.php
  48. 33 0
      resources/views/app/patient/segment-templates/_child_plan/nutrition/VEGETABLES/last-plan.php
  49. 118 0
      resources/views/app/patient/segment-templates/_child_plan/nutrition/WATER_INTAKE/edit-plan.php
  50. 33 0
      resources/views/app/patient/segment-templates/_child_plan/nutrition/WATER_INTAKE/last-plan.php
  51. 314 0
      resources/views/app/patient/segment-templates/_child_review/exercise/AEROBIC_ACTIVITY/edit-review.php
  52. 35 0
      resources/views/app/patient/segment-templates/_child_review/exercise/AEROBIC_ACTIVITY/last-review.php
  53. 56 0
      resources/views/app/patient/segment-templates/_child_review/exercise/AEROBIC_ACTIVITY/view-review.php
  54. 131 0
      resources/views/app/patient/segment-templates/_child_review/exercise/NEAT/edit-review.php
  55. 35 0
      resources/views/app/patient/segment-templates/_child_review/exercise/NEAT/last-review.php
  56. 31 0
      resources/views/app/patient/segment-templates/_child_review/exercise/NEAT/view-review.php
  57. 136 0
      resources/views/app/patient/segment-templates/_child_review/exercise/STRENGTH_TRAINING/edit-review.php
  58. 35 0
      resources/views/app/patient/segment-templates/_child_review/exercise/STRENGTH_TRAINING/last-review.php
  59. 36 0
      resources/views/app/patient/segment-templates/_child_review/exercise/STRENGTH_TRAINING/view-review.php
  60. 118 0
      resources/views/app/patient/segment-templates/_child_review/nutrition/DAILY_INTAKE_CALORIES/edit-review.php
  61. 32 0
      resources/views/app/patient/segment-templates/_child_review/nutrition/DAILY_INTAKE_CALORIES/last-review.php
  62. 118 0
      resources/views/app/patient/segment-templates/_child_review/nutrition/DAILY_INTAKE_CARBOHYDRATES/edit-review.php
  63. 32 0
      resources/views/app/patient/segment-templates/_child_review/nutrition/DAILY_INTAKE_CARBOHYDRATES/last-review.php
  64. 131 0
      resources/views/app/patient/segment-templates/_child_review/nutrition/FAST_FOOD/edit-review.php
  65. 33 0
      resources/views/app/patient/segment-templates/_child_review/nutrition/FAST_FOOD/last-review.php
  66. 118 0
      resources/views/app/patient/segment-templates/_child_review/nutrition/HIGH_SUGAR_BEVERAGES/edit-review.php
  67. 32 0
      resources/views/app/patient/segment-templates/_child_review/nutrition/HIGH_SUGAR_BEVERAGES/last-review.php
  68. 118 0
      resources/views/app/patient/segment-templates/_child_review/nutrition/PORTION_SIZES/edit-review.php
  69. 32 0
      resources/views/app/patient/segment-templates/_child_review/nutrition/PORTION_SIZES/last-review.php
  70. 131 0
      resources/views/app/patient/segment-templates/_child_review/nutrition/SNACKS/edit-review.php
  71. 33 0
      resources/views/app/patient/segment-templates/_child_review/nutrition/SNACKS/last-review.php
  72. 118 0
      resources/views/app/patient/segment-templates/_child_review/nutrition/VEGETABLES/edit-review.php
  73. 32 0
      resources/views/app/patient/segment-templates/_child_review/nutrition/VEGETABLES/last-review.php
  74. 118 0
      resources/views/app/patient/segment-templates/_child_review/nutrition/WATER_INTAKE/edit-review.php
  75. 32 0
      resources/views/app/patient/segment-templates/_child_review/nutrition/WATER_INTAKE/last-review.php
  76. 0 0
      resources/views/app/patient/segment-templates/intake_exercise/edit.blade.php
  77. 38 0
      resources/views/app/patient/segment-templates/intake_exercise/summary.blade.php
  78. 0 0
      resources/views/app/patient/segment-templates/intake_nutrition/edit.blade.php
  79. 55 0
      resources/views/app/patient/segment-templates/intake_nutrition/summary.blade.php
  80. 0 0
      resources/views/app/patient/segment-templates/plan_exercise/edit.blade.php
  81. 38 0
      resources/views/app/patient/segment-templates/plan_exercise/summary.blade.php
  82. 0 0
      resources/views/app/patient/segment-templates/plan_nutrition/edit.blade.php
  83. 45 0
      resources/views/app/patient/segment-templates/plan_nutrition/summary.blade.php
  84. 0 1
      resources/views/app/patient/vitals-settings/bmi-management-form.blade.php
  85. 217 0
      resources/views/app/patient/wizard-partials/common-script.blade.php
  86. 3 0
      routes/web.php

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

@@ -398,6 +398,14 @@ class NoteController extends Controller
         return view('app.patient.supplements-reconcile', compact('patient', 'note'));
     }
 
+    public function nutritionCenter(Request $request, Client $patient, Note $note) {
+        return view('app.patient.nutrition-center', compact('patient', 'note'));
+    }
+
+    public function exerciseCenter(Request $request, Client $patient, Note $note) {
+        return view('app.patient.exercise-center', compact('patient', 'note'));
+    }
+
     public function ccmAgreement(Request $request, Note $note) {
         return view('app.patient.note.ccm-agreement', compact('note'));
     }

+ 13 - 0
app/Models/Point.php

@@ -254,6 +254,19 @@ class Point extends Model
         ];
     }
 
+    public static function getOnlyPointOfCategory(Client $_patient, String $_category) {
+        $point = Point
+            ::where('client_id', $_patient->id)
+            ->where('category', $_category)
+            ->first();
+
+        if ($point && $point->data) {
+            $point->data = json_decode($point->data);
+        }
+
+        return $point;
+    }
+
     public static function fillPointStateAndBadge(Point $point, Note $note)
     {
 

+ 36 - 5
public/css/style.css

@@ -192,6 +192,9 @@ body.stag_rhs_collapsed .app-right-panel {
 .mcp-theme-1 .opacity-60 {
     opacity: .6;
 }
+.mcp-theme-1 .opacity-35 {
+    opacity: .35;
+}
 .mcp-theme-1 .overflow-visible {
     overflow: visible;
 }
@@ -446,7 +449,7 @@ body [note-rte][data-field-name="planValue"] {
 body [note-rte][slim-rte] .ql-editor[contenteditable],
 body [note-rte][data-field-name="reviewValue"] .ql-editor[contenteditable],
 body [note-rte][data-field-name="planValue"] .ql-editor[contenteditable] {
-    min-height: 28px !important;
+    min-height: 56px !important;
     padding: .25rem .5rem !important;
 }
 .ql-container p {
@@ -1419,6 +1422,12 @@ span.select2-container.select2-container--default.select2-container--open {
 }
 .stag-popup .stag-popup-title>span {
     font-size: 17px;
+    display: inline-flex;
+    align-items: center;
+}
+.stag-popup .stag-popup-title>span>img {
+    max-height: 26px;
+    margin-right: 8px;
 }
 .fc .other-client {
     box-shadow: 1px 1px 2px deeppink !important;
@@ -1534,6 +1543,9 @@ table.table-edit-sheet .ql-editor[contenteditable] {
 .w-35 {
     width: 35%;
 }
+.w-40 {
+    width: 40%;
+}
 .client-single-dashboard .hide-if-dashboard {
     display: none;
 }
@@ -2098,10 +2110,9 @@ body.in-iframe .main-row > .sidebar {
 }
 [visit-moe][fixed-center] [url]:not([show]) {
     position: fixed !important;
-    top: 50% !important;
-    left: 50% !important;
-    width: 600px;
-    transform: translate(-50%, -50%) !important;
+    top: 200px !important;
+    left: calc(50% - 360px) !important;
+    width: 720px;
 }
 [visit-moe] [url][right] {
     right: 0;
@@ -2113,6 +2124,12 @@ body.in-iframe .main-row > .sidebar {
 [visit-moe][large] form, [visit-moe][large] [url] {
     width: 450px;
 }
+[visit-moe][larger] form, [visit-moe][large] [url] {
+    width: 600px;
+}
+[visit-moe][largest] form, [visit-moe][largest] [url] {
+    width: 750px;
+}
 [visit-moe][bottom] form {
     bottom: 100%;
 }
@@ -2430,4 +2447,18 @@ td.row-selection-highlight:after {
 }
 [stag-collapsible-card][collapsed] .card-body {
     display: none;
+}
+
+/* lifestyle rx specific */
+.border-top-nutrition-rx {
+    border-top: 3px solid #a4d067;
+}
+.border-top-exercise-rx {
+    border-top: 3px solid #43c2cb;
+}
+.icon-nutrition-rx-row {
+    max-height: 18px;
+}
+.icon-nutrition-rx-row-sm {
+    max-height: 14px;
 }

TEMPAT SAMPAH
public/img/exercise-rx.png


TEMPAT SAMPAH
public/img/exercise-rx/bike.png


TEMPAT SAMPAH
public/img/exercise-rx/elliptical.png


TEMPAT SAMPAH
public/img/exercise-rx/jog.png


TEMPAT SAMPAH
public/img/exercise-rx/strength.png


TEMPAT SAMPAH
public/img/exercise-rx/swim.png


TEMPAT SAMPAH
public/img/exercise-rx/walk.png


TEMPAT SAMPAH
public/img/nutrition-rx.png


TEMPAT SAMPAH
public/img/nutrition-rx/hs.png


TEMPAT SAMPAH
public/img/nutrition-rx/hsb.png


TEMPAT SAMPAH
public/img/nutrition-rx/ig.png


TEMPAT SAMPAH
public/img/nutrition-rx/us.png


TEMPAT SAMPAH
public/img/nutrition-rx/vc.png


TEMPAT SAMPAH
public/img/nutrition-rx/wi.png


+ 12 - 9
public/js/mc.js

@@ -453,16 +453,9 @@ function initPatientPresenceIndicator() {
 
 // not really the place for this!
 // find a better place to put this
-window.saveVisitForm = function(_trigger, _silent = false, _close = false, _doneCallback = null) {
-    let form = $(_trigger).closest('form');
-
-    if (!_silent && !form[0].checkValidity()) {
-        form[0].reportValidity();
-        return false;
-    }
-
+window.fillJsonDataField = function(form, field = "data") {
     // add [data-name] values to payload
-    let dataField = form.find('[name="data"]').first();
+    let dataField = form.find('[name="' + field + '"]').first();
     let parsed = null;
     if(dataField.val()) {
         parsed = JSON.parse(dataField.val());
@@ -493,6 +486,16 @@ window.saveVisitForm = function(_trigger, _silent = false, _close = false, _done
     if(parsed) {
         dataField.val(JSON.stringify(parsed));
     }
+}
+window.saveVisitForm = function(_trigger, _silent = false, _close = false, _doneCallback = null) {
+    let form = $(_trigger).closest('form');
+
+    if (!_silent && !form[0].checkValidity()) {
+        form[0].reportValidity();
+        return false;
+    }
+
+    fillJsonDataField(form);
 
     let closeOnSave = false, noteSection = form.closest('.note-section');
     if($(_trigger).closest('[visit-moe]').is('[close-on-save]')) {

+ 1 - 1
public/js/shortcut.js

@@ -126,7 +126,7 @@
                         backtrackAfterApplying = true;
                         strPart = '@';
                         let options = [], noteRTE = $(input).closest('[note-rte]');
-                        let scSets = noteRTE.attr('use-shortcuts') ? noteRTE.attr('use-shortcuts').split(',') : 'user'
+                        let scSets = noteRTE.attr('use-shortcuts') ? noteRTE.attr('use-shortcuts').split(',') : ['user']
                         for (let i = 0; i < scSets.length; i++) {
                             if(window[$.trim(scSets[i]) + 'Shortcuts']) {
                                 options = options.concat(window[$.trim(scSets[i]) + 'Shortcuts']);

+ 2 - 1
public/js/stag-popup.js

@@ -34,6 +34,7 @@ function submitStagPopup(_form) {
     return false;
 }
 function closeStagPopup(_noEvent = false) {
+    hideMoeFormMask();
     if(!stagPopupsQueue.length) return false;
     let popup = stagPopupsQueue[stagPopupsQueue.length - 1];
     let closeAll = !!popup.attr('close-all-with-self');
@@ -121,7 +122,7 @@ function openDynamicStagPopup(_url, initer, title, updateParent, style = '', rep
         }
 
         popup.attr('mc-initer', initer);
-        popup.find('.stag-popup-title>span').text(title);
+        popup.find('.stag-popup-title>span').html(title);
         popup.find('.stag-popup-content-inner').html(_data);
 
         convertContentLinksForInPopupNavigation(popup);

+ 99 - 0
resources/views/app/patient/exercise-center.blade.php

@@ -0,0 +1,99 @@
+<?php
+
+use App\Models\Point;
+use App\Models\Client;
+use App\Models\Note;
+use App\Models\Segment;
+
+/** @var Client $patient */
+/** @var Note $note */
+
+$aerobicActivity = Point::getOnlyPointOfCategory($patient, 'AEROBIC_ACTIVITY');
+$strengthTraining = Point::getOnlyPointOfCategory($patient, 'STRENGTH_TRAINING');
+$neat = Point::getOnlyPointOfCategory($patient, 'NEAT');
+
+$points = [
+    ["category" => 'AEROBIC_ACTIVITY', "name" => 'Aerobic Activity', "point" => $aerobicActivity],
+    ["category" => 'STRENGTH_TRAINING', "name" => 'Strength Training', "point" => $strengthTraining],
+    ["category" => 'NEAT', "name" => 'Non-Exercise Activity Time (NEAT)', "point" => $neat],
+];
+?>
+
+<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">
+
+            @foreach($points as $p)
+                <?php $point = $p['point']; ?>
+                <tr class="point-row" data-uid="{{$point ? $point->uid : ''}}">
+                    <td>
+                        <div class="d-flex align-items-center">
+                            <b class="mr-2">{{$p['name']}}</b>
+                            @if($p['category'] === 'STRENGTH_TRAINING')
+                                <img src="/img/exercise-rx/strength.png" class="icon-nutrition-rx-row" alt="">
+                            @endif
+                        </div>
+                        <div class="text-sm mt-1">
+                        </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">
+                                <?php
+                                $segment = $note->getSegmentByInternalName('intake_exercise');
+                                if($segment) {
+                                    include resource_path('views/app/patient/segment-templates/_child_review/exercise/' . $p['category'] . '/edit-review.php');
+                                }
+                                ?>
+                            </div>
+                        </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">
+                                <?php
+                                $segment = $note->getSegmentByInternalName('plan_exercise');
+                                if($segment) {
+                                    include resource_path('views/app/patient/segment-templates/_child_plan/exercise/' . $p['category'] . '/edit-plan.php');
+                                }
+                                ?>
+                            </div>
+                        </div>
+                    </td>
+                </tr>
+            @endforeach
+
+        </table>
+
+    </div>
+</div>
+<script>
+    (function() {
+        function init() {
+            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)'));
+        }
+        addMCInitializer('exercise-center-{{$note->id}}', init, '#exercise-center-{{$note->id}}');
+    }).call(window);
+</script>

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

@@ -2495,7 +2495,7 @@
                                 <span>Care Team</span>
                             </div>
                         </div>
-                        <div class="nbt-container border-right border-info d-inline-flex align-self-stretch">
+                        <!--<div class="nbt-container border-right border-info d-inline-flex align-self-stretch">
                             <div class="position-relative on-click-menu d-inline-flex align-items-center px-2 py-1">
                                 <span class="">LS <i class="fa fa-caret-up"></i></span>
                                 <div menu bottom class="bg-white border">
@@ -2508,7 +2508,7 @@
                                     <a href="#" class="ls-segment-trigger px-2 py-1 text-nowrap d-block" data-target="lifestyle_stress">Stress</a>
                                 </div>
                             </div>
-                        </div>
+                        </div>-->
                         <div class="nbt-container border-right border-info d-inline-flex align-self-stretch">
                             <div native target="_blank"
                                  class="c-pointer d-inline-flex align-items-center incoming-reports-trigger px-2 py-1"

+ 20 - 0
resources/views/app/patient/note/dashboard_script.blade.php

@@ -155,6 +155,26 @@
                             return false;
                         }
 
+                        if(editParent.is('[data-segment-template-name="plan_nutrition"]') ||
+                            editParent.is('[data-segment-template-name="intake_nutrition"]')) {
+                            openDynamicStagPopup('/nutrition-center/{{$note->client->uid}}/{{$note->uid}}',
+                                'nutrition-center-{{$note->id}}',
+                                '<img src="/img/nutrition-rx.png" class=""/> Nutrition Rx',
+                                false,
+                                "medium-large overflow-visible");
+                            return false;
+                        }
+
+                        if(editParent.is('[data-segment-template-name="plan_exercise"]') ||
+                            editParent.is('[data-segment-template-name="intake_exercise"]')) {
+                            openDynamicStagPopup('/exercise-center/{{$note->client->uid}}/{{$note->uid}}',
+                                'exercise-center-{{$note->id}}',
+                                '<img src="/img/exercise-rx.png" class=""/> Exercise Rx',
+                                false,
+                                "medium-large overflow-visible");
+                            return false;
+                        }
+
                         // OPEN popup for if note-segment-view exists
                         if($('.' + editParent.attr('data-segment-template-name') + '-trigger').length) {
                             $('.' + editParent.attr('data-segment-template-name') + '-trigger').trigger('click');

+ 126 - 0
resources/views/app/patient/nutrition-center.blade.php

@@ -0,0 +1,126 @@
+<?php
+
+use App\Models\Point;
+use App\Models\Client;
+use App\Models\Note;
+use App\Models\Segment;
+
+/** @var Client $patient */
+/** @var Note $note */
+
+$highSugarBeverages = Point::getOnlyPointOfCategory($patient, 'HIGH_SUGAR_BEVERAGES');
+$waterIntake = Point::getOnlyPointOfCategory($patient, 'WATER_INTAKE');
+$fastFood = Point::getOnlyPointOfCategory($patient, 'FAST_FOOD');
+$snacks = Point::getOnlyPointOfCategory($patient, 'SNACKS');
+$vegetables = Point::getOnlyPointOfCategory($patient, 'VEGETABLES');
+$portionSizes = Point::getOnlyPointOfCategory($patient, 'PORTION_SIZES');
+$dailyIntakeCarbohydrates = Point::getOnlyPointOfCategory($patient, 'DAILY_INTAKE_CARBOHYDRATES');
+$dailyIntakeCalories = Point::getOnlyPointOfCategory($patient, 'DAILY_INTAKE_CALORIES');
+
+$points = [
+    ["category" => 'HIGH_SUGAR_BEVERAGES', "name" => 'High Sugar Beverages', "point" => $highSugarBeverages],
+    ["category" => 'WATER_INTAKE', "name" => 'Water Intake', "point" => $waterIntake],
+    ["category" => 'FAST_FOOD', "name" => 'Fast Food', "point" => $fastFood],
+    ["category" => 'SNACKS', "name" => 'Snacks', "point" => $snacks],
+    ["category" => 'VEGETABLES', "name" => 'Vegetables', "point" => $vegetables],
+    ["category" => 'PORTION_SIZES', "name" => 'Portion Sizes', "point" => $portionSizes],
+    ["category" => 'DAILY_INTAKE_CARBOHYDRATES', "name" => 'Daily Intake Carbohydrates', "point" => $dailyIntakeCarbohydrates],
+    ["category" => 'DAILY_INTAKE_CALORIES', "name" => 'Daily Intake Calories', "point" => $dailyIntakeCalories],
+];
+?>
+
+<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">
+
+            @foreach($points as $p)
+                <?php $point = $p['point']; ?>
+                <tr class="point-row" data-uid="{{$point ? $point->uid : ''}}">
+                    <td>
+                        <div class="d-flex align-items-center">
+                            <b class="mr-2">{{$p['name']}}</b>
+                            @if($p['category'] === 'HIGH_SUGAR_BEVERAGES')
+                                <img src="/img/nutrition-rx/hsb.png" class="icon-nutrition-rx-row" alt="">
+                            @elseif($p['category'] === 'WATER_INTAKE')
+                                <img src="/img/nutrition-rx/wi.png" class="icon-nutrition-rx-row" alt="">
+                            @elseif($p['category'] === 'VEGETABLES')
+                                <img src="/img/nutrition-rx/vc.png" class="icon-nutrition-rx-row" alt="">
+                            @elseif($p['category'] === 'DAILY_INTAKE_CARBOHYDRATES' || $p['category'] === 'DAILY_INTAKE_CALORIES')
+                                <img src="/img/nutrition-rx/ig.png" class="icon-nutrition-rx-row" alt="">
+                            @endif
+                        </div>
+                        <div class="text-sm mt-1">
+                            @if($p['category'] === 'HIGH_SUGAR_BEVERAGES')
+                                E.g. soda, sweet tea, coffee, juice, etc.
+                            @elseif($p['category'] === 'WATER_INTAKE')
+                                Ounces per day
+                            @elseif($p['category'] === 'FAST_FOOD')
+                                Meals per week
+                            @elseif($p['category'] === 'PORTION_SIZES')
+                                Servings per meal
+                            @elseif($p['category'] === 'DAILY_INTAKE_CARBOHYDRATES' || $p['category'] === 'DAILY_INTAKE_CALORIES')
+
+                            @endif
+                        </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">
+                                <?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>
+                        </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">
+                                <?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>
+                        </div>
+                    </td>
+                </tr>
+            @endforeach
+
+        </table>
+
+    </div>
+</div>
+<script>
+    (function() {
+        function init() {
+            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)'));
+        }
+        addMCInitializer('nutrition-center-{{$note->id}}', init, '#nutrition-center-{{$note->id}}');
+    }).call(window);
+</script>

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

@@ -30,7 +30,7 @@ else {
     <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/upsertChildPlan" class="mcp-theme-1" left>
+    <form url="/api/visitPoint/upsertChildPlan" class="mcp-theme-1 w-100" left>
         <input type="hidden" name="uid" value="<?= $point->uid ?>">
         <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
         <input type="hidden" name="data">

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

@@ -0,0 +1,314 @@
+<?php
+
+/*
+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
+}
+ */
+
+$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-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 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-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>
+            </div>
+        </form>
+    </div>
+<?php endif; ?>
+

+ 35 - 0
resources/views/app/patient/segment-templates/_child_plan/exercise/AEROBIC_ACTIVITY/last-plan.php

@@ -0,0 +1,35 @@
+<div class="mb-1 font-weight-bold text-secondary">Change Goal</div>
+<?php if ($point->lastChildPlan): ?>
+    <?php $parsedPlan = json_decode($point->lastChildPlan->data); ?>
+    <div class="<?= $point->last_child_plan_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
+        <div class="inline-html-container">
+            <?php $plan = $parsedPlan; ?>
+            <?php include(resource_path('views/app/patient/segment-templates/_child_plan/exercise/' . $p['category'] . '/view-plan.php')); ?>
+        </div>
+
+        <?php if ($point->last_child_plan_point_scoped_note_id === $patient->core_note_id): ?>
+            <span class="text-sm">(updated on the patient's chart)</span>
+        <?php else: ?>
+            <?php if ($point->last_child_plan_point_scoped_note_id === $note->id): ?>
+                <span class="text-sm">(updated on this note)</span>
+            <?php else: ?>
+                <div class="d-inline position-relative on-click-menu">
+                    <span class="text-sm text-primary c-pointer">
+                        <?= relative_friendly_date($point->last_child_plan_effective_date) ?>
+                        <?php if($point->lastChildPlan->creatorPro): ?>
+                            by <?= $point->lastChildPlan->creatorPro->displayName() ?>
+                        <?php endif; ?>
+                    </span>
+                    <div menu right class="bg-white border">
+                        <a native target="_blank"
+                           href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $point->lastChildPlanNote]) ?>"
+                           class="px-2 py-1 d-block text-nowrap text-sm">Go to note</a>
+                    </div>
+                </div>
+            <?php endif; ?>
+        <?php endif; ?>
+
+    </div>
+<?php else: ?>
+    <span class="text-secondary text-sm">None</span>
+<?php endif; ?>

+ 56 - 0
resources/views/app/patient/segment-templates/_child_plan/exercise/AEROBIC_ACTIVITY/view-plan.php

@@ -0,0 +1,56 @@
+<?php
+if(@$plan && @($plan->active)) {
+    if (@($plan->walk->active)) {
+    ?>
+        <div class="mb-1 d-flex align-items-baseline">
+            <span><?= @($plan->walk->intensity) ?: '-' ?> Walk</span>
+            <span class="ml-2 text-sm"><?= @($plan->walk->frequency) ?: '-' ?> day(s)/week</span>
+            <span class="ml-2 text-sm"><?= @($plan->walk->time) ?: '-' ?> min(s)/day</span>
+        </div>
+    <?php
+    }
+    if (@($plan->jog->active)) {
+        ?>
+        <div class="mb-1 d-flex align-items-baseline">
+            <span><?= @($plan->jog->intensity) ?: '-' ?> Jog</span>
+            <span class="ml-2 text-sm"><?= @($plan->jog->frequency) ?: '-' ?> day(s)/week</span>
+            <span class="ml-2 text-sm"><?= @($plan->jog->time) ?: '-' ?> min(s)/day</span>
+        </div>
+        <?php
+    }
+    if (@($plan->elliptical->active)) {
+        ?>
+        <div class="mb-1 d-flex align-items-baseline">
+            <span><?= @($plan->elliptical->intensity) ?: '-' ?> Elliptical</span>
+            <span class="ml-2 text-sm"><?= @($plan->elliptical->frequency) ?: '-' ?> day(s)/week</span>
+            <span class="ml-2 text-sm"><?= @($plan->elliptical->time) ?: '-' ?> min(s)/day</span>
+        </div>
+        <?php
+    }
+    if (@($plan->swim->active)) {
+        ?>
+        <div class="mb-1 d-flex align-items-baseline">
+            <span><?= @($plan->swim->intensity) ?: '-' ?> Swim</span>
+            <span class="ml-2 text-sm"><?= @($plan->swim->frequency) ?: '-' ?> day(s)/week</span>
+            <span class="ml-2 text-sm"><?= @($plan->swim->time) ?: '-' ?> min(s)/day</span>
+        </div>
+        <?php
+    }
+    if (@($plan->bike->active)) {
+        ?>
+        <div class="mb-1 d-flex align-items-baseline">
+            <span><?= @($plan->bike->intensity) ?: '-' ?> Bike</span>
+            <span class="ml-2 text-sm"><?= @($plan->bike->frequency) ?: '-' ?> day(s)/week</span>
+            <span class="ml-2 text-sm"><?= @($plan->bike->time) ?: '-' ?> min(s)/day</span>
+        </div>
+        <?php
+    }
+    ?>
+    <div class="text-secondary"><?= @($plan->memo) ?: '' ?></div>
+    <?php
+}
+else {
+    ?> - <?php
+}
+?>
+

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

@@ -0,0 +1,131 @@
+<?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-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-field-name="memo"><?= @($currentValue->memo) ?></div>
+            </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>
+            </div>
+        </form>
+    </div>
+<?php endif; ?>
+

+ 35 - 0
resources/views/app/patient/segment-templates/_child_plan/exercise/NEAT/last-plan.php

@@ -0,0 +1,35 @@
+<div class="mb-1 font-weight-bold text-secondary">Change Goal</div>
+<?php if ($point->lastChildPlan): ?>
+    <?php $parsedPlan = json_decode($point->lastChildPlan->data); ?>
+    <div class="<?= $point->last_child_plan_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
+        <div class="inline-html-container">
+            <?php $plan = $parsedPlan; ?>
+            <?php include(resource_path('views/app/patient/segment-templates/_child_plan/exercise/' . $p['category'] . '/view-plan.php')); ?>
+        </div>
+
+        <?php if ($point->last_child_plan_point_scoped_note_id === $patient->core_note_id): ?>
+            <span class="text-sm">(updated on the patient's chart)</span>
+        <?php else: ?>
+            <?php if ($point->last_child_plan_point_scoped_note_id === $note->id): ?>
+                <span class="text-sm">(updated on this note)</span>
+            <?php else: ?>
+                <div class="d-inline position-relative on-click-menu">
+                    <span class="text-sm text-primary c-pointer">
+                        <?= relative_friendly_date($point->last_child_plan_effective_date) ?>
+                        <?php if($point->lastChildPlan->creatorPro): ?>
+                            by <?= $point->lastChildPlan->creatorPro->displayName() ?>
+                        <?php endif; ?>
+                    </span>
+                    <div menu right class="bg-white border">
+                        <a native target="_blank"
+                           href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $point->lastChildPlanNote]) ?>"
+                           class="px-2 py-1 d-block text-nowrap text-sm">Go to note</a>
+                    </div>
+                </div>
+            <?php endif; ?>
+        <?php endif; ?>
+
+    </div>
+<?php else: ?>
+    <span class="text-secondary text-sm">None</span>
+<?php endif; ?>

+ 31 - 0
resources/views/app/patient/segment-templates/_child_plan/exercise/NEAT/view-plan.php

@@ -0,0 +1,31 @@
+<?php
+if(@$plan && @($plan->active)) {
+    if (@($plan->parkAway)) {
+    ?>
+        <div class="mb-1">Park away from entrances.</div>
+    <?php
+    }
+    if (@($plan->stairsInsteadOfElevators)) {
+        ?>
+        <div class="mb-1">Take the stairs instead of elevator/escalator.</div>
+        <?php
+    }
+    if (@($plan->standInsteadOfSit)) {
+        ?>
+        <div class="mb-1">Prefer standing over sitting.</div>
+        <?php
+    }
+    if (@($plan->stepsGoals)) {
+        ?>
+        <div class="mb-1">Steps/day goal: <?= $plan->stepsGoals ?>.</div>
+        <?php
+    }
+    ?>
+    <div class="text-secondary"><?= @($plan->memo) ?: '' ?></div>
+    <?php
+}
+else {
+    ?> - <?php
+}
+?>
+

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

@@ -0,0 +1,136 @@
+<?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-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-field-name="memo"><?= @($currentValue->memo) ?></div>
+            </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>
+            </div>
+        </form>
+    </div>
+<?php endif; ?>
+

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

@@ -0,0 +1,35 @@
+<div class="mb-1 font-weight-bold text-secondary">Change Goal</div>
+<?php if ($point->lastChildPlan): ?>
+    <?php $parsedPlan = json_decode($point->lastChildPlan->data); ?>
+    <div class="<?= $point->last_child_plan_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
+        <div class="inline-html-container">
+            <?php $plan = $parsedPlan; ?>
+            <?php include(resource_path('views/app/patient/segment-templates/_child_plan/exercise/' . $p['category'] . '/view-plan.php')); ?>
+        </div>
+
+        <?php if ($point->last_child_plan_point_scoped_note_id === $patient->core_note_id): ?>
+            <span class="text-sm">(updated on the patient's chart)</span>
+        <?php else: ?>
+            <?php if ($point->last_child_plan_point_scoped_note_id === $note->id): ?>
+                <span class="text-sm">(updated on this note)</span>
+            <?php else: ?>
+                <div class="d-inline position-relative on-click-menu">
+                    <span class="text-sm text-primary c-pointer">
+                        <?= relative_friendly_date($point->last_child_plan_effective_date) ?>
+                        <?php if($point->lastChildPlan->creatorPro): ?>
+                            by <?= $point->lastChildPlan->creatorPro->displayName() ?>
+                        <?php endif; ?>
+                    </span>
+                    <div menu right class="bg-white border">
+                        <a native target="_blank"
+                           href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $point->lastChildPlanNote]) ?>"
+                           class="px-2 py-1 d-block text-nowrap text-sm">Go to note</a>
+                    </div>
+                </div>
+            <?php endif; ?>
+        <?php endif; ?>
+
+    </div>
+<?php else: ?>
+    <span class="text-secondary text-sm">None</span>
+<?php endif; ?>

+ 36 - 0
resources/views/app/patient/segment-templates/_child_plan/exercise/STRENGTH_TRAINING/view-plan.php

@@ -0,0 +1,36 @@
+<?php
+if(@$plan && @($plan->active)) {
+    if (@($plan->muscleStrengthening)) {
+    ?>
+        <div class="mb-1">Do muscle strengthening exercises on moderate or greater intensity at least two days per week.</div>
+    <?php
+    }
+    if (@($plan->allMajorMuscleGroups)) {
+        ?>
+        <div class="mb-1">Do exercises to strengthen all major muscle groups: legs, hips, back, chest, abdomen, shoulders and arms.</div>
+        <?php
+    }
+    if (@($plan->sets)) {
+        ?>
+        <div class="mb-1">Sets per exercise: <?= $plan->sets ?>.</div>
+        <?php
+    }
+    if (@($plan->reps)) {
+        ?>
+        <div class="mb-1">Repetitions per set: <?= $plan->reps ?>.</div>
+        <?php
+    }
+    if (@($plan->resistanceBandsBodyWeight)) {
+        ?>
+        <div class="mb-1">Use resistance bands or using body weight to do exercises.</div>
+        <?php
+    }
+    ?>
+    <div class="text-secondary"><?= @($plan->memo) ?: '' ?></div>
+    <?php
+}
+else {
+    ?> - <?php
+}
+?>
+

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

@@ -0,0 +1,118 @@
+<?php
+$currentValue = '';
+$previousValue = '';
+$previousChildPlan = null;
+if (@$point) {
+    if ($point->lastChildPlan && $point->last_child_plan_point_scoped_note_id === $note->id) {
+        $parsedPlan = json_decode($point->lastChildPlan->data);
+        if(@$parsedPlan->value) {
+            $currentValue = $parsedPlan->value;
+            $previousChildPlan = \App\Models\Point::where('id', '<', $point->lastChildPlan->id)
+                ->where('category', 'PLAN')
+                ->where('parent_point_id', $point->id)
+                ->orderBy('id', 'DESC')
+                ->first();
+            if($previousChildPlan && $previousChildPlan->data) {
+                $parsedPlan = json_decode($previousChildPlan->data);
+                $previousValue = $parsedPlan->value;
+            }
+        }
+    }
+    else {
+        $previousChildPlan = \App\Models\Point::where('parent_point_id', $point->id)
+            ->where('category', 'PLAN')
+            ->orderBy('id', 'DESC')
+            ->first();
+        if($previousChildPlan && $previousChildPlan->data) {
+            $parsedPlan = json_decode($previousChildPlan->data);
+            if(@$parsedPlan->value) {
+                $previousValue = $parsedPlan->value;
+            }
+        }
+    }
+}
+?>
+<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>
+    <?php if($point): ?>
+        <form 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">
+
+            <?php if($segment->segmentTemplate->internal_name === 'intake_problems' && $previousValue): ?>
+                <div class="d-none disallow-if-value-same-as"><?= str_compact($previousValue) ?></div>
+            <?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) ?>) (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
+                    <?= $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>
+        </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; ?>
+

+ 33 - 0
resources/views/app/patient/segment-templates/_child_plan/nutrition/DAILY_INTAKE_CALORIES/last-plan.php

@@ -0,0 +1,33 @@
+<div class="mb-1 font-weight-bold text-secondary">Change Goal</div>
+<?php if ($point->lastChildPlan): ?>
+    <?php $parsedPlan = json_decode($point->lastChildPlan->data); ?>
+    <div class="<?= $point->last_child_plan_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
+        <div class="inline-html-container"><?= $parsedPlan->value ?></div>
+        <div class="text-secondary text-sm"></div>
+
+        <?php if ($point->last_child_plan_point_scoped_note_id === $patient->core_note_id): ?>
+            <span class="text-sm">(updated on the patient's chart)</span>
+        <?php else: ?>
+            <?php if ($point->last_child_plan_point_scoped_note_id === $note->id): ?>
+                <span class="text-sm">(updated on this note)</span>
+            <?php else: ?>
+                <div class="d-inline position-relative on-click-menu">
+                    <span class="text-sm text-primary c-pointer">
+                        <?= relative_friendly_date($point->last_child_plan_effective_date) ?>
+                        <?php if($point->lastChildPlan->creatorPro): ?>
+                            by <?= $point->lastChildPlan->creatorPro->displayName() ?>
+                        <?php endif; ?>
+                    </span>
+                    <div menu right class="bg-white border">
+                        <a native target="_blank"
+                           href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $point->lastChildPlanNote]) ?>"
+                           class="px-2 py-1 d-block text-nowrap text-sm">Go to note</a>
+                    </div>
+                </div>
+            <?php endif; ?>
+        <?php endif; ?>
+
+    </div>
+<?php else: ?>
+    <span class="text-secondary text-sm">None</span>
+<?php endif; ?>

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

@@ -0,0 +1,118 @@
+<?php
+$currentValue = '';
+$previousValue = '';
+$previousChildPlan = null;
+if (@$point) {
+    if ($point->lastChildPlan && $point->last_child_plan_point_scoped_note_id === $note->id) {
+        $parsedPlan = json_decode($point->lastChildPlan->data);
+        if(@$parsedPlan->value) {
+            $currentValue = $parsedPlan->value;
+            $previousChildPlan = \App\Models\Point::where('id', '<', $point->lastChildPlan->id)
+                ->where('category', 'PLAN')
+                ->where('parent_point_id', $point->id)
+                ->orderBy('id', 'DESC')
+                ->first();
+            if($previousChildPlan && $previousChildPlan->data) {
+                $parsedPlan = json_decode($previousChildPlan->data);
+                $previousValue = $parsedPlan->value;
+            }
+        }
+    }
+    else {
+        $previousChildPlan = \App\Models\Point::where('parent_point_id', $point->id)
+            ->where('category', 'PLAN')
+            ->orderBy('id', 'DESC')
+            ->first();
+        if($previousChildPlan && $previousChildPlan->data) {
+            $parsedPlan = json_decode($previousChildPlan->data);
+            if(@$parsedPlan->value) {
+                $previousValue = $parsedPlan->value;
+            }
+        }
+    }
+}
+?>
+<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>
+    <?php if($point): ?>
+        <form 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">
+
+            <?php if($segment->segmentTemplate->internal_name === 'intake_problems' && $previousValue): ?>
+                <div class="d-none disallow-if-value-same-as"><?= str_compact($previousValue) ?></div>
+            <?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) ?>) (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
+                    <?= $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>
+        </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; ?>
+

+ 33 - 0
resources/views/app/patient/segment-templates/_child_plan/nutrition/DAILY_INTAKE_CARBOHYDRATES/last-plan.php

@@ -0,0 +1,33 @@
+<div class="mb-1 font-weight-bold text-secondary">Change Goal</div>
+<?php if ($point->lastChildPlan): ?>
+    <?php $parsedPlan = json_decode($point->lastChildPlan->data); ?>
+    <div class="<?= $point->last_child_plan_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
+        <div class="inline-html-container"><?= $parsedPlan->value ?></div>
+        <div class="text-secondary text-sm"></div>
+
+        <?php if ($point->last_child_plan_point_scoped_note_id === $patient->core_note_id): ?>
+            <span class="text-sm">(updated on the patient's chart)</span>
+        <?php else: ?>
+            <?php if ($point->last_child_plan_point_scoped_note_id === $note->id): ?>
+                <span class="text-sm">(updated on this note)</span>
+            <?php else: ?>
+                <div class="d-inline position-relative on-click-menu">
+                    <span class="text-sm text-primary c-pointer">
+                        <?= relative_friendly_date($point->last_child_plan_effective_date) ?>
+                        <?php if($point->lastChildPlan->creatorPro): ?>
+                            by <?= $point->lastChildPlan->creatorPro->displayName() ?>
+                        <?php endif; ?>
+                    </span>
+                    <div menu right class="bg-white border">
+                        <a native target="_blank"
+                           href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $point->lastChildPlanNote]) ?>"
+                           class="px-2 py-1 d-block text-nowrap text-sm">Go to note</a>
+                    </div>
+                </div>
+            <?php endif; ?>
+        <?php endif; ?>
+
+    </div>
+<?php else: ?>
+    <span class="text-secondary text-sm">None</span>
+<?php endif; ?>

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

@@ -0,0 +1,118 @@
+<?php
+$currentValue = '';
+$previousValue = '';
+$previousChildPlan = null;
+if (@$point) {
+    if ($point->lastChildPlan && $point->last_child_plan_point_scoped_note_id === $note->id) {
+        $parsedPlan = json_decode($point->lastChildPlan->data);
+        if(@$parsedPlan->value) {
+            $currentValue = $parsedPlan->value;
+            $previousChildPlan = \App\Models\Point::where('id', '<', $point->lastChildPlan->id)
+                ->where('category', 'PLAN')
+                ->where('parent_point_id', $point->id)
+                ->orderBy('id', 'DESC')
+                ->first();
+            if($previousChildPlan && $previousChildPlan->data) {
+                $parsedPlan = json_decode($previousChildPlan->data);
+                $previousValue = $parsedPlan->value;
+            }
+        }
+    }
+    else {
+        $previousChildPlan = \App\Models\Point::where('parent_point_id', $point->id)
+            ->where('category', 'PLAN')
+            ->orderBy('id', 'DESC')
+            ->first();
+        if($previousChildPlan && $previousChildPlan->data) {
+            $parsedPlan = json_decode($previousChildPlan->data);
+            if(@$parsedPlan->value) {
+                $previousValue = $parsedPlan->value;
+            }
+        }
+    }
+}
+?>
+<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>
+    <?php if($point): ?>
+        <form 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">
+
+            <?php if($segment->segmentTemplate->internal_name === 'intake_problems' && $previousValue): ?>
+                <div class="d-none disallow-if-value-same-as"><?= str_compact($previousValue) ?></div>
+            <?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) ?>) (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
+                    <?= $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>
+        </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; ?>
+

+ 33 - 0
resources/views/app/patient/segment-templates/_child_plan/nutrition/FAST_FOOD/last-plan.php

@@ -0,0 +1,33 @@
+<div class="mb-1 font-weight-bold text-secondary">Change Goal</div>
+<?php if ($point->lastChildPlan): ?>
+    <?php $parsedPlan = json_decode($point->lastChildPlan->data); ?>
+    <div class="<?= $point->last_child_plan_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
+        <div class="inline-html-container"><?= $parsedPlan->value ?></div>
+        <div class="text-secondary text-sm"></div>
+
+        <?php if ($point->last_child_plan_point_scoped_note_id === $patient->core_note_id): ?>
+            <span class="text-sm">(updated on the patient's chart)</span>
+        <?php else: ?>
+            <?php if ($point->last_child_plan_point_scoped_note_id === $note->id): ?>
+                <span class="text-sm">(updated on this note)</span>
+            <?php else: ?>
+                <div class="d-inline position-relative on-click-menu">
+                    <span class="text-sm text-primary c-pointer">
+                        <?= relative_friendly_date($point->last_child_plan_effective_date) ?>
+                        <?php if($point->lastChildPlan->creatorPro): ?>
+                            by <?= $point->lastChildPlan->creatorPro->displayName() ?>
+                        <?php endif; ?>
+                    </span>
+                    <div menu right class="bg-white border">
+                        <a native target="_blank"
+                           href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $point->lastChildPlanNote]) ?>"
+                           class="px-2 py-1 d-block text-nowrap text-sm">Go to note</a>
+                    </div>
+                </div>
+            <?php endif; ?>
+        <?php endif; ?>
+
+    </div>
+<?php else: ?>
+    <span class="text-secondary text-sm">None</span>
+<?php endif; ?>

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

@@ -0,0 +1,118 @@
+<?php
+$currentValue = '';
+$previousValue = '';
+$previousChildPlan = null;
+if (@$point) {
+    if ($point->lastChildPlan && $point->last_child_plan_point_scoped_note_id === $note->id) {
+        $parsedPlan = json_decode($point->lastChildPlan->data);
+        if(@$parsedPlan->value) {
+            $currentValue = $parsedPlan->value;
+            $previousChildPlan = \App\Models\Point::where('id', '<', $point->lastChildPlan->id)
+                ->where('category', 'PLAN')
+                ->where('parent_point_id', $point->id)
+                ->orderBy('id', 'DESC')
+                ->first();
+            if($previousChildPlan && $previousChildPlan->data) {
+                $parsedPlan = json_decode($previousChildPlan->data);
+                $previousValue = $parsedPlan->value;
+            }
+        }
+    }
+    else {
+        $previousChildPlan = \App\Models\Point::where('parent_point_id', $point->id)
+            ->where('category', 'PLAN')
+            ->orderBy('id', 'DESC')
+            ->first();
+        if($previousChildPlan && $previousChildPlan->data) {
+            $parsedPlan = json_decode($previousChildPlan->data);
+            if(@$parsedPlan->value) {
+                $previousValue = $parsedPlan->value;
+            }
+        }
+    }
+}
+?>
+<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>
+    <?php if($point): ?>
+        <form 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">
+
+            <?php if($segment->segmentTemplate->internal_name === 'intake_problems' && $previousValue): ?>
+                <div class="d-none disallow-if-value-same-as"><?= str_compact($previousValue) ?></div>
+            <?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) ?>) (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
+                    <?= $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>
+        </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; ?>
+

+ 33 - 0
resources/views/app/patient/segment-templates/_child_plan/nutrition/HIGH_SUGAR_BEVERAGES/last-plan.php

@@ -0,0 +1,33 @@
+<div class="mb-1 font-weight-bold text-secondary">Change Goal</div>
+<?php if ($point->lastChildPlan): ?>
+    <?php $parsedPlan = json_decode($point->lastChildPlan->data); ?>
+    <div class="<?= $point->last_child_plan_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
+        <div class="inline-html-container"><?= $parsedPlan->value ?></div>
+        <div class="text-secondary text-sm"></div>
+
+        <?php if ($point->last_child_plan_point_scoped_note_id === $patient->core_note_id): ?>
+            <span class="text-sm">(updated on the patient's chart)</span>
+        <?php else: ?>
+            <?php if ($point->last_child_plan_point_scoped_note_id === $note->id): ?>
+                <span class="text-sm">(updated on this note)</span>
+            <?php else: ?>
+                <div class="d-inline position-relative on-click-menu">
+                    <span class="text-sm text-primary c-pointer">
+                        <?= relative_friendly_date($point->last_child_plan_effective_date) ?>
+                        <?php if($point->lastChildPlan->creatorPro): ?>
+                            by <?= $point->lastChildPlan->creatorPro->displayName() ?>
+                        <?php endif; ?>
+                    </span>
+                    <div menu right class="bg-white border">
+                        <a native target="_blank"
+                           href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $point->lastChildPlanNote]) ?>"
+                           class="px-2 py-1 d-block text-nowrap text-sm">Go to note</a>
+                    </div>
+                </div>
+            <?php endif; ?>
+        <?php endif; ?>
+
+    </div>
+<?php else: ?>
+    <span class="text-secondary text-sm">None</span>
+<?php endif; ?>

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

@@ -0,0 +1,118 @@
+<?php
+$currentValue = '';
+$previousValue = '';
+$previousChildPlan = null;
+if (@$point) {
+    if ($point->lastChildPlan && $point->last_child_plan_point_scoped_note_id === $note->id) {
+        $parsedPlan = json_decode($point->lastChildPlan->data);
+        if(@$parsedPlan->value) {
+            $currentValue = $parsedPlan->value;
+            $previousChildPlan = \App\Models\Point::where('id', '<', $point->lastChildPlan->id)
+                ->where('category', 'PLAN')
+                ->where('parent_point_id', $point->id)
+                ->orderBy('id', 'DESC')
+                ->first();
+            if($previousChildPlan && $previousChildPlan->data) {
+                $parsedPlan = json_decode($previousChildPlan->data);
+                $previousValue = $parsedPlan->value;
+            }
+        }
+    }
+    else {
+        $previousChildPlan = \App\Models\Point::where('parent_point_id', $point->id)
+            ->where('category', 'PLAN')
+            ->orderBy('id', 'DESC')
+            ->first();
+        if($previousChildPlan && $previousChildPlan->data) {
+            $parsedPlan = json_decode($previousChildPlan->data);
+            if(@$parsedPlan->value) {
+                $previousValue = $parsedPlan->value;
+            }
+        }
+    }
+}
+?>
+<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>
+    <?php if($point): ?>
+        <form 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">
+
+            <?php if($segment->segmentTemplate->internal_name === 'intake_problems' && $previousValue): ?>
+                <div class="d-none disallow-if-value-same-as"><?= str_compact($previousValue) ?></div>
+            <?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) ?>) (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
+                    <?= $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>
+        </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; ?>
+

+ 33 - 0
resources/views/app/patient/segment-templates/_child_plan/nutrition/PORTION_SIZES/last-plan.php

@@ -0,0 +1,33 @@
+<div class="mb-1 font-weight-bold text-secondary">Change Goal</div>
+<?php if ($point->lastChildPlan): ?>
+    <?php $parsedPlan = json_decode($point->lastChildPlan->data); ?>
+    <div class="<?= $point->last_child_plan_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
+        <div class="inline-html-container"><?= $parsedPlan->value ?></div>
+        <div class="text-secondary text-sm"></div>
+
+        <?php if ($point->last_child_plan_point_scoped_note_id === $patient->core_note_id): ?>
+            <span class="text-sm">(updated on the patient's chart)</span>
+        <?php else: ?>
+            <?php if ($point->last_child_plan_point_scoped_note_id === $note->id): ?>
+                <span class="text-sm">(updated on this note)</span>
+            <?php else: ?>
+                <div class="d-inline position-relative on-click-menu">
+                    <span class="text-sm text-primary c-pointer">
+                        <?= relative_friendly_date($point->last_child_plan_effective_date) ?>
+                        <?php if($point->lastChildPlan->creatorPro): ?>
+                            by <?= $point->lastChildPlan->creatorPro->displayName() ?>
+                        <?php endif; ?>
+                    </span>
+                    <div menu right class="bg-white border">
+                        <a native target="_blank"
+                           href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $point->lastChildPlanNote]) ?>"
+                           class="px-2 py-1 d-block text-nowrap text-sm">Go to note</a>
+                    </div>
+                </div>
+            <?php endif; ?>
+        <?php endif; ?>
+
+    </div>
+<?php else: ?>
+    <span class="text-secondary text-sm">None</span>
+<?php endif; ?>

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

@@ -0,0 +1,118 @@
+<?php
+$currentValue = '';
+$previousValue = '';
+$previousChildPlan = null;
+if (@$point) {
+    if ($point->lastChildPlan && $point->last_child_plan_point_scoped_note_id === $note->id) {
+        $parsedPlan = json_decode($point->lastChildPlan->data);
+        if(@$parsedPlan->value) {
+            $currentValue = $parsedPlan->value;
+            $previousChildPlan = \App\Models\Point::where('id', '<', $point->lastChildPlan->id)
+                ->where('category', 'PLAN')
+                ->where('parent_point_id', $point->id)
+                ->orderBy('id', 'DESC')
+                ->first();
+            if($previousChildPlan && $previousChildPlan->data) {
+                $parsedPlan = json_decode($previousChildPlan->data);
+                $previousValue = $parsedPlan->value;
+            }
+        }
+    }
+    else {
+        $previousChildPlan = \App\Models\Point::where('parent_point_id', $point->id)
+            ->where('category', 'PLAN')
+            ->orderBy('id', 'DESC')
+            ->first();
+        if($previousChildPlan && $previousChildPlan->data) {
+            $parsedPlan = json_decode($previousChildPlan->data);
+            if(@$parsedPlan->value) {
+                $previousValue = $parsedPlan->value;
+            }
+        }
+    }
+}
+?>
+<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>
+    <?php if($point): ?>
+        <form 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">
+
+            <?php if($segment->segmentTemplate->internal_name === 'intake_problems' && $previousValue): ?>
+                <div class="d-none disallow-if-value-same-as"><?= str_compact($previousValue) ?></div>
+            <?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) ?>) (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
+                    <?= $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>
+        </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; ?>
+

+ 33 - 0
resources/views/app/patient/segment-templates/_child_plan/nutrition/SNACKS/last-plan.php

@@ -0,0 +1,33 @@
+<div class="mb-1 font-weight-bold text-secondary">Change Goal</div>
+<?php if ($point->lastChildPlan): ?>
+    <?php $parsedPlan = json_decode($point->lastChildPlan->data); ?>
+    <div class="<?= $point->last_child_plan_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
+        <div class="inline-html-container"><?= $parsedPlan->value ?></div>
+        <div class="text-secondary text-sm"></div>
+
+        <?php if ($point->last_child_plan_point_scoped_note_id === $patient->core_note_id): ?>
+            <span class="text-sm">(updated on the patient's chart)</span>
+        <?php else: ?>
+            <?php if ($point->last_child_plan_point_scoped_note_id === $note->id): ?>
+                <span class="text-sm">(updated on this note)</span>
+            <?php else: ?>
+                <div class="d-inline position-relative on-click-menu">
+                    <span class="text-sm text-primary c-pointer">
+                        <?= relative_friendly_date($point->last_child_plan_effective_date) ?>
+                        <?php if($point->lastChildPlan->creatorPro): ?>
+                            by <?= $point->lastChildPlan->creatorPro->displayName() ?>
+                        <?php endif; ?>
+                    </span>
+                    <div menu right class="bg-white border">
+                        <a native target="_blank"
+                           href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $point->lastChildPlanNote]) ?>"
+                           class="px-2 py-1 d-block text-nowrap text-sm">Go to note</a>
+                    </div>
+                </div>
+            <?php endif; ?>
+        <?php endif; ?>
+
+    </div>
+<?php else: ?>
+    <span class="text-secondary text-sm">None</span>
+<?php endif; ?>

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

@@ -0,0 +1,118 @@
+<?php
+$currentValue = '';
+$previousValue = '';
+$previousChildPlan = null;
+if (@$point) {
+    if ($point->lastChildPlan && $point->last_child_plan_point_scoped_note_id === $note->id) {
+        $parsedPlan = json_decode($point->lastChildPlan->data);
+        if(@$parsedPlan->value) {
+            $currentValue = $parsedPlan->value;
+            $previousChildPlan = \App\Models\Point::where('id', '<', $point->lastChildPlan->id)
+                ->where('category', 'PLAN')
+                ->where('parent_point_id', $point->id)
+                ->orderBy('id', 'DESC')
+                ->first();
+            if($previousChildPlan && $previousChildPlan->data) {
+                $parsedPlan = json_decode($previousChildPlan->data);
+                $previousValue = $parsedPlan->value;
+            }
+        }
+    }
+    else {
+        $previousChildPlan = \App\Models\Point::where('parent_point_id', $point->id)
+            ->where('category', 'PLAN')
+            ->orderBy('id', 'DESC')
+            ->first();
+        if($previousChildPlan && $previousChildPlan->data) {
+            $parsedPlan = json_decode($previousChildPlan->data);
+            if(@$parsedPlan->value) {
+                $previousValue = $parsedPlan->value;
+            }
+        }
+    }
+}
+?>
+<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>
+    <?php if($point): ?>
+        <form 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">
+
+            <?php if($segment->segmentTemplate->internal_name === 'intake_problems' && $previousValue): ?>
+                <div class="d-none disallow-if-value-same-as"><?= str_compact($previousValue) ?></div>
+            <?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) ?>) (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
+                    <?= $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>
+        </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; ?>
+

+ 33 - 0
resources/views/app/patient/segment-templates/_child_plan/nutrition/VEGETABLES/last-plan.php

@@ -0,0 +1,33 @@
+<div class="mb-1 font-weight-bold text-secondary">Change Goal</div>
+<?php if ($point->lastChildPlan): ?>
+    <?php $parsedPlan = json_decode($point->lastChildPlan->data); ?>
+    <div class="<?= $point->last_child_plan_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
+        <div class="inline-html-container"><?= $parsedPlan->value ?></div>
+        <div class="text-secondary text-sm"></div>
+
+        <?php if ($point->last_child_plan_point_scoped_note_id === $patient->core_note_id): ?>
+            <span class="text-sm">(updated on the patient's chart)</span>
+        <?php else: ?>
+            <?php if ($point->last_child_plan_point_scoped_note_id === $note->id): ?>
+                <span class="text-sm">(updated on this note)</span>
+            <?php else: ?>
+                <div class="d-inline position-relative on-click-menu">
+                    <span class="text-sm text-primary c-pointer">
+                        <?= relative_friendly_date($point->last_child_plan_effective_date) ?>
+                        <?php if($point->lastChildPlan->creatorPro): ?>
+                            by <?= $point->lastChildPlan->creatorPro->displayName() ?>
+                        <?php endif; ?>
+                    </span>
+                    <div menu right class="bg-white border">
+                        <a native target="_blank"
+                           href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $point->lastChildPlanNote]) ?>"
+                           class="px-2 py-1 d-block text-nowrap text-sm">Go to note</a>
+                    </div>
+                </div>
+            <?php endif; ?>
+        <?php endif; ?>
+
+    </div>
+<?php else: ?>
+    <span class="text-secondary text-sm">None</span>
+<?php endif; ?>

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

@@ -0,0 +1,118 @@
+<?php
+$currentValue = '';
+$previousValue = '';
+$previousChildPlan = null;
+if (@$point) {
+    if ($point->lastChildPlan && $point->last_child_plan_point_scoped_note_id === $note->id) {
+        $parsedPlan = json_decode($point->lastChildPlan->data);
+        if(@$parsedPlan->value) {
+            $currentValue = $parsedPlan->value;
+            $previousChildPlan = \App\Models\Point::where('id', '<', $point->lastChildPlan->id)
+                ->where('category', 'PLAN')
+                ->where('parent_point_id', $point->id)
+                ->orderBy('id', 'DESC')
+                ->first();
+            if($previousChildPlan && $previousChildPlan->data) {
+                $parsedPlan = json_decode($previousChildPlan->data);
+                $previousValue = $parsedPlan->value;
+            }
+        }
+    }
+    else {
+        $previousChildPlan = \App\Models\Point::where('parent_point_id', $point->id)
+            ->where('category', 'PLAN')
+            ->orderBy('id', 'DESC')
+            ->first();
+        if($previousChildPlan && $previousChildPlan->data) {
+            $parsedPlan = json_decode($previousChildPlan->data);
+            if(@$parsedPlan->value) {
+                $previousValue = $parsedPlan->value;
+            }
+        }
+    }
+}
+?>
+<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>
+    <?php if($point): ?>
+        <form 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">
+
+            <?php if($segment->segmentTemplate->internal_name === 'intake_problems' && $previousValue): ?>
+                <div class="d-none disallow-if-value-same-as"><?= str_compact($previousValue) ?></div>
+            <?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) ?>) (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
+                    <?= $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>
+        </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; ?>
+

+ 33 - 0
resources/views/app/patient/segment-templates/_child_plan/nutrition/WATER_INTAKE/last-plan.php

@@ -0,0 +1,33 @@
+<div class="mb-1 font-weight-bold text-secondary">Change Goal</div>
+<?php if ($point->lastChildPlan): ?>
+    <?php $parsedPlan = json_decode($point->lastChildPlan->data); ?>
+    <div class="<?= $point->last_child_plan_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
+        <div class="inline-html-container"><?= $parsedPlan->value ?></div>
+        <div class="text-secondary text-sm"></div>
+
+        <?php if ($point->last_child_plan_point_scoped_note_id === $patient->core_note_id): ?>
+            <span class="text-sm">(updated on the patient's chart)</span>
+        <?php else: ?>
+            <?php if ($point->last_child_plan_point_scoped_note_id === $note->id): ?>
+                <span class="text-sm">(updated on this note)</span>
+            <?php else: ?>
+                <div class="d-inline position-relative on-click-menu">
+                    <span class="text-sm text-primary c-pointer">
+                        <?= relative_friendly_date($point->last_child_plan_effective_date) ?>
+                        <?php if($point->lastChildPlan->creatorPro): ?>
+                            by <?= $point->lastChildPlan->creatorPro->displayName() ?>
+                        <?php endif; ?>
+                    </span>
+                    <div menu right class="bg-white border">
+                        <a native target="_blank"
+                           href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $point->lastChildPlanNote]) ?>"
+                           class="px-2 py-1 d-block text-nowrap text-sm">Go to note</a>
+                    </div>
+                </div>
+            <?php endif; ?>
+        <?php endif; ?>
+
+    </div>
+<?php else: ?>
+    <span class="text-secondary text-sm">None</span>
+<?php endif; ?>

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

@@ -0,0 +1,314 @@
+<?php
+
+/*
+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
+}
+ */
+
+$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-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 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-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>
+            </div>
+        </form>
+    </div>
+<?php endif; ?>
+

+ 35 - 0
resources/views/app/patient/segment-templates/_child_review/exercise/AEROBIC_ACTIVITY/last-review.php

@@ -0,0 +1,35 @@
+<div class="mb-1 font-weight-bold text-secondary">Current Aerobic Activity</div>
+<?php if ($point->lastChildReview): ?>
+    <?php $parsedReview = json_decode($point->lastChildReview->data); ?>
+    <div class="<?= $point->last_child_review_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
+        <div class="inline-html-container">
+            <?php $review = $parsedReview; ?>
+            <?php include(resource_path('views/app/patient/segment-templates/_child_review/exercise/' . $p['category'] . '/view-review.php')); ?>
+        </div>
+
+        <?php if ($point->last_child_review_point_scoped_note_id === $patient->core_note_id): ?>
+            <span class="text-sm">(updated on the patient's chart)</span>
+        <?php else: ?>
+            <?php if ($point->last_child_review_point_scoped_note_id === $note->id): ?>
+                <span class="text-sm">(updated on this note)</span>
+            <?php else: ?>
+                <div class="d-inline position-relative on-click-menu">
+                    <span class="text-sm text-primary c-pointer">
+                        <?= relative_friendly_date($point->last_child_review_effective_date) ?>
+                        <?php if($point->lastChildReview->creatorPro): ?>
+                        by <?= $point->lastChildReview->creatorPro->displayName() ?>
+                        <?php endif; ?>
+                    </span>
+                    <div menu right class="bg-white border">
+                        <a native target="_blank"
+                           href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $point->lastChildReviewNote]) ?>"
+                           class="px-2 py-1 d-block text-nowrap text-sm">Go to note</a>
+                    </div>
+                </div>
+            <?php endif; ?>
+        <?php endif; ?>
+
+    </div>
+<?php else: ?>
+    <span class="text-secondary text-sm">None</span>
+<?php endif; ?>

+ 56 - 0
resources/views/app/patient/segment-templates/_child_review/exercise/AEROBIC_ACTIVITY/view-review.php

@@ -0,0 +1,56 @@
+<?php
+if(@$review && @($review->active)) {
+    if (@($review->walk->active)) {
+    ?>
+        <div class="mb-1 d-flex align-items-baseline">
+            <span><?= @($review->walk->intensity) ?: '-' ?> Walk</span>
+            <span class="ml-2 text-sm"><?= @($review->walk->frequency) ?: '-' ?> day(s)/week</span>
+            <span class="ml-2 text-sm"><?= @($review->walk->time) ?: '-' ?> min(s)/day</span>
+        </div>
+    <?php
+    }
+    if (@($review->jog->active)) {
+        ?>
+        <div class="mb-1 d-flex align-items-baseline">
+            <span><?= @($review->jog->intensity) ?: '-' ?> Jog</span>
+            <span class="ml-2 text-sm"><?= @($review->jog->frequency) ?: '-' ?> day(s)/week</span>
+            <span class="ml-2 text-sm"><?= @($review->jog->time) ?: '-' ?> min(s)/day</span>
+        </div>
+        <?php
+    }
+    if (@($review->elliptical->active)) {
+        ?>
+        <div class="mb-1 d-flex align-items-baseline">
+            <span><?= @($review->elliptical->intensity) ?: '-' ?> Elliptical</span>
+            <span class="ml-2 text-sm"><?= @($review->elliptical->frequency) ?: '-' ?> day(s)/week</span>
+            <span class="ml-2 text-sm"><?= @($review->elliptical->time) ?: '-' ?> min(s)/day</span>
+        </div>
+        <?php
+    }
+    if (@($review->swim->active)) {
+        ?>
+        <div class="mb-1 d-flex align-items-baseline">
+            <span><?= @($review->swim->intensity) ?: '-' ?> Swim</span>
+            <span class="ml-2 text-sm"><?= @($review->swim->frequency) ?: '-' ?> day(s)/week</span>
+            <span class="ml-2 text-sm"><?= @($review->swim->time) ?: '-' ?> min(s)/day</span>
+        </div>
+        <?php
+    }
+    if (@($review->bike->active)) {
+        ?>
+        <div class="mb-1 d-flex align-items-baseline">
+            <span><?= @($review->bike->intensity) ?: '-' ?> Bike</span>
+            <span class="ml-2 text-sm"><?= @($review->bike->frequency) ?: '-' ?> day(s)/week</span>
+            <span class="ml-2 text-sm"><?= @($review->bike->time) ?: '-' ?> min(s)/day</span>
+        </div>
+        <?php
+    }
+    ?>
+    <div class="text-secondary"><?= @($review->memo) ?: '' ?></div>
+    <?php
+}
+else {
+    ?> - <?php
+}
+?>
+

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

@@ -0,0 +1,131 @@
+<?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-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-field-name="memo"><?= @($currentValue->memo) ?></div>
+            </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>
+            </div>
+        </form>
+    </div>
+<?php endif; ?>
+

+ 35 - 0
resources/views/app/patient/segment-templates/_child_review/exercise/NEAT/last-review.php

@@ -0,0 +1,35 @@
+<div class="mb-1 font-weight-bold text-secondary">Current Non-Exercise Activity Time (NEAT)</div>
+<?php if ($point->lastChildReview): ?>
+    <?php $parsedReview = json_decode($point->lastChildReview->data); ?>
+    <div class="<?= $point->last_child_review_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
+        <div class="inline-html-container">
+            <?php $review = $parsedReview; ?>
+            <?php include(resource_path('views/app/patient/segment-templates/_child_review/exercise/' . $p['category'] . '/view-review.php')); ?>
+        </div>
+
+        <?php if ($point->last_child_review_point_scoped_note_id === $patient->core_note_id): ?>
+            <span class="text-sm">(updated on the patient's chart)</span>
+        <?php else: ?>
+            <?php if ($point->last_child_review_point_scoped_note_id === $note->id): ?>
+                <span class="text-sm">(updated on this note)</span>
+            <?php else: ?>
+                <div class="d-inline position-relative on-click-menu">
+                    <span class="text-sm text-primary c-pointer">
+                        <?= relative_friendly_date($point->last_child_review_effective_date) ?>
+                        <?php if($point->lastChildReview->creatorPro): ?>
+                        by <?= $point->lastChildReview->creatorPro->displayName() ?>
+                        <?php endif; ?>
+                    </span>
+                    <div menu right class="bg-white border">
+                        <a native target="_blank"
+                           href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $point->lastChildReviewNote]) ?>"
+                           class="px-2 py-1 d-block text-nowrap text-sm">Go to note</a>
+                    </div>
+                </div>
+            <?php endif; ?>
+        <?php endif; ?>
+
+    </div>
+<?php else: ?>
+    <span class="text-secondary text-sm">None</span>
+<?php endif; ?>

+ 31 - 0
resources/views/app/patient/segment-templates/_child_review/exercise/NEAT/view-review.php

@@ -0,0 +1,31 @@
+<?php
+if(@$review && @($review->active)) {
+    if (@($review->parkAway)) {
+    ?>
+        <div class="mb-1">Currently parks away from entrances.</div>
+    <?php
+    }
+    if (@($review->stairsInsteadOfElevators)) {
+        ?>
+        <div class="mb-1">Currently takes the stairs instead of elevator/escalator.</div>
+        <?php
+    }
+    if (@($review->standInsteadOfSit)) {
+        ?>
+        <div class="mb-1">Currently prefers standing over sitting.</div>
+        <?php
+    }
+    if (@($review->stepsGoals)) {
+        ?>
+        <div class="mb-1">Current steps/day: <?= $review->stepsGoals ?>.</div>
+        <?php
+    }
+    ?>
+    <div class="text-secondary"><?= @($review->memo) ?: '' ?></div>
+    <?php
+}
+else {
+    ?> - <?php
+}
+?>
+

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

@@ -0,0 +1,136 @@
+<?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-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-field-name="memo"><?= @($currentValue->memo) ?></div>
+            </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>
+            </div>
+        </form>
+    </div>
+<?php endif; ?>
+

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

@@ -0,0 +1,35 @@
+<div class="mb-1 font-weight-bold text-secondary">Current Strength Training</div>
+<?php if ($point->lastChildReview): ?>
+    <?php $parsedReview = json_decode($point->lastChildReview->data); ?>
+    <div class="<?= $point->last_child_review_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
+        <div class="inline-html-container">
+            <?php $review = $parsedReview; ?>
+            <?php include(resource_path('views/app/patient/segment-templates/_child_review/exercise/' . $p['category'] . '/view-review.php')); ?>
+        </div>
+
+        <?php if ($point->last_child_review_point_scoped_note_id === $patient->core_note_id): ?>
+            <span class="text-sm">(updated on the patient's chart)</span>
+        <?php else: ?>
+            <?php if ($point->last_child_review_point_scoped_note_id === $note->id): ?>
+                <span class="text-sm">(updated on this note)</span>
+            <?php else: ?>
+                <div class="d-inline position-relative on-click-menu">
+                    <span class="text-sm text-primary c-pointer">
+                        <?= relative_friendly_date($point->last_child_review_effective_date) ?>
+                        <?php if($point->lastChildReview->creatorPro): ?>
+                        by <?= $point->lastChildReview->creatorPro->displayName() ?>
+                        <?php endif; ?>
+                    </span>
+                    <div menu right class="bg-white border">
+                        <a native target="_blank"
+                           href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $point->lastChildReviewNote]) ?>"
+                           class="px-2 py-1 d-block text-nowrap text-sm">Go to note</a>
+                    </div>
+                </div>
+            <?php endif; ?>
+        <?php endif; ?>
+
+    </div>
+<?php else: ?>
+    <span class="text-secondary text-sm">None</span>
+<?php endif; ?>

+ 36 - 0
resources/views/app/patient/segment-templates/_child_review/exercise/STRENGTH_TRAINING/view-review.php

@@ -0,0 +1,36 @@
+<?php
+if(@$review && @($review->active)) {
+    if (@($review->muscleStrengthening)) {
+    ?>
+        <div class="mb-1">Currently doing muscle strengthening exercises on moderate or greater intensity at least two days per week.</div>
+    <?php
+    }
+    if (@($review->allMajorMuscleGroups)) {
+        ?>
+        <div class="mb-1">Currently doing exercises to strengthen all major muscle groups: legs, hips, back, chest, abdomen, shoulders and arms.</div>
+        <?php
+    }
+    if (@($review->sets)) {
+        ?>
+        <div class="mb-1">Sets per exercise: <?= $review->sets ?>.</div>
+        <?php
+    }
+    if (@($review->reps)) {
+        ?>
+        <div class="mb-1">Repetitions per set: <?= $review->reps ?>.</div>
+        <?php
+    }
+    if (@($review->resistanceBandsBodyWeight)) {
+        ?>
+        <div class="mb-1">Currently using resistance bands or using body weight to do exercises.</div>
+        <?php
+    }
+    ?>
+    <div class="text-secondary"><?= @($review->memo) ?: '' ?></div>
+    <?php
+}
+else {
+    ?> - <?php
+}
+?>
+

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

@@ -0,0 +1,118 @@
+<?php
+$currentValue = '';
+$previousValue = '';
+$previousChildReview = null;
+if (@$point) {
+    if ($point->lastChildReview && $point->last_child_review_point_scoped_note_id === $note->id) {
+        $parsedReview = json_decode($point->lastChildReview->data);
+        if(@$parsedReview->value) {
+            $currentValue = $parsedReview->value;
+            $previousChildReview = \App\Models\Point::where('id', '<', $point->lastChildReview->id)
+                ->where('category', 'REVIEW')
+                ->where('parent_point_id', $point->id)
+                ->orderBy('id', 'DESC')
+                ->first();
+            if($previousChildReview && $previousChildReview->data) {
+                $parsedReview = json_decode($previousChildReview->data);
+                $previousValue = $parsedReview->value;
+            }
+        }
+    }
+    else {
+        $previousChildReview = \App\Models\Point::where('parent_point_id', $point->id)
+            ->where('category', 'REVIEW')
+            ->orderBy('id', 'DESC')
+            ->first();
+        if($previousChildReview && $previousChildReview->data) {
+            $parsedReview = json_decode($previousChildReview->data);
+            if(@$parsedReview->value) {
+                $previousValue = $parsedReview->value;
+            }
+        }
+    }
+}
+?>
+<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>
+    <?php if($point): ?>
+        <form 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">
+
+            <?php if($segment->segmentTemplate->internal_name === 'intake_problems' && $previousValue): ?>
+                <div class="d-none disallow-if-value-same-as"><?= str_compact($previousValue) ?></div>
+            <?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) ?>) (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
+                     <?= $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 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>
+        </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; ?>
+

+ 32 - 0
resources/views/app/patient/segment-templates/_child_review/nutrition/DAILY_INTAKE_CALORIES/last-review.php

@@ -0,0 +1,32 @@
+<div class="mb-1 font-weight-bold text-secondary">Current Daily Calories</div>
+<?php if ($point->lastChildReview): ?>
+    <?php $parsedReview = json_decode($point->lastChildReview->data); ?>
+    <div class="<?= $point->last_child_review_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
+        <div class="inline-html-container"><?= @$parsedReview->value ?></div>
+
+        <?php if ($point->last_child_review_point_scoped_note_id === $patient->core_note_id): ?>
+            <span class="text-sm">(updated on the patient's chart)</span>
+        <?php else: ?>
+            <?php if ($point->last_child_review_point_scoped_note_id === $note->id): ?>
+                <span class="text-sm">(updated on this note)</span>
+            <?php else: ?>
+                <div class="d-inline position-relative on-click-menu">
+                    <span class="text-sm text-primary c-pointer">
+                        <?= relative_friendly_date($point->last_child_review_effective_date) ?>
+                        <?php if($point->lastChildReview->creatorPro): ?>
+                        by <?= $point->lastChildReview->creatorPro->displayName() ?>
+                        <?php endif; ?>
+                    </span>
+                    <div menu right class="bg-white border">
+                        <a native target="_blank"
+                           href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $point->lastChildReviewNote]) ?>"
+                           class="px-2 py-1 d-block text-nowrap text-sm">Go to note</a>
+                    </div>
+                </div>
+            <?php endif; ?>
+        <?php endif; ?>
+
+    </div>
+<?php else: ?>
+    <span class="text-secondary text-sm">None</span>
+<?php endif; ?>

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

@@ -0,0 +1,118 @@
+<?php
+$currentValue = '';
+$previousValue = '';
+$previousChildReview = null;
+if (@$point) {
+    if ($point->lastChildReview && $point->last_child_review_point_scoped_note_id === $note->id) {
+        $parsedReview = json_decode($point->lastChildReview->data);
+        if(@$parsedReview->value) {
+            $currentValue = $parsedReview->value;
+            $previousChildReview = \App\Models\Point::where('id', '<', $point->lastChildReview->id)
+                ->where('category', 'REVIEW')
+                ->where('parent_point_id', $point->id)
+                ->orderBy('id', 'DESC')
+                ->first();
+            if($previousChildReview && $previousChildReview->data) {
+                $parsedReview = json_decode($previousChildReview->data);
+                $previousValue = $parsedReview->value;
+            }
+        }
+    }
+    else {
+        $previousChildReview = \App\Models\Point::where('parent_point_id', $point->id)
+            ->where('category', 'REVIEW')
+            ->orderBy('id', 'DESC')
+            ->first();
+        if($previousChildReview && $previousChildReview->data) {
+            $parsedReview = json_decode($previousChildReview->data);
+            if(@$parsedReview->value) {
+                $previousValue = $parsedReview->value;
+            }
+        }
+    }
+}
+?>
+<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>
+    <?php if($point): ?>
+        <form 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">
+
+            <?php if($segment->segmentTemplate->internal_name === 'intake_problems' && $previousValue): ?>
+                <div class="d-none disallow-if-value-same-as"><?= str_compact($previousValue) ?></div>
+            <?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) ?>) (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
+                     <?= $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 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>
+        </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; ?>
+

+ 32 - 0
resources/views/app/patient/segment-templates/_child_review/nutrition/DAILY_INTAKE_CARBOHYDRATES/last-review.php

@@ -0,0 +1,32 @@
+<div class="mb-1 font-weight-bold text-secondary">Current Carbohydrate Intake (grams)</div>
+<?php if ($point->lastChildReview): ?>
+    <?php $parsedReview = json_decode($point->lastChildReview->data); ?>
+    <div class="<?= $point->last_child_review_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
+        <div class="inline-html-container"><?= @$parsedReview->value ?></div>
+
+        <?php if ($point->last_child_review_point_scoped_note_id === $patient->core_note_id): ?>
+            <span class="text-sm">(updated on the patient's chart)</span>
+        <?php else: ?>
+            <?php if ($point->last_child_review_point_scoped_note_id === $note->id): ?>
+                <span class="text-sm">(updated on this note)</span>
+            <?php else: ?>
+                <div class="d-inline position-relative on-click-menu">
+                    <span class="text-sm text-primary c-pointer">
+                        <?= relative_friendly_date($point->last_child_review_effective_date) ?>
+                        <?php if($point->lastChildReview->creatorPro): ?>
+                        by <?= $point->lastChildReview->creatorPro->displayName() ?>
+                        <?php endif; ?>
+                    </span>
+                    <div menu right class="bg-white border">
+                        <a native target="_blank"
+                           href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $point->lastChildReviewNote]) ?>"
+                           class="px-2 py-1 d-block text-nowrap text-sm">Go to note</a>
+                    </div>
+                </div>
+            <?php endif; ?>
+        <?php endif; ?>
+
+    </div>
+<?php else: ?>
+    <span class="text-secondary text-sm">None</span>
+<?php endif; ?>

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

@@ -0,0 +1,131 @@
+<?php
+$currentMealsPerWeek = '';
+$currentSelfPreparedMealsPerWeek = '';
+$previousValue = '';
+$previousChildReview = null;
+if (@$point) {
+    if ($point->lastChildReview && $point->last_child_review_point_scoped_note_id === $note->id) {
+        $parsedReview = json_decode($point->lastChildReview->data);
+        $currentMealsPerWeek = @($parsedReview->mealsPerWeek) ?: '';
+        $currentSelfPreparedMealsPerWeek = @($parsedReview->selfPrepMealsPerWeek) ?: '';
+        $previousChildReview = \App\Models\Point::where('id', '<', $point->lastChildReview->id)
+            ->where('category', 'REVIEW')
+            ->where('parent_point_id', $point->id)
+            ->orderBy('id', 'DESC')
+            ->first();
+        if($previousChildReview && $previousChildReview->data) {
+            $parsedReview = json_decode($previousChildReview->data);
+            $previousValue = '<span class="text-sm">Meals per week:</span> ' . (@($parsedReview->mealsPerWeek) ? strip_tags($parsedReview->mealsPerWeek) : '-') . '<br>' .
+                '<span class="text-sm">Self-prepared meals per week:</span> ' . (@($parsedReview->selfPrepMealsPerWeek) ? strip_tags($parsedReview->selfPrepMealsPerWeek) : '-');
+        }
+    }
+    else {
+        $previousChildReview = \App\Models\Point::where('parent_point_id', $point->id)
+            ->where('category', 'REVIEW')
+            ->orderBy('id', 'DESC')
+            ->first();
+        if($previousChildReview && $previousChildReview->data) {
+            $parsedReview = json_decode($previousChildReview->data);
+            $previousValue = '<span class="text-sm">Meals per week:</span> ' . (@($parsedReview->mealsPerWeek) ? strip_tags($parsedReview->mealsPerWeek) : '-') . '<br>' .
+                '<span class="text-sm">Self-prepared meals per week:</span> ' . (@($parsedReview->selfPrepMealsPerWeek) ? strip_tags($parsedReview->selfPrepMealsPerWeek) : '-');
+        }
+    }
+}
+?>
+<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>
+    <?php if($point): ?>
+        <form 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">
+
+            <?php if($segment->segmentTemplate->internal_name === 'intake_problems' && $previousValue): ?>
+                <div class="d-none disallow-if-value-same-as"><?= str_compact($previousValue) ?></div>
+            <?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) ?>) (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="mealsPerWeek"><?= $currentMealsPerWeek ?></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="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>
+        </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; ?>
+

+ 33 - 0
resources/views/app/patient/segment-templates/_child_review/nutrition/FAST_FOOD/last-review.php

@@ -0,0 +1,33 @@
+<div class="mb-1 font-weight-bold text-secondary">Current Consumption</div>
+<?php if ($point->lastChildReview): ?>
+    <?php $parsedReview = json_decode($point->lastChildReview->data); ?>
+    <div class="<?= $point->last_child_review_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
+        <div class="inline-html-container mb-1"><span class="text-sm">Meals per week:</span> <?= @$parsedReview->mealsPerWeek ? strip_tags($parsedReview->mealsPerWeek) : '' ?></div>
+        <div class="inline-html-container mb-1"><span class="text-sm">Self-prepared meals per week:</span> <?= @$parsedReview->selfPrepMealsPerWeek ? strip_tags($parsedReview->selfPrepMealsPerWeek) : '' ?></div>
+
+        <?php if ($point->last_child_review_point_scoped_note_id === $patient->core_note_id): ?>
+            <span class="text-sm">(updated on the patient's chart)</span>
+        <?php else: ?>
+            <?php if ($point->last_child_review_point_scoped_note_id === $note->id): ?>
+                <span class="text-sm">(updated on this note)</span>
+            <?php else: ?>
+                <div class="d-inline position-relative on-click-menu">
+                    <span class="text-sm text-primary c-pointer">
+                        <?= relative_friendly_date($point->last_child_review_effective_date) ?>
+                        <?php if($point->lastChildReview->creatorPro): ?>
+                            by <?= $point->lastChildReview->creatorPro->displayName() ?>
+                        <?php endif; ?>
+                    </span>
+                    <div menu right class="bg-white border">
+                        <a native target="_blank"
+                           href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $point->lastChildReviewNote]) ?>"
+                           class="px-2 py-1 d-block text-nowrap text-sm">Go to note</a>
+                    </div>
+                </div>
+            <?php endif; ?>
+        <?php endif; ?>
+
+    </div>
+<?php else: ?>
+    <span class="text-secondary text-sm">None</span>
+<?php endif; ?>

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

@@ -0,0 +1,118 @@
+<?php
+$currentValue = '';
+$previousValue = '';
+$previousChildReview = null;
+if (@$point) {
+    if ($point->lastChildReview && $point->last_child_review_point_scoped_note_id === $note->id) {
+        $parsedReview = json_decode($point->lastChildReview->data);
+        if(@$parsedReview->value) {
+            $currentValue = $parsedReview->value;
+            $previousChildReview = \App\Models\Point::where('id', '<', $point->lastChildReview->id)
+                ->where('category', 'REVIEW')
+                ->where('parent_point_id', $point->id)
+                ->orderBy('id', 'DESC')
+                ->first();
+            if($previousChildReview && $previousChildReview->data) {
+                $parsedReview = json_decode($previousChildReview->data);
+                $previousValue = $parsedReview->value;
+            }
+        }
+    }
+    else {
+        $previousChildReview = \App\Models\Point::where('parent_point_id', $point->id)
+            ->where('category', 'REVIEW')
+            ->orderBy('id', 'DESC')
+            ->first();
+        if($previousChildReview && $previousChildReview->data) {
+            $parsedReview = json_decode($previousChildReview->data);
+            if(@$parsedReview->value) {
+                $previousValue = $parsedReview->value;
+            }
+        }
+    }
+}
+?>
+<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>
+    <?php if($point): ?>
+        <form 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">
+
+            <?php if($segment->segmentTemplate->internal_name === 'intake_problems' && $previousValue): ?>
+                <div class="d-none disallow-if-value-same-as"><?= str_compact($previousValue) ?></div>
+            <?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) ?>) (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
+                     <?= $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 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>
+        </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; ?>
+

+ 32 - 0
resources/views/app/patient/segment-templates/_child_review/nutrition/HIGH_SUGAR_BEVERAGES/last-review.php

@@ -0,0 +1,32 @@
+<div class="mb-1 font-weight-bold text-secondary">Current Consumption</div>
+<?php if ($point->lastChildReview): ?>
+    <?php $parsedReview = json_decode($point->lastChildReview->data); ?>
+    <div class="<?= $point->last_child_review_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
+        <div class="inline-html-container"><?= @$parsedReview->value ?></div>
+
+        <?php if ($point->last_child_review_point_scoped_note_id === $patient->core_note_id): ?>
+            <span class="text-sm">(updated on the patient's chart)</span>
+        <?php else: ?>
+            <?php if ($point->last_child_review_point_scoped_note_id === $note->id): ?>
+                <span class="text-sm">(updated on this note)</span>
+            <?php else: ?>
+                <div class="d-inline position-relative on-click-menu">
+                    <span class="text-sm text-primary c-pointer">
+                        <?= relative_friendly_date($point->last_child_review_effective_date) ?>
+                        <?php if($point->lastChildReview->creatorPro): ?>
+                        by <?= $point->lastChildReview->creatorPro->displayName() ?>
+                        <?php endif; ?>
+                    </span>
+                    <div menu right class="bg-white border">
+                        <a native target="_blank"
+                           href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $point->lastChildReviewNote]) ?>"
+                           class="px-2 py-1 d-block text-nowrap text-sm">Go to note</a>
+                    </div>
+                </div>
+            <?php endif; ?>
+        <?php endif; ?>
+
+    </div>
+<?php else: ?>
+    <span class="text-secondary text-sm">None</span>
+<?php endif; ?>

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

@@ -0,0 +1,118 @@
+<?php
+$currentValue = '';
+$previousValue = '';
+$previousChildReview = null;
+if (@$point) {
+    if ($point->lastChildReview && $point->last_child_review_point_scoped_note_id === $note->id) {
+        $parsedReview = json_decode($point->lastChildReview->data);
+        if(@$parsedReview->value) {
+            $currentValue = $parsedReview->value;
+            $previousChildReview = \App\Models\Point::where('id', '<', $point->lastChildReview->id)
+                ->where('category', 'REVIEW')
+                ->where('parent_point_id', $point->id)
+                ->orderBy('id', 'DESC')
+                ->first();
+            if($previousChildReview && $previousChildReview->data) {
+                $parsedReview = json_decode($previousChildReview->data);
+                $previousValue = $parsedReview->value;
+            }
+        }
+    }
+    else {
+        $previousChildReview = \App\Models\Point::where('parent_point_id', $point->id)
+            ->where('category', 'REVIEW')
+            ->orderBy('id', 'DESC')
+            ->first();
+        if($previousChildReview && $previousChildReview->data) {
+            $parsedReview = json_decode($previousChildReview->data);
+            if(@$parsedReview->value) {
+                $previousValue = $parsedReview->value;
+            }
+        }
+    }
+}
+?>
+<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>
+    <?php if($point): ?>
+        <form 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">
+
+            <?php if($segment->segmentTemplate->internal_name === 'intake_problems' && $previousValue): ?>
+                <div class="d-none disallow-if-value-same-as"><?= str_compact($previousValue) ?></div>
+            <?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) ?>) (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
+                     <?= $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 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>
+        </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; ?>
+

+ 32 - 0
resources/views/app/patient/segment-templates/_child_review/nutrition/PORTION_SIZES/last-review.php

@@ -0,0 +1,32 @@
+<div class="mb-1 font-weight-bold text-secondary">Current average number of servings/meal</div>
+<?php if ($point->lastChildReview): ?>
+    <?php $parsedReview = json_decode($point->lastChildReview->data); ?>
+    <div class="<?= $point->last_child_review_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
+        <div class="inline-html-container"><?= @$parsedReview->value ?></div>
+
+        <?php if ($point->last_child_review_point_scoped_note_id === $patient->core_note_id): ?>
+            <span class="text-sm">(updated on the patient's chart)</span>
+        <?php else: ?>
+            <?php if ($point->last_child_review_point_scoped_note_id === $note->id): ?>
+                <span class="text-sm">(updated on this note)</span>
+            <?php else: ?>
+                <div class="d-inline position-relative on-click-menu">
+                    <span class="text-sm text-primary c-pointer">
+                        <?= relative_friendly_date($point->last_child_review_effective_date) ?>
+                        <?php if($point->lastChildReview->creatorPro): ?>
+                        by <?= $point->lastChildReview->creatorPro->displayName() ?>
+                        <?php endif; ?>
+                    </span>
+                    <div menu right class="bg-white border">
+                        <a native target="_blank"
+                           href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $point->lastChildReviewNote]) ?>"
+                           class="px-2 py-1 d-block text-nowrap text-sm">Go to note</a>
+                    </div>
+                </div>
+            <?php endif; ?>
+        <?php endif; ?>
+
+    </div>
+<?php else: ?>
+    <span class="text-secondary text-sm">None</span>
+<?php endif; ?>

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

@@ -0,0 +1,131 @@
+<?php
+$currentUnhealthySnacks = '';
+$currentHealthySnacks = '';
+$previousValue = '';
+$previousChildReview = null;
+if (@$point) {
+    if ($point->lastChildReview && $point->last_child_review_point_scoped_note_id === $note->id) {
+        $parsedReview = json_decode($point->lastChildReview->data);
+        $currentUnhealthySnacks = @($parsedReview->unhealthySnacks) ?: '';
+        $currentHealthySnacks = @($parsedReview->healthySnacks) ?: '';
+        $previousChildReview = \App\Models\Point::where('id', '<', $point->lastChildReview->id)
+            ->where('category', 'REVIEW')
+            ->where('parent_point_id', $point->id)
+            ->orderBy('id', 'DESC')
+            ->first();
+        if($previousChildReview && $previousChildReview->data) {
+            $parsedReview = json_decode($previousChildReview->data);
+            $previousValue = '<span class="text-sm">Unhealthy snacks:</span> ' . (@($parsedReview->unhealthySnacks) ? strip_tags($parsedReview->unhealthySnacks) : '-') . '<br>' .
+                '<span class="text-sm">Healthy snacks:</span> ' . (@($parsedReview->healthySnacks) ? strip_tags($parsedReview->healthySnacks) : '-');
+        }
+    }
+    else {
+        $previousChildReview = \App\Models\Point::where('parent_point_id', $point->id)
+            ->where('category', 'REVIEW')
+            ->orderBy('id', 'DESC')
+            ->first();
+        if($previousChildReview && $previousChildReview->data) {
+            $parsedReview = json_decode($previousChildReview->data);
+            $previousValue = '<span class="text-sm">Unhealthy snacks:</span> ' . (@($parsedReview->unhealthySnacks) ? strip_tags($parsedReview->unhealthySnacks) : '-') . '<br>' .
+                '<span class="text-sm">Healthy snacks:</span> ' . (@($parsedReview->healthySnacks) ? strip_tags($parsedReview->healthySnacks) : '-');
+        }
+    }
+}
+?>
+<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>
+    <?php if($point): ?>
+        <form 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">
+
+            <?php if($segment->segmentTemplate->internal_name === 'intake_problems' && $previousValue): ?>
+                <div class="d-none disallow-if-value-same-as"><?= str_compact($previousValue) ?></div>
+            <?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) ?>) (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="unhealthySnacks"><?= $currentUnhealthySnacks ?></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="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>
+        </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; ?>
+

+ 33 - 0
resources/views/app/patient/segment-templates/_child_review/nutrition/SNACKS/last-review.php

@@ -0,0 +1,33 @@
+<div class="mb-1 font-weight-bold text-secondary">Current Consumption</div>
+<?php if ($point->lastChildReview): ?>
+    <?php $parsedReview = json_decode($point->lastChildReview->data); ?>
+    <div class="<?= $point->last_child_review_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
+        <div class="inline-html-container mb-1"><span class="text-sm">Unhealthy snacks:</span> <?= @$parsedReview->unhealthySnacks ? strip_tags($parsedReview->unhealthySnacks) : '' ?></div>
+        <div class="inline-html-container mb-1"><span class="text-sm">Healthy snacks:</span> <?= @$parsedReview->healthySnacks ? strip_tags($parsedReview->healthySnacks) : '' ?></div>
+
+        <?php if ($point->last_child_review_point_scoped_note_id === $patient->core_note_id): ?>
+            <span class="text-sm">(updated on the patient's chart)</span>
+        <?php else: ?>
+            <?php if ($point->last_child_review_point_scoped_note_id === $note->id): ?>
+                <span class="text-sm">(updated on this note)</span>
+            <?php else: ?>
+                <div class="d-inline position-relative on-click-menu">
+                    <span class="text-sm text-primary c-pointer">
+                        <?= relative_friendly_date($point->last_child_review_effective_date) ?>
+                        <?php if($point->lastChildReview->creatorPro): ?>
+                            by <?= $point->lastChildReview->creatorPro->displayName() ?>
+                        <?php endif; ?>
+                    </span>
+                    <div menu right class="bg-white border">
+                        <a native target="_blank"
+                           href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $point->lastChildReviewNote]) ?>"
+                           class="px-2 py-1 d-block text-nowrap text-sm">Go to note</a>
+                    </div>
+                </div>
+            <?php endif; ?>
+        <?php endif; ?>
+
+    </div>
+<?php else: ?>
+    <span class="text-secondary text-sm">None</span>
+<?php endif; ?>

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

@@ -0,0 +1,118 @@
+<?php
+$currentValue = '';
+$previousValue = '';
+$previousChildReview = null;
+if (@$point) {
+    if ($point->lastChildReview && $point->last_child_review_point_scoped_note_id === $note->id) {
+        $parsedReview = json_decode($point->lastChildReview->data);
+        if(@$parsedReview->value) {
+            $currentValue = $parsedReview->value;
+            $previousChildReview = \App\Models\Point::where('id', '<', $point->lastChildReview->id)
+                ->where('category', 'REVIEW')
+                ->where('parent_point_id', $point->id)
+                ->orderBy('id', 'DESC')
+                ->first();
+            if($previousChildReview && $previousChildReview->data) {
+                $parsedReview = json_decode($previousChildReview->data);
+                $previousValue = $parsedReview->value;
+            }
+        }
+    }
+    else {
+        $previousChildReview = \App\Models\Point::where('parent_point_id', $point->id)
+            ->where('category', 'REVIEW')
+            ->orderBy('id', 'DESC')
+            ->first();
+        if($previousChildReview && $previousChildReview->data) {
+            $parsedReview = json_decode($previousChildReview->data);
+            if(@$parsedReview->value) {
+                $previousValue = $parsedReview->value;
+            }
+        }
+    }
+}
+?>
+<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>
+    <?php if($point): ?>
+        <form 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">
+
+            <?php if($segment->segmentTemplate->internal_name === 'intake_problems' && $previousValue): ?>
+                <div class="d-none disallow-if-value-same-as"><?= str_compact($previousValue) ?></div>
+            <?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) ?>) (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
+                     <?= $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 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>
+        </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; ?>
+

+ 32 - 0
resources/views/app/patient/segment-templates/_child_review/nutrition/VEGETABLES/last-review.php

@@ -0,0 +1,32 @@
+<div class="mb-1 font-weight-bold text-secondary">Current Consumption</div>
+<?php if ($point->lastChildReview): ?>
+    <?php $parsedReview = json_decode($point->lastChildReview->data); ?>
+    <div class="<?= $point->last_child_review_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
+        <div class="inline-html-container"><?= @$parsedReview->value ?></div>
+
+        <?php if ($point->last_child_review_point_scoped_note_id === $patient->core_note_id): ?>
+            <span class="text-sm">(updated on the patient's chart)</span>
+        <?php else: ?>
+            <?php if ($point->last_child_review_point_scoped_note_id === $note->id): ?>
+                <span class="text-sm">(updated on this note)</span>
+            <?php else: ?>
+                <div class="d-inline position-relative on-click-menu">
+                    <span class="text-sm text-primary c-pointer">
+                        <?= relative_friendly_date($point->last_child_review_effective_date) ?>
+                        <?php if($point->lastChildReview->creatorPro): ?>
+                        by <?= $point->lastChildReview->creatorPro->displayName() ?>
+                        <?php endif; ?>
+                    </span>
+                    <div menu right class="bg-white border">
+                        <a native target="_blank"
+                           href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $point->lastChildReviewNote]) ?>"
+                           class="px-2 py-1 d-block text-nowrap text-sm">Go to note</a>
+                    </div>
+                </div>
+            <?php endif; ?>
+        <?php endif; ?>
+
+    </div>
+<?php else: ?>
+    <span class="text-secondary text-sm">None</span>
+<?php endif; ?>

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

@@ -0,0 +1,118 @@
+<?php
+$currentValue = '';
+$previousValue = '';
+$previousChildReview = null;
+if (@$point) {
+    if ($point->lastChildReview && $point->last_child_review_point_scoped_note_id === $note->id) {
+        $parsedReview = json_decode($point->lastChildReview->data);
+        if(@$parsedReview->value) {
+            $currentValue = $parsedReview->value;
+            $previousChildReview = \App\Models\Point::where('id', '<', $point->lastChildReview->id)
+                ->where('category', 'REVIEW')
+                ->where('parent_point_id', $point->id)
+                ->orderBy('id', 'DESC')
+                ->first();
+            if($previousChildReview && $previousChildReview->data) {
+                $parsedReview = json_decode($previousChildReview->data);
+                $previousValue = $parsedReview->value;
+            }
+        }
+    }
+    else {
+        $previousChildReview = \App\Models\Point::where('parent_point_id', $point->id)
+            ->where('category', 'REVIEW')
+            ->orderBy('id', 'DESC')
+            ->first();
+        if($previousChildReview && $previousChildReview->data) {
+            $parsedReview = json_decode($previousChildReview->data);
+            if(@$parsedReview->value) {
+                $previousValue = $parsedReview->value;
+            }
+        }
+    }
+}
+?>
+<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>
+    <?php if($point): ?>
+        <form 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">
+
+            <?php if($segment->segmentTemplate->internal_name === 'intake_problems' && $previousValue): ?>
+                <div class="d-none disallow-if-value-same-as"><?= str_compact($previousValue) ?></div>
+            <?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) ?>) (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
+                     <?= $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 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>
+        </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; ?>
+

+ 32 - 0
resources/views/app/patient/segment-templates/_child_review/nutrition/WATER_INTAKE/last-review.php

@@ -0,0 +1,32 @@
+<div class="mb-1 font-weight-bold text-secondary">Current Intake (ounces per day)</div>
+<?php if ($point->lastChildReview): ?>
+    <?php $parsedReview = json_decode($point->lastChildReview->data); ?>
+    <div class="<?= $point->last_child_review_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
+        <div class="inline-html-container"><?= @$parsedReview->value ?></div>
+
+        <?php if ($point->last_child_review_point_scoped_note_id === $patient->core_note_id): ?>
+            <span class="text-sm">(updated on the patient's chart)</span>
+        <?php else: ?>
+            <?php if ($point->last_child_review_point_scoped_note_id === $note->id): ?>
+                <span class="text-sm">(updated on this note)</span>
+            <?php else: ?>
+                <div class="d-inline position-relative on-click-menu">
+                    <span class="text-sm text-primary c-pointer">
+                        <?= relative_friendly_date($point->last_child_review_effective_date) ?>
+                        <?php if($point->lastChildReview->creatorPro): ?>
+                        by <?= $point->lastChildReview->creatorPro->displayName() ?>
+                        <?php endif; ?>
+                    </span>
+                    <div menu right class="bg-white border">
+                        <a native target="_blank"
+                           href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $point->lastChildReviewNote]) ?>"
+                           class="px-2 py-1 d-block text-nowrap text-sm">Go to note</a>
+                    </div>
+                </div>
+            <?php endif; ?>
+        <?php endif; ?>
+
+    </div>
+<?php else: ?>
+    <span class="text-secondary text-sm">None</span>
+<?php endif; ?>

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


+ 38 - 0
resources/views/app/patient/segment-templates/intake_exercise/summary.blade.php

@@ -0,0 +1,38 @@
+<?php
+
+use App\Models\Point;
+
+/** @var \App\Models\Client $patient */
+
+$aerobicActivity = Point::getOnlyPointOfCategory($patient, 'AEROBIC_ACTIVITY');
+$strengthTraining = Point::getOnlyPointOfCategory($patient, 'STRENGTH_TRAINING');
+$neat = Point::getOnlyPointOfCategory($patient, 'NEAT');
+
+$points = [
+    ["category" => 'AEROBIC_ACTIVITY', "name" => 'Aerobic Activity', "point" => $aerobicActivity],
+    ["category" => 'STRENGTH_TRAINING', "name" => 'Strength Training', "point" => $strengthTraining],
+    ["category" => 'NEAT', "name" => 'Non-Exercise Activity Time (NEAT)', "point" => $neat],
+];
+?>
+
+<?php foreach ($points as $p): ?>
+<?php $point = $p['point']; ?>
+<?php if(!!$point): ?>
+<?php $review = $point->lastChildReview; ?>
+<?php if ($review && @($review->data)) $review->data = json_decode($review->data); ?>
+<div class="mb-2">
+    <div class="d-flex align-items-baseline">
+        <b><?= $p['name'] ?></b>
+    </div>
+    <?php if(!!$review): ?>
+    <div class="pl-3 mt-1 d-flex align-items-baseline">
+        <span class="text-secondary font-weight-bold mr-2">Subjective:</span>
+        <div class="inline-html-container">
+            <?php $review = $review->data; ?>
+            <?php include(resource_path('views/app/patient/segment-templates/_child_review/exercise/' . $p['category'] . '/view-review.php')); ?>
+        </div>
+    </div>
+    <?php endif; ?>
+</div>
+<?php endif; ?>
+<?php endforeach; ?>

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


+ 55 - 0
resources/views/app/patient/segment-templates/intake_nutrition/summary.blade.php

@@ -0,0 +1,55 @@
+<?php
+
+use App\Models\Point;
+
+/** @var \App\Models\Client $patient */
+
+$highSugarBeverages = Point::getOnlyPointOfCategory($patient, 'HIGH_SUGAR_BEVERAGES');
+$waterIntake = Point::getOnlyPointOfCategory($patient, 'WATER_INTAKE');
+$fastFood = Point::getOnlyPointOfCategory($patient, 'FAST_FOOD');
+$snacks = Point::getOnlyPointOfCategory($patient, 'SNACKS');
+$vegetables = Point::getOnlyPointOfCategory($patient, 'VEGETABLES');
+$portionSizes = Point::getOnlyPointOfCategory($patient, 'PORTION_SIZES');
+$dailyIntakeCarbohydrates = Point::getOnlyPointOfCategory($patient, 'DAILY_INTAKE_CARBOHYDRATES');
+$dailyIntakeCalories = Point::getOnlyPointOfCategory($patient, 'DAILY_INTAKE_CALORIES');
+
+$points = [
+    ["category" => 'HIGH_SUGAR_BEVERAGES', "name" => 'High Sugar Beverages', "point" => $highSugarBeverages],
+    ["category" => 'WATER_INTAKE', "name" => 'Water Intake', "point" => $waterIntake],
+    ["category" => 'FAST_FOOD', "name" => 'Fast Food', "point" => $fastFood],
+    ["category" => 'SNACKS', "name" => 'Snacks', "point" => $snacks],
+    ["category" => 'VEGETABLES', "name" => 'Vegetables', "point" => $vegetables],
+    ["category" => 'PORTION_SIZES', "name" => 'Portion Sizes', "point" => $portionSizes],
+    ["category" => 'DAILY_INTAKE_CARBOHYDRATES', "name" => 'Daily Intake Carbohydrates', "point" => $dailyIntakeCarbohydrates],
+    ["category" => 'DAILY_INTAKE_CALORIES', "name" => 'Daily Intake Calories', "point" => $dailyIntakeCalories],
+];
+?>
+
+<?php foreach ($points as $p): ?>
+<?php $point = $p['point']; ?>
+<?php if(!!$point): ?>
+<?php $review = $point->lastChildReview; ?>
+<?php if ($review && @($review->data)) $review->data = json_decode($review->data); ?>
+<div class="mb-2">
+    <div class="d-flex align-items-baseline">
+        <b><?= $p['name'] ?></b>
+    </div>
+    <?php if(!!$review): ?>
+    <div class="pl-3 mt-1 d-flex align-items-baseline">
+        <span class="text-secondary font-weight-bold mr-2">Subjective:</span>
+        <div>
+            <?php if($p['category'] === 'FAST_FOOD'): ?>
+                <div class="mb-1"><span class="text-sm">Meals per week:</span> <?= @$review->data->mealsPerWeek ? strip_tags($review->data->mealsPerWeek) : '' ?></div>
+                <div class="mb-1"><span class="text-sm">Self-prepared meals per week:</span> <?= @$review->data->selfPrepMealsPerWeek ? strip_tags($review->data->selfPrepMealsPerWeek) : '' ?></div>
+            <?php elseif ($p['category'] === 'SNACKS'): ?>
+                <div class="mb-1"><span class="text-sm">Unhealthy snacks:</span> <?= @$review->data->unhealthySnacks ? strip_tags($review->data->unhealthySnacks) : '' ?></div>
+                <div class="mb-1"><span class="text-sm">Healthy snacks:</span> <?= @$review->data->healthySnacks ? strip_tags($review->data->healthySnacks) : '' ?></div>
+            <?php else: ?>
+                <span>{!! $review->data->value ? strip_tags($review->data->value) : '-' !!}</span>
+            <?php endif; ?>
+        </div>
+    </div>
+    <?php endif; ?>
+</div>
+<?php endif; ?>
+<?php endforeach; ?>

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


+ 38 - 0
resources/views/app/patient/segment-templates/plan_exercise/summary.blade.php

@@ -0,0 +1,38 @@
+<?php
+
+use App\Models\Point;
+
+/** @var \App\Models\Client $patient */
+
+$aerobicActivity = Point::getOnlyPointOfCategory($patient, 'AEROBIC_ACTIVITY');
+$strengthTraining = Point::getOnlyPointOfCategory($patient, 'STRENGTH_TRAINING');
+$neat = Point::getOnlyPointOfCategory($patient, 'NEAT');
+
+$points = [
+    ["category" => 'AEROBIC_ACTIVITY', "name" => 'Aerobic Activity', "point" => $aerobicActivity],
+    ["category" => 'STRENGTH_TRAINING', "name" => 'Strength Training', "point" => $strengthTraining],
+    ["category" => 'NEAT', "name" => 'Non-Exercise Activity Time (NEAT)', "point" => $neat],
+];
+?>
+
+<?php foreach ($points as $p): ?>
+<?php $point = $p['point']; ?>
+<?php if(!!$point): ?>
+<?php $plan = $point->lastChildPlan; ?>
+<?php if ($plan && @($plan->data)) $plan->data = json_decode($plan->data); ?>
+<div class="mb-2">
+    <div class="d-flex align-items-baseline">
+        <b><?= $p['name'] ?></b>
+    </div>
+    <?php if(!!$plan): ?>
+    <div class="pl-3 mt-1 d-flex align-items-baseline">
+        <span class="text-secondary font-weight-bold mr-2">Plan:</span>
+        <div class="inline-html-container">
+            <?php $plan = $plan->data; ?>
+            <?php include(resource_path('views/app/patient/segment-templates/_child_plan/exercise/' . $p['category'] . '/view-plan.php')); ?>
+        </div>
+    </div>
+    <?php endif; ?>
+</div>
+<?php endif; ?>
+<?php endforeach; ?>

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


+ 45 - 0
resources/views/app/patient/segment-templates/plan_nutrition/summary.blade.php

@@ -0,0 +1,45 @@
+<?php
+
+use App\Models\Point;
+
+/** @var \App\Models\Client $patient */
+
+$highSugarBeverages = Point::getOnlyPointOfCategory($patient, 'HIGH_SUGAR_BEVERAGES');
+$waterIntake = Point::getOnlyPointOfCategory($patient, 'WATER_INTAKE');
+$fastFood = Point::getOnlyPointOfCategory($patient, 'FAST_FOOD');
+$snacks = Point::getOnlyPointOfCategory($patient, 'SNACKS');
+$vegetables = Point::getOnlyPointOfCategory($patient, 'VEGETABLES');
+$portionSizes = Point::getOnlyPointOfCategory($patient, 'PORTION_SIZES');
+$dailyIntakeCarbohydrates = Point::getOnlyPointOfCategory($patient, 'DAILY_INTAKE_CARBOHYDRATES');
+$dailyIntakeCalories = Point::getOnlyPointOfCategory($patient, 'DAILY_INTAKE_CALORIES');
+
+$points = [
+    ["category" => 'HIGH_SUGAR_BEVERAGES', "name" => 'High Sugar Beverages', "point" => $highSugarBeverages],
+    ["category" => 'WATER_INTAKE', "name" => 'Water Intake', "point" => $waterIntake],
+    ["category" => 'FAST_FOOD', "name" => 'Fast Food', "point" => $fastFood],
+    ["category" => 'SNACKS', "name" => 'Snacks', "point" => $snacks],
+    ["category" => 'VEGETABLES', "name" => 'Vegetables', "point" => $vegetables],
+    ["category" => 'PORTION_SIZES', "name" => 'Portion Sizes', "point" => $portionSizes],
+    ["category" => 'DAILY_INTAKE_CARBOHYDRATES', "name" => 'Daily Intake Carbohydrates', "point" => $dailyIntakeCarbohydrates],
+    ["category" => 'DAILY_INTAKE_CALORIES', "name" => 'Daily Intake Calories', "point" => $dailyIntakeCalories],
+];
+?>
+
+<?php foreach ($points as $p): ?>
+<?php $point = $p['point']; ?>
+<?php if(!!$point): ?>
+<?php $plan = $point->lastChildPlan; ?>
+<?php if($plan && @($plan->data)) $plan->data = json_decode($plan->data); ?>
+<div class="mb-2">
+    <div class="d-flex align-items-baseline">
+        <b><?= $p['name'] ?></b>
+    </div>
+    <?php if(!!$plan): ?>
+    <div class="pl-3 mt-1 d-flex align-items-baseline">
+        <span class="text-secondary font-weight-bold mr-2">Plan:</span>
+        <span>{!! $plan->data->value ? strip_tags($plan->data->value) : '-' !!}</span>
+    </div>
+    <?php endif; ?>
+</div>
+<?php endif; ?>
+<?php endforeach; ?>

+ 0 - 1
resources/views/app/patient/vitals-settings/bmi-management-form.blade.php

@@ -188,7 +188,6 @@
             let parentSegment = $('#bmi-management-settings');
             parentSegment.find('[heightFeetInput], [heightInchesInput]').off('change input paste');
             parentSegment.find('[heightFeetInput], [heightInchesInput]').on('change input paste', function () {
-                debugger
                 let inches = 0;
                 let ft = +(parentSegment.find('[heightFeetInput]').val()),
                     inc = +(parentSegment.find('[heightInchesInput]').val());

+ 217 - 0
resources/views/app/patient/wizard-partials/common-script.blade.php

@@ -448,6 +448,223 @@ parentSegment.find('.frm-edit-{{$label}}')
         return false;
     });
 
+// 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 () {
+        let form = $(this);
+        showMask();
+        $.post(form.attr('url'), form.serialize(), _data => {
+            if(!hasResponseError(_data)) {
+                $('.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');
+                refreshDynamicStagPopup();
+            }
+        }).then(() => {
+            hideMask();
+        });
+        return false;
+    });
+
+/* exercise specific */
+parentSegment.find('.frm-review-plan-exercise [data-name="active"]')
+    .off('change')
+    .on('change', function () {
+        let form = $(this).closest('form');
+        form.find('[if-active]')[this.checked ? 'removeClass' : 'addClass']('d-none');
+        return false;
+    })
+    .trigger('change');
+parentSegment.find('.frm-review-plan-exercise [data-name="walk->active"]')
+    .off('change')
+    .on('change', function () {
+        let form = $(this).closest('form');
+        form.find('[if-walk-active]')[this.checked ? 'removeClass' : 'addClass']('d-none');
+        return false;
+    })
+    .trigger('change');
+parentSegment.find('.frm-review-plan-exercise [data-name="jog->active"]')
+    .off('change')
+    .on('change', function () {
+        let form = $(this).closest('form');
+        form.find('[if-jog-active]')[this.checked ? 'removeClass' : 'addClass']('d-none');
+        return false;
+    })
+    .trigger('change');
+parentSegment.find('.frm-review-plan-exercise [data-name="elliptical->active"]')
+    .off('change')
+    .on('change', function () {
+        let form = $(this).closest('form');
+        form.find('[if-elliptical-active]')[this.checked ? 'removeClass' : 'addClass']('d-none');
+        return false;
+    })
+    .trigger('change');
+parentSegment.find('.frm-review-plan-exercise [data-name="swim->active"]')
+    .off('change')
+    .on('change', function () {
+        let form = $(this).closest('form');
+        form.find('[if-swim-active]')[this.checked ? 'removeClass' : 'addClass']('d-none');
+        return false;
+    })
+    .trigger('change');
+parentSegment.find('.frm-review-plan-exercise [data-name="bike->active"]')
+    .off('change')
+    .on('change', function () {
+        let form = $(this).closest('form');
+        form.find('[if-bike-active]')[this.checked ? 'removeClass' : 'addClass']('d-none');
+        return false;
+    })
+    .trigger('change');
+parentSegment.find('.frm-review-plan-exercise .btn-toggle-activity[data-type]')
+    .off('click')
+    .on('click', function () {
+        let form = $(this).closest('form'),
+            checkbox = form.find('[data-name="' + $(this).attr('data-type') + '->active"]'),
+            current = checkbox.prop('checked');
+        if(!current) {
+            checkbox.prop('checked', true).trigger('change');
+            $(this).removeClass('btn-default border').addClass('btn-info');
+            $(this).closest('td').find('img').removeClass('opacity-35');
+        }
+        else {
+            checkbox.prop('checked', false).trigger('change');
+            $(this).removeClass('btn-info').addClass('btn-default border');
+            $(this).closest('td').find('img').addClass('opacity-35');
+        }
+        return false;
+    });
+parentSegment.find('.frm-review-plan-exercise')
+    .off('submit')
+    .on('submit', function () {
+        let form = $(this);
+        if (!form[0].checkValidity()) {
+            form[0].reportValidity();
+            return false;
+        }
+        let dataField = 'data';
+        if(form.find('[name="childReviewData"]').length) {
+            dataField = 'childReviewData';
+        }
+        else if(form.find('[name="childPlanData"]').length) {
+            dataField = 'childPlanData';
+        }
+        fillJsonDataField(form, dataField);
+        showMask();
+        $.post(form.attr('url'), form.serialize(), _data => {
+            if(!hasResponseError(_data)) {
+                $('.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');
+                refreshDynamicStagPopup();
+            }
+        }).then(() => {
+            hideMask();
+        });
+        return false;
+    });
+/* end of exercise specific */
+
 parentSegment.find('.toggle-relevance')
     .off('click.toggle-relevance')
     .on('click.toggle-relevance', function () {

+ 3 - 0
routes/web.php

@@ -473,6 +473,9 @@ Route::middleware('pro.auth')->group(function () {
     Route::get('/memos-thread/{patient}', 'PatientController@memosThread')->name('memos-thread');
     Route::get('/messages-thread/{patient}', 'PatientController@messagesThread')->name('messages-thread');
 
+    Route::get('/nutrition-center/{patient}/{note}', 'NoteController@nutritionCenter')->name('nutrition-center');
+    Route::get('/exercise-center/{patient}/{note}', 'NoteController@exerciseCenter')->name('exercise-center');
+
     Route::get('/problems-quick-add/{patient}/{note}', 'NoteController@problemsQuickAdd')->name('problems-quick-add');
 
     //mb claim single view