@extends('medportal::me.layout')
@section('title', __('medportal::lang.my_records'))
@section('body')
<div class="mp-card">
    <h3>@lang('medportal::lang.my_records')</h3>
    <div class="mp-body">
        <a class="mp-btn" href="{{ route('mportal.me.dashboard') }}">&larr; @lang('medportal::lang.me_title')</a>
    </div>
</div>

@if($visibility['prescription'])
<div class="mp-card">
    <h3>@lang('medportal::lang.type_prescription')</h3>
    <div class="mp-body">
        @if($prescriptions->isEmpty())<p class="mp-muted">—</p>@else
        <table>
            <tr><th>@lang('medportal::lang.date')</th><th>@lang('medportal::lang.status')</th></tr>
            @foreach($prescriptions as $p)
                <tr><td>{{ $p->prescribed_date }}</td><td>{{ $p->status ?? '' }}</td></tr>
            @endforeach
        </table>
        @endif
    </div>
</div>
@endif

@if($visibility['lab_result'] || $visibility['clinical_note'])
<div class="mp-card">
    <h3>@lang('medportal::lang.type_lab_result')</h3>
    <div class="mp-body">
        @if($reports->isEmpty())<p class="mp-muted">—</p>@else
        <table>
            <tr><th>@lang('medportal::lang.questionnaire')</th><th></th></tr>
            @foreach($reports as $r)
                <tr><td>{{ $r->report_title ?? '' }}</td><td class="mp-muted">{{ $r->report_type ?? '' }}</td></tr>
            @endforeach
        </table>
        @endif
    </div>
</div>
@endif

@if($visibility['imaging_report'])
<div class="mp-card">
    <h3>@lang('medportal::lang.type_imaging_report')</h3>
    <div class="mp-body">
        @if($imaging->isEmpty())<p class="mp-muted">—</p>@else
        <table>
            <tr><th>@lang('medportal::lang.status')</th><th>Impression</th></tr>
            @foreach($imaging as $im)
                <tr><td>{{ $im->report_status ?? '' }}</td><td>{{ \Illuminate\Support\Str::limit($im->impression ?? '', 90) }}</td></tr>
            @endforeach
        </table>
        @endif
    </div>
</div>
@endif

@if($visibility['vitals'])
<div class="mp-card">
    <h3>@lang('medportal::lang.type_vitals')</h3>
    <div class="mp-body">
        @if($vitals->isEmpty())<p class="mp-muted">—</p>@else
        <table>
            <tr><th>@lang('medportal::lang.date')</th><th>BP</th><th>Temp</th><th>Weight</th></tr>
            @foreach($vitals as $v)
                <tr>
                    <td class="mp-muted">{{ $v->recorded_at ?? '' }}</td>
                    <td>{{ $v->bp_systolic ?? '' }}{{ isset($v->bp_diastolic) ? '/' . $v->bp_diastolic : '' }}</td>
                    <td>{{ $v->temperature ?? '' }}</td>
                    <td>{{ $v->weight_kg ?? '' }}</td>
                </tr>
            @endforeach
        </table>
        @endif
    </div>
</div>
@endif
@endsection
