McpController.php 23 KB

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