feat: add management patient
This commit is contained in:
parent
c48a6073cf
commit
daafcbdf4c
@ -2,9 +2,64 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\ManagePatient\StoreNewPatient;
|
||||
use App\Http\Requests\ManagePatient\UpdatePatient;
|
||||
use App\Models\Patient;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PatientController extends Controller
|
||||
{
|
||||
//
|
||||
public function index()
|
||||
{
|
||||
$patients = Patient::all();
|
||||
return view('patient.index', compact('patients'));
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('patient.add');
|
||||
}
|
||||
|
||||
public function store(StoreNewPatient $request)
|
||||
{
|
||||
$patient = new Patient();
|
||||
$patient->fill($request->validated());
|
||||
|
||||
// Generate a 16-character medical record number
|
||||
$uniqueNumber = str_pad(rand(1, 99999999), 8, '0', STR_PAD_LEFT); // Ensure 8 digits
|
||||
$timestamp = substr(time(), -5); // Take the last 8 digits of the timestamp
|
||||
$patient->medical_record_number = 'MR' . $timestamp . $uniqueNumber; // Combine to make 16 characters
|
||||
$patient->save();
|
||||
|
||||
return redirect()->route('patient-management.index')->with('success', 'Data pasien baru berhasil ditambahkan!');
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$patient = Patient::findOrFail($id);
|
||||
return view('patient.show', compact('patient'));
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$patient = Patient::findOrFail($id);
|
||||
return view('patient.edit', compact('patient'));
|
||||
}
|
||||
|
||||
public function update(UpdatePatient $request, $id)
|
||||
{
|
||||
$patient = Patient::findOrFail($id);
|
||||
$patient->fill($request->validated());
|
||||
$patient->save();
|
||||
|
||||
return redirect()->route('patient-management.index')->with('success', 'Data pasien berhasil diperbarui!');
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$patient = Patient::findOrFail($id);
|
||||
$patient->delete();
|
||||
|
||||
return redirect()->route('patient-management.index')->with('success', 'Data pasien berhasil dihapus!');
|
||||
}
|
||||
}
|
||||
|
||||
80
app/Http/Requests/ManagePatient/StoreNewPatient.php
Normal file
80
app/Http/Requests/ManagePatient/StoreNewPatient.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\ManagePatient;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class StoreNewPatient extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'identity_number' => ['required', 'numeric', 'unique:patients,identity_number'],
|
||||
'first_name' => ['required', 'string', 'max:255'],
|
||||
'last_name' => ['required', 'string', 'max:255'],
|
||||
'birth_date' => ['required', 'date'],
|
||||
'gender' => ['required', Rule::in(['L', 'P'])],
|
||||
'blood_type' => ['required', Rule::in(['A', 'B', 'AB', 'O'])],
|
||||
'phone_number' => ['required', 'string', 'max:15'],
|
||||
'email' => ['required', 'email', 'unique:patients,email'],
|
||||
'address' => ['required', 'string'],
|
||||
'allergies' => ['required', 'string'],
|
||||
'current_medicines' => ['required', 'string'],
|
||||
'medical_history' => ['required', 'string'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom error messages for validation rules.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'identity_number.required' => 'NIK wajib diisi.',
|
||||
'identity_number.numeric' => 'NIK harus berupa angka.',
|
||||
'identity_number.unique' => 'NIK sudah terdaftar.',
|
||||
'first_name.required' => 'Nama depan wajib diisi.',
|
||||
'first_name.string' => 'Nama depan harus berupa teks.',
|
||||
'first_name.max' => 'Nama depan tidak boleh lebih dari 255 karakter.',
|
||||
'last_name.required' => 'Nama belakang wajib diisi.',
|
||||
'last_name.string' => 'Nama belakang harus berupa teks.',
|
||||
'last_name.max' => 'Nama belakang tidak boleh lebih dari 255 karakter.',
|
||||
'birth_date.required' => 'Tanggal lahir wajib diisi.',
|
||||
'birth_date.date' => 'Tanggal lahir harus berupa tanggal yang valid.',
|
||||
'gender.required' => 'Jenis kelamin wajib dipilih.',
|
||||
'gender.in' => 'Jenis kelamin harus berupa Laki-Laki (L) atau Perempuan (P).',
|
||||
'blood_type.required' => 'Golongan darah wajib dipilih.',
|
||||
'blood_type.in' => 'Golongan darah harus berupa A, B, AB, atau O.',
|
||||
'phone_number.required' => 'Nomor HP wajib diisi.',
|
||||
'phone_number.string' => 'Nomor HP harus berupa teks.',
|
||||
'phone_number.max' => 'Nomor HP tidak boleh lebih dari 15 karakter.',
|
||||
'email.required' => 'Email wajib diisi.',
|
||||
'email.email' => 'Email harus berupa alamat email yang valid.',
|
||||
'email.unique' => 'Email sudah terdaftar.',
|
||||
'address.required' => 'Alamat wajib diisi.',
|
||||
'address.string' => 'Alamat harus berupa teks.',
|
||||
'allergies.required' => 'Alergi wajib diisi.',
|
||||
'allergies.string' => 'Alergi harus berupa teks.',
|
||||
'current_medicines.required' => 'Konsumsi obat saat ini wajib diisi.',
|
||||
'current_medicines.string' => 'Konsumsi obat saat ini harus berupa teks.',
|
||||
'medical_history.required' => 'Histori medis wajib diisi.',
|
||||
'medical_history.string' => 'Histori medis harus berupa teks.',
|
||||
];
|
||||
}
|
||||
}
|
||||
88
app/Http/Requests/ManagePatient/UpdatePatient.php
Normal file
88
app/Http/Requests/ManagePatient/UpdatePatient.php
Normal file
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\ManagePatient;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdatePatient extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'identity_number' => [
|
||||
'required',
|
||||
'numeric',
|
||||
Rule::unique('patients', 'identity_number')->ignore($this->route('id')),
|
||||
],
|
||||
'first_name' => ['required', 'string', 'max:255'],
|
||||
'last_name' => ['required', 'string', 'max:255'],
|
||||
'birth_date' => ['required', 'date'],
|
||||
'gender' => ['required', Rule::in(['L', 'P'])],
|
||||
'blood_type' => ['required', Rule::in(['A', 'B', 'AB', 'O'])],
|
||||
'phone_number' => ['required', 'string', 'max:15'],
|
||||
'email' => [
|
||||
'required',
|
||||
'email',
|
||||
Rule::unique('patients', 'email')->ignore($this->route('id')),
|
||||
],
|
||||
'address' => ['required', 'string'],
|
||||
'allergies' => ['required', 'string'],
|
||||
'current_medicines' => ['required', 'string'],
|
||||
'medical_history' => ['required', 'string'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom error messages for validation rules.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'identity_number.required' => 'NIK wajib diisi.',
|
||||
'identity_number.numeric' => 'NIK harus berupa angka.',
|
||||
'identity_number.unique' => 'NIK sudah terdaftar.',
|
||||
'first_name.required' => 'Nama depan wajib diisi.',
|
||||
'first_name.string' => 'Nama depan harus berupa teks.',
|
||||
'first_name.max' => 'Nama depan tidak boleh lebih dari 255 karakter.',
|
||||
'last_name.required' => 'Nama belakang wajib diisi.',
|
||||
'last_name.string' => 'Nama belakang harus berupa teks.',
|
||||
'last_name.max' => 'Nama belakang tidak boleh lebih dari 255 karakter.',
|
||||
'birth_date.required' => 'Tanggal lahir wajib diisi.',
|
||||
'birth_date.date' => 'Tanggal lahir harus berupa tanggal yang valid.',
|
||||
'gender.required' => 'Jenis kelamin wajib dipilih.',
|
||||
'gender.in' => 'Jenis kelamin harus berupa Laki-Laki (L) atau Perempuan (P).',
|
||||
'blood_type.required' => 'Golongan darah wajib dipilih.',
|
||||
'blood_type.in' => 'Golongan darah harus berupa A, B, AB, atau O.',
|
||||
'phone_number.required' => 'Nomor HP wajib diisi.',
|
||||
'phone_number.string' => 'Nomor HP harus berupa teks.',
|
||||
'phone_number.max' => 'Nomor HP tidak boleh lebih dari 15 karakter.',
|
||||
'email.required' => 'Email wajib diisi.',
|
||||
'email.email' => 'Email harus berupa alamat email yang valid.',
|
||||
'email.unique' => 'Email sudah terdaftar.',
|
||||
'address.required' => 'Alamat wajib diisi.',
|
||||
'address.string' => 'Alamat harus berupa teks.',
|
||||
'allergies.required' => 'Alergi wajib diisi.',
|
||||
'allergies.string' => 'Alergi harus berupa teks.',
|
||||
'current_medicines.required' => 'Konsumsi obat saat ini wajib diisi.',
|
||||
'current_medicines.string' => 'Konsumsi obat saat ini harus berupa teks.',
|
||||
'medical_history.required' => 'Histori medis wajib diisi.',
|
||||
'medical_history.string' => 'Histori medis harus berupa teks.',
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -9,4 +9,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
class Patient extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $table = "patients";
|
||||
protected $guarded = ["id"];
|
||||
}
|
||||
|
||||
@ -27,9 +27,9 @@ return new class extends Migration
|
||||
|
||||
// Medical Information
|
||||
$table->string('blood_type', 10); // (Golongan Darah)
|
||||
$table->string('allergies');
|
||||
$table->string('current_medicines');
|
||||
$table->text('medical_history');
|
||||
$table->string('allergies')->nullable(); // (Alergi)
|
||||
$table->string('current_medicines')->nullable(); // (Obat yang Sedang Dikonsumsi)
|
||||
$table->text('medical_history')->nullable(); // (Riwayat Penyakit)
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
||||
170
resources/views/patient/add.blade.php
Normal file
170
resources/views/patient/add.blade.php
Normal file
@ -0,0 +1,170 @@
|
||||
@extends('layouts.app')
|
||||
@section('content-header')
|
||||
<div class="content-header">
|
||||
<div class="container-fluid">
|
||||
<div class="row mb-2">
|
||||
<div class="col-sm-6">
|
||||
<h1 class="m-0">Tambah Pasien</h1>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<ol class="breadcrumb float-sm-right">
|
||||
<li class="breadcrumb-item"><a href="#">Home</a></li>
|
||||
<li class="breadcrumb-item active">Tambah Pasien</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@section('main-content')
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card card-primary">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Data Pasien</h3>
|
||||
</div>
|
||||
<form action="{{ route('patient-management.store') }}" method="POST">
|
||||
@csrf
|
||||
<div class="card-body" style="padding-bottom: 0.5rem">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label>NIK <strong class="text-danger">*</strong></label>
|
||||
<input name="identity_number" type="number" class="form-control"
|
||||
placeholder="Masukan NIK" value="{{ old('identity_number') }}" required>
|
||||
@error('identity_number')
|
||||
<small style="color: red;">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Nama Depan <strong class="text-danger">*</strong></label>
|
||||
<input name="first_name" type="text" class="form-control"
|
||||
placeholder="Masukan Nama Depan" value="{{ old('first_name') }}" required>
|
||||
@error('first_name')
|
||||
<small style="color: red;">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Nama Belakang <strong class="text-danger">*</strong></label>
|
||||
<input name="last_name" type="text" class="form-control"
|
||||
placeholder="Masukan Nama Belakang" value="{{ old('last_name') }}" required>
|
||||
@error('last_name')
|
||||
<small style="color: red;">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Tanggal Lahir <strong class="text-danger">*</strong></label>
|
||||
<input name="birth_date" type="date" class="form-control" placeholder="Tanggal Lahir"
|
||||
value="{{ old('birth_date') }}" required>
|
||||
@error('birth_date')
|
||||
<small style="color: red;">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Jenis Kelamin <strong class="text-danger">*</strong></label>
|
||||
<select name="gender" class="form-control">
|
||||
<option value="">-- Pilih --</option>
|
||||
<option value="L" {{ old('gender') == 'L' ? 'selected' : '' }}>Laki-Laki
|
||||
</option>
|
||||
<option value="P" {{ old('gender') == 'P' ? 'selected' : '' }}>Perempuan
|
||||
</option>
|
||||
</select>
|
||||
@error('gender')
|
||||
<small style="color: red;">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>No. HP <strong class="text-danger">*</strong></label>
|
||||
<input name="phone_number" type="text" class="form-control" placeholder="No. HP"
|
||||
value="{{ old('phone_number') }}" required>
|
||||
@error('phone_number')
|
||||
<small style="color: red;">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Contact Email <strong class="text-danger">*</strong></label>
|
||||
<input name="email" type="email" class="form-control" placeholder="Masukan Email"
|
||||
value="{{ old('email') }}" required>
|
||||
@error('email')
|
||||
<small style="color: red;">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label>Golongan Darah <strong class="text-danger">*</strong></label>
|
||||
<select name="blood_type" class="form-control">
|
||||
<option value="">-- Pilih --</option>
|
||||
<option value="A" {{ old('blood_type') == 'A' ? 'selected' : '' }}>A </option>
|
||||
<option value="B" {{ old('blood_type') == 'B' ? 'selected' : '' }}>B
|
||||
</option>
|
||||
<option value="AB" {{ old('blood_type') == 'AB' ? 'selected' : '' }}>AB
|
||||
</option>
|
||||
<option value="O" {{ old('blood_type') == 'O' ? 'selected' : '' }}>O
|
||||
</option>
|
||||
<option value="Lainnya" {{ old('blood_type') == 'Lainnya' ? 'selected' : '' }}>
|
||||
Lainnya
|
||||
</option>
|
||||
</select>
|
||||
@error('gender')
|
||||
<small style="color: red;">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Alamat <strong class="text-danger">*</strong></label>
|
||||
<textarea class="form-control" name="address" cols="20" rows="3" placeholder="Masukan Alamat" required>{{ old('address') }}</textarea>
|
||||
@error('address')
|
||||
<small style="color: red;">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Alergi: <strong class="text-danger">*</strong></label>
|
||||
<textarea class="form-control" name="allergies" cols="20" rows="3" placeholder="Sebutkan alergi jika ada"
|
||||
required>{{ old('allergies') }}</textarea>
|
||||
@error('allergies')
|
||||
<small style="color: red;">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Konsumsi Obat Saat Ini: <strong class="text-danger">*</strong></label>
|
||||
<textarea class="form-control" name="current_medicines" cols="20" rows="3"
|
||||
placeholder="Obat yang dikonsumsi saat ini, contoh : bodrex, almodipine" required>{{ old('current_medicines') }}</textarea>
|
||||
@error('current_medicines')
|
||||
<small style="color: red;">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Histori Medis: <strong class="text-danger">*</strong></label>
|
||||
<textarea class="form-control" name="medical_history" cols="20" rows="3"
|
||||
placeholder="Histori medis pasien" required>{{ old('medical_history') }}</textarea>
|
||||
@error('medical_history')
|
||||
<small style="color: red;">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<span class="text-muted float-start ml-4">
|
||||
<strong class="text-danger">*</strong> Wajib Diisi
|
||||
</span>
|
||||
<div class="card-footer mt-2">
|
||||
<button type="button" class="btn btn-primary" onclick="history.back()">Kembali</button>
|
||||
<button type="submit" class="btn btn-success">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@push('scripts')
|
||||
@if (session('success'))
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
Toast.fire({
|
||||
icon: 'success',
|
||||
title: "{{ session('success') }}",
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endif
|
||||
@endpush
|
||||
187
resources/views/patient/edit.blade.php
Normal file
187
resources/views/patient/edit.blade.php
Normal file
@ -0,0 +1,187 @@
|
||||
@extends('layouts.app')
|
||||
@section('content-header')
|
||||
<div class="content-header">
|
||||
<div class="container-fluid">
|
||||
<div class="row mb-2">
|
||||
<div class="col-sm-6">
|
||||
<h1 class="m-0">Edit Pasien</h1>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<ol class="breadcrumb float-sm-right">
|
||||
<li class="breadcrumb-item"><a href="#">Home</a></li>
|
||||
<li class="breadcrumb-item active">Edit Pasien</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@section('main-content')
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card card-primary">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Edit Data Pasien</h3>
|
||||
</div>
|
||||
<form action="{{ route('patient-management.update', $patient->id) }}" method="POST">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
<div class="card-body" style="padding-bottom: 0.5rem">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label>No. Rekam Medis</label>
|
||||
<input name="medical_record_number" type="text" class="form-control"
|
||||
value="{{ old('medical_record_number', $patient->medical_record_number) }}"
|
||||
readonly>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>NIK <strong class="text-danger">*</strong></label>
|
||||
<input name="identity_number" type="number" class="form-control"
|
||||
placeholder="Masukan NIK"
|
||||
value="{{ old('identity_number', $patient->identity_number) }}" required>
|
||||
@error('identity_number')
|
||||
<small style="color: red;">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Nama Depan <strong class="text-danger">*</strong></label>
|
||||
<input name="first_name" type="text" class="form-control"
|
||||
placeholder="Masukan Nama Depan"
|
||||
value="{{ old('first_name', $patient->first_name) }}" required>
|
||||
@error('first_name')
|
||||
<small style="color: red;">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Nama Belakang <strong class="text-danger">*</strong></label>
|
||||
<input name="last_name" type="text" class="form-control"
|
||||
placeholder="Masukan Nama Belakang"
|
||||
value="{{ old('last_name', $patient->last_name) }}" required>
|
||||
@error('last_name')
|
||||
<small style="color: red;">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Tanggal Lahir <strong class="text-danger">*</strong></label>
|
||||
<input name="birth_date" type="date" class="form-control" placeholder="Tanggal Lahir"
|
||||
value="{{ old('birth_date', $patient->birth_date) }}" required>
|
||||
@error('birth_date')
|
||||
<small style="color: red;">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Jenis Kelamin <strong class="text-danger">*</strong></label>
|
||||
<select name="gender" class="form-control">
|
||||
<option value="">-- Pilih --</option>
|
||||
<option value="L"
|
||||
{{ old('gender', $patient->gender) == 'L' ? 'selected' : '' }}>Laki-Laki
|
||||
</option>
|
||||
<option value="P"
|
||||
{{ old('gender', $patient->gender) == 'P' ? 'selected' : '' }}>Perempuan
|
||||
</option>
|
||||
</select>
|
||||
@error('gender')
|
||||
<small style="color: red;">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>No. HP <strong class="text-danger">*</strong></label>
|
||||
<input name="phone_number" type="text" class="form-control" placeholder="No. HP"
|
||||
value="{{ old('phone_number', $patient->phone_number) }}" required>
|
||||
@error('phone_number')
|
||||
<small style="color: red;">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Contact Email <strong class="text-danger">*</strong></label>
|
||||
<input name="email" type="email" class="form-control" placeholder="Masukan Email"
|
||||
value="{{ old('email', $patient->email) }}" required>
|
||||
@error('email')
|
||||
<small style="color: red;">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label>Golongan Darah <strong class="text-danger">*</strong></label>
|
||||
<select name="blood_type" class="form-control">
|
||||
<option value="">-- Pilih --</option>
|
||||
<option value="A"
|
||||
{{ old('blood_type', $patient->blood_type) == 'A' ? 'selected' : '' }}>A
|
||||
</option>
|
||||
<option value="B"
|
||||
{{ old('blood_type', $patient->blood_type) == 'B' ? 'selected' : '' }}>B
|
||||
</option>
|
||||
<option value="AB"
|
||||
{{ old('blood_type', $patient->blood_type) == 'AB' ? 'selected' : '' }}>AB
|
||||
</option>
|
||||
<option value="O"
|
||||
{{ old('blood_type', $patient->blood_type) == 'O' ? 'selected' : '' }}>O
|
||||
</option>
|
||||
<option value="Lainnya"
|
||||
{{ old('blood_type', $patient->blood_type) == 'Lainnya' ? 'selected' : '' }}>
|
||||
Lainnya</option>
|
||||
</select>
|
||||
@error('blood_type')
|
||||
<small style="color: red;">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Alamat <strong class="text-danger">*</strong></label>
|
||||
<textarea class="form-control" name="address" cols="20" rows="3" placeholder="Masukan Alamat" required>{{ old('address', $patient->address) }}</textarea>
|
||||
@error('address')
|
||||
<small style="color: red;">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Alergi: <strong class="text-danger">*</strong></label>
|
||||
<textarea class="form-control" name="allergies" cols="20" rows="3"
|
||||
placeholder="Sebutkan alergi jika ada" required>{{ old('allergies', $patient->allergies) }}</textarea>
|
||||
@error('allergies')
|
||||
<small style="color: red;">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Konsumsi Obat Saat Ini: <strong class="text-danger">*</strong></label>
|
||||
<textarea class="form-control" name="current_medicines" cols="20" rows="3"
|
||||
placeholder="Obat yang dikonsumsi saat ini, contoh : bodrex, almodipine" required>{{ old('current_medicines', $patient->current_medicines) }}</textarea>
|
||||
@error('current_medicines')
|
||||
<small style="color: red;">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Histori Medis: <strong class="text-danger">*</strong></label>
|
||||
<textarea class="form-control" name="medical_history" cols="20" rows="3"
|
||||
placeholder="Histori medis pasien" required>{{ old('medical_history', $patient->medical_history) }}</textarea>
|
||||
@error('medical_history')
|
||||
<small style="color: red;">{{ $message }}</small>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<span class="text-muted float-start ml-4">
|
||||
<strong class="text-danger">*</strong> Wajib Diisi
|
||||
</span>
|
||||
<div class="card-footer mt-2">
|
||||
<button type="button" class="btn btn-primary" onclick="history.back()">Kembali</button>
|
||||
<button type="submit" class="btn btn-success">Update</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@push('scripts')
|
||||
@if (session('success'))
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
Toast.fire({
|
||||
icon: 'success',
|
||||
title: "{{ session('success') }}",
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endif
|
||||
@endpush
|
||||
158
resources/views/patient/index.blade.php
Normal file
158
resources/views/patient/index.blade.php
Normal file
@ -0,0 +1,158 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@push('styles')
|
||||
<!-- DataTables -->
|
||||
<link rel="stylesheet" href="{{ asset('plugins/datatables-bs4/css/dataTables.bootstrap4.min.css') }}">
|
||||
<link rel="stylesheet" href="{{ asset('plugins/datatables-responsive/css/responsive.bootstrap4.min.css') }}">
|
||||
<link rel="stylesheet" href="{{ asset('plugins/datatables-buttons/css/buttons.bootstrap4.min.css') }}">
|
||||
@endpush
|
||||
|
||||
@section('content-header')
|
||||
<div class="content-header">
|
||||
<div class="container-fluid">
|
||||
<div class="row mb-2">
|
||||
<div class="col-sm-6">
|
||||
<h1 class="m-0">Manajemen Pasien</h1>
|
||||
</div><!-- /.col -->
|
||||
<div class="col-sm-6">
|
||||
<ol class="breadcrumb float-sm-right">
|
||||
<li class="breadcrumb-item"><a href="#">Home</a></li>
|
||||
<li class="breadcrumb-item active">Manajemen Pasien</li>
|
||||
</ol>
|
||||
</div><!-- /.col -->
|
||||
</div><!-- /.row -->
|
||||
</div><!-- /.container-fluid -->
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('main-content')
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<a href="{{ route('patient-management.create') }}" class="btn btn-info">
|
||||
<i class="fas fa-plus"></i>
|
||||
Tambah Data Pasien
|
||||
</a>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table id="tableData" class="table table-bordered table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>No</th>
|
||||
<th>Rekam Medis</th>
|
||||
<th>Nama Lengkap</th>
|
||||
<th>Dibuat Pada</th>
|
||||
<th>Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($patients as $index => $data)
|
||||
<tr>
|
||||
<td>{{ $index + 1 }}</td>
|
||||
<td>{{ $data->medical_record_number }}</td>
|
||||
<td>{{ $data->first_name }} {{ $data->last_name }}</td>
|
||||
<td>{{ $data->created_at }}</td>
|
||||
<td>
|
||||
<a href="{{ route('patient-management.show', $data->id) }}" class="btn btn-sm btn-info">
|
||||
<i class="fas fa-search"></i> Lihat
|
||||
</a>
|
||||
|
||||
<a href="{{ route('patient-management.edit', $data->id) }}" class="btn btn-sm btn-warning">
|
||||
<i class="fas fa-pencil-alt"></i> Edit
|
||||
</a>
|
||||
|
||||
<button type="button" class="btn btn-sm btn-danger delete-btn"
|
||||
data-url="{{ route('patient-management.destroy', $data->id) }}">
|
||||
<i class="fas fa-trash"></i> Hapus
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- /.card-body -->
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Delete Confirmation Modal -->
|
||||
<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="deleteModalLabel">Konfirmasi Hapus</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
Apakah Anda yakin ingin menghapus data ini?
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Batal</button>
|
||||
<form id="deleteForm" action="" method="POST">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit" class="btn btn-danger">Hapus</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
@if (session('success'))
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
Toast.fire({
|
||||
icon: 'success',
|
||||
title: "{{ session('success') }}",
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endif
|
||||
@if (session('error'))
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
Toast.fire({
|
||||
icon: 'error',
|
||||
title: "{{ session('error') }}",
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endif
|
||||
|
||||
<script src="{{ asset('plugins/datatables/jquery.dataTables.min.js') }}"></script>
|
||||
<script src="{{ asset('plugins/datatables-bs4/js/dataTables.bootstrap4.min.js') }}"></script>
|
||||
<script src="{{ asset('plugins/datatables-responsive/js/dataTables.responsive.min.js') }}"></script>
|
||||
<script src="{{ asset('plugins/datatables-responsive/js/responsive.bootstrap4.min.js') }}"></script>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$("#tableData").DataTable({
|
||||
"paging": true,
|
||||
"lengthChange": false,
|
||||
"searching": true,
|
||||
"ordering": true,
|
||||
"info": true,
|
||||
"autoWidth": false,
|
||||
"responsive": true,
|
||||
});
|
||||
});
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
const deleteButtons = document.querySelectorAll('.delete-btn');
|
||||
const deleteModal = document.getElementById('deleteModal');
|
||||
const deleteForm = document.getElementById('deleteForm');
|
||||
|
||||
deleteButtons.forEach(button => {
|
||||
button.addEventListener('click', function() {
|
||||
const url = this.getAttribute('data-url');
|
||||
deleteForm.setAttribute('action', url);
|
||||
$(deleteModal).modal('show'); // Use jQuery to show the modal
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
53
resources/views/patient/show.blade.php
Normal file
53
resources/views/patient/show.blade.php
Normal file
@ -0,0 +1,53 @@
|
||||
@extends('layouts.app')
|
||||
@section('content-header')
|
||||
<div class="content-header">
|
||||
<div class="container-fluid">
|
||||
<div class="row mb-2">
|
||||
<div class="col-sm-6">
|
||||
<h1 class="m-0">Detail Pasien</h1>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<ol class="breadcrumb float-sm-right">
|
||||
<li class="breadcrumb-item"><a href="#">Home</a></li>
|
||||
<li class="breadcrumb-item active">Detail Pasien</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@section('main-content')
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card card-primary">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Data Pasien</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<p><strong>No. Rekam Medis:</strong> {{ $patient->medical_record_number }}</p>
|
||||
<p><strong>NIK:</strong> {{ $patient->identity_number }}</p>
|
||||
<p><strong>Nama Depan:</strong> {{ $patient->first_name }}</p>
|
||||
<p><strong>Nama Belakang:</strong> {{ $patient->last_name }}</p>
|
||||
<p><strong>Tanggal Lahir:</strong> {{ $patient->birth_date }}</p>
|
||||
<p><strong>Jenis Kelamin:</strong> {{ $patient->gender == 'L' ? 'Laki-Laki' : 'Perempuan' }}</p>
|
||||
<p><strong>No. HP:</strong> {{ $patient->phone_number }}</p>
|
||||
<p><strong>Email:</strong> {{ $patient->email }}</p>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<p><strong>Golongan Darah:</strong> {{ $patient->blood_type }}</p>
|
||||
<p><strong>Alamat:</strong> {{ $patient->address }}</p>
|
||||
<p><strong>Alergi:</strong> {{ $patient->allergies }}</p>
|
||||
<p><strong>Konsumsi Obat Saat Ini:</strong> {{ $patient->current_medicines }}</p>
|
||||
<p><strong>Histori Medis:</strong> {{ $patient->medical_history }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<button type="button" class="btn btn-primary" onclick="history.back()">Kembali</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@ -5,6 +5,7 @@ use App\Http\Controllers\DashboardController;
|
||||
use App\Http\Controllers\ManageUserController;
|
||||
use App\Http\Controllers\ProfileController;
|
||||
use App\Http\Controllers\InsuranceController;
|
||||
use App\Http\Controllers\PatientController;
|
||||
use App\Http\Controllers\ServiceRoomController;
|
||||
use App\Http\Controllers\TreatmentController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
@ -67,6 +68,15 @@ Route::middleware('auth')->group(function () {
|
||||
Route::delete('/ruang-pelayanan/{id}', [ServiceRoomController::class, 'destroy'])->name('service-room.destroy');
|
||||
});
|
||||
|
||||
# Manage Pasien
|
||||
Route::get('/pasien', [PatientController::class, 'index'])->name('patient-management.index');
|
||||
Route::get('/pasien/tambah', [PatientController::class, 'create'])->name('patient-management.create');
|
||||
Route::post('/pasien', [PatientController::class, 'store'])->name('patient-management.store');
|
||||
Route::get('/pasien/{id}/edit', [PatientController::class, 'edit'])->name('patient-management.edit');
|
||||
Route::put('/pasien/{id}', [PatientController::class, 'update'])->name('patient-management.update');
|
||||
Route::delete('/pasien/{id}', [PatientController::class, 'destroy'])->name('patient-management.destroy');
|
||||
Route::get('/pasien/{id}', [PatientController::class, 'show'])->name('patient-management.show');
|
||||
|
||||
// Profile Page
|
||||
Route::get('/profil-akun', [ProfileController::class, 'edit'])->name('profile.edit');
|
||||
Route::put('/profil-akun', [ProfileController::class, 'update'])->name('profile.update');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user