PatientController.php 25 KB

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