Browse Source

Med reconciliation - disallow if none reconciled

Vijayakrishnan 3 years ago
parent
commit
e238a63eba
1 changed files with 22 additions and 2 deletions
  1. 22 2
      resources/views/app/patient/medications-reconcile.blade.php

+ 22 - 2
resources/views/app/patient/medications-reconcile.blade.php

@@ -99,7 +99,17 @@ $medications = $points;
                 var quill = new Quill(el, {
                 var quill = new Quill(el, {
                     theme: 'snow',
                     theme: 'snow',
                     modules: {
                     modules: {
-                        toolbar: false
+                        toolbar: false,
+                        keyboard: {
+                            bindings: {
+                                'tab': {
+                                    key: 9,
+                                    handler: function(range, context) {
+                                        return true;
+                                    }
+                                }
+                            }
+                        }
                     }
                     }
                 });
                 });
                 quill.root.innerHTML = existingContent;
                 quill.root.innerHTML = existingContent;
@@ -125,13 +135,16 @@ $medications = $points;
             $('#medications-reconcile-{{$note->id}} .btn-save-reviews')
             $('#medications-reconcile-{{$note->id}} .btn-save-reviews')
                 .off('click')
                 .off('click')
                 .on('click', function() {
                 .on('click', function() {
-                    showMask();
                     let payload = {
                     let payload = {
                         noteUid: '{{$note->uid}}',
                         noteUid: '{{$note->uid}}',
                         reviews: []
                         reviews: []
                     }
                     }
+
+                    let hasAtLeastOneNonEmptyReview = false;
+
                     $('#medications-reconcile-{{$note->id}} [data-point-uid]').each(function () {
                     $('#medications-reconcile-{{$note->id}} [data-point-uid]').each(function () {
                         if($.trim($('<div/>').html($(this).find('.ql-editor').html()).text())) {
                         if($.trim($('<div/>').html($(this).find('.ql-editor').html()).text())) {
+                            hasAtLeastOneNonEmptyReview = true;
                             payload.reviews.push({
                             payload.reviews.push({
                                 parentPointUid: $(this).attr('data-point-uid'),
                                 parentPointUid: $(this).attr('data-point-uid'),
                                 data: JSON.stringify({
                                 data: JSON.stringify({
@@ -142,6 +155,13 @@ $medications = $points;
                         }
                         }
                     });
                     });
 
 
+                    if(!hasAtLeastOneNonEmptyReview) {
+                        toastr.error('New subjective is empty on all medications!');
+                        return false;
+                    }
+
+                    showMask();
+
                     $.ajax({
                     $.ajax({
                         url: '/api/visitPoint/upsertChildReviewMulti',
                         url: '/api/visitPoint/upsertChildReviewMulti',
                         type:"POST",
                         type:"POST",