瀏覽代碼

Nutrition segments - all except fast-food and snacks

Vijayakrishnan 3 年之前
父節點
當前提交
5e689939ca
共有 18 個文件被更改,包括 1211 次插入4 次删除
  1. 3 0
      public/css/style.css
  2. 4 4
      resources/views/app/patient/nutrition-center.blade.php
  3. 118 0
      resources/views/app/patient/segment-templates/_child_plan/DAILY_INTAKE_CALORIES/edit-plan.php
  4. 33 0
      resources/views/app/patient/segment-templates/_child_plan/DAILY_INTAKE_CALORIES/last-plan.php
  5. 118 0
      resources/views/app/patient/segment-templates/_child_plan/DAILY_INTAKE_CARBOHYDRATES/edit-plan.php
  6. 33 0
      resources/views/app/patient/segment-templates/_child_plan/DAILY_INTAKE_CARBOHYDRATES/last-plan.php
  7. 118 0
      resources/views/app/patient/segment-templates/_child_plan/PORTION_SIZES/edit-plan.php
  8. 33 0
      resources/views/app/patient/segment-templates/_child_plan/PORTION_SIZES/last-plan.php
  9. 118 0
      resources/views/app/patient/segment-templates/_child_plan/VEGETABLES/edit-plan.php
  10. 33 0
      resources/views/app/patient/segment-templates/_child_plan/VEGETABLES/last-plan.php
  11. 118 0
      resources/views/app/patient/segment-templates/_child_review/DAILY_INTAKE_CALORIES/edit-review.php
  12. 32 0
      resources/views/app/patient/segment-templates/_child_review/DAILY_INTAKE_CALORIES/last-review.php
  13. 118 0
      resources/views/app/patient/segment-templates/_child_review/DAILY_INTAKE_CARBOHYDRATES/edit-review.php
  14. 32 0
      resources/views/app/patient/segment-templates/_child_review/DAILY_INTAKE_CARBOHYDRATES/last-review.php
  15. 118 0
      resources/views/app/patient/segment-templates/_child_review/PORTION_SIZES/edit-review.php
  16. 32 0
      resources/views/app/patient/segment-templates/_child_review/PORTION_SIZES/last-review.php
  17. 118 0
      resources/views/app/patient/segment-templates/_child_review/VEGETABLES/edit-review.php
  18. 32 0
      resources/views/app/patient/segment-templates/_child_review/VEGETABLES/last-review.php

+ 3 - 0
public/css/style.css

@@ -1534,6 +1534,9 @@ table.table-edit-sheet .ql-editor[contenteditable] {
 .w-35 {
     width: 35%;
 }
+.w-40 {
+    width: 40%;
+}
 .client-single-dashboard .hide-if-dashboard {
     display: none;
 }

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

@@ -21,11 +21,11 @@ $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" => '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],*/
+    ["category" => 'DAILY_INTAKE_CALORIES', "name" => 'Daily Intake Calories', "point" => $dailyIntakeCalories],
 ];
 ?>
 
@@ -40,7 +40,7 @@ $points = [
                     <td>
                         <b>{{$p['name']}}</b>
                     </td>
-                    <td>
+                    <td class="w-40">
                         <div class="d-flex align-items-start">
                             <div class="flex-grow-1">
                                 @if($point)
@@ -61,7 +61,7 @@ $points = [
                             </div>
                         </div>
                     </td>
-                    <td>
+                    <td class="w-40">
                         <div class="d-flex align-items-start position-relative">
                             <div class="flex-grow-1">
                                 @if($point)

+ 118 - 0
resources/views/app/patient/segment-templates/_child_plan/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 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>
+    <?php if($point): ?>
+        <form url="/api/visitPoint/upsertChildPlan" class="mcp-theme-1" right>
+            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+            <input type="hidden" name="data">
+
+            <?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 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" right>
+            <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>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="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/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/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 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>
+    <?php if($point): ?>
+        <form url="/api/visitPoint/upsertChildPlan" class="mcp-theme-1" right>
+            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+            <input type="hidden" name="data">
+
+            <?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 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" right>
+            <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>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="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/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/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 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>
+    <?php if($point): ?>
+        <form url="/api/visitPoint/upsertChildPlan" class="mcp-theme-1" right>
+            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+            <input type="hidden" name="data">
+
+            <?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 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" right>
+            <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>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="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/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/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 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>
+    <?php if($point): ?>
+        <form url="/api/visitPoint/upsertChildPlan" class="mcp-theme-1" right>
+            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+            <input type="hidden" name="data">
+
+            <?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 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" right>
+            <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>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="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/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_review/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 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>
+    <?php if($point): ?>
+        <form url="/api/visitPoint/upsertChildReview" class="mcp-theme-1" right>
+            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+            <input type="hidden" name="data">
+
+            <?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 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" right>
+            <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/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/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 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>
+    <?php if($point): ?>
+        <form url="/api/visitPoint/upsertChildReview" class="mcp-theme-1" right>
+            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+            <input type="hidden" name="data">
+
+            <?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 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" right>
+            <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/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; ?>

+ 118 - 0
resources/views/app/patient/segment-templates/_child_review/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 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>
+    <?php if($point): ?>
+        <form url="/api/visitPoint/upsertChildReview" class="mcp-theme-1" right>
+            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+            <input type="hidden" name="data">
+
+            <?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 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" right>
+            <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/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; ?>

+ 118 - 0
resources/views/app/patient/segment-templates/_child_review/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 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>
+    <?php if($point): ?>
+        <form url="/api/visitPoint/upsertChildReview" class="mcp-theme-1" right>
+            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+            <input type="hidden" name="data">
+
+            <?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 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" right>
+            <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/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; ?>