Explorar el Código

Patients list updates, central accessible-patients method

Vijayakrishnan hace 4 años
padre
commit
436994f548
Se han modificado 2 ficheros con 44 adiciones y 18 borrados
  1. 13 11
      app/Http/Controllers/HomeController.php
  2. 31 7
      resources/views/app/patients.blade.php

+ 13 - 11
app/Http/Controllers/HomeController.php

@@ -330,17 +330,19 @@ class HomeController extends Controller
         switch ($filter) {
             case 'not-yet-seen':
                 $query = $query
-                    ->where(function ($query) use ($performer) {     // own patient and primary OB visit pending
-                        $query->where('mcp_pro_id', $performer->pro->id)
-                            ->where('has_mcp_done_onboarding_visit', '!=', 'YES');
-                    })
-                    ->orWhere(function ($query) {   // mcp of any client program and program OB pending
-                        $query->where(function ($_query) {
-                            $_query->select(DB::raw('COUNT(id)'))
-                                ->from('client_program')
-                                ->whereColumn('client_id', 'client.id')
-                                ->where('has_mcp_done_onboarding_visit', '!=', 'YES');
-                        }, '>=', 1);
+                    ->where(function ($query) use ($performer) {
+                        $query
+                            ->where(function ($query) use ($performer) {     // own patient and primary OB visit pending
+                                $query->where('mcp_pro_id', $performer->pro->id)
+                                    ->where('has_mcp_done_onboarding_visit', '<>', 'YES');
+                            })
+                            ->orWhere(function ($query) use ($performer) {   // mcp of any client program and program OB pending
+                                $query->select(DB::raw('COUNT(id)'))
+                                    ->from('client_program')
+                                    ->whereColumn('client_id', 'client.id')
+                                    ->where('mcp_pro_id', $performer->pro->id)
+                                    ->where('has_mcp_done_onboarding_visit', '<>', 'YES');
+                            }, '>=', 1);
                     });
                 break;
 

+ 31 - 7
resources/views/app/patients.blade.php

@@ -2,6 +2,27 @@
 
 @section('content')
 
+    <?php
+    $showProgramsColumn = false;
+    foreach($patients as $patient) {
+        if(count($patient->clientPrograms)) {
+            if($pro->pro_type === 'ADMIN') {
+                $showProgramsColumn = true;
+                break;
+            }
+            else {
+                foreach($patient->clientPrograms as $clientProgram) {
+                    if(in_array($pro->id, [$clientProgram->mcp_pro_id, $clientProgram->manager_pro_id])) {
+                        $showProgramsColumn = true;
+                        break;
+                    }
+                }
+                if($showProgramsColumn) break;
+            }
+        }
+    }
+    ?>
+
     <div class="p-3 mcp-theme-1">
     <div class="card">
 
@@ -19,11 +40,11 @@
             <table class="table table-condensed p-0 m-0">
                 <thead class="bg-light">
                 <tr>
-                    <th></th>
+                    <th class="border-0"></th>
                     <th class="px-3 border-0">#</th>
                     <th class="border-0">Patient</th>
                     <th class="border-0">Created At</th>
-                    <th class="border-0">Program(s)</th>
+                    @if($showProgramsColumn)<th class="border-0">Program(s)</th>@endif
                     <th class="border-0">MCN</th>
                     <th class="border-0">PCP</th>
                     {{--<th class="border-0">RMM</th>--}}
@@ -47,12 +68,16 @@
                             <div>{{ friendly_date_time($patient->dob, false) }}{{ $patient->sex === 'M' ? ', Male' : ($patient->sex === ', F' ? 'Female' : '') }}</div>
                         </td>
                         <td>{{friendly_date_time_short_with_tz($patient->created_at, true, 'EASTERN')}}</td>
+                        @if($showProgramsColumn)
                         <td>
                             <?php $programNumber = 0; ?>
                             @foreach($patient->clientPrograms as $clientProgram)
                                 <?php
-                                $program = $clientProgram->program;
-                                $programNumber++;
+                                    if($pro->pro_type === 'ADMIN' ||
+                                        in_array($pro->id, [$clientProgram->mcp_pro_id, $clientProgram->manager_pro_id])
+                                    ) {
+                                        $program = $clientProgram->program;
+                                        $programNumber++;
                                 ?>
                                 <div class="mb-1 text-nowrap">
                                     {{ $programNumber }}. {{ $program->title }}
@@ -62,11 +87,10 @@
                                         <span title="Onboarding Complete" class="ml-1 text-secondary"><i class="fa fa-check"></i></span>
                                     @endif
                                 </div>
+                                <?php } ?>
                             @endforeach
-                            @if(!count($patient->clientPrograms))
-                                -
-                            @endif
                         </td>
+                        @endif
                         <td>
                             @if($patient->was_medicare_validation_successful && $patient->is_part_b_primary == 'YES')
                             Covered <span style="color:green"><i class="fa fa-check-circle"></i></span>