<?php

use Illuminate\Support\Facades\Route;

use App\Http\Controllers\AuthController;

use App\Http\Controllers\PendaftaranController;
use App\Http\Controllers\LaporanController;
use App\Http\Controllers\AntrianController;
use App\Http\Controllers\DataPasienController;
use App\Http\Controllers\PemeriksaanController;
use App\Http\Controllers\RekamMedisController;
use App\Http\Controllers\UserController;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('login', [AuthController::class, 'loginPage'])->name('login');
Route::post('auth', [AuthController::class, 'auth']);

// Pendaftaran Antrian
Route::group([
  'middleware' => 'auth',
  'prefix' => 'pendaftaran'
], function () {
  Route::get('cariPasien', [PendaftaranController::class, 'cariPasien']);
  Route::get('pasienBaru', [PendaftaranController::class, 'pasienBaru']);
  Route::post('pemeriksaan/baru', [PendaftaranController::class, 'storeDataPasien']);


  // pemeriksaan
  Route::get('pemeriksaan/{id}', [PemeriksaanController::class, 'pendaftaranPemeriksaan']);
  Route::post('pemeriksaan/antrian/{id}', [PemeriksaanController::class, 'storePemeriksaan']);
});



Route::group([
  'middleware' => 'auth'
], function () {
  // home
  Route::get('/', [PendaftaranController::class, 'index'])->name('home');

  // antrian pemeriksaan
  Route::get('antrian', [PemeriksaanController::class, 'daftarAntrianPemeriksaan']);
  Route::get('antrian/data', [PemeriksaanController::class, 'data']);
  Route::delete('antrianDelete/{pemeriksaan}', [PemeriksaanController::class, 'deleteAntrian']);

  // Penanganan Pasien
  Route::get('penangananPasien/{id}', [RekamMedisController::class, 'pencatatanRekamMedis']);
  Route::put('dataPenangananPasien/{pemeriksaan}', [RekamMedisController::class, 'storeRekamMedis']);


  // Data Pasien
  Route::resource('data_pasien', DataPasienController::class);
  Route::get('showAnamnesa/{id}', [DataPasienController::class, 'showAnamnesa']);
  Route::put('updateAnamnesa/{id}', [DataPasienController::class, 'updateAnamnesa']);
  Route::delete('anamnesa/delete/{id}', [DataPasienController::class, 'deleteAnamnesa']);
  Route::get('pasien/data', [DataPasienController::class, 'data']);

  // Laporan
  Route::get('laporan', [LaporanController::class, 'index']);
  Route::post('laporan', [LaporanController::class, 'index']);

  // Daftar Pengguna
  Route::apiResource('user', UserController::class);

  Route::get('logout', [AuthController::class, 'logout'])->name('logout');
});
