-
Notifications
You must be signed in to change notification settings - Fork 517
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
Encounter Qustions dropdown values moved to constants and i18 applied for all strings #9859
base: develop
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request introduces comprehensive internationalization (i18n) support for encounter-related components. The changes span multiple files, including the Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Finishing Touches
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
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/common/constants.tsx
(1 hunks)src/components/Questionnaire/QuestionTypes/EncounterQuestion.tsx
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: cypress-run (1)
🔇 Additional comments (3)
src/components/Questionnaire/QuestionTypes/EncounterQuestion.tsx (2)
14-14
: LGTM! Clean import of diet preferences constant.The import statement is well-placed with other imports from the common directory.
396-400
: LGTM! Clean implementation of dynamic diet preferences.The dynamic mapping of diet preferences from constants improves maintainability and follows React best practices.
src/common/constants.tsx (1)
1761-1764
: LGTM! Well-documented deprecated constant.The deprecated constant is properly documented with JSDoc comment and points to the new location.
src/common/constants.tsx
Outdated
export const DIET_PREFERENCE_OPTIONS = [ | ||
{ label: "Vegetarian", value: "vegetarian" }, | ||
{ label: "Dairy Free", value: "diary_free" }, | ||
{ label: "Nut Free", value: "nut_free" }, | ||
{ label: "Gluten Free", value: "gluten_free" }, | ||
{ label: "Vegan", value: "vegan" }, | ||
{ label: "Halal", value: "halal" }, | ||
{ label: "Kosher", value: "kosher" }, | ||
{ label: "None", value: "none" }, | ||
] as const; |
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.
Fix typo in diet preference value.
There's a typo in the "dairy_free" value (currently spelled as "diary_free").
Apply this diff to fix the typo:
- { label: "Dairy Free", value: "diary_free" },
+ { label: "Dairy Free", value: "dairy_free" },
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
export const DIET_PREFERENCE_OPTIONS = [ | |
{ label: "Vegetarian", value: "vegetarian" }, | |
{ label: "Dairy Free", value: "diary_free" }, | |
{ label: "Nut Free", value: "nut_free" }, | |
{ label: "Gluten Free", value: "gluten_free" }, | |
{ label: "Vegan", value: "vegan" }, | |
{ label: "Halal", value: "halal" }, | |
{ label: "Kosher", value: "kosher" }, | |
{ label: "None", value: "none" }, | |
] as const; | |
export const DIET_PREFERENCE_OPTIONS = [ | |
{ label: "Vegetarian", value: "vegetarian" }, | |
{ label: "Dairy Free", value: "dairy_free" }, | |
{ label: "Nut Free", value: "nut_free" }, | |
{ label: "Gluten Free", value: "gluten_free" }, | |
{ label: "Vegan", value: "vegan" }, | |
{ label: "Halal", value: "halal" }, | |
{ label: "Kosher", value: "kosher" }, | |
{ label: "None", value: "none" }, | |
] as const; |
src/common/constants.tsx
Outdated
export const DIET_PREFERENCE_OPTIONS = [ | ||
{ label: "Vegetarian", value: "vegetarian" }, | ||
{ label: "Dairy Free", value: "diary_free" }, | ||
{ label: "Nut Free", value: "nut_free" }, | ||
{ label: "Gluten Free", value: "gluten_free" }, | ||
{ label: "Vegan", value: "vegan" }, | ||
{ label: "Halal", value: "halal" }, | ||
{ label: "Kosher", value: "kosher" }, | ||
{ label: "None", value: "none" }, | ||
] as const; |
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.
only the value list is needed, the label can be kept in i18n texts. Refer README for translation guidelines.
src/common/constants.tsx
Outdated
/** | ||
* @deprecated use `LocalStorageKeys.patientTokenKey` instead | ||
*/ | ||
export const CarePatientTokenKey = LocalStorageKeys.patientTokenKey; |
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.
?
Do the same for all things present in EncounterQuestion and not just diet preference. Also add i18n translations for all literal strings in the file |
9c6fbd2
to
e3c3e78
Compare
e3c3e78
to
e0fa855
Compare
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
🧹 Nitpick comments (2)
src/common/constants.tsx (2)
1784-1791
: Add JSDoc comments to explain abbreviations.The encounter class values use abbreviations that may not be immediately clear to other developers. Consider adding JSDoc comments to explain what each abbreviation means (e.g., imp = inpatient, amb = ambulatory, etc.).
+/** + * Encounter class types + * imp - Inpatient encounter + * amb - Ambulatory encounter + * obsenc - Observation encounter + * emer - Emergency encounter + * vr - Virtual encounter + * hh - Home health encounter + */ export const ENCOUNTER_CLASS = [ "imp", "amb", "obsenc", "emer", "vr", "hh", ] as const;
1793-1807
: Standardize casing format for priority values.The priority values mix uppercase ("ASAP") with snake_case format. Standardize all values to use snake_case for consistency.
export const ENCOUNTER_PRIORITY = [ - "ASAP", + "asap", "callback_results", "callback_for_scheduling", "elective", "emergency", "preop", "as_needed", "routine", "rush_reporting", "stat", "timing_critical", "use_as_directed", "urgent", ] as const;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
public/locale/en.json
(10 hunks)src/common/constants.tsx
(1 hunks)src/components/Questionnaire/QuestionTypes/EncounterQuestion.tsx
(12 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/components/Questionnaire/QuestionTypes/EncounterQuestion.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: cypress-run (1)
- GitHub Check: OSSAR-Scan
🔇 Additional comments (5)
src/common/constants.tsx (4)
1772-1782
: LGTM! Well-structured encounter status values.The status values follow a logical progression and use consistent snake_case formatting.
1809-1820
: LGTM! Consistent admit source values.The admit source values use consistent snake_case formatting and are well-organized.
1822-1834
: LGTM! Well-structured discharge disposition values.The discharge disposition values use consistent snake_case formatting and are logically organized.
1761-1770
: 🛠️ Refactor suggestion
⚠️ Potential issueFix typo and refactor to array format.
- Fix the typo in "diary_free" value.
- Refactor to use array format for consistency with existing patterns.
-export const ENCOUNTER_DIET_PREFERENCE = [ - "vegetarian", - "diary_free", - "nut_free", - "gluten_free", - "vegan", - "halal", - "kosher", - "none", -] as const; +export const ENCOUNTER_DIET_PREFERENCE = [ + "vegetarian", + "dairy_free", + "nut_free", + "gluten_free", + "vegan", + "halal", + "kosher", + "none" +] as const;Likely invalid or redundant comment.
public/locale/en.json (1)
351-351
: LGTM! Complete and well-organized translations.All encounter-related constants have corresponding translations with proper naming conventions.
Also applies to: 719-719, 725-725, 816-816, 884-884, 1061-1061, 1120-1120, 1179-1179, 1565-1565, 1696-1696, 1698-1698, 1702-1702, 1703-1703, 1718-1718, 1723-1723
Hi @rithviknishad I have moved the values to an array. Can you please check and confirm |
e0fa855
to
58a9b6f
Compare
Do update the PR title btw |
👋 Hi, @arhamathar, This message is automatically generated by prince-chrismc/label-merge-conflicts-action so don't hesitate to report issues/improvements there. |
58a9b6f
to
2bc071d
Compare
👋 Hi, @arhamathar, This message is automatically generated by prince-chrismc/label-merge-conflicts-action so don't hesitate to report issues/improvements there. |
2bc071d
to
6c71732
Compare
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 (2)
src/types/emr/encounter.ts (2)
39-51
: Consider adding descriptions for abbreviated values.The discharge disposition constants use abbreviated values that might not be immediately clear (e.g., "aadvice", "exp", "psy", "snf"). Consider adding comments or using more descriptive values.
53-67
: Maintain consistent casing in priority constants.The priority constant "ASAP" uses uppercase while other values use snake_case. Consider maintaining consistency.
Apply this diff to maintain consistent casing:
- "ASAP", + "asap",
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
public/locale/en.json
(9 hunks)src/components/Questionnaire/QuestionTypes/EncounterQuestion.tsx
(12 hunks)src/types/emr/encounter.ts
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/components/Questionnaire/QuestionTypes/EncounterQuestion.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: cypress-run (1)
🔇 Additional comments (5)
src/types/emr/encounter.ts (4)
6-17
: LGTM! Well-structured admit source constants.The
ENCOUNTER_ADMIT_SOURCE
array is well-organized and uses consistent snake_case naming convention.
19-26
: LGTM! Well-structured class constants.The
ENCOUNTER_CLASS
array follows the established pattern and naming conventions.
69-79
: LGTM! Well-structured status constants.The
ENCOUNTER_STATUS
array follows the established pattern and naming conventions.
81-93
: LGTM! Type-safe type definitions.The type definitions correctly use the constant arrays with
typeof
and array indexing for type safety.public/locale/en.json (1)
362-362
: Verify translations for all encounter constants.The translations for encounter-related strings have been added, but let's verify the coverage:
- Missing translation for encounter class "obsenc" (Observation)
- Missing translation for encounter priority "use_as_directed"
- Missing translation for encounter status "entered_in_error"
Run this script to check for missing translations:
Also applies to: 763-763, 769-769, 932-932, 1126-1126, 1127-1127, 1187-1187, 1250-1250, 1676-1676, 1841-1841, 1844-1844, 1848-1848, 1849-1849, 1873-1873, 1880-1880
export const ENCOUNTER_DIET_PREFERENCE = [ | ||
"vegetarian", | ||
"diary_free", | ||
"nut_free", | ||
"gluten_free", | ||
"vegan", | ||
"halal", | ||
"kosher", | ||
"none", | ||
] as const; |
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.
Fix typo in diet preference constant.
There's a typo in the diet preference value "diary_free" which should be "dairy_free".
Apply this diff to fix the typo:
- "diary_free",
+ "dairy_free",
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
export const ENCOUNTER_DIET_PREFERENCE = [ | |
"vegetarian", | |
"diary_free", | |
"nut_free", | |
"gluten_free", | |
"vegan", | |
"halal", | |
"kosher", | |
"none", | |
] as const; | |
export const ENCOUNTER_DIET_PREFERENCE = [ | |
"vegetarian", | |
"dairy_free", | |
"nut_free", | |
"gluten_free", | |
"vegan", | |
"halal", | |
"kosher", | |
"none", | |
] as const; |
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.
currently backend uses diary_free so it will need to be updated there first.
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.
@Jacobjeevan Understood, thanks for the clarification. I'll withdraw my suggestion since changing it would break compatibility with the backend. Would you like me to create a follow-up issue to track updating both the backend and frontend to use the correct spelling?
✏️ Learnings added
Learnt from: Jacobjeevan
PR: ohcnetwork/care_fe#9859
File: src/types/emr/encounter.ts:28-37
Timestamp: 2025-01-16T12:22:40.009Z
Learning: The backend API for diet preferences uses "diary_free" (instead of "dairy_free") as one of the valid values, so the frontend must maintain the same spelling for compatibility.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
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.
yeah, go ahead
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.
Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!
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.
oh i was talking to you @coderabbitai
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.
@coderabbitai create the issue as suggested above.
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.
@Jacobjeevan I've created issue #10029 to track updating the "diary_free" typo to "dairy_free" in both backend and frontend. You've been assigned to the issue.
🔗 Analysis chain
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
gh issue create \
--title "Fix typo: Update 'diary_free' to 'dairy_free' in diet preferences" \
--body "Currently, both the backend and frontend use 'diary_free' as one of the diet preference values, which is a typo. This should be updated to 'dairy_free'.
Required changes:
1. Update the backend API to use 'dairy_free'
2. Update the frontend constant ENCOUNTER_DIET_PREFERENCE to use 'dairy_free'
Note: Both changes need to be coordinated to maintain compatibility.
References:
- Discussion: https://github.com/ohcnetwork/care_fe/pull/9859#discussion_r1917012367
- PR: https://github.com/ohcnetwork/care_fe/pull/9859" \
--assignee "Jacobjeevan"
Length of output: 730
If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!
Proposed Changes
@ohcnetwork/care-fe-code-reviewers
Merge Checklist
Summary by CodeRabbit
Release Notes
New Features
Improvements
Localization