|
@@ -2096,6 +2096,92 @@ WHERE
|
|
return view('app.practice-management.rpm-matrix-for-admin', compact('patients', 'daysRemaining', 'careMonthStart', 'paginator', 'perPage'));
|
|
return view('app.practice-management.rpm-matrix-for-admin', compact('patients', 'daysRemaining', 'careMonthStart', 'paginator', 'perPage'));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public function claimsReport(Request $request) {
|
|
|
|
+
|
|
|
|
+ $performer = $this->performer();
|
|
|
|
+
|
|
|
|
+ $conditions = ["(claim.status = 'SUBMITTED')"];
|
|
|
|
+
|
|
|
|
+ // default sort
|
|
|
|
+ if(!$request->input('sort_by')) {
|
|
|
|
+ $orderBy = "cline.created_at DESC NULLS LAST";
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ $sortBy = json_decode($request->input('sort_by'));
|
|
|
|
+ $orderByClause = [];
|
|
|
|
+ foreach ($sortBy as $sortCriteria) {
|
|
|
|
+ $orderByClause[] = "{$sortCriteria->key} {$sortCriteria->order} NULLS LAST";
|
|
|
|
+ }
|
|
|
|
+ $orderBy = implode(', ', $orderByClause);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // filters from the UI
|
|
|
|
+ if(trim($request->input('f_start'))) {
|
|
|
|
+ $v = trim($request->input('f_start'));
|
|
|
|
+ $conditions[] = "(cline.date_of_service >= '{$v}')";
|
|
|
|
+ }
|
|
|
|
+ if(trim($request->input('f_end'))) {
|
|
|
|
+ $v = trim($request->input('f_end'));
|
|
|
|
+ $conditions[] = "(cline.date_of_service <= '{$v}')";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $defaultPageSize = 25;
|
|
|
|
+
|
|
|
|
+ $page = $request->input('page') ?: 1;
|
|
|
|
+ $perPage = $request->input('per_page') ?: $defaultPageSize;
|
|
|
|
+ $offset = ($page - 1) * $perPage;
|
|
|
|
+
|
|
|
|
+ $countQuery = "
|
|
|
|
+SELECT COUNT(*)
|
|
|
|
+FROM claim_line cline
|
|
|
|
+ join claim on cline.claim_id = claim.id
|
|
|
|
+ join client on claim.client_id = client.id
|
|
|
|
+ left join pro on claim.pro_id = pro.id
|
|
|
|
+ left join client_primary_coverage cpc on client.effective_client_primary_coverage_id = cpc.id
|
|
|
|
+ left join payer on cpc.commercial_payer_id = payer.id
|
|
|
|
+WHERE
|
|
|
|
+ " . implode(' AND ', $conditions) . "
|
|
|
|
+";
|
|
|
|
+
|
|
|
|
+ $countResult = DB::select($countQuery);
|
|
|
|
+ $total = $countResult[0]->count;
|
|
|
|
+
|
|
|
|
+ $query = "
|
|
|
|
+SELECT (client.name_first || ' ' || client.name_last) as client_name,
|
|
|
|
+ client.uid as client_uid,
|
|
|
|
+ client.dob,
|
|
|
|
+ client.age_in_years,
|
|
|
|
+ client.is_enrolled_in_rm,
|
|
|
|
+ client.mailing_address_state,
|
|
|
|
+ (pro.name_first || ' ' || pro.name_last) as pro_name,
|
|
|
|
+ (CASE
|
|
|
|
+ WHEN cpc.plan_type LIKE 'COMMERCIAL' THEN payer.name
|
|
|
|
+ ELSE cpc.plan_type
|
|
|
|
+ END) as payer_name,
|
|
|
|
+ cline.date_of_service,
|
|
|
|
+ cline.cpt
|
|
|
|
+FROM claim_line cline
|
|
|
|
+ join claim on cline.claim_id = claim.id
|
|
|
|
+ join client on claim.client_id = client.id
|
|
|
|
+ left join pro on claim.pro_id = pro.id
|
|
|
|
+ left join client_primary_coverage cpc on client.effective_client_primary_coverage_id = cpc.id
|
|
|
|
+ left join payer on cpc.commercial_payer_id = payer.id
|
|
|
|
+WHERE
|
|
|
|
+ " . implode(' AND ', $conditions) . "
|
|
|
|
+ ORDER BY {$orderBy} OFFSET {$offset} LIMIT {$perPage}
|
|
|
|
+";
|
|
|
|
+
|
|
|
|
+ // dd($query);
|
|
|
|
+
|
|
|
|
+ $rows = DB::select($query);
|
|
|
|
+
|
|
|
|
+ $paginator = new LengthAwarePaginator($rows, $total, $request->input('per_page') ?: $defaultPageSize, $request->input('page') ?: 1);
|
|
|
|
+ $perPage = $request->input('per_page') ?: $defaultPageSize;
|
|
|
|
+ $paginator->setPath(route('practice-management.claims-report'));
|
|
|
|
+
|
|
|
|
+ return view('app.practice-management.claims-report', compact('rows', 'paginator', 'perPage'));
|
|
|
|
+ }
|
|
|
|
+
|
|
public function remoteMonitoringMCP(Request $request) {
|
|
public function remoteMonitoringMCP(Request $request) {
|
|
return $this->rpmMatrixByProType($request, 'mcp');
|
|
return $this->rpmMatrixByProType($request, 'mcp');
|
|
}
|
|
}
|