Segment.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace App\Models;
  3. # use Illuminate\Database\Eloquent\Model;
  4. class Segment extends Model
  5. {
  6. protected $table = 'segment';
  7. public function segmentTemplate() {
  8. return $this->hasOne(SegmentTemplate::class, 'id', 'segment_template_id');
  9. }
  10. public function note() {
  11. return $this->hasOne(Note::class, 'id', 'note_id');
  12. }
  13. public function client() {
  14. return $this->hasOne(Client::class, 'id', 'client_id');
  15. }
  16. public function shortName(){
  17. return trim(array_reverse(explode('>', $this->display_title))[0]);
  18. }
  19. public function summarySuggestions()
  20. {
  21. return $this->hasMany(SegmentSummarySuggestion::class, 'segment_id', 'id');
  22. }
  23. public function summaryUpdates()
  24. {
  25. return $this->hasMany(SegmentSummaryUpdate::class, 'segment_id', 'id');
  26. }
  27. public function getRecalculatedHtml($performer){
  28. $pro = $performer->pro;
  29. $segment = $this;
  30. $segmentTemplate = $this->segmentTemplate;
  31. $note = $this->note;
  32. $patient = $note->client;
  33. $data = compact('performer', 'pro', 'segment', 'segmentTemplate', 'note', 'patient');
  34. $summaryHtml = view('app.patient.segment-templates.' . $segmentTemplate->internal_name . '/summary', $data)->render();
  35. $wizardPowered = [
  36. 'intake_medications',
  37. 'plan_medications',
  38. 'intake_problems',
  39. 'plan_problems',
  40. 'intake_goals',
  41. 'plan_goals',
  42. 'intake_allergies',
  43. 'plan_allergies',
  44. 'intake_care_team',
  45. 'plan_care_team',
  46. 'intake_supplements',
  47. 'plan_supplements'
  48. ];
  49. if(!in_array($segmentTemplate->internal_name, $wizardPowered)) {
  50. $editHtml = view('app.patient.segment-templates.' . $segmentTemplate->internal_name . '/edit', $data)->render();
  51. }
  52. return [
  53. 'summaryHtml'=> $summaryHtml ,
  54. 'editHtml' => $editHtml
  55. ];
  56. }
  57. }