|
Patient
@if($questionsWithAnswers && $questionsWithAnswers->isNotEmpty() && $questionsWithAnswers->first() && isset($questionsWithAnswers->first()->PATIENT_ID))
@php
// For contract bookings, check if there's a package with this identification
$genderId = null;
$patient = null;
$patientName = null;
$patientIdentification = null;
// Check order packages for contract booking patient info
if(isset($order) && $order->Packages && $order->Packages->isNotEmpty()) {
foreach($order->Packages as $package) {
// Get GENDER_ID from pivot
$packageGenderId = $package->pivot->GENDER_ID ?? null;
$packageIdentification = $package->pivot->IDENTIFICATION ?? null;
// Match by identification if provided, otherwise use first package
if($packageGenderId && (empty($identification) || $packageIdentification == $identification)) {
$genderId = $packageGenderId;
// Also get name from pivot if available
$patientName = $package->pivot->NAME ?? null;
$patientIdentification = $packageIdentification;
break;
}
}
}
// Fall back to patient lookup if no gender from package
if(!$genderId) {
$patient = \App\Models\ENDUSER::find($questionsWithAnswers->first()->PATIENT_ID);
if($patient) {
$genderId = $patient->GENDER_ID;
$patientName = $patient->FULL_NAME;
$patientIdentification = $patient->IDENTIFICATION;
}
}
@endphp
@if($patientName || $genderId)
{{ $patientName ?? '' }}
@if($genderId)
{{ $genderId == 1 ? 'Male' : ($genderId == 2 ? 'Female' : 'Unknown') }}
@endif
@if($patientIdentification)
{{ $patientIdentification }}
@endif
@endif
@endif
|
Order
@if($questionsWithAnswers && $questionsWithAnswers->isNotEmpty() && $questionsWithAnswers->first() && isset($questionsWithAnswers->first()->END_USER_LAB_ORDER_ID))
Reservation ID:{{ $questionsWithAnswers->first()->END_USER_LAB_ORDER_ID }}
@if(isset($order) && $order && $order->HOSPITAL)
Branch:{{ isset($lang) && $lang === 'ar' ? ($order->HOSPITAL->NAME_AR ?: $order->HOSPITAL->NAME_EN) : $order->HOSPITAL->NAME_EN }}
@endif
@endif
|
Test
@if($questionsWithAnswers && $questionsWithAnswers->isNotEmpty() && $questionsWithAnswers->first() && isset($questionsWithAnswers->first()->LAB_CATEGORY_PACKAGE_ID))
@php
$test = \App\Models\LABCATEGORYPACKAGE::find($questionsWithAnswers->first()->LAB_CATEGORY_PACKAGE_ID);
@endphp
@if($test)
{{ isset($lang) && $lang === 'ar' ? ($test->NAME_AR ?: $test->NAME_EN) : $test->NAME_EN }}
@endif
@endif
|
Questions
@if($questionsWithAnswers)
@php
$totalQuestions = $questionsWithAnswers->count();
$answeredQuestions = $questionsWithAnswers->filter(function($q) {
if (isset($q->question) && ($q->question->TYPE == 'SELECT' || $q->question->TYPE == 'MULTIPLE_SELECT')) {
return !empty($q->OPTION_ID);
} elseif (isset($q->question) && $q->question->TYPE == 'FILE') {
return !empty($q->ANSWER) && str_starts_with($q->ANSWER, '/');
} else {
return !empty($q->ANSWER);
}
})->count();
$pendingQuestions = $totalQuestions - $answeredQuestions;
@endphp
Total:{{ $totalQuestions }}
Answered:{{ $answeredQuestions }}
Pending:{{ $pendingQuestions }}
@else
Total:0
Answered:0
Pending:0
@endif
|