Sfoglia il codice sorgente

Facility search impl

Vijayakrishnan 3 anni fa
parent
commit
5181da1efc

+ 14 - 0
app/Http/Controllers/HomeController.php

@@ -1588,6 +1588,20 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
         return view('app/pharmacy-suggest', compact('pharmacies'));
     }
 
+    public function facilitySuggestJSON(Request $request)
+    {
+        $term = $request->input('term') ? trim($request->input('term')) : '';
+        if (empty($term)) return '';
+        $matches = DB::select(
+            "SELECT (name || ' ' || address_city || ' ' || address_state) as text, name, address_city as city, address_state as state, address_zip as zip, phone, fax FROM facility WHERE name ILIKE :term ORDER BY name",
+            ['term' => '%' . $term . '%']
+        );
+        return json_encode([
+            "success" => true,
+            "data" => $matches
+        ]);
+    }
+
     public function proSuggest(Request $request) {
         $term = $request->input('term') ? trim($request->input('term')) : '';
         if (empty($term)) return '';

+ 14 - 0
resources/views/app/patient/prescriptions-popup/list-popup.blade.php

@@ -758,6 +758,8 @@ GROUP BY erx_category");
                         }
                         Vue.nextTick(() => {
                             showStagPopup('pp-logistics-popup', true);
+                            $('[stag-popup-key="pp-logistics-popup"] [stag-suggest-initialized]').removeAttr('stag-suggest-initialized');
+                            initStagSuggest();
                         });
                     },
                     saveLogistics: function() {
@@ -1171,6 +1173,18 @@ GROUP BY erx_category");
                             }
                         }
                     });
+
+                    $('[stag-popup-key="pp-logistics-popup"] .facility-search').off('stag-suggest-selected');
+                    $('[stag-popup-key="pp-logistics-popup"] .facility-search').on('stag-suggest-selected', (_e, _input, _data) => {
+                        if(self.currentPrescriptionLogistics && self.currentPrescriptionLogistics.logisticsDetailJson) {
+                            self.currentPrescriptionLogistics.logisticsDetailJson.facilityName = _data.name;
+                            self.currentPrescriptionLogistics.logisticsDetailJson.facilityCity = _data.city;
+                            self.currentPrescriptionLogistics.logisticsDetailJson.facilityState = _data.state;
+                            self.currentPrescriptionLogistics.logisticsDetailJson.facilityZip = _data.zip;
+                            self.currentPrescriptionLogistics.logisticsDetailJson.facilityPhone = _data.phone;
+                            self.currentPrescriptionLogistics.logisticsDetailJson.facilityFax = _data.fax;
+                        }
+                    });
                 }
             });
 

+ 5 - 2
resources/views/app/patient/prescriptions-popup/logistics-form.blade.php

@@ -1,5 +1,5 @@
 <div class="stag-popup stag-popup-sm mcp-theme-1" stag-popup-key="pp-logistics-popup">
-    <form method="POST" action="">
+    <form method="POST" action="" class="overflow-visible min-height-300px">
         <h3 class="stag-popup-title mb-2">
             <span>Logistics</span>
             <a href="#" class="ml-auto text-secondary"
@@ -7,7 +7,10 @@
         </h3>
         <div class="mb-2">
             <label class="text-sm text-secondary mb-1">Business Name</label>
-            <input type="text" class="form-control form-control-sm min-width-unset"
+            <input type="text" class="form-control form-control-sm min-width-unset facility-search"
+                   stag-suggest
+                   stag-suggest-ep="/search-facility/json"
+                   autocomplete="donotdoit"
                    v-model="currentPrescriptionLogistics.logisticsDetailJson.facilityName">
         </div>
         <div class="row">

+ 14 - 0
resources/views/app/patient/prescriptions/list.blade.php

@@ -776,6 +776,8 @@ GROUP BY erx_category");
                         }
                         Vue.nextTick(() => {
                             showStagPopup('logistics-popup', true);
+                            $('[stag-popup-key="logistics-popup"] [stag-suggest-initialized]').removeAttr('stag-suggest-initialized');
+                            initStagSuggest();
                         });
                     },
                     saveLogistics: function() {
@@ -1222,6 +1224,18 @@ GROUP BY erx_category");
                             }
                         }
                     });
+
+                    $('[stag-popup-key="logistics-popup"] .facility-search').off('stag-suggest-selected');
+                    $('[stag-popup-key="logistics-popup"] .facility-search').on('stag-suggest-selected', (_e, _input, _data) => {
+                        if(self.currentPrescriptionLogistics && self.currentPrescriptionLogistics.logisticsDetailJson) {
+                            self.currentPrescriptionLogistics.logisticsDetailJson.facilityName = _data.name;
+                            self.currentPrescriptionLogistics.logisticsDetailJson.facilityCity = _data.city;
+                            self.currentPrescriptionLogistics.logisticsDetailJson.facilityState = _data.state;
+                            self.currentPrescriptionLogistics.logisticsDetailJson.facilityZip = _data.zip;
+                            self.currentPrescriptionLogistics.logisticsDetailJson.facilityPhone = _data.phone;
+                            self.currentPrescriptionLogistics.logisticsDetailJson.facilityFax = _data.fax;
+                        }
+                    });
                 }
             });
 

+ 5 - 2
resources/views/app/patient/prescriptions/logistics-form.blade.php

@@ -1,5 +1,5 @@
 <div class="stag-popup stag-popup-sm mcp-theme-1" stag-popup-key="logistics-popup">
-    <form method="POST" action="">
+    <form method="POST" action="" class="overflow-visible min-height-300px">
         <h3 class="stag-popup-title mb-2">
             <span>Logistics</span>
             <a href="#" class="ml-auto text-secondary"
@@ -7,7 +7,10 @@
         </h3>
         <div class="mb-2">
             <label class="text-sm text-secondary mb-1">Business Name</label>
-            <input type="text" class="form-control form-control-sm min-width-unset"
+            <input type="text" class="form-control form-control-sm min-width-unset facility-search"
+                   stag-suggest
+                   stag-suggest-ep="/search-facility/json"
+                   autocomplete="donotdoit"
                    v-model="currentPrescriptionLogistics.logisticsDetailJson.facilityName">
         </div>
         <div class="row">

+ 1 - 0
routes/web.php

@@ -489,6 +489,7 @@ Route::middleware('pro.auth')->group(function () {
     Route::any('/fdb-duplicate-therapy', 'FDBPGController@duplicateTherapy');
 
     Route::get('/search-payer/json', 'PayerController@searchPayerV2JSON')->name('searchPayerV2JSON');
+    Route::get('/search-facility/json', 'HomeController@facilitySuggestJSON')->name('facilitySuggestJSON');
 
 });