patients.blade.php 14 KB

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