123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- <?php
- namespace App\Http\Controllers;
- use App\Models\Appointment;
- use App\Models\BDTDevice;
- use App\Models\CareMonth;
- use App\Models\Client;
- use App\Models\ClientBDTDevice;
- use App\Models\ClientInfoLine;
- use App\Models\Erx;
- use App\Models\Facility;
- use App\Models\Handout;
- use App\Models\IncomingReport;
- use App\Models\MBClaim;
- use App\Models\MBPayer;
- use App\Models\Note;
- use App\Models\NoteTemplate;
- use App\Models\Pro;
- use App\Models\Product;
- use App\Models\ProProAccess;
- use App\Models\SectionTemplate;
- use App\Models\Shipment;
- use App\Models\SupplyOrder;
- use App\Models\Ticket;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Facades\File;
- use App\Models\Bill;
- use App\Models\ClientSMS;
- use Illuminate\Support\Facades\Http;
- use PDF;
- class AdminController extends Controller
- {
- public function patients(Request $request)
- {
- $filters = $request->all();
- $patients = Client::whereNull('shadow_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"
- ]
- */
- if ($request->input('name')) {
- $name = trim($request->input('name'));
- if ($name) {
- $patients = $patients->where(function ($q) use ($name) {
- $q->where('name_first', 'ILIKE', '%' . $name . '%')
- ->orWhere('name_last', 'ILIKE', '%' . $name . '%');
- });
- }
- }
- $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_max', '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;
- }
- $initiative = $request->input('initiative');
- if($initiative){
- $wildCardedInitiative = '%'.$initiative.'%';
- $patients->where('initiative', 'ilike', $wildCardedInitiative);
- }
- $include_test_records = $request->input('include_test_records');
- if(!$include_test_records){
- $patients = $patients->where(function ($q) {
- $q->whereNull('client_engagement_status_category')
- ->orWhere('client_engagement_status_category', '<>', 'DUMMY');
- });
- }
- $patients = $patients->orderBy('created_at', 'DESC')->paginate(50);
- return view('app.admin.patients', compact('patients', 'filters'));
- }
- public function notes(Request $request)
- {
- $notes = Note::paginate(5);
- // SELECT * FROM note WHERE client_id IN (SELECT id FROM client WHERE mcp_pro_id = :me.id);
- return view('app.mcp.notes', compact('notes'));
- }
- public function appointments(Request $request)
- {
- $appointments = Appointment::paginate(5);
- return view('app.mcp.appointments', compact('appointments'));
- }
- public function bills(Request $request)
- {
- $bills = Bill::paginate(5);
- return view('app.mcp.bills', compact('bills'));
- }
- public function erx_and_orders(Request $request)
- {
- $erxAndOrders = Erx::paginate(5);
- return view('app.mcp.erx_and_orders', compact('erxAndOrders'));
- }
- public function reports(Request $request)
- {
- $data = [];
- return view('app.mcp.reports', $data);
- }
- public function supply_orders(Request $request)
- {
- $supplyOrders = SupplyOrder::paginate(5);
- return view('app.mcp.supply_orders', compact('supplyOrders'));
- }
- }
|