<?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 WardHandover extends Model
{
    use BelongsToOwner, SoftDeletes;

    public const STATUS_DRAFT = 'draft';

    public const STATUS_COMPLETED = 'completed';

    protected $table = 'care_ward_handovers';

    protected $fillable = [
        'owner_ref',
        'organization_id',
        'care_unit_id',
        'from_shift',
        'to_shift',
        'handed_over_at',
        'handed_over_by',
        'received_by',
        'situation',
        'background',
        'assessment',
        'recommendation',
        'patient_summaries',
        'status',
    ];

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

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

    public function organization(): BelongsTo
    {
        return $this->belongsTo(Organization::class, 'organization_id');
    }
}
