Bladeren bron

Behavior segments - food triggers

Vijayakrishnan 3 jaren geleden
bovenliggende
commit
f5d1df84b9

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

@@ -15,8 +15,8 @@ $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" => 'FOOD_TRIGGERS', "name" => 'Food Triggers', "point" => $foodTriggers],
+    /*["category" => 'CRAVINGS', "name" => 'Cravings', "point" => $cravings],
     ["category" => 'SLEEP_HABITS', "name" => 'Sleep Habits', "point" => $sleepHabits],*/
 ];
 ?>

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

@@ -0,0 +1,149 @@
+<?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>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-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; ?>

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

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

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

@@ -0,0 +1,149 @@
+<?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-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
+}
+?>
+

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

@@ -12,7 +12,7 @@ $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">Current tracking:</span> <?= $tracking ?></div>
+    <div class="mb-1"><span class="text-sm">Currently tracking:</span> <?= $tracking ?></div>
     <?php
     if (@($review->tracking->other) && @($review->tracking->otherDetail)) {
         ?>