فهرست منبع

Create patient updates + patient suggest return order update

Vijayakrishnan Krishnan 3 روز پیش
والد
کامیت
255e4716f2

+ 9 - 1
app/Http/Controllers/HomeController.php

@@ -1690,7 +1690,7 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
         if (empty($term)) return '';
 
         // replace comma with space
-        $term = str_replace(',', ' ', $term);
+        $term = preg_replace("/[,\s]+/", ' ', $term);
 
         // special param for phone matching
         $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 = "
         SELECT $columns FROM client c 
         WHERE c.shadow_pro_id IS NULL
               AND c.duplicate_of_client_id IS NULL
               $termWhere
               $proWhere
+              $orderBy
         ";
 
         /*
@@ -1777,11 +1783,13 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
         */
 
         $params = [
+            'termRaw' =>  $term,
             'term' => '%' . $term . '%',
             'phoneTerm' => '%' . $phoneTerm . '%',
             'phoneTermRaw' => '%' . $originalTerm . '%',
         ];
         if(!empty($term2)) {
+            //$params['term2Raw'] = $term2;
             $params['term2'] = '%' . $term2 . '%';
         }
         $clients = DB::select($sql, $params);

+ 6 - 6
resources/views/app/patient/create-patient/demographics-form.blade.php

@@ -5,11 +5,11 @@
 	<div class="col-md-12 form-group mt-2">
 		<div class="d-md-flex align-items-center">
 			<label class="font-weight-bold m-0 w-25">Name:</label>
-			<input autocomplete="_blank" type="text" name="patientNamePrefix" placeholder="Prefix" class="ml-2 mb-md-0 mb-2 form-control input-sm w-md-50">
-			<input autocomplete="_blank" type="text" required name="patientNameFirst" placeholder="First*" required class="ml-2 mb-md-0 mb-2 form-control input-sm">
-			<input autocomplete="_blank" type="text" name="patientNameMiddle" placeholder="Middle" class="ml-2 mb-md-0 mb-2 form-control input-sm">
-			<input autocomplete="_blank" type="text" name="patientNameLast" placeholder="Last*" required class="ml-2 mb-md-0 mb-2 form-control input-sm">
-			<input autocomplete="_blank" type="text" name="patientNameSuffix" placeholder="Suffix" class="ml-2 mb-md-0 mb-2 form-control input-sm w-md-50">
+			{{--<input autocomplete="_blank" type="text" name="patientNamePrefix" placeholder="Prefix" class="ml-2 mb-md-0 mb-2 form-control input-sm w-md-50">--}}
+			<input autocomplete="_blank" type="text" name="patientFirstName" placeholder="First*" required class="ml-2 mb-md-0 mb-2 form-control input-sm">
+			<input autocomplete="_blank" type="text" name="patientMiddleName" placeholder="Middle" class="ml-2 mb-md-0 mb-2 form-control input-sm">
+			<input autocomplete="_blank" type="text" name="patientLastName" placeholder="Last*" required class="ml-2 mb-md-0 mb-2 form-control input-sm">
+			<input autocomplete="_blank" type="text" name="patientSuffix" placeholder="Suffix" class="ml-2 mb-md-0 mb-2 form-control input-sm w-md-50">
 		</div>
 	</div>
 	<div class="col-md-12">
@@ -39,7 +39,7 @@
 		<div class="row align-items-center form-group">
 			<label class="col-md-2 pr-0 font-weight-bold m-0">DOB: <span class="text-danger">*</span></label>
 			<div class="col-md-10">
-				<input type="date" required name="patientDob" value="" class="form-control input-sm" max="{{date('Y-m-d')}}">
+				<input type="date" required name="patientBirthDate" value="" class="form-control input-sm" max="{{date('Y-m-d')}}">
 			</div>
 		</div>
 	</div>