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

diet preference value moved to constants as snake_case #9859

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

Conversation

arhamathar
Copy link
Contributor

@arhamathar arhamathar commented Jan 9, 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

  • New Features

    • Introduced a variety of encounter management constants, enhancing the application's functionality.
    • Improved localization support with dynamic generation of select options for encounter-related fields.
    • Added new localization keys for managing patient information and encounters.
  • Refactor

    • Replaced hardcoded labels and placeholders with translatable strings for better internationalization.

@arhamathar arhamathar requested a review from a team as a code owner January 9, 2025 11:08
Copy link
Contributor

coderabbitai bot commented Jan 9, 2025

Walkthrough

The pull request introduces new constants related to encounter management in the application, including dietary preferences, statuses, classes, priorities, admit sources, and discharge dispositions. Additionally, the EncounterQuestion component has been updated to support internationalization (i18n) by replacing hardcoded text with dynamic translations. This enhances the localization capabilities of the component. Moreover, new keys have been added to the localization JSON file to support these updates.

Changes

File Change Summary
src/common/constants.tsx - Added constants for diet preferences, encounter statuses, classes, priorities, admit sources, and discharge dispositions.
src/components/Questionnaire/QuestionTypes/EncounterQuestion.tsx - Integrated i18n support by replacing hardcoded labels with translated strings and dynamically generating select options using the newly added constants.
public/locale/en.json - Added new localization keys for admit source, diet preference, discharge disposition, encounter class, encounter status, loading messages, priority, and selection prompts.

Assessment against linked issues

Objective Addressed Explanation
Update encounters with diet preferences [#9817]
Handle diet preference conversion to kebab-case [#9817] Conversion logic not visible in the current changes.

Possibly related PRs

Suggested labels

needs review

Suggested reviewers

  • rithviknishad
  • Jacobjeevan

Poem

🥕 In the garden of code, new constants bloom,
For encounters and diets, they make room.
With translations that dance, and options that play,
A rabbit hops forth, in a bright, joyful way!
From static to dynamic, the changes take flight,
Enhancing our app, making everything right! 🌼


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 9, 2025

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit e0fa855
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/67812225ac301300085fb576
😎 Deploy Preview https://deploy-preview-9859--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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0592e63 and 9c6fbd2.

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

Comment on lines 1766 to 1834
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;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

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.

Suggested change
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;

Comment on lines 1766 to 1834
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;
Copy link
Member

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.

Comment on lines 1761 to 1764
/**
* @deprecated use `LocalStorageKeys.patientTokenKey` instead
*/
export const CarePatientTokenKey = LocalStorageKeys.patientTokenKey;
Copy link
Member

Choose a reason for hiding this comment

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

?

@rithviknishad
Copy link
Member

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

Comment on lines 1761 to 1834
export const ENCOUNTER_DIET_PREFERENCE = {
encounter_diet_preference__vegetarian: "vegetarian",
encounter_diet_preference__diary_free: "diary_free",
encounter_diet_preference__nut_free: "nut_free",
encounter_diet_preference__gluten_free: "gluten_free",
encounter_diet_preference__vegan: "vegan",
encounter_diet_preference__halal: "halal",
encounter_diet_preference__kosher: "kosher",
encounter_diet_preference__none: "none",
} as const;

export const ENCOUNTER_STATUS = {
encounter_status__planned: "planned",
encounter_status__in_progress: "in_progress",
encounter_status__on_hold: "on_hold",
encounter_status__discharged: "discharged",
encounter_status__completed: "completed",
encounter_status__cancelled: "cancelled",
encounter_status__discontinued: "discontinued",
encounter_status__entered_in_error: "entered_in_error",
encounter_status__unknown: "unknown",
} as const;

export const ENCOUNTER_CLASS = {
encounter_class__imp: "imp",
encounter_class__amb: "amb",
encounter_class__obsenc: "obsenc",
encounter_class__emer: "emer",
encounter_class__vr: "vr",
encounter_class__hh: "hh",
} as const;

export const ENCOUNTER_PRIORITY = {
encounter_priority__asap: "ASAP",
encounter_priority__callback_results: "callback_results",
encounter_priority__callback_for_scheduling: "callback_for_scheduling",
encounter_priority__elective: "elective",
encounter_priority__emergency: "emergency",
encounter_priority__preop: "preop",
encounter_priority__as_needed: "as_needed",
encounter_priority__routine: "routine",
encounter_priority__rush_reporting: "rush_reporting",
encounter_priority__stat: "stat",
encounter_priority__timing_critical: "timing_critical",
encounter_priority__use_as_directed: "use_as_directed",
encounter_priority__urgent: "urgent",
} as const;

export const ENCOUNTER_ADMIT_SOURCE = {
encounter_admit_sources__hosp_trans: "hosp_trans",
encounter_admit_sources__emd: "emd",
encounter_admit_sources__outp: "outp",
encounter_admit_sources__born: "born",
encounter_admit_sources__gp: "gp",
encounter_admit_sources__mp: "mp",
encounter_admit_sources__nursing: "nursing",
encounter_admit_sources__psych: "psych",
encounter_admit_sources__rehab: "rehab",
encounter_admit_sources__other: "other",
} as const;

export const ENCOUNTER_DISCHARGE_DISPOSITION = {
encounter_discharge_disposition__home: "home",
encounter_discharge_disposition__alt_home: "alt_home",
encounter_discharge_disposition__other_hcf: "other_hcf",
encounter_discharge_disposition__hosp: "hosp",
encounter_discharge_disposition__long: "long",
encounter_discharge_disposition__aadvice: "aadvice",
encounter_discharge_disposition__exp: "exp",
encounter_discharge_disposition__psy: "psy",
encounter_discharge_disposition__rehab: "rehab",
encounter_discharge_disposition__snf: "snf",
encounter_discharge_disposition__oth: "oth",
} as const;
Copy link
Member

Choose a reason for hiding this comment

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

let's just keep an array instead of object

Copy link
Member

@rithviknishad rithviknishad Jan 10, 2025

Choose a reason for hiding this comment

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

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/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

📥 Commits

Reviewing files that changed from the base of the PR and between e3c3e78 and e0fa855.

📒 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 issue

Fix typo and refactor to array format.

  1. Fix the typo in "diary_free" value.
  2. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failed to update encounters on selecting certain diet preference
2 participants