patients.blade.php 15 KB

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