|
@@ -858,4 +858,155 @@ WHERE mcp_pro_id = :pro_id
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //DNA_DASHBOARD
|
|
|
|
+
|
|
|
|
+ //queries
|
|
|
|
+ private function patientsQueryAsDna(){
|
|
|
|
+ // WHERE na_pro_id = :me.id
|
|
|
|
+ return Client::where('default_na_pro_id', $this->id);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private function patientsAwaitingMcpVisitQueryAsDna(){
|
|
|
|
+ // WHERE has_mcp_done_onboarding_visit <> 'YES'
|
|
|
|
+ return Client::where('default_na_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 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)
|
|
|
|
+ ->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)
|
|
|
|
+ ->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;
|
|
|
|
+ return Appointment::whereHas('client', function($clientQuery) use ($myId) {
|
|
|
|
+ return $clientQuery->where('default_na_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;
|
|
|
|
+ return Appointment::whereHas('client', function($clientQuery) use ($myId) {
|
|
|
|
+ return $clientQuery->where('default_na_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
|
|
|
|
+ $myId = $this->id;
|
|
|
|
+ return IncomingReport::whereHas('client',function($clientQuery) use ($myId) {
|
|
|
|
+ return $clientQuery->where('default_na_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;
|
|
|
|
+ $myId = $this->id;
|
|
|
|
+ return SupplyOrder::whereHas('client',function($clientQuery) use ($myId) {
|
|
|
|
+ return $clientQuery->where('default_na_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;
|
|
|
|
+ return SupplyOrder::whereHas('client',function($clientQuery) use ($myId) {
|
|
|
|
+ return $clientQuery->where('default_na_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();
|
|
|
|
+ }
|
|
|
|
+ public function patientsAwaitingMcpVisitCountAsDna(){
|
|
|
|
+ return $this->patientsAwaitingMcpVisitQueryAsDna()->count();
|
|
|
|
+ }
|
|
|
|
+ public function patientsWithoutAppointmentCountAsDna(){
|
|
|
|
+ return $this->patientsWithoutAppointmentQueryAsDna()->count();
|
|
|
|
+ }
|
|
|
|
+ public function encountersPendingMyReviewCountAsDna(){
|
|
|
|
+ return $this->encountersPendingMyReviewQueryAsDna()->count();
|
|
|
|
+ }
|
|
|
|
+ public function encountersInProgressCountAsDna(){
|
|
|
|
+ return $this->encountersInProgressQueryAsDna()->count();
|
|
|
|
+ }
|
|
|
|
+ public function appointmentsPendingConfirmationCountAsDna(){
|
|
|
|
+ return $this->appointmentsPendingConfirmationQueryAsDna()->count();
|
|
|
|
+ }
|
|
|
|
+ public function cancelledAppointmentsPendingAckCountAsDna(){
|
|
|
|
+ return $this->cancelledAppointmentsPendingAckQueryAsDna()->count();
|
|
|
|
+ }
|
|
|
|
+ public function reportsPendingAckCountAsDna(){
|
|
|
|
+ return $this->reportsPendingAckQueryAsDna()->count();
|
|
|
|
+ }
|
|
|
|
+ public function supplyOrdersPendingMyAckCountAsDna(){
|
|
|
|
+ return $this->supplyOrdersPendingMyAckQueryAsDna()->count();
|
|
|
|
+ }
|
|
|
|
+ public function supplyOrdersPendingHcpApprovalCountAsDna(){
|
|
|
|
+ return $this->supplyOrdersPendingHcpApprovalQueryAsDna()->count();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //records
|
|
|
|
+ private $DNA_RESULTS_PAGE_SIZE = 50;
|
|
|
|
+
|
|
|
|
+ public function patientsRecordsAsDna(){
|
|
|
|
+ return $this->patientsQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
|
|
|
|
+ }
|
|
|
|
+ public function patientsAwaitingMcpVisitRecordsAsDna(){
|
|
|
|
+ return $this->patientsAwaitingMcpVisitQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
|
|
|
|
+ }
|
|
|
|
+ public function patientsWithoutAppointmentRecordsAsDna(){
|
|
|
|
+ return $this->patientsWithoutAppointmentQueryAsDna()->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 encountersInProgressRecordsAsDna(){
|
|
|
|
+ return $this->encountersInProgressQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
|
|
|
|
+ }
|
|
|
|
+ public function appointmentsPendingConfirmationRecordsAsDna(){
|
|
|
|
+ return $this->appointmentsPendingConfirmationQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
|
|
|
|
+ }
|
|
|
|
+ public function cancelledAppointmentsPendingAckRecordsAsDna(){
|
|
|
|
+ return $this->cancelledAppointmentsPendingAckQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
|
|
|
|
+ }
|
|
|
|
+ public function reportsPendingAckRecordsAsDna(){
|
|
|
|
+ return $this->reportsPendingAckQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
|
|
|
|
+ }
|
|
|
|
+ public function supplyOrdersPendingMyAckRecordsAsDna(){
|
|
|
|
+ return $this->supplyOrdersPendingMyAckQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
|
|
|
|
+ }
|
|
|
|
+ public function supplyOrdersPendingHcpApprovalRecordsAsDna(){
|
|
|
|
+ return $this->supplyOrdersPendingHcpApprovalQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|