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: Update the value to Home Health in Create Encounter Form #9806

Conversation

AdityaJ2305
Copy link
Contributor

@AdityaJ2305 AdityaJ2305 commented Jan 7, 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
    • Updated default encounter class to be dynamically sourced from configuration, enhancing flexibility in form initialization.
    • Introduced a new environment variable to specify the default encounter type.
    • Added a new configuration option for default encounter type within the care configuration.
  • Chores
    • Removed a blank line from the end of a file for code cleanliness.
  • Documentation
    • Expanded the set of environment variables available for configuration by adding a new optional property.

@AdityaJ2305 AdityaJ2305 requested a review from a team as a code owner January 7, 2025 04:03
Copy link
Contributor

coderabbitai bot commented Jan 7, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request modifies the CreateEncounterForm component by changing the default value for the encounter_class field from a hardcoded string "amb" (Ambulatory) to a dynamic value sourced from the careConfig.defaultEncounterType. Additionally, a new environment variable REACT_DEFAULT_ENCOUNTER_TYPE is introduced, and the careConfig object is updated to include this property, defaulting to "hh" (Home Health) if the variable is not set.

Changes

File Change Summary
src/components/Encounter/CreateEncounterForm.tsx Modified default encounter_class from "amb" to careConfig.defaultEncounterType
.example.env Added environment variable REACT_DEFAULT_ENCOUNTER_TYPE=
care.config.ts Added property defaultEncounterType to careConfig, retrieving value from REACT_DEFAULT_ENCOUNTER_TYPE
src/vite-env.d.ts Added optional property REACT_DEFAULT_ENCOUNTER_TYPE to ImportMetaEnv interface
src/types/notes/messages.ts Removed a blank line at the end of the file

Assessment against linked issues

Objective Addressed Explanation
Set Default Encounter Type to "Home Health" [#9803]

Possibly related PRs

  • Patient encounter notes #9617: This PR introduces patient encounter notes, which is directly related to the changes in the main PR that modify the default value for the encounter_class field, as both involve enhancements to encounter-related functionalities.
  • Fix: Display Modify date and i18n Localization in Patient Encounter Page #9696: This PR focuses on displaying created and modified dates on the Patient Encounter page, which aligns with the main PR's changes that enhance the encounter configuration, indicating a broader context of improving encounter management features.

Suggested labels

needs review, changes required

Suggested reviewers

  • Jacobjeevan

Poem

🐇 In the form where encounters are made,
"Amb" has now gracefully strayed.
With "hh" as the new guiding light,
Home health takes the lead, shining bright.
A hop in the code, a leap for the care,
Configured with love, for all to share! 🌼


📜 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 91c7df9 and 7ae303a.

📒 Files selected for processing (4)
  • .example.env (1 hunks)
  • care.config.ts (2 hunks)
  • src/types/notes/messages.ts (0 hunks)
  • src/vite-env.d.ts (1 hunks)

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

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 7ae303a
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/677cb151c967520008fe91a1
😎 Deploy Preview https://deploy-preview-9806--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.

@rithviknishad
Copy link
Member

rithviknishad commented Jan 7, 2025

Read the issue fully @AdityaJ2305

I don't see where this is configured via envs

@rithviknishad rithviknishad added the invalid This doesn't seem right label Jan 7, 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: 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 9a839bd and 779986e.

📒 Files selected for processing (1)
  • src/components/Encounter/CreateEncounterForm.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Test
  • GitHub Check: cypress-run (1)
  • GitHub Check: OSSAR-Scan
🔇 Additional comments (2)
src/components/Encounter/CreateEncounterForm.tsx (2)

Line range hint 31-43: Well-integrated change with existing validation and UI.

The default value change is well-supported by:

  1. The zod schema includes "hh" as a valid encounter class
  2. The encounterClasses array properly defines the Home Health option with appropriate metadata

Also applies to: 91-96


Line range hint 98-106: Type-safe implementation with proper prop handling.

The change maintains type safety and proper prop handling:

  1. The encounterClass prop remains optional
  2. The default value is only used when the prop is not provided
  3. Type checking ensures only valid encounter classes can be used

Also applies to: 141-144

src/components/Encounter/CreateEncounterForm.tsx Outdated Show resolved Hide resolved
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)
.example.env (1)

70-72: Add documentation and default value for REACT_DEFAULT_ENCOUNTER_TYPE.

Please enhance the configuration by:

  1. Documenting the valid options (e.g., "hh" for Home Health, "amb" for Ambulatory)
  2. Setting a default value to match the code's fallback
 # Default Encounter type
-REACT_DEFAULT_ENCOUNTER_TYPE=
+# Valid options: "hh" (Home Health), "amb" (Ambulatory)
+REACT_DEFAULT_ENCOUNTER_TYPE=hh
care.config.ts (1)

51-51: Enhance type safety and value validation for defaultEncounterType.

Consider adding type safety and validation:

  1. Define an enum or union type for valid encounter types
  2. Add runtime validation for the environment variable value
+// At the top of the file with other interfaces
+type EncounterType = "hh" | "amb";
+const VALID_ENCOUNTER_TYPES: EncounterType[] = ["hh", "amb"];
+
+const validateEncounterType = (value: string): EncounterType => {
+  if (VALID_ENCOUNTER_TYPES.includes(value as EncounterType)) {
+    return value as EncounterType;
+  }
+  console.warn(`Invalid encounter type: ${value}. Falling back to "hh"`);
+  return "hh";
+};

 // In the careConfig object
-  defaultEncounterType: env.REACT_DEFAULT_ENCOUNTER_TYPE || "hh",
+  defaultEncounterType: validateEncounterType(env.REACT_DEFAULT_ENCOUNTER_TYPE || "hh"),
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 779986e and 91c7df9.

📒 Files selected for processing (3)
  • .example.env (1 hunks)
  • care.config.ts (1 hunks)
  • src/components/Encounter/CreateEncounterForm.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/Encounter/CreateEncounterForm.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: OSSAR-Scan
  • GitHub Check: cypress-run (1)
🔇 Additional comments (1)
care.config.ts (1)

51-51: Verify the changes in the CreateEncounterForm component.

The configuration changes look good, but let's verify they're properly connected to the form component.

✅ Verification successful

Configuration changes are properly integrated ✓

The CreateEncounterForm component correctly uses careConfig.defaultEncounterType as a fallback value for the encounter_class property.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the CreateEncounterForm component uses careConfig.defaultEncounterType

# Search for CreateEncounterForm component and its usage of defaultEncounterType
rg -l "CreateEncounterForm" | xargs rg "defaultEncounterType|encounter_class.*amb"

Length of output: 205

care.config.ts Outdated Show resolved Hide resolved
src/components/Encounter/CreateEncounterForm.tsx Outdated Show resolved Hide resolved
@rithviknishad rithviknishad removed the invalid This doesn't seem right label Jan 7, 2025
.example.env Outdated Show resolved Hide resolved
@rithviknishad rithviknishad merged commit b60e720 into ohcnetwork:develop Jan 7, 2025
4 of 7 checks passed
Copy link

github-actions bot commented Jan 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! 🙌

nihal467 added a commit that referenced this pull request Jan 13, 2025
* added patient home actions plugin hook

* expose core app env in global scope

* enable heatmap and fix appointments column size (#9713)

* Fix: Forgot password error should be handled properly  (#9707)

* forgot password mutation

* updated

* Added no user assingned message (#9666)

Co-authored-by: Rithvik Nishad <[email protected]>

* Remove facility name from facility users page (#9746)

* Enhance organization management by adding new organization types and updating related components. Refactor organization level retrieval to use metadata for improved localization. Remove deprecated organization levels constant and clean up unused code in various components.

* Cancel button fix in Book Appointment screen (#9757)

* Add public flag to facility (#9759)

* Auto-Hide Sidebar on mobile (#9758)

* Implement Permission Context and Update User Permissions Handling

- Introduced a new PermissionContext to manage user permissions and super admin status across the application.
- Updated AppRouter to utilize PermissionProvider for managing permissions.
- Changed UserModel to store permissions as strings instead of objects.
- Refactored OrganizationFacilities and OrganizationPatients components to use updated permission checks and organization identifiers.
- Enhanced OrganizationLayout to conditionally render navigation items based on user permissions.

This commit improves the permission management system and ensures consistent handling of user permissions throughout the application.

* Replaced ButtonV2's with Button in entire codebase (#9736)

* fixes overlapping text (#9767)

* Care Loading icon in organization and facility users (#9723)

* Clean up facility search in index

* Add searchPostFix prop to ValueSetSelect and related components

- Introduced a new `searchPostFix` prop in `ValueSetSelect` to allow appending a suffix to the search query.
- Updated `MedicationRequestQuestion` and `MedicationStatementQuestion` components to utilize the `searchPostFix` prop with a default value of " clinical drug".
- This change enhances search functionality by providing more context in search queries.

* Clean up patient login

* Fix cancel button in update encounter form (#9772)

* disabled image build and deploy for care stagin (#9779)

* Bump @tanstack/react-query-devtools from 5.62.11 to 5.62.15 (#9785)

Bumps [@tanstack/react-query-devtools](https://github.com/TanStack/query/tree/HEAD/packages/react-query-devtools) from 5.62.11 to 5.62.15.
- [Release notes](https://github.com/TanStack/query/releases)
- [Commits](https://github.com/TanStack/query/commits/HEAD/packages/react-query-devtools)

---
updated-dependencies:
- dependency-name: "@tanstack/react-query-devtools"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Patient encounter notes (#9617)

Co-authored-by: Bodhisha Thomas <[email protected]>
Co-authored-by: Bodhish Thomas <[email protected]>

* Fix Auto hide without hook (#9780)

* Enhance encounter data handling by adding encounterId prop across multiple components (#9793)

* Disable encounter create during save (#9795)

* Enhance encounter data handling by adding encounterId prop across multiple components

- Added `encounterId` prop to `ObservationChart`, `ObservationHistoryTable`, `ObservationsList`, `QuestionnaireResponsesList`, and `StructuredResponseView` components to improve data fetching and display related to specific encounters.
- Updated query parameters in API calls to include `encounterId` for better data context.
- Refactored `EncounterPlotsTab` and `EncounterUpdatesTab` to pass the new `encounterId` prop, ensuring consistent data handling across the application.

This change improves the overall functionality and user experience by ensuring that encounter-specific data is accurately retrieved and displayed.

* fix: disable encounter create button during save to prevent multiple submissions #9794

* Refactor PatientHome and EncounterShow components; update FacilityOrganizationSelector labels

- Removed unused state and commented-out code in PatientHome for improved readability.
- Enhanced patient data display by updating the last updated and created by fields to use `updated_by` instead of `modified_by`.
- Updated date formatting functions to ensure consistent display of patient and encounter dates.
- Changed labels in FacilityOrganizationSelector from "Organization" to "Select Department" and adjusted related text for clarity.

These changes streamline the codebase and improve user interface clarity.

* Partial Cleanup Public Router | Public Pages Header

* Rewire enableWhen

* Remove localStorage watch from AuthUserProvider

* Implement immediate redirection after successful login

* Fix: Update the value to Home Health in Create Encounter Form (#9806)

* Update Questionnaire Styling

* Update Questionnaire Styling

* Update Auth Handling

* Cleanup Patient Auth State

* Handle Null created_by

* Types for null patient.created_by

* Bump i18next from 24.2.0 to 24.2.1 (#9818)

Bumps [i18next](https://github.com/i18next/i18next) from 24.2.0 to 24.2.1.
- [Release notes](https://github.com/i18next/i18next/releases)
- [Changelog](https://github.com/i18next/i18next/blob/master/CHANGELOG.md)
- [Commits](i18next/i18next@v24.2.0...v24.2.1)

---
updated-dependencies:
- dependency-name: i18next
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump input-otp from 1.4.1 to 1.4.2 (#9819)

Bumps [input-otp](https://github.com/guilhermerodz/input-otp/tree/HEAD/packages/input-otp) from 1.4.1 to 1.4.2.
- [Changelog](https://github.com/guilhermerodz/input-otp/blob/master/CHANGELOG.md)
- [Commits](https://github.com/guilhermerodz/input-otp/commits/HEAD/packages/input-otp)

---
updated-dependencies:
- dependency-name: input-otp
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Rename dosage field to frequency in ongoing medication form (#9811)

* feat: Add new fields to Question interface (#9824)

* Cleanup Labels in Questionnaire

* Allergy intolerance Cleanup (#9812)

* cleanup CarePatientTokenKey (#9827)

* changed the facility name (#9829)

* Cleanup localStorage Management in Patient Login; Fix Time in Confirmation

* Use PatientContext from Router when required

* Cleanup Navbars

* AllergyList: Add i18n; map key

* Add Actions in Encounter

* Remove Shortcut for Nursing Care

* Update Crowdin configuration file

* Update Crowdin configuration file

* Fix: Replace InputWithError and InputErrors components with ShadCN’s components directly. (#9847)

* fixed eslint errors caused while creating plugin map

* refactored the patient registration form using react hook form

* added patient registration form plugin hook

* updated validations

* added patient info card actions plugin hook

* set same_phone_number to true by default in patient registration

* set same_address to true and same_phone_number to false by default in patient registration

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Mohammed Nihal <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Allow Instances to Set Default Encounter Type as "Home Health" via Care Environment
2 participants