|
@@ -1243,7 +1243,7 @@ SELECT client.name_first, client.name_last,
|
|
(client.name_first || ' ' || client.name_last) as client_name,
|
|
(client.name_first || ' ' || client.name_last) as client_name,
|
|
client.uid as client_uid,
|
|
client.uid as client_uid,
|
|
client.dob,
|
|
client.dob,
|
|
- client.is_enrolled_in_rm,
|
|
|
|
|
|
+ care_month.is_client_enrolled_in_rm,
|
|
client.most_recent_completed_mcp_note_date,
|
|
client.most_recent_completed_mcp_note_date,
|
|
client.most_recent_completed_mcp_note_id,
|
|
client.most_recent_completed_mcp_note_id,
|
|
mrmnote.effective_dateest::date as most_recent_completed_mcp_note_date_cm,
|
|
mrmnote.effective_dateest::date as most_recent_completed_mcp_note_date_cm,
|
|
@@ -1311,7 +1311,7 @@ SELECT client.name_first, client.name_last,
|
|
(client.name_first || ' ' || client.name_last) as client_name,
|
|
(client.name_first || ' ' || client.name_last) as client_name,
|
|
client.uid as client_uid,
|
|
client.uid as client_uid,
|
|
client.dob,
|
|
client.dob,
|
|
- client.is_enrolled_in_rm,
|
|
|
|
|
|
+ care_month.is_client_enrolled_in_rm,
|
|
client.most_recent_completed_mcp_note_date,
|
|
client.most_recent_completed_mcp_note_date,
|
|
client.most_recent_completed_mcp_note_id,
|
|
client.most_recent_completed_mcp_note_id,
|
|
mrmnote.effective_dateest::date as most_recent_completed_mcp_note_date_cm,
|
|
mrmnote.effective_dateest::date as most_recent_completed_mcp_note_date_cm,
|
|
@@ -1371,7 +1371,7 @@ SELECT client.name_first, client.name_last,
|
|
(client.name_first || ' ' || client.name_last) as client_name,
|
|
(client.name_first || ' ' || client.name_last) as client_name,
|
|
client.uid as client_uid,
|
|
client.uid as client_uid,
|
|
client.dob,
|
|
client.dob,
|
|
- client.is_enrolled_in_rm,
|
|
|
|
|
|
+ care_month.is_client_enrolled_in_rm,
|
|
client.most_recent_completed_mcp_note_date,
|
|
client.most_recent_completed_mcp_note_date,
|
|
client.most_recent_completed_mcp_note_id,
|
|
client.most_recent_completed_mcp_note_id,
|
|
mrmnote.effective_dateest::date as most_recent_completed_mcp_note_date_cm,
|
|
mrmnote.effective_dateest::date as most_recent_completed_mcp_note_date_cm,
|
|
@@ -1431,7 +1431,7 @@ SELECT client.name_first, client.name_last,
|
|
(client.name_first || ' ' || client.name_last) as client_name,
|
|
(client.name_first || ' ' || client.name_last) as client_name,
|
|
client.uid as client_uid,
|
|
client.uid as client_uid,
|
|
client.dob,
|
|
client.dob,
|
|
- client.is_enrolled_in_rm,
|
|
|
|
|
|
+ care_month.is_client_enrolled_in_rm,
|
|
client.most_recent_completed_mcp_note_date,
|
|
client.most_recent_completed_mcp_note_date,
|
|
client.most_recent_completed_mcp_note_id,
|
|
client.most_recent_completed_mcp_note_id,
|
|
mrmnote.effective_dateest::date as most_recent_completed_mcp_note_date_cm,
|
|
mrmnote.effective_dateest::date as most_recent_completed_mcp_note_date_cm,
|
|
@@ -1555,10 +1555,10 @@ WHERE care_month.uid = '{$careMonthUid}' AND client.uid = '{$clientUid}'
|
|
if(trim($request->input('f_rpm'))) {
|
|
if(trim($request->input('f_rpm'))) {
|
|
$v = trim($request->input('f_rpm'));
|
|
$v = trim($request->input('f_rpm'));
|
|
if($v === 'yes') {
|
|
if($v === 'yes') {
|
|
- $conditions[] = "(client.is_enrolled_in_rm IS NOT NULL AND client.is_enrolled_in_rm = 'YES')";
|
|
|
|
|
|
+ $conditions[] = "(care_month.is_client_enrolled_in_rm IS TRUE)";
|
|
}
|
|
}
|
|
elseif($v === 'no') {
|
|
elseif($v === 'no') {
|
|
- $conditions[] = "(client.is_enrolled_in_rm IS NULL OR client.is_enrolled_in_rm != 'YES')";
|
|
|
|
|
|
+ $conditions[] = "(care_month.is_client_enrolled_in_rm IS NOT TRUE)";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(trim($request->input('f_cell_bp'))) {
|
|
if(trim($request->input('f_cell_bp'))) {
|
|
@@ -1628,10 +1628,10 @@ WHERE care_month.uid = '{$careMonthUid}' AND client.uid = '{$clientUid}'
|
|
}
|
|
}
|
|
|
|
|
|
if($request->input('not-enrolled')) {
|
|
if($request->input('not-enrolled')) {
|
|
- $conditions[] = "(client.is_enrolled_in_rm != 'YES')";
|
|
|
|
|
|
+ $conditions[] = "(care_month.is_client_enrolled_in_rm IS NOT TRUE)";
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- $conditions[] = "(client.is_enrolled_in_rm = 'YES')";
|
|
|
|
|
|
+ $conditions[] = "(care_month.is_client_enrolled_in_rm IS TRUE)";
|
|
}
|
|
}
|
|
|
|
|
|
$proTypeCondition = '';
|
|
$proTypeCondition = '';
|
|
@@ -1672,7 +1672,7 @@ SELECT client.name_first, client.name_last,
|
|
(client.name_first || ' ' || client.name_last) as client_name,
|
|
(client.name_first || ' ' || client.name_last) as client_name,
|
|
client.uid as client_uid,
|
|
client.uid as client_uid,
|
|
client.dob,
|
|
client.dob,
|
|
- client.is_enrolled_in_rm,
|
|
|
|
|
|
+ care_month.is_client_enrolled_in_rm,
|
|
client.most_recent_completed_mcp_note_date,
|
|
client.most_recent_completed_mcp_note_date,
|
|
client.most_recent_completed_mcp_note_id,
|
|
client.most_recent_completed_mcp_note_id,
|
|
mrmnote.effective_dateest::date as most_recent_completed_mcp_note_date_cm,
|
|
mrmnote.effective_dateest::date as most_recent_completed_mcp_note_date_cm,
|
|
@@ -1851,10 +1851,10 @@ WHERE
|
|
if(trim($request->input('f_rpm'))) {
|
|
if(trim($request->input('f_rpm'))) {
|
|
$v = trim($request->input('f_rpm'));
|
|
$v = trim($request->input('f_rpm'));
|
|
if($v === 'yes') {
|
|
if($v === 'yes') {
|
|
- $conditions[] = "(client.is_enrolled_in_rm IS NOT NULL AND client.is_enrolled_in_rm = 'YES')";
|
|
|
|
|
|
+ $conditions[] = "(care_month.is_client_enrolled_in_rm IS TRUE)";
|
|
}
|
|
}
|
|
elseif($v === 'no') {
|
|
elseif($v === 'no') {
|
|
- $conditions[] = "(client.is_enrolled_in_rm IS NULL OR client.is_enrolled_in_rm != 'YES')";
|
|
|
|
|
|
+ $conditions[] = "(care_month.is_client_enrolled_in_rm IS NOT TRUE)";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(trim($request->input('f_cell_bp'))) {
|
|
if(trim($request->input('f_cell_bp'))) {
|
|
@@ -1950,10 +1950,10 @@ WHERE
|
|
}
|
|
}
|
|
|
|
|
|
if($request->input('not-enrolled')) {
|
|
if($request->input('not-enrolled')) {
|
|
- $conditions[] = "(client.is_enrolled_in_rm != 'YES')";
|
|
|
|
|
|
+ $conditions[] = "(care_month.is_client_enrolled_in_rm IS NOT TRUE)";
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- $conditions[] = "(client.is_enrolled_in_rm = 'YES')";
|
|
|
|
|
|
+ $conditions[] = "(care_month.is_client_enrolled_in_rm IS TRUE)";
|
|
}
|
|
}
|
|
|
|
|
|
if($request->input('f_claim_closed')) {
|
|
if($request->input('f_claim_closed')) {
|
|
@@ -2017,7 +2017,7 @@ SELECT client.name_first, client.name_last,
|
|
client.uid as client_uid,
|
|
client.uid as client_uid,
|
|
client.dob,
|
|
client.dob,
|
|
client.age_in_years,
|
|
client.age_in_years,
|
|
- client.is_enrolled_in_rm,
|
|
|
|
|
|
+ care_month.is_client_enrolled_in_rm,
|
|
client.most_recent_completed_mcp_note_date,
|
|
client.most_recent_completed_mcp_note_date,
|
|
client.most_recent_completed_mcp_note_id,
|
|
client.most_recent_completed_mcp_note_id,
|
|
client.cell_number,
|
|
client.cell_number,
|
|
@@ -2233,7 +2233,7 @@ WHERE
|
|
(client.name_first || ' ' || client.name_last) as client_name,
|
|
(client.name_first || ' ' || client.name_last) as client_name,
|
|
client.uid as client_uid,
|
|
client.uid as client_uid,
|
|
client.dob,
|
|
client.dob,
|
|
- client.is_enrolled_in_rm,
|
|
|
|
|
|
+ care_month.is_client_enrolled_in_rm,
|
|
client.most_recent_completed_mcp_note_date,
|
|
client.most_recent_completed_mcp_note_date,
|
|
care_month.uid as care_month_uid,
|
|
care_month.uid as care_month_uid,
|
|
care_month.id as care_month_id,
|
|
care_month.id as care_month_id,
|
|
@@ -2331,7 +2331,7 @@ SELECT client.name_first, client.name_last,
|
|
client.uid as client_uid,
|
|
client.uid as client_uid,
|
|
client.chart_number,
|
|
client.chart_number,
|
|
client.dob,
|
|
client.dob,
|
|
- client.is_enrolled_in_rm,
|
|
|
|
|
|
+ care_month.is_client_enrolled_in_rm,
|
|
client.most_recent_completed_mcp_note_date,
|
|
client.most_recent_completed_mcp_note_date,
|
|
client.most_recent_completed_mcp_note_id,
|
|
client.most_recent_completed_mcp_note_id,
|
|
mrmnote.effective_dateest::date as most_recent_completed_mcp_note_date_cm,
|
|
mrmnote.effective_dateest::date as most_recent_completed_mcp_note_date_cm,
|
|
@@ -2407,7 +2407,7 @@ WHERE
|
|
SELECT count(*)
|
|
SELECT count(*)
|
|
FROM care_month join client on care_month.client_id = client.id
|
|
FROM care_month join client on care_month.client_id = client.id
|
|
WHERE
|
|
WHERE
|
|
- client.shadow_pro_id is null AND client.is_enrolled_in_rm = 'YES'
|
|
|
|
|
|
+ client.shadow_pro_id is null AND care_month.is_client_enrolled_in_rm IS TRUE
|
|
AND EXTRACT(MONTH from care_month.start_date) = " . ($request->input('m') ?: 'EXTRACT(MONTH from now())') . "
|
|
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())') . "
|
|
AND EXTRACT(YEAR from care_month.start_date) = " . ($request->input('y') ?: 'EXTRACT(YEAR from now())') . "
|
|
" . (count($conditions) > 0 ? 'AND ' . implode(" AND ", $conditions) : '')
|
|
" . (count($conditions) > 0 ? 'AND ' . implode(" AND ", $conditions) : '')
|
|
@@ -2421,7 +2421,7 @@ WHERE
|
|
$conditions = [];
|
|
$conditions = [];
|
|
|
|
|
|
$c_isMCP = "client.mcp_pro_id = {$performer->pro->id}";
|
|
$c_isMCP = "client.mcp_pro_id = {$performer->pro->id}";
|
|
- $c_enrolledInRPM = "client.is_enrolled_in_rm = 'YES'";
|
|
|
|
|
|
+ $c_enrolledInRPM = "care_month.is_client_enrolled_in_rm IS TRUE";
|
|
$c_hasDevice = "(SELECT COUNT(client_bdt_device.id) FROM client_bdt_device JOIN bdt_device bd on client_bdt_device.device_id = bd.id WHERE client_bdt_device.client_id = client.id) > 0";
|
|
$c_hasDevice = "(SELECT COUNT(client_bdt_device.id) FROM client_bdt_device JOIN bdt_device bd on client_bdt_device.device_id = bd.id WHERE client_bdt_device.client_id = client.id) > 0";
|
|
$c_lastVisitBefore90Days = "DATE_PART('day', care_month.start_date::timestamp - client.most_recent_completed_mcp_note_date::timestamp) > 90";
|
|
$c_lastVisitBefore90Days = "DATE_PART('day', care_month.start_date::timestamp - client.most_recent_completed_mcp_note_date::timestamp) > 90";
|
|
$c_lastVisitWithin90Days = "DATE_PART('day', care_month.start_date::timestamp - client.most_recent_completed_mcp_note_date::timestamp) <= 90";
|
|
$c_lastVisitWithin90Days = "DATE_PART('day', care_month.start_date::timestamp - client.most_recent_completed_mcp_note_date::timestamp) <= 90";
|
|
@@ -2475,7 +2475,7 @@ WHERE
|
|
private function rpmConditionsAdmin($performer, $rc, $rc2) {
|
|
private function rpmConditionsAdmin($performer, $rc, $rc2) {
|
|
$conditions = [];
|
|
$conditions = [];
|
|
|
|
|
|
- $c_enrolledInRPM = "client.is_enrolled_in_rm = 'YES'";
|
|
|
|
|
|
+ $c_enrolledInRPM = "care_month.is_client_enrolled_in_rm IS TRUE";
|
|
$c_hasDevice = "(SELECT COUNT(client_bdt_device.id) FROM client_bdt_device JOIN bdt_device bd on client_bdt_device.device_id = bd.id WHERE client_bdt_device.client_id = client.id) > 0";
|
|
$c_hasDevice = "(SELECT COUNT(client_bdt_device.id) FROM client_bdt_device JOIN bdt_device bd on client_bdt_device.device_id = bd.id WHERE client_bdt_device.client_id = client.id) > 0";
|
|
$c_lastVisitBefore90Days = "DATE_PART('day', care_month.start_date::timestamp - client.most_recent_completed_mcp_note_date::timestamp) > 90";
|
|
$c_lastVisitBefore90Days = "DATE_PART('day', care_month.start_date::timestamp - client.most_recent_completed_mcp_note_date::timestamp) > 90";
|
|
$c_lastVisitWithin90Days = "DATE_PART('day', care_month.start_date::timestamp - client.most_recent_completed_mcp_note_date::timestamp) <= 90";
|
|
$c_lastVisitWithin90Days = "DATE_PART('day', care_month.start_date::timestamp - client.most_recent_completed_mcp_note_date::timestamp) <= 90";
|
|
@@ -3771,12 +3771,12 @@ ORDER BY c.name_last, c.name_first
|
|
$pro = $this->performer()->pro;
|
|
$pro = $this->performer()->pro;
|
|
if($pro->pro_type !== 'ADMIN') {
|
|
if($pro->pro_type !== 'ADMIN') {
|
|
if($pro->is_hcp){
|
|
if($pro->is_hcp){
|
|
- $patients = $patients->where('mcp_pro_id', $this->performer()->pro->id);
|
|
|
|
|
|
+ $patients = $patients->where('mcp_pro_id', $this->performer()->pro->id);
|
|
}
|
|
}
|
|
if($pro->is_considered_for_dna){
|
|
if($pro->is_considered_for_dna){
|
|
- $patients = $patients->where('default_na_pro_id', $this->performer()->pro->id);
|
|
|
|
|
|
+ $patients = $patients->where('default_na_pro_id', $this->performer()->pro->id);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -3839,8 +3839,8 @@ ORDER BY c.name_last, c.name_first
|
|
$patients->where('is_eligible_for_rm', '=', $request->input('is_eligible_for_rm'));
|
|
$patients->where('is_eligible_for_rm', '=', $request->input('is_eligible_for_rm'));
|
|
}
|
|
}
|
|
|
|
|
|
- if($request->input('is_enrolled_in_rm')){
|
|
|
|
- $patients->where('is_enrolled_in_rm', '=', $request->input('is_enrolled_in_rm'));
|
|
|
|
|
|
+ if($request->input('is_enrolled_in_rm')){ /*-- correct --*/
|
|
|
|
+ $patients->where('is_enrolled_in_rm', '=', $request->input('is_enrolled_in_rm')); /*-- correct --*/
|
|
}
|
|
}
|
|
|
|
|
|
if($request->input('has_rm_setup_been_performed')){
|
|
if($request->input('has_rm_setup_been_performed')){
|
|
@@ -3899,7 +3899,12 @@ ORDER BY c.name_last, c.name_first
|
|
$conditions[] = "(c.is_eligible_for_rm = '" . $request->input('rm_eligible') . "')";
|
|
$conditions[] = "(c.is_eligible_for_rm = '" . $request->input('rm_eligible') . "')";
|
|
}
|
|
}
|
|
if($request->input('rm_enrolled')) {
|
|
if($request->input('rm_enrolled')) {
|
|
- $conditions[] = "(c.is_enrolled_in_rm = '" . $request->input('rm_enrolled') . "')";
|
|
|
|
|
|
+ if($request->input('rm_enrolled') === 'YES') {
|
|
|
|
+ $conditions[] = "(cm.is_client_enrolled_in_rm IS TRUE)";
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ $conditions[] = "(cm.is_client_enrolled_in_rm IS NOT TRUE)";
|
|
|
|
+ }
|
|
}
|
|
}
|
|
if($request->input('rm_setup')) {
|
|
if($request->input('rm_setup')) {
|
|
$conditions[] = "(c.has_rm_setup_been_performed IS " . ($request->input('rm_setup') === 'YES' ? 'TRUE' : 'FALSE') . ")";
|
|
$conditions[] = "(c.has_rm_setup_been_performed IS " . ($request->input('rm_setup') === 'YES' ? 'TRUE' : 'FALSE') . ")";
|
|
@@ -3976,7 +3981,7 @@ ORDER BY c.name_last, c.name_first
|
|
cm.start_date,
|
|
cm.start_date,
|
|
c.uid as client_uid,
|
|
c.uid as client_uid,
|
|
c.is_eligible_for_rm,
|
|
c.is_eligible_for_rm,
|
|
- c.is_enrolled_in_rm,
|
|
|
|
|
|
+ cm.is_client_enrolled_in_rm,
|
|
c.has_rm_setup_been_performed,
|
|
c.has_rm_setup_been_performed,
|
|
(c.name_first || ' ' || c.name_last) as client_name,
|
|
(c.name_first || ' ' || c.name_last) as client_name,
|
|
(mcp.name_first || ' ' || mcp.name_last) as mcp_name,
|
|
(mcp.name_first || ' ' || mcp.name_last) as mcp_name,
|