|
@@ -62,7 +62,7 @@ class Pro extends Model
|
|
|
{
|
|
|
return $this->hasMany(ProTeam::class, 'mcp_pro_id', 'id');
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public function teamsWhereAssistant()
|
|
|
{
|
|
|
return $this->hasMany(ProTeam::class, 'assistant_pro_id', 'id');
|
|
@@ -165,7 +165,7 @@ class Pro extends Model
|
|
|
$accesses = VisitTemplateAccess::where('pro_id', $this->id)->where('is_active', true)->pluck('visit_template_id')->toArray();
|
|
|
|
|
|
$allAllowedVisitTemplatesIDs = array_unique(array_merge($allAccessibleVisitTemplatesIDs, $accesses));
|
|
|
-
|
|
|
+
|
|
|
return VisitTemplate::whereIn('id', $allAllowedVisitTemplatesIDs)->get();
|
|
|
}
|
|
|
|
|
@@ -628,7 +628,7 @@ WHERE mcp_pro_id = :pro_id
|
|
|
}
|
|
|
|
|
|
function get_patients_without_remote_measurement_in_48_hours_count_as_mcp() {
|
|
|
- return DB::select("SELECT COUNT(*) as count FROM client WHERE ((most_recent_cellular_measurement_at+ interval '48 hour')::timestamp < NOW() OR most_recent_cellular_measurement_id IS NULL) AND client.mcp_pro_id = :mcp_pro_id AND is_active IS TRUE", ['mcp_pro_id'=>$this->id])[0]->count;
|
|
|
+ return DB::select("SELECT COUNT(*) as count FROM client WHERE ((most_recent_cellular_measurement_at+ interval '48 hour')::timestamp < NOW() OR most_recent_cellular_measurement_id IS NULL) AND client.mcp_pro_id = :mcp_pro_id AND is_active IS TRUE", ['mcp_pro_id'=>$this->id])[0]->count;
|
|
|
}
|
|
|
|
|
|
function get_cancelled_appointments_pending_acknowledgement_count_as_mcp_query() {
|
|
@@ -696,12 +696,12 @@ SELECT count(distinct(care_month.id))
|
|
|
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 bill on care_month.mcp_rm_generic_bill_id = bill.id
|
|
|
left join note mrmnote on mrmnote.id = (
|
|
|
- select max(n.id) from note n
|
|
|
- where
|
|
|
- n.client_id = client.id AND
|
|
|
+ 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 AND
|
|
|
n.effective_dateest::date < (care_month.start_date::date + INTERVAL '1 month')
|
|
|
)
|
|
|
WHERE
|
|
@@ -725,12 +725,12 @@ SELECT count(distinct(care_month.id))
|
|
|
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 bill on care_month.rmm_rm_generic_bill_id = bill.id
|
|
|
left join note mrmnote on mrmnote.id = (
|
|
|
- select max(n.id) from note n
|
|
|
- where
|
|
|
- n.client_id = client.id AND
|
|
|
+ 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 AND
|
|
|
n.effective_dateest::date < (care_month.start_date::date + INTERVAL '1 month')
|
|
|
)
|
|
|
WHERE
|
|
@@ -794,14 +794,14 @@ WHERE
|
|
|
->where('is_status_acknowledgement_from_appointment_pro_pending', true)
|
|
|
//->where('raw_date', '>=', DB::raw('NOW()'))
|
|
|
->orderBy('raw_date', 'asc')
|
|
|
- ->get();
|
|
|
+ ->paginate(20);
|
|
|
}
|
|
|
public function getAppointmentsPendingDecisionAck() {
|
|
|
return Appointment::where('pro_id', $this->id)
|
|
|
->where('is_decision_acknowledgement_from_appointment_pro_pending', true)
|
|
|
//->where('raw_date', '>=', DB::raw('NOW()'))
|
|
|
->orderBy('raw_date', 'asc')
|
|
|
- ->get();
|
|
|
+ ->paginate(20);
|
|
|
}
|
|
|
public function getAppointmentsPendingTimeChangeAck() {
|
|
|
return Appointment::where('pro_id', $this->id)
|
|
@@ -1084,7 +1084,7 @@ WHERE
|
|
|
}
|
|
|
|
|
|
//DNA_DASHBOARD
|
|
|
-
|
|
|
+
|
|
|
//queries
|
|
|
private function patientsQueryAsDna(){
|
|
|
// WHERE na_pro_id = :me.id
|
|
@@ -1118,7 +1118,7 @@ WHERE
|
|
|
->whereNull('today_mcp_appointment_date')
|
|
|
->whereNull('next_mcp_appointment_date');
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private function encountersPendingMyReviewQueryAsDna(){
|
|
|
// WHERE ally_pro_id = me.id AND is_cancelled IS NOT TRUE AND is_signed_by_hcp IS TRUE AND is_signed_by_ally IS NOT TRUE;
|
|
|
return Note::where('ally_pro_id', $this->id)
|
|
@@ -1164,7 +1164,7 @@ WHERE
|
|
|
return $clientQuery->where('rd_pro_id', $myId);
|
|
|
})->where('status', 'PENDING');
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private function cancelledAppointmentsPendingAckQueryAsDna(){
|
|
|
// WHERE client_id IN (SELECT id FROM client WHERE default_na_pro_id = :me.id) AND status = 'CANCELLED' AND is_status_acknowledgement_from_default_na_pending IS TRUE;
|
|
|
$myId = $this->id;
|
|
@@ -1182,7 +1182,7 @@ WHERE
|
|
|
})->where('status', 'CANCELLED')
|
|
|
->where('is_status_acknowledgement_from_default_na_pending', true);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private function reportsPendingAckQueryAsDna(){
|
|
|
// WHERE client_id IN (SELECT id FROM client WHERE default_na_pro_id = :me.id) AND has_na_pro_signed IS FALSE AND is_entry_error
|
|
|
$myId = $this->id;
|
|
@@ -1200,7 +1200,7 @@ WHERE
|
|
|
})->where('has_na_pro_signed', '<>', true)
|
|
|
->where('is_entry_error','<>', true);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private function supplyOrdersPendingMyAckQueryAsDna(){
|
|
|
// WHERE client_id IN (SELECT id FROM client WHERE default_na_pro_id = :me.id) AND has_na_pro_signed IS FALSE AND is_signed_by_pro IS TRUE AND is_cancelled IS NOT TRUE;
|
|
|
$myId = $this->id;
|
|
@@ -1373,8 +1373,8 @@ WHERE
|
|
|
}
|
|
|
|
|
|
public function measurementsPendingReviewAsDna(){
|
|
|
- //Measurements Pending Review
|
|
|
- // SELECT * FROM measurement WHERE client_id IN (SELECT id FROM client WHERE rmm_pro_id = :me.id)
|
|
|
+ //Measurements Pending Review
|
|
|
+ // SELECT * FROM measurement WHERE client_id IN (SELECT id FROM client WHERE rmm_pro_id = :me.id)
|
|
|
// AND has_been_stamped_by_rmm IS FALSE AND is_cellular IS TRUE AND is_cellular_zero IS NOT TRUE AND is_active IS TRUE ORDER BY ts DESC;
|
|
|
$myId = $this->id;
|
|
|
return Measurement::whereHas('client',function($clientQuery) use ($myId) {
|
|
@@ -1417,7 +1417,7 @@ WHERE
|
|
|
$todayMonth = date('m', $today);
|
|
|
$todayYear = date('Y', $today);
|
|
|
if ($todayDate < 15) {
|
|
|
- $nextPaymentDate = new DateTime();
|
|
|
+ $nextPaymentDate = new DateTime();
|
|
|
$nextPaymentDate->setDate($todayYear, $todayMonth, 15);
|
|
|
$nextPaymentDate = $nextPaymentDate->format('m/d/Y');
|
|
|
} else {
|
|
@@ -1429,7 +1429,7 @@ WHERE
|
|
|
|
|
|
return $nextPaymentDate;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public function getNextPaymentDateAsRd(){
|
|
|
$nextPaymentDate = '--';
|
|
|
//if today is < 15th, next payment is 15th, else nextPayment is
|
|
@@ -1439,7 +1439,7 @@ WHERE
|
|
|
$todayMonth = date('m', $today);
|
|
|
$todayYear = date('Y', $today);
|
|
|
if ($todayDate < 15) {
|
|
|
- $nextPaymentDate = new DateTime();
|
|
|
+ $nextPaymentDate = new DateTime();
|
|
|
$nextPaymentDate->setDate($todayYear, $todayMonth, 15);
|
|
|
$nextPaymentDate = $nextPaymentDate->format('m/d/Y');
|
|
|
} else {
|
|
@@ -1544,8 +1544,8 @@ ORDER BY cm.created_at DESC
|
|
|
return Bill::where('bill_service_type', 'GENERIC')
|
|
|
->where('generic_pro_id', $this->id)
|
|
|
->orderBy('created_at', 'DESC')->get();
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
public function myNotesPendingSupervisorPhysicianStamping(){
|
|
|
$pro = $this;
|
|
|
return Note::where('is_stamped_by_supervising_physician', false)->where('is_flagged_for_supervising_physician_review', true)->whereHas('hcpCompanyPro', function($qry) use($pro){
|
|
@@ -1573,15 +1573,15 @@ ORDER BY cm.created_at DESC
|
|
|
crfu.uid,
|
|
|
crfu.next_follow_up_reason,
|
|
|
crfu.next_follow_up_memo,
|
|
|
- pro.name_first as pro_first_name,
|
|
|
+ pro.name_first as pro_first_name,
|
|
|
pro.name_last AS pro_last_name,
|
|
|
c.uid as client_uid,
|
|
|
(c.name_first || ' ' || c.name_last) as client_name,
|
|
|
crfu.status AS status
|
|
|
- FROM client_rep_follow_up crfu
|
|
|
+ FROM client_rep_follow_up crfu
|
|
|
join client c on crfu.id = c.client_rep_follow_up_id
|
|
|
join pro pro on pro.id = crfu.client_rep_pro_id
|
|
|
- WHERE crfu.status = 'SCHEDULED'
|
|
|
+ WHERE crfu.status = 'SCHEDULED'
|
|
|
AND crfu.next_follow_up_date = :date
|
|
|
ORDER BY crfu.created_at DESC;
|
|
|
"), ['date' => date('Y-m-d')]);
|