Note.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. namespace App\Models;
  3. # use Illuminate\Database\Eloquent\Model;
  4. class Note extends Model
  5. {
  6. protected $table = "note";
  7. public function client()
  8. {
  9. return $this->hasOne(Client::class, 'id', 'client_id');
  10. }
  11. public function hcpPro()
  12. {
  13. return $this->hasOne(Pro::class, 'id', 'hcp_pro_id');
  14. }
  15. public function noteTemplate()
  16. {
  17. return $this->hasOne(NoteTemplate::class, 'id', 'note_template_id');
  18. }
  19. public function createdSession()
  20. {
  21. return $this->hasOne(AppSession::class, 'id', 'created_by_session_id');
  22. }
  23. public function allyPro()
  24. {
  25. return $this->hasOne(Pro::class, 'id', 'ally_pro_id');
  26. }
  27. public function bills()
  28. {
  29. return $this->hasMany(Bill::class, 'note_id', 'id')
  30. ->where('bill_service_type', '<>', 'GENERIC')
  31. ->orderBy('id', 'asc');
  32. }
  33. public function addendums()
  34. {
  35. return $this->hasMany(NoteAddendum::class, 'note_id', 'id')->where('is_removed', false);
  36. }
  37. public function sections()
  38. {
  39. return $this->hasMany(Section::class, 'note_id', 'id')
  40. ->where('is_active', true)
  41. ->orderBy('position_index', 'asc');
  42. }
  43. public function reasons()
  44. {
  45. return $this->hasMany(NoteReason::class, 'note_id', 'id');
  46. }
  47. public function claims()
  48. {
  49. return $this->hasMany(Claim::class, 'note_id', 'id')->orderBy('created_at', 'DESC');
  50. }
  51. public function summary()
  52. {
  53. $parts = [];
  54. foreach ($this->sections as $section) {
  55. $parts[] = $section->summary_html;
  56. }
  57. $parts = array_map(function($_part) {
  58. return '<div class="note-section-summary">' . $_part . '</div>';
  59. }, $parts);
  60. return implode("", $parts);
  61. }
  62. public function hcpCompany()
  63. {
  64. return $this->hasOne(Company::class, 'id', 'hcp_company_id');
  65. }
  66. public function hcpCompanyProPayer()
  67. {
  68. return $this->hasOne(CompanyProPayer::class, 'id', 'hcp_company_pro_payer_id');
  69. }
  70. public function hcpCompanyLocation()
  71. {
  72. return $this->hasOne(CompanyLocation::class, 'id', 'hcp_company_location_id');
  73. }
  74. public function currentNotePickupForProcessing() {
  75. return $this->hasOne(NotePickupForProcessing::class, 'id', 'current_note_pickup_for_processing_id');
  76. }
  77. }