PatientController.php 8.2 KB

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