Преглед изворни кода

Bills pending sign logic fixes

Vijayakrishnan пре 3 година
родитељ
комит
c1af795513

+ 79 - 43
app/Http/Controllers/PracticeManagementController.php

@@ -478,67 +478,103 @@ OFFSET {$offset} LIMIT {$perPage}
     public function bills(Request $request, $filter = '')
     {
         $proID = $this->performer()->pro->id;
-        $query = Bill::where('is_cancelled', false)->where('bill_service_type', '<>', 'CARE_MONTH');
+        $isAdmin = $this->performer()->pro->pro_type === 'ADMIN';
+        $query = Bill::where('is_cancelled', false)->where('bill_service_type', 'NOTE');
         switch ($filter) {
             case 'not-yet-signed':
                 $query = $query
-                    ->where(function ($q) use ($proID) {
-                        $q->where(function ($q2) use ($proID) {
-                            $q2->where('hcp_pro_id', $proID)->where('is_signed_by_hcp', false);
+                    ->where(function ($q) use ($proID, $isAdmin) {
+                        $q->where(function ($q2) use ($proID, $isAdmin) {
+                            $q2->where('is_signed_by_hcp', false);
+                            if(!$isAdmin) {
+                                $q2->where('hcp_pro_id', $proID);
+                            }
+                        })/*
+                        ->orWhere(function ($q2) use ($proID, $isAdmin) {
+                            $q2->where('is_signed_by_cm', false);
+                            if(!$isAdmin) {
+                                $q2->where('cm_pro_id', $proID);
+                            }
                         })
-                            ->orWhere(function ($q2) use ($proID) {
-                                $q2->where('cm_pro_id', $proID)->where('is_signed_by_cm', false);
-                            })
-                            ->orWhere(function ($q2) use ($proID) {
-                                $q2->where('rme_pro_id', $proID)->where('is_signed_by_rme', false);
-                            })
-                            ->orWhere(function ($q2) use ($proID) {
-                                $q2->where('rmm_pro_id', $proID)->where('is_signed_by_rmm', false);
-                            })
-                            ->orWhere(function ($q2) use ($proID) {
-                                $q2->where('generic_pro_id', $proID)->where('is_signed_by_generic_pro', false);
-                            });
+                        ->orWhere(function ($q2) use ($proID, $isAdmin) {
+                            $q2->where('is_signed_by_rme', false);
+                            if(!$isAdmin) {
+                                $q2->where('rme_pro_id', $proID);
+                            }
+                        })
+                        ->orWhere(function ($q2) use ($proID, $isAdmin) {
+                            $q2->where('is_signed_by_rmm', false);
+                            if(!$isAdmin) {
+                                $q2->where('rmm_pro_id', $proID);
+                            }
+                        })
+                        ->orWhere(function ($q2) use ($proID, $isAdmin) {
+                            $q2->where('is_signed_by_generic_pro', false);
+                            if(!$isAdmin) {
+                                $q2->where('generic_pro_id', $proID);
+                            }
+                        })*/;
                     });
                 break;
 
             case 'previous':
                 $query = $query
-                    ->where(function ($q) use ($proID) {
-                        $q->where(function ($q2) use ($proID) {
-                            $q2->where('hcp_pro_id', $proID)->where('is_signed_by_hcp', true);
-                        })
-                            ->orWhere(function ($q2) use ($proID) {
-                                $q2->where('cm_pro_id', $proID)->where('is_signed_by_cm', true);
+                    ->where(function ($q) use ($proID, $isAdmin) {
+                        $q->where(function ($q2) use ($proID, $isAdmin) {
+                            $q2->where('is_signed_by_hcp', true);
+                            if(!$isAdmin) {
+                                $q2->where('hcp_pro_id', $proID);
+                            }
+                        })/*
+                            ->orWhere(function ($q2) use ($proID, $isAdmin) {
+                                $q2->where('is_signed_by_cm', true);
+                                if(!$isAdmin) {
+                                    $q2->where('cm_pro_id', $proID);
+                                }
+                            })
+                            ->orWhere(function ($q2) use ($proID, $isAdmin) {
+                                $q2->where('is_signed_by_rme', true);
+                                if(!$isAdmin) {
+                                    $q2->where('rme_pro_id', $proID);
+                                }
                             })
-                            ->orWhere(function ($q2) use ($proID) {
-                                $q2->where('rme_pro_id', $proID)->where('is_signed_by_rme', true);
+                            ->orWhere(function ($q2) use ($proID, $isAdmin) {
+                                $q2->where('is_signed_by_rmm', true);
+                                if(!$isAdmin) {
+                                    $q2->where('rmm_pro_id', $proID);
+                                }
                             })
-                            ->orWhere(function ($q2) use ($proID) {
-                                $q2->where('rmm_pro_id', $proID)->where('is_signed_by_rmm', true);
-                            });
+                            ->orWhere(function ($q2) use ($proID, $isAdmin) {
+                                $q2->where('is_signed_by_generic_pro', true);
+                                if(!$isAdmin) {
+                                    $q2->where('generic_pro_id', $proID);
+                                }
+                            })*/;
                     });
                 break;
 
             // more cases can be added as needed
             default:
-                $query = $query
-                    ->where(function ($q) use ($proID) {
-                        $q->where(function ($q2) use ($proID) {
-                            $q2->where('hcp_pro_id', $proID);
-                        })
-                            ->orWhere(function ($q2) use ($proID) {
-                                $q2->where('cm_pro_id', $proID);
-                            })
-                            ->orWhere(function ($q2) use ($proID) {
-                                $q2->where('rme_pro_id', $proID);
-                            })
-                            ->orWhere(function ($q2) use ($proID) {
-                                $q2->where('rmm_pro_id', $proID);
-                            });
-                    });
+                if(!$isAdmin) {
+                    $query = $query
+                        ->where(function ($q) use ($proID) {
+                            $q->where(function ($q2) use ($proID) {
+                                $q2->where('hcp_pro_id', $proID);
+                            })/*
+                                ->orWhere(function ($q2) use ($proID) {
+                                    $q2->where('cm_pro_id', $proID);
+                                })
+                                ->orWhere(function ($q2) use ($proID) {
+                                    $q2->where('rme_pro_id', $proID);
+                                })
+                                ->orWhere(function ($q2) use ($proID) {
+                                    $q2->where('rmm_pro_id', $proID);
+                                })*/;
+                        });
+                }
                 break;
         }
-        $bills = $query->orderBy('created_at', 'desc')->get();
+        $bills = $query->orderBy('created_at', 'desc')->paginate(50);
         return view('app.practice-management.bills', compact('bills', 'filter'));
     }
 

+ 17 - 7
resources/views/app/practice-management/bills.blade.php

@@ -23,6 +23,7 @@
                 <tr>
                     <th class="px-3 border-0">Created</th>
                     <th class="border-0">Patient</th>
+                    <th class="border-0">Pro</th>
                     <th class="border-0 w-50">Context</th>
                     <th class="border-0">Role</th>
                     <th class="border-0">Amount</th>
@@ -39,6 +40,11 @@
                             <a href="/patients/view/{{ $bill->client->uid }}">{{ $bill->client->displayName() }}</a>
                             @endif
                         </td>
+                        <td class="">
+                            @if($bill->hcp)
+                                {{ $bill->hcp->displayName() }}
+                            @endif
+                        </td>
                         <td class="stag-no-wrap-td">
                             @if($bill->careMonth)
                                 <b>{{ $bill->code }}</b>
@@ -61,15 +67,15 @@
                             <?php
                             $roles = [];
                             if($bill->hcp_pro_id === $pro->id) $roles[] = 'HCP';
-                            if($bill->cm_pro_id === $pro->id) $roles[] = 'CM';
+                            /*if($bill->cm_pro_id === $pro->id) $roles[] = 'CM';
                             if($bill->rme_pro_id === $pro->id) $roles[] = 'RME';
-                            if($bill->rmm_pro_id === $pro->id) $roles[] = 'RMM';
+                            if($bill->rmm_pro_id === $pro->id) $roles[] = 'RMM';*/
                             $roles = implode("<br>", $roles);
                             ?>
                             {!! $roles !!}
                         </td>
                         <td>
-                            @if($bill->hcp_pro_id === $pro->id)
+                            @if($pro->pro_type === 'ADMIN' || $bill->hcp_pro_id === $pro->id)
                                 @if($bill->has_hcp_been_paid)
                                     <div>
                                         <span class="text-dark">HCP Received:</span>
@@ -82,7 +88,7 @@
                                     </div>
                                 @endif
                             @endif
-                            @if($bill->cm_pro_id === $pro->id)
+                            {{--@if($pro->pro_type === 'ADMIN' || $bill->cm_pro_id === $pro->id)
                                 @if($bill->has_cm_been_paid)
                                     <div>
                                         <span class="text-dark">CM Received:</span>
@@ -95,7 +101,7 @@
                                     </div>
                                 @endif
                             @endif
-                            @if($bill->rmm_pro_id === $pro->id)
+                            @if($pro->pro_type === 'ADMIN' || $bill->rmm_pro_id === $pro->id)
                                 @if($bill->has_rmm_been_paid)
                                     <div>
                                         <span class="text-dark">RMM Received:</span>
@@ -108,7 +114,7 @@
                                     </div>
                                 @endif
                             @endif
-                            @if($bill->rme_pro_id === $pro->id)
+                            @if($pro->pro_type === 'ADMIN' || $bill->rme_pro_id === $pro->id)
                                 @if($bill->has_rme_been_paid)
                                     <div>
                                         <span class="text-dark">RME Received:</span>
@@ -120,12 +126,16 @@
                                         <span class="font-weight-bold text-dark ml-2">{{ $bill->rme_expected_payment_amount ? '$' . $bill->rme_expected_payment_amount : '-' }}</span>
                                     </div>
                                 @endif
-                            @endif
+                            @endif--}}
                         </td>
                     </tr>
                 @endforeach
                 </tbody>
             </table>
+
+            <div class="mx-3 mt-3">
+                {{$bills->withQueryString()->links()}}
+            </div>
         </div>
     </div>
     </div>