patients.blade.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  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. <th class="border-0 px-1">OB</th>
  63. <th class="border-0">Signed<br>Notes</th>
  64. <th class="border-0">CM<br>Setup</th>
  65. <th class="border-0">Created At</th>
  66. <th class="border-0">Address</th>
  67. @if($showProgramsColumn)<th class="border-0">Program(s)</th>@endif
  68. <th class="border-0">MCN</th>
  69. <th class="border-0">PCP</th>
  70. <th class="border-0"><span class="text-nowrap">Recent Notes</span><br>(overall)</th>
  71. <th class="border-0"><span class="text-nowrap">Recent Notes</span><br>(me)</th>
  72. <th class="border-0">Appointments</th>
  73. <th class="border-0">Account</th>
  74. <th class="border-0">Tags</th>
  75. </tr>
  76. </thead>
  77. <tbody>
  78. @foreach($patients as $patient)
  79. <tr>
  80. @if($pro->pro_type === 'ADMIN')
  81. <td>{{$loop->index + 1}}</td>
  82. @endif
  83. <td class="px-3">
  84. <a href="{{route('patients.view.dashboard', $patient)}}">
  85. {{$patient->chart_number}}
  86. </a>
  87. </td>
  88. <td>
  89. {{$patient->displayName()}}
  90. <div>{{ friendly_date_time($patient->dob, false) }}{{ $patient->sex === 'M' ? ', Male' : ($patient->sex === ', F' ? 'Female' : '') }}</div>
  91. </td>
  92. <td class="px-1">
  93. @if($patient->has_mcp_done_onboarding_visit !== 'YES')
  94. <span title="MCP Onboarding Visit Pending"><i class="fa fa-exclamation-triangle"></i></span>
  95. @else
  96. <i class="fa fa-check text-secondary on-hover-opaque"></i>
  97. @endif
  98. </td>
  99. <td>
  100. <?php $numSignedNotes = $patient->numSignedNotes(); ?>
  101. <span class="{{$numSignedNotes && $patient->has_mcp_done_onboarding_visit !== 'YES' ? 'font-weight-bold text-warning-mellow' : 'text-secondary'}}">
  102. {{$numSignedNotes ? $numSignedNotes :'-'}}
  103. </span>
  104. </td>
  105. <td>
  106. @if($patient->has_cm_setup_been_performed)
  107. <i class="fa fa-check text-secondary on-hover-opaque"></i>
  108. <br>
  109. <a href="{{route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $patient->cmSetupNote])}}">Note</a>
  110. @else
  111. -
  112. @endif
  113. </td>
  114. <td>
  115. {{ friendly_date_time_short_with_tz($patient->created_at, true, 'EASTERN') }}
  116. <hr>
  117. @if($pro->pro_type === 'ADMIN')
  118. {{ $patient->initiative }}
  119. @endif
  120. </td>
  121. <td>
  122. <?php
  123. $addressParts = [];
  124. if (!!$patient->mailing_address_line1) $addressParts[] = $patient->mailing_address_line1;
  125. if (!!$patient->mailing_address_line2) $addressParts[] = $patient->mailing_address_line2;
  126. $addressParts = implode(", ", $addressParts) . "<br/>";
  127. $addressPart2 = [];
  128. if (!!$patient->mailing_address_city) $addressPart2[] = $patient->mailing_address_city;
  129. if (!!$patient->mailing_address_state) $addressPart2[] = $patient->mailing_address_state;
  130. $addressParts .= implode(", ", $addressPart2);
  131. echo $addressParts;
  132. ?>
  133. </td>
  134. @if($showProgramsColumn)
  135. <td>
  136. <?php $programNumber = 0; ?>
  137. @foreach($patient->clientPrograms as $clientProgram)
  138. <?php
  139. if($pro->pro_type === 'ADMIN' ||
  140. in_array($pro->id, [$clientProgram->mcp_pro_id, $clientProgram->manager_pro_id])
  141. ) {
  142. // $program = $clientProgram->program;
  143. $programNumber++;
  144. ?>
  145. <div class="mb-1 text-nowrap">
  146. {{ $programNumber }}. {{ $clientProgram->title }}
  147. @if($clientProgram->has_mcp_done_onboarding_visit !== 'YES')
  148. <span title="Onboarding Pending" class="ml-1"><i class="fa fa-exclamation-triangle"></i></span>
  149. @else
  150. <span title="Onboarding Complete" class="ml-1 text-secondary"><i class="fa fa-check"></i></span>
  151. @endif
  152. </div>
  153. <?php } ?>
  154. @endforeach
  155. </td>
  156. @endif
  157. <td>
  158. @if($patient->was_medicare_validation_successful && $patient->is_part_b_primary == 'YES')
  159. Covered <span style="color:green"><i class="fa fa-check-circle"></i></span>
  160. @elseif($patient->was_medicare_validation_successful)
  161. <div>Valid Medicare Number</div>
  162. <div class="text-secondary">Not Medicare Part B</div>
  163. @if($patient->is_medicare_advantage == 'YES')
  164. <div class="text-secondary">Medicare Advantage: <b>{{$patient->medicare_advantage_plan}}</b></div>
  165. @endif
  166. @else
  167. @if($patient->mcn)
  168. <div>Invalid MCN</div>
  169. @else
  170. @if($patient->is_coverage_manually_verified)
  171. {{$patient->coverage_manual_verification_memo}} <span style="color:green"><i class="fa fa-check-circle">
  172. @else
  173. <div>No Info Provided</div>
  174. @endif
  175. @endif
  176. @endif
  177. </td>
  178. <td>
  179. {{ $patient->mcp ? $patient->mcp->displayName() : '-' }}
  180. </td>
  181. <td class="p-0">
  182. <?php $allNotes = $patient->recentNotes(); ?>
  183. <table class="table table-sm table-condensed table-bordered m-0 width-200px">
  184. <tbody>
  185. @foreach($allNotes as $note)
  186. <tr>
  187. <td>
  188. <a href="{{route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $note])}}"><b class="text-nowrap">{{friendlier_date($note->effective_dateest)}}</b></a>
  189. <br>
  190. <span class="text-nowrap">{{$note->hcpPro->displayName()}}</span>
  191. </td>
  192. <td>{{$note->new_or_fu_or_na}}</td>
  193. </tr>
  194. @endforeach
  195. </tbody>
  196. </table>
  197. </td>
  198. <td class="py-0 pl-2">
  199. <?php $myNotes = $patient->recentNotes($pro); ?>
  200. <table class="table table-sm table-condensed table-bordered m-0 width-200px">
  201. <tbody>
  202. @foreach($myNotes 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. </td>
  207. <td>{{$note->new_or_fu_or_na}}</td>
  208. </tr>
  209. @endforeach
  210. </tbody>
  211. </table>
  212. </td>
  213. <td>
  214. <table class="table table-sm border-0 my-0">
  215. <tbody>
  216. <?php $numAppts = 0; ?>
  217. @foreach($patient->upcomingAppointments as $appointment)
  218. @if($appointment->status !== 'CANCELLED' && $appointment->status !== 'ABANDONED')
  219. <tr>
  220. <td class="text-black p-0 border-0">
  221. <div class="pb-0">
  222. {{ friendly_date_time($appointment->start_time, false) }}, {{ friendly_time($appointment->raw_start_time) }}
  223. <span class="d-inline-block text-secondary text-sm">({{ $appointment->timezone }})</span>
  224. <br>
  225. <b class="mr-1">{{$appointment->pro->displayName()}}</b>
  226. <span class="text-secondary text-sm">({{ $appointment->status }})</span>
  227. </div>
  228. </td>
  229. </tr>
  230. <?php $numAppts++; ?>
  231. @endif
  232. @endforeach
  233. @if(!$numAppts)
  234. <tr>
  235. <td class="text-secondary p-0 border-0">
  236. No upcoming appointments
  237. </td>
  238. </tr>
  239. @endif
  240. </tbody>
  241. </table>
  242. </td>
  243. <td>
  244. @if($patient->linkedAccounts && count($patient->linkedAccounts))
  245. <span class="font-weight-bold text-info"><i class="fa fa-check"></i></span>
  246. @else
  247. <span class="text-secondary">-</span>
  248. @endif
  249. </td>
  250. <td>
  251. @if($patient->tags)
  252. <?php
  253. $tags = explode("|", $patient->tags);
  254. $tags = array_filter($tags, function($_x) {
  255. return !empty($_x);
  256. });
  257. $tags = implode(", ", $tags);
  258. ?>
  259. {{ $tags }}
  260. @endif
  261. </td>
  262. </tr>
  263. @endforeach
  264. </tbody>
  265. </table>
  266. <div class="ml-2 mt-2">
  267. {{$patients->links()}}
  268. </div>
  269. </div>
  270. </div>
  271. </div>
  272. <script>
  273. (function() {
  274. function init() {
  275. function submit() {
  276. let url = '/patients' +
  277. ($('#patients-filter').val() ? '/' + $('#patients-filter').val() : '') +
  278. ($('#patients-search input').val() ? '?q=' + encodeURIComponent($('#patients-search input').val()) : '');
  279. fastLoad(url);
  280. return false;
  281. }
  282. $('#patients-search').off('submit').on('submit', submit);
  283. $('#patients-filter').off('change').on('change', submit);
  284. @if($pro->id === 1 || $pro->id === 16)
  285. patientAcquisitionChart();
  286. @endif
  287. }
  288. @if($pro->pro_type === 'ADMIN')
  289. <?php
  290. $dates = [];
  291. $acquisitions = [];
  292. for ($i = count($patientAcquisitionData) - 1; $i >= 0; $i--) {
  293. $dates[] = $patientAcquisitionData[$i]->date;
  294. $acquisitions[] = $patientAcquisitionData[$i]->count;
  295. }
  296. ?>
  297. function patientAcquisitionChart() {
  298. var chart = c3.generate({
  299. bindto: '#patientAcquisitionChart',
  300. data: {
  301. x: 'x',
  302. // xFormat: '%Y%m%d', // 'xFormat' can be used as custom format of 'x'
  303. columns: [
  304. ['x', <?= implode(", ", array_map(function($_x) { return "'" . $_x . "'"; }, $dates)) ?>],
  305. ['New Patients', <?= implode(", ", array_map(function($_x) { return "'" . $_x . "'"; }, $acquisitions)) ?>],
  306. ]
  307. },
  308. axis: {
  309. x: {
  310. type: 'timeseries',
  311. tick: {
  312. format: '%Y-%m-%d',
  313. multiline: true,
  314. fit: true,
  315. rotate: -45
  316. },
  317. },
  318. }
  319. });
  320. }
  321. @endif
  322. addMCInitializer('patients-list', init, '#patients-list');
  323. }).call(window);
  324. </script>
  325. @endsection