浏览代码

Patient dashboard - show only latest 20 measurements

Vijayakrishnan 3 年之前
父节点
当前提交
988d403d1e
共有 2 个文件被更改,包括 13 次插入1 次删除
  1. 12 0
      app/Models/Client.php
  2. 1 1
      resources/views/app/patient/partials/measurements.blade.php

+ 12 - 0
app/Models/Client.php

@@ -132,6 +132,18 @@ class Client extends Model
             ->orderByRaw('ts DESC NULLS LAST');
     }
 
+    public function recentMeasurements()
+    {
+        return $this->hasMany(Measurement::class, 'client_id', 'id')
+            ->where('is_removed', false)
+            ->whereNotNull('label')
+            ->where('label', '<>', 'SBP')
+            ->where('label', '<>', 'DBP')
+            ->where('is_cellular_zero', false)
+            ->orderByRaw('ts DESC NULLS LAST')
+            ->offset(0)->limit(20);
+    }
+
     public function nonZeroMeasurements()
     {
         return $this->hasMany(Measurement::class, 'client_id', 'id')

+ 1 - 1
resources/views/app/patient/partials/measurements.blade.php

@@ -53,7 +53,7 @@
     </div>
     <table class="table table-sm border-0 m-0">
         <tbody>
-        @foreach($patient->measurements as $measurement)
+        @foreach($patient->recentMeasurements as $measurement)
             @if(1 || !empty($measurement->label) && !in_array($measurement->label, $vitalLabels))
                 @if(!in_array($measurement->label, ["SBP", "DBP"]))
                     @if(!empty($measurement->client_bdt_measurement_id))