diff --git a/app/Http/Controllers/PatienRegistrationController.php b/app/Http/Controllers/PatienRegistrationController.php index 48c856c..4dd2f98 100644 --- a/app/Http/Controllers/PatienRegistrationController.php +++ b/app/Http/Controllers/PatienRegistrationController.php @@ -2,9 +2,90 @@ namespace App\Http\Controllers; +use App\Http\Requests\ManageRegistration\StoreNewRegistration; +use App\Http\Requests\ManageRegistration\UpdateRegistration; +use App\Models\Insurance; +use App\Models\PatienRegistration; +use App\Models\Patient; +use App\Models\ServiceRoom; use Illuminate\Http\Request; class PatienRegistrationController extends Controller { - // + public function index() + { + $registrations = PatienRegistration::with(['user', 'patient', 'insurance', 'service_room'])->get(); + return view('registration.index', compact('registrations')); + } + + public function create() + { + $patients = Patient::all(); + $insurances = Insurance::all(); + $serviceRooms = ServiceRoom::all(); + return view('registration.add', compact('patients', 'insurances', 'serviceRooms')); + } + + public function store(StoreNewRegistration $request) + { + $validatedData = $request->validated(); + $data = [ + 'registration_date' => $validatedData['registration_date'], + 'patient_id' => $validatedData['patient_id'], + 'insurance_id' => $validatedData['insurance_id'], + 'insurance_number' => $validatedData['insurance_number'], + 'service_room_id' => $validatedData['service_room_id'], + 'responsible_person_name' => $validatedData['responsible_person_name'], + 'responsible_person_phone' => $validatedData['responsible_person_phone'], + 'responsible_email' => $validatedData['responsible_email'], + 'responsible_person_relationship' => $validatedData['responsible_person_relationship'], + 'responsible_person_address' => $validatedData['responsible_person_address'], + 'user_id' => auth()->id(), + ]; + + PatienRegistration::create($data); + + + return redirect()->route('patient-registration.index')->with('success', 'Pendaftaran pasien berhasil.'); + } + + public function edit($id) + { + $registration = PatienRegistration::findOrFail($id); + $patients = Patient::all(); + $insurances = Insurance::all(); + $serviceRooms = ServiceRoom::all(); + + return view('registration.edit', compact('registration', 'patients', 'insurances', 'serviceRooms')); + } + + public function update(UpdateRegistration $request, $id) + { + $registration = PatienRegistration::findOrFail($id); + $validatedData = $request->validated(); + $data = [ + 'registration_date' => $validatedData['registration_date'], + 'patient_id' => $validatedData['patient_id'], + 'insurance_id' => $validatedData['insurance_id'], + 'insurance_number' => $validatedData['insurance_number'], + 'service_room_id' => $validatedData['service_room_id'], + 'responsible_person_name' => $validatedData['responsible_person_name'], + 'responsible_person_phone' => $validatedData['responsible_person_phone'], + 'responsible_email' => $validatedData['responsible_email'], + 'responsible_person_relationship' => $validatedData['responsible_person_relationship'], + 'responsible_person_address' => $validatedData['responsible_person_address'], + 'user_id' => auth()->id(), + ]; + + $registration->update($data); + + return redirect()->route('patient-registration.index')->with('success', 'Pendaftaran pasien berhasil diperbarui.'); + } + public function destroy($id) + { + $registration = PatienRegistration::findOrFail($id); + $registration->delete(); + + return redirect()->route('patient-registration.index')->with('success', 'Pendaftaran pasien berhasil dihapus.'); + } } diff --git a/app/Http/Requests/ManageRegistration/StoreNewRegistration.php b/app/Http/Requests/ManageRegistration/StoreNewRegistration.php new file mode 100644 index 0000000..00a5964 --- /dev/null +++ b/app/Http/Requests/ManageRegistration/StoreNewRegistration.php @@ -0,0 +1,75 @@ +|string> + */ + public function rules(): array + { + return [ + 'registration_date' => ['required', 'date'], + 'patient_id' => ['required', 'exists:patients,id'], + 'insurance_id' => ['required', 'exists:insurances,id'], + 'insurance_number' => ['required', 'numeric'], + 'service_room_id' => ['required', 'exists:service_rooms,id'], + 'responsible_person_name' => ['required', 'string', 'max:255'], + 'responsible_person_phone' => ['required', 'string', 'max:15'], + 'responsible_email' => ['required', 'email', 'max:255'], + 'responsible_person_relationship' => ['required', 'string', 'max:100'], + 'responsible_person_address' => ['required', 'string', 'max:500'], + ]; + } + + /** + * Get custom error messages for validation rules. + * + * @return array + */ + public function messages(): array + { + return [ + 'registration_date.required' => 'Tanggal registrasi wajib diisi.', + 'registration_date.date' => 'Tanggal registrasi harus berupa tanggal yang valid.', + 'patient_id.required' => 'Pasien wajib dipilih.', + 'patient_id.exists' => 'Pasien yang dipilih tidak valid.', + 'insurance_id.required' => 'Asuransi wajib dipilih.', + 'insurance_id.exists' => 'Asuransi yang dipilih tidak valid.', + 'insurance_number.required' => 'Nomor asuransi wajib diisi.', + 'insurance_number.string' => 'Nomor asuransi harus berupa teks.', + 'insurance_number.max' => 'Nomor asuransi tidak boleh lebih dari 20 karakter.', + 'service_room_id.required' => 'Ruangan layanan wajib dipilih.', + 'service_room_id.exists' => 'Ruangan layanan yang dipilih tidak valid.', + 'responsible_person_name.required' => 'Nama penanggung jawab wajib diisi.', + 'responsible_person_name.string' => 'Nama penanggung jawab harus berupa teks.', + 'responsible_person_name.max' => 'Nama penanggung jawab tidak boleh lebih dari 255 karakter.', + 'responsible_person_phone.required' => 'Nomor HP penanggung jawab wajib diisi.', + 'responsible_person_phone.string' => 'Nomor HP penanggung jawab harus berupa teks.', + 'responsible_person_phone.max' => 'Nomor HP penanggung jawab tidak boleh lebih dari 15 karakter.', + 'responsible_email.required' => 'Email penanggung jawab wajib diisi.', + 'responsible_email.email' => 'Email penanggung jawab harus berupa alamat email yang valid.', + 'responsible_email.max' => 'Email penanggung jawab tidak boleh lebih dari 255 karakter.', + 'responsible_person_relationship.required' => 'Hubungan dengan pasien wajib diisi.', + 'responsible_person_relationship.string' => 'Hubungan dengan pasien harus berupa teks.', + 'responsible_person_relationship.max' => 'Hubungan dengan pasien tidak boleh lebih dari 100 karakter.', + 'responsible_person_address.required' => 'Alamat penanggung jawab wajib diisi.', + 'responsible_person_address.string' => 'Alamat penanggung jawab harus berupa teks.', + 'responsible_person_address.max' => 'Alamat penanggung jawab tidak boleh lebih dari 500 karakter.', + ]; + } +} diff --git a/app/Http/Requests/ManageRegistration/UpdateRegistration.php b/app/Http/Requests/ManageRegistration/UpdateRegistration.php new file mode 100644 index 0000000..4e2b760 --- /dev/null +++ b/app/Http/Requests/ManageRegistration/UpdateRegistration.php @@ -0,0 +1,75 @@ +|string> + */ + public function rules(): array + { + return [ + 'registration_date' => ['required', 'date'], + 'patient_id' => ['required', 'exists:patients,id'], + 'insurance_id' => ['required', 'exists:insurances,id'], + 'insurance_number' => ['required', 'numeric'], + 'service_room_id' => ['required', 'exists:service_rooms,id'], + 'responsible_person_name' => ['required', 'string', 'max:255'], + 'responsible_person_phone' => ['required', 'string', 'max:15'], + 'responsible_email' => ['required', 'email', 'max:255'], + 'responsible_person_relationship' => ['required', 'string', 'max:100'], + 'responsible_person_address' => ['required', 'string', 'max:500'], + ]; + } + + /** + * Get custom error messages for validation rules. + * + * @return array + */ + public function messages(): array + { + return [ + 'registration_date.required' => 'Tanggal registrasi wajib diisi.', + 'registration_date.date' => 'Tanggal registrasi harus berupa tanggal yang valid.', + 'patient_id.required' => 'Pasien wajib dipilih.', + 'patient_id.exists' => 'Pasien yang dipilih tidak valid.', + 'insurance_id.required' => 'Asuransi wajib dipilih.', + 'insurance_id.exists' => 'Asuransi yang dipilih tidak valid.', + 'insurance_number.required' => 'Nomor asuransi wajib diisi.', + 'insurance_number.string' => 'Nomor asuransi harus berupa teks.', + 'insurance_number.max' => 'Nomor asuransi tidak boleh lebih dari 20 karakter.', + 'service_room_id.required' => 'Ruangan layanan wajib dipilih.', + 'service_room_id.exists' => 'Ruangan layanan yang dipilih tidak valid.', + 'responsible_person_name.required' => 'Nama penanggung jawab wajib diisi.', + 'responsible_person_name.string' => 'Nama penanggung jawab harus berupa teks.', + 'responsible_person_name.max' => 'Nama penanggung jawab tidak boleh lebih dari 255 karakter.', + 'responsible_person_phone.required' => 'Nomor HP penanggung jawab wajib diisi.', + 'responsible_person_phone.string' => 'Nomor HP penanggung jawab harus berupa teks.', + 'responsible_person_phone.max' => 'Nomor HP penanggung jawab tidak boleh lebih dari 15 karakter.', + 'responsible_email.required' => 'Email penanggung jawab wajib diisi.', + 'responsible_email.email' => 'Email penanggung jawab harus berupa alamat email yang valid.', + 'responsible_email.max' => 'Email penanggung jawab tidak boleh lebih dari 255 karakter.', + 'responsible_person_relationship.required' => 'Hubungan dengan pasien wajib diisi.', + 'responsible_person_relationship.string' => 'Hubungan dengan pasien harus berupa teks.', + 'responsible_person_relationship.max' => 'Hubungan dengan pasien tidak boleh lebih dari 100 karakter.', + 'responsible_person_address.required' => 'Alamat penanggung jawab wajib diisi.', + 'responsible_person_address.string' => 'Alamat penanggung jawab harus berupa teks.', + 'responsible_person_address.max' => 'Alamat penanggung jawab tidak boleh lebih dari 500 karakter.', + ]; + } +} diff --git a/app/Models/PatienRegistration.php b/app/Models/PatienRegistration.php index 99de599..121301a 100644 --- a/app/Models/PatienRegistration.php +++ b/app/Models/PatienRegistration.php @@ -9,4 +9,27 @@ use Illuminate\Database\Eloquent\SoftDeletes; class PatienRegistration extends Model { use HasFactory, SoftDeletes; + + protected $table = 'patien_registrations'; + protected $guarded = ["id"]; + + public function user() + { + return $this->belongsTo(User::class, 'user_id'); + } + + public function patient() + { + return $this->belongsTo(Patient::class, 'patient_id'); + } + + public function insurance() + { + return $this->belongsTo(insurance::class, 'insurance_id'); + } + + public function service_room() + { + return $this->belongsTo(ServiceRoom::class, 'service_room_id'); + } } diff --git a/resources/views/registration/add.blade.php b/resources/views/registration/add.blade.php new file mode 100644 index 0000000..e034134 --- /dev/null +++ b/resources/views/registration/add.blade.php @@ -0,0 +1,167 @@ +@extends('layouts.app') +@push('styles') + {{-- Select2 JS --}} + + +@endpush +@section('content-header') +
+
+
+
+

Tambah Registrasi Pasien

+
+
+ +
+
+
+
+@endsection +@section('main-content') +
+
+
+
+

Form Registrasi Pasien

+
+
+ @csrf +
+
+ +
+
+ + + @error('registration_date') + {{ $message }} + @enderror +
+
+ + + @error('patient_id') + {{ $message }} + @enderror +
+
+ + + @error('insurance_id') + {{ $message }} + @enderror +
+
+ + + @error('insurance_number') + {{ $message }} + @enderror +
+
+ + + @error('service_room_id') + {{ $message }} + @enderror +
+
+ +
+
+ + + @error('responsible_person_name') + {{ $message }} + @enderror +
+
+ + + @error('responsible_person_phone') + {{ $message }} + @enderror +
+
+ + + @error('responsible_email') + {{ $message }} + @enderror +
+
+ + + @error('responsible_person_relationship') + {{ $message }} + @enderror +
+
+ + + @error('responsible_person_address') + {{ $message }} + @enderror +
+
+
+
+ +
+
+
+
+@endsection +@push('scripts') + + +@endpush diff --git a/resources/views/registration/edit.blade.php b/resources/views/registration/edit.blade.php new file mode 100644 index 0000000..f298745 --- /dev/null +++ b/resources/views/registration/edit.blade.php @@ -0,0 +1,170 @@ +@extends('layouts.app') +@push('styles') + + +@endpush +@section('content-header') +
+
+
+
+

Edit Registrasi Pasien

+
+
+ +
+
+
+
+@endsection +@section('main-content') +
+
+
+
+

Form Edit Registrasi Pasien

+
+
+ @csrf + @method('PUT') +
+
+ +
+
+ + + @error('registration_date') + {{ $message }} + @enderror +
+
+ + + @error('patient_id') + {{ $message }} + @enderror +
+
+ + + @error('insurance_id') + {{ $message }} + @enderror +
+
+ + + @error('insurance_number') + {{ $message }} + @enderror +
+
+ + + @error('service_room_id') + {{ $message }} + @enderror +
+
+ +
+
+ + + @error('responsible_person_name') + {{ $message }} + @enderror +
+
+ + + @error('responsible_person_phone') + {{ $message }} + @enderror +
+
+ + + @error('responsible_email') + {{ $message }} + @enderror +
+
+ + + @error('responsible_person_relationship') + {{ $message }} + @enderror +
+
+ + + @error('responsible_person_address') + {{ $message }} + @enderror +
+
+
+
+ +
+
+
+
+@endsection +@push('scripts') + + +@endpush diff --git a/resources/views/registration/index.blade.php b/resources/views/registration/index.blade.php new file mode 100644 index 0000000..ba91af3 --- /dev/null +++ b/resources/views/registration/index.blade.php @@ -0,0 +1,159 @@ +@extends('layouts.app') + +@push('styles') + + + + +@endpush + +@section('content-header') +
+
+
+
+

Registrasi Pasien

+
+
+ +
+
+
+
+@endsection + +@section('main-content') +
+ +
+ + + + + + + + + + + + + + @foreach ($registrations as $index => $data) + + + + + + + + + + @endforeach + +
NoRekam MedisNama LengkapJaminan KesehatanDibuat OlehDibuat PadaAksi
{{ $index + 1 }}{{ $data->patient->medical_record_number }}{{ $data->patient->first_name }} {{ $data->patient->last_name }}{{ $data->insurance->name }}{{ $data->user->name }}{{ $data->created_at }} + +   Edit + + + +
+
+ +
+ + + + +@endsection + +@push('scripts') + @if (session('success')) + + @endif + @if (session('error')) + + @endif + + + + + + + +@endpush diff --git a/routes/web.php b/routes/web.php index a49dd69..b739de3 100644 --- a/routes/web.php +++ b/routes/web.php @@ -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\PatienRegistrationController; use App\Http\Controllers\PatientController; use App\Http\Controllers\ServiceRoomController; use App\Http\Controllers\TreatmentController; @@ -77,6 +78,15 @@ Route::middleware('auth')->group(function () { Route::delete('/pasien/{id}', [PatientController::class, 'destroy'])->name('patient-management.destroy'); Route::get('/pasien/{id}', [PatientController::class, 'show'])->name('patient-management.show'); + # Manage Registrasi Pasien + Route::get('/registrasi-pasien', [PatienRegistrationController::class, 'index'])->name('patient-registration.index'); + Route::get('/registrasi-pasien/tambah', [PatienRegistrationController::class, 'create'])->name('patient-registration.create'); + Route::get('/registrasi-pasien/{id}', [PatienRegistrationController::class, 'show'])->name('patient-registration.show'); + Route::post('/registrasi-pasien', [PatienRegistrationController::class, 'store'])->name('patient-registration.store'); + Route::get('/registrasi-pasien/{id}/edit', [PatienRegistrationController::class, 'edit'])->name('patient-registration.edit'); + Route::put('/registrasi-pasien/{id}', [PatienRegistrationController::class, 'update'])->name('patient-registration.update'); + Route::delete('/registrasi-pasien/{id}', [PatienRegistrationController::class, 'destroy'])->name('patient-registration.destroy'); + // Profile Page Route::get('/profil-akun', [ProfileController::class, 'edit'])->name('profile.edit'); Route::put('/profil-akun', [ProfileController::class, 'update'])->name('profile.update');