Эх сурвалжийг харах

Care month single - cm entries list update

Vijayakrishnan 3 жил өмнө
parent
commit
8e4e10c367

+ 4 - 0
app/Models/CareMonthEntry.php

@@ -11,4 +11,8 @@ class CareMonthEntry extends Model
     public function careMonth() {
         return $this->belongsTo(CareMonth::class, 'care_month_id', 'id');
     }
+
+    public function pro() {
+        return $this->hasOne(Pro::class, 'id', 'pro_id');
+    }
 }

+ 8 - 4
app/Models/Client.php

@@ -752,7 +752,7 @@ class Client extends Model
         return $notes;
     }
 
-    public function cmMeasurementsMatrix($_careMonth = null) {
+    public function cmMeasurementsMatrix($_careMonth, $pro = null) {
 
         $days = [];
 
@@ -799,9 +799,13 @@ ORDER BY m.ts DESC
             // get existing entries for listing
             $match->entries = CareMonthEntry::where('care_month_id', $match->care_month_id)
                 ->where('is_removed', false)
-                ->where('effective_date', $match->dateYMD)
-                ->orderBy('created_at')
-                ->get();
+                ->where('effective_date', $match->dateYMD);
+
+            if(!!$pro) {
+                $match->entries = $match->entries->where('pro_id', $pro->id);
+            }
+
+            $match->entries = $match->entries->orderBy('created_at')->get();
 
             if(!isset($days[$match->date])) {
                 $days[$match->date] = [];

+ 8 - 2
resources/views/app/patient/care-month/_matrix.blade.php

@@ -1,5 +1,5 @@
 <?php
-$days = $patient->cmMeasurementsMatrix($careMonth);
+$days = $patient->cmMeasurementsMatrix($careMonth, ($pro->pro_type === 'ADMIN' ? null : $pro));
 
 $performerRole = false;
 if ($pro->pro_type === 'ADMIN') {
@@ -326,9 +326,15 @@ foreach ($days as $k => $day) {
                     @foreach($m->entries as $entry)
                         <div class="my-1 d-flex align-items-baseline flex-nowrap">
                             <b class="mr-2">{{round($entry->time_in_seconds / 60)}}m</b>
-                            <span class="text-secondary mr-2 text-nowrap text-sm">({{date('h:i a', strtotime($entry->created_at))}})</span>
+                            <span class="text-secondary mr-2 text-nowrap text-sm">({{friendly_date_time($entry->created_at)}})</span>
                             <span class="text-secondary inline-html-container flex-grow-1">{!! $entry->content_text !!}</span>
                         </div>
+                        @if($pro->pro_type === 'ADMIN')
+                            <div class="mt-1">
+                                <span class="text-secondary">Pro: </span>
+                                {{$entry->pro ? $entry->pro->displayName() : '-'}}
+                            </div>
+                        @endif
                     @endforeach
                     @if($performerRole === 'MCP' || $performerRole === 'NON-HCP')
                         <div moe large relative>