@@ -3,6 +3,8 @@ const AppointmentController = require('../controllers/appointment.controller');
33const ClinicalNotesController = require ( '../controllers/clinical-notes.controller' ) ;
44const asyncHandler = require ( '../utils/asyncHandler' ) ;
55const { authenticate, authorize, authorizeAppointmentAccess, authorizePatientAppointments } = require ( '../middleware/auth.middleware' ) ;
6+ const { validateBody } = require ( '../middleware/validation.middleware' ) ;
7+ const { appointmentCreateSchema, appointmentUpdateSchema } = require ( '../validators/appointment.validator' ) ;
68const { clinicalNotesValidator } = require ( '../validators' ) ;
79
810const router = express . Router ( ) ;
@@ -176,7 +178,7 @@ router.get('/doctors/:doctor_id/availability', asyncHandler(AppointmentControlle
176178 * name: status
177179 * schema:
178180 * type: string
179- * enum: [scheduled, confirmed, in-progress, completed, cancelled, no-show]
181+ * enum: [pending, scheduled, confirmed, in-progress, completed, cancelled, no-show]
180182 * description: Filter by appointment status
181183 * - in: query
182184 * name: doctor_id
@@ -196,7 +198,13 @@ router.get('/doctors/:doctor_id/availability', asyncHandler(AppointmentControlle
196198 * schema:
197199 * $ref: '#/components/schemas/PaginatedResponse'
198200 */
199- router . post ( '/' , authenticate , authorize ( 'doctor' , 'admin' , 'staff' , 'patient' ) , asyncHandler ( AppointmentController . createAppointment ) ) ;
201+ router . post (
202+ '/' ,
203+ authenticate ,
204+ authorize ( 'doctor' , 'admin' , 'staff' , 'patient' ) ,
205+ validateBody ( appointmentCreateSchema ) ,
206+ asyncHandler ( AppointmentController . createAppointment )
207+ ) ;
200208/**
201209 * @swagger
202210 * /appointments/check-availability:
@@ -280,7 +288,7 @@ router.post('/check-availability', authenticate, asyncHandler(AppointmentControl
280288 * name: status
281289 * schema:
282290 * type: string
283- * enum: [scheduled, confirmed, in-progress, completed, cancelled, no-show]
291+ * enum: [pending, scheduled, confirmed, in-progress, completed, cancelled, no-show]
284292 * responses:
285293 * 200:
286294 * description: Patient appointments retrieved successfully
@@ -322,7 +330,7 @@ router.get('/me', authenticate, authorize('patient'), asyncHandler(AppointmentCo
322330 * name: status
323331 * schema:
324332 * type: string
325- * enum: [scheduled, confirmed, in-progress, completed, cancelled, no-show]
333+ * enum: [pending, scheduled, confirmed, in-progress, completed, cancelled, no-show]
326334 * responses:
327335 * 200:
328336 * description: Appointments retrieved successfully
@@ -431,7 +439,7 @@ router.get('/', authenticate, authorize('doctor', 'admin', 'staff'), asyncHandle
431439 * example: "14:00"
432440 * status:
433441 * type: string
434- * enum: [scheduled, confirmed, in-progress, completed, cancelled, no-show]
442+ * enum: [pending, scheduled, confirmed, in-progress, completed, cancelled, no-show]
435443 * location:
436444 * type: string
437445 * reason_for_visit:
@@ -467,7 +475,13 @@ router.get('/', authenticate, authorize('doctor', 'admin', 'staff'), asyncHandle
467475 * description: Appointment not found
468476 */
469477router . get ( '/:id' , authenticate , authorizeAppointmentAccess , asyncHandler ( AppointmentController . getAppointmentById ) ) ;
470- router . put ( '/:id' , authenticate , authorizeAppointmentAccess , asyncHandler ( AppointmentController . updateAppointment ) ) ;
478+ router . put (
479+ '/:id' ,
480+ authenticate ,
481+ authorizeAppointmentAccess ,
482+ validateBody ( appointmentUpdateSchema ) ,
483+ asyncHandler ( AppointmentController . updateAppointment )
484+ ) ;
471485/**
472486 * @swagger
473487 * /appointments/{id}/reschedule:
@@ -546,7 +560,7 @@ router.use(
546560 * name: status
547561 * schema:
548562 * type: string
549- * enum: [scheduled, confirmed, in-progress, completed, cancelled, no-show]
563+ * enum: [pending, scheduled, confirmed, in-progress, completed, cancelled, no-show]
550564 * responses:
551565 * 200:
552566 * description: Nested appointments retrieved successfully
@@ -614,7 +628,7 @@ patientAppointmentsRouter.get('/', asyncHandler(AppointmentController.getPatient
614628 * type: string
615629 * status:
616630 * type: string
617- * enum: [scheduled, confirmed, in-progress, completed, cancelled, no-show]
631+ * enum: [pending, scheduled, confirmed, in-progress, completed, cancelled, no-show]
618632 * location:
619633 * type: string
620634 * reason_for_visit:
@@ -654,6 +668,7 @@ patientAppointmentsRouter.put(
654668 '/:appointment_id' ,
655669 mapNestedAppointmentId ,
656670 authorizeAppointmentAccess ,
671+ validateBody ( appointmentUpdateSchema ) ,
657672 asyncHandler ( AppointmentController . updateAppointment )
658673) ;
659674
0 commit comments