<?php

namespace App\Models;

use App\Models\Concerns\BelongsToOwner;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;

class NursingNote extends Model
{
    use BelongsToOwner, SoftDeletes;

    protected $table = 'care_nursing_notes';

    protected $fillable = [
        'owner_ref',
        'organization_id',
        'visit_id',
        'patient_id',
        'care_unit_id',
        'note_type',
        'shift_code',
        'body',
        'recorded_by',
        'recorded_at',
    ];

    protected function casts(): array
    {
        return [
            'recorded_at' => 'datetime',
        ];
    }

    public function visit(): BelongsTo
    {
        return $this->belongsTo(Visit::class, 'visit_id');
    }

    public function patient(): BelongsTo
    {
        return $this->belongsTo(Patient::class, 'patient_id');
    }

    public function careUnit(): BelongsTo
    {
        return $this->belongsTo(CareUnit::class, 'care_unit_id');
    }
}
