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

Fixes certain users from being unable to view an encounter from organizations patients #10688

Conversation

rithviknishad
Copy link
Member

@rithviknishad rithviknishad commented Feb 19, 2025

Proposed Changes

  • Fixes certain users unable to open encounter page through Organization > Patients > Encounter > View Encounter
  • Update encounter routes to always be sub-route of patient
  • Update related navigates to include patient ID

@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 new localization label for viewing encounters.
    • Enhanced navigation across the application by integrating patient identifiers into encounter-related URLs. This update refines the paths for viewing encounter details, discharge summaries, file tabs, and questionnaires, ensuring a more consistent and context-aware user experience.
  • Bug Fixes
    • Improved routing logic for encounter-related navigation to include patient identifiers, ensuring accurate context in URLs.

@rithviknishad rithviknishad requested a review from a team as a code owner February 19, 2025 09:06
Copy link
Contributor

coderabbitai bot commented Feb 19, 2025

Walkthrough

This pull request introduces a new localization entry for "view_encounter" and updates multiple routes and URL constructions across the application to include a patientId parameter. The changes affect routing declarations, navigation logic, and link components in various modules to ensure that patient context is explicitly carried through encounter-related functionalities.

Changes

Files Change Summary
public/locale/en.json Added new entry "view_encounter": "View Encounter" for localization.
src/Routers/routes/ConsultationRoutes.tsx Updated route definitions to include patientId in several encounter-related routes.
src/components/Encounter/CreateEncounterForm.tsx, src/components/Facility/EncounterCard.tsx, src/components/Files/FilesTab.tsx, src/components/Patient/EncounterQuestionnaire.tsx, src/components/Patient/PatientInfoCard.tsx, src/pages/Encounters/EncounterList.tsx Modified URL and navigation logic in links to incorporate patientId into the encounter-related paths.
src/pages/Encounters/EncounterShow.tsx Updated component props to include patientId and modified URL structure for links.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant NavigationComponent
    participant Router
    participant EncounterShow

    User->>NavigationComponent: Trigger action (e.g., view encounter)
    NavigationComponent->>Router: Construct URL with facilityId, patientId, encounterId, and tab (subPage optional)
    Router->>EncounterShow: Forward request with parameters including patientId
    EncounterShow-->>User: Render encounter details in context
Loading

Possibly related PRs

Suggested reviewers

  • rithviknishad

Poem

I'm a hopping little rabbit in the code,
Traversing routes where patient IDs now bode.
From localization keys to URLs that gleam,
Every path refined like a neat little beam.
With a twitch of my nose and a happy little cheer,
I celebrate these changes—coding magic is here!
🥕🐇 Happy hops to a future crystal clear!


📜 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 fc03998 and 0b1b598.

📒 Files selected for processing (1)
  • src/pages/Encounters/EncounterShow.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/pages/Encounters/EncounterShow.tsx
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Test
  • GitHub Check: cypress-run (1)
  • GitHub Check: Cloudflare Pages: care-fe

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

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 0b1b598
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/67b5d0079a5c120008cecfd9
😎 Deploy Preview https://deploy-preview-10688.preview.ohc.network
📱 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

cloudflare-workers-and-pages bot commented Feb 19, 2025

Deploying care-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0b1b598
Status: ✅  Deploy successful!
Preview URL: https://8306ca9f.care-fe.pages.dev
Branch Preview URL: https://rithviknishad-fix-make-encou.care-fe.pages.dev

View logs

Copy link

cypress bot commented Feb 19, 2025

CARE    Run #4868

Run Properties:  status check passed Passed #4868  •  git commit fc039983c0: Fixes certain users from being unable to view an encounter from organizations pa...
Project CARE
Branch Review rithviknishad/fix/make-encounter-routes-always-subroute-of-patient
Run status status check passed Passed #4868
Run duration 06m 46s
Commit git commit fc039983c0: Fixes certain users from being unable to view an encounter from organizations pa...
Committer Rithvik Nishad
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 11
View all changes introduced in this branch ↗︎

@rithviknishad rithviknishad changed the title Update encounter routes to always be sub-route of patient and update related navigates to include patient ID Fixes certain users from being unable to view encounter from organizations patients Feb 19, 2025
@rithviknishad rithviknishad changed the title Fixes certain users from being unable to view encounter from organizations patients Fixes certain users from being unable to view an encounter from organizations patients Feb 19, 2025
@nihal467
Copy link
Member

nihal467 commented Feb 19, 2025

@rithviknishad
image

  • When we open the update encounter (questionnaire page) via patient encounter dashboard, it's crashing the page with console error

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 (1)
src/Routers/routes/ConsultationRoutes.tsx (1)

9-86: Well-structured routing changes.

The routing changes look comprehensive and consistent. The new structure ensures that patient context is maintained throughout the encounter-related routes, which should fix the reported issue where users couldn't view encounters.

Consider documenting these routing patterns in your team's documentation to maintain consistency in future route additions.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 218e316 and fc03998.

📒 Files selected for processing (2)
  • src/Routers/routes/ConsultationRoutes.tsx (1 hunks)
  • src/pages/Encounters/EncounterShow.tsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/pages/Encounters/EncounterShow.tsx
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Test
  • GitHub Check: OSSAR-Scan
  • GitHub Check: cypress-run (1)
🔇 Additional comments (2)
src/Routers/routes/ConsultationRoutes.tsx (2)

43-65:

✅ Verification successful

Verify patientId handling in EncounterShow component.

The changes look good and align with the PR objectives. To ensure the fix works as intended, let's verify the EncounterShow component's implementation.


🏁 Script executed:

#!/bin/bash
# Check EncounterShow implementation
ast-grep --pattern 'interface $_ {
  $$$
  patientId: $_
  $$$
}'

Length of output: 18915


EncounterShow Component Validated: Patient ID Handling Confirmed

The updated encounter routes correctly pass the patientId prop. Verification of the EncounterShow component (see src/pages/Encounters/EncounterShow.tsx, lines 44–50) confirms that its Props interface properly includes patientId as a string. The changes align perfectly with the PR objectives.

  • The interface in EncounterShow.tsx confirms patientId is required and correctly typed.
  • The updated routes in ConsultationRoutes.tsx pass the patientId to EncounterShow as expected.

39-42:

✅ Verification successful

Verify props passed to QuestionnaireResponseView.

The route provides facilityId and encounterId but these aren't passed to the component. This might be related to the reported crash in the questionnaire page.

Let's check the component's prop requirements:


🏁 Script executed:

#!/bin/bash
# Check QuestionnaireResponseView implementation
ast-grep --pattern 'interface $_ {
  $$$
  responseId: $_
  patientId: $_
  $$$
}'

Length of output: 84


I'll run a new script to search for the definition of QuestionnaireResponseView to check its expected props more directly. This should help confirm whether it actually requires facilityId and encounterId.


🏁 Script executed:

#!/bin/bash
# Search for the function definition of QuestionnaireResponseView and show context lines for better insight into its props
rg --max-columns=200 -A 5 -B 5 "QuestionnaireResponseView" 

Length of output: 2704


Props verification successful: QuestionnaireResponseView receives only the required props.

  • The component is defined to accept only responseId and patientId, which matches the props passed from the route.
  • Although the URL includes additional parameters (facilityId and encounterId), these are intended for routing and not required by the component, so their omission from the props is correct.
  • No changes are necessary for this route. If future requirements call for these additional parameters in the component, the props definition should be updated accordingly.

@nihal467
Copy link
Member

LGTM, questionnaire creation via both org and facility both looks good

@nihal467 nihal467 removed their assignment Feb 19, 2025
Copy link
Contributor

@Jacobjeevan Jacobjeevan left a comment

Choose a reason for hiding this comment

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

LGTM.

@@ -64,6 +65,7 @@ export const EncounterShow = (props: Props) => {
pathParams: { id: encounterId },
queryParams: {
facility: facilityId,
patient: patientId,
Copy link
Contributor

@Jacobjeevan Jacobjeevan Feb 19, 2025

Choose a reason for hiding this comment

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

Adding the note here so we don't forget:

  • we will need to modify BE as adding patientId here bypasses current permissions.
  • currently when patientId is present, it's checking against patient permissions
    • if not, it checks if facilityId is present (and against encounter permissions).

@rithviknishad rithviknishad merged commit 56defe9 into develop Feb 19, 2025
21 of 23 checks passed
@rithviknishad rithviknishad deleted the rithviknishad/fix/make-encounter-routes-always-subroute-of-patient branch February 19, 2025 12:44
Copy link

@rithviknishad 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
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants