Jelajahi Sumber

MC weight loss - impl save/load

Vijayakrishnan 3 tahun lalu
induk
melakukan
296e4e145d

+ 3 - 0
public/js/mc.js

@@ -455,6 +455,9 @@ function initPatientPresenceIndicator() {
 // find a better place to put this
 window.fillJsonDataField = function(form, field = "data") {
     // add [data-name] values to payload
+    if(form.is('[data-field-name]')) {
+        field = form.attr('data-field-name');
+    }
     let dataField = form.find('[name="' + field + '"]').first();
     let parsed = null;
     if(dataField.val()) {

+ 129 - 70
resources/views/app/patient/segment-templates/mc_weight_loss_intake_subjective/edit.blade.php

@@ -11,8 +11,30 @@ if (!empty($patient->sex)) {
 }
 $theirName[] = $patient->name_last . ', ' . $patient->name_first;
 $theirName = implode(" ", $theirName);
+
+$point = \App\Models\Point::getOnlyPointOfCategory($patient, 'WEIGHT_LOSS_INTAKE');
+
+$currentValue = null;
+if ($point && $point->lastChildReview && $point->last_child_review_point_scoped_note_id === $note->id) {
+    $currentValue = json_decode($point->lastChildReview->data);
+}
+
 ?>
 
+<div visit-moe close-on-save close-on-cancel class="d-block">
+    <form show url="/api/visitPoint/{{ $point ? 'upsertChildReview' : 'addTopLevel' }}" data-field-name="{{$point ? 'data' : 'childReviewData'}}">
+
+        @if($point)
+            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+            <input type="hidden" name="data">
+        @else
+            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
+            <input type="hidden" name="category" value="WEIGHT_LOSS_INTAKE">
+            <input type="hidden" name="additionReasonCategory" value="ON_INTAKE">
+            <input type="hidden" name="childReviewData">
+        @endif
+
 <section class="intake primary-form">
     <div class="p-2">
         <p>Hello, {{$theirName}}. My name is {{$myName}}.</p>
@@ -22,9 +44,9 @@ $theirName = implode(" ", $theirName);
             <div>
                 <p>1. First {{$theirName}}, let me ask you, if there were three things that you could magically just change about your health, what would they be?</p>
                 <ul>
-                    <li><input autofocus></li>
-                    <li><input></li>
-                    <li><input></li>
+                    <li><input autofocus type="text" data-name="condition_1" value="{{@($currentValue->condition_1)}}"></li>
+                    <li><input type="text" data-name="condition_2" value="{{@($currentValue->condition_2)}}"></li>
+                    <li><input type="text" data-name="condition_3" value="{{@($currentValue->condition_3)}}"></li>
                 </ul>
             </div>
             <div>
@@ -32,11 +54,11 @@ $theirName = implode(" ", $theirName);
                 <ul>
                     <li>
                         <label>Height</label>
-                        <input type="text" class="number"> <span>inches</span>
+                        <input type="text" class="number" data-name="currentHeight" value="{{@($currentValue->currentHeight)}}"> <span>inches</span>
                     </li>
                     <li>
                         <label>Weight</label>
-                        <input type="text" class="number"> <span>lbs.</span>
+                        <input type="text" class="number" data-name="currentWeight" value="{{@($currentValue->currentWeight)}}"> <span>lbs.</span>
                     </li>
                 </ul>
             </div>
@@ -45,7 +67,7 @@ $theirName = implode(" ", $theirName);
                 <ul>
                     <li>
                         <label>Weight at 20</label>
-                        <input type="text" class="number"> <span>lbs.</span>
+                        <input type="text" class="number" data-name="weightAt20" value="{{@($currentValue->weightAt20)}}"> <span>lbs.</span>
                     </li>
                 </ul>
             </div>
@@ -54,7 +76,7 @@ $theirName = implode(" ", $theirName);
                 <ul>
                     <li>
                         <label>Waistline</label>
-                        <input type="text" class="number"> <span>inches</span>
+                        <input type="text" class="number" data-name="currentWaistline" value="{{@($currentValue->currentWaistline)}}"> <span>inches</span>
                     </li>
                 </ul>
             </div>
@@ -63,44 +85,44 @@ $theirName = implode(" ", $theirName);
                 <ul>
                     <li>
                         <label>Waistline at 20</label>
-                        <input type="text" class="number"> <span>inches</span>
+                        <input type="text" class="number" data-name="waistlineAt20" value="{{@($currentValue->waistlineAt20)}}"> <span>inches</span>
                     </li>
                 </ul>
             </div>
             <div>
                 <p>6. How has the current COVID-19 coronavirus pandemic or quarantine affected your weight, stress level, your lifestyle, or simply just your health in general?</p>
                 <ul>
-                    <li><input></li>
+                    <li><input type="text" data-name="howCovidHasAffected" value="{{@($currentValue->howCovidHasAffected)}}"></li>
                 </ul>
             </div>
             <div>
                 <p>7. Would you say that your weight is currently stable, or are you losing weight, or gaining weight?</p>
                 <ul>
-                    <li><input></li>
+                    <li><input type="text" data-name="weightStableLosingOrGaining" value="{{@($currentValue->weightStableLosingOrGaining)}}"></li>
                 </ul>
             </div>
             <div>
                 <p>8. What other medical conditions or feelings are you experiencing that you feel might improve with weight loss? For example, joint pain, energy level, etc.</p>
                 <ul>
-                    <li><input></li>
-                    <li><input></li>
-                    <li><input></li>
+                    <li><input type="text" data-name="improveConditionByWeightLoss_1" value="{{@($currentValue->improveConditionByWeightLoss_1)}}"></li>
+                    <li><input type="text" data-name="improveConditionByWeightLoss_2" value="{{@($currentValue->improveConditionByWeightLoss_2)}}"></li>
+                    <li><input type="text" data-name="improveConditionByWeightLoss_3" value="{{@($currentValue->improveConditionByWeightLoss_3)}}"></li>
                     <li><button class="add btn btn-sm btn-primary">Add</button></li>
                 </ul>
             </div>
             <div>
                 <p>9. Encouragement / Education:</p>
                 <ul>
-                    <li><input type=checkbox> <span>Great! I think you will really love this personalized care plan we will send you.</span></li>
-                    <li><input type=checkbox> <span>Our care plans are structured on the basis of "calorie planning".</span></li>
-                    <li><input type=checkbox> <span>Did you know that there are 3500 calories in a pound of body fat?</span></li>
-                    <li><input type=checkbox> <span>So, for example, a 12 ounce can of coke has about 150 calories.</span></li>
-                    <li><input type=checkbox> <span>It takes you about 35 minutes walking at 3.5 miles per hour to burn those 150 calories. So, it's actually very hard to change weight with exercise! It's much easier to avoid drinking that one can of coke vs. trying to burn it by working out.</span></li>
-                    <li><input type=checkbox> <span>So, imagine there is a patient with a habit of drinking one can of coke per day.</span></li>
-                    <li><input type=checkbox> <span>Every 30 days, this patient is consuming about 4500 calories from that one daily can of coke.</span></li>
-                    <li><input type=checkbox> <span>So, that one coke per day habit is worth about 1.3 pounds of body fat per month!</span></li>
-                    <li><input type=checkbox> <span>So, with no other changes in exercise or diet, if the ONLY thing this patient did was give up the daily coke habit, he would lose 1.3 pounds per month - or approximately 4 pounds of body fat every 3 months. Just from giving up one can of coke!</span></li>
-                    <li><input type=checkbox> <span>Exercise is definitely important in keeping your body healthy - but for weight loss - as you can see - is much more important to control calories that come in. And it's not hard to make small changes that really add up!</span></li>
+                    <li><input type="checkbox" data-name="encouragement_1" {{@($currentValue->encouragement_1) ? 'checked' : ''}}> <span>Great! I think you will really love this personalized care plan we will send you.</span></li>
+                    <li><input type="checkbox" data-name="encouragement_2" {{@($currentValue->encouragement_2) ? 'checked' : ''}}> <span>Our care plans are structured on the basis of "calorie planning".</span></li>
+                    <li><input type="checkbox" data-name="encouragement_3" {{@($currentValue->encouragement_3) ? 'checked' : ''}}> <span>Did you know that there are 3500 calories in a pound of body fat?</span></li>
+                    <li><input type="checkbox" data-name="encouragement_4" {{@($currentValue->encouragement_4) ? 'checked' : ''}}> <span>So, for example, a 12 ounce can of coke has about 150 calories.</span></li>
+                    <li><input type="checkbox" data-name="encouragement_5" {{@($currentValue->encouragement_5) ? 'checked' : ''}}> <span>It takes you about 35 minutes walking at 3.5 miles per hour to burn those 150 calories. So, it's actually very hard to change weight with exercise! It's much easier to avoid drinking that one can of coke vs. trying to burn it by working out.</span></li>
+                    <li><input type="checkbox" data-name="encouragement_6" {{@($currentValue->encouragement_6) ? 'checked' : ''}}> <span>So, imagine there is a patient with a habit of drinking one can of coke per day.</span></li>
+                    <li><input type="checkbox" data-name="encouragement_7" {{@($currentValue->encouragement_7) ? 'checked' : ''}}> <span>Every 30 days, this patient is consuming about 4500 calories from that one daily can of coke.</span></li>
+                    <li><input type="checkbox" data-name="encouragement_8" {{@($currentValue->encouragement_8) ? 'checked' : ''}}> <span>So, that one coke per day habit is worth about 1.3 pounds of body fat per month!</span></li>
+                    <li><input type="checkbox" data-name="encouragement_9" {{@($currentValue->encouragement_9) ? 'checked' : ''}}> <span>So, with no other changes in exercise or diet, if the ONLY thing this patient did was give up the daily coke habit, he would lose 1.3 pounds per month - or approximately 4 pounds of body fat every 3 months. Just from giving up one can of coke!</span></li>
+                    <li><input type="checkbox" data-name="encouragement_10" {{@($currentValue->encouragement_10) ? 'checked' : ''}}> <span>Exercise is definitely important in keeping your body healthy - but for weight loss - as you can see - is much more important to control calories that come in. And it's not hard to make small changes that really add up!</span></li>
                 </ul>
             </div>
             <div>
@@ -108,26 +130,26 @@ $theirName = implode(" ", $theirName);
                 <ul class=gappers>
                     <li>
                         <span>3 months?</span>
-                        <label>Weight</label> <input type="text" class="number"> <span>lbs.</span>
-                        <label>Waistline</label> <input type="text" class="number"> <span>inches</span>
+                        <label>Weight</label> <input type="text" class="number" data-name="weightGoal3Months" value="{{@($currentValue->weightGoal3Months)}}"> <span>lbs.</span>
+                        <label>Waistline</label> <input type="text" class="number" data-name="waistlineGoal3Months" value="{{@($currentValue->waistlineGoal3Months)}}"> <span>inches</span>
                     </li>
                     <li>
                         <span>6 months?</span>
-                        <label>Weight</label> <input type="text" class="number"> <span>lbs.</span>
-                        <label>Waistline</label> <input type="text" class="number"> <span>inches</span>
+                        <label>Weight</label> <input type="text" class="number" data-name="weightGoal6Months" value="{{@($currentValue->weightGoal6Months)}}"> <span>lbs.</span>
+                        <label>Waistline</label> <input type="text" class="number" data-name="waistlineGoal6Months" value="{{@($currentValue->waistlineGoal6Months)}}"> <span>inches</span>
                     </li>
                     <li>
                         <span>1 year?</span>
-                        <label>Weight</label> <input type="text" class="number"> <span>lbs.</span>
-                        <label>Waistline</label> <input type="text" class="number"> <span>inches</span>
+                        <label>Weight</label> <input type="text" class="number" data-name="weightGoal12Months" value="{{@($currentValue->weightGoal12Months)}}"> <span>lbs.</span>
+                        <label>Waistline</label> <input type="text" class="number" data-name="waistlineGoal12Months" value="{{@($currentValue->waistlineGoal12Months)}}"> <span>inches</span>
                     </li>
                 </ul>
             </div>
             <div>
                 <p>11. HEALTHY LIFESTYLE STEPS: So for this sample patient you just saw, giving up coke was a very meaningful lifestyle step that has a big calorie effect over time. What are some things in your life that are simple changes that can really add up? Let’s be SPECIFIC. For example, giving up croutons in your salad, or taking a walk, etc.</p>
                 <ul>
-                    <li><input></li>
-                    <li><input></li>
+                    <li><input type="text" data-name="simpleChange_1" value="{{@($currentValue->simpleChange_1)}}"></li>
+                    <li><input type="text" data-name="simpleChange_2" value="{{@($currentValue->simpleChange_2)}}"></li>
                     <li><button class="add btn btn-sm btn-primary">Add</button></li>
                 </ul>
             </div>
@@ -135,12 +157,12 @@ $theirName = implode(" ", $theirName);
                 <p>12. What is the highest your weight or waistline has ever been?</p>
                 <ul class=gappers>
                     <li>
-                        <label>Weight</label> <input type="text" class="number"> <span>lbs.</span>
-                        <label>When was that?</label> <input>
+                        <label>Weight</label> <input type="text" class="number" data-name="highestWeight" value="{{@($currentValue->highestWeight)}}"> <span>lbs.</span>
+                        <label>When was that?</label> <input type="text" data-name="highestWeightWhen" value="{{@($currentValue->highestWeightWhen)}}">
                     </li>
                     <li>
-                        <label>Waistline</label> <input type="text" class="number"> <span>inches</span>
-                        <label>When was that?</label> <input>
+                        <label>Waistline</label> <input type="text" class="number" data-name="highestWaistline" value="{{@($currentValue->highestWaistline)}}"> <span>inches</span>
+                        <label>When was that?</label> <input type="text" data-name="highestWaistlineWhen" value="{{@($currentValue->highestWaistlineWhen)}}">
                     </li>
                 </ul>
             </div>
@@ -148,16 +170,16 @@ $theirName = implode(" ", $theirName);
                 <p>13. What is your most recent?</p>
                 <ul class=gappers>
                     <li>
-                        <label>A1c</label> <input type="text" class="number">
-                        <label>When was that?</label> <input>
+                        <label>A1c</label> <input type="text" class="number" data-name="mostRecentA1C" value="{{@($currentValue->mostRecentA1C)}}">
+                        <label>When was that?</label> <input type="text" data-name="mostRecentA1CWhen" value="{{@($currentValue->mostRecentA1CWhen)}}">
                     </li>
                     <li>
-                        <label>BP (S/D)</label> <input type="text" class="number">/<input type="text" class="number"> <span>mmHg</span>
-                        <label>When was that?</label> <input>
+                        <label>BP (S/D)</label> <input type="text" class="number" data-name="mostRecentSBP" value="{{@($currentValue->mostRecentSBP)}}">/<input type="text" class="number" data-name="mostRecentDBP" value="{{@($currentValue->mostRecentDBP)}}"> <span>mmHg</span>
+                        <label>When was that?</label> <input type="text" data-name="mostRecentBPWhen" value="{{@($currentValue->mostRecentBPWhen)}}">
                     </li>
                     <li>
-                        <label>LDL</label> <input type="text" class="number"> <span>mg/dL</span>
-                        <label>When was that?</label> <input>
+                        <label>LDL</label> <input type="text" class="number" data-name="mostRecentLDL" value="{{@($currentValue->mostRecentLDL)}}"> <span>mg/dL</span>
+                        <label>When was that?</label> <input type="text" data-name="mostRecentLDLWhen" value="{{@($currentValue->mostRecentLDLWhen)}}">
                     </li>
                 </ul>
             </div>
@@ -165,58 +187,97 @@ $theirName = implode(" ", $theirName);
                 <p>14. Do you recall your highest ever recorded?</p>
                 <ul class=gappers>
                     <li>
-                        <label>A1c</label> <input type="text" class="number">
-                        <label>When was that?</label> <input>
+                        <label>A1c</label> <input type="text" class="number" data-name="highestA1C" value="{{@($currentValue->highestA1C)}}">
+                        <label>When was that?</label> <input type="text" data-name="highestA1CWhen" value="{{@($currentValue->highestA1CWhen)}}">
                     </li>
                     <li>
-                        <label>BP (S/D)</label> <input type="text" class="number">/<input type="text" class="number"> <span>mmHg</span>
-                        <label>When was that?</label> <input>
+                        <label>BP (S/D)</label> <input type="text" class="number" data-name="highestSBP" value="{{@($currentValue->highestSBP)}}">/<input type="text" class="number" data-name="highestDBP" value="{{@($currentValue->highestDBP)}}"> <span>mmHg</span>
+                        <label>When was that?</label> <input type="text" data-name="highestBPWhen" value="{{@($currentValue->highestBPWhen)}}">
                     </li>
                     <li>
-                        <label>LDL</label> <input type="text" class="number"> <span>mg/dL</span>
-                        <label>When was that?</label> <input>
+                        <label>LDL</label> <input type="text" class="number" data-name="highestLDL" value="{{@($currentValue->highestLDL)}}"> <span>mg/dL</span>
+                        <label>When was that?</label> <input type="text" data-name="highestLDLWhen" value="{{@($currentValue->highestLDLWhen)}}">
                     </li>
                 </ul>
             </div>
             <div>
                 <p>15. Are you on any special type of diet?</p>
                 <ul>
-                    <li><input></li>
+                    <li><input type="text" data-name="specialDiet" value="{{@($currentValue->specialDiet)}}"></li>
                 </ul>
             </div>
             <div>
                 <p>16. What is a typical day like for you?</p>
                 <ul>
-                    <li><label>What time do you usually wake up</label> <input></li>
-                    <li><label>How consistent is the time you wake up</label> <input></li>
-                    <li><label>What do you usually have for breakfast</label> <input></li>
-                    <li><label>Then what do you do between breakfast and lunch</label> <input></li>
-                    <li><label>What do you have for lunch</label> <input></li>
-                    <li><label>Then what do you do between lunch and dinner</label> <input></li>
-                    <li><label>What do you have for dinner</label> <input></li>
-                    <li><label>Then what do you do between dinner and going to bed</label> <input></li>
-                    <li><label>When do you go to bed</label> <input></li>
-                    <li><label>How consistent is the time you go to bed</label> <input></li>
-                    <li><label>How well would you say you sleep</label> <input></li>
-                    <li><label>How much do you smoke</label> <input></li>
-                    <li><label>How much do you drink</label> <input></li>
+                    <li><label>What time do you usually wake up</label> <input type="text" data-name="typicalDayWakeUp" value="{{@($currentValue->typicalDayWakeUp)}}"></li>
+                    <li><label>How consistent is the time you wake up</label> <input type="text" data-name="typicalDayWakeUpConsistency" value="{{@($currentValue->typicalDayWakeUpConsistency)}}"></li>
+                    <li><label>What do you usually have for breakfast</label> <input type="text" data-name="typicalDayBreakfast" value="{{@($currentValue->typicalDayBreakfast)}}"></li>
+                    <li><label>Then what do you do between breakfast and lunch</label> <input type="text" data-name="typicalDayBetweenBreakfastAndLunch" value="{{@($currentValue->typicalDayBetweenBreakfastAndLunch)}}"></li>
+                    <li><label>What do you have for lunch</label> <input type="text" data-name="typicalDayLunch" value="{{@($currentValue->typicalDayLunch)}}"></li>
+                    <li><label>Then what do you do between lunch and dinner</label> <input type="text" data-name="typicalDayBetweenLunchAndDinner" value="{{@($currentValue->typicalDayBetweenLunchAndDinner)}}"></li>
+                    <li><label>What do you have for dinner</label> <input type="text" data-name="typicalDayDinner" value="{{@($currentValue->typicalDayDinner)}}"></li>
+                    <li><label>Then what do you do between dinner and going to bed</label> <input type="text" data-name="typicalDayBetweenDinnerAndBed" value="{{@($currentValue->typicalDayBetweenDinnerAndBed)}}"></li>
+                    <li><label>When do you go to bed</label> <input type="text" data-name="typicalDayBedTime" value="{{@($currentValue->typicalDayBedTime)}}"></li>
+                    <li><label>How consistent is the time you go to bed</label> <input type="text" data-name="typicalDayBedTimeConsistency" value="{{@($currentValue->typicalDayBedTimeConsistency)}}"></li>
+                    <li><label>How well would you say you sleep</label> <input type="text" data-name="typicalDaySleepQuality" value="{{@($currentValue->typicalDaySleepQuality)}}"></li>
+                    <li><label>How much do you smoke</label> <input type="text" data-name="typicalDaySmoke" value="{{@($currentValue->typicalDaySmoke)}}"></li>
+                    <li><label>How much do you drink</label> <input type="text" data-name="typicalDayDrink" value="{{@($currentValue->typicalDayDrink)}}"></li>
                 </ul>
             </div>
             <div>
                 <p>17. ACTIVITY ASSESSMENT:</p>
                 <ul>
-                    <li><label>How many minutes of walking or movement do you typically get in a day</label> <input type="text" class="number"></li>
-                    <li><label>How many days per week do you exercise to the point where your heart rate goes up</label> <input></li>
-                    <li><label>How many days per week do you exercise to the point where your muscles feel like they've had a work out</label> <input></li>
+                    <li><label>How many minutes of walking or movement do you typically get in a day</label><input type="text" class="number" data-name="walkMovementPerDay" value="{{@($currentValue->walkMovementPerDay)}}"></li>
+                    <li><label>How many days per week do you exercise to the point where your heart rate goes up</label> <input type="text" data-name="exerciseDaysHeartRateUpPerWeek" value="{{@($currentValue->exerciseDaysHeartRateUpPerWeek)}}"></li>
+                    <li><label>How many days per week do you exercise to the point where your muscles feel like they've had a work out</label> <input type="text" data-name="exerciseDaysMuscleWorkoutPerWeek" value="{{@($currentValue->exerciseDaysMuscleWorkoutPerWeek)}}"></li>
                 </ul>
             </div>
         </div>
 
-        <button class="btn btn-sm btn-primary">Save</button>
-        <button id="sign-and-submit" class="btn btn-sm btn-success">Sign & Submit</button>
+        <!--<button class="btn btn-sm btn-primary">Save</button>
+        <button id="sign-and-submit" class="btn btn-sm btn-success">Sign & Submit</button>-->
     </div>
 </section>
 
+        <div class="p-3">
+            <button submit class="btn btn-sm btn-primary mr-2"><i class="fa fa-save"></i></button>
+            <div class="d-inline-flex align-self-stretch align-items-center">
+                <span class="autosave-indicator saving text-sm text-secondary">Saving changes &hellip;</span>
+                <span class="autosave-indicator saved text-sm text-secondary">
+                    <i class="fa fa-check"></i>
+                    Saved
+                </span>
+            </div>
+        </div>
+    </form>
+</div>
+
+<script>
+    (function() {
+
+        window.segmentInitializers.<?= !!@$segment ? $segment->segmentTemplate->internal_name : $segmentInternalName ?> = function() {
+
+            // HACK to make things simpler
+            // if !point, create empty parent WEIGHT_LOSS_INTAKE now
+            @if(!$point)
+
+            $.post('/api/visitPoint/addTopLevel', {
+                noteUid: '{{$note->uid}}',
+                category: 'WEIGHT_LOSS_INTAKE',
+                additionReasonCategory: 'ON_INTAKE'
+            }, _data => {
+                if(!hasResponseError(_data)) {
+                    $('.visit-segment[data-segment-template-name="mc_weight_loss_intake_subjective"]').find('.refresh-segment').trigger('click');
+                }
+            }, 'json');
+
+            @endif
+
+        };
+
+    }).call(window);
+</script>
+
 <style>
     .intake * {
         box-sizing: border-box;
@@ -336,8 +397,7 @@ $theirName = implode(" ", $theirName);
             $.post('/api/note/createUsingFreeTextHtml', {
                 clientUid: '{{ $patient->uid  }}',
                 hcpProUid: '{{ $pro->uid  }}',
-                effectiveDateEST: '{{ date('
-                Y - m - d ') }}',
+                effectiveDateEST: '{{ date('Y - m - d ') }}',
                 title: 'Visit Note',
                 freeTextHtml: content[0].outerHTML
             }, function(_data) {
@@ -350,8 +410,7 @@ $theirName = implode(" ", $theirName);
                     $.post('/api/client/updateMcpOnboardingVisitInfo', {
                         uid: '{{$patient->uid}}',
                         hasMcpDoneOnboardingVisit: 'YES',
-                        mcpOnboardingVisitDate: '{{date('
-                        Y - m - d ')}}',
+                        mcpOnboardingVisitDate: '{{date('Y - m - d ')}}',
                         mcpOnboardingVisitNoteUid: noteUid,
                     }, function(_data) {
                         if (!_data.success) {