PatientController.php 8.2 KB

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