<?php

namespace App\Models;

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

class Visit extends Model
{
    use BelongsToCompany;

    protected $fillable = [
        'company_id',
        'patient_id',
        'doctor_id',
        'appointment_id',
        'visit_date',
        'chief_complaint',
        'complaint_details',
        'symptoms',
        'diagnosis',
        'examination_notes',
        'blood_pressure',
        'pulse',
        'temperature',
        'weight',
        'height',
        'treatment_plan',
        'prescription_notes',
        'required_tests',
        'required_radiology',
        'follow_up_date',
        'private_notes',
        'status',
    ];

    protected $casts = [
        'visit_date' => 'datetime',
        'follow_up_date' => 'date',
    ];

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

    public function doctor(): BelongsTo
    {
        return $this->belongsTo(User::class, 'doctor_id');
    }

    public function invoice(): HasOne
    {
        return $this->hasOne(Invoice::class);
    }
}
