Pemeriksaan Fisik (Abnormal)
@php $badge = getStatusBadge($appointment->physicalExamResult); @endphp
{{ $badge['text'] }}
@php
// System labels untuk tampilan
$systemLabels = [
'head_neck' => ['name' => 'Kepala & Leher', 'icon' => 'ri-user-line'],
'chest' => ['name' => 'Dada', 'icon' => 'ri-heart-line'],
'abdomen' => ['name' => 'Perut', 'icon' => 'ri-stomach-line'],
'extremities' => ['name' => 'Ekstremitas', 'icon' => 'ri-hand-line'],
'neurological' => ['name' => 'Neurologis', 'icon' => 'ri-brain-line'],
'genitourinary' => ['name' => 'Genitourinari', 'icon' => 'ri-medicine-bottle-line'],
'skin' => ['name' => 'Kulit', 'icon' => 'ri-skin-line'],
'musculoskeletal' => ['name' => 'Muskuloskeletal', 'icon' => 'ri-body-scan-line'],
];
// Function to check if a physical exam value is abnormal
function isAbnormalPhysicalValue($field, $value, $patient = null)
{
if (empty($value) || $value === '-' || $value === '') {
return false;
}
// Check BMI -> abnormal jika <18.5 (Underweight), 23.0–24.9 (Overweight), ≥25 (Obesitas)
if ($field === 'bmi' && is_numeric($value)) {
$bmi = (float) $value;
return $bmi < 18.5 || $bmi >= 23; // 23.0–24.9 Overweight; ≥25 Obesitas
}
// Check Blood Pressure
if ($field === 'blood_pressure' && $value) {
// Parse blood pressure (format: "120/80")
if (preg_match('/(\d+)\/(\d+)/', $value, $matches)) {
$systolic = (int) $matches[1];
$diastolic = (int) $matches[2];
return $systolic >= 140 || $diastolic >= 90; // Hypertension
}
}
// Check Heart Rate
if ($field === 'heart_rate' && is_numeric($value)) {
$hr = (int) $value;
return $hr < 60 || $hr > 100; // Bradycardia or Tachycardia
}
// Check Respiratory Rate
if ($field === 'respiratory_rate' && is_numeric($value)) {
$rr = (int) $value;
return $rr < 12 || $rr > 24; // Abnormal respiratory rate
}
// Check Body Temperature
if ($field === 'body_temperature' && is_numeric($value)) {
$temp = (float) $value;
return $temp < 36.0 || $temp > 37.2; // Fever or Hypothermia
}
// Check Waist Circumference (for metabolic risk)
if ($field === 'waist_circumference' && is_numeric($value)) {
$waist = (int) $value;
$gender = $patient ? $patient->gender : 'male';
if ($gender === 'male') {
return $waist > 90; // Male: >90cm is high risk
} else {
return $waist > 80; // Female: >80cm is high risk
}
}
// Check Vision (if less than 6/6 or 20/20)
if (
in_array($field, [
'vision_left_uncorrected',
'vision_right_uncorrected',
'vision_left_corrected',
'vision_right_corrected',
])
) {
// If vision is less than 6/6 or 20/20, it's considered abnormal
if (preg_match('/(\d+)\/(\d+)/', $value, $matches)) {
$numerator = (int) $matches[1];
$denominator = (int) $matches[2];
return $numerator < $denominator; // Vision less than perfect
}
}
// Check Color Vision
if ($field === 'color_vision') {
return !in_array(strtolower($value), ['normal', 'tidak ada', 'tidak buta warna']);
}
// Menggunakan pendekatan yang sama seperti di result_detail.blade.php
// Daftar nilai normal yang spesifik
$normalValues = [
'Dalam Batas Normal',
'Simetris Normal',
'Vesikuler',
'Tidak Ada',
'Datar',
'Tidak Teraba',
'Reguler',
'Compos Mentis',
'Baik',
'Normal',
'Tidak Ditemukan',
'Tidak Tampak',
'Bersih',
'Jernih',
'Teratur',
'Kuat',
'Tidak Dilakukan',
'Negatif Normal',
'Dalam Batas',
'Sehat',
'Normal Limits',
'WOL',
'Clear',
'Good',
'Strong',
'Tidak Terdengar',
'Tidak Membesar',
'Tidak Nyeri',
'Tidak Ada Kelainan',
'Tidak Ada Gangguan',
'Tidak Ada Masalah',
'Tidak Ada Gejala',
'Tidak Ada Tanda',
'Tidak Ada Indikasi',
'Tidak Ada Bukti',
'Tidak Ada Manifestasi',
'Tidak Ada Keluhan',
'Tidak Ada Kelainan Fisik',
'Tidak Ada Kelainan Organik',
'Tidak Ada Kelainan Fungsional',
'Tidak Ada Kelainan Struktural',
'Negatif',
'Tidak Ditemukan Kelainan',
];
// Daftar nilai abnormal yang spesifik (seperti di process.blade.php)
$abnormalValues = [
'Kurang Sehat',
'Tidak Sehat',
'Ada Kelainan',
'Ada Masalah',
'Ada Gangguan',
'Ada Gejala',
'Ada Tanda',
'Ada Indikasi',
'Ada Bukti',
'Ada Manifestasi',
'Ada Keluhan',
'Ada Kelainan Fisik',
'Ada Kelainan Organik',
'Ada Kelainan Fungsional',
'Ada Kelainan Struktural',
];
$valueTrimmed = trim($value);
// Cek apakah nilai adalah nilai normal
if (in_array($valueTrimmed, $normalValues)) {
return false; // Nilai normal, tidak abnormal
}
// Cek apakah nilai adalah nilai abnormal yang spesifik
if (in_array($valueTrimmed, $abnormalValues)) {
return true; // Nilai abnormal spesifik, perlu ditampilkan di summary
}
// Jika nilai bukan normal dan bukan abnormal spesifik, maka kemungkinan besar abnormal
return true;
}
// Get abnormal results only
$abnormalResults = [];
$patient = $appointment->patient;
// Check vital signs and anthropometry - hanya tampilkan yang benar-benar abnormal
$vitalFields = [
'bmi' => 'IMT',
'blood_pressure' => 'Tekanan Darah',
'heart_rate' => 'Denyut Jantung',
'respiratory_rate' => 'Laju Pernapasan',
'body_temperature' => 'Suhu Badan',
'waist_circumference' => 'Lingkar Perut',
];
foreach ($vitalFields as $field => $label) {
$value = $appointment->physicalExamResult->$field;
// Cek apakah nilai abnormal berdasarkan kriteria medis
$isAbnormal = false;
if ($field === 'bmi' && is_numeric($value)) {
$bmi = (float) $value;
$isAbnormal = $bmi < 18.5 || $bmi >= 23;
} elseif ($field === 'blood_pressure' && $value) {
// Parse blood pressure (format: "120/80")
if (preg_match('/(\d+)\/(\d+)/', $value, $matches)) {
$systolic = (int) $matches[1];
$diastolic = (int) $matches[2];
$isAbnormal = $systolic >= 140 || $diastolic >= 90;
}
} elseif ($field === 'heart_rate' && is_numeric($value)) {
$hr = (int) $value;
$isAbnormal = $hr < 60 || $hr > 100;
} elseif ($field === 'respiratory_rate' && is_numeric($value)) {
$rr = (int) $value;
$isAbnormal = $rr < 12 || $rr > 24;
} elseif ($field === 'body_temperature' && is_numeric($value)) {
$temp = (float) $value;
$isAbnormal = $temp < 36.0 || $temp > 37.2;
} elseif ($field === 'waist_circumference' && is_numeric($value)) {
$waist = (int) $value;
$gender = $patient ? $patient->gender : 'male';
$isAbnormal = ($gender === 'male' && $waist > 90) || ($gender === 'female' && $waist > 80);
}
if ($value && $isAbnormal) {
$abnormalResults['vital_signs'][$field] = [
'label' => $label,
'value' => $value,
'unit' =>
$field === 'bmi'
? ''
: ($field === 'blood_pressure'
? ' mmHg'
: ($field === 'heart_rate'
? ' bpm'
: ($field === 'respiratory_rate'
? ' /menit'
: ($field === 'body_temperature'
? '°C'
: ' cm')))),
];
}
}
// Check vision tests
$visionFields = [
'vision_left_uncorrected' => 'Visus Kiri Tanpa Koreksi',
'vision_right_uncorrected' => 'Visus Kanan Tanpa Koreksi',
'vision_left_corrected' => 'Visus Kiri Dengan Koreksi',
'vision_right_corrected' => 'Visus Kanan Dengan Koreksi',
'color_vision' => 'Buta Warna',
];
foreach ($visionFields as $field => $label) {
$value = $appointment->physicalExamResult->$field;
if ($value && isAbnormalPhysicalValue($field, $value, $patient)) {
$abnormalResults['vision'][$field] = [
'label' => $label,
'value' => $value,
'unit' => '',
];
}
}
// Check detailed physical examination using the same logic as result_detail.blade.php
if ($appointment->physicalExamResult->physical_examination_data) {
$examData = \App\Helpers\PhysicalExamHelper::processExamData(
$appointment->physicalExamResult->physical_examination_data,
);
foreach ($examData as $system => $findings) {
if (is_array($findings)) {
foreach ($findings as $part => $result) {
if ($result && trim($result) !== '' && !str_ends_with($part, '_detail')) {
// Menggunakan logika yang sama seperti di result_detail.blade.php
$isNormalValue = in_array($result, [
'Dalam Batas Normal',
'Simetris Normal',
'Vesikuler',
'Tidak Ada',
'Datar',
'Tidak Teraba',
'Reguler',
'Compos Mentis',
'Baik',
'Normal',
'Tidak Ditemukan',
'Tidak Tampak',
'Bersih',
'Jernih',
'Teratur',
'Kuat',
'Tidak Dilakukan',
'Negatif Normal',
'Dalam Batas',
'Sehat',
'Normal Limits',
'WOL',
'Clear',
'Good',
'Strong',
'Tidak Terdengar',
'Tidak Membesar',
'Tidak Nyeri',
'Tidak Ada Kelainan',
'Tidak Ada Gangguan',
'Tidak Ada Masalah',
'Tidak Ada Gejala',
'Tidak Ada Tanda',
'Tidak Ada Indikasi',
'Tidak Ada Bukti',
'Tidak Ada Manifestasi',
'Tidak Ada Keluhan',
'Tidak Ada Kelainan Fisik',
'Tidak Ada Kelainan Organik',
'Tidak Ada Kelainan Fungsional',
'Tidak Ada Kelainan Struktural',
'Negatif',
'Tidak Ditemukan Kelainan',
]);
$isAbnormalFlag = strtolower(trim($result)) === 'abnormal';
$detailValue = $findings[$part . '_detail'] ?? null;
// Jika bukan nilai normal, maka kemungkinan abnormal
if (!$isNormalValue) {
if (!isset($abnormalResults['detailed_exam'][$system])) {
$abnormalResults['detailed_exam'][$system] = [];
}
// Bersihkan duplikasi internal pada result dan detailValue
$cleanResult = trim($result);
$cleanDetailValue = $detailValue ? trim($detailValue) : null;
// Jika nilai adalah "Abnormal", gunakan detail value
if ($isAbnormalFlag && $cleanDetailValue) {
$abnormalResults['detailed_exam'][$system][$part] = [
'label' => \App\Helpers\PhysicalExamHelper::getFieldLabel($part),
'value' => $cleanDetailValue,
'detail' => null,
];
} elseif (
strtolower($cleanResult) === 'ada' &&
$cleanDetailValue &&
!empty($cleanDetailValue)
) {
// Jika nilai adalah "Ada" dan ada detail value, gunakan detail value
$abnormalResults['detailed_exam'][$system][$part] = [
'label' => \App\Helpers\PhysicalExamHelper::getFieldLabel($part),
'value' => $cleanDetailValue,
'detail' => null,
];
} else {
// Tampilkan nilai asli (termasuk "Kurang Sehat", dll)
$abnormalResults['detailed_exam'][$system][$part] = [
'label' => \App\Helpers\PhysicalExamHelper::getFieldLabel($part),
'value' => $cleanResult,
'detail' => $cleanDetailValue,
];
}
}
}
}
}
}
}
@endphp
@php
// Create simple format like lab results summary
$physicalAbnormal = [];
// Add vital signs abnormalities
if (!empty($abnormalResults['vital_signs'])) {
foreach ($abnormalResults['vital_signs'] as $field => $data) {
if ($field === 'bmi') {
$bmiVal = (float) $data['value'];
$bmiCat = '';
if ($bmiVal < 18.5) {
$bmiCat = 'Underweight';
} elseif ($bmiVal < 23) {
$bmiCat = 'Normal';
} elseif ($bmiVal < 25) {
$bmiCat = 'Overweight';
} elseif ($bmiVal < 30) {
$bmiCat = 'Obesitas I';
} else {
$bmiCat = 'Obesitas II';
}
$physicalAbnormal[] = "{$data['label']}: {$data['value']}{$data['unit']} ({$bmiCat})";
} else {
$physicalAbnormal[] = "{$data['label']}: {$data['value']}{$data['unit']}";
}
}
}
// Add vision abnormalities
if (!empty($abnormalResults['vision'])) {
foreach ($abnormalResults['vision'] as $field => $data) {
$physicalAbnormal[] = "{$data['label']}: {$data['value']}{$data['unit']}";
}
}
// Add detailed examination abnormalities
if (!empty($abnormalResults['detailed_exam'])) {
foreach ($abnormalResults['detailed_exam'] as $system => $findings) {
foreach ($findings as $part => $data) {
$displayName = $data['label'];
$value = $data['value'];
$detail = $data['detail'] ?? null;
/**
* Tampilkan detail jika value adalah "Ket. Lain", "Ada", atau mengandung kata "keterangan"/"ket.".
* Ini menyelaraskan dengan render di tabel yang menampilkan detail spesifik (mis. "Lemah").
*/
$valueStr = is_string($value) ? strtolower(trim($value)) : '';
$useDetail =
$detail &&
($valueStr === 'ket. lain' ||
$valueStr === 'keterangan lain' ||
$valueStr === 'ada' ||
$valueStr === 'abnormal' ||
str_contains($valueStr, 'ket.') ||
str_contains($valueStr, 'keterangan'));
// Gunakan helper untuk memastikan tidak ada duplikasi
$displayValue = $useDetail ? $detail : $value;
// Bersihkan duplikasi internal menggunakan helper
$displayValue = \App\Helpers\PhysicalExamHelper::cleanDuplicateText($displayValue);
// Strip HTML tags untuk summary text (karena renderPhysicalExamValue menghasilkan HTML)
// Kita hanya perlu text bersih untuk list summary
$displayValue = strip_tags($displayValue);
$displayValue = trim($displayValue);
$physicalAbnormal[] = "{$displayName}: {$displayValue}";
}
}
}
@endphp
@if (!empty($physicalAbnormal))
@foreach ($physicalAbnormal as $note)
-
{{ $note }}
@endforeach
@elseif (!empty($abnormalResults))
@if (isset($abnormalResults['vital_signs']) && count($abnormalResults['vital_signs']) > 0)
Tanda Vital & Antropometri
@foreach ($abnormalResults['vital_signs'] as $field => $data)
|
{{ $data['label'] }}
|
{{ $data['value'] }}{{ $data['unit'] }}
@if ($field === 'bmi' && $appointment->physicalExamResult->bmi_category)
({{ $appointment->physicalExamResult->bmi_category }})
@endif
@if ($field === 'blood_pressure' && $appointment->physicalExamResult->blood_pressure_category)
({{ $appointment->physicalExamResult->blood_pressure_category }})
@endif
|
@endforeach
@endif
@if (isset($abnormalResults['vision']) && count($abnormalResults['vision']) > 0)
Pemeriksaan Mata
@foreach ($abnormalResults['vision'] as $field => $data)
|
{{ $data['label'] }}
|
@php
$visionSource = null;
if (str_contains($field, 'corrected')) {
$visionSource = 'Dengan Kacamata';
} elseif (str_contains($field, 'uncorrected')) {
$visionSource = 'Tanpa Kacamata';
}
@endphp
{{ $data['value'] }}{{ $data['unit'] }}
@if ($visionSource)
{{ $visionSource }}
@endif
|
@endforeach
@endif
@if (isset($abnormalResults['detailed_exam']) && count($abnormalResults['detailed_exam']) > 0)
Detail Pemeriksaan Fisik
@foreach ($abnormalResults['detailed_exam'] as $system => $findings)
@if (isset($systemLabels[$system]))
{{ $systemLabels[$system]['name'] }}
@foreach ($findings as $part => $data)
|
{{ $data['label'] }}
|
{!!
\App\Helpers\PhysicalExamHelper::renderPhysicalExamValue(
$data['value'],
$data['detail'],
)
!!}
|
@endforeach
@endif
@endforeach
@endif
@else
Semua hasil pemeriksaan fisik dalam batas normal
@endif
@if ($appointment->physicalExamResult->notes || $appointment->physicalExamResult->doctor_notes)
@if ($appointment->physicalExamResult->notes)
Catatan Pemeriksaan:
{{ $appointment->physicalExamResult->notes }}
@endif
@if ($appointment->physicalExamResult->doctor_notes)
@php
$peConc = $appointment->physicalExamResult->doctor_notes;
$peConcStr = is_string($peConc) ? strtolower(trim($peConc)) : '';
$isPeAbnormal = $peConc && $peConcStr !== 'normal' && $peConcStr !== 'dalam batas normal';
@endphp
Kesimpulan & Catatan Dokter:
{{ $peConc }}
@endif
@endif