Samson Mutunga %!s(int64=2) %!d(string=hai) anos
pai
achega
55e19c11f4

+ 1 - 0
resources/views/app/patient/modules/sleep_health_intake/edit.blade.php

@@ -222,6 +222,7 @@ if ($point->lastChildReview && $point->lastChildReview->data) {
 					this.initSelect2();
 					this.initOnSelectChange();
 					this.initOmegaCC();
+					initRequestToAddAProblem();
 				}
 			});
 

+ 4 - 2
resources/views/app/patient/modules/sleep_health_intake/partials/obstructive_sleep_apnea.blade.php

@@ -14,7 +14,9 @@ $questionnaire = [
                         'value' => 'No',
                         'label' => 'No'
                     ]
-                ]
+                    ],
+                    'problem' => 'Snoring',
+                    'problem_if_value' => 'Yes'
             ],
             'your_snoring_is' => [
                 'title' => 'Your Snoring is...?',
@@ -693,7 +695,7 @@ $questionnaire = [
                             </div>
                             @else
                             <label class="mb-0 mr-3">
-                                <input type="radio" name="{{ $questionKey }}" data-name="{{ $questionKey }}" value="{{ $option['value'] }}" <?= @$contentData[$questionKey] === $option['value'] ? 'checked' : '' ?> @change="onInputChange" />
+                                <input type="radio" <?= @$questionValue['problem'] ? 'data-problem="'.@$questionValue['problem'].'" data-problem-value="'.@$questionValue['problem_if_value'].'"': '' ?> name="{{ $questionKey }}" data-name="{{ $questionKey }}" value="{{ $option['value'] }}" <?= @$contentData[$questionKey] === $option['value'] ? 'checked' : '' ?> @change="onInputChange" />
                                 <span>{{ $option['label'] }}</span>
                             </label>
                             @endif

+ 22 - 0
resources/views/app/patient/note/segment_script.blade.php

@@ -119,6 +119,27 @@
             saveVisitForm(_trigger, true, true);
         };
 
+        window.initRequestToAddAProblem = function(){
+            //On any input/select etc, add these attribute:
+            // data-problem="Sneezing"
+            // data-problem-value="Yes" Note: this is the value to compare with to trigger problems center popup
+
+            var problemInput = $('[data-problem]');
+            problemInput.on('change', function(e){
+                var input = e.target;
+                var value = input.value;
+                var isProblemIfAnswerIs = $(input).data('problem-value');
+                if(value === isProblemIfAnswerIs){
+                    if (confirm("Do you want to add this as a problem?") == true) {
+                        $('#active-problems').click();
+                    } else {
+                       //Do nothing for now
+                    }
+                    
+                }
+            });
+        };
+
         function initRTEs(_parent) {
             _parent.find('[note-rte]:not(.ql-container)').each(function() {
 
@@ -196,6 +217,7 @@
         }
 
         function init() {
+            initRequestToAddAProblem();
 
             $(document)
                 .off('input.auto-grow', '[visit-moe] form textarea')