Skip to content
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

Merged

Conversation

AdityaJ2305
Copy link
Contributor

@AdityaJ2305 AdityaJ2305 commented Feb 6, 2025

Proposed Changes

@ohcnetwork/care-fe-code-reviewers

Merge Checklist

  • Add specs that demonstrate bug / test a new feature.
  • Update product documentation.
  • Ensure that UI text is kept in I18n files.
  • Prep screenshot or demo video for changelog entry, and attach it to issue.
  • Request for Peer Reviews
  • Completion of QA

Summary by CodeRabbit

  • Refactor
    • Enhanced patient registration validation for gender input, ensuring clearer and more robust data submission.
    • Revised form defaults for improved consistency by shifting from static to dynamic field management.
    • Streamlined error notifications during registration to provide generic alerts.
    • Updated the pincode field to clearly indicate that it is required.

@AdityaJ2305 AdityaJ2305 requested a review from a team as a code owner February 6, 2025 22:53
Copy link
Contributor

coderabbitai bot commented Feb 6, 2025

Walkthrough

The 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

File(s) Change Summary
src/.../PatientRegistration.tsx Updated gender handling: added z.enum(GENDERS) in validation; removed gender from default form values; simplified onError error handling; updated pincode label to indicate a required field.
src/.../constants.ts Added new constant GENDERS for gender enumeration.

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
Loading

Assessment against linked issues

Objective Addressed Explanation
Frontend validation for gender selection (#10459)
Prevent duplicate error notifications (#10459) Simplified error handling avoids duplicate alerts.
Display required asterisk for pincode field (#10459) Pincode field label updated to indicate required.
Use Zod validation error messages for Age field (#10459) No changes were made to the Age field validation.

Possibly related PRs

Suggested labels

needs review, changes required

Suggested reviewers

  • rithviknishad
  • Jacobjeevan

Poem

I'm a rabbit in the code, hopping with delight,
Fixing forms and validations, making everything just right.
Gender enums now guide the way, with fields set on track,
Simplified errors and required pins—no message does double-back.
I nibble on carrots and dance in arrays,
Celebrating clean logic in so many cute ways!
Happy coding from a rabbit, in this whimsical techy bouquet!

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Feb 6, 2025

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 8194a6f
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/67a5bd1dd9252800086d3200
😎 Deploy Preview https://deploy-preview-10462--care-ohc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between e4e67a5 and 844c981.

📒 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 and GENDER_TYPES. While GENDER_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.ts

Length 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.tsx

Length 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.

@rithviknishad rithviknishad added needs testing P1 breaking issue or vital feature labels Feb 7, 2025
@nihal467
Copy link
Member

nihal467 commented Feb 7, 2025

LGTM

@khavinshankar khavinshankar merged commit 226dc5a into ohcnetwork:develop Feb 7, 2025
15 checks passed
Copy link

github-actions bot commented Feb 7, 2025

@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! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 breaking issue or vital feature tested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issues in Public Patient Registration Form
4 participants