Forráskód Böngészése

next_fu > ICD autocomplete

Vijayakrishnan 4 éve
szülő
commit
010a75d493

+ 28 - 1
resources/views/app/patient/canvas-sections/next_fu/form.blade.php

@@ -84,7 +84,7 @@ $formID = rand(0, 100000);
                            v-model="item.name" required>
                 </td>
                 <td>
-                    <input type="text" :data-index="index"
+                    <input type="text" :data-index="index" data-field="icd"
                            class="form-control form-control-sm"
                            v-model="item.icd">
                 </td>
@@ -116,6 +116,7 @@ $formID = rand(0, 100000);
                 mounted: function() {
                     $('#next_fuSection_{{$formID}} [moe][initialized]').removeAttr('initialized');
                     initMoes();
+                    this.initICDAutoSuggest();
                 },
                 watch: {
                     $data: {
@@ -133,6 +134,9 @@ $formID = rand(0, 100000);
                             "icd": '',
                             "memo": '',
                         });
+                        Vue.nextTick(() => {
+                            this.initICDAutoSuggest();
+                        });
                     },
                     removeNextCCItem: function(_index) {
                         this.data['next_cc']['list'].splice(_index, 1);
@@ -150,6 +154,29 @@ $formID = rand(0, 100000);
                         }
                         return plItems;
                     },
+                    initICDAutoSuggest: function() {
+                        let self = this;
+                        $('#next_fuSection_{{$formID}} input[type="text"][data-field="icd"]:not([ac-initialized])').each(function() {
+                            var elem = this,
+                                dynID = 'icd-' + Math.ceil(Math.random() * 1000000),
+                                vueIndex = $(this).attr('data-index');
+                            $(elem).attr('id', dynID);
+                            new window.Def.Autocompleter.Search(dynID,
+                                'https://clinicaltables.nlm.nih.gov/api/icd10cm/v3/search?sf=code,name&ef=name', {
+                                    tableFormat: true,
+                                    valueCols: [0],
+                                    colHeaders: ['Code', 'Name'],
+                                }
+                            );
+                            window.Def.Autocompleter.Event.observeListSelections(dynID, function() {
+                                let autocomp = elem.autocomp, acData = autocomp.getSelectedItemData();
+                                self.data['next_cc']['list'][vueIndex].icd = acData[0].code;
+                                self.data['next_cc']['list'][vueIndex].memo = acData[0].data['name'];
+                                return false;
+                            });
+                            $(elem).attr('ac-initialized', 1);
+                        });
+                    },
                 }
             });
         }