<?php

namespace App\Models;

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

class InvestigationResultValue extends Model
{
    use BelongsToOwner;

    protected $table = 'care_investigation_result_values';

    protected $fillable = [
        'owner_ref', 'investigation_result_id', 'parameter', 'value', 'unit',
        'reference_low', 'reference_high', 'reference_text', 'is_abnormal',
    ];

    protected function casts(): array
    {
        return [
            'reference_low' => 'decimal:4',
            'reference_high' => 'decimal:4',
            'is_abnormal' => 'boolean',
        ];
    }

    public function result(): BelongsTo
    {
        return $this->belongsTo(InvestigationResult::class, 'investigation_result_id');
    }
}
