4
0

2 Коммиты b776c7a3d6 ... 9e86d5454d

Автор SHA1 Сообщение Дата
  Vijayakrishnan Krishnan 9e86d5454d Client rm status: list filter fixes 1 неделя назад
  Vijayakrishnan Krishnan 72ad4c7f62 Patient list fixes 1 неделя назад

+ 27 - 10
app/Http/Controllers/AdminController.php

@@ -42,6 +42,9 @@ class AdminController extends Controller
 
     public function patients(Request $request)
     {
+
+        // DB::enableQueryLog();
+
         $filters = $request->all();
         $patients = AdminPatient::whereNull('shadow_pro_id');
 
@@ -304,14 +307,22 @@ class AdminController extends Controller
 
         $insurance = $request->get('insurance');
         if($insurance){
-            if($insurance === 'MEDICARE'){
-                $patients = $patients->whereHas('effectiveClientPrimaryCoverage', function($cpcQuery) {
-                    return $cpcQuery->where('is_partbprimary', '=', 'YES');
-                });
-            }else{
-                $patients = $patients->whereHas('effectiveClientPrimaryCoverage', function($cpcQuery) use ($insurance){
-                    return $cpcQuery->where('commercial_payer_id', '=', $insurance);
-                });
+
+            if(strpos($insurance, '_new_|') === 0){
+                $trimmed = trim(str_replace('_new_|', '', $insurance));
+                $condSql = "EXISTS(SELECT 1 FROM insurance_card WHERE client_id = admin_patient_list.id AND is_active = TRUE AND (carrier_category ILIKE '%{$trimmed}%' OR carrier_name ILIKE '%{$trimmed}%'))";
+                $patients = $patients->whereRaw($condSql);
+            }
+            else {
+                if($insurance === 'MEDICARE'){
+                    $patients = $patients->whereHas('effectiveClientPrimaryCoverage', function($cpcQuery) {
+                        return $cpcQuery->where('is_partbprimary', '=', 'YES');
+                    });
+                }else{
+                    $patients = $patients->whereHas('effectiveClientPrimaryCoverage', function($cpcQuery) use ($insurance) {
+                        return $cpcQuery->where('commercial_payer_id', '=', $insurance);
+                    });
+                }
             }
         }
 
@@ -358,9 +369,15 @@ class AdminController extends Controller
           $patients = $patients->orderByRaw($sortBySQL)->paginate(25);
         }
 
-        $insurances = DB::select('SELECT DISTINCT commercial_payer_name, commercial_payer_id FROM client_primary_coverage WHERE commercial_payer_name IS NOT NULL ORDER BY commercial_payer_name ASC');
+        $oldInsurances = DB::select('SELECT DISTINCT commercial_payer_name, commercial_payer_id FROM client_primary_coverage WHERE commercial_payer_name IS NOT NULL ORDER BY commercial_payer_name ASC');
+
+        $newInsurances = DB::select("select distinct COALESCE(ic.carrier_name, ic.carrier_category) as payer_name from insurance_card ic");
+
+        // $qLog = DB::getQueryLog();
+
+        // dd($qLog);
 
-        return view('app.admin.patients', compact('patients', 'filters', 'insurances'));
+        return view('app.admin.patients', compact('patients', 'filters', 'oldInsurances', 'newInsurances'));
     }
 
     public function partBPatients(Request $request){

+ 6 - 8
app/Http/Controllers/McpController.php

@@ -45,16 +45,14 @@ class McpController extends Controller
         $pro = $this->performer->pro;
         $filters = $request->all();
         $patients = McpPatient::whereNull('shadow_pro_id');
-        
-        //TODO: implement in admin controller 
-        if($pro->pro_type != 'ADMIN'){
-            $patients->where('mcp_pro_id', $pro->id);
-        }
 
-        //Also include the ones given access to:
+        // where I am the mcp or I have access via ClientProAccess
         $proAccessClientIDs = ClientProAccess::where('pro_id', $pro->id)->pluck('client_id')->toArray();
-        $patients = $patients->orWhereIn('id', $proAccessClientIDs);
-        
+        $patients->where(function ($query2) use ($pro, $proAccessClientIDs) {
+            $query2
+                ->where('mcp_pro_id', $pro->id)
+                ->orWhereIn('id', $proAccessClientIDs);
+        });
 
         // filters
         /*

+ 11 - 3
app/Http/Controllers/PracticeManagementController.php

@@ -4650,13 +4650,21 @@ ORDER BY c.name_last, c.name_first
         $pro = $this->performer()->pro;
         if($pro->pro_type !== 'ADMIN') {
             if($pro->is_hcp){
-               $patients = $patients->where('mcp_pro_id', $this->performer()->pro->id);
+                $patients = $patients->where('mcp_pro_id', $this->performer()->pro->id);
             }
             if($pro->is_considered_for_dna){
                 $patients = $patients->where('default_na_pro_id', $this->performer()->pro->id);
-             }
-
+            }
+        }
 
+        if ($request->input('name')) {
+            $name = trim($request->input('name'));
+            if ($name) {
+                $patients = $patients->where(function ($q) use ($name) {
+                    $q->where('name_first', 'ILIKE', '%' . $name . '%')
+                    ->orWhere('name_last', 'ILIKE', '%' . $name . '%');
+                });
+            }
         }
 
         // filters

+ 14 - 1
app/Models/Client.php

@@ -45,6 +45,19 @@ class Client extends Model
         return $this->hasOne(ClientPrimaryCoverage::class, 'id', 'temporary_outsider_new_client_primary_coverage_id');
     }
 
+    /* NEW: insurance_card */
+    public function insuranceCards(){
+        return $this->hasMany(InsuranceCard::class, 'client_id', 'id');
+    }
+    public function getPrimaryInsuranceCard()
+    {
+        return $this->insuranceCards
+            ->where('coverage_order', '=', 'PRIMARY')
+            ->where('is_active', '=', true)
+            ->first();
+    }
+
+
     public function displayName($_flat = true)
     {
         $result = '';
@@ -1082,7 +1095,7 @@ ORDER BY m.ts DESC
         return $this->hasMany(Survey::class, 'entity_uid', 'uid');
     }
 
-    public function insuranceCards() {
+    public function insuranceCardsCustom() {
         $sql = "
 select ic.*,
        (SELECT jsonb_build_object(

+ 1 - 1
resources/views/app/admin/client_ccm_rm_status_filters.blade.php

@@ -185,7 +185,7 @@
 			<label>&nbsp;</label>
 			<div class=" d-flex">
 				<button type="button" v-on:click.prevent="doSubmit()" class="btn btn-primary btn-sm mr-2"><i class="fas fa-filter"></i> Filter</button>
-				<a href="#" v-on:click.prevent="fastLoad('{{route('mcp.patients')}}')" class="btn btn-link btn-sm text-secondary">Clear Filters</a>
+				<a href="#" v-on:click.prevent="fastLoad('{{route('practice-management.client-ccm-rm-status')}}')" class="btn btn-link btn-sm text-secondary">Clear Filters</a>
 			</div>
 		</div>
 	</div>

+ 11 - 4
resources/views/app/admin/patients_filters.blade.php

@@ -198,10 +198,17 @@ use App\Models\Company;
 			<label>Insurance:</label>
 			<select class="form-control"  name="insurance" v-model="filters.insurance">
 				<option value=""></option>
-				<option value="MEDICARE">Medicare (Part B)</option>
-				@foreach($insurances as $insurance)
-				<option value="{{$insurance->commercial_payer_id}}">{{$insurance->commercial_payer_name}}</option>
-				@endforeach
+				<optgroup label="NEW">
+					@foreach($newInsurances as $insurance)
+						<option value="_new_|{{$insurance->payer_name}}">{{$insurance->payer_name}}</option>
+					@endforeach
+				</optgroup>
+				<optgroup label="DEPRECATED">
+					<option value="MEDICARE">*Medicare (Part B)</option>
+					@foreach($oldInsurances as $insurance)
+						<option value="{{$insurance->commercial_payer_id}}">*{{$insurance->commercial_payer_name}}</option>
+					@endforeach
+				</optgroup>
 			</select>
 		</div>
 	</div>

+ 6 - 10
resources/views/app/patient/coverage_column_fast_renderer.blade.php

@@ -35,19 +35,15 @@
                 <span class="{{ @$truncateName ? 'coverage-payer-name':'' }}"
                       title="{{$patient->insuranceDisplayName()}}">{{$patient->insuranceDisplayName()}}</span>
             @endif
+        @elseif(!!$patient->plan_type)
+            <span class="coverage-payer-name" title="{{$patient->plan_type}}">{{$patient->plan_type}}</span>
         @endif
         <div class="">
-            @if($patient->plan_type === 'MEDICARE')
-                Medicare
-                @if(@$patient->mpb_remaining)
-                    <span class="text-muted d-block text-sm ml-1">(Ded: {{format_number(@$patient->mpb_remaining)}})</span>
-                @endif
+            @if($patient->plan_type === 'MEDICARE' && @$patient->mpb_remaining)
+                <span class="text-muted text-sm ml-1">(Ded: {{format_number(@$patient->mpb_remaining)}})</span>
             @endif
-            @if($patient->plan_type === 'COMMERCIAL')
-                Commercial
-                @if(@$patient->deductible_amount && !!+@$patient->deductible_amount)
-                    <span class="text-muted d-block text-sm ml-1">(Ded: {{format_number(@$patient->deductible_amount)}})</span>
-                @endif
+            @if($patient->plan_type === 'COMMERCIAL' && @$patient->deductible_amount && !!+@$patient->deductible_amount)
+                <span class="text-muted text-sm ml-1">(Ded: {{format_number(@$patient->deductible_amount)}})</span>
             @endif
         </div>
     </div>

+ 2 - 2
resources/views/app/patient/coverage_column_renderer.blade.php

@@ -42,12 +42,12 @@
         <div class="">
             @if($coverage && $coverage->plan_type === 'MEDICARE')
                 @if(@$patient->mpb_remaining)
-                    <span class="text-muted d-block text-sm ml-1">(Ded: {{format_number(@$patient->mpb_remaining)}})</span>
+                    <span class="text-muted text-sm ml-1">(Ded: {{format_number(@$patient->mpb_remaining)}})</span>
                 @endif
             @endif
             @if($coverage && $coverage->plan_type === 'COMMERCIAL')
                 @if(@$coverage->deductible_amount && !!+@$coverage->deductible_amount)
-                    <span class="text-muted d-block text-sm ml-1">(Ded: {{format_number(@$coverage->deductible_amount)}})</span>
+                    <span class="text-muted text-sm ml-1">(Ded: {{format_number(@$coverage->deductible_amount)}})</span>
                 @endif
             @endif
         </div>

+ 2 - 2
resources/views/layouts/patient-header.blade.php

@@ -442,10 +442,10 @@ $addressParts .= implode(", ", $addressPart2);
             </div>
         </div>
 
-        <?php $cards = $patient->insuranceCards(); ?>
+        <?php $cards = $patient->insuranceCardsCustom(); ?>
         @if($cards && count($cards) > 0)
             <div class="d-flex bg-light p-2 border header-coverage-status" style="max-width: 305px;">
-                @include('app.patient.insurance_card_renderer', ['insurance_cards' => $patient->insuranceCards()])
+                @include('app.patient.insurance_card_renderer', ['insurance_cards' => $patient->insuranceCardsCustom()])
             </div>
         @else
             @if($hasCoverageColumn)