all(); $patients = Client::whereNull('shadow_pro_id')->where('default_na_pro_id', $this->performer->pro->id); // filters /* array:18 [▼ "age_category" => "LESS_THAN" "age_value_1" => "34" "age_value_2" => null "sex" => "M" "bmi_category" => "BETWEEN" "bmi_value_1" => "20" "bmi_value_2" => "25" "last_visit_category" => "LESS_THAN" "last_visit_value_1" => "2021-10-14" "last_visit_value_2" => null "next_appointment_category" => "LESS_THAN" "next_appointment_value_1" => "2021-10-15" "status" => "ACTIVE" "last_weighed_in_category" => "EXACTLY" "last_weighed_in_value_1" => "2021-10-07" "last_bp_category" => "BETWEEN" "last_bp_value_1" => "2021-10-01" "last_bp_value_2" => "2021-10-31" ] */ $this->filterMultiQuery($request, $patients, 'age_in_years', 'age_category', 'age_value_1', 'age_value_2'); $this->filterSimpleQuery($request, $patients, 'sex', 'sex'); $this->filterMultiQuery($request, $patients, 'usual_bmi', 'bmi_category', 'bmi_value_1', 'bmi_value_2'); $this->filterMultiQuery($request, $patients, 'most_recent_weight_at', 'last_weighed_in_category', 'last_weighed_in_value_1', 'last_weighed_in_value_2'); $this->filterMultiQuery($request, $patients, 'most_recent_bp_at', 'last_bp_category', 'last_bp_value_1', 'last_bp_value_2'); switch($request->input('status')) { case 'ACTIVE': $patients->where('is_active', true)->where('has_mcp_done_onboarding_visit', true); break; case 'AWAITING_VISIT': $patients->where('is_active', true)->where('has_mcp_done_onboarding_visit', false); break; case 'INACTIVE': $patients->where('is_active', '<>', true); break; } $patients = $patients->orderBy('created_at', 'DESC')->paginate(20); return view('app.dna.patients', compact('patients', 'filters')); } public function filterSimpleQuery(Request $request, $query, $columnName, $valueName) { if($request->input($valueName)) { $query->where($columnName, $request->input($valueName)); } } public function filterMultiQuery(Request $request, $query, $columnName, $keyName, $valueName1, $valueName2) { switch($request->input($keyName)) { case 'EXACTLY': if($request->input($valueName1)) { $query->where($columnName, $request->input($valueName1)); } break; case 'LESS_THAN': if($request->input($valueName1)) { $query->where($columnName, '<', $request->input($valueName1)); } break; case 'GREATER_THAN': if($request->input($valueName1)) { $query->where($columnName, '>', $request->input($valueName1)); } break; case 'BETWEEN': if($request->input($valueName1) && $request->input($valueName2)) { $query ->where($columnName, '>=', $request->input($valueName1)) ->where($columnName, '<=', $request->input($valueName2)); } break; case 'NOT_BETWEEN': if($request->input($valueName1) && $request->input($valueName2)) { $query ->where(function ($q) use ($request, $columnName, $valueName1, $valueName2) { $q->where($columnName, '<', $request->input($valueName1)) ->orWhere($columnName, '>', $request->input($valueName2)); }); } break; } } public function notes(Request $request) { $data = []; return view('app.dna.notes', $data); } public function appointments(Request $request) { $data = []; return view('app.dna.appointments', $data); } public function bills(Request $request) { $data = []; return view('app.dna.bills', $data); } public function erx_and_orders(Request $request) { $data = []; return view('app.dna.erx_and_orders', $data); } public function reports(Request $request) { $data = []; return view('app.dna.reports', $data); } public function supply_orders(Request $request) { $data = []; return view('app.dna.supply_orders', $data); } public function new_patients_awaiting_visit(Request $request){ $data = []; return view('app.dna.new_patients_awaiting_visit', $data); } public function notes_pending_signature(Request $request){ $data = []; return view('app.dna.notes_pending_signature', $data); } public function notes_pending_billing(Request $request){ $data = []; return view('app.dna.notes_pending_billing', $data); } public function reports_pending_signature(Request $request){ $data = []; return view('app.dna.reports_pending_signature', $data); } public function patients_without_appointments(Request $request){ $data = []; return view('app.dna.patients_without_appointments', $data); } public function patients_overdue_for_visit(Request $request){ $data = []; return view('app.dna.patients_overdue_for_visit', $data); } public function cancelled_appointments_pending_review(Request $request){ $data = []; return view('app.dna.cancelled_appointments_pending_review', $data); } public function cancelled_bills_pending_review(Request $request){ $data = []; return view('app.dna.cancelled_bills_pending_review', $data); } public function cancelled_supply_orders_pending_review(Request $request){ $data = []; return view('app.dna.cancelled_supply_orders_pending_review', $data); } public function erx_and_orders_pending_signature(Request $request){ $data = []; return view('app.dna.erx_and_orders_pending_signature', $data); } public function supply_orders_pending_signature(Request $request){ $data = []; return view('app.dna.supply_orders_pending_signature', $data); } //From the new spec public function patientsCountAsDna(){ $pro = $this->performer->pro; $records = $pro->patientsRecordsAsDna(); return view('app.dna.patients_count_as_dna', $records); } public function patientsAwaitingMcpVisitCountAsDna(){ $pro = $this->performer->pro; $records = $pro->patientsAwaitingMcpVisitRecordsAsDna(); return view('app.dna.patients_awaiting_mcp_visit_count_as_dna', $records); } public function patientsWithoutAppointmentCountAsDna(){ $pro = $this->performer->pro; $records = $pro->patientsWithoutAppointmentRecordsAsDna(); return view('app.dna.patients_without_appointment_count_as_dna', $records); } public function encountersPendingMyReviewCountAsDna(){ $pro = $this->performer->pro; $records = $pro->encountersPendingMyReviewRecordsAsDna(); return view('app.dna.encounters_pending_my_review_count_as_dna', $records); } public function encountersInProgressCountAsDna(){ $pro = $this->performer->pro; $records = $pro->encountersInProgressRecordsAsDna(); return view('app.dna.encounters_in_progress_count_as_dna', $records); } public function appointmentsPendingConfirmationCountAsDna(){ $pro = $this->performer->pro; $records = $pro->appointmentsPendingConfirmationRecordsAsDna(); return view('app.dna.appointments_pending_confirmation_count_as_dna', $records); } public function cancelledAppointmentsPendingAckCountAsDna(){ $pro = $this->performer->pro; $records = $pro->cancelledAppointmentsPendingAckRecordsAsDna(); return view('app.dna.cancelled_appointments_pending_ack_count_as_dna', $records); } public function reportsPendingAckCountAsDna(){ $pro = $this->performer->pro; $records = $pro->reportsPendingAckRecordsAsDna(); return view('app.dna.reports_pending_ack_count_as_dna', $records); } public function supplyOrdersPendingMyAckCountAsDna(){ $pro = $this->performer->pro; $records = $pro->supplyOrdersPendingMyAckRecordsAsDna(); return view('app.dna.supply_orders_pending_my_ack_count_as_dna', $records); } public function supplyOrdersPendingHcpApprovalCountAsDna(){ $pro = $this->performer->pro; $records = $pro->supplyOrdersPendingHcpApprovalRecordsAsDna(); return view('app.dna.supply_orders_pending_hcp_approval_count_as_dna', $records); } }