|
@@ -1166,11 +1166,11 @@ SELECT client.name_first, client.name_last,
|
|
|
client.rmm_pro_id,
|
|
|
client.rme_pro_id,
|
|
|
client.cell_number,
|
|
|
- client.most_recent_cellular_bp_dbp_mm_hg,
|
|
|
- client.most_recent_cellular_bp_sbp_mm_hg,
|
|
|
- client.most_recent_cellular_bp_measurement_at,
|
|
|
- client.most_recent_cellular_weight_value,
|
|
|
- client.most_recent_cellular_weight_measurement_at
|
|
|
+ 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.most_recent_cellular_weight_value,
|
|
|
+ care_month.most_recent_cellular_weight_measurement_at
|
|
|
FROM care_month join client on care_month.client_id = client.id join note mrnote on client.most_recent_completed_mcp_note_id = mrnote.id
|
|
|
left join note mrmnote on mrmnote.id = (
|
|
|
select max(n.id) from note n
|
|
@@ -1234,11 +1234,11 @@ SELECT client.name_first, client.name_last,
|
|
|
client.rmm_pro_id,
|
|
|
client.rme_pro_id,
|
|
|
client.cell_number,
|
|
|
- client.most_recent_cellular_bp_dbp_mm_hg,
|
|
|
- client.most_recent_cellular_bp_sbp_mm_hg,
|
|
|
- client.most_recent_cellular_bp_measurement_at,
|
|
|
- client.most_recent_cellular_weight_value,
|
|
|
- client.most_recent_cellular_weight_measurement_at
|
|
|
+ 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.most_recent_cellular_weight_value,
|
|
|
+ care_month.most_recent_cellular_weight_measurement_at
|
|
|
FROM care_month join client on care_month.client_id = client.id join note mrnote on client.most_recent_completed_mcp_note_id = mrnote.id
|
|
|
left join note mrmnote on mrmnote.id = (
|
|
|
select max(n.id) from note n
|
|
@@ -1257,6 +1257,171 @@ WHERE care_month.uid = '{$careMonthUid}' AND client.uid = '{$clientUid}'
|
|
|
return view('app.practice-management.remote-monitoring-row', ['iPatient' => $patients[0], 'trIndex' => $request->input('trIndex')]);
|
|
|
}
|
|
|
|
|
|
+ private function remoteMonitoring_RowByProType(Request $request, $mode) {
|
|
|
+
|
|
|
+ $clientUid = $request->input('clientUid');
|
|
|
+ $careMonthUid = $request->input('careMonthUid');
|
|
|
+
|
|
|
+ $query = "
|
|
|
+SELECT client.name_first, client.name_last,
|
|
|
+ (client.name_first || ' ' || client.name_last) as client_name,
|
|
|
+ client.uid as client_uid,
|
|
|
+ client.dob,
|
|
|
+ client.is_enrolled_in_rm,
|
|
|
+ client.most_recent_completed_mcp_note_date,
|
|
|
+ client.most_recent_completed_mcp_note_id,
|
|
|
+ mrmnote.effective_dateest::date as most_recent_completed_mcp_note_date_cm,
|
|
|
+ mrmnote.id as most_recent_completed_mcp_note_id_cm,
|
|
|
+ mrmnote.uid as most_recent_completed_mcp_note_uid_cm,
|
|
|
+ client.cell_number,
|
|
|
+ client.is_assigned_cellular_bp_device,
|
|
|
+ client.is_assigned_cellular_weight_scale_device,
|
|
|
+ care_month.uid as care_month_uid,
|
|
|
+ care_month.id as care_month_id,
|
|
|
+ care_month.start_date,
|
|
|
+ care_month.rm_total_time_in_seconds_by_mcp,
|
|
|
+ care_month.rm_total_time_in_seconds_by_rmm_pro,
|
|
|
+ care_month.number_of_days_with_remote_measurements,
|
|
|
+ care_month.has_mcp_interacted_with_client_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,
|
|
|
+ care_month.mcp_pro_id as care_month_mcp_pro_id,
|
|
|
+ care_month.rmm_pro_id as care_month_rmm_pro_id,
|
|
|
+ client.mcp_pro_id,
|
|
|
+ client.default_na_pro_id,
|
|
|
+ client.rmm_pro_id,
|
|
|
+ client.rme_pro_id,
|
|
|
+ client.cell_number,
|
|
|
+ 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.most_recent_cellular_weight_value,
|
|
|
+ care_month.most_recent_cellular_weight_measurement_at
|
|
|
+FROM care_month join client on care_month.client_id = client.id join note mrnote on client.most_recent_completed_mcp_note_id = mrnote.id
|
|
|
+ left join note mrmnote on mrmnote.id = (
|
|
|
+ select max(n.id) from note n
|
|
|
+ where
|
|
|
+ n.client_id = client.id AND
|
|
|
+ n.is_cancelled = FALSE AND
|
|
|
+ (n.is_signed_by_hcp IS NOT NULL AND n.is_signed_by_hcp = TRUE) AND
|
|
|
+ n.effective_dateest::date >= care_month.start_date::date AND
|
|
|
+ n.effective_dateest::date < (care_month.start_date::date + INTERVAL '1 month')
|
|
|
+ )
|
|
|
+WHERE care_month.uid = '{$careMonthUid}' AND client.uid = '{$clientUid}'
|
|
|
+";
|
|
|
+
|
|
|
+ $patients = DB::select($query);
|
|
|
+
|
|
|
+ return view('app.practice-management.remote-monitoring-row-by-pro-type', ['iPatient' => $patients[0], 'trIndex' => $request->input('trIndex'), 'mode' => $mode]);
|
|
|
+ }
|
|
|
+
|
|
|
+ private function rpmMatrixByProType(Request $request, $mode) {
|
|
|
+
|
|
|
+ $performer = $this->performer();
|
|
|
+
|
|
|
+ // abort_if($performer->pro->pro_type !== 'ADMIN' && !$performer->pro->can_view_rm_matrix, 403);
|
|
|
+
|
|
|
+ $ym = ($request->input('y') ?: 'Y') . '-' . ($request->input('m') ?: 'm');
|
|
|
+ $careMonthStart = date($ym . '-01');
|
|
|
+
|
|
|
+ $rc = $request->input('rc') ?: 1;
|
|
|
+ $rc2 = $request->input('rc2') ?: 2;
|
|
|
+
|
|
|
+ $conditions = [];// $this->rpmConditions($performer, $rc, $rc2);
|
|
|
+
|
|
|
+ $sortBy = $request->input('sort_by') ?: 'name_first';
|
|
|
+ $sortDir = $request->input('sort_dir') ?: 'ASC';
|
|
|
+ $orderBy = "ORDER BY $sortBy $sortDir NULLS LAST";
|
|
|
+
|
|
|
+ $query = "
|
|
|
+SELECT client.name_first, client.name_last,
|
|
|
+ (client.name_first || ' ' || client.name_last) as client_name,
|
|
|
+ client.uid as client_uid,
|
|
|
+ client.dob,
|
|
|
+ client.is_enrolled_in_rm,
|
|
|
+ client.most_recent_completed_mcp_note_date,
|
|
|
+ client.most_recent_completed_mcp_note_id,
|
|
|
+ mrmnote.effective_dateest::date as most_recent_completed_mcp_note_date_cm,
|
|
|
+ mrmnote.id as most_recent_completed_mcp_note_id_cm,
|
|
|
+ mrmnote.uid as most_recent_completed_mcp_note_uid_cm,
|
|
|
+ client.cell_number,
|
|
|
+ client.is_assigned_cellular_bp_device,
|
|
|
+ client.is_assigned_cellular_weight_scale_device,
|
|
|
+ care_month.uid as care_month_uid,
|
|
|
+ care_month.id as care_month_id,
|
|
|
+ care_month.start_date,
|
|
|
+ care_month.rm_total_time_in_seconds_by_mcp,
|
|
|
+ care_month.rm_total_time_in_seconds_by_rmm_pro,
|
|
|
+ care_month.number_of_days_with_remote_measurements,
|
|
|
+ care_month.has_mcp_interacted_with_client_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,
|
|
|
+ care_month.mcp_pro_id as care_month_mcp_pro_id,
|
|
|
+ care_month.rmm_pro_id as care_month_rmm_pro_id,
|
|
|
+ client.mcp_pro_id,
|
|
|
+ client.default_na_pro_id,
|
|
|
+ client.rmm_pro_id,
|
|
|
+ client.rme_pro_id,
|
|
|
+ client.cell_number,
|
|
|
+ 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.most_recent_cellular_weight_value,
|
|
|
+ care_month.most_recent_cellular_weight_measurement_at
|
|
|
+FROM care_month join client on care_month.client_id = client.id join note mrnote on client.most_recent_completed_mcp_note_id = mrnote.id
|
|
|
+ left join note mrmnote on mrmnote.id = (
|
|
|
+ select max(n.id) from note n
|
|
|
+ where
|
|
|
+ n.client_id = client.id AND
|
|
|
+ n.is_cancelled = FALSE AND
|
|
|
+ (n.is_signed_by_hcp IS NOT NULL AND n.is_signed_by_hcp = TRUE) AND
|
|
|
+ n.effective_dateest::date >= care_month.start_date::date AND
|
|
|
+ n.effective_dateest::date < (care_month.start_date::date + INTERVAL '1 month')
|
|
|
+ )
|
|
|
+WHERE
|
|
|
+ (care_month.mcp_pro_id = {$performer->pro->id} OR care_month.rmm_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())') . "
|
|
|
+ " . (count($conditions) > 0 ? 'AND ' . implode(" AND ", $conditions) : '') . "
|
|
|
+ $orderBy
|
|
|
+";
|
|
|
+
|
|
|
+ $patients = DB::select($query);
|
|
|
+
|
|
|
+ $timestamp = strtotime(date('Y-m-d'));
|
|
|
+ $daysRemaining = (int)date('t', $timestamp) - (int)date('j', $timestamp);
|
|
|
+
|
|
|
+ return view('app.practice-management.rpm-matrix-by-pro-type', compact('patients', 'daysRemaining', 'careMonthStart', 'mode'));
|
|
|
+ }
|
|
|
+
|
|
|
+ public function remoteMonitoringMCP(Request $request) {
|
|
|
+ return $this->rpmMatrixByProType($request, 'mcp');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function remoteMonitoringRMM(Request $request) {
|
|
|
+ return $this->rpmMatrixByProType($request, 'rmm');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function remoteMonitoringRME(Request $request) {
|
|
|
+ return $this->rpmMatrixByProType($request, 'rme');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function remoteMonitoring_RowMCP(Request $request) {
|
|
|
+ return $this->remoteMonitoring_RowByProType($request, 'mcp');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function remoteMonitoring_RowRMM(Request $request) {
|
|
|
+ return $this->remoteMonitoring_RowByProType($request, 'rmm');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function remoteMonitoring_RowRME(Request $request) {
|
|
|
+ return $this->remoteMonitoring_RowByProType($request, 'rme');
|
|
|
+ }
|
|
|
+
|
|
|
public function rpm_work_matrix(Request $request) {
|
|
|
|
|
|
// get the patient having most recent unstamped measurement
|