-
Notifications
You must be signed in to change notification settings - Fork 607
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: Bugs in Public Patient Registration Form #10462
Fix: Bugs in Public Patient Registration Form #10462
Conversation
WalkthroughThe pull request updates the Patient Registration form by modifying the gender field’s validation and form initialization. A new constant for gender enumeration is introduced and applied in the validation schema. The form’s default values are refactored to exclude the gender field, and error handling for the patient creation mutation is simplified to a generic toast message. Additionally, the pincode field label is updated to show it as required. Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant PR as PatientRegistration Component
participant V as Zod Validator
participant CP as createPatient Mutation
participant T as Toast Notification
U->>PR: Submit registration form
PR->>V: Validate form data (gender, pincode, etc.)
V-->>PR: Return validation result
alt Validation succeeds
PR->>CP: Trigger createPatient mutation
CP-->>PR: Return success or error
alt Error received
PR->>T: Display generic toast error
end
else Validation fails
PR->>T: Display error messages
end
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Tip 🌐 Web search-backed reviews and chat
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/PublicAppointments/PatientRegistration.tsx (1)
43-56
: Remove commented out code.The commented out
initialForm
object is no longer used and should be removed to maintain code cleanliness.-// const initialForm: Omit<AppointmentPatientRegister, "gender"> & { -// ageInputType: "age" | "date_of_birth"; -// gender: "male" | "female" | "transgender" | "non_binary"; -// } = { -// name: "", -// gender: "male", -// ageInputType: "date_of_birth", -// year_of_birth: undefined, -// date_of_birth: undefined, -// phone_number: "", -// address: "", -// pincode: "", -// geo_organization: undefined, -// };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/pages/PublicAppointments/PatientRegistration.tsx
(5 hunks)
🧰 Additional context used
📓 Learnings (1)
src/pages/PublicAppointments/PatientRegistration.tsx (1)
Learnt from: Jacobjeevan
PR: ohcnetwork/care_fe#10260
File: src/components/Patient/PatientRegistration.tsx:286-289
Timestamp: 2025-01-28T15:50:07.442Z
Learning: For patient registration in the frontend, either year_of_birth or date_of_birth is required for successful registration. If date_of_birth is not available, year_of_birth must be present.
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: cypress-run (1)
🔇 Additional comments (3)
src/pages/PublicAppointments/PatientRegistration.tsx (3)
85-85
: LGTM! Gender validation is properly enforced.The validation schema now uses a type-safe enum validation for gender, ensuring only valid gender values are accepted.
392-392
: LGTM! Pincode field is properly marked as required.The pincode field label is correctly marked as required, matching its validation schema.
26-26
: Verify GENDERS constant usage.The code imports both
GENDERS
andGENDER_TYPES
. WhileGENDER_TYPES
is used in the radio group rendering,GENDERS
is only used in the validation schema. This might indicate inconsistent gender type definitions.✅ Verification successful
🏁 Script executed:
#!/bin/bash # Description: Check for consistency between GENDERS and GENDER_TYPES constants # Search for GENDERS and GENDER_TYPES definitions rg -A 5 'const (GENDERS|GENDER_TYPES)' src/common/constants.tsLength of output: 128
I'll generate a new shell script to search the entire repository for the definitions of both constants, so that we can locate them and assess their consistency.
🏁 Script executed:
#!/bin/bash echo "Searching for definition of 'GENDERS' in repository..." rg -l "const GENDERS" . echo "Searching for definition of 'GENDER_TYPES' in repository..." rg -l "const GENDER_TYPES" .Length of output: 370
I'll generate a new shell script to retrieve the definitions of both constants from the file so we can inspect their structure and ensure their consistency.
🏁 Script executed:
#!/bin/bash echo "Definition of GENDERS:" rg -A 10 "const GENDERS" src/common/constants.tsx echo "Definition of GENDER_TYPES:" rg -A 10 "const GENDER_TYPES" src/common/constants.tsxLength of output: 1145
GENDERS and GENDER_TYPES definitions are consistent.
The constant GENDERS is derived using a map on GENDER_TYPES, ensuring that both the validation schema and the radio group render consistent gender ids. No inconsistency was found.
LGTM |
@AdityaJ2305 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