|
@@ -372,6 +372,45 @@ class PracticeManagementController extends Controller
|
|
|
return view('app.practice-management.my-favorites', compact('myFavorites', 'filter'));
|
|
|
}
|
|
|
|
|
|
+ public function patientsWithoutCoverage(Request $request, $filter = 'all')
|
|
|
+ {
|
|
|
+ $performer = $this->performer();
|
|
|
+
|
|
|
+ $sql = "SELECT cl.uid, cl.name_first, cl.name_last FROM client cl ";
|
|
|
+
|
|
|
+ $joinClause = 'LEFT JOIN client_primary_coverage cpc ON cl.latest_client_primary_coverage_id = cpc.id ';
|
|
|
+ $withoutCondition = "cl.latest_client_primary_coverage_id IS NULL";
|
|
|
+ $pendingCondition = "
|
|
|
+(cl.latest_client_primary_coverage_id IS NOT NULL -- coverage exists, but status is null or unknown
|
|
|
+ AND (
|
|
|
+ (cpc.plan_type = 'MEDICARE' AND (cpc.is_partbprimary = 'UNKNOWN' OR cpc.is_partbprimary IS NULL))
|
|
|
+ OR
|
|
|
+ (cpc.plan_type != 'MEDICARE' AND
|
|
|
+ (cpc.manual_determination_category = 'UNKNOWN' OR cpc.manual_determination_category IS NULL))
|
|
|
+ ))";
|
|
|
+
|
|
|
+ switch ($filter) {
|
|
|
+ case 'without-coverage-information':
|
|
|
+ $sql .= 'WHERE ';
|
|
|
+ $sql .= $withoutCondition;
|
|
|
+ break;
|
|
|
+ case 'pending-coverage-verification':
|
|
|
+ $sql .= $joinClause . 'WHERE ';
|
|
|
+ $sql .= $pendingCondition;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ $sql .= $joinClause . 'WHERE ';
|
|
|
+ $sql .= $withoutCondition . ' OR ' . $pendingCondition;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ $sql .= ' ORDER BY cl.name_first ASC';
|
|
|
+
|
|
|
+ $pendingCoverage = DB::select(DB::raw($sql));
|
|
|
+
|
|
|
+ return view('app.practice-management.patients-without-coverage', compact('pendingCoverage', 'filter'));
|
|
|
+ }
|
|
|
+
|
|
|
public function proAvailability(Request $request, $proUid = null)
|
|
|
{
|
|
|
$performer = $this->performer();
|