McpController.php 23 KB

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