|
@@ -1592,10 +1592,24 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
|
|
{
|
|
{
|
|
$term = $request->input('term') ? trim($request->input('term')) : '';
|
|
$term = $request->input('term') ? trim($request->input('term')) : '';
|
|
if (empty($term)) return '';
|
|
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(
|
|
$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([
|
|
return json_encode([
|
|
"success" => true,
|
|
"success" => true,
|
|
"data" => $matches
|
|
"data" => $matches
|