-
Notifications
You must be signed in to change notification settings - Fork 540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix appointment slot computation to include end time and improve exception handling logic #10068
Fix appointment slot computation to include end time and improve exception handling logic #10068
Conversation
…ption handling logic
WalkthroughThe pull request modifies the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for care-ohc ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/pages/Scheduling/utils.ts (1)
71-71
: Consider reverting the while loop condition.The change from
time < endTime
totime <= endTime
is unnecessary as the break conditionif (slotEndTime > endTime)
already controls the inclusion of the last slot. The<=
condition doesn't affect the actual slots generated and makes the control flow less clear by suggesting that slots might be created exactly atendTime
.- while (time <= endTime) { + while (time < endTime) {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/pages/Scheduling/utils.ts
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: cypress-run (1)
src/pages/Scheduling/utils.ts
Outdated
(slotStart >= exceptionTime && slotStart < exceptionEndTime) || | ||
(slotEnd > exceptionTime && slotEnd <= exceptionEndTime) || | ||
(slotStart <= exceptionTime && slotEnd >= exceptionEndTime) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider using date-fns's areIntervalsOverlapping
.
While the new overlap conditions correctly handle all scenarios, they could be simplified and made more robust using date-fns's areIntervalsOverlapping
function. This would:
- Handle all overlap cases consistently
- Eliminate potential edge cases with the current mix of
>=
,>
,<
, and<=
operators - Make the code more maintainable and aligned with the library's usage elsewhere
- (slotStart >= exceptionTime && slotStart < exceptionEndTime) ||
- (slotEnd > exceptionTime && slotEnd <= exceptionEndTime) ||
- (slotStart <= exceptionTime && slotEnd >= exceptionEndTime)
+ areIntervalsOverlapping(
+ { start: slotStart, end: slotEnd },
+ { start: exceptionTime, end: exceptionEndTime },
+ { inclusive: true }
+ )
Don't forget to add areIntervalsOverlapping
to the date-fns imports:
import {
addMinutes,
format,
isSameDay,
isWithinInterval,
+ areIntervalsOverlapping,
parse,
} from "date-fns";
Committable suggestion skipped: line range outside the PR's diff.
…tions and ensure accurate slot availability (Backend Logic)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work
@abhimanyurajeesh Your efforts have helped advance digital healthcare and TeleICU systems. 🚀 Thank you for taking the time out to make CARE better. We hope you continue to innovate and contribute; your impact is immense! 🙌 |
Proposed Changes
< endTime
to time<= endTime
to include the end time in the calculation.This should now correctly return all available slots, that might have been missed due to the strict comparison.
@ohcnetwork/care-fe-code-reviewers
Merge Checklist
Summary by CodeRabbit