|
@@ -2447,4 +2447,59 @@ ORDER BY c.name_last, c.name_first
|
|
|
$patients = $patients->orderBy('created_at', 'DESC')->paginate(20);
|
|
|
return view('app.admin.client-ccm-rm-status', compact('patients', 'filters'));
|
|
|
}
|
|
|
+
|
|
|
+ public function rmActionReport(Request $request){
|
|
|
+
|
|
|
+
|
|
|
+ $careMonthStartDate = $request->get('care_month_start_date');
|
|
|
+ $numOfMeasurements = $request->get('num_of_measurements'); //16_or_more, 12_or_more
|
|
|
+
|
|
|
+ $hasRecentVisit = $request->get('has_recent_visit'); //yes no
|
|
|
+ $hasBeenSpokenToThisMonth = $request('has_been_spoken_to'); //yes no
|
|
|
+
|
|
|
+ $cmQuery = CareMonth::where('start_date', $careMonthStartDate);
|
|
|
+
|
|
|
+ if($numOfMeasurements){
|
|
|
+ if($numOfMeasurements == '16_or_more'){
|
|
|
+ $cmQuery = $cmQuery->where('number_of_days_with_remote_measurements', '>=', 16);
|
|
|
+ }
|
|
|
+ if($numOfMeasurements == '12_or_more'){
|
|
|
+ $cmQuery = $cmQuery->where('number_of_days_with_remote_measurements', '>=', 12);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if($hasRecentVisit){
|
|
|
+ if($hasRecentVisit == 'YES'){
|
|
|
+ $cmQuery = $cmQuery->whereHas('client', function($clientQuery) {
|
|
|
+ return $clientQuery->whereRaw("most_recent_completed_mcp_note_date::DATE >= (NOW() - interval '60 days')::DATE)");
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ $cmQuery = $cmQuery->whereHas('client', function($clientQuery) {
|
|
|
+ return $clientQuery->whereRaw("most_recent_completed_mcp_note_date::DATE < (NOW() - interval '60 days')::DATE)");
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if($hasBeenSpokenToThisMonth){
|
|
|
+ if($hasBeenSpokenToThisMonth == 'YES'){
|
|
|
+ $cmQuery = $cmQuery->where('has_anyone_interacted_with_client_about_rm_outside_note', '=', true);
|
|
|
+ }else{
|
|
|
+ $cmQuery = $cmQuery->where('has_anyone_interacted_with_client_about_rm_outside_note', '=', false);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private function getCareMonthsWith16OrMoreMeasurements(){
|
|
|
+ return CareMonth::where('number_of_days_with_remote_measurements' , '>=', '16');
|
|
|
+ }
|
|
|
+
|
|
|
+ private function getCareMonthsWith12OrMoreMeasurements(){
|
|
|
+ return CareMonth::where('number_of_days_with_remote_measurements' , '>=', '12');
|
|
|
+ }
|
|
|
+
|
|
|
+ private function getCareMonthsWith12OrMoreMeasurements(){
|
|
|
+ return CareMonth::where('number_of_days_with_remote_measurements' , '>=', '12');
|
|
|
+ }
|
|
|
}
|