소스 검색

Behavior segments - cravings

Vijayakrishnan 3 년 전
부모
커밋
973b51fb36

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

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

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

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

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

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

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

@@ -120,7 +120,7 @@ if (@$point) {
                     <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">
+                        <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>

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

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

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

@@ -120,7 +120,7 @@ if (@$point) {
                     <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">
+                        <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>

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

@@ -651,6 +651,19 @@ parentSegment.find('.frm-review-plan-behavior [data-name="tracking->other"]')
         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 */