Vijayakrishnan 3 роки тому
батько
коміт
b8a5a4a617

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

@@ -1,21 +1,30 @@
 <?php
+
+/*
+Format:
+{
+    active: true/false,
+    parkAway: true/false,
+    stairsInsteadOfElevators: true/false,
+    standInsteadOfSit: true/false,
+    stepsGoals: number,
+    memo: text
+}
+ */
+
 $currentValue = '';
 $previousValue = '';
 $previousChildPlan = null;
 if (@$point) {
     if ($point->lastChildPlan && $point->last_child_plan_point_scoped_note_id === $note->id) {
-        $parsedPlan = json_decode($point->lastChildPlan->data);
-        if(@$parsedPlan->value) {
-            $currentValue = $parsedPlan->value;
-            $previousChildPlan = \App\Models\Point::where('id', '<', $point->lastChildPlan->id)
-                ->where('category', 'PLAN')
-                ->where('parent_point_id', $point->id)
-                ->orderBy('id', 'DESC')
-                ->first();
-            if($previousChildPlan && $previousChildPlan->data) {
-                $parsedPlan = json_decode($previousChildPlan->data);
-                $previousValue = $parsedPlan->value;
-            }
+        $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 {
@@ -24,79 +33,83 @@ if (@$point) {
             ->orderBy('id', 'DESC')
             ->first();
         if($previousChildPlan && $previousChildPlan->data) {
-            $parsedPlan = json_decode($previousChildPlan->data);
-            if(@$parsedPlan->value) {
-                $previousValue = $parsedPlan->value;
-            }
+            $previousValue = json_decode($previousChildPlan->data);
         }
     }
 }
 ?>
-<div moe wide class="d-inline">
+<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>
-    <?php if($point): ?>
-        <form url="/api/visitPoint/upsertChildPlan" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
+    <form url="/api/visitPoint/<?= $point ? 'upsertChildPlan' : 'addTopLevel' ?>"
+          class="mcp-theme-1 frm-review-plan-exercise" right>
+
+        <?php if($point): ?>
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
             <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
-            <input type="hidden" name="data">
-
-            <?php if($segment->segmentTemplate->internal_name === 'intake_problems' && $previousValue): ?>
-                <div class="d-none disallow-if-value-same-as"><?= str_compact($previousValue) ?></div>
-            <?php endif; ?>
-
-            <?php if($previousValue): ?>
-                <div class="mb-2">
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?>) (click to copy)</span>
-                    </div>
-                    <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
-                </div>
-            <?php endif; ?>
-
-            <p class="mb-2"><b>Change goal:</b></p>
-
-            <div class="mb-2">
-                <div note-rte
-                    <?= $segment->segmentTemplate->internal_name === 'intake_problems' ? 'use-shortcuts="hpi,user"' : '' ?>
-                     class="form-group mb-2 border-left border-right rte-holder"
-                     data-field-name="value"><?= $currentValue ?></div>
-            </div>
-            <div>
-                <button type="submit"  class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
-        </form>
-    <?php else: ?>
-        <form url="/api/visitPoint/addTopLevel" class="mcp-theme-1 frm-add-review-plan-nutrition w-100" left>
+        <?php else: ?>
             <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
             <input type="hidden" name="category" value="<?= $p['category'] ?>">
             <input type="hidden" name="additionReasonCategory" value="ON_INTAKE">
+        <?php endif; ?>
+
+        <?php if ($point): ?>
             <input type="hidden" name="data">
+        <?php else: ?>
+            <input type="hidden" name="childPlanData">
+        <?php endif; ?>
 
-            <?php if($previousValue): ?>
-                <div class="mb-2">
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?>) (click to copy)</span>
-                    </div>
-                    <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
+        <?php if($previousValue): ?>
+            <div class="mb-2">
+                <div class="d-flex align-items-baseline mb-1">
+                    <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?>)</span>
+                </div>
+                <div class="p-2 bg-light border inline-html-container">
+                    <?php $plan = $previousValue; ?>
+                    <?php include(resource_path('views/app/patient/segment-templates/_child_plan/exercise/' . $p['category'] . '/view-plan.php')); ?>
                 </div>
-            <?php endif; ?>
+            </div>
+        <?php endif; ?>
+
+        <p class="mb-2"><b>Change Goal:</b></p>
 
-            <p class="mb-2"><b>Change goal:</b></p>
+        <label class="mb-2 d-flex align-items-center">
+            <input type="checkbox" data-name="active" <?= @($currentValue->active) ? 'checked' : ''?>>
+            <span class="ml-2">Prescribe Non-Exercise Activity Time (NEAT) Instructions?</span>
+        </label>
 
+        <div if-active>
+            <label class="mb-2 d-flex align-items-baseline">
+                <input type="checkbox" data-name="parkAway" <?= @($currentValue->parkAway) ? 'checked' : ''?>>
+                <span class="ml-2">Park away from entrances</span>
+            </label>
+            <label class="mb-2 d-flex align-items-baseline">
+                <input type="checkbox" data-name="stairsInsteadOfElevators" <?= @($currentValue->stairsInsteadOfElevators) ? 'checked' : ''?>>
+                <span class="ml-2">Take the stairs instead of elevator/escalator</span>
+            </label>
+            <label class="mb-2 d-flex align-items-baseline">
+                <input type="checkbox" data-name="standInsteadOfSit" <?= @($currentValue->standInsteadOfSit) ? 'checked' : ''?>>
+                <span class="ml-2">Prefer standing over sitting</span>
+            </label>
+            <div class="row mb-2">
+                <div class="col-6">
+                    <label class="mb-1">Steps/day goal</label>
+                    <input type="text" data-name="stepsGoals" class="form-control form-control-sm" value="<?= @($currentValue->stepsGoals) ?>">
+                </div>
+            </div>
             <div class="mb-2">
-                <div note-rte
+                <label for="" class="mb-1">Other</label>
+                <div note-rte slim-rte
                      class="form-group mb-2 border-left border-right rte-holder"
-                     data-field-name="planValue"><?= $currentValue ?></div>
+                     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>
-    <?php endif; ?>
+        </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">

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

@@ -2,8 +2,10 @@
 <?php if ($point->lastChildPlan): ?>
     <?php $parsedPlan = json_decode($point->lastChildPlan->data); ?>
     <div class="<?= $point->last_child_plan_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
-        <div class="inline-html-container"><?= $parsedPlan->value ?></div>
-        <div class="text-secondary text-sm"></div>
+        <div class="inline-html-container">
+            <?php $plan = $parsedPlan; ?>
+            <?php include(resource_path('views/app/patient/segment-templates/_child_plan/exercise/' . $p['category'] . '/view-plan.php')); ?>
+        </div>
 
         <?php if ($point->last_child_plan_point_scoped_note_id === $patient->core_note_id): ?>
             <span class="text-sm">(updated on the patient's chart)</span>

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

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

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

@@ -52,7 +52,7 @@ if (@$point) {
         <?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">
+            <input type="hidden" name="additionReasonCategory" value="DURING_VISIT">
         <?php endif; ?>
 
         <?php if ($point): ?>

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

@@ -1,21 +1,30 @@
 <?php
+
+/*
+Format:
+{
+    active: true/false,
+    parkAway: true/false,
+    stairsInsteadOfElevators: true/false,
+    standInsteadOfSit: true/false,
+    stepsGoals: number,
+    memo: text
+}
+ */
+
 $currentValue = '';
 $previousValue = '';
 $previousChildReview = null;
 if (@$point) {
     if ($point->lastChildReview && $point->last_child_review_point_scoped_note_id === $note->id) {
-        $parsedReview = json_decode($point->lastChildReview->data);
-        if(@$parsedReview->value) {
-            $currentValue = $parsedReview->value;
-            $previousChildReview = \App\Models\Point::where('id', '<', $point->lastChildReview->id)
-                ->where('category', 'REVIEW')
-                ->where('parent_point_id', $point->id)
-                ->orderBy('id', 'DESC')
-                ->first();
-            if($previousChildReview && $previousChildReview->data) {
-                $parsedReview = json_decode($previousChildReview->data);
-                $previousValue = $parsedReview->value;
-            }
+        $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 {
@@ -24,79 +33,83 @@ if (@$point) {
             ->orderBy('id', 'DESC')
             ->first();
         if($previousChildReview && $previousChildReview->data) {
-            $parsedReview = json_decode($previousChildReview->data);
-            if(@$parsedReview->value) {
-                $previousValue = $parsedReview->value;
-            }
+            $previousValue = json_decode($previousChildReview->data);
         }
     }
 }
 ?>
-<div moe wide class="d-inline">
+<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>
-    <?php if($point): ?>
-        <form url="/api/visitPoint/upsertChildReview" class="mcp-theme-1 w-100 frm-upsert-review-plan-nutrition" left>
+    <form url="/api/visitPoint/<?= $point ? 'upsertChildReview' : 'addTopLevel' ?>"
+          class="mcp-theme-1 frm-review-plan-exercise" right>
+
+        <?php if($point): ?>
             <input type="hidden" name="uid" value="<?= $point->uid ?>">
             <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
-            <input type="hidden" name="data">
-
-            <?php if($segment->segmentTemplate->internal_name === 'intake_problems' && $previousValue): ?>
-                <div class="d-none disallow-if-value-same-as"><?= str_compact($previousValue) ?></div>
-            <?php endif; ?>
-
-            <?php if($previousValue): ?>
-                <div class="mb-2">
-                    <div class="d-flex align-items-baseline mb-1">
-                        <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?>) (click to copy)</span>
-                    </div>
-                    <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
-                </div>
-            <?php endif; ?>
-
-            <p class="mb-2"><b>Current Daily Calories</b></p>
-
-            <div class="mb-2">
-                <div note-rte
-                     <?= $segment->segmentTemplate->internal_name === 'intake_problems' ? 'use-shortcuts="hpi,user"' : '' ?>
-                     class="form-group mb-2 border-left border-right rte-holder"
-                     data-field-name="value"><?= $currentValue ?></div>
-            </div>
-            <div>
-                <button type="submit"  class="btn btn-sm btn-primary mr-2">Save</button>
-                <button cancel class="btn btn-sm btn-default border">Cancel</button>
-            </div>
-        </form>
-    <?php else: ?>
-        <form url="/api/visitPoint/addTopLevel" class="mcp-theme-1 frm-add-review-plan-nutrition w-100" left>
+        <?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) ?>) (click to copy)</span>
-                    </div>
-                    <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
+        <?php if($previousValue): ?>
+            <div class="mb-2">
+                <div class="d-flex align-items-baseline mb-1">
+                    <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?>)</span>
+                </div>
+                <div class="p-2 bg-light border inline-html-container">
+                    <?php $review = $previousValue; ?>
+                    <?php include(resource_path('views/app/patient/segment-templates/_child_review/exercise/' . $p['category'] . '/view-review.php')); ?>
                 </div>
-            <?php endif; ?>
+            </div>
+        <?php endif; ?>
+
+        <p class="mb-2"><b>Current Non-Exercise Activity Time (NEAT)</b></p>
 
-            <p class="mb-2"><b>Current Daily Calories</b></p>
+        <label class="mb-2 d-flex align-items-center">
+            <input type="checkbox" data-name="active" <?= @($currentValue->active) ? 'checked' : ''?>>
+            <span class="ml-2">Record Non-Exercise Activity Time (NEAT)</span>
+        </label>
 
+        <div if-active>
+            <label class="mb-2 d-flex align-items-baseline">
+                <input type="checkbox" data-name="parkAway" <?= @($currentValue->parkAway) ? 'checked' : ''?>>
+                <span class="ml-2">Currently parks away from entrances</span>
+            </label>
+            <label class="mb-2 d-flex align-items-baseline">
+                <input type="checkbox" data-name="stairsInsteadOfElevators" <?= @($currentValue->stairsInsteadOfElevators) ? 'checked' : ''?>>
+                <span class="ml-2">Currently takes the stairs instead of elevator/escalator</span>
+            </label>
+            <label class="mb-2 d-flex align-items-baseline">
+                <input type="checkbox" data-name="standInsteadOfSit" <?= @($currentValue->standInsteadOfSit) ? 'checked' : ''?>>
+                <span class="ml-2">Currently prefers standing over sitting</span>
+            </label>
+            <div class="row mb-2">
+                <div class="col-6">
+                    <label class="mb-1">Current steps/day</label>
+                    <input type="text" data-name="stepsGoals" class="form-control form-control-sm" value="<?= @($currentValue->stepsGoals) ?>">
+                </div>
+            </div>
             <div class="mb-2">
-                <div note-rte
+                <label for="" class="mb-1">Other</label>
+                <div note-rte slim-rte
                      class="form-group mb-2 border-left border-right rte-holder"
-                     data-field-name="reviewValue"><?= $currentValue ?></div>
+                     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>
-    <?php endif; ?>
+        </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">

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

@@ -1,8 +1,11 @@
-<div class="mb-1 font-weight-bold text-secondary">Current Daily Calories</div>
+<div class="mb-1 font-weight-bold text-secondary">Current Non-Exercise Activity Time (NEAT)</div>
 <?php if ($point->lastChildReview): ?>
     <?php $parsedReview = json_decode($point->lastChildReview->data); ?>
     <div class="<?= $point->last_child_review_point_scoped_note_id === $note->id ? 'bg-warning-mellow p-2 rounded' : '' ?>">
-        <div class="inline-html-container"><?= @$parsedReview->value ?></div>
+        <div class="inline-html-container">
+            <?php $review = $parsedReview; ?>
+            <?php include(resource_path('views/app/patient/segment-templates/_child_review/exercise/' . $p['category'] . '/view-review.php')); ?>
+        </div>
 
         <?php if ($point->last_child_review_point_scoped_note_id === $patient->core_note_id): ?>
             <span class="text-sm">(updated on the patient's chart)</span>

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

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