Parcourir la source

disallow save if review/plan same as previous

Vijayakrishnan il y a 3 ans
Parent
commit
23cd37e76f

+ 2 - 0
resources/views/app/patient/wizard-partials/common-fields.blade.php

@@ -163,6 +163,7 @@
                 </div>
                 <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
             </div>
+            <div class="d-none disallow-if-review-same-as" compare-width="reviewValue"><?= str_compact($previousValue) ?></div>
             <?php endif; ?>
             <div note-rte
                  class="form-group mb-2 border-left border-right rte-holder bg-white"
@@ -207,6 +208,7 @@
                 </div>
                 <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
             </div>
+            <div class="d-none disallow-if-plan-same-as" compare-width="planValue"><?= str_compact($previousValue) ?></div>
             <?php endif; ?>
             <div note-rte
                  class="form-group mb-2 border-left border-right rte-holder bg-white"

+ 27 - 6
resources/views/app/patient/wizard-partials/common-script.blade.php

@@ -253,13 +253,34 @@ parentSegment.find('.frm-edit-{{$label}}')
         }
 
         @if($patient->core_note_id !== $note->id)
-        // store plan content
-        let planContent = parsed && parsed.planValue ? parsed.planValue : '';
         let reviewContent = parsed && parsed.reviewValue ? parsed.reviewValue : '';
-        // if(!$.trim($('<div/>').html(planContent).text())) {
-        //     toastr.error('Directions cannot be empty');
-        //     return false;
-        // }
+
+        let compareWith = false;
+        if(form.find('.disallow-if-review-same-as')) {
+            compareWith = $.trim(form.find('.disallow-if-review-same-as').text());
+            if(compareWith && reviewContent) {
+                let newValue = $('<div/>').html(reviewContent).text().replace(/[^a-zA-Z0-9]/g, '');
+                if(newValue === compareWith) {
+                    alert('New review should be different from the previous review!');
+                    return false;
+                }
+            }
+        }
+
+        let planContent = parsed && parsed.planValue ? parsed.planValue : '';
+
+        compareWith = false;
+        if(form.find('.disallow-if-plan-same-as')) {
+            compareWith = $.trim(form.find('.disallow-if-plan-same-as').text());
+            if(compareWith && planContent) {
+                let newValue = $('<div/>').html(planContent).text().replace(/[^a-zA-Z0-9]/g, '');
+                if(newValue === compareWith) {
+                    alert('New plan should be different from the previous plan!');
+                    return false;
+                }
+            }
+        }
+
         if(parsed.planValue) delete parsed.planValue;
         if(parsed.reviewValue) delete parsed.reviewValue;
         @endif