PatientController.php 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Models\Appointment;
  4. use App\Models\BDTDevice;
  5. use App\Models\CareMonth;
  6. use App\Models\Client;
  7. use App\Models\ClientBDTDevice;
  8. use App\Models\ClientInfoLine;
  9. use App\Models\Facility;
  10. use App\Models\Handout;
  11. use App\Models\NoteTemplate;
  12. use App\Models\Pro;
  13. use App\Models\Program;
  14. use App\Models\SectionTemplate;
  15. use Illuminate\Http\Request;
  16. use Illuminate\Support\Facades\File;
  17. class PatientController extends Controller
  18. {
  19. public function dashboard(Request $request, Client $patient )
  20. {
  21. $mcpPros = Pro::where('is_enrolled_as_mcp', true)->get();
  22. $facilities = Facility::where('is_active', true)->get();
  23. $devices = BDTDevice::where('is_active', true)->orderBy('imei', 'asc')->get();
  24. $devices = $devices->filter(function ($record) {
  25. $matching = ClientBDTDevice::where('device_id', $record->id)->get();
  26. return count($matching) === 0;
  27. });
  28. $dxInfoLines = ClientInfoLine::where('client_id', $patient->id)
  29. ->where('category', 'dx')
  30. ->where('is_removed', false)
  31. ->orderBy('content_text', 'asc')
  32. ->get();
  33. return view('app.patient.dashboard',
  34. compact('patient', 'facilities', 'devices', 'dxInfoLines'));
  35. }
  36. public function actionItems(Request $request, Client $patient )
  37. {
  38. $facilities = Facility::where('is_active', true)->get();
  39. return view('app.patient.action-items', compact('patient', 'facilities'));
  40. }
  41. public function actionItemsErx(Request $request, Client $patient, $filter = 'open')
  42. {
  43. $allPros = Pro::all();
  44. $facilities = Facility::where('is_active', true)->get();
  45. return view('app.patient.action-items-erx', compact('patient', 'facilities', 'filter', 'allPros'));
  46. }
  47. public function actionItemsLab(Request $request, Client $patient, $filter = 'open')
  48. {
  49. $allPros = Pro::all();
  50. $facilities = Facility::where('is_active', true)->get();
  51. return view('app.patient.action-items-lab', compact('patient', 'facilities', 'filter', 'allPros'));
  52. }
  53. public function actionItemsImaging(Request $request, Client $patient, $filter = 'open')
  54. {
  55. $allPros = Pro::all();
  56. $facilities = Facility::where('is_active', true)->get();
  57. return view('app.patient.action-items-imaging', compact('patient', 'facilities', 'filter', 'allPros'));
  58. }
  59. public function actionItemsEquipment(Request $request, Client $patient, $filter = 'open')
  60. {
  61. $allPros = Pro::all();
  62. $facilities = Facility::where('is_active', true)->get();
  63. return view('app.patient.action-items-equipment', compact('patient', 'facilities', 'filter', 'allPros'));
  64. }
  65. public function actionItemsOther(Request $request, Client $patient, $filter = 'open')
  66. {
  67. $allPros = Pro::all();
  68. $facilities = Facility::where('is_active', true)->get();
  69. return view('app.patient.action-items-other', compact('patient', 'facilities', 'filter', 'allPros'));
  70. }
  71. public function intake(Request $request, Client $patient )
  72. {
  73. $files = File::allFiles(resource_path('views/app/intake-templates'));
  74. $templates = [];
  75. foreach ($files as $file) {
  76. $templates[] = str_replace(".blade.php", "", $file->getFilename());
  77. }
  78. return view('app.patient.intake', compact('patient', 'templates'));
  79. }
  80. public function carePlan(Request $request, Client $patient )
  81. {
  82. return view('app.patient.care-plan', compact('patient'));
  83. }
  84. public function medications(Request $request, Client $patient )
  85. {
  86. $infoLines = ClientInfoLine::where('client_id', $patient->id)
  87. ->where('category', 'rx')
  88. ->where('is_removed', false)
  89. ->orderBy('content_text', 'asc')
  90. ->get();
  91. return view('app.patient.medications', compact('patient', 'infoLines'));
  92. }
  93. public function dxAndFocusAreas(Request $request, Client $patient )
  94. {
  95. $dxInfoLines = ClientInfoLine::where('client_id', $patient->id)
  96. ->where('category', 'dx')
  97. ->where('is_removed', false)
  98. ->orderBy('content_text', 'asc')
  99. ->get();
  100. return view('app.patient.dx-and-focus-areas', compact('patient', 'dxInfoLines'));
  101. }
  102. public function careTeam(Request $request, Client $patient )
  103. {
  104. $infoLines = ClientInfoLine::where('client_id', $patient->id)
  105. ->where('category', 'care_team')
  106. ->where('is_removed', false)
  107. ->get();
  108. return view('app.patient.care-team', compact('patient', 'infoLines'));
  109. }
  110. public function devices(Request $request, Client $patient )
  111. {
  112. $devices = BDTDevice::where('is_active', true)->get();
  113. $devices = $devices->filter(function ($record) {
  114. $matching = ClientBDTDevice::where('device_id', $record->id)->get();
  115. return count($matching) === 0;
  116. });
  117. return view('app.patient.devices', compact('patient', 'devices'));
  118. }
  119. public function measurements(Request $request, Client $patient )
  120. {
  121. return view('app.patient.measurements', compact('patient'));
  122. }
  123. public function labsAndStudies(Request $request, Client $patient )
  124. {
  125. return view('app.patient.labs-and-studies', compact('patient'));
  126. }
  127. public function history(Request $request, Client $patient )
  128. {
  129. $infoLines = ClientInfoLine::where('client_id', $patient->id)
  130. ->where('category', 'LIKE', 'history_%')
  131. ->where('is_removed', false)
  132. ->get();
  133. return view('app.patient.history', compact('patient', 'infoLines'));
  134. }
  135. public function memos(Request $request, Client $patient )
  136. {
  137. return view('app.patient.memos', compact('patient'));
  138. }
  139. public function sms(Request $request, Client $patient )
  140. {
  141. return view('app.patient.sms', compact('patient'));
  142. }
  143. public function smsNumbers(Request $request, Client $patient )
  144. {
  145. return view('app.patient.sms-numbers', compact('patient'));
  146. }
  147. public function immunizations(Request $request, Client $patient )
  148. {
  149. return view('app.patient.immunizations', compact('patient'));
  150. }
  151. public function allergies(Request $request, Client $patient )
  152. {
  153. $infoLines = ClientInfoLine::where('client_id', $patient->id)
  154. ->where('category', 'allergy')
  155. ->where('is_removed', false)
  156. ->get();
  157. return view('app.patient.allergies', compact('patient', 'infoLines'));
  158. }
  159. public function notes(Request $request, Client $patient, $filter = 'active')
  160. {
  161. $pros = $this->pros;
  162. return view('app.patient.notes', compact('patient','pros', 'filter'));
  163. }
  164. public function sections(Request $request, Client $patient )
  165. {
  166. $pros = $this->pros;
  167. $sections = $patient->sections;
  168. $allSections = SectionTemplate::where('is_active', true)->get();
  169. foreach ($allSections as $section) {
  170. $section->used = false;
  171. foreach ($sections as $section) {
  172. if ($section->sectionTemplate->id === $section->id) {
  173. $section->used = true;
  174. $section->section_uid = $section->uid;
  175. break;
  176. }
  177. }
  178. }
  179. return view('app.patient.sections', compact('patient', 'pros', 'allSections'));
  180. }
  181. public function handouts(Request $request, Client $patient )
  182. {
  183. $handouts = Handout::where('is_active', true)->get();
  184. return view('app.patient.handouts', compact('patient', 'handouts'));
  185. }
  186. public function flowSheets(Request $request, Client $patient )
  187. {
  188. return view('app.patient.flowsheets', compact('patient'));
  189. }
  190. public function settings(Request $request, Client $patient )
  191. {
  192. return view('app.patient.settings', compact('patient'));
  193. }
  194. public function account(Request $request, Client $patient )
  195. {
  196. return view('app.patient.account', compact('patient'));
  197. }
  198. public function careChecklist(Request $request, Client $patient )
  199. {
  200. return view('app.patient.care-checklist', compact('patient'));
  201. }
  202. public function documents(Request $request, Client $patient )
  203. {
  204. return view('app.patient.documents', compact('patient'));
  205. }
  206. public function education(Request $request, Client $patient )
  207. {
  208. return view('app.patient.education', compact('patient'));
  209. }
  210. public function messaging(Request $request, Client $patient )
  211. {
  212. return view('app.patient.messaging', compact('patient'));
  213. }
  214. public function duplicate(Request $request, Client $patient )
  215. {
  216. return view('app.patient.duplicate', compact('patient'));
  217. }
  218. public function careMonths(Request $request, Client $patient )
  219. {
  220. $careMonths = CareMonth::where('client_id', $patient->id)->orderBy('start_date', 'desc')->get();
  221. return view('app.patient.care-months', compact('patient', 'careMonths'));
  222. }
  223. public function presence(Request $request, Client $patient )
  224. {
  225. return json_encode([
  226. "online" => $patient->is_online
  227. ]);
  228. }
  229. public function embedSection(Request $request, Client $patient, $section, $selectable) {
  230. return view('app.patient.partials.' . $section, compact('patient', 'selectable'));
  231. }
  232. public function calendar(Request $request, Client $patient, Appointment $currentAppointment) {
  233. return view('app.patient.appointment-calendar', compact('patient', 'currentAppointment'));
  234. }
  235. public function programs(Request $request, Client $patient, $filter = '') {
  236. $pros = $this->pros;
  237. return view('app.patient.programs', compact('patient', 'pros', 'filter'));
  238. }
  239. }