{{-- Ophthalmology specialty fields, injected into ClinicCore's patient form
     via the SpecialtyDriverRegistry. Receives $patient (ClcPatient|null). --}}
@php
    $ophth = (isset($patient) && $patient)
        ? \Modules\OphthalmologyClinic\Entities\OphthPatientProfile::where('clc_patient_id', $patient->id)->first()
        : null;
    $val = fn($f) => old($f, $ophth->{$f} ?? '');
@endphp
<div class="row">
    <div class="col-md-12"><h5 style="margin:6px 0;"><i class="fas fa-eye" style="color:#6610f2;"></i> Ophthalmology</h5><hr style="margin:4px 0 12px;"></div>
</div>
<table class="table table-sm" style="margin-bottom:8px;">
    <thead>
        <tr><th style="width:34%;"></th><th>Right (OD)</th><th>Left (OS)</th></tr>
    </thead>
    <tbody>
        <tr>
            <td><strong>Visual acuity</strong></td>
            <td><input type="text" name="va_right" class="form-control input-sm" placeholder="6/6" value="{{ $val('va_right') }}"></td>
            <td><input type="text" name="va_left" class="form-control input-sm" placeholder="6/6" value="{{ $val('va_left') }}"></td>
        </tr>
        <tr>
            <td><strong>Sphere</strong></td>
            <td><input type="number" step="0.25" name="sphere_right" class="form-control input-sm" placeholder="±0.00" value="{{ $val('sphere_right') }}"></td>
            <td><input type="number" step="0.25" name="sphere_left" class="form-control input-sm" placeholder="±0.00" value="{{ $val('sphere_left') }}"></td>
        </tr>
        <tr>
            <td><strong>Cylinder</strong></td>
            <td><input type="number" step="0.25" name="cylinder_right" class="form-control input-sm" placeholder="±0.00" value="{{ $val('cylinder_right') }}"></td>
            <td><input type="number" step="0.25" name="cylinder_left" class="form-control input-sm" placeholder="±0.00" value="{{ $val('cylinder_left') }}"></td>
        </tr>
        <tr>
            <td><strong>Axis</strong></td>
            <td><input type="number" min="0" max="180" name="axis_right" class="form-control input-sm" placeholder="0–180" value="{{ $val('axis_right') }}"></td>
            <td><input type="number" min="0" max="180" name="axis_left" class="form-control input-sm" placeholder="0–180" value="{{ $val('axis_left') }}"></td>
        </tr>
        <tr>
            <td><strong>IOP (mmHg)</strong></td>
            <td><input type="number" step="0.1" name="iop_right" class="form-control input-sm" placeholder="10–21" value="{{ $val('iop_right') }}"></td>
            <td><input type="number" step="0.1" name="iop_left" class="form-control input-sm" placeholder="10–21" value="{{ $val('iop_left') }}"></td>
        </tr>
    </tbody>
</table>
<div class="row">
    <div class="col-md-4">
        <div class="checkbox">
            <label><input type="checkbox" name="wears_glasses" value="1" {{ old('wears_glasses', $ophth->wears_glasses ?? false) ? 'checked' : '' }}> Wears glasses / lenses</label>
        </div>
    </div>
    <div class="col-md-8">
        <div class="form-group">
            <label>Ophthalmic notes</label>
            <input type="text" name="notes" class="form-control" value="{{ $val('notes') }}" placeholder="Cataract, glaucoma, diabetic retinopathy…">
        </div>
    </div>
</div>
