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

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

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

    • Added year of birth calculation in patient registration form
    • Enhanced gender display with internationalization support
  • Improvements

    • Updated responsive layout for nationality and geo-organization fields
    • Improved date field component with more precise input handling
    • Refined date input field with stricter character limit controls

@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 pull request introduces internationalization for patient gender display, enhances the patient registration form with a year of birth calculation feature, and improves the date input field's handling and layout. The changes focus on improving user experience by adding localization, providing more informative input feedback, and creating a more responsive design across different device screen sizes.

Changes

File Change Summary
src/components/Patient/PatientInfoCard.tsx Updated gender display to use translation function for internationalization
src/components/Patient/PatientRegistration.tsx Added year of birth calculation when age is entered, modified layout for nationality and geo-organization fields
src/components/ui/date-field.tsx Adjusted component layout for better responsiveness and enhanced year input validation

Assessment against linked issues

Objective Addressed Explanation
Keep DOB year input to max length 4 No changes were made to limit the input length for the year of birth field.
Make patient registration form responsive
Show Year of Birth when age is typed

Possibly related PRs

Suggested labels

tested, reviewed, needs review

Suggested reviewers

  • rithviknishad
  • Jacobjeevan

Poem

🐰 A rabbit's tale of code so bright,
Translating genders with pure delight,
Age becomes a year so clear,
Responsive design brings users near,
Internationalization takes its flight! 🌍


📜 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 9c2ef6b and 66b52ed.

📒 Files selected for processing (1)
  • src/components/ui/date-field.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/ui/date-field.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: cypress-run (1)
  • GitHub Check: OSSAR-Scan

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 66b52ed
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/6799969db7e7c50008fd864c
😎 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

{form.getValues("age") && (
<div className="text-violet-600 text-sm font-bold">
{t("year_of_birth")}:{" "}
{new Date().getFullYear() -
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can use differenceInYears from date-fns

cc: @Jacobjeevan

@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
const newDay = e.target.value;
const newDay = e.target.value.slice(0, 2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not necessary right? i don't see any cases where it'll have more than 2 characters

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rithviknishad i used this 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 i have to change input type to "text"

const newMonth = e.target.value;
const newMonth = e.target.value.slice(0, 2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too

const newYear = e.target.value;
const newYear = e.target.value.slice(0, 4);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this makes UX bad if they move their caret to left and start typing. numbers will start disappearing and carets start jumping here and there.

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

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