Explorar o código

Facility suggest query enhancements

Vijayakrishnan %!s(int64=3) %!d(string=hai) anos
pai
achega
34b3f2141d

+ 17 - 3
app/Http/Controllers/HomeController.php

@@ -1592,10 +1592,24 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
     {
         $term = $request->input('term') ? trim($request->input('term')) : '';
         if (empty($term)) return '';
+
+        $terms = explode(' ', $term);
+        $terms = array_filter($terms, function($_x) {
+            return !!trim($_x);
+        });
+
+        $whereCondition = [];
+        $whereParams = [];
+        for ($i = 0; $i < count($terms); $i++) {
+            $whereCondition[] = "(name ILIKE :term{$i} OR address_city ILIKE :term{$i} OR address_state ILIKE :term{$i} OR address_zip ILIKE :term{$i})";
+            $whereParams["term{$i}"] = '%' . $terms[$i] . '%';
+        }
+        $whereCondition = implode(" AND ", $whereCondition);
+
         $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 . '%']
-        );
+            "SELECT (name || ' ' || address_city || ' ' || address_state || ' ' || address_zip) as text, 
+       name, address_city as city, address_state as state, address_zip as zip, phone, fax FROM facility 
+       WHERE {$whereCondition} ORDER BY name", $whereParams);
         return json_encode([
             "success" => true,
             "data" => $matches

+ 4 - 1
resources/views/app/patient/prescriptions-popup/logistics-form.blade.php

@@ -1,7 +1,10 @@
 <div class="stag-popup stag-popup-sm mcp-theme-1" stag-popup-key="pp-logistics-popup">
     <form method="POST" action="" class="overflow-visible min-height-300px">
         <h3 class="stag-popup-title mb-2">
-            <span>Logistics</span>
+            <span v-if="currentPrescription && currentPrescription.erx_category === 'DRUG'">Pharmacy</span>
+            <span v-else-if="currentPrescription && currentPrescription.erx_category === 'LAB'">Lab</span>
+            <span v-else-if="currentPrescription && currentPrescription.erx_category === 'IMAGING'">Lab</span>
+            <span v-else>Logistics</span>
             <a href="#" class="ml-auto text-secondary"
                onclick="return closeStagPopup()"><i class="fa fa-times-circle"></i></a>
         </h3>

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

@@ -2,9 +2,9 @@
     <form method="POST" action="" class="overflow-visible min-height-300px">
         <h3 class="stag-popup-title mb-2">
 
-            <span v-if="currentPrescription.erx_category === 'DRUG'">Pharmacy</span>
-            <span v-else-if="currentPrescription.erx_category === 'LAB'">Lab</span>
-            <span v-else-if="currentPrescription.erx_category === 'IMAGING'">Lab</span>
+            <span v-if="currentPrescription && currentPrescription.erx_category === 'DRUG'">Pharmacy</span>
+            <span v-else-if="currentPrescription && currentPrescription.erx_category === 'LAB'">Lab</span>
+            <span v-else-if="currentPrescription && currentPrescription.erx_category === 'IMAGING'">Lab</span>
             <span v-else>Logistics</span>
 
             <a href="#" class="ml-auto text-secondary"