patients.blade.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. @extends ('layouts/template')
  2. @section('content')
  3. @if($pro->id === 1 || $pro->id === 16)
  4. <link href="/c3/c3.min.css" rel="stylesheet">
  5. <script src="/c3/d3.v5.min.js" charset="utf-8"></script>
  6. <script src="/c3/c3.min.js"></script>
  7. @endif
  8. <?php
  9. $showProgramsColumn = false;
  10. foreach($patients as $patient) {
  11. if(count($patient->clientPrograms)) {
  12. if($pro->pro_type === 'ADMIN') {
  13. $showProgramsColumn = true;
  14. break;
  15. }
  16. else {
  17. foreach($patient->clientPrograms as $clientProgram) {
  18. if(in_array($pro->id, [$clientProgram->mcp_pro_id, $clientProgram->manager_pro_id])) {
  19. $showProgramsColumn = true;
  20. break;
  21. }
  22. }
  23. if($showProgramsColumn) break;
  24. }
  25. }
  26. }
  27. ?>
  28. <div class="p-3 mcp-theme-1" id="patients-list">
  29. <div class="card">
  30. <div class="card-header px-3 py-2 d-flex align-items-center">
  31. <strong class="mr-4">
  32. <i class="fas fa-user-injured"></i>
  33. Patients
  34. </strong>
  35. <div class="ml-auto d-flex align-items-center search-form">
  36. <form action="" method="get" class="mr-2" id="patients-search">
  37. <input type="text" name="q" value="{{request()->input('q')}}" class="form-control form-control-sm"
  38. placeholder="Name / Email / Tags">
  39. </form>
  40. <select class="ml-auto max-width-300px form-control form-control-sm"
  41. id="patients-filter">
  42. <option value="" {{ $filter === '' ? 'selected' : '' }}>All patients</option>
  43. <option value="not-yet-seen" {{ $filter === 'not-yet-seen' ? 'selected' : '' }}>Patients I have not seen yet</option>
  44. <option value="having-birthday-today" {{ $filter === 'having-birthday-today' ? 'selected' : '' }}>Patients having birthday today</option>
  45. </select>
  46. </div>
  47. </div>
  48. @if($pro->id === 1 || $pro->id === 16)
  49. <div class="card-header px-3 py-4 d-flex align-items-center bg-white justify-content-center">
  50. <div id="patientAcquisitionChart" class="w-75"></div>
  51. </div>
  52. @endif
  53. <div class="card-body p-0">
  54. <table class="table table-condensed p-0 m-0">
  55. <thead class="bg-light">
  56. <tr>
  57. @if($pro->pro_type === 'ADMIN')
  58. <th class="border-0"></th>
  59. @endif
  60. <th class="px-3 border-0">Chart #</th>
  61. <th class="border-0">Patient</th>
  62. @if($pro->isDefaultNA() || $pro->pro_type === 'ADMIN')
  63. <th class="border-0">Source</th>
  64. @endif
  65. <th class="border-0 px-1">OB</th>
  66. <th class="border-0">Signed<br>Notes</th>
  67. <th class="border-0">CM<br>Setup</th>
  68. <th class="border-0">Created At</th>
  69. <th class="border-0">Address</th>
  70. @if($showProgramsColumn)
  71. <th class="border-0">Program(s)</th>@endif
  72. <th class="border-0">MCN</th>
  73. <th class="border-0">PCP</th>
  74. <th class="border-0"><span class="text-nowrap">Recent Notes</span><br>(overall)</th>
  75. <th class="border-0"><span class="text-nowrap">Recent Notes</span><br>(me)</th>
  76. <th class="border-0">Appointments</th>
  77. <th class="border-0">Account</th>
  78. <th class="border-0">Tags</th>
  79. </tr>
  80. </thead>
  81. <tbody>
  82. @foreach($patients as $patient)
  83. <tr>
  84. @if($pro->pro_type === 'ADMIN')
  85. <td>{{$loop->index + 1}}</td>
  86. @endif
  87. <td class="px-3">
  88. <a href="{{route('patients.view.dashboard', $patient)}}">
  89. {{$patient->chart_number}}
  90. </a>
  91. </td>
  92. <td>
  93. {{$patient->displayName()}}
  94. <div>{{ friendly_date_time($patient->dob, false) }}{{ $patient->sex === 'M' ? ', Male' : ($patient->sex === ', F' ? 'Female' : '') }}</div>
  95. </td>
  96. @if($pro->isDefaultNA() || $pro->pro_type === 'ADMIN')
  97. <td>
  98. @if($patient->has_system_source)
  99. @if($patient->system_source_category === 'PRO_TEAM' && $patient->systemSourceProTeam)
  100. <div class="text-nowrap">Via team profile</div>
  101. <a native target="_blank" href="{{config('app.stagfe6_url')}}/{{$patient->systemSourceProTeam->slug}}">{{$patient->systemSourceProTeam->slug}}</a>
  102. @elseif($patient->system_source_category === 'PRO' && $patient->systemSourcePro)
  103. <div class="text-nowrap">Via pro profile</div>
  104. <a native target="_blank" href="{{config('app.stagfe6_url')}}/{{$patient->systemSourcePro->slug}}">{{$patient->systemSourcePro->slug}}</a>
  105. @endif
  106. @endif
  107. </td>
  108. @endif
  109. <td class="px-1">
  110. @if($patient->has_mcp_done_onboarding_visit !== 'YES')
  111. <span title="MCP Onboarding Visit Pending"><i class="fa fa-exclamation-triangle"></i></span>
  112. @else
  113. <i class="fa fa-check text-secondary on-hover-opaque"></i>
  114. @endif
  115. </td>
  116. <td>
  117. <?php $numSignedNotes = $patient->numSignedNotes(); ?>
  118. <span class="{{$numSignedNotes && $patient->has_mcp_done_onboarding_visit !== 'YES' ? 'font-weight-bold text-warning-mellow' : 'text-secondary'}}">
  119. {{$numSignedNotes ? $numSignedNotes :'-'}}
  120. </span>
  121. </td>
  122. <td>
  123. @if($patient->has_cm_setup_been_performed)
  124. <i class="fa fa-check text-secondary on-hover-opaque"></i>
  125. <br>
  126. <a href="{{route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $patient->cmSetupNote])}}">Note</a>
  127. @else
  128. -
  129. @endif
  130. </td>
  131. <td>
  132. {{ friendly_date_time_short_with_tz($patient->created_at, true, 'EASTERN') }}
  133. <hr>
  134. @if($pro->pro_type === 'ADMIN')
  135. {{ $patient->initiative }}
  136. @endif
  137. </td>
  138. <td>
  139. <?php
  140. $addressParts = [];
  141. if (!!$patient->mailing_address_line1) $addressParts[] = $patient->mailing_address_line1;
  142. if (!!$patient->mailing_address_line2) $addressParts[] = $patient->mailing_address_line2;
  143. $addressParts = implode(", ", $addressParts) . "<br/>";
  144. $addressPart2 = [];
  145. if (!!$patient->mailing_address_city) $addressPart2[] = $patient->mailing_address_city;
  146. if (!!$patient->mailing_address_state) $addressPart2[] = $patient->mailing_address_state;
  147. $addressParts .= implode(", ", $addressPart2);
  148. echo $addressParts;
  149. ?>
  150. </td>
  151. @if($showProgramsColumn)
  152. <td>
  153. <?php $programNumber = 0; ?>
  154. @foreach($patient->clientPrograms as $clientProgram)
  155. <?php
  156. if($pro->pro_type === 'ADMIN' ||
  157. in_array($pro->id, [$clientProgram->mcp_pro_id, $clientProgram->manager_pro_id])
  158. ) {
  159. // $program = $clientProgram->program;
  160. $programNumber++;
  161. ?>
  162. <div class="mb-1 text-nowrap">
  163. {{ $programNumber }}. {{ $clientProgram->title }}
  164. @if($clientProgram->has_mcp_done_onboarding_visit !== 'YES')
  165. <span title="Onboarding Pending" class="ml-1"><i class="fa fa-exclamation-triangle"></i></span>
  166. @else
  167. <span title="Onboarding Complete" class="ml-1 text-secondary"><i class="fa fa-check"></i></span>
  168. @endif
  169. </div>
  170. <?php } ?>
  171. @endforeach
  172. </td>
  173. @endif
  174. <td>
  175. @if($patient->was_medicare_validation_successful && $patient->is_part_b_primary == 'YES')
  176. Covered <span style="color:green"><i class="fa fa-check-circle"></i></span>
  177. @elseif($patient->was_medicare_validation_successful)
  178. <div>Valid Medicare Number</div>
  179. <div class="text-secondary">Not Medicare Part B</div>
  180. @if($patient->is_medicare_advantage == 'YES')
  181. <div class="text-secondary">Medicare Advantage: <b>{{$patient->medicare_advantage_plan}}</b></div>
  182. @endif
  183. @else
  184. @if($patient->mcn)
  185. <div>Invalid MCN</div>
  186. @else
  187. @if($patient->is_coverage_manually_verified)
  188. {{$patient->coverage_manual_verification_memo}} <span style="color:green"><i class="fa fa-check-circle">
  189. @else
  190. <div>No Info Provided</div>
  191. @endif
  192. @endif
  193. @endif
  194. </td>
  195. <td>
  196. {{ $patient->mcp ? $patient->mcp->displayName() : '-' }}
  197. </td>
  198. <td class="p-0">
  199. <?php $allNotes = $patient->recentNotes(); ?>
  200. <table class="table table-sm table-condensed table-bordered m-0 width-200px">
  201. <tbody>
  202. @foreach($allNotes as $note)
  203. <tr>
  204. <td>
  205. <a href="{{route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $note])}}"><b class="text-nowrap">{{friendlier_date($note->effective_dateest)}}</b></a>
  206. <br>
  207. <span class="text-nowrap">{{$note->hcpPro->displayName()}}</span>
  208. </td>
  209. <td>{{$note->new_or_fu_or_na}}</td>
  210. </tr>
  211. @endforeach
  212. </tbody>
  213. </table>
  214. </td>
  215. <td class="py-0 pl-2">
  216. <?php $myNotes = $patient->recentNotes($pro); ?>
  217. <table class="table table-sm table-condensed table-bordered m-0 width-200px">
  218. <tbody>
  219. @foreach($myNotes as $note)
  220. <tr>
  221. <td>
  222. <a href="{{route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $note])}}"><b class="text-nowrap">{{friendlier_date($note->effective_dateest)}}</b></a>
  223. </td>
  224. <td>{{$note->new_or_fu_or_na}}</td>
  225. </tr>
  226. @endforeach
  227. </tbody>
  228. </table>
  229. </td>
  230. <td>
  231. <table class="table table-sm border-0 my-0">
  232. <tbody>
  233. <?php $numAppts = 0; ?>
  234. @foreach($patient->upcomingAppointments as $appointment)
  235. @if($appointment->status !== 'CANCELLED' && $appointment->status !== 'ABANDONED')
  236. <tr>
  237. <td class="text-black p-0 border-0">
  238. <div class="pb-0">
  239. {{ friendly_date_time($appointment->start_time, false) }}, {{ friendly_time($appointment->raw_start_time) }}
  240. <span class="d-inline-block text-secondary text-sm">({{ $appointment->timezone }})</span>
  241. <br>
  242. <b class="mr-1">{{$appointment->pro->displayName()}}</b>
  243. <span class="text-secondary text-sm">({{ $appointment->status }})</span>
  244. </div>
  245. </td>
  246. </tr>
  247. <?php $numAppts++; ?>
  248. @endif
  249. @endforeach
  250. @if(!$numAppts)
  251. <tr>
  252. <td class="text-secondary p-0 border-0">
  253. No upcoming appointments
  254. </td>
  255. </tr>
  256. @endif
  257. </tbody>
  258. </table>
  259. </td>
  260. <td>
  261. @if($patient->linkedAccounts && count($patient->linkedAccounts))
  262. <span class="font-weight-bold text-info"><i class="fa fa-check"></i></span>
  263. @else
  264. <span class="text-secondary">-</span>
  265. @endif
  266. </td>
  267. <td>
  268. @if($patient->tags)
  269. <?php
  270. $tags = explode("|", $patient->tags);
  271. $tags = array_filter($tags, function($_x) {
  272. return !empty($_x);
  273. });
  274. $tags = implode(", ", $tags);
  275. ?>
  276. {{ $tags }}
  277. @endif
  278. </td>
  279. </tr>
  280. @endforeach
  281. </tbody>
  282. </table>
  283. <div class="ml-2 mt-2">
  284. {{$patients->links()}}
  285. </div>
  286. </div>
  287. </div>
  288. </div>
  289. <script>
  290. (function() {
  291. function init() {
  292. function submit() {
  293. let url = '/patients' +
  294. ($('#patients-filter').val() ? '/' + $('#patients-filter').val() : '') +
  295. ($('#patients-search input').val() ? '?q=' + encodeURIComponent($('#patients-search input').val()) : '');
  296. fastLoad(url);
  297. return false;
  298. }
  299. $('#patients-search').off('submit').on('submit', submit);
  300. $('#patients-filter').off('change').on('change', submit);
  301. @if($pro->id === 1 || $pro->id === 16)
  302. patientAcquisitionChart();
  303. @endif
  304. }
  305. @if($pro->pro_type === 'ADMIN')
  306. <?php
  307. $dates = [];
  308. $acquisitions = [];
  309. for ($i = count($patientAcquisitionData) - 1; $i >= 0; $i--) {
  310. $dates[] = $patientAcquisitionData[$i]->date;
  311. $acquisitions[] = $patientAcquisitionData[$i]->count;
  312. }
  313. ?>
  314. function patientAcquisitionChart() {
  315. var chart = c3.generate({
  316. bindto: '#patientAcquisitionChart',
  317. data: {
  318. x: 'x',
  319. // xFormat: '%Y%m%d', // 'xFormat' can be used as custom format of 'x'
  320. columns: [
  321. ['x', <?= implode(", ", array_map(function($_x) { return "'" . $_x . "'"; }, $dates)) ?>],
  322. ['New Patients', <?= implode(", ", array_map(function($_x) { return "'" . $_x . "'"; }, $acquisitions)) ?>],
  323. ]
  324. },
  325. axis: {
  326. x: {
  327. type: 'timeseries',
  328. tick: {
  329. format: '%Y-%m-%d',
  330. multiline: true,
  331. fit: true,
  332. rotate: -45
  333. },
  334. },
  335. }
  336. });
  337. }
  338. @endif
  339. addMCInitializer('patients-list', init, '#patients-list');
  340. }).call(window);
  341. </script>
  342. @endsection