Browse Source

CM measurements matrix (WIP)

Vijayakrishnan 3 năm trước cách đây
mục cha
commit
80e07eda46

+ 48 - 0
app/Models/Client.php

@@ -645,4 +645,52 @@ class Client extends Model
         $notes = $notes->orderBy('effective_dateest', 'DESC')->limit(5)->get();
         return $notes;
     }
+
+    public function cmMeasurementsMatrix($_careMonth = null) {
+
+        $days = [];
+
+        $matches = DB::select(
+            "
+SELECT m.id   AS measurement_id,
+       m.uid  AS measurement_uid,
+       cm.id  AS care_month_id,
+       cm.uid AS care_month_uid,
+       m.label,
+       m.value,
+       m.dbp_mm_hg,
+       m.sbp_mm_hg,
+       m.value_pulse,
+       m.value_irregular,
+       m.numeric_value,
+       m.effective_date,
+       m.ts
+FROM measurement m
+         JOIN care_month cm ON m.care_month_id = cm.id
+WHERE m.care_month_id = :careMonthID
+        AND m.bdt_measurement_id IS NOT NULL
+        AND m.is_cellular_zero IS FALSE
+        AND m.is_removed IS FALSE
+ORDER BY m.effective_date
+            ",
+            ['careMonthID' => $_careMonth->id]
+        );
+
+        foreach ($matches as $match) {
+            $time = (floor($match->ts / 1000));
+            $realTimezone = resolve_timezone('EASTERN');
+            $date = new \DateTime("@$time");
+            $date->setTimezone(new \DateTimeZone($realTimezone));
+            $match->date = $date->format("m/d/Y");
+            $match->time = $date->format("h:i A");
+
+            if(!isset($days[$match->date])) {
+                $days[$match->date] = [];
+            }
+            $days[$match->date][] = $match;
+        }
+
+        return $days;
+
+    }
 }

+ 3 - 0
public/css/style.css

@@ -292,6 +292,9 @@ body>nav.navbar {
 .mcp-theme-1 .width-50px {
     width: 50px !important;
 }
+.mcp-theme-1 .width-60px {
+    width: 60px !important;
+}
 .mcp-theme-1 .width-70px {
     width: 70px !important;
 }

+ 44 - 0
resources/views/app/patient/care-month/_matrix.blade.php

@@ -0,0 +1,44 @@
+<?php
+    $days = $patient->cmMeasurementsMatrix($careMonth);
+    dump($days);
+?>
+<table class="table table-striped table-sm table-bordered mt-2 mb-0">
+    <thead>
+    <tr>
+        <th class="px-2 text-secondary">Date</th>
+        <th class="px-2 text-secondary w-25">Measurements</th>
+        <th class="px-2 text-secondary w-25">Stamp + Entry</th>
+        <th class="px-2 text-secondary">Entries</th>
+    </tr>
+    </thead>
+    <tbody>
+    @foreach($days as $k => $day)
+        <tr>
+            <td>
+                {{$k}}
+            </td>
+            <td>
+                @foreach($days[$k] as $m)
+                    <div class="mb-1 d-flex align-items-baseline">
+                        <span class="width-60px text-sm text-nowrap text-secondary">{{$m->time}}</span>
+                        <span class="width-50px">
+                            @if($m->label === 'BP')
+                                BP
+                            @elseif($m->label === 'Wt. (lbs.)')
+                                Weight
+                            @endif
+                        </span>
+                        <span class="width-100px font-weight-bold">
+                            @if($m->label === 'BP')
+                                {{ $m->sbp_mm_hg }}/{{ $m->dbp_mm_hg }}
+                            @elseif($m->label === 'Wt. (lbs.)')
+                                {{ round(floatval($m->numeric_value), 2) }} lbs
+                            @endif
+                        </span>
+                    </div>
+                @endforeach
+            </td>
+        </tr>
+    @endforeach
+    </tbody>
+</table>

+ 2 - 0
resources/views/app/patient/care-month/dashboard.blade.php

@@ -387,6 +387,8 @@
                         </div>
                     </div>
 
+                    @include('app.patient.care-month._matrix')
+
                     <table class="table table-striped table-sm table-bordered mt-2 mb-0">
                         <thead>
                         <tr>