PatientController.php 9.4 KB

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