|
@@ -1100,12 +1100,24 @@ WHERE
|
|
|
return Client::where('default_na_pro_id', $this->id)->where('has_mcp_done_onboarding_visit', '<>', 'YES');
|
|
|
}
|
|
|
|
|
|
+ private function patientsAwaitingMcpVisitQueryAsRd(){
|
|
|
+ // WHERE has_mcp_done_onboarding_visit <> 'YES'
|
|
|
+ return Client::where('rd_pro_id', $this->id)->where('has_mcp_done_onboarding_visit', '<>', 'YES');
|
|
|
+ }
|
|
|
+
|
|
|
private function patientsWithoutAppointmentQueryAsDna(){
|
|
|
// WHERE today_mcp_appointment_date IS NULL AND next_mcp_appointment_date IS NULL
|
|
|
return Client::where('default_na_pro_id', $this->id)
|
|
|
->whereNull('today_mcp_appointment_date')
|
|
|
->whereNull('next_mcp_appointment_date');
|
|
|
}
|
|
|
+
|
|
|
+ private function patientsWithoutAppointmentQueryAsRd(){
|
|
|
+ // WHERE today_mcp_appointment_date IS NULL AND next_mcp_appointment_date IS NULL
|
|
|
+ return Client::where('rd_pro_id', $this->id)
|
|
|
+ ->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;
|
|
@@ -1115,6 +1127,14 @@ WHERE
|
|
|
->where('is_signed_by_ally','<>', true);
|
|
|
}
|
|
|
|
|
|
+ private function encountersPendingMyReviewQueryAsRd(){
|
|
|
+ // 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)
|
|
|
+ ->where('is_cancelled', '<>', true)
|
|
|
+ ->where('is_signed_by_hcp', true)
|
|
|
+ ->where('is_signed_by_ally','<>', true);
|
|
|
+ }
|
|
|
+
|
|
|
private function encountersInProgressQueryAsDna(){
|
|
|
// SELECT * FROM note WHERE ally_pro_id = me.id AND is_cancelled IS NOT TRUE AND is_signed_by_hcp IS NOT TRUE ORDER BY effective_dateest DESC, created_at DESC;
|
|
|
return Note::where('ally_pro_id', $this->id)
|
|
@@ -1122,6 +1142,13 @@ WHERE
|
|
|
->where('is_signed_by_hcp', '<>', true);
|
|
|
}
|
|
|
|
|
|
+ private function encountersInProgressQueryAsRd(){
|
|
|
+ // SELECT * FROM note WHERE ally_pro_id = me.id AND is_cancelled IS NOT TRUE AND is_signed_by_hcp IS NOT TRUE ORDER BY effective_dateest DESC, created_at DESC;
|
|
|
+ return Note::where('ally_pro_id', $this->id)
|
|
|
+ ->where('is_cancelled', '<>', true)
|
|
|
+ ->where('is_signed_by_hcp', '<>', true);
|
|
|
+ }
|
|
|
+
|
|
|
private function appointmentsPendingConfirmationQueryAsDna(){
|
|
|
// WHERE client_id IN (SELECT id FROM client WHERE default_na_pro_id = :me.id) AND status = 'PENDING'
|
|
|
$myId = $this->id;
|
|
@@ -1129,6 +1156,14 @@ WHERE
|
|
|
return $clientQuery->where('default_na_pro_id', $myId);
|
|
|
})->where('status', 'PENDING');
|
|
|
}
|
|
|
+
|
|
|
+ private function appointmentsPendingConfirmationQueryAsRd(){
|
|
|
+ // WHERE client_id IN (SELECT id FROM client WHERE default_na_pro_id = :me.id) AND status = 'PENDING'
|
|
|
+ $myId = $this->id;
|
|
|
+ return Appointment::whereHas('client', function($clientQuery) use ($myId) {
|
|
|
+ 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;
|
|
@@ -1138,6 +1173,15 @@ WHERE
|
|
|
})->where('status', 'CANCELLED')
|
|
|
->where('is_status_acknowledgement_from_default_na_pending', true);
|
|
|
}
|
|
|
+
|
|
|
+ private function cancelledAppointmentsPendingAckQueryAsRd(){
|
|
|
+ // 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;
|
|
|
+ return Appointment::whereHas('client', function($clientQuery) use ($myId) {
|
|
|
+ return $clientQuery->where('rd_pro_id', $myId);
|
|
|
+ })->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
|
|
@@ -1147,6 +1191,15 @@ WHERE
|
|
|
})->where('has_na_pro_signed', '<>', true)
|
|
|
->where('is_entry_error','<>', true);
|
|
|
}
|
|
|
+
|
|
|
+ private function reportsPendingAckQueryAsRd(){
|
|
|
+ // 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;
|
|
|
+ return IncomingReport::whereHas('client',function($clientQuery) use ($myId) {
|
|
|
+ return $clientQuery->where('rd_pro_id', $myId);
|
|
|
+ })->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;
|
|
@@ -1158,6 +1211,16 @@ WHERE
|
|
|
->where('is_cancelled', '<>', true);
|
|
|
}
|
|
|
|
|
|
+ private function supplyOrdersPendingMyAckQueryAsRd(){
|
|
|
+ // 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;
|
|
|
+ return SupplyOrder::whereHas('client',function($clientQuery) use ($myId) {
|
|
|
+ return $clientQuery->where('rd_pro_id', $myId);
|
|
|
+ })->where('has_na_pro_signed', '<>', true)
|
|
|
+ ->where('is_signed_by_pro', true)
|
|
|
+ ->where('is_cancelled', '<>', true);
|
|
|
+ }
|
|
|
+
|
|
|
private function supplyOrdersPendingHcpApprovalQueryAsDna(){
|
|
|
// WHERE client_id IN (SELECT id FROM client WHERE default_na_pro_id = :me.id) AND has_na_pro_signed IS TRUE AND is_signed_by_pro IS NOT TRUE AND is_cancelled IS NOT TRUE;
|
|
|
$myId = $this->id;
|
|
@@ -1168,6 +1231,16 @@ WHERE
|
|
|
->where('is_cancelled', '<>', true);
|
|
|
}
|
|
|
|
|
|
+ private function supplyOrdersPendingHcpApprovalQueryAsRd(){
|
|
|
+ // WHERE client_id IN (SELECT id FROM client WHERE default_na_pro_id = :me.id) AND has_na_pro_signed IS TRUE AND is_signed_by_pro IS NOT TRUE AND is_cancelled IS NOT TRUE;
|
|
|
+ $myId = $this->id;
|
|
|
+ return SupplyOrder::whereHas('client',function($clientQuery) use ($myId) {
|
|
|
+ return $clientQuery->where('rd_pro_id', $myId);
|
|
|
+ })->where('has_na_pro_signed', true)
|
|
|
+ ->where('is_signed_by_pro','<>', true)
|
|
|
+ ->where('is_cancelled', '<>', true);
|
|
|
+ }
|
|
|
+
|
|
|
//counts
|
|
|
public function patientsCountAsDna(){
|
|
|
return $this->patientsQueryAsDna()->count();
|
|
@@ -1178,30 +1251,57 @@ WHERE
|
|
|
public function patientsAwaitingMcpVisitCountAsDna(){
|
|
|
return $this->patientsAwaitingMcpVisitQueryAsDna()->count();
|
|
|
}
|
|
|
+ public function patientsAwaitingMcpVisitCountAsrd(){
|
|
|
+ return $this->patientsAwaitingMcpVisitQueryAsRd()->count();
|
|
|
+ }
|
|
|
public function patientsWithoutAppointmentCountAsDna(){
|
|
|
return $this->patientsWithoutAppointmentQueryAsDna()->count();
|
|
|
}
|
|
|
+ public function patientsWithoutAppointmentCountAsRd(){
|
|
|
+ return $this->patientsWithoutAppointmentQueryAsRd()->count();
|
|
|
+ }
|
|
|
public function encountersPendingMyReviewCountAsDna(){
|
|
|
return $this->encountersPendingMyReviewQueryAsDna()->count();
|
|
|
}
|
|
|
+ public function encountersPendingMyReviewCountAsRd(){
|
|
|
+ return $this->encountersPendingMyReviewQueryAsRd()->count();
|
|
|
+ }
|
|
|
public function encountersInProgressCountAsDna(){
|
|
|
return $this->encountersInProgressQueryAsDna()->count();
|
|
|
}
|
|
|
+ public function encountersInProgressCountAsRd(){
|
|
|
+ return $this->encountersInProgressQueryAsRd()->count();
|
|
|
+ }
|
|
|
public function appointmentsPendingConfirmationCountAsDna(){
|
|
|
return $this->appointmentsPendingConfirmationQueryAsDna()->count();
|
|
|
}
|
|
|
+ public function appointmentsPendingConfirmationCountAsRd(){
|
|
|
+ return $this->appointmentsPendingConfirmationQueryAsRd()->count();
|
|
|
+ }
|
|
|
public function cancelledAppointmentsPendingAckCountAsDna(){
|
|
|
return $this->cancelledAppointmentsPendingAckQueryAsDna()->count();
|
|
|
}
|
|
|
+ public function cancelledAppointmentsPendingAckCountAsRd(){
|
|
|
+ return $this->cancelledAppointmentsPendingAckQueryAsRd()->count();
|
|
|
+ }
|
|
|
public function reportsPendingAckCountAsDna(){
|
|
|
return $this->reportsPendingAckQueryAsDna()->count();
|
|
|
}
|
|
|
+ public function reportsPendingAckCountAsRd(){
|
|
|
+ return $this->reportsPendingAckQueryAsRd()->count();
|
|
|
+ }
|
|
|
public function supplyOrdersPendingMyAckCountAsDna(){
|
|
|
return $this->supplyOrdersPendingMyAckQueryAsDna()->count();
|
|
|
}
|
|
|
+ public function supplyOrdersPendingMyAckCountAsRd(){
|
|
|
+ return $this->supplyOrdersPendingMyAckQueryAsRd()->count();
|
|
|
+ }
|
|
|
public function supplyOrdersPendingHcpApprovalCountAsDna(){
|
|
|
return $this->supplyOrdersPendingHcpApprovalQueryAsDna()->count();
|
|
|
}
|
|
|
+ public function supplyOrdersPendingHcpApprovalCountAsRd(){
|
|
|
+ return $this->supplyOrdersPendingHcpApprovalQueryAsRd()->count();
|
|
|
+ }
|
|
|
|
|
|
//records
|
|
|
private $DNA_RESULTS_PAGE_SIZE = 50;
|
|
@@ -1212,33 +1312,65 @@ WHERE
|
|
|
public function patientsAwaitingMcpVisitRecordsAsDna(){
|
|
|
return $this->patientsAwaitingMcpVisitQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
|
|
|
}
|
|
|
+ public function patientsAwaitingMcpVisitRecordsAsRd(){
|
|
|
+ return $this->patientsAwaitingMcpVisitQueryAsRd()->paginate($this->DNA_RESULTS_PAGE_SIZE);
|
|
|
+ }
|
|
|
public function patientsWithoutAppointmentRecordsAsDna(){
|
|
|
return $this->patientsWithoutAppointmentQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
|
|
|
}
|
|
|
+ public function patientsWithoutAppointmentRecordsAsRd(){
|
|
|
+ return $this->patientsWithoutAppointmentQueryAsRd()->paginate($this->DNA_RESULTS_PAGE_SIZE);
|
|
|
+ }
|
|
|
public function encountersPendingMyReviewRecordsAsDna(){
|
|
|
return $this->encountersPendingMyReviewQueryAsDna()
|
|
|
->orderBy('effective_dateest', 'desc')
|
|
|
->orderBy('created_at', 'desc')
|
|
|
->paginate($this->DNA_RESULTS_PAGE_SIZE);
|
|
|
}
|
|
|
+ public function encountersPendingMyReviewRecordsAsRd(){
|
|
|
+ return $this->encountersPendingMyReviewQueryAsRd()
|
|
|
+ ->orderBy('effective_dateest', 'desc')
|
|
|
+ ->orderBy('created_at', 'desc')
|
|
|
+ ->paginate($this->DNA_RESULTS_PAGE_SIZE);
|
|
|
+ }
|
|
|
public function encountersInProgressRecordsAsDna(){
|
|
|
return $this->encountersInProgressQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
|
|
|
}
|
|
|
+
|
|
|
+ public function encountersInProgressRecordsAsRd(){
|
|
|
+ return $this->encountersInProgressQueryAsRd()->paginate($this->DNA_RESULTS_PAGE_SIZE);
|
|
|
+ }
|
|
|
+
|
|
|
public function appointmentsPendingConfirmationRecordsAsDna(){
|
|
|
return $this->appointmentsPendingConfirmationQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
|
|
|
}
|
|
|
+ public function appointmentsPendingConfirmationRecordsAsRd(){
|
|
|
+ return $this->appointmentsPendingConfirmationQueryAsRd()->paginate($this->DNA_RESULTS_PAGE_SIZE);
|
|
|
+ }
|
|
|
public function cancelledAppointmentsPendingAckRecordsAsDna(){
|
|
|
return $this->cancelledAppointmentsPendingAckQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
|
|
|
}
|
|
|
+ public function cancelledAppointmentsPendingAckRecordsAsRd(){
|
|
|
+ return $this->cancelledAppointmentsPendingAckQueryAsRd()->paginate($this->DNA_RESULTS_PAGE_SIZE);
|
|
|
+ }
|
|
|
public function reportsPendingAckRecordsAsDna(){
|
|
|
return $this->reportsPendingAckQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
|
|
|
}
|
|
|
+ public function reportsPendingAckRecordsAsRd(){
|
|
|
+ return $this->reportsPendingAckQueryAsRd()->paginate($this->DNA_RESULTS_PAGE_SIZE);
|
|
|
+ }
|
|
|
public function supplyOrdersPendingMyAckRecordsAsDna(){
|
|
|
return $this->supplyOrdersPendingMyAckQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
|
|
|
}
|
|
|
+ public function supplyOrdersPendingMyAckRecordsAsRd(){
|
|
|
+ return $this->supplyOrdersPendingMyAckQueryAsRd()->paginate($this->DNA_RESULTS_PAGE_SIZE);
|
|
|
+ }
|
|
|
public function supplyOrdersPendingHcpApprovalRecordsAsDna(){
|
|
|
return $this->supplyOrdersPendingHcpApprovalQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
|
|
|
}
|
|
|
+ public function supplyOrdersPendingHcpApprovalRecordsAsRd(){
|
|
|
+ return $this->supplyOrdersPendingHcpApprovalQueryAsRd()->paginate($this->DNA_RESULTS_PAGE_SIZE);
|
|
|
+ }
|
|
|
|
|
|
public function measurementsPendingReviewAsDna(){
|
|
|
//Measurements Pending Review
|