Bläddra i källkod

Centers - add-single no default entry type

Vijayakrishnan 2 år sedan
förälder
incheckning
ae6fdab625

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

@@ -53,8 +53,7 @@
             <div class="d-flex align-items-baseline mt-1">
                 <label class="my-0 d-inline-flex align-items-center">
                     <input type="radio" name="additionReasonCategory" value="ON_INTAKE"
-				{{ !$point ? 'checked' : '' }}
-                            {{$point && $point->addition_reason_category === 'ON_INTAKE' ? 'checked' : ''}}
+				            {{$point && $point->addition_reason_category === 'ON_INTAKE' ? 'checked' : ''}}
                             {{0 && $point && $point->added_in_note_id !== $note->id ? 'readonly disabled' : ''}}>
                     <span class="ml-1">Pre-existing</span>
                 </label>
@@ -121,6 +120,8 @@
 
 </div>
 
+<div if-entry-type-not-empty class="d-none">
+
 <div {{@$point ? 'if-not-entry-error class="d-none"' : ''}}>
     <div if-addition-or-removal-on-intake-or-during-visit class="d-none">
         <div class="row mb-2">
@@ -240,3 +241,5 @@
 
     </div>
 </div>
+
+</div>

+ 17 - 3
resources/views/app/patient/wizard-partials/common-script.blade.php

@@ -170,7 +170,7 @@ parentSegment.find('[name="additionReasonCategory"]')
     .off('change')
     .on('change', function () {
         let form = $(this).closest('form');
-        form.find('[if-addition-on-intake-or-during-visit], [if-addition-on-intake], [if-addition-during-visit], [if-active-and-pre-existing-or-not-active], [if-active-and-not-pre-existing]').addClass('d-none');
+        form.find('[if-addition-on-intake-or-during-visit], [if-addition-on-intake], [if-addition-during-visit], [if-active-and-pre-existing-or-not-active], [if-active-and-not-pre-existing], [if-entry-type-not-empty]').addClass('d-none');
         if(form.find('[name="additionReasonCategory"]:checked').length) form.find('[if-addition-on-intake-or-during-visit]').removeClass('d-none');
         form.find('[if-addition-or-removal-on-intake-or-during-visit]').addClass('d-none');
         if(form.find('[name="additionReasonCategory"]:checked').length || form.find('[name="removalReasonCategory"]:checked').length) {
@@ -192,6 +192,9 @@ parentSegment.find('[name="additionReasonCategory"]')
         if(form.find('[name="isRemoved"]:checked').val() === '0' && form.find('[name="additionReasonCategory"]:checked').val() !== 'ON_INTAKE') {
             form.find('[if-active-and-not-pre-existing]').removeClass('d-none');
         }
+        if(form.find('[name="additionReasonCategory"]:checked').length || form.find('[name="removalReasonCategory"]:checked').length) {
+            form.find('[if-entry-type-not-empty]').removeClass('d-none');
+        }
         return false;
     })
     .trigger('change');
@@ -200,7 +203,7 @@ parentSegment.find('[name="removalReasonCategory"]')
     .off('change')
     .on('change', function () {
         let form = $(this).closest('form');
-        form.find('[if-removal-on-intake-or-during-visit], [if-removal-on-intake], [if-removal-during-visit]').addClass('d-none');
+        form.find('[if-removal-on-intake-or-during-visit], [if-removal-on-intake], [if-removal-during-visit], [if-entry-type-not-empty]').addClass('d-none');
         if(form.find('[name="removalReasonCategory"]:checked').length) form.find('[if-removal-on-intake-or-during-visit]').removeClass('d-none');
         form.find('[if-addition-or-removal-on-intake-or-during-visit]').addClass('d-none');
         if(form.find('[name="additionReasonCategory"]:checked').length || form.find('[name="removalReasonCategory"]:checked').length) {
@@ -220,6 +223,9 @@ parentSegment.find('[name="removalReasonCategory"]')
             form.find('[name="removalEffectiveDate"]').val('{{$patient->core_note_id !== $note->id ? $note->effective_dateest : date("Y-m-d")}}');
             form.find('[name="removalReasonMemo"]').val('{{$patient->core_note_id !== $note->id ? ($note->hcpPro ? $note->hcpPro->displayName() : "")  : ""}}');
         }
+        if(form.find('[name="additionReasonCategory"]:checked').length || form.find('[name="removalReasonCategory"]:checked').length) {
+            form.find('[if-entry-type-not-empty]').removeClass('d-none');
+        }
         return false;
     })
     .trigger('change');
@@ -260,6 +266,12 @@ parentSegment.find('#frm-add-{{$label}}')
             }
         }
 
+        // ensure an entry-type is selected
+        if(!form.find('[name="additionReasonCategory"]:checked').length && !form.find('[name="removalReasonCategory"]:checked').length) {
+            toastr.error('Entry type not selected.')
+            return false;
+        }
+
         if (!form[0].checkValidity()) {
             form[0].reportValidity();
             return false;
@@ -730,7 +742,9 @@ parentSegment.find('.btn-entry-type')
 
         return false;
     });
-parentSegment.find('.btn-entry-type[data-entry-type="Pre-Existing"]').trigger('click');
+
+// do not default to Pre-Existing
+// parentSegment.find('.btn-entry-type[data-entry-type="Pre-Existing"]').trigger('click');
 
 const debounce = (func, wait) => {
     let timeout;