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

Added translations in encounter page and minor fixes in patient registration form #10264

Merged
merged 12 commits into from
Feb 2, 2025

Conversation

Mahendar0701
Copy link
Contributor

@Mahendar0701 Mahendar0701 commented Jan 28, 2025

Proposed Changes

image

  • Added year of birth for age

image

@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

  • New Features

    • Patient details now offer localized gender labels, enhancing language support.
    • The registration form dynamically calculates and displays the year of birth based on the age input.
  • UI Improvements

    • Improved responsive layout for nationality and related fields to ensure optimal viewing on various screen sizes.

@Mahendar0701 Mahendar0701 requested a review from a team as a code owner January 28, 2025 17:28
Copy link
Contributor

coderabbitai bot commented Jan 28, 2025

Walkthrough

This PR updates two patient-related components. The PatientInfoCard now uses a translation function to display the patient's gender, enabling internationalized text. In PatientRegistration, a new conditional block calculates the year of birth from the input age and displays it below the age field, and the layout for nationality and geo-organization fields is adjusted responsively. No changes were made to the public API.

Changes

File(s) Change Summary
src/.../PatientInfoCard.tsx Replaced direct gender display with a localized version using the t function.
src/.../PatientRegistration.tsx Added conditional rendering to calculate and display year of birth based on age input; modified layout for nationality and geo-organization.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant PR as PatientRegistration
    participant Calc as YearOfBirthCalculator

    U->>PR: Enter age
    PR->>Calc: Compute Year = Current Year - Age
    Calc-->>PR: Return computed year
    PR->>U: Display year of birth in UI
Loading

Assessment against linked issues

Objective Addressed Explanation
Show Year of Birth inside the input field when a user types age (Issue #10233)

Possibly related PRs

Suggested labels

tested, reviewed

Suggested reviewers

  • rithviknishad
  • Jacobjeevan

Poem

I'm a little rabbit hopping through the code,
Translating genders and ages in a tidy mode.
Year of birth now blooms from numbers with flair,
Responsive layouts shining bright everywhere.
Carrots and code, a joyful pair,
Splendid changes made with utmost care!
🥕🐇


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a15998e and b0ae173.

📒 Files selected for processing (2)
  • src/components/Patient/PatientInfoCard.tsx (2 hunks)
  • src/components/Patient/PatientRegistration.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/components/Patient/PatientRegistration.tsx
  • src/components/Patient/PatientInfoCard.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: cypress-run (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?

❤️ 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 Jan 28, 2025

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 7bdb76c
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/679f1262d064aa000883e23f
😎 Deploy Preview https://deploy-preview-10264--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.

@Mahendar0701 Mahendar0701 changed the title added translations in encounter page and minor fixes in patient registration form Added translations in encounter page and minor fixes in patient registration form Jan 28, 2025
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: 0

🧹 Nitpick comments (2)
src/components/ui/date-field.tsx (1)

Line range hint 45-101: LGTM! Input length restrictions implemented correctly.

The implementation properly limits input lengths for day (2 digits), month (2 digits), and year (4 digits) using slice(). The validation logic and focus management remain intact.

Consider adding leading zeros for single-digit day/month inputs for consistency:

-    const newDay = e.target.value.slice(0, 2);
+    const newDay = e.target.value.slice(0, 2).padStart(2, '0');
src/components/Patient/PatientInfoCard.tsx (1)

118-119: Consider extracting the repeated gender display into a shared component.

The implementation looks good, but the gender display logic is duplicated between mobile and desktop views.

Consider extracting it into a reusable component to follow DRY principles:

+ const GenderDisplay: React.FC<{ gender: string }> = ({ gender }) => {
+   const { t } = useTranslation();
+   return (
+     <>
+       {formatPatientAge(patient, true)} • {t(`GENDER__${gender}`)}
+     </>
+   );
+ };

  // In the render method:
- {formatPatientAge(patient, true)} • {t(`GENDER__${patient.gender}`)}
+ <GenderDisplay gender={patient.gender} />
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0c3342f and bdd0636.

📒 Files selected for processing (4)
  • src/components/Patient/PatientInfoCard.tsx (2 hunks)
  • src/components/Patient/PatientRegistration.tsx (2 hunks)
  • src/components/ui/date-field.tsx (4 hunks)
  • src/components/ui/phone-input.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/components/ui/phone-input.tsx
🧰 Additional context used
📓 Learnings (1)
src/components/Patient/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 (4)
  • GitHub Check: Test
  • GitHub Check: OSSAR-Scan
  • GitHub Check: CodeQL-Build
  • GitHub Check: cypress-run (1)
🔇 Additional comments (4)
src/components/ui/date-field.tsx (1)

104-104: LGTM! Responsive layout improvements.

The flex-wrap and adjusted gap sizes improve the component's responsiveness across different screen sizes.

src/components/Patient/PatientRegistration.tsx (2)

569-577: LGTM! Year of birth calculation implemented correctly.

The implementation aligns with the requirement that either year_of_birth or date_of_birth is needed for registration. The calculation and display are properly implemented.

Consider edge cases around new year transitions. For example, if someone is 25 years old in December 2024, they might have been born in either 1998 or 1999. Consider adding a note about this ambiguity.


718-718: LGTM! Responsive grid layout improvements.

The grid layout changes properly handle different screen sizes, switching from a single column on mobile to two columns on medium and larger screens.

src/components/Patient/PatientInfoCard.tsx (1)

104-105: LGTM! Verify translation keys exist.

The gender localization implementation looks good. However, let's verify that all possible gender values have corresponding translation keys.

✅ Verification successful

Translation keys verified and match gender values ✓

The gender values used in PatientInfoCard (male, female, non_binary, transgender) have corresponding translation keys (GENDER__male, GENDER__female, GENDER__non_binary, GENDER__transgender) in the i18n files. The implementation is correct.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify translation keys for all possible gender values

# Find all gender values used in the codebase
echo "Searching for gender assignments in the codebase..."
rg -g '*.{ts,tsx}' 'gender[^a-zA-Z].*=.*[^a-zA-Z]' --no-filename | sort -u

# Find GENDER__ translation keys in i18n files
echo -e "\nSearching for GENDER__ translation keys..."
rg -g '*.{json,yaml,yml}' '"GENDER__.*"' --no-filename | sort -u

Length of output: 1054


Script:

#!/bin/bash
# Find Patient type/interface definition and PatientInfoCard usage
echo "Searching for Patient type definition..."
ast-grep --pattern 'interface Patient {
  $$$
  gender: $_
  $$$
}'

echo -e "\nChecking gender values in PatientInfoCard..."
rg -A 1 -B 1 'patient\.gender' src/components/Patient/PatientInfoCard.tsx

Length of output: 1727


Script:

#!/bin/bash
# Find GenderChoices type definition
echo "Searching for GenderChoices type definition..."
ast-grep --pattern 'type GenderChoices = $_'

echo -e "\nSearching for enum or const definition related to gender choices..."
ast-grep --pattern 'enum Gender$_ {
  $$$
}'

echo -e "\nSearching for GENDER_TYPES constant..."
rg -A 5 'GENDER_TYPES\s*=' 

Length of output: 980

@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Jan 29, 2025
Copy link

👋 Hi, @Mahendar0701,
Conflicts have been detected against the base branch. Please rebase your branch against the base branch.


This message is automatically generated by prince-chrismc/label-merge-conflicts-action so don't hesitate to report issues/improvements there.

src/components/ui/phone-input.tsx Outdated Show resolved Hide resolved
src/components/ui/date-field.tsx Outdated Show resolved Hide resolved
src/components/ui/date-field.tsx Outdated Show resolved Hide resolved
src/components/ui/date-field.tsx Outdated Show resolved Hide resolved
src/components/ui/date-field.tsx Outdated Show resolved Hide resolved
@rithviknishad rithviknishad added invalid This doesn't seem right changes required and removed merge conflict pull requests with merge conflict labels Jan 29, 2025
@github-actions github-actions bot added the Deploy-Failed Deplyment is not showing preview label Jan 29, 2025
@Mahendar0701
Copy link
Contributor Author

Mahendar0701 commented Jan 29, 2025

@rithviknishad i used .slice() to set limit for input length for fields DD MM YYYY,
Earlier we can enter any number of digits in the fields DD MM YYYY

Another approach would be adding maxLength for input for that we need to change input type to "text"

Anyway the form validation handles incorrect year

Added max for year field

@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Jan 31, 2025
Copy link

👋 Hi, @Mahendar0701,
Conflicts have been detected against the base branch. Please rebase your branch against the base branch.

@github-actions github-actions bot removed the merge conflict pull requests with merge conflict label Feb 1, 2025
@rithviknishad rithviknishad merged commit 9b50dfa into ohcnetwork:develop Feb 2, 2025
15 checks passed
Copy link

github-actions bot commented Feb 2, 2025

@Mahendar0701 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
changes required Deploy-Failed Deplyment is not showing preview invalid This doesn't seem right
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix typo in encounter, and some minor across platform
3 participants