{{-- Oncology Surgery specialty fields, injected into ClinicCore's patient form via the
     SpecialtyDriverRegistry. Receives $patient (ClcPatient|null). --}}
@php
    $model = \Modules\OncologySurgeryClinic\Entities\OncologySurgeryPatientProfile::class;
    $prof = (isset($patient) && $patient) ? $model::where('clc_patient_id', $patient->id)->first() : null;
    $driver = \Modules\ClinicCore\Entities\Services\SpecialtyDriverRegistry::get('oncology_surgery');
    $fields = $driver ? $driver->fields() : [];
@endphp
<div class="row">
    <div class="col-md-12"><h5 style="margin:6px 0;"><i class="fas fa-stethoscope text-primary"></i> Oncology Surgery</h5><hr style="margin:4px 0 12px;"></div>
</div>
<div class="row">
    @foreach($fields as $f)
        @php $name = $f['name']; $cur = old($name, $prof->{$name} ?? ''); @endphp
        @if($f['type'] === 'bool')
            <div class="col-md-4"><div class="checkbox" style="margin-top:24px;"><label>
                <input type="checkbox" name="{{ $name }}" value="1" {{ old($name, $prof->{$name} ?? false) ? 'checked' : '' }}> {{ $f['label'] }}
            </label></div></div>
        @else
            <div class="col-md-4"><div class="form-group">
                <label>{{ $f['label'] }}</label>
                @if($f['type'] === 'select')
                    <select name="{{ $name }}" class="form-control input-sm">
                        <option value="">—</option>
                        @foreach($f['options'] as $ov => $ol)
                            <option value="{{ $ov }}" {{ (string)$cur === (string)$ov ? 'selected' : '' }}>{{ $ol }}</option>
                        @endforeach
                    </select>
                @elseif($f['type'] === 'text')
                    <input type="text" name="{{ $name }}" class="form-control input-sm" value="{{ $cur }}">
                @elseif($f['type'] === 'int')
                    <input type="number" name="{{ $name }}" class="form-control input-sm" value="{{ $cur }}">
                @elseif($f['type'] === 'decimal')
                    <input type="number" step="0.01" name="{{ $name }}" class="form-control input-sm" value="{{ $cur }}">
                @elseif($f['type'] === 'date')
                    <input type="date" name="{{ $name }}" class="form-control input-sm" value="{{ $cur }}">
                @else
                    <input type="text" name="{{ $name }}" class="form-control input-sm" value="{{ $cur }}">
                @endif
            </div></div>
        @endif
    @endforeach
</div>
