@if ($appointment->physicalExamResult && in_array($appointment->physicalExamResult->status, ['verified', 'completed']))
HASIL PEMERIKSAAN FISIK
@include('pdf.partials.patient_information')
@php // Use PhysicalExamHelper to process data $physicalData = \App\Helpers\PhysicalExamHelper::processExamData( $appointment->physicalExamResult->physical_examination_data, ); // Get field labels and field order from helper $fieldLabels = \App\Helpers\PhysicalExamHelper::getFieldLabels(); $fieldOrder = \App\Helpers\PhysicalExamHelper::getFieldOrder(); @endphp @if ($appointment->physicalExamResult)
Antropometri :
@if ($appointment->physicalExamResult->height)
{{ $appointment->physicalExamResult->height }}cm
Tinggi Badan
@endif @if ($appointment->physicalExamResult->weight)
{{ $appointment->physicalExamResult->weight }}kg
Berat Badan
@endif @if ($appointment->physicalExamResult->bmi)
{{ number_format( $appointment->physicalExamResult->bmi, 2, ) }}
@php $bmi = $appointment->physicalExamResult->bmi; $bmiCategory = ''; if ($bmi < 18.5) { $bmiCategory = 'Underweight'; } elseif ($bmi < 23) { $bmiCategory = 'Normal'; } elseif ($bmi < 25) { $bmiCategory = 'Overweight'; } elseif ($bmi < 30) { $bmiCategory = 'Obesitas I'; } else { $bmiCategory = 'Obesitas II'; } @endphp
{{ $bmiCategory }}
IMT
@endif @if ($appointment->physicalExamResult->waist_circumference)
{{ $appointment->physicalExamResult->waist_circumference }}cm
@php // Interpretasi lingkar perut dan risiko $waist = (float) $appointment->physicalExamResult->waist_circumference; $gender = $appointment->patient ? $appointment->patient->gender : 'male'; $waistNote = ''; if ($gender === 'male') { if ($waist < 90) { $waistNote = 'Normal'; } else { $waistNote = 'Beresiko'; } } else { if ($waist < 80) { $waistNote = 'Normal'; } else { $waistNote = 'Beresiko'; } } @endphp
{{ $waistNote }}
Lingkar Perut
@endif
Tanda Vital :
@if ($appointment->physicalExamResult->blood_pressure_systolic && $appointment->physicalExamResult->blood_pressure_diastolic)
{{ $appointment->physicalExamResult->blood_pressure_systolic }}/{{ $appointment->physicalExamResult->blood_pressure_diastolic }}mmHg
@php // Klasifikasi tekanan darah $sys = (int) $appointment->physicalExamResult->blood_pressure_systolic; $dia = (int) $appointment->physicalExamResult->blood_pressure_diastolic; $bpCat = ''; if ($sys >= 140 || $dia >= 90) { $bpCat = 'Hipertensi'; } else { $bpCat = 'Normal'; } @endphp
{{ $bpCat }}
Tekanan Darah
@endif @if ($appointment->physicalExamResult->heart_rate)
{{ $appointment->physicalExamResult->heart_rate }}x/m
@php // Interpretasi nadi $hr = (int) $appointment->physicalExamResult->heart_rate; $hrCat = ''; if ($hr < 60) { $hrCat = 'Bradikardi'; } elseif ($hr > 100) { $hrCat = 'Takikardi'; } else { $hrCat = 'Normal'; } @endphp
{{ $hrCat }}
Nadi
@endif @if ($appointment->physicalExamResult->respiratory_rate)
{{ $appointment->physicalExamResult->respiratory_rate }}x/m
@php // Interpretasi respirasi $rr = (int) $appointment->physicalExamResult->respiratory_rate; $rrCat = ''; if ($rr < 12) { $rrCat = 'Bradipnea'; } elseif ($rr > 24) { $rrCat = 'Takipnea'; } else { $rrCat = 'Normal'; } @endphp
{{ $rrCat }}
Respirasi
@endif @if ($appointment->physicalExamResult->body_temperature)
{{ number_format( $appointment->physicalExamResult->body_temperature, 1, ) }}°C
@php // Klasifikasi suhu tubuh $t = (float) $appointment->physicalExamResult->body_temperature; $tCat = ''; if ($t > 42.0) { $tCat = 'Hipertermi'; } elseif ($t >= 40.0 && $t <= 42.0) { $tCat = 'Hiperpireksis'; } elseif ($t >= 38.0 && $t < 40.0) { $tCat = 'Febris'; } elseif ($t >= 37.0 && $t < 38.0) { $tCat = 'Sub Febris'; } elseif ($t >= 36.6 && $t <= 37.2) { $tCat = 'Normal'; } elseif ($t < 36.0) { $tCat = 'Hipotermi'; } else { $tCat = 'Normal'; } @endphp
{{ $tCat }}
Suhu
@endif
@if ($appointment->physicalExamResult->general_appearance || $appointment->physicalExamResult->consciousness_level)
Keadaan Umum & Kesadaran :
@if ($appointment->physicalExamResult->general_appearance)
{{ $appointment->physicalExamResult->general_appearance }}
Keadaan Umum
@endif @if ($appointment->physicalExamResult->consciousness_level)
{{ $appointment->physicalExamResult->consciousness_level }}
Kesadaran
@endif @if (!$appointment->physicalExamResult->general_appearance && !$appointment->physicalExamResult->consciousness_level)
-
Tidak ada data
@endif
@endif @if ($appointment->visusResult)
Pemeriksaan Mata :
@php // Fungsi: menentukan apakah nilai visus lebih buruk dari 6/6 // Mengembalikan true jika pembilang < penyebut (contoh: 6/9, 6/12) // Termasuk kasus khusus non-numerik seperti "1/tak terhingga" atau simbol ∞ if (!function_exists('isAbnormalVisionValue')) { function isAbnormalVisionValue($value) { if (!is_string($value) || trim($value) === '') { return false; } $val = trim(strtolower($value)); if (strpos($val, 'tak') !== false || strpos($val, '∞') !== false) { return true; } if (preg_match('/(\d+)\/(\d+)/', $value, $m)) { $num = (int) $m[1]; $den = (int) $m[2]; return $num < $den; // lebih buruk dari 6/6 } return false; } } // Fungsi: menentukan abnormal untuk teks umum (bukan rasio visus) if (!function_exists('isAbnormalText')) { function isAbnormalText($value) { if (!is_string($value)) { return false; } $trimmed = trim($value); if ($trimmed === '' || $trimmed === '-') { return false; } // Placeholder yang tidak dianggap abnormal if (preg_match('/belum diperiksa|tidak diperiksa|tidak dilakukan/i', $trimmed)) { return false; } // Nilai dianggap normal jika mengandung kata "normal" atau "negatif" if (preg_match('/normal/i', $trimmed) || preg_match('/negatif/i', $trimmed)) { return false; } // Kata kunci umum abnormal if (preg_match('/parsial|partial|total|defek|terbatas|abnormal/i', $trimmed)) { return true; } // Default: selain normal/negatif dianggap abnormal return true; } } // Fungsi: menentukan apakah nilai near vision abnormal // Interpretasi: Dalam Batas Normal = normal; Presbiopia Ringan/Sedang/Berat = abnormal // Nilai Jaeger: J20-J25 = normal, J30 ke atas = abnormal; Tidak Dapat di Evaluasi = abnormal if (!function_exists('isAbnormalNearVision')) { function isAbnormalNearVision($value) { if (!is_string($value) || trim($value) === '') { return false; } $val = trim($value); if (stripos($val, 'Dalam Batas Normal') !== false) { return false; } if (stripos($val, 'Presbiopia') !== false) { return true; } if (stripos($val, 'Tidak Dapat di Evaluasi') !== false) { return true; } if (preg_match('/J(\d+)/', $val, $m)) { $num = (int) $m[1]; return $num >= 30; } return false; } } $leftUncorrected = $appointment->visusResult->left_eye_uncorrected ?? null; $rightUncorrected = $appointment->visusResult->right_eye_uncorrected ?? null; $leftCorrected = $appointment->visusResult->left_eye_corrected ?? null; $rightCorrected = $appointment->visusResult->right_eye_corrected ?? null; $isLeftUncorrectedAbn = isAbnormalVisionValue($leftUncorrected); $isRightUncorrectedAbn = isAbnormalVisionValue($rightUncorrected); $isLeftCorrectedAbn = isAbnormalVisionValue($leftCorrected); $isRightCorrectedAbn = isAbnormalVisionValue($rightCorrected); $nearLeftUncorrected = $appointment->visusResult->near_vision_left_uncorrected ?? null; $nearRightUncorrected = $appointment->visusResult->near_vision_right_uncorrected ?? null; $nearLeftCorrected = $appointment->visusResult->near_vision_left_corrected ?? null; $nearRightCorrected = $appointment->visusResult->near_vision_right_corrected ?? null; $isNearLeftUncorrectedAbn = isAbnormalNearVision($nearLeftUncorrected); $isNearRightUncorrectedAbn = isAbnormalNearVision($nearRightUncorrected); $isNearLeftCorrectedAbn = isAbnormalNearVision($nearLeftCorrected); $isNearRightCorrectedAbn = isAbnormalNearVision($nearRightCorrected); $vfLeft = $appointment->visusResult->visual_field_left ?? null; $vfRight = $appointment->visusResult->visual_field_right ?? null; $colorVision = $appointment->visusResult->color_vision ?? null; $isVfLeftAbn = isAbnormalText($vfLeft); $isVfRightAbn = isAbnormalText($vfRight); $isColorVisionAbn = isAbnormalText($colorVision); @endphp
{{ $leftUncorrected ?: '-' }}
Tanpa Kacamata
Mata Kiri
{{ $rightUncorrected ?: '-' }}
Tanpa Kacamata
Mata Kanan
{{ $leftCorrected ?: '-' }}
Dengan Kacamata
Mata Kiri
{{ $rightCorrected ?: '-' }}
Dengan Kacamata
Mata Kanan
@if ($nearLeftUncorrected)
{{ $nearLeftUncorrected }}
Visus Dekat Tanpa Kacamata
Mata Kiri
@endif @if ($nearRightUncorrected)
{{ $nearRightUncorrected }}
Visus Dekat Tanpa Kacamata
Mata Kanan
@endif
{{ $nearLeftCorrected ?: '-' }}
Visus Dekat Dengan Kacamata
Mata Kiri
{{ $nearRightCorrected ?: '-' }}
Visus Dekat Dengan Kacamata
Mata Kanan
@if ($appointment->visusResult->visual_field_left)
{{ $appointment->visusResult->visual_field_left }}
Lapang Pandang Kiri
@endif @if ($appointment->visusResult->visual_field_right)
{{ $appointment->visusResult->visual_field_right }}
Lapang Pandang Kanan
@endif @if ($appointment->visusResult->color_vision)
{{ $appointment->visusResult->color_vision }}
Buta Warna
@endif @if ($appointment->visusResult->interpretation)
{{ $appointment->visusResult->interpretation }}
Interpretasi
@endif
@endif @endif @endif @if ($physicalData && is_array($physicalData))
@php // Get system names from helper $systemNames = \App\Helpers\PhysicalExamHelper::getSystemNamesForPdf(); // Group systems for 2-column layout - same order as process.blade.php $layoutRows = [ 'row1' => ['left' => 'head_neck', 'right' => 'chest_lungs'], 'row2' => ['left' => 'heart', 'right' => 'abdomen'], 'row3' => ['left' => 'extremities', 'right' => 'skin_nails'], 'row4' => ['full' => 'special'], ]; // Helper function untuk membersihkan duplikasi dan mendapatkan display value if (!function_exists('getCleanDisplayValue')) { function getCleanDisplayValue($fieldValue, $detailValue) { $displayValue = $fieldValue; // Jika nilai adalah "Abnormal", "Ket. Lain", atau "Ada", gunakan detail value if ( (strtolower(trim($fieldValue)) === 'abnormal' || stripos($fieldValue, 'ket. lain') !== false || stripos($fieldValue, 'keterangan lain') !== false || strtolower(trim($fieldValue)) === 'ada') && !empty($detailValue) ) { $displayValue = $detailValue; } // Bersihkan duplikasi internal return \App\Helpers\PhysicalExamHelper::cleanDuplicateText($displayValue); } } @endphp
@php $systemKey = $layoutRows['row1']['left']; $systemInfo = $systemNames[$systemKey]; @endphp
{{ $systemInfo['name'] }}
@if (isset($physicalData[$systemKey]) && is_array($physicalData[$systemKey]) && !empty(array_filter($physicalData[$systemKey]))) @foreach ($fieldOrder[$systemKey] as $fieldKey) @if (isset($physicalData[$systemKey][$fieldKey]) && !empty($physicalData[$systemKey][$fieldKey]))
{{ \App\Helpers\PhysicalExamHelper::getFieldLabel($fieldKey) }}: @php $fieldValue = $physicalData[$systemKey][$fieldKey]; $detailValue = $physicalData[$systemKey][$fieldKey . '_detail'] ?? null; // Gunakan helper function untuk mendapatkan display value bersih dari duplikasi $displayValue = getCleanDisplayValue($fieldValue, $detailValue); @endphp @php $colorClass = \App\Helpers\PhysicalExamHelper::getPdfSpecialValueClass($fieldValue, $fieldKey); $styleColor = ''; if ($colorClass === 'black') { $styleColor = 'color: #000000;'; } elseif ($colorClass === 'green') { $styleColor = 'color: #28a745;'; } elseif ($colorClass === 'red') { $styleColor = 'color: #dc3545;'; } @endphp {{ $displayValue }} @if (isset($physicalData[$systemKey][$fieldKey . '_detail']) && !empty($physicalData[$systemKey][$fieldKey . '_detail']) && stripos($fieldValue, 'keterangan lain') !== false)
{{ $physicalData[$systemKey][$fieldKey . '_detail'] }}
@endif
@endif @endforeach @else
- Tidak ada pemeriksaan
@endif
@php $systemKey = $layoutRows['row1']['right']; $systemInfo = $systemNames[$systemKey]; @endphp
{{ $systemInfo['name'] }}
@if (isset($physicalData[$systemKey]) && is_array($physicalData[$systemKey]) && !empty(array_filter($physicalData[$systemKey]))) @foreach ($fieldOrder[$systemKey] as $fieldKey) @if (isset($physicalData[$systemKey][$fieldKey]) && !empty($physicalData[$systemKey][$fieldKey]))
{{ \App\Helpers\PhysicalExamHelper::getFieldLabel($fieldKey) }}: @php $fieldValue = $physicalData[$systemKey][$fieldKey]; $detailValue = $physicalData[$systemKey][$fieldKey . '_detail'] ?? null; // Gunakan helper function untuk mendapatkan display value bersih dari duplikasi $displayValue = getCleanDisplayValue($fieldValue, $detailValue); @endphp @php $colorClass = \App\Helpers\PhysicalExamHelper::getPdfSpecialValueClass($fieldValue, $fieldKey); $styleColor = ''; if ($colorClass === 'black') { $styleColor = 'color: #000000;'; } elseif ($colorClass === 'green') { $styleColor = 'color: #28a745;'; } elseif ($colorClass === 'red') { $styleColor = 'color: #dc3545;'; } @endphp {{ $displayValue }} @if (isset($physicalData[$systemKey][$fieldKey . '_detail']) && !empty($physicalData[$systemKey][$fieldKey . '_detail']) && stripos($fieldValue, 'keterangan lain') !== false)
{{ $physicalData[$systemKey][$fieldKey . '_detail'] }}
@endif
@endif @endforeach @else
- Tidak ada pemeriksaan
@endif
@php $systemKey = $layoutRows['row2']['left']; $systemInfo = $systemNames[$systemKey]; @endphp
{{ $systemInfo['name'] }}
@if (isset($physicalData[$systemKey]) && is_array($physicalData[$systemKey]) && !empty(array_filter($physicalData[$systemKey]))) @foreach ($fieldOrder[$systemKey] as $fieldKey) @if (isset($physicalData[$systemKey][$fieldKey]) && !empty($physicalData[$systemKey][$fieldKey]))
{{ \App\Helpers\PhysicalExamHelper::getFieldLabel($fieldKey) }}: @php $fieldValue = $physicalData[$systemKey][$fieldKey]; $detailValue = $physicalData[$systemKey][$fieldKey . '_detail'] ?? null; // Gunakan helper function untuk mendapatkan display value bersih dari duplikasi $displayValue = getCleanDisplayValue($fieldValue, $detailValue); @endphp @php $colorClass = \App\Helpers\PhysicalExamHelper::getPdfSpecialValueClass($fieldValue, $fieldKey); $styleColor = ''; if ($colorClass === 'black') { $styleColor = 'color: #000000;'; } elseif ($colorClass === 'green') { $styleColor = 'color: #28a745;'; } elseif ($colorClass === 'red') { $styleColor = 'color: #dc3545;'; } @endphp {{ $displayValue }} @if (isset($physicalData[$systemKey][$fieldKey . '_detail']) && !empty($physicalData[$systemKey][$fieldKey . '_detail']) && stripos($fieldValue, 'keterangan lain') !== false)
{{ $physicalData[$systemKey][$fieldKey . '_detail'] }}
@endif
@endif @endforeach @else
- Tidak ada pemeriksaan
@endif
@php $systemKey = $layoutRows['row2']['right']; $systemInfo = $systemNames[$systemKey]; @endphp
{{ $systemInfo['name'] }}
@if (isset($physicalData[$systemKey]) && is_array($physicalData[$systemKey]) && !empty(array_filter($physicalData[$systemKey]))) @foreach ($fieldOrder[$systemKey] as $fieldKey) @if (isset($physicalData[$systemKey][$fieldKey]) && !empty($physicalData[$systemKey][$fieldKey]))
{{ \App\Helpers\PhysicalExamHelper::getFieldLabel($fieldKey) }}: @php $fieldValue = $physicalData[$systemKey][$fieldKey]; $detailValue = $physicalData[$systemKey][$fieldKey . '_detail'] ?? null; // Gunakan helper function untuk mendapatkan display value bersih dari duplikasi $displayValue = getCleanDisplayValue($fieldValue, $detailValue); @endphp @php $colorClass = \App\Helpers\PhysicalExamHelper::getPdfSpecialValueClass($fieldValue, $fieldKey); $styleColor = ''; if ($colorClass === 'black') { $styleColor = 'color: #000000;'; } elseif ($colorClass === 'green') { $styleColor = 'color: #28a745;'; } elseif ($colorClass === 'red') { $styleColor = 'color: #dc3545;'; } @endphp {{ $displayValue }} @if (isset($physicalData[$systemKey][$fieldKey . '_detail']) && !empty($physicalData[$systemKey][$fieldKey . '_detail']) && stripos($fieldValue, 'keterangan lain') !== false)
{{ $physicalData[$systemKey][$fieldKey . '_detail'] }}
@endif
@endif @endforeach @else
- Tidak ada pemeriksaan
@endif
@php $systemKey = $layoutRows['row3']['left']; $systemInfo = $systemNames[$systemKey]; @endphp
{{ $systemInfo['name'] }}
@if (isset($physicalData[$systemKey]) && is_array($physicalData[$systemKey]) && !empty(array_filter($physicalData[$systemKey]))) @foreach ($fieldOrder[$systemKey] as $fieldKey) @if (isset($physicalData[$systemKey][$fieldKey]) && !empty($physicalData[$systemKey][$fieldKey]))
{{ \App\Helpers\PhysicalExamHelper::getFieldLabel($fieldKey) }}: @php $fieldValue = $physicalData[$systemKey][$fieldKey]; $detailValue = $physicalData[$systemKey][$fieldKey . '_detail'] ?? null; // Gunakan helper function untuk mendapatkan display value bersih dari duplikasi $displayValue = getCleanDisplayValue($fieldValue, $detailValue); @endphp @php $colorClass = \App\Helpers\PhysicalExamHelper::getPdfSpecialValueClass($fieldValue, $fieldKey); $styleColor = ''; if ($colorClass === 'black') { $styleColor = 'color: #000000;'; } elseif ($colorClass === 'green') { $styleColor = 'color: #28a745;'; } elseif ($colorClass === 'red') { $styleColor = 'color: #dc3545;'; } @endphp {{ $displayValue }} @if (isset($physicalData[$systemKey][$fieldKey . '_detail']) && !empty($physicalData[$systemKey][$fieldKey . '_detail']) && stripos($fieldValue, 'keterangan lain') !== false)
{{ $physicalData[$systemKey][$fieldKey . '_detail'] }}
@endif
@endif @endforeach @else
- Tidak ada pemeriksaan
@endif
@php $systemKey = $layoutRows['row3']['right']; $systemInfo = $systemNames[$systemKey]; @endphp
{{ $systemInfo['name'] }}
@if (isset($physicalData[$systemKey]) && is_array($physicalData[$systemKey]) && !empty(array_filter($physicalData[$systemKey]))) @foreach ($fieldOrder[$systemKey] as $fieldKey) @if (isset($physicalData[$systemKey][$fieldKey]) && !empty($physicalData[$systemKey][$fieldKey]))
{{ \App\Helpers\PhysicalExamHelper::getFieldLabel($fieldKey) }}: @php $fieldValue = $physicalData[$systemKey][$fieldKey]; $detailValue = $physicalData[$systemKey][$fieldKey . '_detail'] ?? null; // Gunakan helper function untuk mendapatkan display value bersih dari duplikasi $displayValue = getCleanDisplayValue($fieldValue, $detailValue); @endphp @php $colorClass = \App\Helpers\PhysicalExamHelper::getPdfSpecialValueClass($fieldValue, $fieldKey); $styleColor = ''; if ($colorClass === 'black') { $styleColor = 'color: #000000;'; } elseif ($colorClass === 'green') { $styleColor = 'color: #28a745;'; } elseif ($colorClass === 'red') { $styleColor = 'color: #dc3545;'; } @endphp {{ $displayValue }} @if (isset($physicalData[$systemKey][$fieldKey . '_detail']) && !empty($physicalData[$systemKey][$fieldKey . '_detail']) && stripos($fieldValue, 'keterangan lain') !== false)
{{ $physicalData[$systemKey][$fieldKey . '_detail'] }}
@endif
@endif @endforeach @else
- Tidak ada pemeriksaan
@endif
@php $systemKey = $layoutRows['row4']['full']; $systemInfo = $systemNames[$systemKey]; @endphp
{{ $systemInfo['name'] }}
@if (isset($physicalData[$systemKey]) && is_array($physicalData[$systemKey]) && !empty(array_filter($physicalData[$systemKey]))) @foreach ($fieldOrder[$systemKey] as $fieldKey) @if (isset($physicalData[$systemKey][$fieldKey]) && !empty($physicalData[$systemKey][$fieldKey]))
{{ $fieldLabels[$fieldKey] ?? ucwords(str_replace('_', ' ', $fieldKey)) }}: @php $fieldValue = $physicalData[$systemKey][$fieldKey]; $detailValue = $physicalData[$systemKey][$fieldKey . '_detail'] ?? null; // Gunakan helper function untuk mendapatkan display value bersih dari duplikasi $displayValue = getCleanDisplayValue($fieldValue, $detailValue); // Get color class using helper method $colorClass = \App\Helpers\PhysicalExamHelper::getPdfSpecialValueClass($fieldValue, $fieldKey); $styleColor = ''; if ($colorClass === 'black') { $styleColor = 'color: #000000;'; } elseif ($colorClass === 'green') { $styleColor = 'color: #28a745;'; } elseif ($colorClass === 'red') { $styleColor = 'color: #dc3545;'; } @endphp {{ $displayValue }} @if (isset($physicalData[$systemKey][$fieldKey . '_detail']) && !empty($physicalData[$systemKey][$fieldKey . '_detail']) && stripos($fieldValue, 'keterangan lain') !== false)
{{ $physicalData[$systemKey][$fieldKey . '_detail'] }}
@endif
@endif @endforeach @else
- Tidak ada pemeriksaan
@endif
@endif @if ($appointment->physicalExamResult->notes)
CATATAN PEMERIKSAAN
{{ $appointment->physicalExamResult->notes }}
@endif
KESIMPULAN PEMERIKSAAN FISIK:
@php $physicalConclusion = ''; $abnormalFindings = []; // Check for abnormal findings from physical examination using helper if ($physicalData && is_array($physicalData)) { $abnormalFindings = \App\Helpers\PhysicalExamHelper::getAbnormalFindings($physicalData); } // Check vital signs for abnormal values $vitalAbnormal = []; if ( $appointment->physicalExamResult->blood_pressure_systolic && $appointment->physicalExamResult->blood_pressure_diastolic ) { $systolic = $appointment->physicalExamResult->blood_pressure_systolic; $diastolic = $appointment->physicalExamResult->blood_pressure_diastolic; if ($systolic >= 140 || $diastolic >= 90 || $systolic < 90 || $diastolic < 60) { $vitalAbnormal[] = "Tekanan darah: {$systolic}/{$diastolic} mmHg (Hipertensi)"; } } if ($appointment->physicalExamResult->bmi) { $bmi = $appointment->physicalExamResult->bmi; // Abnormal jika <18.5 (Underweight), 23.0–24.9 (Overweight), 25.0–29.9 (Obesitas I), ≥30 (Obesitas II) if ($bmi < 18.5) { $vitalAbnormal[] = 'IMT: ' . number_format($bmi, 2) . ' (Berat badan kurang)'; } elseif ($bmi < 23) { // Normal, tidak dimasukkan } elseif ($bmi < 25) { $vitalAbnormal[] = 'IMT: ' . number_format($bmi, 2) . ' (Overweight)'; } elseif ($bmi < 30) { $vitalAbnormal[] = 'IMT: ' . number_format($bmi, 2) . ' (Obesitas I)'; } else { $vitalAbnormal[] = 'IMT: ' . number_format($bmi, 2) . ' (Obesitas II)'; } } // Check waist circumference for abnormal values if ($appointment->physicalExamResult->waist_circumference) { $waist = $appointment->physicalExamResult->waist_circumference; $gender = $appointment->patient ? $appointment->patient->gender : 'male'; if (($gender === 'male' && $waist > 90) || ($gender === 'female' && $waist > 80)) { $vitalAbnormal[] = "Lingkar Perut: {$waist} cm"; } } // Check general condition and consciousness level if ($appointment->physicalExamResult->general_appearance) { $generalAppearance = trim($appointment->physicalExamResult->general_appearance); // Based on the form options: 'Baik', 'Sedang', 'Buruk' $normalAppearanceTerms = ['baik', 'sehat', 'normal', 'tampak sehat', 'dalam batas normal']; $isNormalAppearance = false; // 'Baik' is considered normal, 'Sedang' and 'Buruk' are abnormal if (stripos($generalAppearance, 'baik') !== false) { $isNormalAppearance = true; } else { foreach ($normalAppearanceTerms as $term) { if (stripos($generalAppearance, $term) !== false) { $isNormalAppearance = true; break; } } } if (!$isNormalAppearance && strlen($generalAppearance) > 2) { $vitalAbnormal[] = 'Keadaan umum: ' . $generalAppearance; } } if ($appointment->physicalExamResult->consciousness_level) { $consciousnessLevel = trim($appointment->physicalExamResult->consciousness_level); // Based on the form options: 'Compos Mentis', 'Somnolen', 'Sopor', 'Koma' // Only 'Compos Mentis' is normal, others are abnormal $normalConsciousnessTerms = ['compos mentis', 'composmentis', 'cm']; $isNormalConsciousness = false; foreach ($normalConsciousnessTerms as $term) { if (stripos($consciousnessLevel, $term) !== false) { $isNormalConsciousness = true; break; } } if (!$isNormalConsciousness && strlen($consciousnessLevel) > 2) { $vitalAbnormal[] = 'Kesadaran: ' . $consciousnessLevel; } } $allAbnormal = array_merge($abnormalFindings, $vitalAbnormal); // Bersihkan duplikasi pada setiap item dalam array $allAbnormal = array_map(function ($item) { return \App\Helpers\PhysicalExamHelper::cleanDuplicateText($item); }, $allAbnormal); // Hapus duplikat yang identik $allAbnormal = array_unique($allAbnormal); if (count($allAbnormal) > 0) { $physicalConclusion = implode(";\n", $allAbnormal) . '.'; } else { $physicalConclusion = 'Pemeriksaan fisik dalam batas normal.'; } @endphp

{{ $physicalConclusion }}

@php $examinerDoctor = null; $examinerUser = null; $isGeneralAccount = false; if ($appointment->physicalExamResult->examiner_id) { $examinerDoctor = \App\Models\PhysicalExamStaff::where( 'employee_id', $appointment->physicalExamResult->examiner_id, )->first(); if (!$examinerDoctor) { $examinerUser = \App\Models\User::find($appointment->physicalExamResult->examiner_id); } } if ($examinerUser) { $examinerEmail = strtolower($examinerUser->email ?? ''); $examinerName = strtolower($examinerUser->name ?? ''); if ($examinerEmail === 'dokterumum@gmail.com' || strpos($examinerName, 'dokter umum') !== false) { $isGeneralAccount = true; } } if ($examinerDoctor && $examinerDoctor->employee && $examinerDoctor->employee->position) { $positionName = strtolower($examinerDoctor->employee->position->name ?? ''); if (strpos($positionName, 'dokter umum') !== false || $positionName === 'dokter umum') { $isGeneralAccount = true; } } @endphp @if (!$isGeneralAccount)
Dokter Pemeriksa
@php $signatureImageData = null; $signatureMimeType = 'png'; $doctorName = 'Dokter Pemeriksa'; $doctorPosition = 'Dokter Umum'; if (!$isGeneralAccount && $examinerDoctor && $examinerDoctor->signature_image) { $signaturePath = storage_path('app/public/' . $examinerDoctor->signature_image); if (file_exists($signaturePath)) { try { $signatureImageData = base64_encode(file_get_contents($signaturePath)); $imageType = pathinfo($signaturePath, PATHINFO_EXTENSION); $signatureMimeType = $imageType === 'jpg' ? 'jpeg' : strtolower($imageType); $doctorName = $examinerDoctor->employee->full_name ?? 'Dokter Pemeriksa'; $doctorPosition = $examinerDoctor->employee->position->name ?? 'Dokter Umum'; } catch (Exception $e) { $signatureImageData = null; } } } if (!$isGeneralAccount && !$signatureImageData && $examinerUser && stripos($examinerUser->name, 'Said') !== false) { $signaturePath = public_path('assets/images/ttd/dr.said.jpg'); if (file_exists($signaturePath)) { try { $signatureImageData = base64_encode(file_get_contents($signaturePath)); $signatureMimeType = 'jpeg'; $doctorName = 'dr. Said. M. Bin. Smith. MAP'; $doctorPosition = 'Dokter Umum'; } catch (Exception $e) { $signatureImageData = null; } } } if (!$isGeneralAccount && !$signatureImageData && $examinerUser && stripos($examinerUser->name, 'Zakia') !== false) { $signaturePath = public_path('assets/images/ttd/dr.zakia.jpg'); if (file_exists($signaturePath)) { try { $signatureImageData = base64_encode(file_get_contents($signaturePath)); $signatureMimeType = 'jpeg'; $doctorName = 'dr. Zakia Alaydrus'; $doctorPosition = 'Dokter Umum'; } catch (Exception $e) { $signatureImageData = null; } } } if (!$isGeneralAccount && !$signatureImageData) { $signaturePath = public_path('assets/images/ttd/dr.said.jpg'); if (file_exists($signaturePath)) { try { $signatureImageData = base64_encode(file_get_contents($signaturePath)); $signatureMimeType = 'jpeg'; $doctorName = 'dr. Said. M. Bin. Smith. MAP'; $doctorPosition = 'Dokter Umum'; } catch (Exception $e) { $signatureImageData = null; } } } @endphp @if (isset($qr_image) && $qr_image) QR Code Verifikasi Pemeriksaan Fisik
{{ $doctorName }}
@elseif ($signatureImageData) Tanda Tangan {{ $doctorName }} @endif
@endif