Class AppointmentController

java.lang.Object
com.example.seraphine.controller.AppointmentController

@RestController @RequestMapping("api/v1/") public class AppointmentController extends Object
The controller for the appointment operations.

Author:
Vinh Truong Canh Thanh, Tri Nguyen Minh, Linh Ngo Phuc
  • Constructor Details

    • AppointmentController

      public AppointmentController()
  • Method Details

    • createAppointment

      @PostMapping("appointment/post") public String createAppointment(@RequestBody Appointment appointment)
      Create an appointment and return a string for creating successfully
      Returns:
      String
    • addAppointmentToDoctor

      @GetMapping("doctor/{doctor_id}/appointment/{appointment_id}/add") public org.springframework.http.ResponseEntity<Void> addAppointmentToDoctor(@PathVariable("doctor_id") Long doctor_id, @PathVariable("appointment_id") Long appointment_id)
      Add a new appointment to doctor list.
      Parameters:
      doctor_id - Long
      appointment_id - Appointment
      Returns:
      an appointment of a doctor
    • bookAppointment

      @GetMapping("user/{user_id}/appointment/{appointment_id}/book") @PreAuthorize("#user_id == authentication.getPrincipal().getId()") public org.springframework.http.ResponseEntity<Void> bookAppointment(@PathVariable("user_id") Long user_id, @PathVariable("appointment_id") Long appointment_id)
      User book an appointment
      Parameters:
      user_id - Long
      appointment_id - Long
      Returns:
      a status for booking successfully
    • showAllAppointments

      @GetMapping("appointment/all") public List<Appointment> showAllAppointments()
      Show all available appointment.
      Returns:
      list of appointment
    • getAppointment

      @GetMapping("user/{user_id}/appointment/{appointment_id}") @PreAuthorize("#user_id == authentication.getPrincipal().getId()") public org.springframework.http.ResponseEntity<Optional<Appointment>> getAppointment(@PathVariable("user_id") Long user_id, @PathVariable("appointment_id") Long appointment_id)
      Get an appointment based on its id.
      Parameters:
      user_id - Long
      appointment_id - Long
      Returns:
      an appointment
    • getAllUserAppointments

      @GetMapping("user/{user_id}/appointment/all") @PreAuthorize("#user_id == authentication.getPrincipal().getId()") public List<Appointment> getAllUserAppointments(@PathVariable("user_id") Long user_id)
      Get all appointment of a specific user based in user id.
      Parameters:
      user_id - Long
      Returns:
      set of appointment for that user
    • getAllDoctorAppointment

      @GetMapping("doctor/{doctor_id}/appointment/all") public List<Appointment> getAllDoctorAppointment(@PathVariable("doctor_id") Long doctor_id)
      Get all appointment of a specific doctor based on doctor id.
      Parameters:
      doctor_id - Long
      Returns:
      list of appointment for that doctor
    • shiftAppointment

      @PutMapping("user/{user_id}/appointment/{appointment_id}/shift") @PreAuthorize("#user_id == authentication.getPrincipal().getId()") public String shiftAppointment(@PathVariable("user_id") Long user_id, @PathVariable("appointment_id") Long appointment_id, @RequestBody Appointment new_appointment)
      Shift an appointment
      Parameters:
      appointment_id - Long
      new_appointment - Appointment
      Returns:
      String
    • cancelAppointment

      @DeleteMapping("user/{user_id}/appointment/{appointment_id}/cancel") @PreAuthorize("#user_id == authentication.getPrincipal().getId()") public org.springframework.http.ResponseEntity<Void> cancelAppointment(@PathVariable("user_id") Long user_id, @PathVariable("appointment_id") Long appointment_id)
      Delete an appointment
      Parameters:
      appointment_id - Long
      Returns:
      status for empty appointment
    • exportAppointment

      @GetMapping("user/{user_id}/appointment/{appointment_id}/generate_pdf") @PreAuthorize("#user_id == authentication.getPrincipal().getId()") public String exportAppointment(@PathVariable("user_id") Long user_id, @PathVariable("appointment_id") Long appointment_id)
      Create pdf and download for an appointment based on id.
      Parameters:
      user_id - Long
      appointment_id - Long
      Returns:
      String
    • remindAppointment

      @GetMapping("user/{user_id}/appointment/{appointment_id}/remind") @PreAuthorize("#user_id == authentication.getPrincipal().getId()") public String remindAppointment(@PathVariable("user_id") Long user_id, @PathVariable("appointment_id") Long appointment_id, @RequestParam String remind_option)
      Remind user for the coming appointment
      Parameters:
      user_id - Long
      appointment_id - Long
      remind_option - String
      Returns:
      String