-
Notifications
You must be signed in to change notification settings - Fork 470
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: Resolve creation of patient name despite having numeric values #9152
Conversation
WalkthroughThe changes in the Changes
Assessment against linked issues
Poem
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: 0
🧹 Outside diff range and nitpick comments (1)
src/components/Patient/PatientRegister.tsx (1)
Line range hint
1023-1029
: Consider enhancing the name field UX.While the validation is working correctly, consider these improvements for better user experience:
- Add a placeholder to guide users about the expected format
- Add a pattern attribute to prevent special characters at input time
<TextFormField required {...field("name")} type="text" label={"Name"} + placeholder="Enter patient's name (letters only)" + pattern="[A-Za-z\s]+" />
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
src/components/Patient/PatientRegister.tsx
(2 hunks)
🔇 Additional comments (3)
src/components/Patient/PatientRegister.tsx (3)
70-70
: LGTM: Import changes are correct.
The validateName
import is properly added and follows the project's import conventions.
424-427
: LGTM: Name validation is properly implemented.
The validation logic:
- Is correctly placed in the form validation switch statement
- Returns an appropriate error message
- Integrates well with the existing form validation system
70-70
: Verify: Changes successfully address the PR objective.
The implementation effectively prevents the creation of patient names with numeric values through:
- Addition of name validation
- Clear error messaging
- Integration with form validation
This matches the requirements from issue #9143.
Also applies to: 424-427
✅ Verification successful
Changes successfully prevent numeric values in patient names
The implementation effectively addresses the PR objective through:
- The
validateName
function uses the regex pattern/^([a-zA-Z]*( [a-zA-Z])?)+$/
which only allows alphabetic characters and spaces - The validation is properly integrated into the form validation logic
- The function is imported and used in the patient registration form
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the validateName function implementation
# Check the validation function implementation
echo "Checking validation function..."
ast-grep --pattern 'export function validateName($_) {
$$$
}'
# Check for any other direct numeric validation in the codebase
echo "Checking for other numeric validation patterns..."
rg 'function.*validateName|name.*validation|numeric.*validation' --type ts
Length of output: 324
Script:
#!/bin/bash
# Let's try a different approach to locate the validation implementation
# Search for validateName in common/validation files
echo "Searching for validateName in validation files..."
fd "validation" --type f --exec cat {}
# Search for name validation usage in PatientRegister
echo "Checking PatientRegister implementation..."
fd "PatientRegister" --type f --exec cat {}
# Look for validation-related imports
echo "Checking validation imports..."
rg "import.*validation" --type ts
Length of output: 68341
@Tanuj1718 have we also accounted for characters like underscores, dots and commas ? |
Yes we have checked. We only allow alphabetic characters and spaces in Name. |
LGTM |
@Tanuj1718 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! 🙌 |
@Tanuj1718 #9177 would be reverting this PR due to reason mentioned in #9143 (comment) |
Okay @rithviknishad , it's always interesting to know about the new things. |
Proposed Changes
Patient.mp4
@ohcnetwork/care-fe-code-reviewers
Merge Checklist
Summary by CodeRabbit
New Features
Bug Fixes
Improvements