<?php

namespace Modules\ClinicCore\Entities;

use Illuminate\Database\Eloquent\Model;
use App\User;

class ClcAppointmentNote extends Model
{
    protected $table = 'clc_appointment_notes';
    protected $guarded = ['id'];

    protected $casts = [
        'signed_at' => 'datetime',
    ];

    /** SIFA P3-T3 typed-note kinds (spec §7 clinical_notes.type). */
    public const NOTE_TYPES = [
        'progress', 'consultation', 'procedure', 'discharge',
        'referral', 'follow_up', 'nursing', 'other',
    ];

    public function appointment()
    {
        return $this->belongsTo(ClcAppointment::class, 'appointment_id');
    }

    public function user()
    {
        return $this->belongsTo(User::class, 'user_id');
    }

    /** P3-T3 note author (falls back to user_id for legacy rows). */
    public function author()
    {
        return $this->belongsTo(User::class, 'author_id');
    }

    public function signer()
    {
        return $this->belongsTo(User::class, 'signed_by');
    }
}
