<?php

namespace Modules\MedPortal\Entities;

use Illuminate\Database\Eloquent\Model;

/**
 * A patient wellness-tracking reading (SIFA Phase 8, health_tools). Distinct
 * from ClinicCore clc_vitals (clinician-recorded). value_num holds a scalar;
 * value_text holds composites like BP "120/80".
 */
class MportalHealthLog extends Model
{
    protected $table = 'mportal_health_logs';

    protected $guarded = ['id'];

    protected $casts = [
        'value_num'  => 'decimal:2',
        'logged_at'  => 'datetime',
    ];

    public const METRICS = ['weight', 'blood_pressure', 'blood_glucose', 'temperature', 'mood', 'steps', 'other'];

    public function scopeForBusiness($query, $businessId)
    {
        return $query->where('business_id', $businessId);
    }

    public function scopeForPatient($query, $patientId)
    {
        return $query->where('patient_id', $patientId);
    }
}
