initial commit

This commit is contained in:
2026-09-23 12:45:02 +07:00
parent d16f454083
commit 507fc6ccdf
235 changed files with 19587 additions and 2835 deletions
+191 -85
View File
@@ -1,118 +1,224 @@
<x-app-layout>
<div class="max-w-4xl mx-auto space-y-6 pb-12">
<div class="flex items-center gap-4">
<a href="{{ url()->previous() }}" class="p-3 bg-white border border-slate-200 rounded-2xl text-slate-400 hover:text-indigo-600 transition-all shadow-sm active:scale-90">
<i class="fas fa-arrow-left"></i>
</a>
<div>
<h2 class="text-2xl font-black text-slate-800 tracking-tight">Tambah Rekam Medis</h2>
<p class="text-sm text-slate-500 font-medium italic uppercase tracking-tighter">Pemeriksaan & Pemberian Obat Pasien</p>
<div class="max-w-5xl mx-auto space-y-6 pb-12" x-data="treatmentForm()">
{{-- HEADER --}}
<div class="flex items-center justify-between gap-4">
<div class="flex items-center gap-4">
<a href="{{ url()->previous() }}" class="p-3 bg-white border border-slate-200 rounded-2xl text-slate-400 hover:text-indigo-600 transition-all shadow-sm active:scale-90">
<i class="fas fa-arrow-left"></i>
</a>
<div>
<h2 class="text-2xl font-black text-slate-800 tracking-tight">Tambah Rekam Medis</h2>
<p class="text-sm text-slate-500 font-medium italic uppercase tracking-tighter">Pemeriksaan & Pemberian Obat Pasien (Multi-Obat Support)</p>
</div>
</div>
</div>
{{-- GLOBAL ERROR BANNER --}}
@if ($errors->any())
<div class="bg-rose-50 border border-rose-200 rounded-2xl p-6 flex items-start gap-4">
<div class="w-10 h-10 bg-rose-100 text-rose-500 rounded-xl flex items-center justify-center shrink-0">
<i class="fas fa-exclamation-triangle"></i>
</div>
<div>
<h4 class="text-xs font-black text-rose-600 uppercase tracking-widest mb-1">Gagal Menyimpan Data</h4>
<ul class="text-[11px] text-rose-500 font-bold list-disc list-inside space-y-1">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
</div>
@endif
<form action="{{ route('treatments.store') }}" method="POST" enctype="multipart/form-data" class="space-y-6">
@csrf
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div class="bg-white border border-slate-200 rounded-[2.5rem] p-8 shadow-sm space-y-6">
<h4 class="text-xs font-black text-indigo-600 uppercase tracking-widest border-b border-slate-100 pb-3">Data Pasien</h4>
<div class="space-y-4">
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Pilih Pasien</label>
<select name="cat_id" required class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold text-slate-800 focus:ring-2 focus:ring-indigo-500 transition-all">
@foreach($cats as $cat)
<option value="{{ $cat->id }}" {{ ($selectedCat && $selectedCat->id == $cat->id) || old('cat_id') == $cat->id ? 'selected' : '' }}>
{{ $cat->nama_kucing }} ({{ $cat->ras }})
</option>
@endforeach
</select>
</div>
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Tanggal Pemeriksaan</label>
<input type="date" name="tanggal" value="{{ date('Y-m-d') }}" required class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold focus:ring-2 focus:ring-indigo-500 transition-all">
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
{{-- LEFT COLUMN: DATA PASIEN --}}
<div class="lg:col-span-1 space-y-6">
<div class="bg-white border border-slate-200 rounded-[2.5rem] p-6 shadow-sm space-y-6">
<h4 class="text-xs font-black text-indigo-600 uppercase tracking-widest border-b border-slate-100 pb-3">Data Pasien</h4>
<div class="space-y-4">
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Pilih Pasien</label>
<select name="cat_id" required class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold text-slate-800 focus:ring-2 focus:ring-indigo-500 transition-all">
<option value="" disabled selected>-- Pilih Pasien --</option>
@foreach($cats as $cat)
<option value="{{ $cat->id }}" {{ ($selectedCat && $selectedCat->id == $cat->id) || old('cat_id') == $cat->id ? 'selected' : '' }}>
{{ $cat->nama_kucing }} ({{ $cat->ras }})
</option>
@endforeach
</select>
</div>
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Tanggal Pemeriksaan</label>
<input type="date" name="tanggal" value="{{ old('tanggal', date('Y-m-d')) }}" required class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold focus:ring-2 focus:ring-indigo-500 transition-all">
</div>
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Foto Bukti / Kondisi (Opsional)</label>
<input type="file" name="foto_bukti" class="w-full text-xs font-bold text-slate-400 file:mr-4 file:py-2 file:px-4 file:rounded-full file:border-0 file:text-[10px] file:font-black file:bg-indigo-50 file:text-indigo-600 hover:file:bg-indigo-100 transition-all">
</div>
</div>
</div>
</div>
<div class="bg-white border border-slate-200 rounded-[2.5rem] p-8 shadow-sm space-y-6">
<h4 class="text-xs font-black text-emerald-600 uppercase tracking-widest border-b border-slate-100 pb-3">Inventori & Dosis</h4>
<div class="space-y-4">
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Pilih Obat (Stok)</label>
<select name="medicine_id" id="medicine_select" required class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold focus:ring-2 focus:ring-emerald-500 transition-all">
<option value="" disabled selected>-- Pilih Obat --</option>
@foreach($medicines as $med)
<option value="{{ $med->id }}" data-unit="{{ $med->unit }}" {{ old('medicine_id') == $med->id ? 'selected' : '' }}>
{{ $med->nama_obat }} (Tersedia: {{ (float)$med->qty }} {{ $med->unit }})
</option>
@endforeach
</select>
</div>
<div class="grid grid-cols-2 gap-4">
{{-- RIGHT COLUMN: HASIL PEMERIKSAAN --}}
<div class="lg:col-span-2 space-y-6">
<div class="bg-white border border-slate-200 rounded-[2.5rem] p-8 shadow-sm space-y-6">
<h4 class="text-xs font-black text-rose-600 uppercase tracking-widest border-b border-slate-100 pb-3">Diagnosa Klinik</h4>
<div class="space-y-4">
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Jumlah Potong Stok</label>
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Keluhan Utama</label>
<input type="text" name="keluhan" value="{{ old('keluhan') }}" required placeholder="Contoh: Flu berat, Nafsu makan turun" class="w-full px-4 py-3 bg-slate-50 border {{ $errors->has('keluhan') ? 'border-rose-500 ring-1 ring-rose-500' : 'border-slate-200' }} rounded-2xl text-sm font-bold focus:ring-2 focus:ring-rose-500 transition-all">
</div>
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Hasil Diagnosa & Tindakan</label>
<textarea name="diagnosa" rows="3" required placeholder="Tulis diagnosa dokter/staf dan tindakan yang diambil..." class="w-full px-4 py-3 bg-slate-50 border {{ $errors->has('diagnosa') ? 'border-rose-500 ring-1 ring-rose-500' : 'border-slate-200' }} rounded-2xl text-sm font-bold focus:ring-2 focus:ring-rose-500 transition-all">{{ old('diagnosa') }}</textarea>
</div>
</div>
</div>
</div>
</div>
{{-- MULTI MEDICINE SECTION --}}
<div class="bg-white border border-slate-200 rounded-[2.5rem] p-8 shadow-sm space-y-6">
<div class="flex items-center justify-between border-b border-slate-100 pb-4">
<h4 class="text-xs font-black text-emerald-600 uppercase tracking-widest">Resep Obat & Penggunaan Stok</h4>
<button type="button" @click="addObat" class="px-4 py-2 bg-emerald-50 text-emerald-600 text-[10px] font-black rounded-xl hover:bg-emerald-600 hover:text-white transition-all flex items-center gap-2">
<i class="fas fa-plus"></i> TAMBAH OBAT
</button>
</div>
<div class="space-y-4">
{{-- Header Table --}}
<div class="hidden md:grid grid-cols-12 gap-4 px-4 text-[9px] font-black text-slate-400 uppercase tracking-widest">
<div class="col-span-4">Nama Obat (Stok Tersedia)</div>
<div class="col-span-2 text-center">Jumlah Stok</div>
<!-- <div class="col-span-2 text-center">Dosis</div>
<div class="col-span-3">Keterangan Pakai</div> -->
<div class="col-span-1"></div>
</div>
{{-- Loop Baris Obat (AlpineJS) --}}
<template x-for="(item, index) in items" :key="index">
<div class="grid grid-cols-1 md:grid-cols-12 gap-3 bg-slate-50 p-4 md:p-2 rounded-2xl items-center border border-slate-100 transition-all">
{{-- Pilih Obat --}}
<div class="col-span-1 md:col-span-4">
<label class="md:hidden text-[9px] font-black text-slate-400 uppercase">Obat</label>
<select :name="`items[${index}][medicine_id]`"
x-model="item.medicine_id"
@change="updateUnit(index, $event)"
required
class="w-full px-3 py-2 bg-white border border-slate-200 rounded-xl text-xs font-bold focus:ring-emerald-500">
<option value="">-- Pilih Obat --</option>
@foreach($medicines as $med)
<option value="{{ $med->id }}" data-unit="{{ $med->unit }}" data-stock="{{ (float)$med->qty }}">
{{ $med->nama_obat }} ({{ (float)$med->qty }} {{ $med->unit }})
</option>
@endforeach
</select>
</div>
{{-- Qty Used --}}
<div class="col-span-1 md:col-span-2">
<label class="md:hidden text-[9px] font-black text-slate-400 uppercase">Qty Potong Stok</label>
<div class="relative">
<input type="number" name="qty_used" id="qty_input" value="{{ old('qty_used', 1) }}" step="0.01" min="0.01" required class="w-full pl-4 pr-14 py-3 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-black text-slate-800">
<span id="unit_label" class="absolute right-4 top-1/2 -translate-y-1/2 text-[9px] font-black text-slate-400 uppercase">UNIT</span>
<input type="number" :name="`items[${index}][qty_used]`" x-model="item.qty_used" step="0.01" required
class="w-full pl-3 pr-10 py-2 bg-white border border-slate-200 rounded-xl text-xs font-black">
<span class="absolute right-3 top-1/2 -translate-y-1/2 text-[8px] font-black text-slate-300" x-text="item.unit"></span>
</div>
</div>
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Dosis (cc/butir)</label>
<input type="text" name="dosis" value="{{ old('dosis') }}" placeholder="Contoh: 0.5cc" required class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold focus:ring-2 focus:ring-emerald-500 transition-all">
{{-- Dosis --}}
<!-- <div class="col-span-1 md:col-span-2">
<label class="md:hidden text-[9px] font-black text-slate-400 uppercase">Dosis</label>
<input type="text" :name="`items[${index}][dosis]`" x-model="item.dosis" required placeholder="0.5 cc / 1 tablet"
class="w-full px-3 py-2 bg-white border border-slate-200 rounded-xl text-xs font-bold">
</div> -->
{{-- Keterangan --}}
<!-- <div class="col-span-1 md:col-span-3">
<label class="md:hidden text-[9px] font-black text-slate-400 uppercase">Ket</label>
<input type="text" :name="`items[${index}][keterangan]`" x-model="item.keterangan" placeholder="Oral / Campur Wetfood"
class="w-full px-3 py-2 bg-white border border-slate-200 rounded-xl text-xs font-bold">
</div> -->
{{-- Tombol Hapus --}}
<div class="col-span-1 md:col-span-1 text-center mt-2 md:mt-0">
<button type="button" @click="removeItem(index)" x-show="items.length > 1" class="w-8 h-8 inline-flex items-center justify-center bg-rose-50 text-rose-500 rounded-lg hover:bg-rose-500 hover:text-white transition-all">
<i class="fas fa-times text-xs"></i>
</button>
</div>
</div>
<p class="text-[9px] text-slate-400 italic px-1 leading-tight">* Gunakan titik (.) untuk desimal, contoh: 2.5</p>
</template>
<div class="bg-amber-50 border border-amber-100 rounded-2xl p-4 flex items-start gap-3">
<i class="fas fa-info-circle text-amber-500 mt-1"></i>
<div>
<p class="text-[10px] text-amber-800 font-bold leading-tight">Gunakan titik (.) untuk angka desimal. Pastikan jumlah potong stok tidak melebihi stok tersedia untuk menghindari error sistem.</p>
</div>
</div>
</div>
</div>
<div class="bg-white border border-slate-200 rounded-[2.5rem] p-8 shadow-sm space-y-6">
<h4 class="text-xs font-black text-rose-600 uppercase tracking-widest border-b border-slate-100 pb-3">Hasil Pemeriksaan</h4>
<div class="space-y-4">
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Keluhan Utama</label>
<input type="text" name="keluhan" value="{{ old('keluhan') }}" required placeholder="Contoh: Mata berair dan bersin" class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold focus:ring-2 focus:ring-rose-500 transition-all">
</div>
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Diagnosa & Tindakan</label>
<textarea name="diagnosa" rows="4" required class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold focus:ring-2 focus:ring-rose-500 transition-all">{{ old('diagnosa') }}</textarea>
</div>
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Keterangan Tambahan (Opsional)</label>
<textarea name="keterangan" rows="2" class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-medium italic">{{ old('keterangan') }}</textarea>
</div>
</div>
</div>
<button type="submit" class="w-full py-5 bg-indigo-600 text-white text-sm font-black rounded-3xl shadow-xl hover:bg-indigo-700 transition-all active:scale-[0.98] flex items-center justify-center gap-2">
<i class="fas fa-save"></i> SIMPAN REKAM MEDIS & UPDATE STOK
<button type="submit" class="w-full py-5 bg-slate-900 text-white text-sm font-black rounded-3xl shadow-xl hover:bg-indigo-700 transition-all active:scale-[0.98] flex items-center justify-center gap-2">
<i class="fas fa-save"></i> SIMPAN REKAM MEDIS & UPDATE SEMUA STOK
</button>
</form>
</div>
@push('scripts')
<script src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js" defer></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
const medicineSelect = document.getElementById('medicine_select');
const unitLabel = document.getElementById('unit_label');
document.addEventListener('alpine:init', () => {
Alpine.data('treatmentForm', () => ({
// Membaca input lama jika validasi form gagal, agar baris obat tidak hilang
init() {
const oldItems = @json(old('items', []));
if (oldItems.length > 0) {
this.items = oldItems.map(item => ({
medicine_id: item.medicine_id || '',
qty_used: item.qty_used || 1,
unit: 'UNIT', // Akan diupdate oleh user
dosis: item.dosis || '',
keterangan: item.keterangan || ''
}));
}
},
items: [{
medicine_id: '',
qty_used: 1,
unit: 'UNIT',
dosis: '',
keterangan: ''
}],
function updateUnit() {
const selectedOption = medicineSelect.options[medicineSelect.selectedIndex];
const unit = selectedOption.getAttribute('data-unit');
unitLabel.textContent = unit ? unit : 'UNIT';
}
addObat() {
this.items.push({
medicine_id: '',
qty_used: 1,
unit: 'UNIT',
dosis: '',
keterangan: ''
});
},
// Update label saat pilihan berubah
medicineSelect.addEventListener('change', updateUnit);
removeItem(index) {
this.items.splice(index, 1);
},
// Update label saat halaman dimuat (jika ada nilai 'old')
if (medicineSelect.value) {
updateUnit();
}
});
// Menggunakan event.target lebih aman dari querySelectorAll
updateUnit(index, event) {
const select = event.target;
const selectedOption = select.options[select.selectedIndex];
const unit = selectedOption.getAttribute('data-unit');
this.items[index].unit = unit ? unit : 'UNIT';
}
}))
})
</script>
@endpush
</x-app-layout>
+184 -81
View File
@@ -1,128 +1,230 @@
<x-app-layout>
<div class="max-w-4xl mx-auto space-y-6 pb-12">
<div class="max-w-5xl mx-auto space-y-6 pb-12" x-data="treatmentForm()">
{{-- HEADER --}}
<div class="flex items-center gap-4">
<a href="{{ route('treatments.index') }}" class="p-3 bg-white border border-slate-200 rounded-2xl text-slate-400 hover:text-indigo-600 transition-all shadow-sm active:scale-90">
<i class="fas fa-arrow-left"></i>
</a>
<div>
<h2 class="text-2xl font-black text-slate-800 tracking-tight">Edit Rekam Medis</h2>
<p class="text-sm text-slate-500 font-medium italic uppercase tracking-tighter">Memperbarui Catatan Medis & Dosis Obat</p>
<p class="text-sm text-slate-500 font-medium italic uppercase tracking-tighter">Memperbarui Catatan & Penyesuaian Multi-Obat</p>
</div>
</div>
{{-- ALERT INFORMASI STOK --}}
<div class="p-4 bg-amber-50 border border-amber-100 rounded-2xl flex items-start gap-3">
<i class="fas fa-exclamation-triangle text-amber-500 mt-1"></i>
<i class="fas fa-sync-alt text-amber-500 mt-1 animate-spin-slow"></i>
<div>
<p class="text-xs font-black text-amber-700 uppercase tracking-widest">Informasi Inventori</p>
<p class="text-[11px] text-amber-600 font-medium leading-relaxed">Mengubah jenis atau jumlah obat akan memicu sistem untuk mengembalikan stok lama dan memotong stok baru secara otomatis.</p>
<p class="text-xs font-black text-amber-700 uppercase tracking-widest">Sinkronisasi Inventori Otomatis</p>
<p class="text-[11px] text-amber-600 font-medium leading-relaxed">Sistem akan otomatis mengembalikan stok lama yang tercatat dan memotong stok baru berdasarkan perubahan yang Anda simpan di bawah ini.</p>
</div>
</div>
{{-- GLOBAL ERROR BANNER --}}
@if ($errors->any())
<div class="p-4 bg-rose-50 border border-rose-100 rounded-2xl text-rose-600 text-[11px] font-bold">
<ul class="list-disc ml-4 uppercase tracking-widest">
<div class="bg-rose-50 border border-rose-200 rounded-2xl p-6 flex items-start gap-4">
<div class="w-10 h-10 bg-rose-100 text-rose-500 rounded-xl flex items-center justify-center shrink-0">
<i class="fas fa-exclamation-triangle"></i>
</div>
<div>
<h4 class="text-xs font-black text-rose-600 uppercase tracking-widest mb-1">Gagal Menyimpan Data</h4>
<ul class="text-[11px] text-rose-500 font-bold list-disc list-inside space-y-1">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
</div>
@endif
<form action="{{ route('treatments.update', $treatment->id) }}" method="POST" enctype="multipart/form-data" class="space-y-6">
@csrf
@method('PATCH')
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div class="bg-white border border-slate-200 rounded-[2.5rem] p-8 shadow-sm space-y-6">
<h4 class="text-xs font-black text-indigo-600 uppercase tracking-widest border-b border-slate-100 pb-3">Data Pasien</h4>
<div class="space-y-4">
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Nama Pasien</label>
<select name="cat_id" required class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold text-slate-800 focus:ring-2 focus:ring-indigo-500">
@foreach($cats as $cat)
<option value="{{ $cat->id }}" {{ old('cat_id', $treatment->cat_id) == $cat->id ? 'selected' : '' }}>
{{ $cat->nama_kucing }} ({{ $cat->ras }})
</option>
@endforeach
</select>
</div>
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Tanggal Pemeriksaan</label>
<input type="date" name="tanggal" value="{{ old('tanggal', $treatment->tanggal->format('Y-m-d')) }}" required class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold focus:ring-2 focus:ring-indigo-500">
</div>
</div>
</div>
<div class="bg-white border border-slate-200 rounded-[2.5rem] p-8 shadow-sm space-y-6">
<h4 class="text-xs font-black text-emerald-600 uppercase tracking-widest border-b border-slate-100 pb-3">Dosis & Stok</h4>
<div class="space-y-4">
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Obat Digunakan</label>
<select name="medicine_id" required class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold focus:ring-2 focus:ring-emerald-500">
@foreach($medicines as $med)
<option value="{{ $med->id }}" {{ old('medicine_id', $treatment->medicine_id) == $med->id ? 'selected' : '' }}>
{{ $med->nama_obat }} (Stok: {{ $med->qty }} {{ $med->unit }})
</option>
@endforeach
</select>
</div>
<div class="grid grid-cols-2 gap-4">
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
{{-- LEFT COLUMN: DATA PASIEN --}}
<div class="lg:col-span-1 space-y-6">
<div class="bg-white border border-slate-200 rounded-[2.5rem] p-6 shadow-sm space-y-6">
<h4 class="text-xs font-black text-indigo-600 uppercase tracking-widest border-b border-slate-100 pb-3">Data Pasien</h4>
<div class="space-y-4">
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Jumlah (Qty)</label>
<input type="number" name="qty_used" value="{{ old('qty_used', $treatment->qty_used) }}" min="1" required class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-black text-slate-800">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Pasien</label>
<select name="cat_id" required class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold text-slate-800 focus:ring-2 focus:ring-indigo-500 transition-all">
@foreach($cats as $cat)
<option value="{{ $cat->id }}" {{ old('cat_id', $treatment->cat_id) == $cat->id ? 'selected' : '' }}>
{{ $cat->nama_kucing }} ({{ $cat->ras }})
</option>
@endforeach
</select>
</div>
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Dosis</label>
<input type="text" name="dosis" value="{{ old('dosis', $treatment->dosis) }}" placeholder="Contoh: 1 tablet" required class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold text-slate-800">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Tanggal Pemeriksaan</label>
<input type="date" name="tanggal" value="{{ old('tanggal', $treatment->tanggal->format('Y-m-d')) }}" required class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold focus:ring-2 focus:ring-indigo-500 transition-all">
</div>
</div>
</div>
</div>
</div>
<div class="bg-white border border-slate-200 rounded-[2.5rem] p-8 shadow-sm space-y-6">
<h4 class="text-xs font-black text-rose-600 uppercase tracking-widest border-b border-slate-100 pb-3">Detail Pemeriksaan Medis</h4>
<div class="space-y-4">
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Keluhan / Gejala</label>
<input type="text" name="keluhan" value="{{ old('keluhan', $treatment->keluhan) }}" required class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold focus:ring-2 focus:ring-rose-500">
{{-- PREVIEW FOTO --}}
<div class="bg-white border border-slate-200 rounded-[2.5rem] p-6 shadow-sm space-y-4">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Lampiran Foto Bukti</label>
<div class="relative group">
<div class="w-full h-48 rounded-3xl bg-slate-50 border-2 border-dashed border-slate-200 overflow-hidden shadow-inner flex items-center justify-center">
<img id="preview" src="{{ $treatment->foto_bukti ? asset('storage/' . $treatment->foto_bukti) : 'https://ui-avatars.com/api/?name=No+Photo&background=f1f5f9&color=94a3b8' }}" class="w-full h-full object-cover">
</div>
<input type="file" name="foto_bukti" onchange="previewImage(event)" class="mt-3 w-full text-[10px] font-black text-slate-400 file:mr-3 file:py-2 file:px-4 file:rounded-full file:border-0 file:text-[9px] file:font-black file:bg-indigo-50 file:text-indigo-600 hover:file:bg-indigo-100 cursor-pointer">
</div>
</div>
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Diagnosa & Tindakan</label>
<textarea name="diagnosa" rows="4" required class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold focus:ring-2 focus:ring-rose-500">{{ old('diagnosa', $treatment->diagnosa) }}</textarea>
</div>
{{-- RIGHT COLUMN: HASIL PEMERIKSAAN --}}
<div class="lg:col-span-2 space-y-6">
<div class="bg-white border border-slate-200 rounded-[2.5rem] p-8 shadow-sm space-y-6">
<h4 class="text-xs font-black text-rose-600 uppercase tracking-widest border-b border-slate-100 pb-3">Diagnosa Klinik</h4>
<div class="space-y-4">
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Keluhan Utama</label>
<input type="text" name="keluhan" value="{{ old('keluhan', $treatment->keluhan) }}" required class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold focus:ring-2 focus:ring-rose-500 transition-all">
</div>
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Hasil Diagnosa & Tindakan</label>
<textarea name="diagnosa" rows="4" required class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold focus:ring-2 focus:ring-rose-500 transition-all">{{ old('diagnosa', $treatment->diagnosa) }}</textarea>
</div>
</div>
</div>
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Keterangan Tambahan</label>
<textarea name="keterangan" rows="2" class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold italic">{{ old('keterangan', $treatment->keterangan) }}</textarea>
{{-- MULTI MEDICINE SECTION --}}
<div class="bg-white border border-slate-200 rounded-[2.5rem] p-8 shadow-sm space-y-6">
<div class="flex items-center justify-between border-b border-slate-100 pb-4">
<h4 class="text-xs font-black text-emerald-600 uppercase tracking-widest">Penyesuaian Resep & Stok</h4>
<button type="button" @click="addObat" class="px-4 py-2 bg-emerald-50 text-emerald-600 text-[10px] font-black rounded-xl hover:bg-emerald-600 hover:text-white transition-all flex items-center gap-2">
<i class="fas fa-plus"></i> TAMBAH OBAT LAIN
</button>
</div>
<div class="space-y-4">
{{-- Header Table --}}
<div class="hidden md:grid grid-cols-12 gap-4 px-4 text-[9px] font-black text-slate-400 uppercase tracking-widest">
<div class="col-span-4">Nama Obat</div>
<div class="col-span-2 text-center">Jumlah</div>
<div class="col-span-1"></div>
</div>
{{-- Loop Baris Obat (Alpine.js) --}}
<template x-for="(item, index) in items" :key="index">
<div class="grid grid-cols-1 md:grid-cols-12 gap-3 bg-slate-50 p-4 md:p-2 rounded-2xl items-center border border-slate-100 transition-all">
{{-- Pilih Obat --}}
<div class="col-span-1 md:col-span-4">
<label class="md:hidden text-[9px] font-black text-slate-400 uppercase tracking-widest mb-1 block">Obat</label>
<select :name="`items[${index}][medicine_id]`"
x-model="item.medicine_id"
@change="updateUnit(index)"
required
class="w-full px-3 py-2 bg-white border border-slate-200 rounded-xl text-xs font-bold focus:ring-emerald-500">
<option value="">-- Pilih --</option>
@foreach($medicines as $med)
<option value="{{ $med->id }}" data-unit="{{ $med->unit }}">
{{ $med->nama_obat }} (Stok: {{ (float)$med->qty }} {{ $med->unit }})
</option>
@endforeach
</select>
</div>
{{-- Qty Used --}}
<div class="col-span-1 md:col-span-2">
<label class="md:hidden text-[9px] font-black text-slate-400 uppercase tracking-widest mb-1 block">Qty Potong Stok</label>
<div class="relative">
<input type="number" :name="`items[${index}][qty_used]`" x-model="item.qty_used" step="0.01" required
class="w-full pl-3 pr-8 py-2 bg-white border border-slate-200 rounded-xl text-xs font-black">
<span class="absolute right-2 top-1/2 -translate-y-1/2 text-[8px] font-black text-slate-300" x-text="item.unit"></span>
</div>
</div>
{{-- Tombol Hapus --}}
<div class="col-span-1 md:col-span-1 text-center mt-2 md:mt-0">
<button type="button" @click="removeItem(index)" x-show="items.length > 1" class="w-8 h-8 inline-flex items-center justify-center bg-rose-50 text-rose-500 rounded-lg hover:bg-rose-500 hover:text-white transition-all">
<i class="fas fa-times text-xs"></i>
</button>
</div>
</div>
</template>
</div>
</div>
</div>
</div>
<div class="bg-white border border-slate-200 rounded-[2.5rem] p-8 shadow-sm space-y-4">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Lampiran Foto Bukti (Opsional)</label>
<div class="flex flex-col md:flex-row gap-6 items-center">
<div class="w-32 h-32 rounded-3xl bg-slate-50 border-2 border-dashed border-slate-200 overflow-hidden ring-4 ring-white shadow-md shrink-0 flex items-center justify-center">
<img id="preview" src="{{ $treatment->foto_bukti ? asset('storage/' . $treatment->foto_bukti) : 'https://ui-avatars.com/api/?name=Bukti+Foto&background=f1f5f9&color=94a3b8' }}" class="w-full h-full object-cover">
</div>
<div class="flex-1 w-full">
<input type="file" name="foto_bukti" onchange="previewImage(event)" class="w-full p-3 bg-slate-50 border border-slate-200 rounded-2xl text-xs font-bold file:mr-4 file:py-2 file:px-4 file:rounded-full file:border-0 file:text-[10px] file:font-black file:bg-indigo-600 file:text-white hover:file:bg-indigo-700 cursor-pointer">
<p class="text-[9px] text-slate-400 mt-2 italic">* Upload foto baru untuk mengganti bukti pengobatan sebelumnya.</p>
</div>
</div>
</div>
<div class="flex gap-4">
<button type="submit" class="flex-1 py-5 bg-indigo-600 text-white text-xs font-black rounded-3xl shadow-xl shadow-indigo-100 hover:bg-indigo-700 transition-all active:scale-[0.98] flex items-center justify-center gap-2">
<i class="fas fa-sync-alt"></i> SIMPAN PERUBAHAN & RE-SYNC STOK
</button>
</div>
<button type="submit" class="w-full py-5 bg-slate-900 text-white text-sm font-black rounded-3xl shadow-xl hover:bg-indigo-600 transition-all active:scale-[0.98] flex items-center justify-center gap-2">
<i class="fas fa-save"></i> PERBARUI REKAM MEDIS & SINKRONISASI STOK
</button>
</form>
</div>
@push('scripts')
<script src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js" defer></script>
@php
// [FIX ERROR SYNTAX BLADE]
$mappedItems = [];
$oldItems = old('items');
if ($oldItems) {
$mappedItems = $oldItems;
} else {
if (isset($treatment->details) && $treatment->details->count() > 0) {
$mappedItems = $treatment->details->map(function($detail) {
return [
'medicine_id' => $detail->medicine_id,
'qty_used' => (float) $detail->qty_used,
'unit' => $detail->medicine->unit ?? 'UNIT',
'dosis' => $detail->dosis ?? '',
'keterangan' => $detail->keterangan ?? '',
];
})->toArray();
} else {
$mappedItems = [[
'medicine_id' => $treatment->medicine_id,
'qty_used' => (float) $treatment->qty_used,
'unit' => $treatment->medicine->unit ?? 'UNIT',
'dosis' => $treatment->dosis ?? '',
'keterangan' => $treatment->keterangan ?? '',
]];
}
}
@endphp
<script>
function treatmentForm() {
return {
items: @json($mappedItems),
addObat() {
this.items.push({
medicine_id: '',
qty_used: 1,
unit: 'UNIT',
dosis: '',
keterangan: ''
});
},
removeItem(index) {
this.items.splice(index, 1);
},
updateUnit(index) {
setTimeout(() => {
const select = document.querySelectorAll('select[name^="items"]')[index];
if (select) {
const selectedOption = select.options[select.selectedIndex];
const unit = selectedOption.getAttribute('data-unit');
this.items[index].unit = unit ? unit : 'UNIT';
}
}, 10);
}
}
}
function previewImage(event) {
const reader = new FileReader();
reader.onload = function() {
@@ -134,4 +236,5 @@
}
}
</script>
@endpush
</x-app-layout>
+142 -50
View File
@@ -1,13 +1,12 @@
<x-app-layout>
<div class="space-y-6 pb-8">
<div class="max-w-7xl mx-auto space-y-6 pb-8">
{{-- SECTION 1: Header --}}
<div class="flex flex-col md:flex-row md:items-center justify-between gap-4">
<div class="flex flex-col md:flex-row md:items-center justify-between gap-4 px-2">
<div>
<h2 class="text-2xl font-black text-slate-800 tracking-tight leading-none mb-1 text-uppercase">Log Rekam Medis</h2>
<p class="text-xs text-slate-500 font-medium italic uppercase tracking-wider">Riwayat kesehatan & penggunaan obat seluruh kucing.</p>
<h2 class="text-2xl font-black text-slate-800 tracking-tight leading-none mb-1 uppercase">Log Rekam Medis</h2>
<p class="text-xs text-slate-500 font-medium italic uppercase tracking-wider">Laporan Riwayat Kesehatan & Penggunaan Inventaris Obat.</p>
</div>
{{-- PROTEKSI TOMBOL CREATE: Hanya muncul jika punya izin Create --}}
@can('check-access', ['treatments', 'create'])
<a href="{{ route('treatments.create') }}" class="inline-flex items-center px-6 py-4 bg-slate-900 text-white text-[10px] font-black rounded-2xl shadow-xl hover:bg-black transition-all active:scale-95 tracking-widest uppercase">
<i class="fas fa-plus-circle mr-2 text-sm"></i> INPUT REKAM MEDIS
@@ -15,17 +14,76 @@
@endcan
</div>
{{-- SECTION 2: Tabel Rekam Medis --}}
<div class="bg-white border border-slate-200 rounded-[2.5rem] overflow-hidden shadow-sm">
{{-- SECTION 2: Filter dan ekspor --}}
<div class="bg-white border border-slate-200 rounded-[2.5rem] p-6 mx-2 shadow-sm">
<form action="{{ route('treatments.index') }}" method="GET" class="space-y-4">
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-4">
{{-- Cari Kucing --}}
<div class="space-y-1">
<label class="text-[9px] font-black text-slate-400 uppercase ml-2 tracking-widest">Pasien</label>
<div class="relative">
<i class="fas fa-search absolute left-4 top-1/2 -translate-y-1/2 text-slate-300 text-xs"></i>
<input type="text" name="search" value="{{ request('search') }}" placeholder="Cari nama kucing..."
class="w-full pl-10 pr-4 py-2.5 bg-slate-50 border-none rounded-xl text-xs font-bold focus:ring-2 focus:ring-indigo-500">
</div>
</div>
{{-- PIC / Staf --}}
<div class="space-y-1">
<label class="text-[9px] font-black text-slate-400 uppercase ml-2 tracking-widest">PIC / Staf</label>
<select name="pic_id" class="w-full px-4 py-2.5 bg-slate-50 border-none rounded-xl text-xs font-bold focus:ring-2 focus:ring-indigo-500">
<option value="">Semua Staf</option>
@foreach($pics as $pic)
<option value="{{ $pic->id }}" {{ request('pic_id') == $pic->id ? 'selected' : '' }}>{{ $pic->name }}</option>
@endforeach
</select>
</div>
{{-- Rentang Tanggal --}}
<div class="lg:col-span-2 space-y-1">
<label class="text-[9px] font-black text-slate-400 uppercase ml-2 tracking-widest">Rentang Waktu</label>
<div class="grid grid-cols-2 gap-2">
<input type="date" name="start_date" value="{{ request('start_date') }}" class="w-full px-4 py-2.5 bg-slate-50 border-none rounded-xl text-xs font-bold focus:ring-2 focus:ring-indigo-500">
<input type="date" name="end_date" value="{{ request('end_date') }}" class="w-full px-4 py-2.5 bg-slate-50 border-none rounded-xl text-xs font-bold focus:ring-2 focus:ring-indigo-500">
</div>
</div>
</div>
{{-- Action Buttons --}}
<div class="flex flex-wrap items-center justify-between gap-4 pt-2 border-t border-slate-50">
<div class="flex items-center gap-2">
<button type="submit" class="px-6 py-2.5 bg-indigo-600 text-white rounded-xl text-[10px] font-black uppercase tracking-widest hover:bg-indigo-700 transition-all shadow-md shadow-indigo-100">
<i class="fas fa-filter mr-2"></i> Terapkan Filter
</button>
<a href="{{ route('treatments.index') }}" class="px-6 py-2.5 bg-slate-100 text-slate-500 rounded-xl text-[10px] font-black uppercase tracking-widest hover:bg-slate-200 transition-all">
<i class="fas fa-sync-alt mr-2"></i> Reset
</a>
</div>
<div class="flex items-center gap-2">
<button type="submit" name="export" value="excel" class="px-4 py-2.5 bg-emerald-50 text-emerald-600 border border-emerald-100 rounded-xl text-[10px] font-black uppercase tracking-widest hover:bg-emerald-600 hover:text-white transition-all">
<i class="fas fa-file-excel mr-2 text-sm"></i> Excel
</button>
<button type="submit" name="export" value="pdf" class="px-4 py-2.5 bg-rose-50 text-rose-600 border border-rose-100 rounded-xl text-[10px] font-black uppercase tracking-widest hover:bg-rose-600 hover:text-white transition-all">
<i class="fas fa-file-pdf mr-2 text-sm"></i> PDF
</button>
</div>
</div>
</form>
</div>
{{-- SECTION 3: Tabel Rekam Medis --}}
<div class="bg-white border border-slate-200 rounded-[2.5rem] overflow-hidden shadow-sm mx-2">
<div class="overflow-x-auto">
<table class="w-full text-left border-collapse">
<thead class="bg-slate-50 text-[10px] font-black text-slate-400 uppercase tracking-widest border-b border-slate-100">
<tr>
<th class="px-6 py-4">Tanggal & Kucing</th>
<th class="px-6 py-4">Keluhan & Diagnosa</th>
<th class="px-6 py-4">Obat (Qty)</th>
<th class="px-6 py-4 text-center">Bukti</th>
<th class="px-6 py-4 text-right" style="min-width: 220px;">Aksi</th>
<th class="px-6 py-5">Tanggal & Kucing</th>
<th class="px-6 py-5">Kondisi</th>
<th class="px-6 py-5">Keluhan & Diagnosa</th>
<th class="px-6 py-5">Obat & Qty</th>
<th class="px-6 py-5 text-center">Lampiran</th>
<th class="px-6 py-5 text-right">Aksi</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-100 font-medium text-slate-700">
@@ -34,81 +92,86 @@
{{-- Tanggal & Kucing --}}
<td class="px-6 py-4">
<div class="flex items-center gap-3">
<div class="w-10 h-10 rounded-xl bg-slate-100 overflow-hidden ring-2 ring-white shadow-sm">
<div class="w-10 h-10 rounded-xl bg-slate-100 overflow-hidden ring-2 ring-white shadow-sm shrink-0">
<img src="{{ $treatment->cat->foto ? asset('storage/'.$treatment->cat->foto) : 'https://ui-avatars.com/api/?name='.urlencode($treatment->cat->nama_kucing).'&background=f1f5f9&color=4f46e5' }}" class="w-full h-full object-cover">
</div>
<div>
<p class="text-[10px] font-black text-indigo-600 uppercase leading-none mb-1">{{ $treatment->tanggal->format('d M Y') }}</p>
<p class="text-sm font-black text-slate-800 leading-none">{{ $treatment->cat->nama_kucing }}</p>
<p class="text-[10px] font-black text-indigo-600 uppercase leading-none mb-1">{{ \Carbon\Carbon::parse($treatment->tanggal)->format('d M Y') }}</p>
<p class="text-sm font-black text-slate-800 leading-none truncate w-32">{{ $treatment->cat->nama_kucing }}</p>
</div>
</div>
</td>
{{-- Keluhan & Diagnosa --}}
<td class="px-6 py-4 max-w-xs">
<p class="text-xs font-black text-slate-800 truncate">{{ $treatment->keluhan }}</p>
<p class="text-[10px] text-slate-500 line-clamp-1 italic uppercase tracking-tighter">{{ $treatment->diagnosa }}</p>
{{-- Kondisi Kucing --}}
<td class="px-6 py-4">
@if($treatment->cat->treatment_status == 1)
<span class="px-2 py-1 bg-rose-50 text-rose-600 rounded-lg text-[8px] font-black border border-rose-100 uppercase tracking-tighter">Under Perawatan</span>
@else
<span class="px-2 py-1 bg-emerald-50 text-emerald-600 rounded-lg text-[8px] font-black border border-emerald-100 uppercase tracking-tighter">Sehat</span>
@endif
</td>
{{-- Obat & Qty --}}
{{-- Keluhan & Diagnosa --}}
<td class="px-6 py-4 max-w-xs">
<p class="text-xs font-black text-slate-800 truncate" title="{{ $treatment->keluhan }}">{{ $treatment->keluhan }}</p>
{{-- Limit diperbesar agar detail catatan obat bisa terbaca --}}
<p class="text-[10px] text-slate-500 line-clamp-2 italic uppercase tracking-tighter" title="{{ $treatment->diagnosa }}">{{ Str::limit($treatment->diagnosa, 75) }}</p>
</td>
{{-- Obat & Qty (Menggunakan Relasi Langsung) --}}
<td class="px-6 py-4">
<div class="flex items-center gap-2">
<span class="px-2 py-1 bg-emerald-50 text-emerald-600 rounded-lg text-[10px] font-black border border-emerald-100 uppercase">
{{ $treatment->nama_obat }}
</span>
<span class="text-[10px] font-bold text-slate-400">x{{ number_format($treatment->qty_used, 0) }}</span>
<div class="flex flex-wrap gap-1.5 max-w-[200px]">
<div class="flex items-center gap-1.5 bg-slate-50 px-2 py-1 rounded-lg border border-slate-100">
<span class="text-[9px] font-black text-slate-700 uppercase">{{ $treatment->medicine->nama_obat ?? 'N/A' }}</span>
<span class="text-[8px] font-bold text-indigo-500">x{{ (float)$treatment->qty_used }}</span>
</div>
</div>
</td>
{{-- Foto Bukti --}}
<td class="px-6 py-4 text-center">
@if($treatment->foto_bukti)
<a href="{{ asset('storage/'.$treatment->foto_bukti) }}" target="_blank" class="w-8 h-8 inline-flex items-center justify-center bg-indigo-50 text-indigo-500 hover:bg-indigo-100 rounded-lg transition-all shadow-sm" title="Lihat Bukti">
<i class="fas fa-image"></i>
<a href="{{ asset('storage/'.$treatment->foto_bukti) }}" target="_blank" class="w-8 h-8 inline-flex items-center justify-center bg-indigo-50 text-indigo-500 hover:bg-indigo-600 hover:text-white rounded-lg transition-all shadow-sm">
<i class="fas fa-image text-xs"></i>
</a>
@else
<span class="text-slate-300 text-[10px] font-bold">TIDAK ADA</span>
<span class="text-slate-200 text-[10px] font-bold tracking-widest">N/A</span>
@endif
</td>
{{-- AKSI --}}
<td class="px-6 py-4 text-right align-middle">
<div class="flex justify-end items-center gap-16">
{{-- PROTEKSI TOMBOL EDIT: Hanya jika punya izin Update --}}
<td class="px-6 py-4 text-right">
<div class="flex justify-end items-center gap-2">
<a href="{{ route('treatments.show', $treatment->id) }}" class="w-8 h-8 flex items-center justify-center bg-slate-50 text-slate-400 hover:bg-indigo-50 hover:text-indigo-600 rounded-xl transition-all shadow-sm">
<i class="fas fa-eye text-[10px]"></i>
</a>
@can('check-access', ['treatments', 'update'])
<a href="{{ route('treatments.edit', $treatment->id) }}"
class="flex items-center gap-3 p-2 text-slate-400 hover:text-amber-600 transition-all group/btn"
title="Edit Rekam Medis">
<i class="fas fa-edit text-base"></i>
<span class="text-[10px] font-black uppercase hidden group-hover/btn:inline tracking-widest">Edit</span>
<a href="{{ route('treatments.edit', $treatment->id) }}" class="w-8 h-8 flex items-center justify-center bg-slate-50 text-slate-400 hover:bg-amber-50 hover:text-amber-600 rounded-xl transition-all shadow-sm">
<i class="fas fa-edit text-[10px]"></i>
</a>
@endcan
{{-- PROTEKSI TOMBOL HAPUS: Hanya jika punya izin Delete --}}
@can('check-access', ['treatments', 'delete'])
<form action="{{ route('treatments.destroy', $treatment->id) }}" method="POST" class="inline m-0">
@csrf @method('DELETE')
<button type="button"
onclick="confirmDelete(this, 'Rekam Medis {{ addslashes($treatment->cat->nama_kucing) }}')"
class="flex items-center gap-3 p-2 text-slate-400 hover:text-rose-600 transition-all group/btn"
title="Hapus Data">
<i class="fas fa-trash-alt text-base"></i>
<span class="text-[10px] font-black uppercase hidden group-hover/btn:inline tracking-widest">Hapus</span>
<button type="button" onclick="confirmDelete(this, 'Rekam Medis {{ addslashes($treatment->cat->nama_kucing) }}')"
class="w-8 h-8 flex items-center justify-center bg-slate-50 text-slate-400 hover:bg-rose-50 hover:text-rose-600 rounded-xl transition-all shadow-sm">
<i class="fas fa-trash-alt text-[10px]"></i>
</button>
</form>
@endcan
</div>
</td>
</tr>
@empty
<tr>
<td colspan="5" class="px-6 py-24 text-center">
<div class="w-16 h-16 bg-slate-50 rounded-3xl flex items-center justify-center mx-auto mb-4">
<i class="fas fa-notes-medical text-2xl text-slate-200"></i>
<td colspan="6" class="px-6 py-32 text-center">
<div class="w-20 h-20 bg-slate-50 rounded-[2rem] flex items-center justify-center mx-auto mb-4 border border-slate-100">
<i class="fas fa-microscope text-3xl text-slate-200"></i>
</div>
<p class="text-slate-400 font-bold uppercase text-[10px] tracking-widest">Belum ada riwayat rekam medis</p>
<h3 class="text-slate-400 font-black uppercase text-xs tracking-[0.4em]">Data Tidak Ditemukan</h3>
<p class="text-slate-300 text-[10px] font-bold mt-2 uppercase italic tracking-tighter">Gunakan filter yang berbeda atau input rekam medis baru</p>
</td>
</tr>
@endforelse
@@ -117,9 +180,38 @@
</div>
{{-- Pagination --}}
<div class="p-6 border-t border-slate-100 bg-slate-50/30">
@if($treatments->hasPages())
<div class="p-8 border-t border-slate-100 bg-slate-50/30">
{{ $treatments->links() }}
</div>
@endif
</div>
</div>
@push('scripts')
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script>
function confirmDelete(button, name) {
Swal.fire({
title: 'Hapus Rekam Medis?',
text: "Menghapus data " + name + " akan mengembalikan stok obat ke inventaris secara otomatis.",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#e11d48',
cancelButtonColor: '#64748b',
confirmButtonText: 'Ya, Hapus Data',
cancelButtonText: 'Batal',
customClass: {
popup: 'rounded-[2.5rem]',
confirmButton: 'rounded-xl font-black uppercase text-[10px] tracking-widest px-6 py-3',
cancelButton: 'rounded-xl font-black uppercase text-[10px] tracking-widest px-6 py-3'
}
}).then((result) => {
if (result.isConfirmed) {
button.closest('form').submit();
}
})
}
</script>
@endpush
</x-app-layout>
@@ -0,0 +1,172 @@
<x-app-layout>
<div class="max-w-5xl mx-auto space-y-6 pb-12">
{{-- HEADER --}}
<div class="flex items-center justify-between px-2">
<div class="flex items-center gap-4">
<a href="{{ route('treatments.index') }}" class="p-3 bg-white border border-slate-200 rounded-2xl text-slate-400 hover:text-indigo-600 transition-all shadow-sm">
<i class="fas fa-arrow-left"></i>
</a>
<div>
<h2 class="text-2xl font-black text-slate-800 tracking-tight leading-none uppercase">Detail Rekam Medis</h2>
<p class="text-[10px] text-indigo-600 font-black uppercase tracking-widest mt-1">ID Pemeriksaan: #TR-{{ str_pad($treatment->id, 5, '0', STR_PAD_LEFT) }}</p>
</div>
</div>
<div class="flex gap-2">
<button onclick="window.print()" class="px-4 py-2 bg-white border border-slate-200 text-slate-600 text-[10px] font-black rounded-xl uppercase tracking-widest hover:bg-slate-50">
<i class="fas fa-print mr-2"></i> Cetak Laporan
</button>
</div>
</div>
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
{{-- KOLOM KIRI: PASIEN & PROGRES --}}
<div class="space-y-6">
{{-- Info Kucing --}}
<div class="bg-white border border-slate-200 rounded-[2.5rem] p-6 shadow-sm text-center">
<div class="w-24 h-24 rounded-3xl bg-slate-100 mx-auto overflow-hidden ring-4 ring-indigo-50 shadow-md">
<img src="{{ $treatment->cat->foto ? asset('storage/'.$treatment->cat->foto) : 'https://ui-avatars.com/api/?name='.urlencode($treatment->cat->nama_kucing) }}" class="w-full h-full object-cover">
</div>
<h3 class="mt-4 text-xl font-black text-slate-800 uppercase tracking-tight">{{ $treatment->cat->nama_kucing }}</h3>
<p class="text-[10px] font-bold text-slate-400 uppercase">{{ $treatment->cat->ras }} • {{ \Carbon\Carbon::parse($treatment->tanggal)->format('d F Y') }}</p>
{{-- Progres Status --}}
<div class="mt-6 pt-6 border-t border-slate-50">
<p class="text-[9px] font-black text-slate-400 uppercase tracking-widest mb-3">Progres Pengobatan</p>
@php
$isImproving = Str::contains(strtolower($treatment->diagnosa), ['baik', 'makan', 'aktif', 'sembuh', 'turun panas']);
@endphp
@if($isImproving || $treatment->status_perawatan == 2)
<div class="bg-emerald-50 border border-emerald-100 rounded-2xl p-4">
<i class="fas fa-chart-line text-emerald-500 text-xl mb-2"></i>
<p class="text-xs font-black text-emerald-700 uppercase">Kondisi Membaik / Sembuh</p>
<p class="text-[10px] text-emerald-600 font-medium mt-1">Pasien menunjukkan respon positif terhadap terapi obat.</p>
</div>
@else
<div class="bg-amber-50 border border-amber-100 rounded-2xl p-4">
<i class="fas fa-stagnation text-amber-500 text-xl mb-2"></i>
<p class="text-xs font-black text-amber-700 uppercase">Kondisi Stuck / Tetap</p>
<p class="text-[10px] text-amber-600 font-medium mt-1">Belum ada perubahan signifikan. Perlu observasi lanjutan.</p>
</div>
@endif
</div>
</div>
{{-- Bukti Foto --}}
<div class="bg-white border border-slate-200 rounded-[2.5rem] p-6 shadow-sm">
<p class="text-[9px] font-black text-slate-400 uppercase tracking-widest mb-4">Lampiran Bukti</p>
@if($treatment->foto_bukti)
<img src="{{ asset('storage/'.$treatment->foto_bukti) }}" class="w-full rounded-2xl shadow-sm border border-slate-100">
@else
<div class="py-8 text-center bg-slate-50 rounded-2xl border border-dashed border-slate-200">
<i class="fas fa-image text-slate-200 text-2xl mb-2"></i>
<p class="text-[9px] font-black text-slate-300 uppercase">Tidak ada lampiran foto</p>
</div>
@endif
</div>
</div>
{{-- KOLOM KANAN: DETAIL MEDIS --}}
@php
// Logika Pemisahan String: Mengekstrak Dosis dan Keterangan dari Kolom Diagnosa
// Contoh: "Flu Berat | Dosis: 0.5cc (Campur wetfood)"
$fullDiagnosa = $treatment->diagnosa;
$pureDiagnosa = $fullDiagnosa;
$extractedDosis = 'Sesuai Resep / Standar';
$extractedKeterangan = '-';
// Pisahkan berdasarkan tanda "|" (pemisah Dosis)
if (str_contains($fullDiagnosa, '| Dosis:')) {
$parts = explode('| Dosis:', $fullDiagnosa);
$pureDiagnosa = trim($parts[0]);
// Cek jika ada keterangan dalam tanda kurung "()" setelah Dosis
$dosisAndKet = trim($parts[1]);
if (preg_match('/^(.*)\((.*)\)$/', $dosisAndKet, $matches)) {
$extractedDosis = trim($matches[1]);
$extractedKeterangan = trim($matches[2]);
} else {
$extractedDosis = $dosisAndKet;
}
}
@endphp
<div class="lg:col-span-2 space-y-6">
{{-- Ringkasan Diagnosa --}}
<div class="bg-white border border-slate-200 rounded-[2.5rem] p-8 shadow-sm">
<div class="flex items-center gap-3 mb-6">
<div class="w-10 h-10 rounded-xl bg-rose-50 text-rose-500 flex items-center justify-center">
<i class="fas fa-stethoscope"></i>
</div>
<h4 class="text-sm font-black text-slate-800 uppercase tracking-widest">Laporan Diagnosa</h4>
</div>
<div class="space-y-4">
<div>
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest">Keluhan / Gejala Utama:</label>
<p class="text-sm font-bold text-slate-700 mt-1">{{ $treatment->keluhan }}</p>
</div>
<div>
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest">Hasil Pemeriksaan Klinik:</label>
<div class="bg-slate-50 p-4 rounded-2xl border border-slate-100 mt-2">
<p class="text-sm text-slate-600 font-medium leading-relaxed italic">"{{ $pureDiagnosa }}"</p>
</div>
</div>
</div>
</div>
{{-- Tabel Obat Detail --}}
<div class="bg-white border border-slate-200 rounded-[2.5rem] overflow-hidden shadow-sm">
<div class="px-8 py-5 border-b border-slate-50 bg-emerald-50/30">
<h4 class="text-xs font-black text-emerald-700 uppercase tracking-widest">Daftar Obat Terkait Kasus Ini</h4>
</div>
<div class="overflow-x-auto">
<table class="w-full text-left">
<thead class="bg-slate-50 text-[9px] font-black text-slate-400 uppercase tracking-widest">
<tr>
<th class="px-8 py-4">Item Obat</th>
<th class="px-4 py-4 text-center">Qty / Potong Stok</th>
<th class="px-4 py-4">Dosis</th>
<th class="px-8 py-4">Keterangan Khusus</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-50">
<tr>
<td class="px-8 py-4">
<span class="text-xs font-black text-slate-800 uppercase">{{ $treatment->medicine->nama_obat ?? 'OBAT DIHAPUS' }}</span>
</td>
<td class="px-4 py-4 text-center text-xs font-black text-indigo-600">
{{ (float)$treatment->qty_used }} <span class="text-[9px] text-slate-400 uppercase">{{ $treatment->medicine->unit ?? '' }}</span>
</td>
<td class="px-4 py-4 text-xs font-bold text-slate-600">{{ $extractedDosis }}</td>
<td class="px-8 py-4 text-[10px] font-medium text-slate-400 italic">{{ $extractedKeterangan }}</td>
</tr>
</tbody>
</table>
</div>
</div>
{{-- Status Resolusi (Sembuh / Belum) --}}
@if($treatment->status_perawatan == 2)
<div class="bg-emerald-50 border border-emerald-200 rounded-[2.5rem] p-6 shadow-sm flex items-start gap-4">
<div class="w-10 h-10 bg-emerald-100 text-emerald-600 rounded-xl flex items-center justify-center shrink-0">
<i class="fas fa-check-circle"></i>
</div>
<div>
<h4 class="text-sm font-black text-emerald-700 uppercase tracking-widest mb-1">Kasus Diselesaikan (Sembuh)</h4>
<p class="text-xs font-bold text-emerald-600 italic">"{{ $treatment->remark_pasca_sakit ?? 'Tidak ada catatan pasca sakit' }}"</p>
</div>
</div>
@endif
{{-- Footer Info --}}
<div class="flex items-center justify-between px-6 text-[9px] font-black text-slate-300 uppercase tracking-[0.2em]">
<span>Diperiksa Oleh: {{ $treatment->user->name ?? 'Staf / Dokter' }}</span>
<span>Terakhir Update: {{ $treatment->updated_at->format('d/m/Y H:i') }}</span>
</div>
</div>
</div>
</div>
</x-app-layout>