patients.blade.php 17 KB

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