Browse Source

cc_hpi > ICD autocomplete

Vijayakrishnan 4 years ago
parent
commit
a8fa1429db
1 changed files with 29 additions and 2 deletions
  1. 29 2
      resources/views/app/patient/canvas-sections/cc_hpi/form.blade.php

+ 29 - 2
resources/views/app/patient/canvas-sections/cc_hpi/form.blade.php

@@ -68,12 +68,12 @@ $formID = rand(0, 100000);
                 </select>
                 </select>
             </td>
             </td>
             <td>
             <td>
-                <input type="text" :data-index="index"
+                <input type="text" :data-index="index" data-field="title"
                        class="form-control form-control-sm"
                        class="form-control form-control-sm"
                        v-model="item.name" required>
                        v-model="item.name" required>
             </td>
             </td>
             <td>
             <td>
-                <input type="text" :data-index="index"
+                <input type="text" :data-index="index" data-field="icd"
                        class="form-control form-control-sm"
                        class="form-control form-control-sm"
                        v-model="item.icd" required>
                        v-model="item.icd" required>
             </td>
             </td>
@@ -127,6 +127,7 @@ $formID = rand(0, 100000);
                 mounted: function() {
                 mounted: function() {
                     $('#cc_hpiSection_{{$formID}} [moe][initialized]').removeAttr('initialized');
                     $('#cc_hpiSection_{{$formID}} [moe][initialized]').removeAttr('initialized');
                     initMoes();
                     initMoes();
+                    this.initICDAutoSuggest();
                 },
                 },
                 watch: {
                 watch: {
                     $data: {
                     $data: {
@@ -147,6 +148,9 @@ $formID = rand(0, 100000);
                                 "free_text": ''
                                 "free_text": ''
                             },
                             },
                         });
                         });
+                        Vue.nextTick(() => {
+                            this.initICDAutoSuggest();
+                        });
                     },
                     },
                     removeItem: function(_index) {
                     removeItem: function(_index) {
                         this.data['current_cch']['list'].splice(_index, 1);
                         this.data['current_cch']['list'].splice(_index, 1);
@@ -164,6 +168,29 @@ $formID = rand(0, 100000);
                         }
                         }
                         return plItems;
                         return plItems;
                     },
                     },
+                    initICDAutoSuggest: function() {
+                        let self = this;
+                        $('#cc_hpiSection_{{$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['current_cch']['list'][vueIndex].icd = acData[0].code;
+                                self.data['current_cch']['list'][vueIndex].memo = acData[0].data['name'];
+                                return false;
+                            });
+                            $(elem).attr('ac-initialized', 1);
+                        });
+                    },
                 }
                 }
             });
             });
         }
         }