|
@@ -2250,7 +2250,6 @@ WHERE
|
|
left join bill rmmBill on care_month.rmm_rm_generic_bill_id = rmmBill.id";
|
|
left join bill rmmBill on care_month.rmm_rm_generic_bill_id = rmmBill.id";
|
|
|
|
|
|
$defaultPageSize = 25;
|
|
$defaultPageSize = 25;
|
|
-
|
|
|
|
$page = $request->input('page') ?: 1;
|
|
$page = $request->input('page') ?: 1;
|
|
$perPage = $request->input('per_page') ?: $defaultPageSize;
|
|
$perPage = $request->input('per_page') ?: $defaultPageSize;
|
|
$offset = ($page - 1) * $perPage;
|
|
$offset = ($page - 1) * $perPage;
|
|
@@ -2428,6 +2427,146 @@ WHERE
|
|
return view('app.practice-management.rpm-matrix-for-admin', compact('patients', 'daysRemaining', 'careMonthStart', 'paginator', 'perPage', 'stats'));
|
|
return view('app.practice-management.rpm-matrix-for-admin', compact('patients', 'daysRemaining', 'careMonthStart', 'paginator', 'perPage', 'stats'));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public function rpmManager(Request $request) {
|
|
|
|
+
|
|
|
|
+ // whether this pro should be allowed access
|
|
|
|
+ $performer = $this->performer();
|
|
|
|
+ $pro = $performer->pro;
|
|
|
|
+ if($pro->pro_type !== 'ADMIN' &&
|
|
|
|
+ !$pro->is_considered_for_mcp_assignment &&
|
|
|
|
+ !$pro->is_considered_for_rmm &&
|
|
|
|
+ !$pro->is_considered_for_rme) {
|
|
|
|
+ abort(403);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $conditions = [];
|
|
|
|
+
|
|
|
|
+ // show only if enrolled in RPM
|
|
|
|
+ $conditions[] = "(care_month.is_client_enrolled_in_rm IS TRUE)";
|
|
|
|
+
|
|
|
|
+ // m and y are mandatory
|
|
|
|
+ $v = trim($request->input('m'));
|
|
|
|
+ if(!$v) $v = date("m");
|
|
|
|
+ $conditions[] = "(EXTRACT(MONTH from care_month.start_date) = $v)";
|
|
|
|
+ $month = $v;
|
|
|
|
+ $v = trim($request->input('y'));
|
|
|
|
+ if(!$v) $v = date("Y");
|
|
|
|
+ $conditions[] = "(EXTRACT(YEAR from care_month.start_date) = $v)";
|
|
|
|
+ $year = $v;
|
|
|
|
+
|
|
|
|
+ // count query
|
|
|
|
+ $countQuery = "
|
|
|
|
+SELECT count(*)
|
|
|
|
+FROM care_month join client on care_month.client_id = client.id
|
|
|
|
+ left join pro mcpPro on care_month.mcp_pro_id = mcpPro.id
|
|
|
|
+ left join pro rmmPro on care_month.rmm_pro_id = rmmPro.id
|
|
|
|
+ left join pro rmePro on care_month.rme_pro_id = rmePro.id
|
|
|
|
+ left join note mrnote on client.most_recent_completed_mcp_note_id = mrnote.id
|
|
|
|
+ left join appointment nv on nv.id = mrnote.follow_up_appointment_id
|
|
|
|
+WHERE
|
|
|
|
+ " . (count($conditions) > 0 ? implode(" AND ", $conditions) : '') . "
|
|
|
|
+";
|
|
|
|
+
|
|
|
|
+ $countResult = DB::select($countQuery);
|
|
|
|
+ $total = $countResult[0]->count;
|
|
|
|
+
|
|
|
|
+ $orderBy = "care_month.start_date DESC, care_month.number_of_days_with_remote_measurements DESC NULLS LAST, care_month.rm_total_time_in_seconds_by_mcp DESC NULLS LAST, care_month.rm_total_time_in_seconds_by_rmm_pro DESC NULLS LAST";
|
|
|
|
+ $defaultPageSize = 25;
|
|
|
|
+ $page = $request->input('page') ?: 1;
|
|
|
|
+ $perPage = $request->input('per_page') ?: $defaultPageSize;
|
|
|
|
+ $offset = ($page - 1) * $perPage;
|
|
|
|
+
|
|
|
|
+ // main query
|
|
|
|
+ $query = "
|
|
|
|
+SELECT
|
|
|
|
+ -- display columns
|
|
|
|
+ (client.name_first || ' ' || client.name_last) as client_name,
|
|
|
|
+ client.dob,
|
|
|
|
+ care_month.start_date,
|
|
|
|
+ (mcpPro.name_first || ' ' || mcpPro.name_last) as mcp_name,
|
|
|
|
+ (rmmPro.name_first || ' ' || rmmPro.name_last) as rmm_name,
|
|
|
|
+ (rmePro.name_first || ' ' || rmePro.name_last) as rme_name,
|
|
|
|
+ care_month.days_between_most_recent_mcp_note_date_and_end_of_care_month,
|
|
|
|
+ care_month.number_of_days_with_remote_measurements,
|
|
|
|
+ care_month.number_of_days_with_remote_bp_measurements,
|
|
|
|
+ care_month.number_of_days_with_remote_weight_measurements,
|
|
|
|
+ care_month.has_cellular_weight_scale_been_ordered,
|
|
|
|
+ care_month.has_cellular_weight_scale_device,
|
|
|
|
+ care_month.most_recent_cellular_weight_value,
|
|
|
|
+ care_month.most_recent_cellular_weight_measurement_at,
|
|
|
|
+ care_month.has_cellular_bp_device,
|
|
|
|
+ care_month.has_cellular_bp_meter_been_ordered,
|
|
|
|
+ care_month.most_recent_cellular_bp_dbp_mm_hg,
|
|
|
|
+ care_month.most_recent_cellular_bp_sbp_mm_hg,
|
|
|
|
+ care_month.most_recent_cellular_bp_measurement_at,
|
|
|
|
+ care_month.entries_json,
|
|
|
|
+ care_month.has_mcp_interacted_with_client_about_rm,
|
|
|
|
+ care_month.has_anyone_interacted_with_client_about_rm,
|
|
|
|
+ care_month.has_admin_interacted_with_client_about_rm,
|
|
|
|
+ care_month.has_rmm_interacted_with_client_about_rm,
|
|
|
|
+ care_month.rm_total_time_in_seconds,
|
|
|
|
+ care_month.rm_total_time_in_seconds_by_mcp,
|
|
|
|
+ care_month.rm_total_time_in_seconds_by_rmm_pro,
|
|
|
|
+ care_month.is_billable_by_mcp,
|
|
|
|
+ care_month.is_billed_by_mcp,
|
|
|
|
+ care_month.is_billable_by_rmm,
|
|
|
|
+ care_month.is_billed_by_rmm,
|
|
|
|
+ care_month.is_billable_by_rme,
|
|
|
|
+ care_month.is_billed_by_rme,
|
|
|
|
+ care_month.is_99454_claimable,
|
|
|
|
+ care_month.is_99454_claimed,
|
|
|
|
+ care_month.is_99454_claiming_waived,
|
|
|
|
+ care_month.why_99454_not_claimable_reason,
|
|
|
|
+ care_month.why_claiming_99454_waived,
|
|
|
|
+ care_month.is_99457_claimable,
|
|
|
|
+ care_month.is_99457_claimed,
|
|
|
|
+ care_month.is_99457_claiming_waived,
|
|
|
|
+ care_month.why_99457_not_claimable_reason,
|
|
|
|
+ care_month.why_claiming_99457_waived,
|
|
|
|
+ care_month.is_99458_claimable,
|
|
|
|
+ care_month.is_99458_claimed,
|
|
|
|
+ care_month.is_99458_claiming_waived,
|
|
|
|
+ care_month.why_99458_not_claimable_reason,
|
|
|
|
+ care_month.why_claiming_99458_waived,
|
|
|
|
+ nv.raw_date as next_visit_date,
|
|
|
|
+ -- TODO vital settings
|
|
|
|
+
|
|
|
|
+ -- functionality support columns
|
|
|
|
+ client.uid as client_uid,
|
|
|
|
+ care_month.uid as care_month_uid,
|
|
|
|
+ mcpPro.mcp_rpm_payment_strategy,
|
|
|
|
+ mcpPro.mcp_rpm_payment_amount,
|
|
|
|
+ rmmPro.rmm_payment_strategy,
|
|
|
|
+ rmmPro.rmm_payment_amount,
|
|
|
|
+ rmePro.rme_payment_strategy,
|
|
|
|
+ rmePro.rme_payment_amount
|
|
|
|
+
|
|
|
|
+FROM care_month join client on care_month.client_id = client.id
|
|
|
|
+ left join pro mcpPro on care_month.mcp_pro_id = mcpPro.id
|
|
|
|
+ left join pro rmmPro on care_month.rmm_pro_id = rmmPro.id
|
|
|
|
+ left join pro rmePro on care_month.rme_pro_id = rmePro.id
|
|
|
|
+ left join note mrnote on client.most_recent_completed_mcp_note_id = mrnote.id
|
|
|
|
+ left join appointment nv on nv.id = mrnote.follow_up_appointment_id
|
|
|
|
+WHERE
|
|
|
|
+ " . (count($conditions) > 0 ? implode(" AND ", $conditions) : '') . "
|
|
|
|
+ ORDER BY {$orderBy} OFFSET {$offset} LIMIT {$perPage}
|
|
|
|
+
|
|
|
|
+";
|
|
|
|
+
|
|
|
|
+ $patients = DB::select($query);
|
|
|
|
+ $paginator = new LengthAwarePaginator($patients, $total, $request->input('per_page') ?: $defaultPageSize, $request->input('page') ?: 1);
|
|
|
|
+ $paginator->setPath(route('practice-management.rpm-matrix-admin'));
|
|
|
|
+
|
|
|
|
+ $proRoles = [];
|
|
|
|
+ if($pro->pro_type === 'ADMIN') $proRoles[] = 'ADMIN';
|
|
|
|
+ if($pro->pro_type === 'ADMIN' || $pro->is_considered_for_mcp_assignment) $proRoles[] = 'MCP';
|
|
|
|
+ if($pro->pro_type === 'ADMIN' || $pro->is_considered_for_rmm) $proRoles[] = 'RMM';
|
|
|
|
+ if($pro->pro_type === 'ADMIN' || $pro->is_considered_for_rme) $proRoles[] = 'RME';
|
|
|
|
+ $viewingAs = $request->input('viewingAs') ?: $proRoles[0];
|
|
|
|
+
|
|
|
|
+ return view('app.practice-management.rpm-manager.index', compact('patients', 'month', 'year','paginator', 'perPage', 'proRoles', 'viewingAs'));
|
|
|
|
+ }
|
|
|
|
+
|
|
public function claimsReport(Request $request) {
|
|
public function claimsReport(Request $request) {
|
|
|
|
|
|
$performer = $this->performer();
|
|
$performer = $this->performer();
|