|
@@ -1690,7 +1690,7 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
|
|
if (empty($term)) return '';
|
|
if (empty($term)) return '';
|
|
|
|
|
|
// replace comma with space
|
|
// replace comma with space
|
|
- $term = str_replace(',', ' ', $term);
|
|
|
|
|
|
+ $term = preg_replace("/[,\s]+/", ' ', $term);
|
|
|
|
|
|
// special param for phone matching
|
|
// special param for phone matching
|
|
$phoneTerm = preg_replace('/[^a-zA-Z0-9]/', '', $originalTerm);
|
|
$phoneTerm = preg_replace('/[^a-zA-Z0-9]/', '', $originalTerm);
|
|
@@ -1734,12 +1734,18 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ $orderBy = "ORDER BY CASE
|
|
|
|
+ WHEN POSITION(LOWER(:termRaw) IN LOWER(c.name_last)) = 0 THEN 99999
|
|
|
|
+ ELSE POSITION(LOWER(:termRaw) IN LOWER(c.name_last))
|
|
|
|
+ END";
|
|
|
|
+
|
|
$sql = "
|
|
$sql = "
|
|
SELECT $columns FROM client c
|
|
SELECT $columns FROM client c
|
|
WHERE c.shadow_pro_id IS NULL
|
|
WHERE c.shadow_pro_id IS NULL
|
|
AND c.duplicate_of_client_id IS NULL
|
|
AND c.duplicate_of_client_id IS NULL
|
|
$termWhere
|
|
$termWhere
|
|
$proWhere
|
|
$proWhere
|
|
|
|
+ $orderBy
|
|
";
|
|
";
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -1777,11 +1783,13 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
|
|
*/
|
|
*/
|
|
|
|
|
|
$params = [
|
|
$params = [
|
|
|
|
+ 'termRaw' => $term,
|
|
'term' => '%' . $term . '%',
|
|
'term' => '%' . $term . '%',
|
|
'phoneTerm' => '%' . $phoneTerm . '%',
|
|
'phoneTerm' => '%' . $phoneTerm . '%',
|
|
'phoneTermRaw' => '%' . $originalTerm . '%',
|
|
'phoneTermRaw' => '%' . $originalTerm . '%',
|
|
];
|
|
];
|
|
if(!empty($term2)) {
|
|
if(!empty($term2)) {
|
|
|
|
+ //$params['term2Raw'] = $term2;
|
|
$params['term2'] = '%' . $term2 . '%';
|
|
$params['term2'] = '%' . $term2 . '%';
|
|
}
|
|
}
|
|
$clients = DB::select($sql, $params);
|
|
$clients = DB::select($sql, $params);
|