|
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
|
|
|
|
|
use App\Models\AppSession;
|
|
|
use App\Models\BillingReport;
|
|
|
+use App\Models\CareMonth;
|
|
|
use App\Models\ClaimEDI;
|
|
|
use App\Models\Handout;
|
|
|
use App\Models\MBClaim;
|
|
@@ -668,6 +669,114 @@ class PracticeManagementController extends Controller
|
|
|
return view('app.practice-management.billing-manager', compact('notes', 'allPros', 'expectedForHcp', 'targetPro', 'proUid', 'filters'));
|
|
|
}
|
|
|
|
|
|
+ public function remoteMonitoring(Request $request) {
|
|
|
+
|
|
|
+ $performer = $this->performer();
|
|
|
+
|
|
|
+ $ym = ($request->input('y') ?: 'Y') . '-' . ($request->input('m') ?: 'm');
|
|
|
+ $careMonthStart = date($ym . '-01');
|
|
|
+
|
|
|
+ // filters
|
|
|
+ $filters = '';
|
|
|
+ $fmd = $request->input('fmd');
|
|
|
+ if($fmd && $fmd !== 'all') {
|
|
|
+ switch($fmd) {
|
|
|
+ case 'lt16':
|
|
|
+ $filters .= ' AND care_month.number_of_days_with_remote_measurements < 16 ';
|
|
|
+ break;
|
|
|
+ case 'gte16':
|
|
|
+ $filters .= ' AND care_month.number_of_days_with_remote_measurements >= 16 ';
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $fcomm = $request->input('fcomm');
|
|
|
+ if($fcomm && $fcomm !== 'all') {
|
|
|
+ switch($fcomm) {
|
|
|
+ case '0':
|
|
|
+ $filters .= ' AND care_month.has_non_hcp_communicated_to_patient_about_rm = FALSE ';
|
|
|
+ break;
|
|
|
+ case '1':
|
|
|
+ $filters .= ' AND care_month.has_non_hcp_communicated_to_patient_about_rm = TRUE ';
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $patients = DB::select(
|
|
|
+ DB::raw(
|
|
|
+ "
|
|
|
+SELECT client.name_first, client.name_last, client.uid as client_uid,
|
|
|
+ care_month.uid as care_month_uid,
|
|
|
+ care_month.id as care_month_id,
|
|
|
+ care_month.start_date,
|
|
|
+ care_month.number_of_days_with_remote_measurements,
|
|
|
+ care_month.has_non_hcp_communicated_to_patient_about_rm,
|
|
|
+ care_month.rm_num_measurements_not_stamped_by_mcp,
|
|
|
+ care_month.rm_num_measurements_not_stamped_by_non_hcp,
|
|
|
+ care_month.rm_num_measurements_not_stamped_by_rmm,
|
|
|
+ care_month.rm_num_measurements_not_stamped_by_rme,
|
|
|
+ client.mcp_pro_id,
|
|
|
+ client.default_na_pro_id,
|
|
|
+ client.rmm_pro_id,
|
|
|
+ client.rme_pro_id,
|
|
|
+ client.cell_number
|
|
|
+FROM care_month join client on care_month.client_id = client.id
|
|
|
+WHERE (
|
|
|
+ (client.mcp_pro_id = {$performer->pro->id})
|
|
|
+ OR (client.rmm_pro_id = {$performer->pro->id})
|
|
|
+ OR (client.rme_pro_id = {$performer->pro->id})
|
|
|
+ OR (client.default_na_pro_id = {$performer->pro->id})
|
|
|
+ )
|
|
|
+ AND EXTRACT(MONTH from care_month.start_date) = " . ($request->input('m') ?: 'EXTRACT(MONTH from now())') . "
|
|
|
+ AND EXTRACT(YEAR from care_month.start_date) = " . ($request->input('y') ?: 'EXTRACT(YEAR from now())') . "
|
|
|
+ {$filters}
|
|
|
+ORDER BY care_month.number_of_days_with_remote_measurements DESC NULLS LAST, client.name_first ASC, client.name_last ASC
|
|
|
+"
|
|
|
+ )
|
|
|
+ );
|
|
|
+
|
|
|
+ $timestamp = strtotime(date('Y-m-d'));
|
|
|
+ $daysRemaining = (int)date('t', $timestamp) - (int)date('j', $timestamp);
|
|
|
+
|
|
|
+ return view('app.practice-management.remote-monitoring', compact('patients', 'daysRemaining', 'careMonthStart'));
|
|
|
+ }
|
|
|
+
|
|
|
+ public function remoteMonitoringMeasurements(Request $request, CareMonth $careMonth) {
|
|
|
+
|
|
|
+ $performer = $this->performer();
|
|
|
+
|
|
|
+ date_default_timezone_set('US/Eastern');
|
|
|
+
|
|
|
+ $start = strtotime(date($careMonth->start_date));
|
|
|
+ $end = date_add(date_create(date($careMonth->start_date)), date_interval_create_from_date_string("1 month"))->getTimestamp();
|
|
|
+ $start *= 1000;
|
|
|
+ $end *= 1000;
|
|
|
+
|
|
|
+ $measurements = DB::select(
|
|
|
+ DB::raw(
|
|
|
+ "
|
|
|
+SELECT * FROM measurement RIGHT JOIN client on measurement.client_id = client.id
|
|
|
+WHERE
|
|
|
+ client.id = {$careMonth->client_id}
|
|
|
+ AND measurement.label IS NOT NULL
|
|
|
+ AND measurement.label NOT IN ('SBP', 'DBP')
|
|
|
+ AND (measurement.is_cellular_zero = FALSE or measurement.is_cellular_zero IS NULL)
|
|
|
+ AND measurement.is_removed IS FALSE
|
|
|
+ AND measurement.client_bdt_measurement_id IS NOT NULL
|
|
|
+ AND measurement.ts >= {$start} AND measurement.ts < {$end}
|
|
|
+ AND (
|
|
|
+ (client.mcp_pro_id = {$performer->pro->id} AND measurement.has_been_stamped_by_mcp IS FALSE)
|
|
|
+ OR (client.rmm_pro_id = {$performer->pro->id} AND measurement.has_been_stamped_by_rmm IS FALSE)
|
|
|
+ OR (client.rme_pro_id = {$performer->pro->id} AND measurement.has_been_stamped_by_rme IS FALSE)
|
|
|
+ OR (client.default_na_pro_id = {$performer->pro->id} AND measurement.has_been_stamped_by_non_hcp IS FALSE)
|
|
|
+ )
|
|
|
+ORDER BY ts DESC
|
|
|
+"
|
|
|
+ )
|
|
|
+ );
|
|
|
+
|
|
|
+ return view('app.practice-management.remote-monitoring-measurements', compact('careMonth', 'measurements'));
|
|
|
+ }
|
|
|
+
|
|
|
public function billMatrix(Request $request)
|
|
|
{
|
|
|
$bClients = [];
|