@extends('dashboard.doctor.layouts.master') @section('title', trans('doctor.visits.title')) @section('toolbar')

{{ trans('doctor.visits.title') }} — {{ $booking->patient->name }}

{{ trans('doctor.visits.view_patient') }}
@endsection @section('content') @php $na = trans('doctor.common.not_available'); $statusBadge = ['pending' => 'warning', 'confirmed' => 'success', 'completed' => 'info', 'cancelled' => 'danger'][$booking->status] ?? 'secondary'; $fileIcon = fn ($type, $path) => $type === 'image' || preg_match('/\.(jpe?g|png|webp|gif)$/i', (string) $path) ? 'image' : 'file'; $patient = $booking->patient; @endphp
@if(session('success'))
{{ session('success') }}
@endif
{{-- Patient, medical history and files --}}
{{ mb_substr((string) $patient->name, 0, 1) }}
{{ $patient->name }}
{{ $patient->phone }}
@if ($profile?->date_of_birth) {{ trans('clinic.patients.age', ['age' => \Illuminate\Support\Carbon::parse($profile->date_of_birth)->age]) }} @endif @if ($profile?->gender) {{ trans('clinic.patients.gender_' . $profile->gender) }} @endif @if ($profile?->occupation) {{ $profile->occupation }} @endif

{{ trans('doctor.patients.medical_history') }}

@if (! $profile)
{{ $na }}
@else @php $conditions = $conditionOptions->filter(fn ($o) => ! empty($profile->medical_history[$o->code] ?? false)); $medications = $medicationOptions->filter(fn ($o) => ! empty($profile->medication_history[$o->code] ?? false)); @endphp
{{ trans('clinic.patient_profile.medical_history') }}
@forelse ($conditions as $option) {{ $option->name }} @empty {{ $na }} @endforelse @if (! empty($profile->medical_history['other'] ?? null))
{{ $profile->medical_history['other'] }}
@endif
{{ trans('clinic.patient_profile.medication_history') }}
@forelse ($medications as $option) {{ $option->name }} @empty {{ $na }} @endforelse @foreach (['other', 'notes'] as $key) @if (! empty($profile->medication_history[$key] ?? null))
{{ $profile->medication_history[$key] }}
@endif @endforeach
{{ trans('clinic.patient_profile.surgical_history') }}
@if (! empty($profile->surgical_history['had_surgery'] ?? false))
{{ $profile->surgical_history['type'] ?? '' }} · {{ $profile->surgical_history['hospital'] ?? '' }} {{ $profile->surgical_history['date'] ?? '' }}
@else {{ $na }} @endif
{{ trans('clinic.patient_profile.allergies') }}
@if ($profile->allergy_type) {{ trans('clinic.patient_profile.allergy_types.' . $profile->allergy_type) }} {{ $profile->allergy_substance }} @if ($profile->allergy_severity)({{ trans('clinic.patient_profile.severities.' . $profile->allergy_severity) }})@endif @if ($profile->allergy_notes)
{{ $profile->allergy_notes }}
@endif @else {{ $na }} @endif
@endif

{{ trans('doctor.visits.patient_files') }} {{ $patientFiles->count() }}

{{-- The visit --}}

{{ trans('doctor.visits.booking_details') }} #{{ $booking->id }}

{{ trans('doctor.schedule.statuses.' . $booking->status) }}
@foreach ([ [trans('doctor.schedule.date'), $booking->scheduled_at->format('Y-m-d h:i A'), 'ltr'], [trans('doctor.schedule.type'), trans('doctor.schedule.types.' . $booking->type), 'auto'], [trans('doctor.schedule.branch'), $booking->branch?->name, 'auto'], [trans('doctor.visits.clinic'), $booking->clinicProfile?->name, 'auto'], [trans('doctor.visits.duration'), $booking->duration_minutes ? trans('doctor.visits.minutes', ['count' => $booking->duration_minutes]) : null, 'auto'], [trans('doctor.visits.price'), number_format((float) $booking->price, 2), 'ltr'], [trans('doctor.visits.payment'), $booking->payment?->status === 'paid' ? trans('doctor.visits.paid_online') : (in_array($booking->status, ['confirmed', 'completed'], true) ? trans('doctor.visits.paid') : trans('doctor.visits.unpaid')), 'auto'], [trans('doctor.visits.my_share'), $booking->doctor_share_amount !== null ? number_format((float) $booking->doctor_share_amount, 2) : null, 'ltr'], ] as [$label, $value, $dir])
{{ $label }}
{{ $value ?: $na }}
@endforeach
@if ($booking->status === 'cancelled')
{{ trans('doctor.visits.cancelled_on', ['date' => $booking->cancelled_at?->format('Y-m-d H:i')]) }} @if ($booking->cancel_reason)
{{ $booking->cancel_reason }}
@endif
@endif @if ($booking->rescheduledFrom)
{{ trans('doctor.visits.rescheduled_from', ['date' => $booking->rescheduledFrom->scheduled_at?->format('Y-m-d H:i')]) }}
@endif @if ($booking->followupSource)
{{ trans('doctor.visits.is_followup_of', ['date' => $booking->followupSource->booking?->scheduled_at?->format('Y-m-d')]) }}
@endif @if ($booking->followup)
{{ trans('clinic.followups.title') }}: {{ trans('clinic.followups.statuses.' . $booking->followup->status) }} @if ($booking->followup->due_date) · {{ $booking->followup->due_date->format('Y-m-d') }}@endif @if ($booking->followup->doctor_note)
{{ $booking->followup->doctor_note }}
@endif
@endif @if ($booking->review)
{{ trans('doctor.visits.patient_review') }} @for ($i = 1; $i <= 5; $i++)@endfor
@if ($booking->review->doctor_comment)
{{ $booking->review->doctor_comment }}
@endif
@endif

{{ trans('doctor.visits.patient_attachments') }} {{ $booking->attachments->count() }}

@if ($booking->attachments->isEmpty())
{{ trans('doctor.visits.no_booking_files') }}
@else @endif
@if($booking->medicalRecord)

{{ trans('doctor.visits.record_title') }}

{{ trans('doctor.visits.diagnosis') }}
{{ $booking->medicalRecord->diagnosis ?: trans('doctor.common.not_available') }}
{{ trans('doctor.visits.prescription') }}
{{ $booking->medicalRecord->prescription ?: trans('doctor.common.not_available') }}
{{ trans('doctor.visits.report') }}
{{ $booking->medicalRecord->report ?: trans('doctor.common.not_available') }}
@if($booking->medicalRecord->attachment_path)
{{ trans('doctor.visits.attachment') }}
@if($booking->medicalRecord->attachment_type === 'image') @else {{ trans('doctor.visits.view_file') }} @endif
@endif
{{ trans('doctor.visits.published_at') }}: {{ $booking->medicalRecord->published_at?->format('Y-m-d H:i') }} @if($booking->medicalRecord->last_edited_at) — {{ trans('doctor.visits.last_edited_at') }}: {{ $booking->medicalRecord->last_edited_at->format('Y-m-d H:i') }} @endif
{{ trans('doctor.visits.edit_record') }}
@else

{{ trans('doctor.visits.record_the_visit') }}

@csrf
@endif

{{ trans('doctor.visits.previous_visits') }} {{ $previousVisits->count() }}

@forelse ($previousVisits as $visit)
{{ $visit->scheduled_at?->format('d M') }}
{{ $visit->scheduled_at?->format('Y') }}
{{ trans('doctor.schedule.types.' . $visit->type) }} {{ trans('doctor.schedule.statuses.' . $visit->status) }}
@if ($visit->medicalRecord)
{{ trans('doctor.visits.diagnosis') }}: {{ $visit->medicalRecord->diagnosis ?: $na }}
{{ trans('doctor.visits.prescription') }}: {{ $visit->medicalRecord->prescription ?: $na }}
@endif @if ($visit->attachments->isNotEmpty())
{{ $visit->attachments->count() }}
@endif
{{ trans('doctor.visits.open') }}
@empty
{{ trans('doctor.visits.no_previous_visits') }}
@endforelse
@endsection @section('js') @endsection