|
@@ -3,6 +3,7 @@
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
use App\Models\AppSession;
|
|
|
+use App\Models\BillingReport;
|
|
|
use App\Models\ClaimEDI;
|
|
|
use App\Models\Measurement;
|
|
|
use App\Models\Bill;
|
|
@@ -33,6 +34,13 @@ use Illuminate\Http\Request;
|
|
|
|
|
|
class PracticeManagementController extends Controller
|
|
|
{
|
|
|
+
|
|
|
+ public function billingReport(Request $request)
|
|
|
+ {
|
|
|
+ $rows = BillingReport::paginate(200);
|
|
|
+ return view('app.practice-management.billing-report', compact('rows'));
|
|
|
+ }
|
|
|
+
|
|
|
public function dashboard(Request $request)
|
|
|
{
|
|
|
return view('app.practice-management.dashboard');
|
|
@@ -883,55 +891,66 @@ class PracticeManagementController extends Controller
|
|
|
return view('app.practice-management.shipments-multi-print', compact('shipments'));
|
|
|
}
|
|
|
|
|
|
- public function patientClaimSummary(Request $request, $proUid=null)
|
|
|
+ public function patientClaimSummary(Request $request, $proUid = null)
|
|
|
{
|
|
|
|
|
|
$notesTotal = DB::select(DB::raw("SELECT COUNT(*) FROM note WHERE is_cancelled IS NOT TRUE"))[0]->count;
|
|
|
$notesTotalWithBillingClosed = DB::select(DB::raw("SELECT COUNT(*) FROM note WHERE is_cancelled IS NOT TRUE AND is_bill_closed IS TRUE"))[0]->count;
|
|
|
$notesTotalWithClaimingClosed = DB::select(DB::raw("SELECT COUNT(*) FROM note WHERE is_cancelled IS NOT TRUE AND is_claim_closed IS TRUE"))[0]->count;
|
|
|
|
|
|
+ $notes3rdPartyTotal = DB::select(DB::raw("SELECT COUNT(*) FROM note n LEFT JOIN client c ON n.client_id = c.id WHERE n.is_cancelled IS NOT TRUE AND c.is_part_b_primary <> 'YES'"))[0]->count;
|
|
|
+ $notes3rdPartyTotalWithBillingClosed = DB::select(DB::raw("SELECT COUNT(*) FROM note n LEFT JOIN client c ON n.client_id = c.id WHERE n.is_cancelled IS NOT TRUE AND n.is_bill_closed IS TRUE AND c.is_part_b_primary <> 'YES'"))[0]->count;
|
|
|
+ $notes3rdPartyTotalWithClaimingClosed = DB::select(DB::raw("SELECT COUNT(*) FROM note n LEFT JOIN client c ON n.client_id = c.id WHERE n.is_cancelled IS NOT TRUE AND n.is_claim_closed IS TRUE AND c.is_part_b_primary <> 'YES'"))[0]->count;
|
|
|
+
|
|
|
$patientsTotal = DB::select(DB::raw("SELECT COUNT(*) FROM client WHERE is_active IS TRUE AND 0 NOT IN (SELECT c FROM (SELECT COUNT(*) c FROM note WHERE is_cancelled IS NOT TRUE AND note.client_id = client.id) x)"))[0]->count;
|
|
|
$patientsTotalWithBillingClosed = DB::select(DB::raw("SELECT COUNT(*) FROM client WHERE is_active IS TRUE AND 0 NOT IN (SELECT c FROM (SELECT COUNT(*) c FROM note WHERE is_cancelled IS NOT TRUE AND note.client_id = client.id) y) AND 0 IN (SELECT c FROM (SELECT COUNT(*) c FROM note WHERE is_cancelled IS NOT TRUE AND is_bill_closed IS NOT TRUE AND note.client_id = client.id) x)"))[0]->count;
|
|
|
$patientsTotalWithClaimingClosed = DB::select(DB::raw("SELECT COUNT(*) FROM client WHERE is_active IS TRUE AND 0 NOT IN (SELECT c FROM (SELECT COUNT(*) c FROM note WHERE is_cancelled IS NOT TRUE AND note.client_id = client.id) y) AND 0 IN (SELECT c FROM (SELECT COUNT(*) c FROM note WHERE is_cancelled IS NOT TRUE AND is_claim_closed IS NOT TRUE AND note.client_id = client.id) x)"))[0]->count;
|
|
|
|
|
|
+
|
|
|
$performerPro = $this->performer->pro;
|
|
|
$allPros = [];
|
|
|
if ($performerPro->pro_type == 'ADMIN') {
|
|
|
$allPros = Pro::all();
|
|
|
} else {
|
|
|
- $allPros = [$performerPro];
|
|
|
+ $allPros = [$performerPro];
|
|
|
}
|
|
|
|
|
|
//Patient | MCP | # Notes Total | # Notes without Billing Closed | # Notes without Claiming Closed
|
|
|
$patientsQuery = Client::where('is_dummy', '=', false)
|
|
|
- ->select('id', 'uid', 'name_first', 'name_last', 'mcp_pro_id',
|
|
|
+ ->select('id', 'uid', 'name_first', 'name_last', 'mcp_pro_id', 'is_part_b_primary', 'medicare_advantage_plan',
|
|
|
DB::raw("(SELECT name_first||' '||name_last FROM pro where pro.id = client.mcp_pro_id) as mcp"),
|
|
|
DB::raw("(SELECT uid FROM pro where pro.id = mcp_pro_id) as mcp_pro_uid"),
|
|
|
DB::raw("(SELECT COUNT(*) FROM note where note.client_id = client.id) as notes_total"),
|
|
|
DB::raw("(SELECT COUNT(*) FROM note where note.client_id = client.id AND is_bill_closed IS NOT true) as notes_without_billing_closed"),
|
|
|
DB::raw("(SELECT COUNT(*) FROM note where note.client_id = client.id AND is_claim_closed IS NOT true) as notes_without_claiming_closed")
|
|
|
- )->orderBy('notes_without_claiming_closed', 'desc');
|
|
|
+ )->orderBy('is_part_b_primary', 'asc')->orderBy('notes_without_claiming_closed', 'desc');
|
|
|
|
|
|
- if($proUid){
|
|
|
- $mcpPro = Pro::where('uid', $proUid)->first();
|
|
|
- if($mcpPro){
|
|
|
- $patientsQuery->where('client.mcp_pro_id','=', $mcpPro->id);
|
|
|
- }
|
|
|
+ if ($proUid) {
|
|
|
+ $mcpPro = Pro::where('uid', $proUid)->first();
|
|
|
+ if ($mcpPro) {
|
|
|
+ $patientsQuery->where('client.mcp_pro_id', '=', $mcpPro->id);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- $patients = $patientsQuery->paginate(50);
|
|
|
-
|
|
|
- $data = [
|
|
|
- 'patients' => $patients,
|
|
|
- 'proUid' => $proUid,
|
|
|
- 'allPros' => $allPros,
|
|
|
- 'notesTotal' => $notesTotal,
|
|
|
- 'notesTotalWithBillingClosed' => $notesTotalWithBillingClosed,
|
|
|
- 'notesTotalWithClaimingClosed' => $notesTotalWithClaimingClosed,
|
|
|
- 'patientsTotal' => $patientsTotal,
|
|
|
- 'patientsTotalWithBillingClosed' => $patientsTotalWithBillingClosed,
|
|
|
- 'patientsTotalWithClaimingClosed' => $patientsTotalWithClaimingClosed
|
|
|
- ];
|
|
|
+ $patients = $patientsQuery->paginate(50);
|
|
|
+
|
|
|
+ $data = [
|
|
|
+ 'patients' => $patients,
|
|
|
+ 'proUid' => $proUid,
|
|
|
+ 'allPros' => $allPros,
|
|
|
+ 'notesTotal' => $notesTotal,
|
|
|
+ 'notesTotalWithBillingClosed' => $notesTotalWithBillingClosed,
|
|
|
+ 'notesTotalWithClaimingClosed' => $notesTotalWithClaimingClosed,
|
|
|
+
|
|
|
+ 'notes3rdPartyTotal' => $notes3rdPartyTotal,
|
|
|
+ 'notes3rdPartyTotalWithBillingClosed' => $notes3rdPartyTotalWithBillingClosed,
|
|
|
+ 'notes3rdPartyTotalWithClaimingClosed' => $notes3rdPartyTotalWithClaimingClosed,
|
|
|
+
|
|
|
+ 'patientsTotal' => $patientsTotal,
|
|
|
+ 'patientsTotalWithBillingClosed' => $patientsTotalWithBillingClosed,
|
|
|
+ 'patientsTotalWithClaimingClosed' => $patientsTotalWithClaimingClosed
|
|
|
+
|
|
|
+ ];
|
|
|
|
|
|
return view('app.practice-management.patient-claim-summary', $data);
|
|
|
}
|