Răsfoiți Sursa

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

= 3 ani în urmă
părinte
comite
d89468fd00
55 a modificat fișierele cu 1815 adăugiri și 39 ștergeri
  1. 4 0
      app/Http/Controllers/NoteController.php
  2. 1 1
      config/app.php
  3. 10 1
      public/css/style.css
  4. BIN
      public/img/behavior-rx.png
  5. BIN
      public/img/behavior-rx/cravings.png
  6. BIN
      public/img/behavior-rx/food-log.png
  7. BIN
      public/img/behavior-rx/phone-tracker.png
  8. BIN
      public/img/behavior-rx/relaxation.png
  9. BIN
      public/img/behavior-rx/reward.png
  10. BIN
      public/img/behavior-rx/sleep.png
  11. BIN
      public/img/behavior-rx/social.png
  12. BIN
      public/img/behavior-rx/stress.png
  13. BIN
      public/img/behavior-rx/work.png
  14. 3 3
      resources/views/app/dna/care-months.blade.php
  15. 7 3
      resources/views/app/patient/accounts.blade.php
  16. 103 0
      resources/views/app/patient/behavior-center.blade.php
  17. 8 0
      resources/views/app/patient/note/dashboard.blade.php
  18. 10 0
      resources/views/app/patient/note/dashboard_script.blade.php
  19. 25 21
      resources/views/app/patient/prescriptions/list.blade.php
  20. 108 0
      resources/views/app/patient/segment-templates/_child_plan/behavior/CRAVINGS/edit-plan.php
  21. 35 0
      resources/views/app/patient/segment-templates/_child_plan/behavior/CRAVINGS/last-plan.php
  22. 10 0
      resources/views/app/patient/segment-templates/_child_plan/behavior/CRAVINGS/view-plan.php
  23. 107 0
      resources/views/app/patient/segment-templates/_child_plan/behavior/FOOD_TRIGGERS/edit-plan.php
  24. 35 0
      resources/views/app/patient/segment-templates/_child_plan/behavior/FOOD_TRIGGERS/last-plan.php
  25. 10 0
      resources/views/app/patient/segment-templates/_child_plan/behavior/FOOD_TRIGGERS/view-plan.php
  26. 180 0
      resources/views/app/patient/segment-templates/_child_plan/behavior/SELF_MONITORING/edit-plan.php
  27. 35 0
      resources/views/app/patient/segment-templates/_child_plan/behavior/SELF_MONITORING/last-plan.php
  28. 30 0
      resources/views/app/patient/segment-templates/_child_plan/behavior/SELF_MONITORING/view-plan.php
  29. 109 0
      resources/views/app/patient/segment-templates/_child_plan/behavior/SLEEP_HABITS/edit-plan.php
  30. 35 0
      resources/views/app/patient/segment-templates/_child_plan/behavior/SLEEP_HABITS/last-plan.php
  31. 11 0
      resources/views/app/patient/segment-templates/_child_plan/behavior/SLEEP_HABITS/view-plan.php
  32. 2 1
      resources/views/app/patient/segment-templates/_child_plan/exercise/AEROBIC_ACTIVITY/edit-plan.php
  33. 2 1
      resources/views/app/patient/segment-templates/_child_plan/exercise/NEAT/edit-plan.php
  34. 2 1
      resources/views/app/patient/segment-templates/_child_plan/exercise/STRENGTH_TRAINING/edit-plan.php
  35. 147 0
      resources/views/app/patient/segment-templates/_child_review/behavior/CRAVINGS/edit-review.php
  36. 35 0
      resources/views/app/patient/segment-templates/_child_review/behavior/CRAVINGS/last-review.php
  37. 24 0
      resources/views/app/patient/segment-templates/_child_review/behavior/CRAVINGS/view-review.php
  38. 150 0
      resources/views/app/patient/segment-templates/_child_review/behavior/FOOD_TRIGGERS/edit-review.php
  39. 35 0
      resources/views/app/patient/segment-templates/_child_review/behavior/FOOD_TRIGGERS/last-review.php
  40. 18 0
      resources/views/app/patient/segment-templates/_child_review/behavior/FOOD_TRIGGERS/view-review.php
  41. 180 0
      resources/views/app/patient/segment-templates/_child_review/behavior/SELF_MONITORING/edit-review.php
  42. 35 0
      resources/views/app/patient/segment-templates/_child_review/behavior/SELF_MONITORING/last-review.php
  43. 30 0
      resources/views/app/patient/segment-templates/_child_review/behavior/SELF_MONITORING/view-review.php
  44. 109 0
      resources/views/app/patient/segment-templates/_child_review/behavior/SLEEP_HABITS/edit-review.php
  45. 35 0
      resources/views/app/patient/segment-templates/_child_review/behavior/SLEEP_HABITS/last-review.php
  46. 11 0
      resources/views/app/patient/segment-templates/_child_review/behavior/SLEEP_HABITS/view-review.php
  47. 2 1
      resources/views/app/patient/segment-templates/_child_review/exercise/AEROBIC_ACTIVITY/edit-review.php
  48. 2 1
      resources/views/app/patient/segment-templates/_child_review/exercise/NEAT/edit-review.php
  49. 2 1
      resources/views/app/patient/segment-templates/_child_review/exercise/STRENGTH_TRAINING/edit-review.php
  50. 0 0
      resources/views/app/patient/segment-templates/intake_behavior/edit.blade.php
  51. 40 0
      resources/views/app/patient/segment-templates/intake_behavior/summary.blade.php
  52. 0 0
      resources/views/app/patient/segment-templates/plan_behavior/edit.blade.php
  53. 40 0
      resources/views/app/patient/segment-templates/plan_behavior/summary.blade.php
  54. 37 4
      resources/views/app/patient/wizard-partials/common-script.blade.php
  55. 1 0
      routes/web.php

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

@@ -406,6 +406,10 @@ class NoteController extends Controller
         return view('app.patient.exercise-center', compact('patient', 'note'));
     }
 
+    public function behaviorCenter(Request $request, Client $patient, Note $note) {
+        return view('app.patient.behavior-center', compact('patient', 'note'));
+    }
+
     public function ccmAgreement(Request $request, Note $note) {
         return view('app.patient.note.ccm-agreement', compact('note'));
     }

+ 1 - 1
config/app.php

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

+ 10 - 1
public/css/style.css

@@ -2151,7 +2151,7 @@ body.in-iframe .main-row > .sidebar {
 .note-container .note-lhs-tree:hover {
     overflow: overlay;
 }
-.note-container .note-lhs-tree.fixed {
+.note-container .note-lhs-tree.fixed, .note-container .note-lhs-tree.fixed-left {
     position: fixed;
     top: 55px;
     max-height: calc(100vh - 55px) !important;
@@ -2162,6 +2162,9 @@ body.in-iframe .main-row > .sidebar {
     margin-left: 220px;
     margin-right: 180px;
 }
+.note-container .note-lhs-tree.fixed-left ~ .note-rhs-content {
+    margin-left: 220px;
+}
 .note-container .note-lhs-tree .note-tree-node.note-tree-heading>a {
 
 }
@@ -2456,6 +2459,12 @@ td.row-selection-highlight:after {
 .border-top-exercise-rx {
     border-top: 3px solid #43c2cb;
 }
+.border-top-behavior-rx {
+    border-top: 3px solid #ffa82e;
+}
+.icon-nutrition-rx-md {
+    max-height: 22px;
+}
 .icon-nutrition-rx-row {
     max-height: 18px;
 }

BIN
public/img/behavior-rx.png


BIN
public/img/behavior-rx/cravings.png


BIN
public/img/behavior-rx/food-log.png


BIN
public/img/behavior-rx/phone-tracker.png


BIN
public/img/behavior-rx/relaxation.png


BIN
public/img/behavior-rx/reward.png


BIN
public/img/behavior-rx/sleep.png


BIN
public/img/behavior-rx/social.png


BIN
public/img/behavior-rx/stress.png


BIN
public/img/behavior-rx/work.png


+ 3 - 3
resources/views/app/dna/care-months.blade.php

@@ -62,14 +62,14 @@
                                 @endif
                             </div>
                         </td>
-                        <td>{{ $careMonth->client->mcp->displayName() }}</td>
+                        <td>{{ $careMonth->mcp ? $careMonth->mcp->displayName() : '--' }}</td>
                         <td>{{ $careMonth->number_of_days_with_remote_measurements }}</td>
                         <td>
                             <?php $bill = $careMonth->rmBill; ?>
                             @if($bill)
                             <div class="d-flex flex-column">
                                 <span>Code: {{ $bill->code }}</span>
-                                <a href="/patients/view/{{ $bill->note->client->uid }}/notes/view/{{ $bill->note->uid }}">Note</a>
+                                <a href="/patients/view/{{ $bill->careMonth->client->uid }}/notes/view/{{ $bill->careMonth->uid }}">Note</a>
                             </div>
                             @endif
                         </td>
@@ -92,4 +92,4 @@
         </div>
     </div>
 </div>
-@endsection
+@endsection

+ 7 - 3
resources/views/app/patient/accounts.blade.php

@@ -61,9 +61,13 @@
                                 <span class="text-sm text-secondary">(REMOVED)</span>
                             @endif
                         </td>
-                        <td>{{ $linkedAccount->account->name_first }} {{ $linkedAccount->account->name_last }}</pre></td>
-                        <td>{{ $linkedAccount->account->email }}</td>
-                        <td>{{ $linkedAccount->account->phone_number }}</td>
+                        <td>
+                        @if($linkedAccount->account)
+                            {{ $linkedAccount->account->name_first }} {{ $linkedAccount->account->name_last }}
+                        @endif
+                        </td>
+                        <td>{{ $linkedAccount->account->email ?? '' }}</td>
+                        <td>{{ $linkedAccount->account->phone_number ?? '' }}</td>
                         <td>
                             <div class="d-flex">
                                 <span class="width-40px">{{ $linkedAccount->is_access_allowed ? 'YES' : 'NO' }}</span>

+ 103 - 0
resources/views/app/patient/behavior-center.blade.php

@@ -0,0 +1,103 @@
+<?php
+
+use App\Models\Point;
+use App\Models\Client;
+use App\Models\Note;
+use App\Models\Segment;
+
+/** @var Client $patient */
+/** @var Note $note */
+
+$selfMonitoring = Point::getOnlyPointOfCategory($patient, 'SELF_MONITORING');
+$foodTriggers = Point::getOnlyPointOfCategory($patient, 'FOOD_TRIGGERS');
+$cravings = Point::getOnlyPointOfCategory($patient, 'CRAVINGS');
+$sleepHabits = Point::getOnlyPointOfCategory($patient, 'SLEEP_HABITS');
+
+$points = [
+    ["category" => 'SELF_MONITORING', "name" => 'Self Monitoring', "point" => $selfMonitoring],
+    ["category" => 'FOOD_TRIGGERS', "name" => 'Food Triggers', "point" => $foodTriggers],
+    ["category" => 'CRAVINGS', "name" => 'Cravings', "point" => $cravings],
+    ["category" => 'SLEEP_HABITS', "name" => 'Sleep Habits', "point" => $sleepHabits],
+];
+?>
+
+<div class="mt-3 p-3 border-top-behavior-rx" id="behavior-center-{{$note->id}}">
+    <div class="point-table-container">
+
+        <table class="table table-sm table-bordered mb-0 bg-white mb-2 point-table">
+
+            @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'] === 'CRAVINGS')
+                                <img src="/img/behavior-rx/cravings.png" class="icon-nutrition-rx-row" alt="">
+                            @elseif($p['category'] === 'SLEEP_HABITS')
+                                <img src="/img/behavior-rx/sleep.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/behavior/' . $p['category'] . '/last-review.php');
+                                    ?>
+                                @else
+                                    -
+                                @endif
+                            </div>
+                            <div class="d-inline-flex flex-column ml-1">
+                                <?php
+                                $segment = $note->getSegmentByInternalName('intake_behavior');
+                                if($segment) {
+                                    include resource_path('views/app/patient/segment-templates/_child_review/behavior/' . $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/behavior/' . $p['category'] . '/last-plan.php');
+                                    ?>
+                                @else
+                                    -
+                                @endif
+                            </div>
+                            <div class="d-inline-flex flex-column ml-1">
+                                <?php
+                                $segment = $note->getSegmentByInternalName('plan_behavior');
+                                if($segment) {
+                                    include resource_path('views/app/patient/segment-templates/_child_plan/behavior/' . $p['category'] . '/edit-plan.php');
+                                }
+                                ?>
+                            </div>
+                        </div>
+                    </td>
+                </tr>
+            @endforeach
+
+        </table>
+
+    </div>
+</div>
+<script>
+    (function() {
+        function init() {
+            let parentSegment = $('#behavior-center-{{$note->id}}');
+            @include('app.patient.wizard-partials.common-script', ['label' => 'behavior', 'segment_part' => 'behavior'])
+            initSegmentMoes(parentSegment);
+            __initRTEs(parentSegment.find('[note-rte]:not(.ql-container)'));
+        }
+        addMCInitializer('behavior-center-{{$note->id}}', init, '#behavior-center-{{$note->id}}');
+    }).call(window);
+</script>

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

@@ -2620,11 +2620,19 @@
                 if(!noteCardHeader.length) return;
                 let resultTop = (noteCardHeader.offset().top + noteCardHeader.outerHeight(true)) - $(window).scrollTop();
                 if(resultTop <= 55) {
+                    @if(!$note->is_signed_by_hcp)
                     tree.addClass('fixed');
                     rhsSidebar.addClass('fixed');
+                    @else
+                    tree.addClass('fixed-left');
+                    @endif
                 }
                 else {
+                    @if(!$note->is_signed_by_hcp)
                     tree.removeClass('fixed');
+                    @else
+                    tree.removeClass('fixed-left');
+                    @endif
                     tree.css('height', 'calc(100vh - ' + resultTop + 'px)');
                     tree.css('max-height', 'calc(100vh - ' + resultTop + 'px)');
                     rhsSidebar.removeClass('fixed');

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

@@ -175,6 +175,16 @@
                             return false;
                         }
 
+                        if(editParent.is('[data-segment-template-name="plan_behavior"]') ||
+                            editParent.is('[data-segment-template-name="intake_behavior"]')) {
+                            openDynamicStagPopup('/behavior-center/{{$note->client->uid}}/{{$note->uid}}',
+                                'behavior-center-{{$note->id}}',
+                                '<img src="/img/behavior-rx.png" class=""/> Behavior 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');

+ 25 - 21
resources/views/app/patient/prescriptions/list.blade.php

@@ -1,25 +1,29 @@
 <div id="prescriptions-{{$patient->id}}" v-cloak>
-    <div class="d-flex align-items-center mb-3">
+    <div class="d-flex align-items-baseline mb-3">
         <div class="font-weight-bold text-secondary font-size-14 m-0">ERx &amp; Orders</div>
-        @if(!request()->input('erx_category') || request()->input('erx_category') === 'DRUG')
-            <span class="mx-2 text-secondary on-hover-opaque">|</span>
-            <a href="#" v-on:click.prevent="newERx('DRUG')">+ Drug</a>
-        @endif
-        @if(!request()->input('erx_category') || request()->input('erx_category') === 'LAB')
-            <span class="mx-2 text-secondary on-hover-opaque">|</span>
-            <a href="#" v-on:click.prevent="newERx('LAB')">+ Lab</a>
-        @endif
-        @if(!request()->input('erx_category') || request()->input('erx_category') === 'IMAGING')
-            <span class="mx-2 text-secondary on-hover-opaque">|</span>
-            <a href="#" v-on:click.prevent="newERx('IMAGING')">+ Imaging</a>
-        @endif
-        @if(!request()->input('erx_category') || request()->input('erx_category') === 'REFERRAL')
-            <span class="mx-2 text-secondary on-hover-opaque">|</span>
-            <a href="#" v-on:click.prevent="newERx('REFERRAL')">+ Referral</a>
-        @endif
-        @if(!request()->input('erx_category') || request()->input('erx_category') === 'OTHER')
-            <span class="mx-2 text-secondary on-hover-opaque">|</span>
-            <a href="#" v-on:click.prevent="newERx('OTHER')">+ Other</a>
+        @if($patient->mcp)
+            @if(!request()->input('erx_category') || request()->input('erx_category') === 'DRUG')
+                <span class="mx-2 text-secondary on-hover-opaque">|</span>
+                <a href="#" v-on:click.prevent="newERx('DRUG')">+ Drug</a>
+            @endif
+            @if(!request()->input('erx_category') || request()->input('erx_category') === 'LAB')
+                <span class="mx-2 text-secondary on-hover-opaque">|</span>
+                <a href="#" v-on:click.prevent="newERx('LAB')">+ Lab</a>
+            @endif
+            @if(!request()->input('erx_category') || request()->input('erx_category') === 'IMAGING')
+                <span class="mx-2 text-secondary on-hover-opaque">|</span>
+                <a href="#" v-on:click.prevent="newERx('IMAGING')">+ Imaging</a>
+            @endif
+            @if(!request()->input('erx_category') || request()->input('erx_category') === 'REFERRAL')
+                <span class="mx-2 text-secondary on-hover-opaque">|</span>
+                <a href="#" v-on:click.prevent="newERx('REFERRAL')">+ Referral</a>
+            @endif
+            @if(!request()->input('erx_category') || request()->input('erx_category') === 'OTHER')
+                <span class="mx-2 text-secondary on-hover-opaque">|</span>
+                <a href="#" v-on:click.prevent="newERx('OTHER')">+ Other</a>
+            @endif
+        @else
+            <span class="ml-3 text-warning-mellow">MCP not set on the patient</span>
         @endif
     </div>
     <div class="d-flex align-items-start bg-white">
@@ -710,7 +714,7 @@ GROUP BY erx_category");
                             let payload = {
                                 noteUid: '{{ @$note ? $note->uid : '' }}',
                                 clientUid: '{{$patient->uid}}',
-                                hcpProUid: '{{$patient->mcp->uid}}',
+                                hcpProUid: '{{$patient->mcp ? $patient->mcp->uid : ''}}',
                                 erxCategory: _type
                             };
                             $.post('/api/erx/create', payload, _data => {

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

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

+ 10 - 0
resources/views/app/patient/segment-templates/_child_plan/behavior/CRAVINGS/view-plan.php

@@ -0,0 +1,10 @@
+<?php
+if (@$plan) {
+    ?>
+    <div class="text-secondary"><?= @($plan->memo) ?: '-' ?></div>
+    <?php
+} else {
+    ?> - <?php
+}
+?>
+

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

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

+ 10 - 0
resources/views/app/patient/segment-templates/_child_plan/behavior/FOOD_TRIGGERS/view-plan.php

@@ -0,0 +1,10 @@
+<?php
+if (@$plan) {
+    ?>
+    <div class="text-secondary"><?= @($plan->memo) ?: '-' ?></div>
+    <?php
+} else {
+    ?> - <?php
+}
+?>
+

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

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

+ 30 - 0
resources/views/app/patient/segment-templates/_child_plan/behavior/SELF_MONITORING/view-plan.php

@@ -0,0 +1,30 @@
+<?php
+$tracking = [];
+if (@($plan->tracking->calorieIntake)) $tracking[] = 'Calorie Intake';
+if (@($plan->tracking->dailyCarbIntake)) $tracking[] = 'Daily Carb Intake';
+if (@($plan->tracking->portionSize)) $tracking[] = 'Portion Size';
+if (@($plan->tracking->eatingSpeed)) $tracking[] = 'Eating Speed';
+$tracking = count($tracking) ? implode(', ', $tracking) : '-';
+$foodMonitoring = [];
+if (@($plan->foodMonitoring->phoneTracker)) $foodMonitoring[] = 'Phone Tracker';
+if (@($plan->foodMonitoring->dailyFoodLog)) $foodMonitoring[] = 'Daily Food Log';
+$foodMonitoring = count($foodMonitoring) ? implode(', ', $foodMonitoring) : '-';
+if (@$plan) {
+    ?>
+    <div class="mb-1"><span class="text-sm">Number of weigh-ins per week:</span> <?= @($plan->weighInsPerWeek) ?: '-' ?>.</div>
+    <div class="mb-1"><span class="text-sm">Track:</span> <?= $tracking ?></div>
+    <?php
+    if (@($plan->tracking->other) && @($plan->tracking->otherDetail)) {
+        ?>
+        <div class="mb-1"><span class="text-sm">Other tracking:</span> <?= $plan->tracking->otherDetail ?></div>
+        <?php
+    }
+    ?>
+    <div class="mb-1"><span class="text-sm">Food monitoring:</span> <?= $foodMonitoring ?></div>
+    <div class="text-secondary"><?= @($plan->memo) ?: '' ?></div>
+    <?php
+} else {
+    ?> - <?php
+}
+?>
+

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

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

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

@@ -0,0 +1,11 @@
+<?php
+if (@$plan) {
+    ?>
+    <div class="mb-1"><span class="text-sm">Hours of sleep:</span> <?= @($plan->hoursOfSleep) ?: '-' ?>.</div>
+    <div class="text-secondary"><?= @($plan->memo) ?: '' ?></div>
+    <?php
+} else {
+    ?> - <?php
+}
+?>
+

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

@@ -69,7 +69,7 @@ if (@$point) {
         <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>
+          class="mcp-theme-1 frm-review-plan-lifestyle frm-review-plan-exercise" right>
 
         <?php if($point): ?>
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
@@ -286,6 +286,7 @@ if (@$point) {
             <label for="" class="mb-1">Memo</label>
             <div note-rte slim-rte
                  class="form-group mb-2 border-left border-right rte-holder"
+                 data-container-name="<?= $point ? 'data' : 'childPlanData' ?>"
                  data-field-name="memo"><?= @($currentValue->memo) ?></div>
         </div>
         <div>

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

@@ -43,7 +43,7 @@ if (@$point) {
         <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>
+          class="mcp-theme-1 frm-review-plan-lifestyle frm-review-plan-exercise" right>
 
         <?php if($point): ?>
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
@@ -102,6 +102,7 @@ if (@$point) {
                 <label for="" class="mb-1">Other</label>
                 <div note-rte slim-rte
                      class="form-group mb-2 border-left border-right rte-holder"
+                     data-container-name="<?= $point ? 'data' : 'childPlanData' ?>"
                      data-field-name="memo"><?= @($currentValue->memo) ?></div>
             </div>
         </div>

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

@@ -44,7 +44,7 @@ if (@$point) {
         <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>
+          class="mcp-theme-1 frm-review-plan-lifestyle frm-review-plan-exercise" right>
 
         <?php if($point): ?>
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
@@ -107,6 +107,7 @@ if (@$point) {
                 <label for="" class="mb-1">Memo</label>
                 <div note-rte slim-rte
                      class="form-group mb-2 border-left border-right rte-holder"
+                     data-container-name="<?= $point ? 'data' : 'childPlanData' ?>"
                      data-field-name="memo"><?= @($currentValue->memo) ?></div>
             </div>
         </div>

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

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

@@ -0,0 +1,35 @@
+<div class="mb-1 font-weight-bold text-secondary">Current Cravings</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/behavior/' . $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; ?>

+ 24 - 0
resources/views/app/patient/segment-templates/_child_review/behavior/CRAVINGS/view-review.php

@@ -0,0 +1,24 @@
+<?php
+$cravings = [];
+if (@($review->sugar)) $cravings[] = 'Sugar';
+if (@($review->starches)) $cravings[] = 'Starches';
+if (@($review->friedFood)) $cravings[] = 'Fried Food';
+if (@($review->sweetDrinks)) $cravings[] = 'Sweet Drinks';
+$cravings = count($cravings) ? implode(', ', $cravings) : '-';
+if (@$review) {
+    ?>
+    <div class="mb-1"><span class="text-sm">Current cravings:</span> <?= $cravings ?></div>
+    <?php
+    if (@($review->other) && @($review->otherDetail)) {
+        ?>
+        <div class="mb-1"><span class="text-sm">Other cravings:</span> <?= $review->otherDetail ?></div>
+        <?php
+    }
+    ?>
+    <div class="text-secondary"><?= @($review->memo) ?: '' ?></div>
+    <?php
+} else {
+    ?> - <?php
+}
+?>
+

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

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

@@ -0,0 +1,35 @@
+<div class="mb-1 font-weight-bold text-secondary">Current Food Triggers</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/behavior/' . $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; ?>

+ 18 - 0
resources/views/app/patient/segment-templates/_child_review/behavior/FOOD_TRIGGERS/view-review.php

@@ -0,0 +1,18 @@
+<?php
+$triggers = [];
+if (@($review->stress)) $triggers[] = 'Stress';
+if (@($review->work)) $triggers[] = 'Work';
+if (@($review->social)) $triggers[] = 'Social';
+if (@($review->reward)) $triggers[] = 'Reward';
+if (@($review->relaxation)) $triggers[] = 'Relaxation';
+$triggers = count($triggers) ? implode(', ', $triggers) : '-';
+if (@$review) {
+    ?>
+    <div class="mb-1"><span class="text-sm">Current food triggers:</span> <?= $triggers ?></div>
+    <div class="text-secondary"><?= @($review->memo) ?: '' ?></div>
+    <?php
+} else {
+    ?> - <?php
+}
+?>
+

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

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

@@ -0,0 +1,35 @@
+<div class="mb-1 font-weight-bold text-secondary">Current Behavior</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/behavior/' . $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; ?>

+ 30 - 0
resources/views/app/patient/segment-templates/_child_review/behavior/SELF_MONITORING/view-review.php

@@ -0,0 +1,30 @@
+<?php
+$tracking = [];
+if (@($review->tracking->calorieIntake)) $tracking[] = 'Calorie Intake';
+if (@($review->tracking->dailyCarbIntake)) $tracking[] = 'Daily Carb Intake';
+if (@($review->tracking->portionSize)) $tracking[] = 'Portion Size';
+if (@($review->tracking->eatingSpeed)) $tracking[] = 'Eating Speed';
+$tracking = count($tracking) ? implode(', ', $tracking) : '-';
+$foodMonitoring = [];
+if (@($review->foodMonitoring->phoneTracker)) $foodMonitoring[] = 'Phone Tracker';
+if (@($review->foodMonitoring->dailyFoodLog)) $foodMonitoring[] = 'Daily Food Log';
+$foodMonitoring = count($foodMonitoring) ? implode(', ', $foodMonitoring) : '-';
+if (@$review) {
+    ?>
+    <div class="mb-1"><span class="text-sm">Current number of weigh-ins per week:</span> <?= @($review->weighInsPerWeek) ?: '-' ?>.</div>
+    <div class="mb-1"><span class="text-sm">Currently tracking:</span> <?= $tracking ?></div>
+    <?php
+    if (@($review->tracking->other) && @($review->tracking->otherDetail)) {
+        ?>
+        <div class="mb-1"><span class="text-sm">Other tracking:</span> <?= $review->tracking->otherDetail ?></div>
+        <?php
+    }
+    ?>
+    <div class="mb-1"><span class="text-sm">Current food monitoring:</span> <?= $foodMonitoring ?></div>
+    <div class="text-secondary"><?= @($review->memo) ?: '' ?></div>
+    <?php
+} else {
+    ?> - <?php
+}
+?>
+

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

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

@@ -0,0 +1,35 @@
+<div class="mb-1 font-weight-bold text-secondary">Current Sleep Habits</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/behavior/' . $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; ?>

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

@@ -0,0 +1,11 @@
+<?php
+if (@$review) {
+    ?>
+    <div class="mb-1"><span class="text-sm">Current hours of sleep:</span> <?= @($review->hoursOfSleep) ?: '-' ?>.</div>
+    <div class="text-secondary"><?= @($review->memo) ?: '' ?></div>
+    <?php
+} else {
+    ?> - <?php
+}
+?>
+

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

@@ -69,7 +69,7 @@ if (@$point) {
         <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>
+          class="mcp-theme-1 frm-review-plan-lifestyle frm-review-plan-exercise" right>
 
         <?php if($point): ?>
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
@@ -286,6 +286,7 @@ if (@$point) {
             <label for="" class="mb-1">Memo</label>
             <div note-rte slim-rte
                  class="form-group mb-2 border-left border-right rte-holder"
+                 data-container-name="<?= $point ? 'data' : 'childReviewData' ?>"
                  data-field-name="memo"><?= @($currentValue->memo) ?></div>
         </div>
         <div>

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

@@ -43,7 +43,7 @@ if (@$point) {
         <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>
+          class="mcp-theme-1 frm-review-plan-lifestyle frm-review-plan-exercise" right>
 
         <?php if($point): ?>
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
@@ -102,6 +102,7 @@ if (@$point) {
                 <label for="" class="mb-1">Other</label>
                 <div note-rte slim-rte
                      class="form-group mb-2 border-left border-right rte-holder"
+                     data-container-name="<?= $point ? 'data' : 'childReviewData' ?>"
                      data-field-name="memo"><?= @($currentValue->memo) ?></div>
             </div>
         </div>

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

@@ -44,7 +44,7 @@ if (@$point) {
         <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>
+          class="mcp-theme-1 frm-review-plan-lifestyle frm-review-plan-exercise" right>
 
         <?php if($point): ?>
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
@@ -107,6 +107,7 @@ if (@$point) {
                 <label for="" class="mb-1">Memo</label>
                 <div note-rte slim-rte
                      class="form-group mb-2 border-left border-right rte-holder"
+                     data-container-name="<?= $point ? 'data' : 'childReviewData' ?>"
                      data-field-name="memo"><?= @($currentValue->memo) ?></div>
             </div>
         </div>

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


+ 40 - 0
resources/views/app/patient/segment-templates/intake_behavior/summary.blade.php

@@ -0,0 +1,40 @@
+<?php
+
+use App\Models\Point;
+
+/** @var \App\Models\Client $patient */
+
+$selfMonitoring = Point::getOnlyPointOfCategory($patient, 'SELF_MONITORING');
+$foodTriggers = Point::getOnlyPointOfCategory($patient, 'FOOD_TRIGGERS');
+$cravings = Point::getOnlyPointOfCategory($patient, 'CRAVINGS');
+$sleepHabits = Point::getOnlyPointOfCategory($patient, 'SLEEP_HABITS');
+
+$points = [
+    ["category" => 'SELF_MONITORING', "name" => 'Self Monitoring', "point" => $selfMonitoring],
+    ["category" => 'FOOD_TRIGGERS', "name" => 'Food Triggers', "point" => $foodTriggers],
+    ["category" => 'CRAVINGS', "name" => 'Cravings', "point" => $cravings],
+    ["category" => 'SLEEP_HABITS', "name" => 'Sleep Habits', "point" => $sleepHabits],
+];
+?>
+
+<?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/behavior/' . $p['category'] . '/view-review.php')); ?>
+        </div>
+    </div>
+    <?php endif; ?>
+</div>
+<?php endif; ?>
+<?php endforeach; ?>

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


+ 40 - 0
resources/views/app/patient/segment-templates/plan_behavior/summary.blade.php

@@ -0,0 +1,40 @@
+<?php
+
+use App\Models\Point;
+
+/** @var \App\Models\Client $patient */
+
+$selfMonitoring = Point::getOnlyPointOfCategory($patient, 'SELF_MONITORING');
+$foodTriggers = Point::getOnlyPointOfCategory($patient, 'FOOD_TRIGGERS');
+$cravings = Point::getOnlyPointOfCategory($patient, 'CRAVINGS');
+$sleepHabits = Point::getOnlyPointOfCategory($patient, 'SLEEP_HABITS');
+
+$points = [
+    ["category" => 'SELF_MONITORING', "name" => 'Self Monitoring', "point" => $selfMonitoring],
+    ["category" => 'FOOD_TRIGGERS', "name" => 'Food Triggers', "point" => $foodTriggers],
+    ["category" => 'CRAVINGS', "name" => 'Cravings', "point" => $cravings],
+    ["category" => 'SLEEP_HABITS', "name" => 'Sleep Habits', "point" => $sleepHabits],
+];
+?>
+
+<?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">Subjective:</span>
+        <div class="inline-html-container">
+            <?php $plan = $plan->data; ?>
+            <?php include(resource_path('views/app/patient/segment-templates/_child_plan/behavior/' . $p['category'] . '/view-plan.php')); ?>
+        </div>
+    </div>
+    <?php endif; ?>
+</div>
+<?php endif; ?>
+<?php endforeach; ?>

+ 37 - 4
resources/views/app/patient/wizard-partials/common-script.blade.php

@@ -91,7 +91,7 @@ function __initRTEs(_collection) {
             if(!pElem.length) {
                 pElem = $(el).closest('form');
             }
-            let v = pElem.find('input[name=data]').val();
+            let v = pElem.find('input[name="' + ($(el).attr('data-container-name') ? $(el).attr('data-container-name') : 'data') + '"]').val();
             if(!!v) {
                 try {
                     v = JSON.parse(v);
@@ -105,7 +105,8 @@ function __initRTEs(_collection) {
             else {
                 v = JSON.stringify(dataObject);
             }
-            pElem.find('input[name=data]').val(v);
+
+            pElem.find('input[name=' + ($(el).attr('data-container-name') ? $(el).attr('data-container-name') : 'data') + ']').val(v);
         };
 
         if(!noteRTE.is('[ignore-changes]')) {
@@ -635,7 +636,39 @@ parentSegment.find('.frm-review-plan-exercise .btn-toggle-activity[data-type]')
         }
         return false;
     });
-parentSegment.find('.frm-review-plan-exercise')
+/* end of exercise specific */
+
+/* behavior specific */
+parentSegment.find('.frm-review-plan-behavior [data-name="tracking->other"]')
+    .off('change')
+    .on('change', function () {
+        let form = $(this).closest('form'), input = form.find('[if-tracking-other]');
+        if(this.checked) {
+            input.prop('readonly', false).focus();
+        }
+        else {
+            input.prop('readonly', true).val('');
+        }
+        return false;
+    })
+    .trigger('change');
+parentSegment.find('.frm-review-plan-behavior [data-name="other"]')
+    .off('change')
+    .on('change', function () {
+        let form = $(this).closest('form'), input = form.find('[if-other]');
+        if(this.checked) {
+            input.prop('readonly', false).focus();
+        }
+        else {
+            input.prop('readonly', true).val('');
+        }
+        return false;
+    })
+    .trigger('change');
+/* end of behavior specific */
+
+/* lifestyle specific */
+parentSegment.find('.frm-review-plan-lifestyle')
     .off('submit')
     .on('submit', function () {
         let form = $(this);
@@ -663,7 +696,7 @@ parentSegment.find('.frm-review-plan-exercise')
         });
         return false;
     });
-/* end of exercise specific */
+/* end of lifestyle specific */
 
 parentSegment.find('.toggle-relevance')
     .off('click.toggle-relevance')

+ 1 - 0
routes/web.php

@@ -475,6 +475,7 @@ Route::middleware('pro.auth')->group(function () {
 
     Route::get('/nutrition-center/{patient}/{note}', 'NoteController@nutritionCenter')->name('nutrition-center');
     Route::get('/exercise-center/{patient}/{note}', 'NoteController@exerciseCenter')->name('exercise-center');
+    Route::get('/behavior-center/{patient}/{note}', 'NoteController@behaviorCenter')->name('behavior-center');
 
     Route::get('/problems-quick-add/{patient}/{note}', 'NoteController@problemsQuickAdd')->name('problems-quick-add');