瀏覽代碼

Merge remote-tracking branch 'origin/optimization' into optimization

= 1 年之前
父節點
當前提交
f9895fd46a

+ 2 - 1
app/Http/Controllers/AdminController.php

@@ -34,6 +34,7 @@ use Illuminate\Support\Facades\Http;
 use PDF;
 use Illuminate\Support\Facades\Schema;
 use App\Models\AdminPatient;
+use App\Models\SupplyOrderView;
 
 class AdminController extends Controller
 {
@@ -553,7 +554,7 @@ class AdminController extends Controller
 
     public function supply_orders(Request $request)
     {
-        $supplyOrders = SupplyOrder::paginate(5);
+        $supplyOrders = SupplyOrderView::paginate(5);
         return view('app.mcp.supply_orders', compact('supplyOrders'));
     }
 

+ 3 - 2
app/Http/Controllers/McpController.php

@@ -35,6 +35,7 @@ use App\Models\ClientProAccess;
 use Illuminate\Support\Facades\Http;
 use PDF;
 use App\Models\McpPatient;
+use App\Models\SupplyOrderView;
 
 class McpController extends Controller
 {
@@ -257,7 +258,7 @@ class McpController extends Controller
     public function supply_orders(Request $request)
     {
         $filters = $request->all();
-        $supplyOrders = SupplyOrder::select('supply_order.*')->where('supply_order.signed_by_pro_id', $this->performer->pro->id);
+        $supplyOrders = SupplyOrderView::where('signed_by_pro_id', $this->performer->pro->id);
         $this->filterMultiQuery($request, $supplyOrders, 'created_at', 'date_category', 'date_value_1', 'date_value_2');
         $status = $request->get('status');
         if($status){
@@ -268,7 +269,7 @@ class McpController extends Controller
             }elseif($status == 'CANCELLED'){
                 $supplyOrders = $supplyOrders->where('is_cancelled', true);
             }else{
-             $supplyOrders = $supplyOrders->join('shipment', 'shipment.id', '=', 'supply_order.shipment_id')->where('shipment.status', $status);
+             $supplyOrders = $supplyOrders->where('shipment_status', $status);
             }
 
         }

+ 3 - 2
app/Http/Controllers/NoteController.php

@@ -20,6 +20,7 @@ use App\Models\Section;
 use App\Models\SectionTemplate;
 use App\Models\Segment;
 use App\Models\SegmentTemplate;
+use App\Models\SupplyOrderView;
 use Illuminate\Support\Facades\DB;
 
 class NoteController extends Controller
@@ -73,13 +74,13 @@ class NoteController extends Controller
         }
 
         // load supplyOrders created on note->effective_date for patient
-        $supplyOrdersOnNote = SupplyOrder::where('client_id', $patient->id)
+        $supplyOrdersOnNote = SupplyOrderView::where('client_id', $patient->id)
             ->where('is_cancelled', false)
             ->where('note_id', $note->id)
             ->get();
 
         // other open supplyOrders as of today
-        $otherOpenSupplyOrders = SupplyOrder::where('client_id', $patient->id)
+        $otherOpenSupplyOrders = SupplyOrderView::where('client_id', $patient->id)
             ->where('is_cancelled', false)
             ->where('note_id', '<>', $note->id)
             ->get();

+ 3 - 1
app/Http/Controllers/PatientController.php

@@ -8,6 +8,7 @@ use App\Models\CareMonth;
 use App\Models\Client;
 use App\Models\ClientBDTDevice;
 use App\Models\ClientInfoLine;
+use App\Models\ClientMemoView;
 use App\Models\ClientPrimaryCoverage;
 use App\Models\ClientProAccess;
 use App\Models\Company;
@@ -112,7 +113,8 @@ class PatientController extends Controller
             ->where('is_removed', false)
             ->orderBy('content_text', 'asc')
             ->get();
-        $clientMemos = $patient->memos;
+
+        $clientMemos = ClientMemoView::where('client_id', $patient->id)->where('is_cancelled', false)->orderBy('created_at', 'DESC')->get();
 
         $shortCutsObject = [];
         foreach ($this->pro->allShortcuts() as $shortcut) {

+ 15 - 0
app/Models/ClientMemoView.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Relations\HasMany;
+use Illuminate\Database\Eloquent\Relations\HasOne;
+
+class ClientMemoView extends Model
+{
+    protected $table = 'client_memo_view';
+
+    public function updates(): HasMany{
+        return $this->hasMany(ClientMemoUpdate::class, 'client_memo_id', 'id')->orderBy('created_at', 'DESC');
+    }
+}

+ 10 - 0
app/Models/SupplyOrderView.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App\Models;
+
+# use Illuminate\Database\Eloquent\Model;
+
+class SupplyOrderView extends Model
+{
+    protected $table = 'supply_order_view';
+}

+ 3 - 3
resources/views/app/mcp/supply_orders.blade.php

@@ -30,14 +30,14 @@
                     @foreach($supplyOrders as $supplyOrder)
                     <tr>
                         <td>{{ friendlier_date_time($supplyOrder->created_at)}}</td>
-                        <td>{{ $supplyOrder->client->displayName() }} -</td>
-                        <td>{{ $supplyOrder->product->title }}</td>
+                        <td>{{ $supplyOrder->client_display_name }} </td>
+                        <td>{{ $supplyOrder->product_title }}</td>
                         <td style="width: 300px;">{{ $supplyOrder->reason }}</td>
                         <td>{{ $supplyOrder->is_cancelled ? 'Yes' : 'No' }}</td>
                         <td class="px-2">
                             @if($supplyOrder->shipment_id)
                             <i class="fa fa-building"></i>
-                            {{$supplyOrder->shipment->status ? $supplyOrder->shipment->status : 'CREATED'}}
+                            {{$supplyOrder->shipment_status ? $supplyOrder->shipment_status : 'CREATED'}}
                             @elseif($supplyOrder->is_cleared_for_shipment)
                             <span class="text-info">
                                 <i class="fa fa-user-nurse"></i>

+ 1 - 120
resources/views/app/patient/note/dashboard.blade.php

@@ -1085,126 +1085,7 @@ use App\Models\Handout;
                 </div>
 
                 <div class="p-3 border-bottom screen-only" data-non-segment-section="Supply Orders Summary">
-                    <div class="">
-                        <div class="d-flex align-items-center mb-2">
-                            <p class="font-weight-bold text-secondary m-0 font-size-14">Supply Orders Summary</p>
-                            <span class="mx-2 text-secondary screen-only">|</span>
-                            <a native target="_blank"
-                               class="screen-only"
-                               open-in-stag-popup
-                               update-parent
-                               mc-initer="patient-supply-orders"
-                               title="{{$patient->displayName()}} - Supply Orders"
-                               popup-style="medium"
-                               href="/patients/view/{{$patient->uid}}/supply-orders?popupmode=1&note-uid={{$note->uid}}&filter=active">
-                                Manage Supply Orders
-                            </a>
-                        </div>
-                        <div class="p-3 border">
-
-                            <p class="font-weight-bold text-secondary mb-2 mr-2">Associated with this note</p>
-                            <div>
-                                @if($supplyOrdersOnNote && count($supplyOrdersOnNote))
-                                    <table class="table table-sm table-bordered mb-0 bg-white">
-                                        <thead>
-                                        <tr class="bg-light">
-                                            <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Title</div></th>
-                                            <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Reason</div></th>
-                                            <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Created At</div></th>
-                                            <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Pro Signed?</div></th>
-                                            <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Cancelled?</div></th>
-                                            <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Shipment</div></th>
-                                        </tr>
-                                        </thead>
-                                        <tbody>
-                                        @foreach($supplyOrdersOnNote as $iSupplyOrder)
-                                            <tr class="">
-                                                <td class="px-2">
-                                                    {{ $iSupplyOrder->product->title }}
-                                                </td>
-                                                <td class="px-2">{{ $iSupplyOrder->reason }}</td>
-                                                <td class="px-2">{{ friendlier_date($iSupplyOrder->created_at) }} <i class="fas fa-info-circle text-primary" data-toggle="tooltip" data-placement="top" data-html="true" title="Created at: {{ friendlier_date_time($iSupplyOrder->created_at) }} By: {{ $iSupplyOrder->createdByPro ? $iSupplyOrder->createdByPro->displayName() : ''}}"></i> </td>
-                                                <td class="px-2">
-                                                    {{ $iSupplyOrder->is_signed_by_pro ? $iSupplyOrder->signedPro->displayName() : '-' }}
-                                                    <i class="fas fa-info-circle text-primary" data-toggle="tooltip" data-placement="top" data-html="true" title="Signed at: {{ friendlier_date_time($iSupplyOrder->pro_signed_at) }}"></i>
-                                                </td>
-                                                <td class="px-2">{{ $iSupplyOrder->is_cancelled ? 'Yes' : 'No' }}</td>
-                                                <td class="px-2">
-                                                    @if($iSupplyOrder->shipment_id)
-                                                        <i class="fa fa-building"></i>
-                                                        {{ucwords(strtolower($iSupplyOrder->shipment->status ? $iSupplyOrder->shipment->status : 'CREATED'))}}
-                                                    @elseif($iSupplyOrder->is_cleared_for_shipment)
-                                                        <span class="text-info">
-                                                        <i class="fa fa-user-nurse"></i>
-                                                        Cleared for shipment
-                                                    </span>
-                                                    @else
-                                                        <span class="text-warning-mellow">
-                                                        <i class="fa fa-user-nurse"></i>
-                                                        Not cleared for shipment
-                                                    </span>
-                                                    @endif
-                                                </td>
-                                            </tr>
-                                        @endforeach
-                                        </tbody>
-                                    </table>
-                                @else
-                                    <div class="text-secondary">-</div>
-                                @endif
-                            </div>
-
-                            <hr class="my-2">
-
-                            <p class="font-weight-bold text-secondary mb-2 mr-2">Others as of {{friendlier_date(date('Y-m-d'))}}</p>
-                            @if($otherOpenSupplyOrders && count($otherOpenSupplyOrders))
-                                <table class="table table-sm table-bordered mb-0 bg-white">
-                                    <thead>
-                                    <tr class="bg-light">
-                                        <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Title</div></th>
-                                        <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Memo</div></th>
-                                        <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Created At</div></th>
-                                        <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Pro Signed?</div></th>
-                                        <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Cancelled?</div></th>
-                                        <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Shipment</div></th>
-                                    </tr>
-                                    </thead>
-                                    <tbody>
-                                    @foreach($otherOpenSupplyOrders as $iSupplyOrder)
-                                        <tr class="">
-                                            <td class="px-2">
-                                                {{ $iSupplyOrder->product->title }}
-                                            </td>
-                                            <td class="px-2">{{ $iSupplyOrder->reason }}</td>
-                                            <td class="px-2">{{ friendlier_date_time($iSupplyOrder->created_at) }}</td>
-                                            <td class="px-2">{{ $iSupplyOrder->is_signed_by_pro ? $iSupplyOrder->signedPro->displayName() : '-' }}</td>
-                                            <td class="px-2">{{ $iSupplyOrder->is_cancelled ? 'Yes' : 'No' }}</td>
-                                            <td class="px-2">
-                                                @if($iSupplyOrder->shipment_id)
-                                                    <i class="fa fa-building"></i>
-                                                    {{ ucwords(strtolower($iSupplyOrder->shipment->status ? $iSupplyOrder->shipment->status : 'CREATED'))}}
-                                                @elseif($iSupplyOrder->is_cleared_for_shipment)
-                                                    <span class="text-info">
-                                                        <i class="fa fa-user-nurse"></i>
-                                                        Cleared for shipment
-                                                    </span>
-                                                @else
-                                                    <span class="text-warning-mellow">
-                                                        <i class="fa fa-user-nurse"></i>
-                                                        Not cleared for shipment
-                                                    </span>
-                                                @endif
-                                            </td>
-                                        </tr>
-                                    @endforeach
-                                    </tbody>
-                                </table>
-                            @else
-                                <div class="text-secondary">-</div>
-                            @endif
-
-                        </div>
-                    </div>
+                    @include('app.patient.note.partials.note-supply-orders')
                 </div>
 
                 {{--@if($patient->currentCareMonth())

+ 147 - 0
resources/views/app/patient/note/partials/note-supply-orders.blade.php

@@ -0,0 +1,147 @@
+<div class="">
+    <div class="d-flex align-items-center mb-2">
+        <p class="font-weight-bold text-secondary m-0 font-size-14">Supply Orders Summary</p>
+        <span class="mx-2 text-secondary screen-only">|</span>
+        <a native target="_blank" class="screen-only" open-in-stag-popup update-parent mc-initer="patient-supply-orders"
+            title="{{ $patient->displayName() }} - Supply Orders" popup-style="medium"
+            href="/patients/view/{{ $patient->uid }}/supply-orders?popupmode=1&note-uid={{ $note->uid }}&filter=active">
+            Manage Supply Orders
+        </a>
+    </div>
+    <div class="p-3 border">
+
+        <p class="font-weight-bold text-secondary mb-2 mr-2">Associated with this note</p>
+        <div>
+            @if ($supplyOrdersOnNote && count($supplyOrdersOnNote))
+                <table class="table table-sm table-bordered mb-0 bg-white">
+                    <thead>
+                        <tr class="bg-light">
+                            <th class="px-2 text-nowrap text-secondary border-bottom-0">
+                                <div class="text-ellipsis">Title</div>
+                            </th>
+                            <th class="px-2 text-nowrap text-secondary border-bottom-0">
+                                <div class="text-ellipsis">Reason</div>
+                            </th>
+                            <th class="px-2 text-nowrap text-secondary border-bottom-0">
+                                <div class="text-ellipsis">Created At</div>
+                            </th>
+                            <th class="px-2 text-nowrap text-secondary border-bottom-0">
+                                <div class="text-ellipsis">Pro Signed?</div>
+                            </th>
+                            <th class="px-2 text-nowrap text-secondary border-bottom-0">
+                                <div class="text-ellipsis">Cancelled?</div>
+                            </th>
+                            <th class="px-2 text-nowrap text-secondary border-bottom-0">
+                                <div class="text-ellipsis">Shipment</div>
+                            </th>
+                        </tr>
+                    </thead>
+                    <tbody>
+                        @foreach ($supplyOrdersOnNote as $iSupplyOrder)
+                            <tr class="">
+                                <td class="px-2">
+                                    {{ $iSupplyOrder->product_title }}
+                                </td>
+                                <td class="px-2">{{ $iSupplyOrder->reason }}</td>
+                                <td class="px-2">{{ friendlier_date($iSupplyOrder->created_at) }} <i
+                                        class="fas fa-info-circle text-primary" data-toggle="tooltip"
+                                        data-placement="top" data-html="true"
+                                        title="Created at: {{ friendlier_date_time($iSupplyOrder->created_at) }} By: {{ $iSupplyOrder->creator_pro_display_name ? $iSupplyOrder->creator_pro_display_name : '' }}"></i>
+                                </td>
+                                <td class="px-2">
+                                    {{ $iSupplyOrder->signed_by_pro_display_name ? $iSupplyOrder->signed_by_pro_display_name : '-' }}
+                                    <i class="fas fa-info-circle text-primary" data-toggle="tooltip"
+                                        data-placement="top" data-html="true"
+                                        title="Signed at: {{ friendlier_date_time($iSupplyOrder->pro_signed_at) }}"></i>
+                                </td>
+                                <td class="px-2">{{ $iSupplyOrder->is_cancelled ? 'Yes' : 'No' }}</td>
+                                <td class="px-2">
+                                    @if ($iSupplyOrder->shipment_id)
+                                        <i class="fa fa-building"></i>
+                                        {{ ucwords(strtolower($iSupplyOrder->shipment_status ? $iSupplyOrder->shipment_status : 'CREATED')) }}
+                                    @elseif($iSupplyOrder->is_cleared_for_shipment)
+                                        <span class="text-info">
+                                            <i class="fa fa-user-nurse"></i>
+                                            Cleared for shipment
+                                        </span>
+                                    @else
+                                        <span class="text-warning-mellow">
+                                            <i class="fa fa-user-nurse"></i>
+                                            Not cleared for shipment
+                                        </span>
+                                    @endif
+                                </td>
+                            </tr>
+                        @endforeach
+                    </tbody>
+                </table>
+            @else
+                <div class="text-secondary">-</div>
+            @endif
+        </div>
+
+        <hr class="my-2">
+
+        <p class="font-weight-bold text-secondary mb-2 mr-2">Others as of {{ friendlier_date(date('Y-m-d')) }}</p>
+        @if ($otherOpenSupplyOrders && count($otherOpenSupplyOrders))
+            <table class="table table-sm table-bordered mb-0 bg-white">
+                <thead>
+                    <tr class="bg-light">
+                        <th class="px-2 text-nowrap text-secondary border-bottom-0">
+                            <div class="text-ellipsis">Title</div>
+                        </th>
+                        <th class="px-2 text-nowrap text-secondary border-bottom-0">
+                            <div class="text-ellipsis">Memo</div>
+                        </th>
+                        <th class="px-2 text-nowrap text-secondary border-bottom-0">
+                            <div class="text-ellipsis">Created At</div>
+                        </th>
+                        <th class="px-2 text-nowrap text-secondary border-bottom-0">
+                            <div class="text-ellipsis">Pro Signed?</div>
+                        </th>
+                        <th class="px-2 text-nowrap text-secondary border-bottom-0">
+                            <div class="text-ellipsis">Cancelled?</div>
+                        </th>
+                        <th class="px-2 text-nowrap text-secondary border-bottom-0">
+                            <div class="text-ellipsis">Shipment</div>
+                        </th>
+                    </tr>
+                </thead>
+                <tbody>
+                    @foreach ($otherOpenSupplyOrders as $iSupplyOrder)
+                        <tr class="">
+                            <td class="px-2">
+                                {{ $iSupplyOrder->product_title }}
+                            </td>
+                            <td class="px-2">{{ $iSupplyOrder->reason }}</td>
+                            <td class="px-2">{{ friendlier_date_time($iSupplyOrder->created_at) }}</td>
+                            <td class="px-2">
+                                {{ $iSupplyOrder->signed_by_pro_display_name ? $iSupplyOrder->signed_by_pro_display_name : '-' }}
+                            </td>
+                            <td class="px-2">{{ $iSupplyOrder->is_cancelled ? 'Yes' : 'No' }}</td>
+                            <td class="px-2">
+                                @if ($iSupplyOrder->shipment_id)
+                                    <i class="fa fa-building"></i>
+                                    {{ ucwords(strtolower($iSupplyOrder->shipment_status ? $iSupplyOrder->shipment_status : 'CREATED')) }}
+                                @elseif($iSupplyOrder->is_cleared_for_shipment)
+                                    <span class="text-info">
+                                        <i class="fa fa-user-nurse"></i>
+                                        Cleared for shipment
+                                    </span>
+                                @else
+                                    <span class="text-warning-mellow">
+                                        <i class="fa fa-user-nurse"></i>
+                                        Not cleared for shipment
+                                    </span>
+                                @endif
+                            </td>
+                        </tr>
+                    @endforeach
+                </tbody>
+            </table>
+        @else
+            <div class="text-secondary">-</div>
+        @endif
+
+    </div>
+</div>

+ 25 - 0
resources/views/app/patient/partials/client-memo-update-history.blade.php

@@ -0,0 +1,25 @@
+<div moe relative bottom class="mr-2">
+    <a start show><i class="fa fa-history"></i></a>
+    <div action="" url right bottom>
+        <table class="table table-condensed table-striped table-sm">
+            <thead>
+                <th>Category</th>
+                <th>Summary</th>
+                <th>Created</th>
+
+            </thead>
+            <tbody>
+                @foreach ($memo->updates as $update)
+                    <tr>
+                        <td>{{ $update->category }}</td>
+                        <td>{{ $update->content }}</td>
+                        <td><strong>{{ $update->createdBy->proname_first }}
+                                {{ $update->createdBy->pro->name_last }}</strong><br />{{ friendly_date_time($update->created_at) }}
+                        </td>
+
+                    </tr>
+                @endforeach
+            </tbody>
+        </table>
+    </div>
+</div>

+ 3 - 28
resources/views/app/patient/partials/client-memos.blade.php

@@ -51,7 +51,6 @@
                 </thead>
                 <tbody>
                     @foreach ($clientMemos as $memo)
-                        <?php $memoCreatedBy = $memo->createdBy->pro; ?>
                         @if (!$memo->is_admin_only || ($memo->is_admin_only && $isProTypeAdmin))
                             <tr>
                                 <td class="text-nowrap">{{ $memo->category }}</td>
@@ -59,7 +58,7 @@
                                     <pre class="m-0 break-spaces">{{ $memo->content }}</pre>
                                 </td>
                                 <td class="text-nowrap">
-                                    <strong>{{ $memoCreatedBy->displayName() }}</strong><br />
+                                    <strong>{{ $memo->creator_pro_display_name }}</strong><br />
                                     {{ friendly_date_time($memo->created_at) }}
                                 </td>
                                 @if ($isProTypeAdmin)
@@ -75,38 +74,14 @@
                                     @if ($memo->mcp_stamp_id)
                                         <span class="text-success">YES <i class="fas fa-info-circle c-pointer"
                                                 data-toggle="tooltip" data-placement="bottom"
-                                                title="{{ friendly_date_time($memo->stamp->created_at) }}"></i></span>
+                                                title="{{ friendly_date_time($memo->stamp_created_at) }}"></i></span>
                                     @else
                                         <span class="text-secondary">NO</span>
                                     @endif
                                 </td>
                                 <td class="text-center delete-column">
                                     @if ($isProTypeAdmin)
-                                        <div moe relative bottom class="mr-2">
-                                            <a start show><i class="fa fa-history"></i></a>
-                                            <div action="" url right bottom>
-                                                <table class="table table-condensed table-striped table-sm">
-                                                    <thead>
-                                                        <th>Category</th>
-                                                        <th>Summary</th>
-                                                        <th>Created</th>
-
-                                                    </thead>
-                                                    <tbody>
-                                                        @foreach ($memo->updates as $update)
-                                                            <tr>
-                                                                <td>{{ $update->category }}</td>
-                                                                <td>{{ $update->content }}</td>
-                                                                <td><strong>{{ $update->createdBy->proname_first }}
-                                                                        {{ $update->createdBy->pro->name_last }}</strong><br />{{ friendly_date_time($update->created_at) }}
-                                                                </td>
-
-                                                            </tr>
-                                                        @endforeach
-                                                    </tbody>
-                                                </table>
-                                            </div>
-                                        </div>
+                                        {{-- @include('app.patient.partials.client-memo-update-history') --}}
                                     @endif
                                     <div moe wide relative class="mr-2">
                                         <a class="on-hover-opaque" start show title="Edit">