getRatingAppointmentInfo
getRatingAppointmentInfo
This method retrieves detailed appointment and agent information based on an encrypted token and verifies if the appointment is eligible for rating.
-
Decrypt Token
- Decrypt the input
tokenusing AES with a secret key. - Extract
bookingIdandappointmentIdfrom the decrypted payload. - If either
bookingIdorappointmentIdis missing, throw a BadRequestException indicating an invalid token.
- Decrypt the input
-
Determine Appointment Type
- Check if
bookingIdstarts with'BKD'to identify if the appointment is internal. - Internal appointments will be queried from
appointmentstable. - External appointments use
appointments_ehrtable.
- Check if
-
Fetch Completed Appointment
-
Query the appropriate repository (
appointmentRepoorappointmentEhrRepo) for the appointment using:appointmentId- Booking ID field name depending on internal/external type (
bookingIdoremrAppointmentId)
-
Use the helper method
fetchCompletedAppointmentwith the appropriate parameters. -
If no appointment is found, throw a NotFoundException.
-
-
Check Rating Status
-
Query the
ratingNotificationRepofor notifications linked to this appointment with status either:RATEDCANCELLED
-
If any such notifications exist:
- If any have status
RATED, throw a BadRequestException indicating the appointment has already been reviewed. - Otherwise, throw a BadRequestException indicating the appointment can no longer be reviewed.
- If any have status
-
-
Construct and Return Appointment Info
-
Return an object containing:
-
bookingId(from the appointment record, depending on appointment type) -
startDatetime -
customerId -
agentobject with:idname(concatenation of agent type name + first and last names)imageUrl
-
-