PatientController.php 25 KB

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