@extends('layouts.app') @php use Illuminate\Support\Facades\Storage; @endphp @section('title', 'Detail Pasien - MCU Klinik Mustika') @push('styles') @endpush @section('breadcrumb')

Detail Pasien

@endsection @section('content')
@if ($patient->photo) {{ $patient->name }} @else {{ strtoupper(substr($patient->name, 0, 2)) }} @endif
@if ($patient->photo) Klik untuk memperbesar @endif

{{ $patient->name }}

@if ($patient->nickname)

"{{ $patient->nickname }}"

@endif ID Pasien: {{ $patient->medical_record_number }} @if ($patient->company)
{{ $patient->company->name }}
@else
Pasien Individu
@endif
@canRoute ('patients.edit') Edit @endcanRoute

Data Pribadi Pasien

  • ID Pasien: {{ $patient->medical_record_number }}

  • NIK: {{ $patient->nik ?? '-' }}

  • @if ($patient->nickname)
  • Nama Panggilan: {{ $patient->nickname }}

  • @endif @if ($patient->religion)
  • Agama: {{ $patient->religion }}

  • @endif @if ($patient->ethnicity)
  • Suku: {{ $patient->ethnicity }}

  • @endif
  • Jenis Kelamin: @if ($patient->gender == 'male') Laki-laki @else Perempuan @endif

  • Tanggal Lahir: {{ $patient->formatted_birth_date ?: 'N/A' }}

  • @if ($patient->birth_place)
  • Tempat Lahir: {{ $patient->birth_place }}

  • @endif
  • Umur: {{ $patient->birth_date ? $patient->age . ' tahun' : 'N/A' }}

  • @if ($patient->marital_status)
  • Status Pernikahan: @switch ($patient->marital_status) @case ('single') Belum Menikah @break @case ('married') Menikah @break @case ('divorced') Cerai @break @case ('widowed') Janda/Duda @break @default {{ $patient->marital_status }} @endswitch

  • @endif @if ($patient->number_of_children !== null)
  • Jumlah Anak: {{ $patient->number_of_children }} anak

  • @endif @if ($patient->blood_type)
  • Golongan Darah: {{ $patient->blood_type }}

  • @endif
  • Nomor Telepon: {{ $patient->phone_number ?? '-' }}

  • Email: {{ $patient->email ?? '-' }}

  • Alamat: {{ $patient->address ?? '-' }}

  • Kontak Darurat

    Nama: {{ $patient->emergency_contact_name ?? '-' }}

    No. Telepon: {{ $patient->emergency_contact_phone ?? '-' }}

  • @if ($patient->notes)
  • Catatan Tambahan

    {{ $patient->notes }}

  • @endif
  • Tanda Tangan Pasien

    @if ($patient->signature_path)
    Tanda tangan {{ $patient->name }}
    Tanda tangan tersedia
    @else
    Tanda tangan belum tersedia
    @endif
@canRoute ('patients.index') Kembali @endcanRoute
@if ($patient->ktp_photo)

Foto KTP

KTP {{ $patient->name }} Klik untuk memperbesar
@endif
@php $latestHealth = $patient->healthQuestionnaires()->latest()->first(); $latestWork = $patient->workActivities()->latest()->first(); $latestFamily = $patient->familyHealthHistories()->latest()->first(); $latestLifestyle = $patient->lifestyleData()->latest()->first(); @endphp

Data Tambahan Pasien

@php $latestUpdate = max( $latestHealth?->updated_at ?? now()->subYear(), $latestWork?->updated_at ?? now()->subYear(), $latestFamily?->updated_at ?? now()->subYear(), $latestLifestyle?->updated_at ?? now()->subYear(), ); @endphp Diperbarui: {{ \App\Helpers\DateHelper::formatShort($latestUpdate) }} {{ $latestUpdate->format('H:i') }}
Informasi Kerja Pasien
Data pekerjaan & perusahaan pasien
Detail Pekerjaan
Informasi Perusahaan & Hobi
@php $previousCompanyHistories = collect(); // 1. Ambil dari riwayat appointment/MCU pasien $pastAppointments = $patient ->appointments() ->where('status', '!=', 'cancelled') ->with(['company', 'mcuResult.company', 'workActivity']) ->orderBy('appointment_date', 'desc') ->get(); foreach ($pastAppointments as $apt) { $comp = $apt->company ?? $apt->mcuResult?->company; if ($comp && (int) $comp->id !== (int) $patient->company_id) { $compKey = $comp->id; if (!$previousCompanyHistories->has($compKey)) { $aptWorkActivity = $apt->workActivity; if (!$aptWorkActivity) { $aptWorkActivity = \App\Models\WorkActivity::where('appointment_id', $apt->id)->first(); } if (!$aptWorkActivity) { $aptWorkActivity = \App\Models\WorkActivity::where('patient_id', $patient->id) ->where('created_at', '<=', $apt->created_at ?: now()) ->orderBy('created_at', 'desc') ->first(); } // Resolusi Jabatan di perusahaan sebelumnya $jobPos = null; if ($aptWorkActivity && !empty($aptWorkActivity->occupation) && $aptWorkActivity->occupation !== '-') { $jobPos = $aptWorkActivity->occupation; } if (!$jobPos || $jobPos === '-') { $corpEmp = $patient->corporateInvitationEmployees?->first( fn($emp) => $emp->invitation?->company_id == $comp->id || $emp->company_id == $comp->id, ); if ($corpEmp) { $jobPos = $corpEmp->resolvedPositionName(); } } if (!$jobPos || $jobPos === '-') { $anyCorpEmp = $patient->corporateInvitationEmployees?->first(); if ($anyCorpEmp) { $jobPos = $anyCorpEmp->resolvedPositionName(); } } if (!$jobPos || $jobPos === '-') { $jobPos = $patient->job_position ?? '-'; } // Resolusi Tahun Mulai Bekerja di perusahaan sebelumnya $workStart = null; if ( $aptWorkActivity && !empty($aptWorkActivity->work_start_year) && $aptWorkActivity->work_start_year !== '-' ) { $workStart = $aptWorkActivity->work_start_year; } if (!$workStart || $workStart === '-') { $aptLog = \App\Models\PatientChangeLog::where('appointment_id', $apt->id) ->where('field_name', 'work_start_year') ->whereNotNull('new_value') ->where('new_value', '!=', '-') ->where('new_value', '!=', '') ->orderBy('created_at', 'desc') ->first(); if ($aptLog) { $workStart = $aptLog->new_value; } } if (!$workStart || $workStart === '-') { $compWork = \App\Models\WorkActivity::where('patient_id', $patient->id) ->whereHas('appointment', function ($q) use ($comp) { $q->where('company_id', $comp->id); }) ->whereNotNull('work_start_year') ->where('work_start_year', '!=', '-') ->where('work_start_year', '!=', '') ->latest() ->first(); if ($compWork) { $workStart = $compWork->work_start_year; } } if (!$workStart || $workStart === '-') { $compLog = \App\Models\PatientChangeLog::where('patient_id', $patient->id) ->where('field_name', 'work_start_year') ->whereNotNull('new_value') ->where('new_value', '!=', '-') ->where('new_value', '!=', '') ->where(function ($q) use ($apt) { $q->where('appointment_id', $apt->id)->orWhere('created_at', '<=', $apt->created_at ?: now()); }) ->orderBy('created_at', 'desc') ->first(); if ($compLog) { $workStart = $compLog->new_value; } } if (!$workStart || $workStart === '-') { $prevWork = \App\Models\WorkActivity::where('patient_id', $patient->id) ->where('created_at', '<=', $apt->created_at ?: now()) ->whereNotNull('work_start_year') ->where('work_start_year', '!=', '-') ->where('work_start_year', '!=', '') ->orderBy('created_at', 'desc') ->first(); if ($prevWork) { $workStart = $prevWork->work_start_year; } } $previousCompanyHistories->put($compKey, [ 'company' => $comp, 'company_name' => $comp->name, 'job_position' => $jobPos ?: '-', 'work_start_year' => $workStart ?: '-', 'last_mcu_date' => $apt->appointment_date ? \App\Helpers\DateHelper::formatDate($apt->appointment_date) : null, ]); } } } // 2. Tambahkan previousCompany milik pasien jika belum ada di list (fallback) if ($patient->previousCompany && (int) $patient->previous_company_id !== (int) $patient->company_id) { if (!$previousCompanyHistories->has($patient->previous_company_id)) { $prevCompId = $patient->previous_company_id; $prevCompanyWork = \App\Models\WorkActivity::where('patient_id', $patient->id) ->whereHas('appointment', function ($q) use ($prevCompId) { $q->where('company_id', $prevCompId); }) ->first(); $jobPos = null; if ($prevCompanyWork && !empty($prevCompanyWork->occupation) && $prevCompanyWork->occupation !== '-') { $jobPos = $prevCompanyWork->occupation; } if (!$jobPos || $jobPos === '-') { $corpEmp = $patient->corporateInvitationEmployees?->first( fn($emp) => $emp->invitation?->company_id == $prevCompId || $emp->company_id == $prevCompId, ); if ($corpEmp) { $jobPos = $corpEmp->resolvedPositionName(); } } if (!$jobPos || $jobPos === '-') { $anyCorpEmp = $patient->corporateInvitationEmployees?->first(); if ($anyCorpEmp) { $jobPos = $anyCorpEmp->resolvedPositionName(); } } if (!$jobPos || $jobPos === '-') { $jobPos = $patient->job_position ?? '-'; } $workStart = null; if ( $prevCompanyWork && !empty($prevCompanyWork->work_start_year) && $prevCompanyWork->work_start_year !== '-' ) { $workStart = $prevCompanyWork->work_start_year; } if (!$workStart || $workStart === '-') { $prevCompLog = \App\Models\PatientChangeLog::where('patient_id', $patient->id) ->where('field_name', 'work_start_year') ->whereNotNull('new_value') ->where('new_value', '!=', '-') ->where('new_value', '!=', '') ->whereHas('appointment', function ($q) use ($prevCompId) { $q->where('company_id', $prevCompId); }) ->orderBy('created_at', 'desc') ->first(); if ($prevCompLog) { $workStart = $prevCompLog->new_value; } } $previousCompanyHistories->put($patient->previous_company_id, [ 'company' => $patient->previousCompany, 'company_name' => $patient->previousCompany->name, 'job_position' => $jobPos ?: '-', 'work_start_year' => $workStart ?: '-', 'last_mcu_date' => null, ]); } } // Resolve work_start_year khusus untuk perusahaan saat ini $latestAppt = $patient->appointments()->where('status', '!=', 'cancelled')->latest()->first(); $currentCompanyWorkActivity = null; if ($latestAppt && (int) $latestAppt->company_id === (int) $patient->company_id) { $currentCompanyWorkActivity = \App\Models\WorkActivity::where('appointment_id', $latestAppt->id)->latest()->first(); } if ((!$currentCompanyWorkActivity || !$currentCompanyWorkActivity->work_start_year) && $patient->company_id) { $currentCompanyWorkActivity = \App\Models\WorkActivity::where('patient_id', $patient->id) ->whereHas('appointment', function ($q) use ($patient) { $q->where('company_id', $patient->company_id); }) ->latest() ->first(); } if (!$currentCompanyWorkActivity || !$currentCompanyWorkActivity->work_start_year) { $currentCompanyWorkActivity = \App\Models\WorkActivity::where('patient_id', $patient->id)->latest()->first(); } $currentWorkStartYear = $currentCompanyWorkActivity?->work_start_year; if (!$currentWorkStartYear) { $anyWorkStart = \App\Models\WorkActivity::where('patient_id', $patient->id) ->whereNotNull('work_start_year') ->where('work_start_year', '!=', '') ->latest() ->first(); if ($anyWorkStart) { $currentWorkStartYear = $anyWorkStart->work_start_year; } } @endphp @if ($previousCompanyHistories->isNotEmpty())
Riwayat Perusahaan Sebelumnya ({{ $previousCompanyHistories->count() }}):
@foreach ($previousCompanyHistories as $prevHist) @endforeach
Perusahaan Jabatan Tahun Mulai Bekerja MCU Terakhir
{{ $prevHist['company_name'] }} {{ $prevHist['job_position'] }} {{ $prevHist['work_start_year'] }} {{ $prevHist['last_mcu_date'] ?? '-' }}
@endif

{{ $patient->company ? $patient->company->name : 'Pasien Individu' }}

@if ($patient->company) {{ $patient->company->address ?? 'Alamat tidak tersedia' }} @endif

{{ $patient->job_position ?? '-' }}

{{ $currentWorkStartYear ?: '-' }}

{{ $latestWork?->hobby ?: '-' }}

{{ $latestWork?->activities ?: '-' }}

@if ($patient->company) Karyawan Perusahaan @else Pasien Individu @endif

@if ($patient->company)
Informasi Detail Perusahaan

Email: {{ $patient->company->email ?? 'Tidak tersedia' }}

Telepon: {{ $patient->company->phone ?? 'Tidak tersedia' }}

Kontak Person: {{ $patient->company->contact_person ?? 'Tidak tersedia' }}

Status: @if ($patient->company->is_active ?? true) Aktif @else Tidak Aktif @endif

@else
Perhatian

Pasien ini tidak terdaftar dalam perusahaan manapun (Pasien Individu).

@endif
@if ($latestWork)
Status: {{ $latestWork->status_label }}
Diperbarui: {{ \App\Helpers\DateHelper::formatShort($latestWork->updated_at) }} {{ $latestWork->updated_at->format('H:i') }}
Kegiatan Waktu Kerja
@php $workActivities = [ 'operates_moving_equipment' => 'Sopir / mengoperasikan peralatan bergerak (mobil, crane, alat lainnya)', 'works_at_height' => 'Bekerja di ketinggian (tangga, Lift, eskalator)', 'works_in_office' => 'Bekerja di perkantoran', 'works_in_noisy_place' => 'Bekerja di tempat bising', 'works_in_dusty_place' => 'Bekerja di tempat berdebu', 'needs_color_accuracy' => 'Perlu keakuratan warna, kode lampu warna', 'is_catering_staff' => 'Staff Catering (seluruh personal yang mengelola makanan)', 'handles_dangerous_materials' => 'Berhubungan dengan bahan yang berpotensi membahayakan', ]; $protectionMap = [ 'operates_moving_equipment' => 'moving_equipment', 'works_at_height' => 'height', 'works_in_office' => 'office', 'works_in_noisy_place' => 'noise', 'works_in_dusty_place' => 'dusty', 'needs_color_accuracy' => 'color', 'is_catering_staff' => 'catering', 'handles_dangerous_materials' => 'dangerous', ]; @endphp
@foreach ($workActivities as $field => $label) @php $protectionKey = $protectionMap[$field] ?? ''; $usesProtection = $protectionKey && $latestWork->{"uses_{$protectionKey}_protection"}; $protectionDetails = $protectionKey ? $latestWork->{"{$protectionKey}_protection_details"} : ''; @endphp @endforeach
Kegiatan Waktu Kerja Y/N Memakai Perlindungan Y/N
{{ $label }} @if ($latestWork->$field) Y @else N @endif @if ($protectionDetails) {{ $protectionDetails }} @else - @endif @if ($usesProtection) Y @else N @endif
@else
Data Aktivitas Kerja belum diisi.
@endif
@if ($latestHealth)
Status: {{ $latestHealth->status_label }}
Diperbarui: {{ \App\Helpers\DateHelper::formatShort($latestHealth->updated_at) }} {{ $latestHealth->updated_at->format('H:i') }}
Riwayat Kesehatan
@php $healthConditions = [ 'column1' => [ 'has_head_injury' => 'Cedera Kepala', 'has_seizure' => 'Ayan', 'has_vision_disorder' => 'Gangguan Penglihatan', 'has_hearing_disorder' => 'Gangguan Pendengaran', 'has_ear_nose_throat_problem' => 'Masalah Pada Telinga, Hidung', 'has_ear_problem_4weeks' => 'Masalah Telinga > 4 Minggu', 'has_womens_health_issue' => 'Masalah Kewanitaan', 'has_chronic_skin_problem' => 'Penyakit Kulit Menahun', 'has_chronic_diarrhea_issue' => 'Diare Kronis', 'has_appetite_loss_4weeks' => 'Nafsu Makan Menurun > 4 mgg', 'has_gastritis_ulcer' => 'Gastritis / Radang Lambung', ], 'column2' => [ 'has_yellow_fever_hepatitis' => 'Sakit Kuning / Hepatitis', 'has_chronic_cough_issue' => 'Batuk Kronis', 'has_hemorrhoids_issue' => 'Ambeien / Hemoroid', 'has_chronic_abdominal_pain' => 'Nyeri Perut Kronis', 'has_sexual_transmitted_disease' => 'Penyakit Kelamin', 'has_diabetes_mellitus' => 'Kencing Manis / Diabetes', 'has_asthma_shortness' => 'Asma / Sesak Napas', 'has_allergy_issue' => 'Alergi', 'has_tuberculosis' => 'TB Paru', 'has_mental_health_problem' => 'Masalah Kejiwaan', 'has_hypertension_issue' => 'Tekanan Darah Tinggi', ], 'column3' => [ 'has_heart_chest_pain' => 'Nyeri Dada / Jantung', 'has_malaria_disease' => 'Malaria', 'has_surgical_operation' => 'Operasi Pembedahan', 'has_abnormal_weight_change' => 'Perubahan BB tdk normal', 'has_back_pain_4weeks' => 'Nyeri Pinggang > 4 mgg', 'has_typhoid_fever' => 'Demam Thyfoid', 'has_joint_swelling_pain' => 'Bengkak / Nyeri pd sendi', 'has_kidney_stone_disease' => 'Kencing Batu / Ginjal', ], ]; @endphp
@php $column1Items = array_keys($healthConditions['column1']); $column2Items = array_keys($healthConditions['column2']); $column3Items = array_keys($healthConditions['column3']); $maxRows = max(count($column1Items), count($column2Items), count($column3Items)); $column1Items = array_pad($column1Items, $maxRows, null); $column2Items = array_pad($column2Items, $maxRows, null); $column3Items = array_pad($column3Items, $maxRows, null); @endphp @for ($i = 0; $i < $maxRows; $i++) @endfor
Apakah Anda Pernah Menderita Y/N Apakah Anda Pernah Menderita Y/N Apakah Anda Pernah Menderita Y/N
@if ($column1Items[$i]) {{ $healthConditions['column1'][$column1Items[$i]] }} @endif @if ($column1Items[$i] && $latestHealth->{$column1Items[$i]}) Y @elseif ($column1Items[$i]) N @endif @if ($column2Items[$i]) {{ $healthConditions['column2'][$column2Items[$i]] }} @endif @if ($column2Items[$i] && $latestHealth->{$column2Items[$i]}) Y @elseif ($column2Items[$i]) N @endif @if ($column3Items[$i]) {{ $healthConditions['column3'][$column3Items[$i]] }} @endif @if ($column3Items[$i] && $latestHealth->{$column3Items[$i]}) Y @elseif ($column3Items[$i]) N @endif
@if ($latestHealth->other_chronic_diseases)
Penyakit Kronis Lainnya:

{{ $latestHealth->other_chronic_diseases }}

@endif @else
Data Riwayat Kesehatan belum diisi.
@endif
@if ($latestFamily)
Status: {{ $latestFamily->status_label }}
Diperbarui: {{ \App\Helpers\DateHelper::formatShort($latestFamily->updated_at) }} {{ $latestFamily->updated_at->format('H:i') }}
Riwayat Kesehatan Keluarga
@php $familyMembers = [ 'father' => 'Bapak', 'mother' => 'Ibu', 'siblings' => 'Saudara', 'others' => 'Lain-lain', ]; @endphp
@foreach ($familyMembers as $key => $label) @endforeach
Diabetes Hipertensi Penyakit Lainnya
{{ $label }} {{ $latestFamily->{$key . '_diabetes'} ?: '-' }} {{ $latestFamily->{$key . '_hypertension'} ?: '-' }} {{ $latestFamily->{$key . '_other_diseases'} ?: '-' }}
@else
Data Riwayat Keluarga belum diisi.
@endif
@if ($latestLifestyle)
Status: {{ $latestLifestyle->status_label }}
Diperbarui: {{ \App\Helpers\DateHelper::formatShort($latestLifestyle->updated_at) }} {{ $latestLifestyle->updated_at->format('H:i') }}
Data Gaya Hidup
@if ($latestLifestyle->alcohol_consumption_weekly) @endif @if ($latestLifestyle->smoking_daily) @endif @if ($latestLifestyle->medications_consumed) @endif
Konsumsi Alkohol/Minggu {{ $latestLifestyle->alcohol_consumption_weekly }}
Rokok/Hari {{ $latestLifestyle->smoking_daily }}
Obat-obatan yang Dikonsumsi {{ $latestLifestyle->medications_consumed }}
@if ($latestLifestyle->health_notes)
Catatan Kesehatan:

{{ $latestLifestyle->health_notes }}

@endif @else
Data Gaya Hidup belum diisi.
@endif
@if ($patient->appointments && $patient->appointments->count() > 0)

Riwayat Kunjungan

@foreach ($patient->appointments as $appointment) @endforeach
Tanggal Paket MCU Status Aksi
{{ \App\Helpers\DateHelper::formatShort( $appointment->appointment_date, ) }} {{ $appointment->mcuPackage ? $appointment->mcuPackage->name : '-' }} {{ ucfirst($appointment->status) }} @canRoute ('appointments.show') @endcanRoute
@endif @if ($patient->mcuResults && $patient->mcuResults->count() > 0)

Hasil MCU

@foreach ($patient->mcuResults as $result) @endforeach
Tanggal Kode Status Aksi
{{ \App\Helpers\DateHelper::formatShort( $result->created_at, ) }} {{ $result->code }} {{ ucfirst($result->status) }} @canRoute ('mcu-results.show') @endcanRoute
@endif
@if ($patientServiceSummary !== null) @include('patients.partials.service-summary', ['summary' => $patientServiceSummary]) @endif

Arsip Riwayat Check-up Legacy

Referensi dari sistem sebelumnya. Arsip ini tidak menjadi appointment atau hasil MCU aktif.

{{ $patient->legacyMcuRecords->count() }} riwayat
@if ($patient->legacyMcuRecords->isNotEmpty())
@foreach ($patient->legacyMcuRecords as $legacyRecord)

Dokter
{{ $legacyRecord->doctor_name ?? '-' }}
Nomor Resep Lama
{{ $legacyRecord->prescription_number ?? '-' }}
Batch Arsip
{{ $legacyRecord->importBatch?->batch_number ?? '-' }}
Sumber
{{ $legacyRecord->importBatch?->source_label ?? '-' }}
@if ($legacyRecord->measurements->isNotEmpty())
@foreach ($legacyRecord->measurements as $measurement) @endforeach
Parameter Nilai
{{ $measurement->display_name }} {{ $measurement->value_text }}{{ $measurement->unit ? ' ' . $measurement->unit : '' }}
@endif @if ($legacyRecord->complaint || $legacyRecord->treatment)
@if ($legacyRecord->complaint)
Keluhan dari sistem lama
{{ $legacyRecord->complaint }}
@endif @if ($legacyRecord->treatment)
Tindakan dari sistem lama
{{ $legacyRecord->treatment }}
@endif
@endif @if ($legacyRecord->documents->isNotEmpty())
Metadata Dokumen Legacy
    @foreach ($legacyRecord->documents as $document)
  • {{ $document->original_filename }} {{ $document->document_type ?? 'Dokumen' }}
  • @endforeach
@endif
@endforeach
@else
Belum ada arsip check-up dari sistem sebelumnya yang tertaut ke pasien ini.
@endif
@endsection