Implement appointment booking features and validation services#20
Merged
Conversation
- Add DoctorScheduleDetailResponse record with schedule fields and static from() factory - Add findByDoctor_IdAndDateAndStartTimeAndEndTime query to DoctorScheduleRepository - Add DoctorScheduleQueryService exposing findDoctorSchedule() and getReferenceById() for cross-domain access without direct repository coupling
- Add Appointment entity extending BaseEntity with LAZY associations to PatientInfo, Account (doctor), and DoctorSchedule - Add AppointmentRepository with queries for patient, doctor, status filters and countAppointmentByDoctorSchedule_Id for Redis slot cold-start sync
…onse - BookAppointmentRequest: doctorId, date, startTime, endTime, reason, patientId with @NotNull/@notblank Jakarta annotations; patientId nullable to support PATIENT role flow where it is resolved from JWT in service validate() - BookAppointmentResponse: record with static from(Appointment, BookAppointmentRequest) factory — takes startTime/endTime from request to avoid triggering lazy proxy load on DoctorSchedule
- Replace non-atomic get/setIfAbsent/increment chain with a single Lua script executed atomically — eliminates race condition window between Redis calls - Cold-start: if key missing, initialize from DB count then increment; skip DB query on hot path when key already exists - Over-limit: decrement and return 0 inside the script atomically - Extract script and RedisScript as static final constants to avoid re-allocation on every request
…validation - validate(): checks date not in past, start time not in past for today, start time before end time; RECEPTIONIST must provide patientId, PATIENT resolves patientId from JWT via PatientQueryService.getPatientIdByAccountId() - doProcess(): verifies schedule isAvailable before slot booking, delegates slot counter to AppointmentSlotService, saves Appointment with PENDING status - PatientQueryService: add getPatientIdByAccountId(UUID accountId) using findByAccount_Id repository query to resolve PatientInfo UUID from Account UUID
- AppointmentController mapped to /appointments - POST / guarded by @PreAuthorize hasAnyRole(PATIENT, RECEPTIONIST) - Accepts @Valid @RequestBody BookAppointmentRequest, returns 201 Created
- Query account by username before calling Keycloak; throw BusinessException with generic message if not found to avoid username enumeration - Throw BusinessException with clear message if account isActive is false, before attempting Keycloak authentication
- JwtContextExtractor: add private constructor to prevent instantiation of utility class with only static methods - GetMedicalRecordDetailService: fix grammar in access denied message - EmployeeQueryService: remove trailing blank line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.