PatientController.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  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\ClientProAccess;
  10. use App\Models\Erx;
  11. use App\Models\Facility;
  12. use App\Models\Handout;
  13. use App\Models\IncomingReport;
  14. use App\Models\MBClaim;
  15. use App\Models\MBPayer;
  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\Measurement;
  29. use Illuminate\Support\Facades\Http;
  30. use PDF;
  31. class PatientController extends Controller
  32. {
  33. public function claimsResolver(Request $request, Client $patient)
  34. {
  35. $notes = $patient->notesAscending;
  36. $hcpSignedNotesCount = 0;
  37. foreach($notes as $note){
  38. if($note->is_signed_by_hcp){
  39. $hcpSignedNotesCount += 1;
  40. }
  41. }
  42. $data = [
  43. 'dog' => 'bark',
  44. 'patient' => $patient,
  45. 'hcpSignedNotesCount' => $hcpSignedNotesCount
  46. ];
  47. return view('app.patient.claims-resolver', $data);
  48. }
  49. public function dashboard(Request $request, Client $patient )
  50. {
  51. $mcpPros = Pro::where('is_enrolled_as_mcp', true)->get();
  52. $facilities = []; // Facility::where('is_active', true)->get();
  53. // get assigned devices
  54. $assignedDeviceIDs = DB::select(DB::raw("SELECT device_id from client_bdt_device where is_active = true"));
  55. $assignedDeviceIDs = array_map(function($_x) {
  56. return $_x->device_id;
  57. }, $assignedDeviceIDs);
  58. // get all except assigned ones
  59. $devices = BDTDevice::where('is_active', true)
  60. ->whereNotIn('id', $assignedDeviceIDs)
  61. ->orderBy('imei', 'asc')
  62. ->get();
  63. $assignedDeviceIDs = null;
  64. unset($assignedDeviceIDs);
  65. $dxInfoLines = ClientInfoLine::where('client_id', $patient->id)
  66. ->where('category', 'dx')
  67. ->where('is_removed', false)
  68. ->orderBy('content_text', 'asc')
  69. ->get();
  70. return view('app.patient.dashboard',
  71. compact('patient', 'facilities', 'devices', 'dxInfoLines'));
  72. }
  73. public function canvasMigrate(Request $request, Client $patient )
  74. {
  75. $mcpPros = Pro::where('is_enrolled_as_mcp', true)->get();
  76. $facilities = []; // Facility::where('is_active', true)->get();
  77. // get assigned devices
  78. $assignedDeviceIDs = DB::select(DB::raw("SELECT device_id from client_bdt_device where is_active = true"));
  79. $assignedDeviceIDs = array_map(function($_x) {
  80. return $_x->device_id;
  81. }, $assignedDeviceIDs);
  82. // get all except assigned ones
  83. $devices = BDTDevice::where('is_active', true)
  84. ->whereNotIn('id', $assignedDeviceIDs)
  85. ->orderBy('imei', 'asc')
  86. ->get();
  87. $assignedDeviceIDs = null;
  88. unset($assignedDeviceIDs);
  89. $dxInfoLines = ClientInfoLine::where('client_id', $patient->id)
  90. ->where('category', 'dx')
  91. ->where('is_removed', false)
  92. ->orderBy('content_text', 'asc')
  93. ->get();
  94. return view('app.patient.canvas-migrate',
  95. compact('patient', 'facilities', 'devices', 'dxInfoLines'));
  96. }
  97. public function canvas(Request $request, Client $patient){
  98. return view('app.patient.canvas_dump', compact('patient'));
  99. }
  100. public function actionItems(Request $request, Client $patient )
  101. {
  102. $facilities = []; // Facility::where('is_active', true)->get();
  103. return view('app.patient.action-items', compact('patient', 'facilities'));
  104. }
  105. public function actionItemsErx(Request $request, Client $patient, $filter = 'open')
  106. {
  107. $allPros = Pro::all();
  108. $facilities = []; // Facility::where('is_active', true)->get();
  109. return view('app.patient.action-items-erx', compact('patient', 'facilities', 'filter', 'allPros'));
  110. }
  111. public function actionItemsLab(Request $request, Client $patient, $filter = 'open')
  112. {
  113. $allPros = Pro::all();
  114. $facilities = []; // Facility::where('is_active', true)->get();
  115. return view('app.patient.action-items-lab', compact('patient', 'facilities', 'filter', 'allPros'));
  116. }
  117. public function actionItemsImaging(Request $request, Client $patient, $filter = 'open')
  118. {
  119. $allPros = Pro::all();
  120. $facilities = []; // Facility::where('is_active', true)->get();
  121. return view('app.patient.action-items-imaging', compact('patient', 'facilities', 'filter', 'allPros'));
  122. }
  123. public function actionItemsEquipment(Request $request, Client $patient, $filter = 'open')
  124. {
  125. $allPros = Pro::all();
  126. $facilities = []; // Facility::where('is_active', true)->get();
  127. return view('app.patient.action-items-equipment', compact('patient', 'facilities', 'filter', 'allPros'));
  128. }
  129. public function actionItemsOther(Request $request, Client $patient, $filter = 'open')
  130. {
  131. $allPros = Pro::all();
  132. $facilities = []; // Facility::where('is_active', true)->get();
  133. return view('app.patient.action-items-other', compact('patient', 'facilities', 'filter', 'allPros'));
  134. }
  135. public function actionItemsErxSingle(Request $request, Client $patient, Ticket $ticket) {
  136. $allPros = Pro::all();
  137. $facilities = []; // Facility::where('is_active', true)->get();
  138. return view('app.patient.action-items-erx-single', compact('patient', 'facilities', 'allPros', 'ticket'));
  139. }
  140. public function actionItemsLabSingle(Request $request, Client $patient, Ticket $ticket) {
  141. $allPros = Pro::all();
  142. $facilities = []; // Facility::where('is_active', true)->get();
  143. return view('app.patient.action-items-lab-single', compact('patient', 'facilities', 'allPros', 'ticket'));
  144. }
  145. public function actionItemsImagingSingle(Request $request, Client $patient, Ticket $ticket) {
  146. $allPros = Pro::all();
  147. $facilities = []; // Facility::where('is_active', true)->get();
  148. return view('app.patient.action-items-imaging-single', compact('patient', 'facilities', 'allPros', 'ticket'));
  149. }
  150. public function actionItemsEquipmentSingle(Request $request, Client $patient, Ticket $ticket) {
  151. $allPros = Pro::all();
  152. $facilities = []; // Facility::where('is_active', true)->get();
  153. return view('app.patient.action-items-equipment-single', compact('patient', 'facilities', 'allPros', 'ticket'));
  154. }
  155. public function actionItemsOtherSingle(Request $request, Client $patient, Ticket $ticket) {
  156. $allPros = Pro::all();
  157. $facilities = []; // Facility::where('is_active', true)->get();
  158. return view('app.patient.action-items-other-single', compact('patient', 'facilities', 'allPros', 'ticket'));
  159. }
  160. public function intake(Request $request, Client $patient )
  161. {
  162. $files = File::allFiles(resource_path('views/app/intake-templates'));
  163. $templates = [];
  164. foreach ($files as $file) {
  165. $templates[] = str_replace(".blade.php", "", $file->getFilename());
  166. }
  167. return view('app.patient.intake', compact('patient', 'templates'));
  168. }
  169. public function carePlan(Request $request, Client $patient )
  170. {
  171. return view('app.patient.care-plan', compact('patient'));
  172. }
  173. public function medications(Request $request, Client $patient )
  174. {
  175. $infoLines = ClientInfoLine::where('client_id', $patient->id)
  176. ->where('category', 'rx')
  177. ->where('is_removed', false)
  178. ->orderBy('content_text', 'asc')
  179. ->get();
  180. return view('app.patient.medications', compact('patient', 'infoLines'));
  181. }
  182. public function dxAndFocusAreas(Request $request, Client $patient )
  183. {
  184. $dxInfoLines = ClientInfoLine::where('client_id', $patient->id)
  185. ->where('category', 'dx')
  186. ->where('is_removed', false)
  187. ->orderBy('content_text', 'asc')
  188. ->get();
  189. return view('app.patient.dx-and-focus-areas', compact('patient', 'dxInfoLines'));
  190. }
  191. public function careTeam(Request $request, Client $patient )
  192. {
  193. $infoLines = ClientInfoLine::where('client_id', $patient->id)
  194. ->where('category', 'care_team')
  195. ->where('is_removed', false)
  196. ->get();
  197. return view('app.patient.care-team', compact('patient', 'infoLines'));
  198. }
  199. public function devices(Request $request, Client $patient )
  200. {
  201. // get assigned devices
  202. $assignedDeviceIDs = DB::select(DB::raw("SELECT device_id from client_bdt_device where is_active = true"));
  203. $assignedDeviceIDs = array_map(function($_x) {
  204. return $_x->device_id;
  205. }, $assignedDeviceIDs);
  206. // get all except assigned ones
  207. $devices = BDTDevice::where('is_active', true)
  208. ->whereNotIn('id', $assignedDeviceIDs)
  209. ->orderBy('imei', 'asc')
  210. ->get();
  211. $assignedDeviceIDs = null;
  212. unset($assignedDeviceIDs);
  213. return view('app.patient.devices', compact('patient', 'devices'));
  214. }
  215. public function measurements(Request $request, Client $patient )
  216. {
  217. $measurements = Measurement::where('client_id', $patient->id)->where('is_active', true)->orderByRaw('ts DESC NULLS LAST')->paginate(30);
  218. return view('app.patient.measurements', compact('patient', 'measurements'));
  219. }
  220. public function labsAndStudies(Request $request, Client $patient )
  221. {
  222. return view('app.patient.labs-and-studies', compact('patient'));
  223. }
  224. public function history(Request $request, Client $patient )
  225. {
  226. $infoLines = ClientInfoLine::where('client_id', $patient->id)
  227. ->where('category', 'LIKE', 'history_%')
  228. ->where('is_removed', false)
  229. ->get();
  230. return view('app.patient.history', compact('patient', 'infoLines'));
  231. }
  232. public function memos(Request $request, Client $patient )
  233. {
  234. return view('app.patient.memos', compact('patient'));
  235. }
  236. public function memosThread(Request $request, Client $patient )
  237. {
  238. return view('app.patient.memos-thread', compact('patient'));
  239. }
  240. public function messagesThread(Request $request, Client $patient )
  241. {
  242. return view('app.patient.messages-thread', compact('patient'));
  243. }
  244. public function sms(Request $request, Client $patient )
  245. {
  246. return view('app.patient.sms', compact('patient'));
  247. }
  248. public function outgoingSmsLog(Request $request, Client $patient )
  249. {
  250. return view('app.patient.outgoing-sms-log', compact('patient'));
  251. }
  252. public function smsNumbers(Request $request, Client $patient )
  253. {
  254. return view('app.patient.sms-numbers', compact('patient'));
  255. }
  256. public function immunizations(Request $request, Client $patient )
  257. {
  258. return view('app.patient.immunizations', compact('patient'));
  259. }
  260. public function allergies(Request $request, Client $patient )
  261. {
  262. $infoLines = ClientInfoLine::where('client_id', $patient->id)
  263. ->where('category', 'allergy')
  264. ->where('is_removed', false)
  265. ->get();
  266. return view('app.patient.allergies', compact('patient', 'infoLines'));
  267. }
  268. public function notes(Request $request, Client $patient, $filter = 'active')
  269. {
  270. $pros = $this->pros;
  271. return view('app.patient.notes', compact('patient','pros', 'filter'));
  272. }
  273. public function genericBills(Request $request, Client $patient)
  274. {
  275. return view('app.patient.generic-bills', compact('patient'));
  276. }
  277. public function rmSetup(Request $request, Client $patient)
  278. {
  279. return view('app.patient.rm-setup', compact('patient'));
  280. }
  281. public function handouts(Request $request, Client $patient )
  282. {
  283. $handouts = Handout::where('is_active', true)->get();
  284. return view('app.patient.handouts', compact('patient', 'handouts'));
  285. }
  286. public function settings(Request $request, Client $patient )
  287. {
  288. return view('app.patient.settings', compact('patient'));
  289. }
  290. public function smsReminders(Request $request, Client $patient )
  291. {
  292. return view('app.patient.sms-reminders', compact('patient'));
  293. }
  294. public function measurementConfirmationNumbers(Request $request, Client $patient )
  295. {
  296. return view('app.patient.measurement-confirmation-numbers', compact('patient'));
  297. }
  298. public function pros(Request $request, Client $patient )
  299. {
  300. return view('app.patient.pros', compact('patient'));
  301. }
  302. public function proChanges(Request $request, Client $patient )
  303. {
  304. return view('app.patient.client-pro-changes', compact('patient'));
  305. }
  306. public function account(Request $request, Client $patient )
  307. {
  308. return view('app.patient.account', compact('patient'));
  309. }
  310. public function careChecklist(Request $request, Client $patient )
  311. {
  312. return view('app.patient.care-checklist', compact('patient'));
  313. }
  314. public function documents(Request $request, Client $patient )
  315. {
  316. return view('app.patient.documents', compact('patient'));
  317. }
  318. public function incomingReports(Request $request, Client $patient, IncomingReport $currentReport = null)
  319. {
  320. return view('app.patient.incoming-reports', compact('patient', 'currentReport'));
  321. }
  322. public function education(Request $request, Client $patient )
  323. {
  324. return view('app.patient.education', compact('patient'));
  325. }
  326. public function messaging(Request $request, Client $patient )
  327. {
  328. return view('app.patient.messaging', compact('patient'));
  329. }
  330. public function duplicate(Request $request, Client $patient )
  331. {
  332. return view('app.patient.duplicate', compact('patient'));
  333. }
  334. public function careMonths(Request $request, Client $patient )
  335. {
  336. $careMonths = CareMonth::where('client_id', $patient->id)->orderBy('start_date', 'desc')->get();
  337. $notes = Note::where('is_cancelled', false)->get();
  338. return view('app.patient.care-months', compact('patient', 'careMonths', 'notes'));
  339. }
  340. public function presence(Request $request, Client $patient )
  341. {
  342. return json_encode([
  343. "online" => $patient->is_online
  344. ]);
  345. }
  346. public function embedSection(Request $request, Client $patient, $section, $selectable) {
  347. return view('app.patient.partials.' . $section, compact('patient', 'selectable'));
  348. }
  349. public function calendar(Request $request, Client $patient, Appointment $currentAppointment) {
  350. $pros = [];
  351. if($this->pro && $this->pro->pro_type != 'ADMIN') {
  352. $accessiblePros = ProProAccess::where('owner_pro_id', $this->pro->id)->get();
  353. $accessibleProIds = [];
  354. foreach($accessiblePros as $accessiblePro){
  355. $accessibleProIds[] = $accessiblePro->accessible_pro_id;
  356. }
  357. $accessibleProIds[] = $this->pro->id;
  358. // for dna, add pros accessible via pro teams
  359. if($this->performer->pro->isDefaultNA()) {
  360. $teams = $this->performer->pro->teamsWhereAssistant;
  361. foreach ($teams as $team) {
  362. if(!in_array($team->mcp_pro_id, $accessibleProIds)) {
  363. $accessibleProIds[] = $team->mcp_pro_id;
  364. }
  365. }
  366. }
  367. $pros = Pro::whereIn('id', $accessibleProIds)->get();
  368. }
  369. $dateLastWeek = date_sub(date_create(), date_interval_create_from_date_string("14 days"));
  370. $dateLastWeek = date_format($dateLastWeek, "Y-m-d");
  371. $appointments = Appointment::where('client_id', $patient->id)
  372. ->orderBy('raw_date', 'desc')->orderBy('raw_start_time', 'desc')
  373. ->where('raw_date', '>=', $dateLastWeek)
  374. ->get();
  375. $appointmentProIDs = $appointments->map(function($_item) {
  376. return $_item->pro_id;
  377. });
  378. $appointmentPros = Pro::whereIn('id', $appointmentProIDs)->get();
  379. return view('app.patient.appointment-calendar',
  380. compact('pros', 'patient', 'currentAppointment', 'appointments', 'appointmentPros'));
  381. }
  382. public function programs(Request $request, Client $patient, $filter = '') {
  383. $pros = $this->pros;
  384. return view('app.patient.programs', compact('patient', 'pros', 'filter'));
  385. }
  386. public function flowsheets(Request $request, Client $patient, $filter = '') {
  387. $pros = $this->pros;
  388. return view('app.patient.flowsheets', compact('patient', 'pros', 'filter'));
  389. }
  390. public function vitalsSettings(Request $request, Client $patient) {
  391. return view('app.patient.vitals-settings', compact('patient'));
  392. }
  393. public function vitalsGraph(Request $request, Client $patient, $filter = '') {
  394. $pros = $this->pros;
  395. return view('app.patient.vitals-graph', compact('patient', 'pros', 'filter'));
  396. }
  397. public function tickets(Request $request, Client $patient, $type = '', String $currentTicket = '') {
  398. $pros = $this->pros;
  399. $allPros = Pro::all();
  400. $qlTicket = $currentTicket;
  401. if(!!$currentTicket) {
  402. $qlTicket = Ticket::where('uid', $currentTicket)->first();
  403. if($qlTicket) {
  404. $currentTicket = $qlTicket;
  405. }
  406. }
  407. return view('app.patient.tickets', compact('patient', 'pros', 'allPros', 'type', 'currentTicket'));
  408. }
  409. public function prescriptions(Request $request, Client $patient, String $type = '', String $currentErx = '') {
  410. if(!!$currentErx) {
  411. $currentErx = Erx::where('uid', $currentErx)->first();
  412. }
  413. $note = $patient->coreNote;
  414. return view('app.patient.prescriptions.index', compact('patient', 'type', 'currentErx', 'note'));
  415. }
  416. public function prescriptionsPopup(Request $request, Client $patient, String $type = '', String $currentErx = '') {
  417. if(!!$currentErx) {
  418. $currentErx = Erx::where('uid', $currentErx)->first();
  419. }
  420. $note = null;
  421. if($request->input('noteUid')) {
  422. $note = Note::where('uid', $request->input('noteUid'))->first();
  423. }
  424. return view('app.patient.prescriptions-popup.list-popup', compact('patient', 'type', 'currentErx', 'note'));
  425. }
  426. public function prescriptionsList(Request $request, Client $patient, String $type = '', String $currentErx = '') {
  427. if(!!$currentErx) {
  428. $currentErx = Erx::where('uid', $currentErx)->first();
  429. }
  430. $note = null;
  431. if($request->input('noteUid')) {
  432. $note = Note::where('uid', $request->input('noteUid'))->first();
  433. }
  434. return view('app.patient.prescriptions.list', compact('patient', 'type', 'currentErx', 'note'));
  435. }
  436. public function downloadPrescriptionAsPdf(Request $request, Erx $prescription){
  437. if($request->input('html')) {
  438. return view('app.patient.prescriptions.pdf.pdf-preview', compact('prescription'));
  439. }
  440. else {
  441. $pdf = PDF::loadView('app.patient.prescriptions.pdf.pdf-preview', compact('prescription'));
  442. return $pdf->download($prescription->created_at .'_' . 'erx.pdf');
  443. }
  444. }
  445. public function transmitPrescription(Request $request, Erx $prescription){
  446. // re-generate pdf with cover sheet as first page and save it to FS
  447. $filePath = config('app.temp_dir') . "/{$prescription->uid}.pdf";
  448. $pdf = PDF::loadView('app.patient.prescriptions.pdf.pdf-preview-with-cover-sheet', compact('prescription'));
  449. $pdf->save($filePath);
  450. // send it along with the rest of the params to /api/erx/transmit [multi-part POST]
  451. $url = config('stag.backendUrl') . '/erx/transmit';
  452. $params = [
  453. "uid" => $request->input('uid'),
  454. "toWho" => $request->input('toWho'),
  455. "toEmail" => $request->input('toEmail'),
  456. "toFaxNumber" => $request->input('toFaxNumber'),
  457. "toFaxNumberAttentionLine" => $request->input('toFaxNumberAttentionLine'),
  458. "toFaxNumberCoverSheetMemo" => $request->input('toFaxNumberCoverSheetMemo'),
  459. ];
  460. if($request->input('copyToPatient')) {
  461. $params["copyToPatientFaxNumber"] = $request->input('copyToPatientFaxNumber');
  462. $params["copyToPatientEmail"] = $request->input('copyToPatientEmail');
  463. }
  464. $pdf = fopen($filePath, 'r');
  465. $response = Http
  466. ::attach('pdfSystemFile', $filePath, "{$prescription->uid}.pdf")
  467. ->withHeaders(['sessionKey' => $request->cookie('sessionKey')])
  468. ->post($url, $params)
  469. ->json();
  470. return $response;
  471. }
  472. public function supplyOrders(Request $request, Client $patient, SupplyOrder $supplyOrder = null)
  473. {
  474. $products = Product::where('is_active', true)->orderBy('created_at', 'desc')->get();
  475. return view('app.patient.supply-orders', compact('patient', 'supplyOrder', 'products'));
  476. }
  477. public function shipments(Request $request, Client $patient, Shipment $shipment = null)
  478. {
  479. return view('app.patient.shipments', compact('patient', 'shipment'));
  480. }
  481. public function appointments(Request $request, Client $patient, $forPro = 'all', $status = 'all') {
  482. $pros = $this->pros;
  483. $appointments = $patient->appointmentsForProByStatus($forPro, strtoupper($status));
  484. $appointmentProIDs = $appointments->map(function($_item) {
  485. return $_item->pro_id;
  486. });
  487. $appointmentPros = Pro::whereIn('id', $appointmentProIDs)->get();
  488. return view('app.patient.appointments',
  489. compact('patient', 'pros', 'appointments', 'appointmentPros', 'forPro', 'status'));
  490. }
  491. public function mcpRequests(Request $request, Client $patient) {
  492. return view('app.patient.mcp-requests', compact('patient'));
  493. }
  494. public function eligibleRefreshes(Request $request, Client $patient) {
  495. return view('app.patient.eligible-refreshes', compact('patient'));
  496. }
  497. public function insuranceCoverage(Request $request, Client $patient) {
  498. $mbPayers = MBPayer::all();
  499. return view('app.patient.insurance-coverage', compact('patient', 'mbPayers'));
  500. }
  501. public function clientPrimaryCoverages(Request $request, Client $patient) {
  502. $mbPayers = MBPayer::all();
  503. return view('app.patient.client-primary-coverages', compact('patient', 'mbPayers'));
  504. }
  505. public function primaryCoverage(Request $request, Client $patient) {
  506. $mbPayers = MBPayer::all();
  507. return view('app.patient.primary-coverage', compact('patient', 'mbPayers'));
  508. }
  509. public function primaryCoverageForm(Request $request, Client $patient) {
  510. $mbPayers = MBPayer::all();
  511. return view('app.patient.primary-coverage-form', compact('patient', 'mbPayers'));
  512. }
  513. public function primaryCoverageManualDeterminationModal(Request $request, Client $patient) {
  514. if($patient->latestClientPrimaryCoverage->plan_type === 'MEDICARE'){
  515. return view('app.patient.primary-coverage-manual-determination-medicare-modal', compact('patient'));
  516. }
  517. if($patient->latestClientPrimaryCoverage->plan_type === 'MEDICAID'){
  518. return view('app.patient.primary-coverage-manual-determination-medicaid-modal', compact('patient'));
  519. }
  520. if($patient->latestClientPrimaryCoverage->plan_type === 'COMMERCIAL'){
  521. return view('app.patient.primary-coverage-manual-determination-commercial-modal', compact('patient'));
  522. }
  523. return "Plan Type is missing!";
  524. }
  525. public function mbClaim(Request $request, MBClaim $mbClaim) {
  526. return view('app.patient.mb-claim-single', compact('mbClaim'));
  527. }
  528. public function accounts(Request $request, Client $patient) {
  529. return view('app.patient.accounts', compact('patient'));
  530. }
  531. public function careMonthMatrix(Request $request, CareMonth $careMonth) {
  532. return view('app.patient.care-month.matrix', [
  533. 'patient' => $careMonth->patient,
  534. 'careMonth' => $careMonth,
  535. ]);
  536. }
  537. public function clientProAccess(Request $request, Client $patient) {
  538. $rows = ClientProAccess::where('client_id', $patient->id)->get();
  539. return view('app.patient.client-pro-access', compact('patient', 'rows'));
  540. }
  541. }