patients.blade.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  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 && $patient->cmSetupNote)
  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. <?php $coverageStatus = $patient->getPrimaryCoverageStatus(); ?>
  176. @if($coverageStatus === 'YES')
  177. <div class="text-nowrap">Covered <i class="fa fa-check-circle text-success"></i>
  178. </div>
  179. @elseif($coverageStatus === 'NO')
  180. <div class="text-nowrap">Not Covered <i class="fa fa-times text-danger"></i></div>
  181. @else
  182. <div class="text-nowrap">Unknown <i
  183. class="fa fa-exclamation-triangle text-warning-mellow"></i></div>
  184. @endif
  185. <?php $coverage = $patient->getPrimaryCoverage(); ?>
  186. @if($coverage)
  187. {{$coverage->toString()}}
  188. @endif
  189. @include('app.patient.coverage-status')
  190. </td>
  191. <td>
  192. {{ $patient->mcp ? $patient->mcp->displayName() : '-' }}
  193. </td>
  194. <td class="p-0">
  195. <?php $allNotes = $patient->recentNotes(); ?>
  196. <table class="table table-sm table-condensed table-bordered m-0 width-200px">
  197. <tbody>
  198. @foreach($allNotes as $note)
  199. <tr>
  200. <td>
  201. <a href="{{route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $note])}}"><b class="text-nowrap">{{friendlier_date($note->effective_dateest)}}</b></a>
  202. <br>
  203. <span class="text-nowrap">{{$note->hcpPro->displayName()}}</span>
  204. </td>
  205. <td>{{$note->new_or_fu_or_na}}</td>
  206. </tr>
  207. @endforeach
  208. </tbody>
  209. </table>
  210. </td>
  211. <td class="py-0 pl-2">
  212. <?php $myNotes = $patient->recentNotes($pro); ?>
  213. <table class="table table-sm table-condensed table-bordered m-0 width-200px">
  214. <tbody>
  215. @foreach($myNotes as $note)
  216. <tr>
  217. <td>
  218. <a href="{{route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $note])}}"><b class="text-nowrap">{{friendlier_date($note->effective_dateest)}}</b></a>
  219. </td>
  220. <td>{{$note->new_or_fu_or_na}}</td>
  221. </tr>
  222. @endforeach
  223. </tbody>
  224. </table>
  225. </td>
  226. <td>
  227. <table class="table table-sm border-0 my-0">
  228. <tbody>
  229. <?php $numAppts = 0; ?>
  230. @foreach($patient->upcomingAppointments as $appointment)
  231. @if($appointment->status !== 'CANCELLED' && $appointment->status !== 'ABANDONED')
  232. <tr>
  233. <td class="text-black p-0 border-0">
  234. <div class="pb-0">
  235. {{ friendly_date_time($appointment->start_time, false) }}, {{ friendly_time($appointment->raw_start_time) }}
  236. <span class="d-inline-block text-secondary text-sm">({{ $appointment->timezone }})</span>
  237. <br>
  238. <b class="mr-1">{{$appointment->pro->displayName()}}</b>
  239. <span class="text-secondary text-sm">({{ $appointment->status }})</span>
  240. </div>
  241. </td>
  242. </tr>
  243. <?php $numAppts++; ?>
  244. @endif
  245. @endforeach
  246. @if(!$numAppts)
  247. <tr>
  248. <td class="text-secondary p-0 border-0">
  249. No upcoming appointments
  250. </td>
  251. </tr>
  252. @endif
  253. </tbody>
  254. </table>
  255. </td>
  256. <td>
  257. @if($patient->linkedAccounts && count($patient->linkedAccounts))
  258. <span class="font-weight-bold text-info"><i class="fa fa-check"></i></span>
  259. @else
  260. <span class="text-secondary">-</span>
  261. @endif
  262. </td>
  263. <td>
  264. @if($patient->tags)
  265. <?php
  266. $tags = explode("|", $patient->tags);
  267. $tags = array_filter($tags, function($_x) {
  268. return !empty($_x);
  269. });
  270. $tags = implode(", ", $tags);
  271. ?>
  272. {{ $tags }}
  273. @endif
  274. </td>
  275. </tr>
  276. @endforeach
  277. </tbody>
  278. </table>
  279. <div class="ml-2 mt-2">
  280. {{$patients->links()}}
  281. </div>
  282. </div>
  283. </div>
  284. </div>
  285. <script>
  286. (function() {
  287. function init() {
  288. function submit() {
  289. let url = '/patients' +
  290. ($('#patients-filter').val() ? '/' + $('#patients-filter').val() : '') +
  291. ($('#patients-search input').val() ? '?q=' + encodeURIComponent($('#patients-search input').val()) : '');
  292. fastLoad(url);
  293. return false;
  294. }
  295. $('#patients-search').off('submit').on('submit', submit);
  296. $('#patients-filter').off('change').on('change', submit);
  297. @if($pro->id === 1 || $pro->id === 16)
  298. patientAcquisitionChart();
  299. @endif
  300. }
  301. @if($pro->pro_type === 'ADMIN')
  302. <?php
  303. $dates = [];
  304. $acquisitions = [];
  305. for ($i = count($patientAcquisitionData) - 1; $i >= 0; $i--) {
  306. $dates[] = $patientAcquisitionData[$i]->date;
  307. $acquisitions[] = $patientAcquisitionData[$i]->count;
  308. }
  309. ?>
  310. function patientAcquisitionChart() {
  311. var chart = c3.generate({
  312. bindto: '#patientAcquisitionChart',
  313. data: {
  314. x: 'x',
  315. // xFormat: '%Y%m%d', // 'xFormat' can be used as custom format of 'x'
  316. columns: [
  317. ['x', <?= implode(", ", array_map(function($_x) { return "'" . $_x . "'"; }, $dates)) ?>],
  318. ['New Patients', <?= implode(", ", array_map(function($_x) { return "'" . $_x . "'"; }, $acquisitions)) ?>],
  319. ]
  320. },
  321. axis: {
  322. x: {
  323. type: 'timeseries',
  324. tick: {
  325. format: '%Y-%m-%d',
  326. multiline: true,
  327. fit: true,
  328. rotate: -45
  329. },
  330. },
  331. }
  332. });
  333. }
  334. @endif
  335. addMCInitializer('patients-list', init, '#patients-list');
  336. }).call(window);
  337. </script>
  338. @endsection