McpController.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Models\Appointment;
  4. use App\Models\BDTDevice;
  5. use App\Models\CareMonth;
  6. use App\Models\Client;
  7. use App\Models\ClientBDTDevice;
  8. use App\Models\ClientInfoLine;
  9. use App\Models\Erx;
  10. use App\Models\Facility;
  11. use App\Models\Handout;
  12. use App\Models\IncomingReport;
  13. use App\Models\MBClaim;
  14. use App\Models\MBPayer;
  15. use App\Models\Measurement;
  16. use App\Models\Note;
  17. use App\Models\NoteTemplate;
  18. use App\Models\Pro;
  19. use App\Models\Product;
  20. use App\Models\ProProAccess;
  21. use App\Models\SectionTemplate;
  22. use App\Models\Shipment;
  23. use App\Models\SupplyOrder;
  24. use App\Models\Ticket;
  25. use Illuminate\Http\Request;
  26. use Illuminate\Support\Facades\DB;
  27. use Illuminate\Support\Facades\File;
  28. use App\Models\Bill;
  29. use App\Models\ClientSMS;
  30. use App\Models\AccountInvite;
  31. use App\Models\ClientMemo;
  32. use Illuminate\Support\Facades\Http;
  33. use PDF;
  34. class McpController extends Controller
  35. {
  36. public function patients(Request $request)
  37. {
  38. $filters = $request->all();
  39. $patients = Client::whereNull('shadow_pro_id');
  40. //TODO: implement in admin controller
  41. if($this->performer->pro->pro_type != 'ADMIN'){
  42. $patients->where('mcp_pro_id', $this->performer->pro->id);
  43. }
  44. // filters
  45. /*
  46. array:18 [▼
  47. "age_category" => "LESS_THAN"
  48. "age_value_1" => "34"
  49. "age_value_2" => null
  50. "sex" => "M"
  51. "bmi_category" => "BETWEEN"
  52. "bmi_value_1" => "20"
  53. "bmi_value_2" => "25"
  54. "last_visit_category" => "LESS_THAN"
  55. "last_visit_value_1" => "2021-10-14"
  56. "last_visit_value_2" => null
  57. "next_appointment_category" => "LESS_THAN"
  58. "next_appointment_value_1" => "2021-10-15"
  59. "status" => "ACTIVE"
  60. "last_weighed_in_category" => "EXACTLY"
  61. "last_weighed_in_value_1" => "2021-10-07"
  62. "last_bp_category" => "BETWEEN"
  63. "last_bp_value_1" => "2021-10-01"
  64. "last_bp_value_2" => "2021-10-31"
  65. ]
  66. */
  67. if ($request->input('name')) {
  68. $name = trim($request->input('name'));
  69. if ($name) {
  70. $patients = $patients->where(function ($q) use ($name) {
  71. $q->where('name_first', 'ILIKE', '%' . $name . '%')
  72. ->orWhere('name_last', 'ILIKE', '%' . $name . '%');
  73. });
  74. }
  75. }
  76. if ($request->input('home_address_state')) {
  77. if($request->input('home_address_state') == 'NONE'){
  78. $patients = $patients->whereNull('mailing_address_state');
  79. }else if($request->input('home_address_state') == 'NOT_MD'){
  80. $patients = $patients->where('mailing_address_state', '<>' , 'MD');
  81. }else{
  82. $patients = $patients->where('mailing_address_state', '=' , $request->input('home_address_state'));
  83. }
  84. }
  85. $this->filterMultiQuery($request, $patients, 'age_in_years', 'age_category', 'age_value_1', 'age_value_2', false);
  86. $this->filterSimpleQuery($request, $patients, 'sex', 'sex');
  87. $this->filterMultiQuery($request, $patients, 'usual_bmi_max', 'bmi_category', 'bmi_value_1', 'bmi_value_2', false);
  88. $this->filterMultiQuery($request, $patients, 'most_recent_weight_at', 'last_weighed_in_category', 'last_weighed_in_value_1', 'last_weighed_in_value_2');
  89. $this->filterMultiQuery($request, $patients, 'most_recent_bp_at', 'last_bp_category', 'last_bp_value_1', 'last_bp_value_2');
  90. $this->filterMultiQuery($request, $patients, 'most_recent_completed_mcp_note_date', 'last_visit_category', 'last_visit_value_1', 'last_visit_value_2');
  91. $status = $request->input('status');
  92. if($status){
  93. if($status === 'ACTIVE'){
  94. $patients->where('is_active', true)->where(function($q) use ($status){
  95. return $q->where('client_engagement_status_category', $status)
  96. ->orWhereNull('client_engagement_status_category');
  97. });
  98. }elseif($status === 'NONE'){
  99. $patients->whereNull('client_engagement_status_category');
  100. }else {
  101. $patients->where('client_engagement_status_category', $status);
  102. }
  103. }
  104. $initiative = $request->input('initiative');
  105. if($initiative){
  106. $wildCardedInitiative = '%'.$initiative.'%';
  107. $patients->where('initiative', 'ilike', $wildCardedInitiative);
  108. }
  109. $include_test_records = $request->input('include_test_records');
  110. if(!$include_test_records){
  111. $patients = $patients->where(function ($q) {
  112. $q->whereNull('client_engagement_status_category')
  113. ->orWhere('client_engagement_status_category', '<>', 'DUMMY');
  114. });
  115. }
  116. if ($request->input('next_appointment_category')) {
  117. if($request->input('next_appointment_category') == 'NONE'){
  118. $patients = $patients->whereNull('next_mcp_appointment_id');
  119. }else{
  120. $self = $this;
  121. $patients = $patients->whereHas('nextMcpAppointment', function($pQry) use ($request, $self){
  122. return $self->filterMultiQuery($request, $pQry, 'raw_date', 'next_appointment_category', 'next_appointment_value_1', 'next_appointment_value_2');
  123. });
  124. }
  125. }
  126. if ($request->input('chart_number')) {
  127. $patients = $patients->where('chart_number', 'ILIKE' , '%'.$request->input('chart_number').'%');
  128. }
  129. $sortBy = $request->input('sort_by') ?: 'name_first';
  130. $sortDir = $request->input('sort_dir') ?: 'ASC';
  131. $patients = $patients->orderByRaw("$sortBy $sortDir NULLS LAST");
  132. $patients = $patients->orderBy('created_at', 'DESC')->paginate(50);
  133. return view('app.mcp.patients', compact('patients', 'filters'));
  134. }
  135. public function notes(Request $request)
  136. {
  137. $filters = $request->all();
  138. $notes = Note::query();
  139. $notes = $notes->where('hcp_pro_id', $this->performer->pro->id);
  140. $this->filterMultiQuery($request, $notes, 'effective_time', 'date_category', 'date_value_1', 'date_value_2');
  141. $this->filterSimpleQuery($request, $notes, 'new_or_fu_or_na', 'new_or_fu_or_na');
  142. $notes = $notes->orderBy('created_at', 'DESC')->paginate(20);
  143. return view('app.mcp.notes', compact('notes','filters'));
  144. }
  145. public function appointments(Request $request)
  146. {
  147. $filters = $request->all();
  148. $appointments = Appointment::where('pro_id', $this->performer->pro->id);
  149. $this->filterMultiQuery($request, $appointments, 'raw_date', 'date_category', 'date_value_1', 'date_value_2');
  150. $this->filterSimpleQuery($request, $appointments, 'status', 'status');
  151. $appointments = $appointments->orderBy('end_time', 'DESC')->paginate(20);
  152. return view('app.mcp.appointments', compact('appointments', 'filters'));
  153. }
  154. public function bills(Request $request)
  155. {
  156. $filters = $request->all();
  157. $bills = Bill::where('hcp_pro_id', $this->performer->pro->id);
  158. $this->filterMultiQuery($request, $bills, 'created_at', 'date_category', 'date_value_1', 'date_value_2');
  159. $status = $request->get('status');
  160. if($status){
  161. if($status == 'CANCELLED') $bills = $bills->where('is_cancelled', true);
  162. if($status == 'NOT_CANCELLED') $bills = $bills->where('is_cancelled', false);
  163. }
  164. $bills = $bills->orderBy('created_at', 'DESC')->paginate(20);
  165. return view('app.mcp.bills', compact('bills', 'filters'));
  166. }
  167. public function clients_bdt_devices(Request $request){
  168. $filters = $request->all();
  169. $devices = ClientBDTDevice::select('client_bdt_device.*')
  170. ->join('client', 'client.id', '=', 'client_bdt_device.client_id')
  171. ->where('client.mcp_pro_id', $this->performer->pro->id);
  172. $this->filterMultiQuery($request, $devices, 'client_bdt_device.created_at', 'date_category', 'date_value_1', 'date_value_2');
  173. $status = $request->get('status');
  174. if($status){
  175. if($status === 'ACTIVE') $devices = $devices->where('client_bdt_device.is_active', true);
  176. if($status === 'DEACTIVATED') $devices = $devices->where('client_bdt_device.is_active', false);
  177. }
  178. $devices = $devices->orderBy('created_at', 'DESC')->paginate(20);
  179. return view('app.mcp.clients_bdt_devices', compact('devices', 'filters'));
  180. }
  181. public function memos(Request $request){
  182. $filters = $request->all();
  183. $memos = ClientMemo::select('client_memo.*')
  184. ->join('client', 'client.id', '=', 'client_memo.client_id')
  185. ->where('client.mcp_pro_id', $this->performer->pro->id);
  186. $this->filterMultiQuery($request, $memos, 'client_memo.created_at', 'date_category', 'date_value_1', 'date_value_2');
  187. $this->filterSimpleQuery($request, $memos, 'category', 'category');
  188. $memos = $memos->orderBy('created_at', 'DESC')->paginate(20);
  189. return view('app.mcp.memos', compact('memos', 'filters'));
  190. }
  191. public function erx_and_orders(Request $request)
  192. {
  193. $filters = $request->all();
  194. $erxAndOrders = Erx::query();
  195. $erxAndOrders = $erxAndOrders->where('hcp_pro_id', $this->performer->pro->id);
  196. $this->filterMultiQuery($request, $erxAndOrders, 'created_at', 'date_category', 'date_value_1', 'date_value_2');
  197. $this->filterSimpleQuery($request, $erxAndOrders, 'pro_declared_status', 'status');
  198. $erxAndOrders = $erxAndOrders->orderBy('created_at', 'DESC')->paginate(20);
  199. return view('app.mcp.erx_and_orders', compact('erxAndOrders', 'filters'));
  200. }
  201. public function reports(Request $request)
  202. {
  203. $filters = $request->all();
  204. $reports = IncomingReport::where('hcp_pro_id', $this->performer->pro->id);
  205. $this->filterMultiQuery($request, $reports, 'report_date', 'date_category', 'date_value_1', 'date_value_2');
  206. $status = $request->get('status');
  207. if($status){
  208. if($status == 'SIGNED') $reports = $reports->where('has_hcp_pro_signed', true);
  209. if($status == 'NOT_SIGNED') $reports = $reports->where('has_hcp_pro_signed', false);
  210. }
  211. $reports = $reports->orderBy('created_at', 'DESC')->paginate(20);
  212. return view('app.mcp.reports', compact('reports', 'filters'));
  213. }
  214. public function supply_orders(Request $request)
  215. {
  216. $filters = $request->all();
  217. $supplyOrders = SupplyOrder::select('supply_order.*')->where('supply_order.signed_by_pro_id', $this->performer->pro->id);
  218. $this->filterMultiQuery($request, $supplyOrders, 'created_at', 'date_category', 'date_value_1', 'date_value_2');
  219. $status = $request->get('status');
  220. if($status){
  221. if($status == 'CLEARED_FOR_SHIPMENT'){
  222. $supplyOrders = $supplyOrders->where('is_cleared_for_shipment', true);
  223. }elseif($status == 'NOT_CLEARED_FOR_SHIPMENT'){
  224. $supplyOrders = $supplyOrders->where('is_cleared_for_shipment', false);
  225. }elseif($status == 'CANCELLED'){
  226. $supplyOrders = $supplyOrders->where('is_cancelled', true);
  227. }else{
  228. $supplyOrders = $supplyOrders->join('shipment', 'shipment.id', '=', 'supply_order.shipment_id')->where('shipment.status', $status);
  229. }
  230. }
  231. $supplyOrders = $supplyOrders->orderBy('created_at', 'DESC')->paginate(20);
  232. return view('app.mcp.supply_orders', compact('supplyOrders', 'filters'));
  233. }
  234. public function client_messages(Request $request)
  235. {
  236. $filters = $request->all();
  237. $clientMessages = ClientSMS::select('client_sms.*')
  238. ->join('client', 'client.id', '=', 'client_sms.client_id')
  239. ->where('client.mcp_pro_id', $this->performer->pro->id);
  240. $this->filterMultiQuery($request, $clientMessages, 'client_sms.created_at', 'date_category', 'date_value_1', 'date_value_2');
  241. $this->filterSimpleQuery($request, $clientMessages, 'sms_status', 'sms_status');
  242. $clientMessages = $clientMessages->orderBy('client_sms.created_at', 'DESC');
  243. $clientMessages = $clientMessages->paginate(20);
  244. return view('app.mcp.client_messages', compact('clientMessages', 'filters'));
  245. }
  246. public function patients_accounts_invites(Request $request){
  247. $filters = $request->all();
  248. $accountInvites = AccountInvite::select('account_invite.*')
  249. ->join('client', 'client.id', '=', 'account_invite.for_client_id');
  250. $accountInvites = $accountInvites->where('client.mcp_pro_id', $this->performer->pro->id);
  251. $this->filterMultiQuery($request, $accountInvites, 'account_invite.created_at', 'date_category', 'date_value_1', 'date_value_2');
  252. $this->filterSimpleQuery($request, $accountInvites, 'account_invite.status', 'status');
  253. $accountInvites = $accountInvites->orderBy('created_at', 'DESC')->paginate(20);
  254. return view('app.mcp.patients-accounts-invites', compact('accountInvites', 'filters'));
  255. }
  256. public function new_patients_awaiting_visit(Request $request){
  257. $data = [
  258. 'records' => Client::where('mcp_pro_id', $this->performer->pro->id)
  259. ->where('has_mcp_done_onboarding_visit', '!=', 'YES')
  260. ->orderBy('created_at')
  261. ->get()
  262. ];
  263. return view('app.mcp.new_patients_awaiting_visit', $data);
  264. }
  265. public function notes_pending_signature(Request $request){
  266. $data = [
  267. 'records' => Note::where('hcp_pro_id', $this->performer->pro->id)
  268. ->where('is_cancelled', '<>', true)
  269. ->where('is_signed_by_hcp', '<>', true)
  270. ->where('is_core_note', false)
  271. ->orderBy('created_at')
  272. ->get()
  273. ];
  274. return view('app.mcp.notes_pending_signature', $data);
  275. }
  276. public function notes_pending_summary_suggestion(Request $request){
  277. $pro = $this->performer->pro;
  278. $data = [
  279. 'records' => $pro->get_notes_pending_summary_suggestion_as_mcp()
  280. ];
  281. return view('app.mcp.notes_pending_summary_suggestion', $data);
  282. }
  283. public function notes_rejected_summary_suggestion(Request $request){
  284. $pro = $this->performer->pro;
  285. $data = [
  286. 'records' => $pro->get_notes_rejected_summary_suggestion_as_mcp()
  287. ];
  288. return view('app.mcp.notes_rejected_summary_suggestion', $data);
  289. }
  290. public function notes_pending_billing(Request $request){
  291. $data = [
  292. 'records' => Note::where('hcp_pro_id', $this->performer->pro->id)
  293. ->where('is_cancelled', '<>', true)
  294. ->where('is_signed_by_hcp', true)
  295. ->where('is_billing_marked_done', '<>', true)
  296. ->orderBy('created_at')
  297. ->get()
  298. ];
  299. return view('app.mcp.notes_pending_billing', $data);
  300. }
  301. public function bills_pending_signature(Request $request){
  302. $data = [
  303. 'records' => Bill::where('bill_service_type', '<>', 'CARE_MONTH')->where(function ($query) {
  304. $query->where('hcp_pro_id', $this->performer->pro->id)->where('is_signed_by_hcp', false)->where('is_cancelled', false);
  305. })
  306. ->orWhere(function ($query) {
  307. $query->where('cm_pro_id', $this->performer->pro->id)->where('is_signed_by_cm', false)->where('is_cancelled', false);
  308. })->orWhere(function ($query) {
  309. $query->where('rme_pro_id', $this->performer->pro->id)->where('is_signed_by_rme', false)->where('is_cancelled', false);
  310. })->orWhere(function ($query) {
  311. $query->where('rmm_pro_id', $this->performer->pro->id)->where('is_signed_by_rmm', false)->where('is_cancelled', false);
  312. })->orWhere(function ($query) {
  313. $query->where('generic_pro_id', $this->performer->pro->id)->where('is_signed_by_generic_pro', false)->where('is_cancelled', false);
  314. })
  315. ->orderBy('created_at', 'DESC')
  316. ->get()
  317. ];
  318. return view('app.mcp.bills_pending_signature', $data);
  319. }
  320. public function reports_pending_signature(Request $request){
  321. $data = [
  322. 'records' => IncomingReport::where('hcp_pro_id', $this->performer->pro->id)
  323. ->where('has_hcp_pro_signed', '<>', true)
  324. ->where('is_entry_error', '<>', true)
  325. ->orderBy('created_at')
  326. ->get()
  327. ];
  328. return view('app.mcp.reports_pending_signature', $data);
  329. }
  330. public function patients_without_appointments(Request $request){
  331. $patients = $this->performer->pro->get_patients_without_appointment_query()->paginate(20);
  332. return view('app.mcp.patients_without_appointments', compact('patients'));
  333. }
  334. public function patients_overdue_for_visit(Request $request){
  335. $patients = $this->performer->pro->get_patients_overdue_for_visit_query()->paginate(20);
  336. return view('app.mcp.patients_overdue_for_visit', compact('patients'));
  337. }
  338. public function cancelled_appointments_pending_review(Request $request){
  339. $data = [];
  340. return view('app.mcp.cancelled_appointments_pending_review', $data);
  341. }
  342. public function cancelled_bills_pending_review(Request $request){
  343. $data = [
  344. 'records' => Bill::where('hcp_pro_id', $this->performer->pro->id)
  345. ->where('bill_service_type', 'NOTE')
  346. ->where('is_cancelled', true)
  347. ->where('is_cancellation_acknowledged', '<>', true)
  348. ->orderBy('created_at')
  349. ->get()
  350. ];
  351. return view('app.mcp.cancelled_bills_pending_review', $data);
  352. }
  353. public function cancelled_supply_orders_pending_review(Request $request){
  354. $data = [
  355. 'records' => SupplyOrder::where('signed_by_pro_id', $this->performer->pro->id)
  356. ->where('is_cancelled', true)
  357. ->where('is_cancellation_acknowledged', '<>', true)
  358. ->orderBy('created_at')
  359. ->get()
  360. ];
  361. return view('app.mcp.cancelled_supply_orders_pending_review', $data);
  362. }
  363. public function erx_and_orders_pending_signature(Request $request){
  364. $data = [
  365. 'records' => Erx::where('hcp_pro_id', $this->performer->pro->id)
  366. ->where('pro_declared_status', '<>', 'CANCELLED')
  367. ->where('has_hcp_pro_signed', '<>', true)
  368. ->orderBy('created_at')
  369. ->get()
  370. ];
  371. return view('app.mcp.erx_and_orders_pending_signature', $data);
  372. }
  373. public function supply_orders_pending_signature(Request $request){
  374. $data = [
  375. 'records' => SupplyOrder::where('created_by_pro_id', $this->performer->pro->id)
  376. ->whereNull('signed_by_pro_id')
  377. ->where('is_cancelled', '<>', true)
  378. ->orderBy('created_at')
  379. ->get()
  380. ];
  381. return view('app.mcp.supply_orders_pending_signature', $data);
  382. }
  383. public function supply_orders_awaiting_shipment(Request $request){
  384. $data = [
  385. 'records' => SupplyOrder::where('created_by_pro_id', $this->performer->pro->id)
  386. ->where('is_signed_by_pro', true)
  387. ->where('is_cleared_for_shipment', true)
  388. ->whereNull('shipment_id')
  389. ->orderBy('created_at')
  390. ->get()
  391. ];
  392. return view('app.mcp.supply_orders_awaiting_shipment', $data);
  393. }
  394. public function unsigned_incoming_reports(Request $request){
  395. $data = [
  396. 'records' => IncomingReport::where('hcp_pro_id', $this->performer->pro->id)
  397. ->whereRaw('(has_hcp_pro_signed IS NULL OR has_hcp_pro_signed = FALSE)')
  398. ->orderBy('created_at', 'desc')
  399. ->get()
  400. ];
  401. return view('app.mcp.unsigned_incoming_reports', $data);
  402. }
  403. public function patients_awaiting_rpm_interaction(Request $request) {
  404. $cmStartDate = date('Y-m-01');
  405. $query = "
  406. SELECT
  407. client.uid as client_uid,
  408. care_month.uid as care_month_uid,
  409. (client.name_first || ' ' || client.name_last) as client_name,
  410. client.age_in_years,
  411. client.sex,
  412. care_month.start_date,
  413. care_month.number_of_days_with_remote_measurements
  414. FROM
  415. client join care_month on client.id = care_month.client_id
  416. WHERE
  417. care_month.start_date = '{$cmStartDate}'
  418. AND care_month.is_client_enrolled_in_rm
  419. AND care_month.has_mcp_interacted_with_client_about_rm IS NOT TRUE
  420. AND care_month.mcp_pro_id = {$this->performer->pro->id}
  421. AND (client.client_engagement_status_category IS NULL OR client.client_engagement_status_category != 'DUMMY')
  422. AND client.name_first NOT ILIKE '%test%'
  423. AND client.name_last NOT ILIKE '%test%'
  424. ORDER BY care_month.number_of_days_with_remote_measurements DESC NULLS LAST
  425. ";
  426. $data = [
  427. 'records' => DB::select($query)
  428. ];
  429. return view('app.mcp.patients_awaiting_rpm_interaction', $data);
  430. }
  431. public function measurements_pending_stamping(Request $request){
  432. $data = [
  433. 'records' => CareMonth::where('mcp_pro_id', $this->performer->pro->id)
  434. ->where('rm_num_measurements_not_stamped_by_mcp', '>', 0)
  435. ->whereNotNull('rm_num_measurements_not_stamped_by_mcp')
  436. ->orderBy('created_at', 'DESC')
  437. ->paginate(15)
  438. ];
  439. return view('app.mcp.measurements_pending_stamping', $data);
  440. }
  441. public function measurements_pending_stamping_in_care_month(Request $request) {
  442. $patient = Client::where('uid', $request->input('patientUid'))->first();
  443. $careMonth = CareMonth::where('uid', $request->input('careMonthUid'))->first();
  444. return view('app.mcp.measurements_pending_stamping_in_care_month', compact('patient', 'careMonth'));
  445. }
  446. public function measurements_mass_stamping(Request $request){
  447. $careMonthsWithMeasurementsPendingStamping = CareMonth::select('id')
  448. ->where('mcp_pro_id', $this->performer->pro->id)
  449. ->where('rm_num_measurements_not_stamped_by_mcp', '>', 0)
  450. ->whereNotNull('rm_num_measurements_not_stamped_by_mcp')
  451. ->orderBy('created_at', 'DESC')
  452. ->get()
  453. ->map(function($_x) {
  454. return $_x->id;
  455. })
  456. ->toArray();
  457. $measurementsPendingStamping = Measurement::whereIn('care_month_id', $careMonthsWithMeasurementsPendingStamping)
  458. ->orderBy('created_at', 'DESC')
  459. ->whereNotNull('ts')
  460. ->whereNotIn('label', ['SBP', 'DBP'])
  461. ->where('is_cellular_zero', '<>', true)
  462. ->where('is_active', true)
  463. ->where('has_been_stamped_by_mcp', false)
  464. ->whereNotNull('client_bdt_measurement_id')
  465. ->paginate(500);
  466. return view('app.mcp.measurements_mass_stamping', compact('measurementsPendingStamping'));
  467. }
  468. }