1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- namespace App\Models;
- # use Illuminate\Database\Eloquent\Model;
- class Segment extends Model
- {
- protected $table = 'segment';
- public function segmentTemplate() {
- return $this->hasOne(SegmentTemplate::class, 'id', 'segment_template_id');
- }
- public function note() {
- return $this->hasOne(Note::class, 'id', 'note_id');
- }
- public function client() {
- return $this->hasOne(Client::class, 'id', 'client_id');
- }
- public function shortName(){
- return trim(array_reverse(explode('>', $this->display_title))[0]);
- }
- public function summarySuggestions()
- {
- return $this->hasMany(SegmentSummarySuggestion::class, 'segment_id', 'id');
- }
- public function summaryUpdates()
- {
- return $this->hasMany(SegmentSummaryUpdate::class, 'segment_id', 'id');
- }
- public function getRecalculatedHtml($performer){
- $pro = $performer->pro;
- $segment = $this;
- $segmentTemplate = $this->segmentTemplate;
- $note = $this->note;
- $patient = $note->client;
- $data = compact('performer', 'pro', 'segment', 'segmentTemplate', 'note', 'patient');
- $summaryHtml = view('app.patient.segment-templates.' . $segmentTemplate->internal_name . '/summary', $data)->render();
- $wizardPowered = [
- 'intake_medications',
- 'plan_medications',
- 'intake_problems',
- 'plan_problems',
- 'intake_goals',
- 'plan_goals',
- 'intake_allergies',
- 'plan_allergies',
- 'intake_care_team',
- 'plan_care_team',
- 'intake_supplements',
- 'plan_supplements'
- ];
- if(!in_array($segmentTemplate->internal_name, $wizardPowered)) {
- $editHtml = view('app.patient.segment-templates.' . $segmentTemplate->internal_name . '/edit', $data)->render();
- }
- return [
- 'summaryHtml'=> $summaryHtml ,
- 'editHtml' => $editHtml
- ];
- }
- }
|