const express = require("express");
const router = express.Router();

const { requireLogin, requireAdmin } = require("../middleware/auth.middleware");

const {
  listPatients,
  showCreatePatient,
  createPatient,
  showEditPatient,
  updatePatient,
  showPatientMedications,
  moveToWaitingRoom,
  showPatientOverview,
  addPatientNote,
  callFromWaitingRoom,
  dischargePatient,
  showMedicationPlan,
  deactivatePatient,
  activatePatient,
  showPatientOverviewDashborad,
  assignMedicationToPatient,
} = require("../controllers/patient.controller");

router.get("/", requireLogin, listPatients);
router.get("/create", requireLogin, showCreatePatient);
router.post("/create", requireLogin, createPatient);
router.get("/edit/:id", requireLogin, showEditPatient);
router.post("/edit/:id", requireLogin, updatePatient);
router.get("/:id/medications", requireLogin, showPatientMedications);
router.post("/waiting-room/:id", requireLogin, moveToWaitingRoom);
router.get("/:id/overview", requireLogin, showPatientOverview);
router.post("/:id/notes", requireLogin, addPatientNote);
router.post("/waiting-room/call/:id", requireAdmin, callFromWaitingRoom);
router.post("/:id/discharge", requireLogin, dischargePatient);
router.get("/:id/plan", requireLogin, showMedicationPlan);
router.post("/deactivate/:id", requireLogin, deactivatePatient);
router.post("/activate/:id", requireLogin, activatePatient);
router.get("/:id", requireLogin, showPatientOverviewDashborad);
router.post("/:id/medications/assign", requireLogin, assignMedicationToPatient);

module.exports = router;
