Jelajahi Sumber

Notes filter

Vijayakrishnan 4 tahun lalu
induk
melakukan
15de95496c

+ 2 - 2
app/Http/Controllers/PatientController.php

@@ -143,10 +143,10 @@ class PatientController extends Controller
         return view('app.patient.allergies', compact('patient', 'infoLines'));
     }
 
-    public function notes(Request $request, Client $patient )
+    public function notes(Request $request, Client $patient, $filter = 'active')
     {
         $pros = $this->pros;
-        return view('app.patient.notes', compact('patient','pros'));
+        return view('app.patient.notes', compact('patient','pros', 'filter'));
     }
 
     public function sections(Request $request, Client $patient )

+ 14 - 1
app/Models/Client.php

@@ -32,7 +32,20 @@ class Client extends Model
     }
 
     public function notes() {
-        return $this->hasMany(Note::class, 'client_id', 'id')->orderBy('effective_dateest', 'desc');
+        return $this->hasMany(Note::class, 'client_id', 'id')
+            ->orderBy('effective_dateest', 'desc');
+    }
+
+    public function activeNotes() {
+        return $this->hasMany(Note::class, 'client_id', 'id')
+            ->where('is_cancelled', false)
+            ->orderBy('effective_dateest', 'desc');
+    }
+
+    public function cancelledNotes() {
+        return $this->hasMany(Note::class, 'client_id', 'id')
+            ->where('is_cancelled', true)
+            ->orderBy('effective_dateest', 'desc');
     }
 
     public function sections() {

+ 22 - 2
resources/views/app/patient/notes.blade.php

@@ -3,7 +3,7 @@
 @section('inner-content')
 
     <div class="pt-2 d-flex align-items-start">
-        <h6 class="my-0 text-secondary d-flex align-items-start">
+        <h6 class="my-0 text-secondary d-flex align-items-center w-100">
             <span class="font-weight-bold text-secondary">Notes</span>
             <span class="mx-2 text-secondary">|</span>
             <div moe>
@@ -26,6 +26,12 @@
                     </div>
                 </form>
             </div>
+            <select class="ml-auto max-width-300px form-control form-control-sm"
+                    onchange="fastLoad('/patients/view/{{$patient->uid}}/notes/' + this.value, true, false, false)">
+                <option value="active" {{ $filter === 'active' ? 'selected' : '' }}>Active notes</option>
+                <option value="cancelled" {{ $filter === 'cancelled' ? 'selected' : '' }}>Cancelled notes</option>
+                <option value="all" {{ $filter === 'all' ? 'selected' : '' }}>All notes</option>
+            </select>
         </h6>
     </div>
 
@@ -42,7 +48,21 @@
         </tr>
         </thead>
         <tbody>
-        @foreach ($patient->notes as $note)
+        <?php
+        $records = [];
+        switch ($filter) {
+            case "active":
+                $records = $patient->activeNotes;
+                break;
+            case "cancelled":
+                $records = $patient->cancelledNotes;
+                break;
+            case "all":
+                $records = $patient->notes;
+                break;
+        }
+        ?>
+        @foreach ($records as $note)
             <tr class="{{ $note->is_cancelled ? 'cancelled-item always-clickable' : '' }}">
                 <td class="px-2">
                     <span class="font-weight-bold">

+ 1 - 1
routes/web.php

@@ -99,7 +99,7 @@ Route::middleware('pro.auth')->group(function () {
         Route::get('immunizations', 'PatientController@immunizations')->name('immunizations');
         Route::get('allergies', 'PatientController@allergies')->name('allergies');
         Route::get('action-items', 'PatientController@actionItems')->name('action-items');
-        Route::get('notes', 'PatientController@notes')->name('notes');
+        Route::get('notes/{filter?}', 'PatientController@notes')->name('notes');
         Route::name('notes.view.')->prefix('notes/view/{note}')->group(function () {
             Route::get('', 'NoteController@dashboard')->name('dashboard');
         });