-
Notifications
You must be signed in to change notification settings - Fork 538
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
Prefill Searched Phone Number in Patient Creation form #9643
Prefill Searched Phone Number in Patient Creation form #9643
Conversation
WalkthroughThe pull request introduces changes to the patient registration workflow, focusing on improving the handling of phone numbers during patient creation. The modifications span two components: Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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/components/Patient/PatientRegistration.tsx (1)
Line range hint
63-90
: Guard against invalid or empty phone numbers from query params.The effect hook updates the form with the query param. While useful for pre-filling the form, ensure that the incoming phone number meets expected formatting, especially if the user manipulates URL parameters directly. Consider adding lightweight validation to ensure reliability.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/components/Patient/PatientIndex.tsx
(1 hunks)src/components/Patient/PatientRegistration.tsx
(3 hunks)
🔇 Additional comments (1)
src/components/Patient/PatientRegistration.tsx (1)
3-3
: Import fromraviger
is valid.The new import for
useQueryParams
is properly declared, consistent with usage in the component. No issues are identified here.
Co-authored-by: Bodhish Thomas <bodhish@gmail.com>
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 (2)
src/components/Patient/PatientRegistration.tsx (2)
Line range hint
319-332
: Enhance duplicate patient detection UXWhile the duplicate detection logic is solid, consider these UX improvements:
- Add loading indicator while checking for duplicates
- Show more informative error messages
- Add retry mechanism for failed duplicate checks
useEffect(() => { const handler = setTimeout(() => { if (!patientId || patientQuery.data?.phone_number !== form.phone_number) { setSuppressDuplicateWarning(false); } setDebouncedNumber(form.phone_number); + // Show loading state + setIsCheckingDuplicates(true); }, 500); return () => { clearTimeout(handler); }; }, [form.phone_number]);
75-75
: Add visual feedback for pre-filled phone numberWhen the phone number is pre-filled from the URL, provide visual feedback to the user to indicate where the data came from.
phone_number: phone_number || "+91", +// Add a notification or highlight when phone number is pre-filled +useEffect(() => { + if (phone_number) { + Notification.Info({ + msg: t("phone_number_prefilled_from_search"), + }); + } +}, []);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/components/Patient/PatientIndex.tsx
(1 hunks)src/components/Patient/PatientRegistration.tsx
(3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/components/Patient/PatientIndex.tsx
🔇 Additional comments (1)
src/components/Patient/PatientRegistration.tsx (1)
3-3
: LGTM: Clean implementation of phone number pre-filling!The implementation correctly handles the phone number from URL query parameters and provides a sensible default value.
Also applies to: 63-64, 75-75
phone_number: phone_number || "+91", | ||
emergency_phone_number: "+91", | ||
}); |
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
Add phone number format validation
The form pre-fills phone numbers with "+91" prefix but lacks proper validation for:
- Phone number format
- International phone numbers
- Length validation (currently only checks length > 13)
Consider adding proper phone number validation:
const [form, setForm] = useState<Partial<PatientModel>>({
nationality: "India",
phone_number: phone_number || "+91",
emergency_phone_number: "+91",
});
+
+const validatePhoneNumber = (number: string) => {
+ // Add phone number validation logic here
+ const phoneRegex = /^\+\d{1,3}\d{10}$/;
+ return phoneRegex.test(number);
+};
Committable suggestion skipped: line range outside the PR's diff.
Co-authored-by: Rithvik Nishad <rithvikn2001@gmail.com>
@amjithtitus09 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
@ohcnetwork/care-fe-code-reviewers
Merge Checklist
Summary by CodeRabbit
New Features
Improvements